diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index e4ade35705..e0c57eab46 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -135,6 +135,7 @@ jobs: - {RTT_BSP: "raspberry-pico", RTT_TOOL_CHAIN: "sourcery-arm"} - {RTT_BSP: "raspberry-pi/raspi4-32", RTT_TOOL_CHAIN: "sourcery-arm"} - {RTT_BSP: "hc32l196", RTT_TOOL_CHAIN: "sourcery-arm"} + - {RTT_BSP: "tae32f5300", RTT_TOOL_CHAIN: "sourcery-arm"} steps: - uses: actions/checkout@v2 - name: Set up Python diff --git a/bsp/Copyright_Notice.md b/bsp/Copyright_Notice.md index 3af24397a7..9fe8282b7e 100644 --- a/bsp/Copyright_Notice.md +++ b/bsp/Copyright_Notice.md @@ -719,6 +719,16 @@ Path: - bsp/swm320/libraries/CMSIS - bsp/swm320-lq100/Libraries/CMSIS/CoreSupport +### tae32f5300 + +License: BSD 3-Clause + +Copyright (c) 2020 Tai-Action. + +Path: + +- bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver + ### tm4c License: unknown-license-reference(bsd-new) @@ -769,4 +779,3 @@ Copyright: Copyright (c) 2014 - 2020 Xilinx, Inc. Path: - bsp/zynqmp-r5-axu4ev/drivers/Zynq_HAL_Driver - diff --git a/bsp/tae32f5300/.config b/bsp/tae32f5300/.config new file mode 100644 index 0000000000..a17560a9e1 --- /dev/null +++ b/bsp/tae32f5300/.config @@ -0,0 +1,601 @@ +# +# Automatically generated file; DO NOT EDIT. +# RT-Thread Project Configuration +# + +# +# RT-Thread Kernel +# +CONFIG_RT_NAME_MAX=8 +# CONFIG_RT_USING_ARCH_DATA_TYPE is not set +# CONFIG_RT_USING_SMP is not set +CONFIG_RT_ALIGN_SIZE=4 +# CONFIG_RT_THREAD_PRIORITY_8 is not set +CONFIG_RT_THREAD_PRIORITY_32=y +# CONFIG_RT_THREAD_PRIORITY_256 is not set +CONFIG_RT_THREAD_PRIORITY_MAX=32 +CONFIG_RT_TICK_PER_SECOND=100 +CONFIG_RT_USING_OVERFLOW_CHECK=y +CONFIG_RT_USING_HOOK=y +CONFIG_RT_USING_IDLE_HOOK=y +CONFIG_RT_IDLE_HOOK_LIST_SIZE=4 +CONFIG_IDLE_THREAD_STACK_SIZE=256 +CONFIG_RT_USING_TIMER_SOFT=y +CONFIG_RT_TIMER_THREAD_PRIO=4 +CONFIG_RT_TIMER_THREAD_STACK_SIZE=512 + +# +# kservice optimization +# +# CONFIG_RT_KSERVICE_USING_STDLIB is not set +# CONFIG_RT_KSERVICE_USING_TINY_SIZE is not set +# CONFIG_RT_USING_ASM_MEMCPY is not set +CONFIG_RT_DEBUG=y +# CONFIG_RT_DEBUG_COLOR is not set +# CONFIG_RT_DEBUG_INIT_CONFIG is not set +# CONFIG_RT_DEBUG_THREAD_CONFIG is not set +# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set +# CONFIG_RT_DEBUG_IPC_CONFIG is not set +# CONFIG_RT_DEBUG_TIMER_CONFIG is not set +# CONFIG_RT_DEBUG_IRQ_CONFIG is not set +# CONFIG_RT_DEBUG_MEM_CONFIG is not set +# CONFIG_RT_DEBUG_SLAB_CONFIG is not set +# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set +# CONFIG_RT_DEBUG_MODULE_CONFIG is not set + +# +# Inter-Thread communication +# +CONFIG_RT_USING_SEMAPHORE=y +CONFIG_RT_USING_MUTEX=y +CONFIG_RT_USING_EVENT=y +CONFIG_RT_USING_MAILBOX=y +CONFIG_RT_USING_MESSAGEQUEUE=y +# CONFIG_RT_USING_SIGNALS is not set + +# +# Memory Management +# +CONFIG_RT_USING_MEMPOOL=y +# CONFIG_RT_USING_MEMHEAP is not set +# CONFIG_RT_USING_NOHEAP is not set +CONFIG_RT_USING_SMALL_MEM=y +# CONFIG_RT_USING_SLAB is not set +# CONFIG_RT_USING_USERHEAP is not set +# CONFIG_RT_USING_MEMTRACE is not set +CONFIG_RT_USING_HEAP=y + +# +# Kernel Device Object +# +CONFIG_RT_USING_DEVICE=y +# CONFIG_RT_USING_DEVICE_OPS is not set +# CONFIG_RT_USING_INTERRUPT_INFO is not set +CONFIG_RT_USING_CONSOLE=y +CONFIG_RT_CONSOLEBUF_SIZE=128 +CONFIG_RT_CONSOLE_DEVICE_NAME="uart0" +# CONFIG_RT_PRINTF_LONGLONG is not set +CONFIG_RT_VER_NUM=0x40004 +CONFIG_ARCH_ARM=y +CONFIG_RT_USING_CPU_FFS=y +CONFIG_ARCH_ARM_CORTEX_M=y +CONFIG_ARCH_ARM_CORTEX_M3=y +# CONFIG_ARCH_CPU_STACK_GROWS_UPWARD is not set + +# +# RT-Thread Components +# +CONFIG_RT_USING_COMPONENTS_INIT=y +CONFIG_RT_USING_USER_MAIN=y +CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048 +CONFIG_RT_MAIN_THREAD_PRIORITY=10 + +# +# C++ features +# +# CONFIG_RT_USING_CPLUSPLUS is not set + +# +# Command shell +# +CONFIG_RT_USING_FINSH=y +CONFIG_RT_USING_MSH=y +CONFIG_FINSH_THREAD_NAME="tshell" +CONFIG_FINSH_THREAD_PRIORITY=20 +CONFIG_FINSH_THREAD_STACK_SIZE=2048 +CONFIG_FINSH_USING_HISTORY=y +CONFIG_FINSH_HISTORY_LINES=5 +CONFIG_FINSH_USING_SYMTAB=y +CONFIG_FINSH_CMD_SIZE=80 +CONFIG_MSH_USING_BUILT_IN_COMMANDS=y +CONFIG_FINSH_USING_DESCRIPTION=y +# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set +# CONFIG_FINSH_USING_AUTH is not set +CONFIG_FINSH_ARG_MAX=10 + +# +# Device virtual file system +# +# CONFIG_RT_USING_DFS is not set + +# +# Device Drivers +# +CONFIG_RT_USING_DEVICE_IPC=y +CONFIG_RT_PIPE_BUFSZ=512 +# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set +CONFIG_RT_USING_SERIAL=y +CONFIG_RT_USING_SERIAL_V1=y +# CONFIG_RT_USING_SERIAL_V2 is not set +# CONFIG_RT_SERIAL_USING_DMA is not set +CONFIG_RT_SERIAL_RB_BUFSZ=64 +# CONFIG_RT_USING_CAN is not set +# CONFIG_RT_USING_HWTIMER is not set +# CONFIG_RT_USING_CPUTIME is not set +CONFIG_RT_USING_I2C=y +# CONFIG_RT_I2C_DEBUG is not set +CONFIG_RT_USING_I2C_BITOPS=y +# CONFIG_RT_I2C_BITOPS_DEBUG is not set +# CONFIG_RT_USING_PHY is not set +CONFIG_RT_USING_PIN=y +# CONFIG_RT_USING_ADC is not set +# CONFIG_RT_USING_DAC is not set +# CONFIG_RT_USING_PWM is not set +# CONFIG_RT_USING_MTD_NOR is not set +# CONFIG_RT_USING_MTD_NAND is not set +# CONFIG_RT_USING_PM is not set +# CONFIG_RT_USING_RTC is not set +# CONFIG_RT_USING_SDIO is not set +# CONFIG_RT_USING_SPI is not set +# CONFIG_RT_USING_WDT is not set +# CONFIG_RT_USING_AUDIO is not set +# CONFIG_RT_USING_SENSOR is not set +# CONFIG_RT_USING_TOUCH is not set +# CONFIG_RT_USING_HWCRYPTO is not set +# CONFIG_RT_USING_PULSE_ENCODER is not set +# CONFIG_RT_USING_INPUT_CAPTURE is not set +# CONFIG_RT_USING_WIFI is not set + +# +# Using USB +# +# CONFIG_RT_USING_USB_HOST is not set +# CONFIG_RT_USING_USB_DEVICE is not set + +# +# POSIX layer and C standard library +# +CONFIG_RT_USING_LIBC=y +# CONFIG_RT_USING_PTHREADS is not set +# CONFIG_RT_USING_MODULE is not set +CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8 + +# +# Network +# + +# +# Socket abstraction layer +# +# CONFIG_RT_USING_SAL is not set + +# +# Network interface device +# +# CONFIG_RT_USING_NETDEV is not set + +# +# light weight TCP/IP stack +# +# CONFIG_RT_USING_LWIP is not set + +# +# AT commands +# +# CONFIG_RT_USING_AT is not set + +# +# VBUS(Virtual Software BUS) +# +# CONFIG_RT_USING_VBUS is not set + +# +# Utilities +# +# CONFIG_RT_USING_RYM is not set +# CONFIG_RT_USING_ULOG is not set +# CONFIG_RT_USING_UTEST is not set +# CONFIG_RT_USING_RT_LINK is not set +# CONFIG_RT_USING_LWP is not set + +# +# RT-Thread Utestcases +# +# CONFIG_RT_USING_UTESTCASES is not set + +# +# RT-Thread online packages +# + +# +# IoT - internet of things +# +# CONFIG_PKG_USING_LORAWAN_DRIVER is not set +# CONFIG_PKG_USING_PAHOMQTT is not set +# CONFIG_PKG_USING_UMQTT is not set +# CONFIG_PKG_USING_WEBCLIENT is not set +# CONFIG_PKG_USING_WEBNET is not set +# CONFIG_PKG_USING_MONGOOSE is not set +# CONFIG_PKG_USING_MYMQTT is not set +# CONFIG_PKG_USING_KAWAII_MQTT is not set +# CONFIG_PKG_USING_BC28_MQTT is not set +# CONFIG_PKG_USING_WEBTERMINAL is not set +# CONFIG_PKG_USING_CJSON is not set +# CONFIG_PKG_USING_JSMN is not set +# CONFIG_PKG_USING_LIBMODBUS is not set +# CONFIG_PKG_USING_FREEMODBUS is not set +# CONFIG_PKG_USING_LJSON is not set +# CONFIG_PKG_USING_EZXML is not set +# CONFIG_PKG_USING_NANOPB is not set + +# +# Wi-Fi +# + +# +# Marvell WiFi +# +# CONFIG_PKG_USING_WLANMARVELL is not set + +# +# Wiced WiFi +# +# CONFIG_PKG_USING_WLAN_WICED is not set +# CONFIG_PKG_USING_RW007 is not set +# CONFIG_PKG_USING_COAP is not set +# CONFIG_PKG_USING_NOPOLL is not set +# CONFIG_PKG_USING_NETUTILS is not set +# CONFIG_PKG_USING_CMUX is not set +# CONFIG_PKG_USING_PPP_DEVICE is not set +# CONFIG_PKG_USING_AT_DEVICE is not set +# CONFIG_PKG_USING_ATSRV_SOCKET is not set +# CONFIG_PKG_USING_WIZNET is not set +# CONFIG_PKG_USING_ZB_COORDINATOR is not set + +# +# IoT Cloud +# +# CONFIG_PKG_USING_ONENET is not set +# CONFIG_PKG_USING_GAGENT_CLOUD is not set +# CONFIG_PKG_USING_ALI_IOTKIT is not set +# CONFIG_PKG_USING_AZURE is not set +# CONFIG_PKG_USING_TENCENT_IOT_EXPLORER is not set +# CONFIG_PKG_USING_JIOT-C-SDK is not set +# CONFIG_PKG_USING_UCLOUD_IOT_SDK is not set +# CONFIG_PKG_USING_JOYLINK is not set +# CONFIG_PKG_USING_NIMBLE is not set +# CONFIG_PKG_USING_OTA_DOWNLOADER is not set +# CONFIG_PKG_USING_IPMSG is not set +# CONFIG_PKG_USING_LSSDP is not set +# CONFIG_PKG_USING_AIRKISS_OPEN is not set +# CONFIG_PKG_USING_LIBRWS is not set +# CONFIG_PKG_USING_TCPSERVER is not set +# CONFIG_PKG_USING_PROTOBUF_C is not set +# CONFIG_PKG_USING_DLT645 is not set +# CONFIG_PKG_USING_QXWZ is not set +# CONFIG_PKG_USING_SMTP_CLIENT is not set +# CONFIG_PKG_USING_ABUP_FOTA is not set +# CONFIG_PKG_USING_LIBCURL2RTT is not set +# CONFIG_PKG_USING_CAPNP is not set +# CONFIG_PKG_USING_RT_CJSON_TOOLS is not set +# CONFIG_PKG_USING_AGILE_TELNET is not set +# CONFIG_PKG_USING_NMEALIB is not set +# CONFIG_PKG_USING_AGILE_JSMN is not set +# CONFIG_PKG_USING_PDULIB is not set +# CONFIG_PKG_USING_BTSTACK is not set +# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set +# CONFIG_PKG_USING_WAYZ_IOTKIT is not set +# CONFIG_PKG_USING_MAVLINK is not set +# CONFIG_PKG_USING_RAPIDJSON is not set +# CONFIG_PKG_USING_BSAL is not set +# CONFIG_PKG_USING_AGILE_MODBUS is not set +# CONFIG_PKG_USING_AGILE_FTP is not set +# CONFIG_PKG_USING_EMBEDDEDPROTO is not set +# CONFIG_PKG_USING_RT_LINK_HW is not set + +# +# security packages +# +# CONFIG_PKG_USING_MBEDTLS is not set +# CONFIG_PKG_USING_libsodium is not set +# CONFIG_PKG_USING_TINYCRYPT is not set +# CONFIG_PKG_USING_TFM is not set +# CONFIG_PKG_USING_YD_CRYPTO is not set + +# +# language packages +# +# CONFIG_PKG_USING_LUA is not set +# CONFIG_PKG_USING_JERRYSCRIPT is not set +# CONFIG_PKG_USING_MICROPYTHON is not set +# CONFIG_PKG_USING_PIKASCRIPT is not set + +# +# multimedia packages +# +# CONFIG_PKG_USING_OPENMV is not set +# CONFIG_PKG_USING_MUPDF is not set +# CONFIG_PKG_USING_STEMWIN is not set +# CONFIG_PKG_USING_WAVPLAYER is not set +# CONFIG_PKG_USING_TJPGD is not set +# CONFIG_PKG_USING_PDFGEN is not set +# CONFIG_PKG_USING_HELIX is not set +# CONFIG_PKG_USING_AZUREGUIX is not set +# CONFIG_PKG_USING_TOUCHGFX2RTT is not set +# CONFIG_PKG_USING_NUEMWIN is not set +# CONFIG_PKG_USING_MP3PLAYER is not set +# CONFIG_PKG_USING_TINYJPEG is not set + +# +# tools packages +# +# CONFIG_PKG_USING_CMBACKTRACE is not set +# CONFIG_PKG_USING_EASYFLASH is not set +# CONFIG_PKG_USING_EASYLOGGER is not set +# CONFIG_PKG_USING_SYSTEMVIEW is not set +# CONFIG_PKG_USING_SEGGER_RTT is not set +# CONFIG_PKG_USING_RDB is not set +# CONFIG_PKG_USING_QRCODE is not set +# CONFIG_PKG_USING_ULOG_EASYFLASH is not set +# CONFIG_PKG_USING_ULOG_FILE is not set +# CONFIG_PKG_USING_LOGMGR is not set +# CONFIG_PKG_USING_ADBD is not set +# CONFIG_PKG_USING_COREMARK is not set +# CONFIG_PKG_USING_DHRYSTONE is not set +# CONFIG_PKG_USING_MEMORYPERF is not set +# CONFIG_PKG_USING_NR_MICRO_SHELL is not set +# CONFIG_PKG_USING_CHINESE_FONT_LIBRARY is not set +# CONFIG_PKG_USING_LUNAR_CALENDAR is not set +# CONFIG_PKG_USING_BS8116A is not set +# CONFIG_PKG_USING_GPS_RMC is not set +# CONFIG_PKG_USING_URLENCODE is not set +# CONFIG_PKG_USING_UMCN is not set +# CONFIG_PKG_USING_LWRB2RTT is not set +# CONFIG_PKG_USING_CPU_USAGE is not set +# CONFIG_PKG_USING_GBK2UTF8 is not set +# CONFIG_PKG_USING_VCONSOLE is not set +# CONFIG_PKG_USING_KDB is not set +# CONFIG_PKG_USING_WAMR is not set +# CONFIG_PKG_USING_MICRO_XRCE_DDS_CLIENT is not set +# CONFIG_PKG_USING_LWLOG is not set +# CONFIG_PKG_USING_ANV_TRACE is not set +# CONFIG_PKG_USING_ANV_MEMLEAK is not set +# CONFIG_PKG_USING_ANV_TESTSUIT is not set +# CONFIG_PKG_USING_ANV_BENCH is not set +# CONFIG_PKG_USING_DEVMEM is not set +# CONFIG_PKG_USING_REGEX is not set +# CONFIG_PKG_USING_MEM_SANDBOX is not set +# CONFIG_PKG_USING_SOLAR_TERMS is not set +# CONFIG_PKG_USING_GAN_ZHI is not set + +# +# system packages +# + +# +# acceleration: Assembly language or algorithmic acceleration packages +# +# CONFIG_PKG_USING_RT_MEMCPY_CM is not set +# CONFIG_PKG_USING_QFPLIB_M0_FULL is not set +# CONFIG_PKG_USING_QFPLIB_M0_TINY is not set +# CONFIG_PKG_USING_QFPLIB_M3 is not set + +# +# Micrium: Micrium software products porting for RT-Thread +# +# CONFIG_PKG_USING_UCOSIII_WRAPPER is not set +# CONFIG_PKG_USING_UCOSII_WRAPPER is not set +# CONFIG_PKG_USING_UC_CRC is not set +# CONFIG_PKG_USING_UC_CLK is not set +# CONFIG_PKG_USING_UC_COMMON is not set +# CONFIG_PKG_USING_UC_MODBUS is not set +# CONFIG_PKG_USING_GUIENGINE is not set +# CONFIG_PKG_USING_CAIRO is not set +# CONFIG_PKG_USING_PIXMAN is not set +# CONFIG_PKG_USING_PARTITION is not set +# CONFIG_PKG_USING_FAL is not set +# CONFIG_PKG_USING_FLASHDB is not set +# CONFIG_PKG_USING_SQLITE is not set +# CONFIG_PKG_USING_RTI is not set +# CONFIG_PKG_USING_LITTLEVGL2RTT is not set +# CONFIG_PKG_USING_CMSIS is not set +# CONFIG_PKG_USING_DFS_YAFFS is not set +# CONFIG_PKG_USING_LITTLEFS is not set +# CONFIG_PKG_USING_DFS_JFFS2 is not set +# CONFIG_PKG_USING_DFS_UFFS is not set +# CONFIG_PKG_USING_LWEXT4 is not set +# CONFIG_PKG_USING_THREAD_POOL is not set +# CONFIG_PKG_USING_ROBOTS is not set +# CONFIG_PKG_USING_EV is not set +# CONFIG_PKG_USING_SYSWATCH is not set +# CONFIG_PKG_USING_SYS_LOAD_MONITOR is not set +# CONFIG_PKG_USING_PLCCORE is not set +# CONFIG_PKG_USING_RAMDISK is not set +# CONFIG_PKG_USING_MININI is not set +# CONFIG_PKG_USING_QBOOT is not set +# CONFIG_PKG_USING_PPOOL is not set +# CONFIG_PKG_USING_OPENAMP is not set +# CONFIG_PKG_USING_RT_KPRINTF_THREADSAFE is not set +# CONFIG_PKG_USING_LPM is not set +# CONFIG_PKG_USING_TLSF is not set +# CONFIG_PKG_USING_EVENT_RECORDER is not set +# CONFIG_PKG_USING_ARM_2D is not set +# CONFIG_PKG_USING_WCWIDTH is not set + +# +# peripheral libraries and drivers +# +# CONFIG_PKG_USING_SENSORS_DRIVERS is not set +# CONFIG_PKG_USING_REALTEK_AMEBA is not set +# CONFIG_PKG_USING_SHT2X is not set +# CONFIG_PKG_USING_SHT3X is not set +# CONFIG_PKG_USING_AS7341 is not set +# CONFIG_PKG_USING_STM32_SDIO is not set +# CONFIG_PKG_USING_ICM20608 is not set +# CONFIG_PKG_USING_U8G2 is not set +# CONFIG_PKG_USING_BUTTON is not set +# CONFIG_PKG_USING_PCF8574 is not set +# CONFIG_PKG_USING_SX12XX is not set +# CONFIG_PKG_USING_SIGNAL_LED is not set +# CONFIG_PKG_USING_LEDBLINK is not set +# CONFIG_PKG_USING_LITTLED is not set +# CONFIG_PKG_USING_LKDGUI is not set +# CONFIG_PKG_USING_NRF5X_SDK is not set +# CONFIG_PKG_USING_NRFX is not set +# CONFIG_PKG_USING_WM_LIBRARIES is not set +# CONFIG_PKG_USING_KENDRYTE_SDK is not set +# CONFIG_PKG_USING_INFRARED is not set +# CONFIG_PKG_USING_AGILE_BUTTON is not set +# CONFIG_PKG_USING_AGILE_LED is not set +# CONFIG_PKG_USING_AT24CXX is not set +# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set +# CONFIG_PKG_USING_AD7746 is not set +# CONFIG_PKG_USING_PCA9685 is not set +# CONFIG_PKG_USING_I2C_TOOLS is not set +# CONFIG_PKG_USING_NRF24L01 is not set +# CONFIG_PKG_USING_TOUCH_DRIVERS is not set +# CONFIG_PKG_USING_MAX17048 is not set +# CONFIG_PKG_USING_RPLIDAR is not set +# CONFIG_PKG_USING_AS608 is not set +# CONFIG_PKG_USING_RC522 is not set +# CONFIG_PKG_USING_WS2812B is not set +# CONFIG_PKG_USING_EMBARC_BSP is not set +# CONFIG_PKG_USING_EXTERN_RTC_DRIVERS is not set +# CONFIG_PKG_USING_MULTI_RTIMER is not set +# CONFIG_PKG_USING_MAX7219 is not set +# CONFIG_PKG_USING_BEEP is not set +# CONFIG_PKG_USING_EASYBLINK is not set +# CONFIG_PKG_USING_PMS_SERIES is not set +# CONFIG_PKG_USING_CAN_YMODEM is not set +# CONFIG_PKG_USING_LORA_RADIO_DRIVER is not set +# CONFIG_PKG_USING_QLED is not set +# CONFIG_PKG_USING_PAJ7620 is not set +# CONFIG_PKG_USING_AGILE_CONSOLE is not set +# CONFIG_PKG_USING_LD3320 is not set +# CONFIG_PKG_USING_WK2124 is not set +# CONFIG_PKG_USING_LY68L6400 is not set +# CONFIG_PKG_USING_DM9051 is not set +# CONFIG_PKG_USING_SSD1306 is not set +# CONFIG_PKG_USING_QKEY is not set +# CONFIG_PKG_USING_RS485 is not set +# CONFIG_PKG_USING_NES is not set +# CONFIG_PKG_USING_VIRTUAL_SENSOR is not set +# CONFIG_PKG_USING_VDEVICE is not set +# CONFIG_PKG_USING_SGM706 is not set +# CONFIG_PKG_USING_STM32WB55_SDK is not set +# CONFIG_PKG_USING_RDA58XX is not set +# CONFIG_PKG_USING_LIBNFC is not set +# CONFIG_PKG_USING_MFOC is not set +# CONFIG_PKG_USING_TMC51XX is not set +# CONFIG_PKG_USING_TCA9534 is not set +# CONFIG_PKG_USING_KOBUKI is not set +# CONFIG_PKG_USING_ROSSERIAL is not set +# CONFIG_PKG_USING_MICRO_ROS is not set +# CONFIG_PKG_USING_MCP23008 is not set +# CONFIG_PKG_USING_BLUETRUM_SDK is not set + +# +# AI packages +# +# CONFIG_PKG_USING_LIBANN is not set +# CONFIG_PKG_USING_NNOM is not set +# CONFIG_PKG_USING_ONNX_BACKEND is not set +# CONFIG_PKG_USING_ONNX_PARSER is not set +# CONFIG_PKG_USING_TENSORFLOWLITEMICRO is not set +# CONFIG_PKG_USING_ELAPACK is not set +# CONFIG_PKG_USING_ULAPACK is not set +# CONFIG_PKG_USING_QUEST is not set +# CONFIG_PKG_USING_NAXOS is not set + +# +# miscellaneous packages +# + +# +# samples: kernel and components samples +# +# CONFIG_PKG_USING_KERNEL_SAMPLES is not set +# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set +# CONFIG_PKG_USING_NETWORK_SAMPLES is not set +# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set + +# +# entertainment: terminal games and other interesting software packages +# +# CONFIG_PKG_USING_CMATRIX is not set +# CONFIG_PKG_USING_SL is not set +# CONFIG_PKG_USING_CAL is not set +# CONFIG_PKG_USING_ACLOCK is not set +# CONFIG_PKG_USING_THREES is not set +# CONFIG_PKG_USING_2048 is not set +# CONFIG_PKG_USING_SNAKE is not set +# CONFIG_PKG_USING_TETRIS is not set +# CONFIG_PKG_USING_DONUT is not set +# CONFIG_PKG_USING_LIBCSV is not set +# CONFIG_PKG_USING_OPTPARSE is not set +# CONFIG_PKG_USING_FASTLZ is not set +# CONFIG_PKG_USING_MINILZO is not set +# CONFIG_PKG_USING_QUICKLZ is not set +# CONFIG_PKG_USING_LZMA is not set +# CONFIG_PKG_USING_MULTIBUTTON is not set +# CONFIG_PKG_USING_FLEXIBLE_BUTTON is not set +# CONFIG_PKG_USING_CANFESTIVAL is not set +# CONFIG_PKG_USING_ZLIB is not set +# CONFIG_PKG_USING_MINIZIP is not set +# CONFIG_PKG_USING_DSTR is not set +# CONFIG_PKG_USING_TINYFRAME is not set +# CONFIG_PKG_USING_KENDRYTE_DEMO is not set +# CONFIG_PKG_USING_DIGITALCTRL is not set +# CONFIG_PKG_USING_UPACKER is not set +# CONFIG_PKG_USING_UPARAM is not set +# CONFIG_PKG_USING_HELLO is not set +# CONFIG_PKG_USING_VI is not set +# CONFIG_PKG_USING_KI is not set +# CONFIG_PKG_USING_ARMv7M_DWT is not set +# CONFIG_PKG_USING_VT100 is not set +# CONFIG_PKG_USING_UKAL is not set +# CONFIG_PKG_USING_CRCLIB is not set +# CONFIG_PKG_USING_LWGPS is not set +# CONFIG_PKG_USING_STATE_MACHINE is not set +# CONFIG_PKG_USING_MCURSES is not set +# CONFIG_PKG_USING_COWSAY is not set +# CONFIG_PKG_USING_TERMBOX is not set + +# +# Hardware Drivers Config +# +CONFIG_MCU_TAE32F53xx=y + +# +# Onboard Peripheral Drivers +# + +# +# On-chip Peripheral Drivers +# +CONFIG_BSP_USING_GPIO=y +CONFIG_BSP_USING_UART=y +CONFIG_BSP_USING_UART0=y +# CONFIG_BSP_USING_UART1 is not set +CONFIG_BSP_USING_I2C1=y +CONFIG_BSP_I2C1_SCL_PIN=51 +CONFIG_BSP_I2C1_SDA_PIN=90 +# CONFIG_BSP_USING_SPI is not set +# CONFIG_BSP_USING_RTC is not set +# CONFIG_BSP_USING_PWM is not set +# CONFIG_BSP_USING_TIMER is not set +# CONFIG_BSP_USING_PULSE_ENCODER is not set + +# +# Board extended module Drivers +# diff --git a/bsp/tae32f5300/.ignore_format.yml b/bsp/tae32f5300/.ignore_format.yml new file mode 100644 index 0000000000..9aaf541688 --- /dev/null +++ b/bsp/tae32f5300/.ignore_format.yml @@ -0,0 +1,6 @@ +# files format check exclude path, please follow the instructions below to modify; +# If you need to exclude an entire folder, add the folder path in dir_path; +# If you need to exclude a file, add the path to the file in file_path. + +dir_path: +- Libraries diff --git a/bsp/tae32f5300/AfterBuildHandler.bat b/bsp/tae32f5300/AfterBuildHandler.bat new file mode 100644 index 0000000000..30cc4ba53c --- /dev/null +++ b/bsp/tae32f5300/AfterBuildHandler.bat @@ -0,0 +1,70 @@ +md build\keil\Execute + +@echo off +:: enter .bat folder +cd %~dp0 +:: 批处理所在路径 +set bat_path=%0 +:: MDK $J 这里传入的是KEIL 编译器头文件路径,利用这个路径找到编译器相关工具链地址 +set tool_chain_inc=%1 +:: MDK #L 这里传入的是KEIL生成的axf文件的完整路径 +set axf_full_path=%2 +:: 获取axf文件的名字,不含后缀 +set axf_name=%~n2 + +if %tool_chain_inc:~-1,1% == \ ( + :: 删除路径最后的\ + set tool_chain_inc=%tool_chain_inc:~,-1% +) + +:: call .bin generate function +call :binGenerate %tool_chain_inc% %axf_full_path% +if %errorlevel% == 1 ( + echo Failed 1: fromelf generate .bin failed! + goto :EOF +) + +:: call 文件复制 +call :doFileCopy %axf_full_path% + +:: 对hex文件进行Patch并生成patch后的.bin和.hex +call :doFilePatch %axf_name% +if %errorlevel% == 1 ( + echo Failed 2: Patch failed! + goto :EOF +) + +exit /b %errorlevel% + +:: Function Definiations ------------------------------------------------ + +:: .bin generate function +:binGenerate +:: 通过头文件路径,获取工具链的根目录 +set tool_chain_root=%~dp1 +:: 获取axf的路径 +set axf_path=%~dp2 +:: 获取axf的名字 +set axf_name=%~n2 +:: echo %axf_path% +:: echo %axf_name% +:: echo %tool_chain_root% +:: 执行fromelf 生成bin文件 +%tool_chain_root%bin\fromelf --bin %2 --output %axf_path%\%axf_name%.bin +exit /b %errorlevel% + +:: 将axf/hex/bin文件复制到Execute文件夹下 +:doFileCopy +:: 获取axf的名字 +set axf_name=%~n1 +copy /Y .\build\keil\Obj\%axf_name%.axf .\build\keil\Execute\%axf_name%.axf +copy /Y .\build\keil\Obj\%axf_name%.hex .\build\keil\Execute\%axf_name%.hex +copy /Y .\build\keil\Obj\%axf_name%.bin .\build\keil\Execute\%axf_name%.bin +:: 根据用户的配置,可能hex不生成,不管这个,直接返回成功 +exit /b 0 + +:: 对文件进行Patch +:doFilePatch +set target_name=%1 +Patcher.exe .\build\keil\Execute\%target_name%.hex +exit /b %errorlevel% diff --git a/bsp/tae32f5300/Kconfig b/bsp/tae32f5300/Kconfig new file mode 100644 index 0000000000..898ce3c956 --- /dev/null +++ b/bsp/tae32f5300/Kconfig @@ -0,0 +1,23 @@ +mainmenu "RT-Thread Project 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 "drivers/Kconfig" + + + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Include/system_tae32f53xx.h b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Include/system_tae32f53xx.h new file mode 100644 index 0000000000..a3c88e6191 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Include/system_tae32f53xx.h @@ -0,0 +1,89 @@ +/** + ****************************************************************************** + * @file system_tae32f53xx.h + * @author MCD Application Team + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Header File. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _SYSTEM_TAE32F53XX_H_ +#define _SYSTEM_TAE32F53XX_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ + + +/** @addtogroup TAE_CMSIS + * @{ + */ + +/** @addtogroup TAE32F53xx_System + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported variables --------------------------------------------------------*/ +/** @addtogroup TAE32F53xx_System_Exported_Variables + * @{ + */ + +/** + * @brief System Clock Frequency (Core Clock) + */ +extern uint32_t SystemCoreClock; + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup TAE32F53xx_System_Exported_Functions + * @{ + */ +extern void SystemInit(void); +extern void SystemCoreClockUpdate(uint32_t sysclk); +/** + * @} + */ + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _SYSTEM_TAE32F53XX_H_ */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Include/tae32f53xx.h b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Include/tae32f53xx.h new file mode 100644 index 0000000000..305ce28b1c --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Include/tae32f53xx.h @@ -0,0 +1,8347 @@ +/** + ****************************************************************************** + * @file tae32f53xx.h + * @author MCD Application Team + * @brief CMSIS TAE32F53xx(Cortex-M3) Device Peripheral Access Layer Header File. + * This file contains all the peripheral register's definitions, bits + * definitions and memory mapping for TAE32F53xx devices. + * + * This file contains: + * - Data structures and the address mapping for all peripherals + * - Peripheral's registers declarations and bits definition + * - Macros to access peripheral registers hardware + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_H_ +#define _TAE32F53XX_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** @defgroup TAE_CMSIS TAE CMSIS + * @brief TAE CMSIS + * @{ + */ + +/** @defgroup TAE32F53xx_Series TAE32F53xx Series + * @brief TAE32F53xx Series + * @{ + */ + + +/* ------- Start of section using anonymous unions and disabling warnings ------- */ +#if defined (__CC_ARM) +#pragma push +#pragma anon_unions +#elif defined (__ICCARM__) +#pragma language=extended +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc11-extensions" +#pragma clang diagnostic ignored "-Wreserved-id-macro" +#elif defined (__GNUC__) +/* anonymous unions are enabled by default */ +#elif defined (__TMS470__) +/* anonymous unions are enabled by default */ +#elif defined (__TASKING__) +#pragma warning 586 +#elif defined (__CSMC__) +/* anonymous unions are enabled by default */ +#else +#warning Not supported compiler type +#endif + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup TAE32F53xx_Exported_Types TAE32F53xx Exported Types + * @brief TAE32F53xx Exported Types + * @{ + */ + +/** @defgroup TAE32F53xx_Peripheral_Interrupt_Number_Definition TAE32F53xx Peripheral Interrupt Number Definition + * @brief TAE32F53xx Peripheral Interrupt Number Definition + * @{ + */ + +/** + * @brief TAE32F53xx Peripheral Interrupt Number Definition + */ +typedef enum { + /* ------------------ Processor Exceptions Numbers ------------------ */ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */ + HardFault_IRQn = -13, /*!< 3 HardFault Interrupt */ + MemoryManagement_IRQn = -12, /*!< 4 Memory Management Interrupt */ + BusFault_IRQn = -11, /*!< 5 Bus Fault Interrupt */ + UsageFault_IRQn = -10, /*!< 6 Usage Fault Interrupt */ + SVCall_IRQn = -5, /*!< 11 SV Call Interrupt */ + DebugMonitor_IRQn = -4, /*!< 12 Debug Monitor Interrupt */ + PendSV_IRQn = -2, /*!< 14 Pend SV Interrupt */ + SysTick_IRQn = -1, /*!< 15 System Tick Interrupt */ + + /* ------------------ Processor Interrupt Numbers ------------------- */ + I2C0_IRQn = 0, /*!< I2C0 Interrupt */ + I2C1_IRQn = 1, /*!< I2C1 Interrupt */ + UART0_IRQn = 2, /*!< UART0 Interrupt */ + UART1_IRQn = 3, /*!< UART1 Interrupt */ + TMR0_IRQn = 4, /*!< TIMER0 Interrupt */ + TMR1_IRQn = 5, /*!< TIMER1 Interrupt */ + TMR2_IRQn = 6, /*!< TIMER2 Interrupt */ + TMR3_IRQn = 7, /*!< TIMER3 Interrupt */ + LVD_IRQn = 8, /*!< LVD Interrupt */ + TMR4_IRQn = 9, /*!< TIMER4 Interrupt */ + TMR5_IRQn = 10, /*!< TIMER5 Interrupt */ + TMR6_IRQn = 11, /*!< TIMER6 Interrupt */ + TMR7_IRQn = 12, /*!< TIMER7 Interrupt */ + IWDG_IRQn = 13, /*!< IWDG Interrupt */ + WWDG_IRQn = 14, /*!< WWDG Interrupt */ + IIR0_IRQn = 15, /*!< IIR0 Interrupt */ + IIR1_IRQn = 16, /*!< IIR1 Interrupt */ + IIR2_IRQn = 17, /*!< IIR2 Interrupt */ + IIR3_IRQn = 18, /*!< IIR3 Interrupt */ + IIR4_IRQn = 19, /*!< IIR4 Interrupt */ + ECU_IRQn = 20, /*!< ECU Cal Done Interrupt */ + DMA_IRQn = 21, /*!< DMA Interrupt */ + CAN_IRQn = 22, /*!< CAN Interrupt */ + GPIOA_IRQn = 23, /*!< GPIOA Interrupt */ + GPIOB_IRQn = 24, /*!< GPIOB Interrupt */ + GPIOC_IRQn = 25, /*!< GPIOC Interrupt */ + GPIOD_IRQn = 26, /*!< GPIOD Interrupt */ + FLASH_IRQn = 27, /*!< FLASH Interrupt */ + DFLASH_IRQn = 28, /*!< DFLASH Interrupt */ + HRPWM_MSTR_IRQn = 29, /*!< Hrpwm Master Global Interrupt */ + HRPWM_SLV0_IRQn = 30, /*!< Hrpwm Slave0 Global Interrupt */ + HRPWM_SLV1_IRQn = 31, /*!< Hrpwm Slave1 Global Interrupt */ + HRPWM_SLV2_IRQn = 32, /*!< Hrpwm Slave2 Global Interrupt */ + HRPWM_SLV3_IRQn = 33, /*!< Hrpwm Slave3 Global Interrupt */ + HRPWM_SLV4_IRQn = 34, /*!< Hrpwm Slave4 Global Interrupt */ + HRPWM_SLV5_IRQn = 35, /*!< Hrpwm Slave5 Global Interrupt */ + HRPWM_FLT_IRQn = 36, /*!< Hrpwm All Fault Interrupt */ + ADC0_NORM_IRQn = 37, /*!< ADC0 Normal Global Interrupt */ + ADC0_HALF_IRQn = 38, /*!< ADC0 DMA Half Done Interrupt */ + ADC0_FULL_IRQn = 39, /*!< ADC0 DMA Full Done Interrupt */ + ADC0_SAMP_IRQn = 40, /*!< ADC0 Sample Done Interrupt */ + ADC1_NORM_IRQn = 41, /*!< ADC1 Normal Global Interrupt */ + ADC1_HALF_IRQn = 42, /*!< ADC1 DMA Half Done Interrupt */ + ADC1_FULL_IRQn = 43, /*!< ADC1 DMA Full Done Interrupt */ + ADC1_SAMP_IRQn = 44, /*!< ADC1 Sample Done Interrupt */ + DAC_IRQn = 45, /*!< DAC Interrupt */ + CMP_IRQn = 46, /*!< CMP Interrupt */ + USB_STA_IRQn = 47, /*!< USB Staus Interrupt */ + USB_DET_IRQn = 48, /*!< USB Detect Interrupt */ + USB_LPM_IRQn = 49, /*!< USB LPM Interrupt */ + USB_EP_IRQn = 50, /*!< USB Endpoint Interrupt */ + DALI_IRQn = 51, /*!< DALI Interrupt */ +} IRQn_Type; +/** + * @} + */ + + +/** @defgroup TAE32F53xx_Configuration_Section_For_CMSIS TAE32F53xx Configuration Section For CMSIS + * @brief TAE32F53xx Configuration Section For CMSIS + * @{ + */ + +/** + * @brief Configuration of the Cortex-M3 Processor and Core Peripherals + */ +#define __CM3_REV 0x0201U /*!< Core revision r2p1 */ +#define __MPU_PRESENT 0U /*!< MPU present */ +#define __VTOR_PRESENT 1U /*!< VTOR present */ +#define __NVIC_PRIO_BITS 3U /*!< Number of Bits used for Priority Levels */ +#define __Vendor_SysTickConfig 0U /*!< Set to 1 if different SysTick Config is used */ + +/** + * @brief CMSIS Device version number v5.3.1 + */ +#define __TAE32F53XX_CMSIS_VERSION_MAIN (0x05) /*!< [31:24] main version */ +#define __TAE32F53XX_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */ +#define __TAE32F53XX_CMSIS_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */ +#define __TAE32F53XX_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */ +#define __TAE32F53XX_CMSIS_VERSION ((__TAE32F53XX_CMSIS_VERSION_MAIN << 24) |\ + (__TAE32F53XX_CMSIS_VERSION_SUB1 << 16) |\ + (__TAE32F53XX_CMSIS_VERSION_SUB2 << 8 ) |\ + (__TAE32F53XX_CMSIS_VERSION_RC)) +/** + * @} + */ + + +/* Includes ------------------------------------------------------------------*/ +#include /*!< Standard int head file */ +#include "core_cm3.h" /*!< Processor and core peripherals */ +#include "system_tae32f53xx.h" /*!< TAE32F53xx System Header */ + + +/** @defgroup TAE32F53xx_Peripheral_Registers_Structures TAE32F53xx Peripheral Registers Structures + * @brief TAE32F53xx Peripheral Registers Structures + * @{ + */ + +/** + * @brief Embedded FLASH Controller Registers Structure + */ +typedef struct { + __IO uint32_t CR; /*!< Address offset: 0x00: FLASH Control Register */ + __IO uint32_t LPR; /*!< Address offset: 0x04: FLASH Lowpower Register */ + __IO uint32_t ISR; /*!< Address offset: 0x08: FLASH Interrupt Status Register */ + __IO uint32_t SR; /*!< Address offset: 0x0C: FLASH Status Register */ + __IO uint32_t DR0; /*!< Address offset: 0x10: FLASH Data Register 0 */ + __IO uint32_t DR1; /*!< Address offset: 0x14: FLASH Data Register 1 */ + __IO uint32_t DR2; /*!< Address offset: 0x18: FLASH Data Register 2 */ + __IO uint32_t DR3; /*!< Address offset: 0x1C: FLASH Data Register 3 */ + __IO uint32_t ADDR; /*!< Address offset: 0x20: FLASH Address Register */ + __I uint32_t RESERVED0; /*!< Reserved */ + __IO uint32_t ECR; /*!< Address offset: 0x28: FLASH Erase Control Register */ + __I uint32_t RESERVED1; /*!< Reserved */ + __IO uint32_t TR0; /*!< Address offset: 0x30: FLASH Timing Register 0 */ + __IO uint32_t TR1; /*!< Address offset: 0x34: FLASH Timing Register 1 */ + __IO uint32_t TR2; /*!< Address offset: 0x38: FLASH Timing Register 2 */ + __IO uint32_t TR3; /*!< Address offset: 0x3C: FLASH Timing Register 3 */ + __I uint32_t RESERVED2[4]; /*!< Reserved */ + __IO uint32_t KEYR; /*!< Address offset: 0x50: FLASH Key Register */ + __I uint32_t RESERVED3[3]; /*!< Reserved */ + __IO uint32_t RDPR; /*!< Address offset: 0x60: FLASH Read Protect Register */ + __I uint32_t RESERVED4[3]; /*!< Reserved */ + __IO uint32_t WRPR; /*!< Address offset: 0x70: FLASH Write Protect Register */ + __I uint32_t RESERVED5[3]; /*!< Reserved */ + __IO uint32_t UID[4]; /*!< Address offset: 0x80: FLASH Unique Identification */ +} FLASH_TypeDef; + + +/** + * @brief Data FLASH Controller Registers Structure + */ +typedef struct { + __IO uint32_t CR; /*!< Address offset: 0x00: DFLASH Control Register */ + __IO uint32_t LPR; /*!< Address offset: 0x04: DFLASH Lowpower Register */ + __IO uint32_t ISR; /*!< Address offset: 0x08: DFLASH Interrupt Status Register */ + __IO uint32_t SR; /*!< Address offset: 0x0C: DFLASH Status Register */ + __IO uint32_t DR; /*!< Address offset: 0x10: DFLASH Data Register */ + __IO uint32_t ADDR; /*!< Address offset: 0x14: DFLASH Address Register */ + __IO uint32_t ECR; /*!< Address offset: 0x18: DFLASH Erase Control Register */ + __I uint32_t RESERVED0; /*!< Reserved */ + __IO uint32_t TR0; /*!< Address offset: 0x20: DFLASH Timing Register 0 */ + __IO uint32_t TR1; /*!< Address offset: 0x24: DFLASH Timing Register 1 */ + __IO uint32_t TR2; /*!< Address offset: 0x28: DFLASH Timing Register 2 */ + __IO uint32_t TR3; /*!< Address offset: 0x2C: DFLASH Timing Register 3 */ + __IO uint32_t KEYR; /*!< Address offset: 0x30: DFLASH Key Register */ +} DFLASH_TypeDef; + + +/** + * @brief General Purpose I/O (GPIO) Registers Structure + */ +typedef struct { + __IO uint32_t BSRR; /*!< Address offset: 0x00: GPIO Bit Set/Reset Register */ + __IO uint32_t DR; /*!< Address offset: 0x04: GPIO Data Register */ + __IO uint32_t PUR; /*!< Address offset: 0x08: GPIO Pullup Register */ + __IO uint32_t PDR; /*!< Address offset: 0x0C: GPIO Pulldown Register */ + __IO uint32_t DSR; /*!< Address offset: 0x10: GPIO Driver Strength Register */ + __IO uint32_t IHYR; /*!< Address offset: 0x14: GPIO Input Hysteresis Register */ + __IO uint32_t OTYPR; /*!< Address offset: 0x18: GPIO Output Type Register */ + __IO uint32_t OSRR; /*!< Address offset: 0x1C: GPIO Output Slew Rate Register */ + __IO uint32_t IER; /*!< Address offset: 0x20: GPIO Interrupt Enable Register */ + __IO uint32_t ITER; /*!< Address offset: 0x24: GPIO Interrupt Trigger Enable Register */ + __IO uint32_t RFTSR; /*!< Address offset: 0x28: GPIO Rising/Falling Trigger Selection Register */ + __IO uint32_t PR; /*!< Address offset: 0x2C: GPIO Pending Register */ + __IO uint32_t SDER; /*!< Address offset: 0x30: GPIO Sync/Debounce Enable Register */ + __I uint32_t RESERVED0[3]; /*!< Reserved */ + __IO uint32_t PMUXR[2]; /*!< Address offset: 0x40: GPIO Pin-Mux Register */ +} GPIO_TypeDef; + + +/** + * @brief Window WATCHDOG (WWDG) Registers Structure + */ +typedef struct { + __IO uint32_t CR; /*!< Address offset: 0x00: WWDG Control Register */ + __IO uint32_t WVR; /*!< Address offset: 0x04: WWDG Window Value Register */ + __IO uint32_t CVR; /*!< Address offset: 0x08: WWDG Counter Value Register */ + __IO uint32_t PSCR; /*!< Address offset: 0x0C: WWDG Prescaler Register */ + __IO uint32_t ISR; /*!< Address offset: 0x10: WWDG Interrupt Status Register */ +} WWDG_TypeDef; + + +/** + * @brief Independent WATCHDOG (IWDG) Registers Structure + */ +typedef struct { + __IO uint32_t KEYR; /*!< Address offset: 0x00: IWDG Key register */ + __IO uint32_t CR; /*!< Address offset: 0x04: IWDG Control register */ + __IO uint32_t RLR; /*!< Address offset: 0x08: IWDG Reload register */ + __IO uint32_t PSCR; /*!< Address offset: 0x0C: IWDG Prescaler register */ + __IO uint32_t SR; /*!< Address offset: 0x10: IWDG Status register */ +} IWDG_TypeDef; + + +/** + * @brief Infinite Impulse Response (IIR) Registers Structure + */ +typedef struct { + __IOM uint32_t CR0; /*!< Address offset: 0x00: IIR Control Register */ + __IOM uint32_t CR1; /*!< Address offset: 0x04: IIR Start Register */ + __IOM uint32_t IER; /*!< Address offset: 0x08: IIR Interrupt Register */ + __IOM uint32_t ISR; /*!< Address offset: 0x0C: IIR Pending Register */ + __IM uint32_t RESERVED0; /*!< Reserved */ + __IOM uint32_t DOR; /*!< Address offset: 0x14: IIR DataO Register */ + __IM uint32_t RESERVED1[3]; /*!< Reserved */ + __IOM uint32_t DIAR; /*!< Address offset: 0x24: IIR DataI Address Register */ + __IM uint32_t RESERVED2; /*!< Reserved */ + __IOM uint32_t SCALR; /*!< Address offset: 0x2C: IIR Scale Register */ + __IOM uint32_t BxCOEFR[5]; /*!< Address offset: 0x30: IIR BxCOEF Register(x = 0...4) */ + __IOM uint32_t AxCOEFR[4]; /*!< Address offset: 0x44: IIR AxCOEF Register(x = 1...4) */ + __IM uint32_t RESERVED3[4]; /*!< Reserved */ + __IOM uint32_t DIASR; /*!< Address offset: 0x64: IIR DataI Addr Shadow Register */ + __IM uint32_t RESERVED4; /*!< Reserved */ + __IOM uint32_t SCALSR; /*!< Address offset: 0x6C: IIR Scale Shadow Register */ + __IOM uint32_t BxCOEFSR[5]; /*!< Address offset: 0x70: IIR B0COEF Shadow Register(x = 0...4) */ + __IOM uint32_t AxCOEFSR[4]; /*!< Address offset: 0x84: IIR A1COEF Shadow Register(x = 1...4) */ +} IIR_TypeDef; + + +/** + * @brief TIMER Registers Structure + */ +typedef struct { + __IOM uint32_t CR; /*!< Address offset: 0x00: Timer Counter Control Register */ + __IOM uint32_t CCCR; /*!< Address offset: 0x04: Timer Capture Compare Control Register */ + __IOM uint32_t EGR; /*!< Address offset: 0x08: Timer Event Generation Register */ + __IOM uint32_t ICFR; /*!< Address offset: 0x0C: Timer Input Capture Filter Register */ + __IOM uint32_t ISR; /*!< Address offset: 0x10: Timer Interrupt Status Register */ + __IM uint32_t RESERVED[3]; /*!< Reserved */ + __IOM uint32_t CSVR; /*!< Address offset: 0x20: Timer Counter Start Register */ + __IOM uint32_t CEVR; /*!< Address offset: 0x24: Timer Counter End Register */ + __IOM uint32_t CCR; /*!< Address offset: 0x28: Timer Capture Compare Register */ + __IOM uint32_t PSCR; /*!< Address offset: 0x2C: Timer Prescaler Register */ + __IOM uint32_t CNTR; /*!< Address offset: 0x30: Timer Counter Register */ + __IOM uint32_t ETER; /*!< Address offset: 0x34: Timer Export Trigger Event Register */ +} TMR_TypeDef; + +/** + * @brief TIMERGRP (Timer Group Sync Register) Registers Structure + */ +typedef struct { + __IOM uint32_t SYNCR; /*!< Timer Group Sync Register */ +} TMRGRP_TypeDef; + + +/** + * @brief UART Registers Structure + */ +typedef struct { + union { + __IOM uint32_t RBR; /*!< Address offset: 0x00: Receive Buffer Register */ + __IOM uint32_t THR; /*!< Address offset: 0x00: Transmit Holding Register */ + __IOM uint32_t DLL; /*!< Address offset: 0x00: Divisor Latch Low */ + }; + union { + __IOM uint32_t DLH; /*!< Address offset: 0x04: Divisor Latch High */ + __IOM uint32_t IER; /*!< Address offset: 0x04: Interrupt Enable Register */ + }; + union { + __IOM uint32_t IIR; /*!< Address offset: 0x08: Interrupt Identity Register */ + __IOM uint32_t FCR; /*!< Address offset: 0x08: FIFO Control Register */ + }; + __IOM uint32_t LCR; /*!< Address offset: 0x0C: Line Control Register */ + __IM uint32_t RESERVED0; /*!< Address offset: 0x10: Reserved */ + __IOM uint32_t LSR; /*!< Address offset: 0x14: Line Status Register */ + __IM uint32_t RESERVED1[25]; /*!< Address offset: 0x18~0x78: Reserved */ + __IOM uint32_t USR; /*!< Address offset: 0x7C: UART Status Register */ + __IOM uint32_t TFL; /*!< Address offset: 0x80: Transmit FIFO Level */ + __IOM uint32_t RFL; /*!< Address offset: 0x84: Receive FIFO Level */ + __IM uint32_t RESERVED2[7]; /*!< Address offset: 0x88~0xA0: Reserved */ + __IOM uint32_t HTX; /*!< Address offset: 0xA4: Halt TX */ + __IM uint32_t RESERVED3; /*!< Address offset: 0xA8: Reserved */ + __IOM uint32_t TCR; /*!< Address offset: 0xAC: Transceiver Control Register */ + __IOM uint32_t DE_EN; /*!< Address offset: 0xB0: Driver Output Enable Register */ + __IOM uint32_t RE_EN; /*!< Address offset: 0xB4: Receiver Output Enable Register */ + __IOM uint32_t DET; /*!< Address offset: 0xB8: Driver Output Enable Timing Register */ + __IOM uint32_t TAT; /*!< Address offset: 0xBC: TurnAround Timing Register */ + __IOM uint32_t DLF; /*!< Address offset: 0xC0: Divisor Latch Fraction Register */ + __IOM uint32_t RAR; /*!< Address offset: 0xC4: Receive Address Register */ + __IOM uint32_t TAR; /*!< Address offset: 0xC8: Transmit Address Register */ + __IOM uint32_t LCR_EXT; /*!< Address offset: 0xCC: Line Extended Control Register */ +} UART_TypeDef; + + +/** + * @brief DMA Channel Numbers + */ +#define DMA_CHN_NB 2 + +/** + * @brief DMA Channel + */ +typedef struct { + __IO uint32_t SAR; /*!< Address offset: 0x00: DMA Channel Source Address Register */ + __I uint32_t RESERVED0; /*!< Address offset: 0x04: Reserved */ + __IO uint32_t DAR; /*!< Address offset: 0x08: DMA Channel Destination Address Register */ + __I uint32_t RESERVED1[3]; /*!< Address offset: 0x0C~0x14: Reserved */ + __IO uint32_t CR0; /*!< Address offset: 0x18: DMA Channel Control Register0 */ + __IO uint32_t CR1; /*!< Address offset: 0x1C: DMA Channel Control Register1 */ + __I uint32_t RESERVED2[8]; /*!< Address offset: 0x20~0x3C: Reserved */ + __IO uint32_t CR2; /*!< Address offset: 0x40: DMA Channel Config Register0 */ + __IO uint32_t CR3; /*!< Address offset: 0x44: DMA Channel Config Register1 */ + __IO uint32_t RESERVED3[4]; /*!< Address offset: 0x48~0x54: Reserved */ +} DMA_CH_TypeDef; + +/** + * @brief DMA Registers Structure + */ +typedef struct { + DMA_CH_TypeDef CH[DMA_CHN_NB]; /*!< DMA Channel control Register */ + + __IM uint32_t RESERVED4[132]; /*!< Reserved */ + __IOM uint32_t TSR; /*!< Address offset: 0x2C0: DMA Tranfer Status Register */ + __IM uint32_t RESERVED5; /*!< Reserved */ + __IOM uint32_t BTSR; /*!< Address offset: 0x2C8: DMA Block Tranfer Status Register */ + __IM uint32_t RESERVED6; /*!< Reserved */ + __IOM uint32_t STSR; /*!< Address offset: 0x2D0: DMA Source Transfer Status Register */ + __IM uint32_t RESERVED7; /*!< Reserved */ + __IOM uint32_t DTSR; /*!< Address offset: 0x2D8: DMA Destination Transfer Status Register */ + __IM uint32_t RESERVED8; /*!< Reserved */ + __IOM uint32_t TESR; /*!< Address offset: 0x2E0: DMA Transfer Error Status Register */ + __IM uint32_t RESERVED9; /*!< Reserved */ + __IOM uint32_t TIPR; /*!< Address offset: 0x2E8: DMA Transfer Interrupt Pending Register */ + __IM uint32_t RESERVED10; /*!< Reserved */ + __IOM uint32_t BTIPR; /*!< Address offset: 0x2F0: DMA Block Transfer Interrupt Pending Register */ + __IM uint32_t RESERVED11; /*!< Reserved */ + __IOM uint32_t STIPR; /*!< Address offset: 0x2F8: DMA Source Transfer Interrupt Pending Register */ + __IM uint32_t RESERVED12; /*!< Reserved */ + __IOM uint32_t DTIPR; /*!< Address offset: 0x300: DMA Destination Transfer Interrupt Pending Register */ + __IM uint32_t RESERVED13; /*!< Reserved */ + __IOM uint32_t TEIPR; /*!< Address offset: 0x308: DMA Transfer Error Interrupt Pending Register */ + __IM uint32_t RESERVED14; /*!< Reserved */ + __IOM uint32_t TIMR; /*!< Address offset: 0x310: DMA Transfer Interrupt Mask Register */ + __IM uint32_t RESERVED15; /*!< Reserved */ + __IOM uint32_t BTIMR; /*!< Address offset: 0x318: DMA Block Transfer Interrupt Mask Register */ + __IM uint32_t RESERVED16; /*!< Reserved */ + __IOM uint32_t STIMR; /*!< Address offset: 0x320: DMA Source Transfer IntClear Register */ + __IM uint32_t RESERVED17; /*!< Reserved */ + __IOM uint32_t DTIMR; /*!< Address offset: 0x328: DMA Destination Transfer Interrupt Mask Register */ + __IM uint32_t RESERVED18; /*!< Reserved */ + __IOM uint32_t TEIMR; /*!< Address offset: 0x330: DMA Transfer Error Interrupt Mask Register */ + __IM uint32_t RESERVED19; /*!< Reserved */ + __IOM uint32_t TCR; /*!< Address offset: 0x338: DMA Transfer Clear Register */ + __IM uint32_t RESERVED20; /*!< Reserved */ + __IOM uint32_t BTCR; /*!< Address offset: 0x340: DMA Block Transfer Clear Register */ + __IM uint32_t RESERVED21; /*!< Reserved */ + __IOM uint32_t STCR; /*!< Address offset: 0x348: DMA Source Transfer Clear Register */ + __IM uint32_t RESERVED22; /*!< Reserved */ + __IOM uint32_t DTCR; /*!< Address offset: 0x350: DMA Destination Transfer Clear Register */ + __IM uint32_t RESERVED23; /*!< Reserved */ + __IOM uint32_t TECR; /*!< Address offset: 0x358: DMA Transfer Error Clear Register */ + __IM uint32_t RESERVED24[15]; /*!< Reserved */ + __IOM uint32_t CR0; /*!< Address offset: 0x398: DMA Control Register0 */ + __IM uint32_t RESERVED25; /*!< Reserved */ + __IOM uint32_t CR1; /*!< Address offset: 0x3A0: DMA Control Register1 */ +} DMA_TypeDef; + + +/** + * @brief ADC DMA + */ +typedef struct { + __IO uint32_t TCR; /*!< Address offset: 0x110: ADC Transfer Control Register */ + __IO uint32_t TAR; /*!< Address offset: 0x114: ADC Transfer Address Register */ + __I uint32_t RESERVED; /*!< Reserved */ + __IO uint32_t TLR; /*!< Address offset: 0x11C: ADC Transfer Length Register */ +} ADC_DMA_TypeDef; + +/** + * @brief Analog to Digital Converter (ADC) Registers Structure + */ +typedef struct { + __IO uint32_t CR0; /*!< Address offset: 0x00 : ADC Control Register 0 */ + __IO uint32_t CR1; /*!< Address offset: 0x04 : ADC Control Register 1 */ + __IO uint32_t CR2; /*!< Address offset: 0x08 : ADC Control Register 2 */ + __IO uint32_t DIFSEL; /*!< Address offset: 0x0C : ADC Differential Select Register */ + __IO uint32_t IER; /*!< Address offset: 0x10 : ADC Interrupt Enable Register */ + __IO uint32_t ISR; /*!< Address offset: 0x14 : ADC Interrupt Status Register */ + __IO uint32_t SIER; /*!< Address offset: 0x18 : ADC Sample Interrupt Enable Register */ + __IO uint32_t SISR; /*!< Address offset: 0x1C : ADC Sample Interrupt Status Register */ + __IO uint32_t SMPR0; /*!< Address offset: 0x20 : ADC Sample Time Register 0 */ + __IO uint32_t SMPR1; /*!< Address offset: 0x24 : ADC Sample Time Register 1 */ + __IO uint32_t CALR0; /*!< Address offset: 0x28 : ADC Calibration Data Register 0 */ + __IO uint32_t CALR1; /*!< Address offset: 0x2C : ADC Calibration Data Register 1 */ + __IO uint32_t SQR0; /*!< Address offset: 0x30 : ADC Regular Sequence Register 0 */ + __IO uint32_t SQR1; /*!< Address offset: 0x34 : ADC Regular Sequence Register 1 */ + __IO uint32_t LR; /*!< Address offset: 0x38 : ADC Regular Length Register */ + __IO uint32_t DR; /*!< Address offset: 0x3C : ADC Regular Data Register */ + __IO uint32_t JSQR; /*!< Address offset: 0x40 : ADC Injected Sequence Register */ + __IO uint32_t JLR; /*!< Address offset: 0x44 : ADC Injected Length Register */ + __I uint32_t RESERVED0[2]; /*!< Reserved */ + __IO uint32_t JDR[4]; /*!< Address offset: 0x50 : ADC Injected Data Register */ + __IO uint32_t TR[3]; /*!< Address offset: 0x60 : ADC Watchdog Threshold Register */ + __I uint32_t RESERVED1; /*!< Reserved */ + __IO uint32_t AWDCR[3]; /*!< Address offset: 0x70 : ADC Watchdog Control Register */ + __I uint32_t RESERVED2; /*!< Reserved */ + __IO uint32_t OFR[4]; /*!< Address offset: 0x80 : ADC Single-End Offset Register */ + __IO uint32_t DOFR[4]; /*!< Address offset: 0x90 : ADC Differential Offset Register */ + __IO uint32_t GCR[4]; /*!< Address offset: 0xA0 : ADC Single-End Gain Coeff Register */ + __IO uint32_t DGCR[4]; /*!< Address offset: 0xB0 : ADC Channel Data Register */ + __IO uint32_t ECR[4]; /*!< Address offset: 0xC0 : ADC Event Control Register */ + __I uint32_t CDR[12]; /*!< Address offset: 0xD0 : ADC Differential Gain Coeff Register */ + __IO uint32_t HIER; /*!< Address offset: 0x100: ADC Half Interrupt Enable Register */ + __IO uint32_t HISR; /*!< Address offset: 0x104: ADC Half Interrupt Status Register */ + __IO uint32_t FIER; /*!< Address offset: 0x108: ADC Full Interrupt Enable Register */ + __IO uint32_t FISR; /*!< Address offset: 0x10C: ADC Full Interrupt Status Register */ + ADC_DMA_TypeDef DMA_CR[12]; /*!< Address offset: 0x110: ADC Transfer Control Register */ +} ADC_TypeDef; + + +/** + * @brief DAC Channel Numbers + */ +#define DAC_CHN_NB 4 + +/** + * @brief Digital to Analog Converter Registers Structure + */ +typedef struct { + __IO uint32_t CR[DAC_CHN_NB]; /*!< DAC Control Register */ + __IO uint32_t ISR; /*!< DAC Interrupt Status Register */ + __IO uint32_t SWTR; /*!< DAC Software Trigger Register */ + __I uint32_t RESERVED0[2]; /*!< Reserved */ + __IO uint32_t WDR[DAC_CHN_NB]; /*!< DAC Write Data Register */ + __IO uint32_t RDR[DAC_CHN_NB]; /*!< DAC Read Data Register */ + __IO uint32_t SIDR[DAC_CHN_NB]; /*!< DAC Sawtooth Increment Data Register */ + __IO uint32_t SRDR[DAC_CHN_NB]; /*!< DAC Sawtooth Reset Data Register */ +} DAC_TypeDef; + + +/** + * @brief CMP Channel Number + */ +#define CMP_CHN_NB 4 + +/** + * @brief Comparator (CMP) Registers Structure + */ +typedef struct { + __IO uint32_t CR[CMP_CHN_NB]; /*!< CMP Control Register */ + __IO uint32_t SR; /*!< CMP Status Register */ + __IO uint32_t DEBR[CMP_CHN_NB]; /*!< CMP Debounce Register */ +} CMP_TypeDef; + + +/** + * @brief Electricity Calculate Unit (ECU) Registers Structure + */ +typedef struct { + __IO uint32_t CON; /*!< Address offset: 0x00: ECU Control Register */ + __IO uint32_t PRC; /*!< Address offset: 0x04: ECU Exit Event Select Register */ + __IO uint32_t SQRT_IN; /*!< Address offset: 0x08: ECU Sqrt Data Input Register */ + __I uint32_t SQRT_OUT; /*!< Address offset: 0x0C: ECU Sqrt Data Output Register */ + __IO uint32_t V_ADDR1; /*!< Address offset: 0x10: ECU V Data Addr Register */ + __IO uint32_t V_ADDR2; /*!< Address offset: 0x14: ECU Register */ + __IO uint32_t I_ADDR1; /*!< Address offset: 0x18: ECU I Data Addr Register */ + __IO uint32_t I_ADDR2; /*!< Address offset: 0x1C: ECU Register */ + __I uint32_t V; /*!< Address offset: 0x20: ECU V Data Read Register */ + __I uint32_t I; /*!< Address offset: 0x24: ECU I Data Read Register */ + __I uint32_t P; /*!< Address offset: 0x28: ECU P Data Read Register */ + __I uint32_t Q; /*!< Address offset: 0x2C: ECU Q Data Read Register */ + __I uint32_t S; /*!< Address offset: 0x30: ECU S Data Read Register */ + __I uint32_t PF; /*!< Address offset: 0x34: ECU PF Data Read Register */ + __I uint32_t F; /*!< Address offset: 0x38: ECU F Data Read Register */ +} ECU_TypeDef; + + +/** + * @brief HRPWM Master Registers + */ +typedef struct { + __IO uint32_t MCR ; /*!< Address offset: 0x00: HRPWM Master PWM Control Register */ + __I uint32_t RESERVED0 ; /*!< Reserved */ + __IO uint32_t MISR; /*!< Address offset: 0x08: HRPWM Master PWM Interrupt Status Register */ + __IO uint32_t MIER; /*!< Address offset: 0x0C: HRPWM Master PWM Interrupt Enable Register */ + __IO uint32_t MCNTR; /*!< Address offset: 0x10: HRPWM Master PWM Counter Register */ + __IO uint32_t MPER; /*!< Address offset: 0x14: HRPWM Master Period Value Register */ + __IO uint32_t MCMPAR; /*!< Address offset: 0x18: HRPWM Master PWM Cmp A Value Register */ + __IO uint32_t MCMPBR; /*!< Address offset: 0x1c: HRPWM Master PWM Cmp B Value Register */ + __IO uint32_t MCMPCR; /*!< Address offset: 0x20: HRPWM Master PWM Cmp C Value Register */ + __IO uint32_t MCMPDR; /*!< Address offset: 0x24: HRPWM Master PWM Cmp D Value Register */ + __I uint32_t RESERVED1[22]; /*!< Reserved */ +} HRPWM_MSTR_TypeDef; + +/** + * @brief HRPWM PWMx Registers + */ +typedef struct { + __IO uint32_t CR0; /*!< Address offset: 0x80: HRPWM Hrpwmx Control Register 0 */ + __IO uint32_t CR1; /*!< Address offset: 0x84: HRPWM Hrpwmx Control Register 1 */ + __IO uint32_t ISR; /*!< Address offset: 0x88: HRPWM Hrpwmx Interrupt Status Register */ + __IO uint32_t IER; /*!< Address offset: 0x8C: HRPWM Hrpwmx Interrupt Enable Register */ + __IO uint32_t CNTR; /*!< Address offset: 0x90: HRPWM Hrpwmx Counter Register */ + __IO uint32_t PERR; /*!< Address offset: 0x94: HRPWM Hrpwmx Period Value Register */ + __IO uint32_t CMPAR; /*!< Address offset: 0x98: HRPWM Hrpwmx Cmp A Register */ + __IO uint32_t CMPBR; /*!< Address offset: 0x9C: HRPWM Hrpwmx Cmp B Register */ + __IO uint32_t CMPCR; /*!< Address offset: 0xA0: HRPWM Hrpwmx Cmp C Register */ + __IO uint32_t CMPDR; /*!< Address offset: 0xA4: HRPWM Hrpwmx Cmp D Register */ + __IO uint32_t DTR; /*!< Address offset: 0xA8: HRPWM Hrpwmx Dead Time Register */ + __IO uint32_t SETAR; /*!< Address offset: 0xAC: HRPWM Hrpwmx Output A Set Register */ + __IO uint32_t CLRAR; /*!< Address offset: 0xB0: HRPWM Hrpwmx Output A Clear Register */ + __IO uint32_t SETBR; /*!< Address offset: 0xB4: HRPWM Hrpwmx Output B Set Register */ + __IO uint32_t CLRBR; /*!< Address offset: 0xB8: HRPWM Hrpwmx Output B Clear Register */ + __IO uint32_t EEFR0; /*!< Address offset: 0xBC: HRPWM Hrpwmx External Event Register */ + __IO uint32_t EEFR1; /*!< Address offset: 0xC0: HRPWM Hrpwmx External Event5 Register */ + __IO uint32_t RSTR; /*!< Address offset: 0xC4: HRPWM Hrpwmx Reset Register */ + __IO uint32_t CHPR; /*!< Address offset: 0xC8: HRPWM Hrpwmx Chopper Register */ + __IO uint32_t OUTR; /*!< Address offset: 0xCC: HRPWM Hrpwmx Output Register */ + __IO uint32_t FLTR; /*!< Address offset: 0xD0: HRPWM Hrpwmx Fault Register */ + __I uint32_t RESERVED[11]; /*!< Reserved */ +} HRPWM_PWMx_TypeDef; + +/** + * @brief HRPWM Common Registers + */ +typedef struct { + __IO uint32_t CR0; /*!< Address offset: 0x380: HRPWM Control Register 0 */ + __IO uint32_t CR1; /*!< Address offset: 0x384: HRPWM Control Register 1 */ + __IO uint32_t CR2; /*!< Address offset: 0x388: HRPWM Control Register 2 */ + __IO uint32_t ISR; /*!< Address offset: 0x38C: HRPWM Interrupt Status Register */ + __IO uint32_t IER; /*!< Address offset: 0x390: HRPWM Interrupt Enable Register */ + __IO uint32_t OENR; /*!< Address offset: 0x394: HRPWM Output Enable Register */ + __IO uint32_t ODISR; /*!< Address offset: 0x398: HRPWM Output Disable Register */ + __IO uint32_t EECR0; /*!< Address offset: 0x39C: HRPWM External Event Register 0 */ + __IO uint32_t EECR1; /*!< Address offset: 0x3A0: HRPWM External Event Register 1 */ + __IO uint32_t EECR2; /*!< Address offset: 0x3A4: HRPWM External Event Register 2 */ + __IO uint32_t ADTR[8]; /*!< Address offset: 0x3A8: HRPWM ADDA Trigger Post Scaler Register */ + __IO uint32_t ADPSR; /*!< Address offset: 0x3C8: HRPWM SOC Length Register */ + __IO uint32_t DLLCR; /*!< Address offset: 0x3CC: HRPWM DLL Control Register */ + __IO uint32_t FLTINR0; /*!< Address offset: 0x3D0: HRPWM Fault Input Register 0 */ + __IO uint32_t FLTINR1; /*!< Address offset: 0x3D4: HRPWM Fault Input Register 1 */ + __IO uint32_t FLTINR2; /*!< Address offset: 0x3D8: HRPWM Fault Input Register 2 */ + __IO uint32_t FLTINR3; /*!< Address offset: 0x3DC: HRPWM Fault Input Register 3 */ +} HRPWM_COMMON_TypeDef; + +/** + * @brief High Resolution PWM (HRPWM) Registers Structure + */ +typedef struct { + HRPWM_MSTR_TypeDef Master; /*!< HRPWM Master Registers */ + HRPWM_PWMx_TypeDef PWM[6]; /*!< HRPWM PWMx Registers */ + HRPWM_COMMON_TypeDef Common; /*!< HRPWM Common Registers */ +} HRPWM_TypeDef; + + +/** + * @brief USB DMA + */ +typedef struct __attribute__((packed)) { + __IO uint16_t CTRL; /*!< Address offset: 0x00 USB DMA Control Register */ + __I uint8_t RESERVED0[2]; /*!< Address offset: 0x02~0x03 Reserverd */ + __IO uint32_t ADDR; /*!< Address offset: 0x04 USB DMA Address Register */ + __IO uint32_t CNT; /*!< Address offset: 0x08 USB DMA Count Register */ + __I uint8_t RESERVED1[4]; /*!< Address offset: 0x0C~0x0F Reserverd */ +} USB_DMA; + +/** + * @brief USB Registers Structure + */ +typedef struct __attribute__((packed)) { + /* USB Common Register */ + __IO uint8_t FADDR; /*!
= 6010050)) +#pragma clang diagnostic pop +#elif defined (__GNUC__) +/* anonymous unions are enabled by default */ +#elif defined (__TMS470__) +/* anonymous unions are enabled by default */ +#elif defined (__TASKING__) +#pragma warning restore +#elif defined (__CSMC__) +/* anonymous unions are enabled by default */ +#else +#warning Not supported compiler type +#endif + + +/** + * @} + */ + + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/ARM/tae32f53xx_ac5_sram.sct b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/ARM/tae32f53xx_ac5_sram.sct new file mode 100644 index 0000000000..040fa5fe6c --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/ARM/tae32f53xx_ac5_sram.sct @@ -0,0 +1,104 @@ +#! armcc -E +; command above MUST be in first line (no comment above!) + +/* +;-------- <<< Use Configuration Wizard in Context Menu >>> ------------------- +*/ + +/*--------------------- Flash Configuration ---------------------------------- +; Flash Configuration +; Flash Base Address <0x0-0xFFFFFFFF:8> +; Flash Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __ROM_BASE 0x00000000 +#define __ROM_SIZE 0x00003000 + +/*--------------------- Embedded RAMA Configuration -------------------------- +; RAMA Configuration +; RAMA Base Address <0x0-0xFFFFFFFF:8> +; RAMA Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMA_BASE 0x20003000 +#define __RAMA_SIZE 0x00001000 + +/*--------------------- Embedded RAMB Configuration -------------------------- +; RAMB Configuration +; RAMB Base Address <0x0-0xFFFFFFFF:8> +; RAMB Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMB_BASE 0x20004000 +#define __RAMB_SIZE 0x00001000 + +/*--------------------- Embedded RAMC Configuration -------------------------- +; RAMC Configuration +; RAMC Base Address <0x0-0xFFFFFFFF:8> +; RAMC Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMC_BASE 0x20005000 +#define __RAMC_SIZE 0x00001000 + +/*--------------------- Stack / Heap Configuration --------------------------- +; Stack / Heap Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __STACK_SIZE 0x00000200 +#define __HEAP_SIZE 0x00000000 + +/* +;------------- <<< end of configuration section >>> --------------------------- +*/ + + +/*---------------------------------------------------------------------------- + User Stack & Heap boundary definition + *----------------------------------------------------------------------------*/ +#define __STACK_TOP (__RAMA_BASE + __RAMA_SIZE) /* starts at end of RAMA */ +#define __HEAP_BASE (AlignExpr(+0, 8)) /* starts after RW_RAMA section, 8 byte aligned */ + + +/*---------------------------------------------------------------------------- + Scatter File Definitions definition + *----------------------------------------------------------------------------*/ +#define __RO_BASE __ROM_BASE +#define __RO_SIZE __ROM_SIZE + +#define __RW_BASE __RAMA_BASE +#define __RW_SIZE (__RAMA_SIZE - __STACK_SIZE - __HEAP_SIZE) + + +LR_ROM __RO_BASE __RO_SIZE { ; load region size_region + ER_ROM __RO_BASE __RO_SIZE { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + + RW_RAMA __RW_BASE __RW_SIZE { ; RWA data + *.o (SECTION_RAMA) + .ANY (+RW +ZI) + } + + RW_RAMB __RAMB_BASE __RAMB_SIZE { ; RWB region + *.o (SECTION_RAMB) + } + + RW_RAMC __RAMC_BASE __RAMC_SIZE { ; RWC region + *.o (SECTION_RAMC) + } + +#if __HEAP_SIZE > 0 + ARM_LIB_HEAP __HEAP_BASE EMPTY __HEAP_SIZE { ; Reserve empty region for heap + } +#endif + + ARM_LIB_STACK __STACK_TOP EMPTY -__STACK_SIZE { ; Reserve empty region for stack + } +} + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/ARM/tae32f53xx_ac6_sram.sct b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/ARM/tae32f53xx_ac6_sram.sct new file mode 100644 index 0000000000..a706ed5679 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/ARM/tae32f53xx_ac6_sram.sct @@ -0,0 +1,104 @@ +#! armclang -E --target=arm-arm-none-eabi -mcpu=cortex-m3 -xc +; command above MUST be in first line (no comment above!) + +/* +;-------- <<< Use Configuration Wizard in Context Menu >>> ------------------- +*/ + +/*--------------------- Flash Configuration ---------------------------------- +; Flash Configuration +; Flash Base Address <0x0-0xFFFFFFFF:8> +; Flash Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __ROM_BASE 0x00000000 +#define __ROM_SIZE 0x00003000 + +/*--------------------- Embedded RAMA Configuration -------------------------- +; RAMA Configuration +; RAMA Base Address <0x0-0xFFFFFFFF:8> +; RAMA Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMA_BASE 0x20003000 +#define __RAMA_SIZE 0x00001000 + +/*--------------------- Embedded RAMB Configuration -------------------------- +; RAMB Configuration +; RAMB Base Address <0x0-0xFFFFFFFF:8> +; RAMB Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMB_BASE 0x20004000 +#define __RAMB_SIZE 0x00001000 + +/*--------------------- Embedded RAMC Configuration -------------------------- +; RAMC Configuration +; RAMC Base Address <0x0-0xFFFFFFFF:8> +; RAMC Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMC_BASE 0x20005000 +#define __RAMC_SIZE 0x00001000 + +/*--------------------- Stack / Heap Configuration --------------------------- +; Stack / Heap Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __STACK_SIZE 0x00000200 +#define __HEAP_SIZE 0x00000000 + +/* +;------------- <<< end of configuration section >>> --------------------------- +*/ + + +/*---------------------------------------------------------------------------- + User Stack & Heap boundary definition + *----------------------------------------------------------------------------*/ +#define __STACK_TOP (__RAMA_BASE + __RAMA_SIZE) /* starts at end of RAMA */ +#define __HEAP_BASE (AlignExpr(+0, 8)) /* starts after RW_RAMA section, 8 byte aligned */ + + +/*---------------------------------------------------------------------------- + Scatter File Definitions definition + *----------------------------------------------------------------------------*/ +#define __RO_BASE __ROM_BASE +#define __RO_SIZE __ROM_SIZE + +#define __RW_BASE __RAMA_BASE +#define __RW_SIZE (__RAMA_SIZE - __STACK_SIZE - __HEAP_SIZE) + + +LR_ROM __RO_BASE __RO_SIZE { ; load region size_region + ER_ROM __RO_BASE __RO_SIZE { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + + RW_RAMA __RW_BASE __RW_SIZE { ; RWA data + *.o (SECTION_RAMA) + .ANY (+RW +ZI) + } + + RW_RAMB __RAMB_BASE __RAMB_SIZE { ; RWB region + *.o (SECTION_RAMB) + } + + RW_RAMC __RAMC_BASE __RAMC_SIZE { ; RWC region + *.o (SECTION_RAMC) + } + +#if __HEAP_SIZE > 0 + ARM_LIB_HEAP __HEAP_BASE EMPTY __HEAP_SIZE { ; Reserve empty region for heap + } +#endif + + ARM_LIB_STACK __STACK_TOP EMPTY -__STACK_SIZE { ; Reserve empty region for stack + } +} + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/GCC/gcc_arm.ld b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/GCC/gcc_arm.ld new file mode 100644 index 0000000000..498beeb8d3 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/GCC/gcc_arm.ld @@ -0,0 +1,295 @@ +/****************************************************************************** + * @file gcc_arm.ld + * @brief GNU Linker Script for Cortex-M based device + * @version V2.0.0 + * @date 21. May 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + *-------- <<< Use Configuration Wizard in Context Menu >>> ------------------- + */ + +/*---------------------- Flash Configuration ---------------------------------- + Flash Configuration + Flash Base Address <0x0-0xFFFFFFFF:8> + Flash Size (in Bytes) <0x0-0xFFFFFFFF:8> + + -----------------------------------------------------------------------------*/ +__ROM_BASE = 0x00000000; +__ROM_SIZE = 0x00040000; + +/*--------------------- Embedded RAM Configuration ---------------------------- + RAM Configuration + RAM Base Address <0x0-0xFFFFFFFF:8> + RAM Size (in Bytes) <0x0-0xFFFFFFFF:8> + + -----------------------------------------------------------------------------*/ +__RAM_BASE = 0x20000000; +__RAM_SIZE = 0x00020000; + +/*--------------------- Stack / Heap Configuration ---------------------------- + Stack / Heap Configuration + Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> + Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> + + -----------------------------------------------------------------------------*/ +__STACK_SIZE = 0x00000400; +__HEAP_SIZE = 0x00000C00; + +/* + *-------------------- <<< end of configuration section >>> ------------------- + */ + +MEMORY +{ + FLASH (rx) : ORIGIN = __ROM_BASE, LENGTH = __ROM_SIZE + RAM (rwx) : ORIGIN = __RAM_BASE, LENGTH = __RAM_SIZE +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + */ +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + KEEP(*(.vectors)) + *(.text*) + + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata*) + + KEEP(*(.eh_frame*)) + } > FLASH + + /* + * SG veneers: + * All SG veneers are placed in the special output section .gnu.sgstubs. Its start address + * must be set, either with the command line option --section-start or in a linker script, + * to indicate where to place these veneers in memory. + */ +/* + .gnu.sgstubs : + { + . = ALIGN(32); + } > FLASH +*/ + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + /* Add each additional data section here */ +/* + LONG (__etext2) + LONG (__data2_start__) + LONG (__data2_end__ - __data2_start__) +*/ + __copy_table_end__ = .; + } > FLASH + + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + /* Add each additional bss section here */ +/* + LONG (__bss2_start__) + LONG (__bss2_end__ - __bss2_start__) +*/ + __zero_table_end__ = .; + } > FLASH + + /** + * Location counter can end up 2byte aligned with narrow Thumb code but + * __etext is assumed by startup code to be the LMA of a section in RAM + * which must be 4byte aligned + */ + __etext = ALIGN (4); + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data) + *(.data.*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + + } > RAM + + /* + * Secondary data section, optional + * + * Remember to add each additional data section + * to the .copy.table above to asure proper + * initialization during startup. + */ +/* + __etext2 = ALIGN (4); + + .data2 : AT (__etext2) + { + . = ALIGN(4); + __data2_start__ = .; + *(.data2) + *(.data2.*) + . = ALIGN(4); + __data2_end__ = .; + + } > RAM2 +*/ + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM AT > RAM + + /* + * Secondary bss section, optional + * + * Remember to add each additional bss section + * to the .zero.table above to asure proper + * initialization during startup. + */ +/* + .bss2 : + { + . = ALIGN(4); + __bss2_start__ = .; + *(.bss2) + *(.bss2.*) + . = ALIGN(4); + __bss2_end__ = .; + } > RAM2 AT > RAM2 +*/ + + .heap (COPY) : + { + . = ALIGN(8); + __end__ = .; + PROVIDE(end = .); + . = . + __HEAP_SIZE; + . = ALIGN(8); + __HeapLimit = .; + } > RAM + + .stack (ORIGIN(RAM) + LENGTH(RAM) - __STACK_SIZE) (COPY) : + { + . = ALIGN(8); + __StackLimit = .; + . = . + __STACK_SIZE; + . = ALIGN(8); + __StackTop = .; + } > RAM + PROVIDE(__stack = __StackTop); + + /* Check if data + heap + stack exceeds RAM limit */ + ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") +} diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/GCC/startup_ARMCM3.S b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/GCC/startup_ARMCM3.S new file mode 100644 index 0000000000..24e9a146f7 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/GCC/startup_ARMCM3.S @@ -0,0 +1,180 @@ +/**************************************************************************//** + * @file startup_ARMCM3.S + * @brief CMSIS-Core(M) Device Startup File for Cortex-M3 Device + * @version V2.0.1 + * @date 23. July 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + .syntax unified + .arch armv7-m + + .section .vectors + .align 2 + .globl __Vectors + .globl __Vectors_End + .globl __Vectors_Size +__Vectors: + .long __StackTop /* Top of Stack */ + .long Reset_Handler /* Reset Handler */ + .long NMI_Handler /* -14 NMI Handler */ + .long HardFault_Handler /* -13 Hard Fault Handler */ + .long MemManage_Handler /* -12 MPU Fault Handler */ + .long BusFault_Handler /* -11 Bus Fault Handler */ + .long UsageFault_Handler /* -10 Usage Fault Handler */ + .long 0 /* Reserved */ + .long 0 /* Reserved */ + .long 0 /* Reserved */ + .long 0 /* Reserved */ + .long SVC_Handler /* -5 SVCall Handler */ + .long DebugMon_Handler /* -4 Debug Monitor Handler */ + .long 0 /* Reserved */ + .long PendSV_Handler /* -2 PendSV Handler */ + .long SysTick_Handler /* -1 SysTick Handler */ + + /* Interrupts */ + .long Interrupt0_Handler /* 0 Interrupt 0 */ + .long Interrupt1_Handler /* 1 Interrupt 1 */ + .long Interrupt2_Handler /* 2 Interrupt 2 */ + .long Interrupt3_Handler /* 3 Interrupt 3 */ + .long Interrupt4_Handler /* 4 Interrupt 4 */ + .long Interrupt5_Handler /* 5 Interrupt 5 */ + .long Interrupt6_Handler /* 6 Interrupt 6 */ + .long Interrupt7_Handler /* 7 Interrupt 7 */ + .long Interrupt8_Handler /* 8 Interrupt 8 */ + .long Interrupt9_Handler /* 9 Interrupt 9 */ + + .space (214 * 4) /* Interrupts 10 .. 224 are left out */ +__Vectors_End: + .equ __Vectors_Size, __Vectors_End - __Vectors + .size __Vectors, . - __Vectors + + + .thumb + .section .text + .align 2 + + .thumb_func + .type Reset_Handler, %function + .globl Reset_Handler + .fnstart +Reset_Handler: + bl SystemInit + + ldr r4, =__copy_table_start__ + ldr r5, =__copy_table_end__ + +.L_loop0: + cmp r4, r5 + bge .L_loop0_done + ldr r1, [r4] + ldr r2, [r4, #4] + ldr r3, [r4, #8] + +.L_loop0_0: + subs r3, #4 + ittt ge + ldrge r0, [r1, r3] + strge r0, [r2, r3] + bge .L_loop0_0 + + adds r4, #12 + b .L_loop0 +.L_loop0_done: + + ldr r3, =__zero_table_start__ + ldr r4, =__zero_table_end__ + +.L_loop2: + cmp r3, r4 + bge .L_loop2_done + ldr r1, [r3] + ldr r2, [r3, #4] + movs r0, 0 + +.L_loop2_0: + subs r2, #4 + itt ge + strge r0, [r1, r2] + bge .L_loop2_0 + + adds r3, #8 + b .L_loop2 +.L_loop2_done: + + bl _start + + .fnend + .size Reset_Handler, . - Reset_Handler + +/* The default macro is not used for HardFault_Handler + * because this results in a poor debug illusion. + */ + .thumb_func + .type HardFault_Handler, %function + .weak HardFault_Handler + .fnstart +HardFault_Handler: + b . + .fnend + .size HardFault_Handler, . - HardFault_Handler + + .thumb_func + .type Default_Handler, %function + .weak Default_Handler + .fnstart +Default_Handler: + b . + .fnend + .size Default_Handler, . - Default_Handler + +/* Macro to define default exception/interrupt handlers. + * Default handler are weak symbols with an endless loop. + * They can be overwritten by real handlers. + */ + .macro Set_Default_Handler Handler_Name + .weak \Handler_Name + .set \Handler_Name, Default_Handler + .endm + + +/* Default exception/interrupt handler */ + + Set_Default_Handler NMI_Handler + Set_Default_Handler MemManage_Handler + Set_Default_Handler BusFault_Handler + Set_Default_Handler UsageFault_Handler + Set_Default_Handler SVC_Handler + Set_Default_Handler DebugMon_Handler + Set_Default_Handler PendSV_Handler + Set_Default_Handler SysTick_Handler + + Set_Default_Handler Interrupt0_Handler + Set_Default_Handler Interrupt1_Handler + Set_Default_Handler Interrupt2_Handler + Set_Default_Handler Interrupt3_Handler + Set_Default_Handler Interrupt4_Handler + Set_Default_Handler Interrupt5_Handler + Set_Default_Handler Interrupt6_Handler + Set_Default_Handler Interrupt7_Handler + Set_Default_Handler Interrupt8_Handler + Set_Default_Handler Interrupt9_Handler + + + .end diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/IAR/startup_ARMCM3.s b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/IAR/startup_ARMCM3.s new file mode 100644 index 0000000000..47ad2ffb99 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/IAR/startup_ARMCM3.s @@ -0,0 +1,155 @@ +;/**************************************************************************//** +; * @file startup_ARMCM3.s +; * @brief CMSIS Core Device Startup File for +; * ARMCM3 Device +; * @version V1.0.0 +; * @date 09. July 2018 +; ******************************************************************************/ +;/* +; * Copyright (c) 2009-2018 Arm Limited. All rights reserved. +; * +; * SPDX-License-Identifier: Apache-2.0 +; * +; * Licensed under the Apache License, Version 2.0 (the License); you may +; * not use this file except in compliance with the License. +; * You may obtain a copy of the License at +; * +; * www.apache.org/licenses/LICENSE-2.0 +; * +; * Unless required by applicable law or agreed to in writing, software +; * distributed under the License is distributed on an AS IS BASIS, WITHOUT +; * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +; * See the License for the specific language governing permissions and +; * limitations under the License. +; */ + +; +; The modules in this file are included in the libraries, and may be replaced +; by any user-defined modules that define the PUBLIC symbol _program_start or +; a user defined start symbol. +; To override the cstartup defined in the library, simply add your modified +; version to the workbench project. +; +; The vector table is normally located at address 0. +; When debugging in RAM, it can be located in RAM, aligned to at least 2^6. +; The name "__vector_table" has special meaning for C-SPY: +; it is where the SP start value is found, and the NVIC vector +; table register (VTOR) is initialized to this address if != 0. +; +; Cortex-M version +; + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN SystemInit + PUBLIC __vector_table + PUBLIC __vector_table_0x1c + PUBLIC __Vectors + PUBLIC __Vectors_End + PUBLIC __Vectors_Size + + DATA + +__vector_table + DCD sfe(CSTACK) ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; -14 NMI Handler + DCD HardFault_Handler ; -13 Hard Fault Handler + DCD MemManage_Handler ; -12 MPU Fault Handler + DCD BusFault_Handler ; -11 Bus Fault Handler + DCD UsageFault_Handler ; -10 Usage Fault Handler +__vector_table_0x1c + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; -5 SVCall Handler + DCD DebugMon_Handler ; -4 Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; -2 PendSV Handler + DCD SysTick_Handler ; -1 SysTick Handler + + ; Interrupts + DCD Interrupt0_Handler ; 0 Interrupt 0 + DCD Interrupt1_Handler ; 1 Interrupt 1 + DCD Interrupt2_Handler ; 2 Interrupt 2 + DCD Interrupt3_Handler ; 3 Interrupt 3 + DCD Interrupt4_Handler ; 4 Interrupt 4 + DCD Interrupt5_Handler ; 5 Interrupt 5 + DCD Interrupt6_Handler ; 6 Interrupt 6 + DCD Interrupt7_Handler ; 7 Interrupt 7 + DCD Interrupt8_Handler ; 8 Interrupt 8 + DCD Interrupt9_Handler ; 9 Interrupt 9 + + DS32 (214) ; Interrupts 10 .. 224 are left out +__Vectors_End + +__Vectors EQU __vector_table +__Vectors_Size EQU __Vectors_End - __Vectors + + + THUMB + +; Reset Handler + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + LDR R0, =__iar_program_start + BX R0 + + + PUBWEAK NMI_Handler + PUBWEAK HardFault_Handler + PUBWEAK MemManage_Handler + PUBWEAK BusFault_Handler + PUBWEAK UsageFault_Handler + PUBWEAK SVC_Handler + PUBWEAK DebugMon_Handler + PUBWEAK PendSV_Handler + PUBWEAK SysTick_Handler + + PUBWEAK Interrupt0_Handler + PUBWEAK Interrupt1_Handler + PUBWEAK Interrupt2_Handler + PUBWEAK Interrupt3_Handler + PUBWEAK Interrupt4_Handler + PUBWEAK Interrupt5_Handler + PUBWEAK Interrupt6_Handler + PUBWEAK Interrupt7_Handler + PUBWEAK Interrupt8_Handler + PUBWEAK Interrupt9_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler +HardFault_Handler +MemManage_Handler +BusFault_Handler +UsageFault_Handler +SVC_Handler +DebugMon_Handler +PendSV_Handler +SysTick_Handler + +Interrupt0_Handler +Interrupt1_Handler +Interrupt2_Handler +Interrupt3_Handler +Interrupt4_Handler +Interrupt5_Handler +Interrupt6_Handler +Interrupt7_Handler +Interrupt8_Handler +Interrupt9_Handler +Default_Handler + B . + + + END diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/startup_tae32f53xx.c b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/startup_tae32f53xx.c new file mode 100644 index 0000000000..4bb352c0bc --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/startup_tae32f53xx.c @@ -0,0 +1,302 @@ +/** + ****************************************************************************** + * @file startup_tae32f53xx.c + * @author MCD Application Team + * @brief CMSIS-Core(M) Device Startup File for a tae32f53xx(Cortex-M3) Device + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +/** @addtogroup TAE_CMSIS + * @{ + */ + +/** @defgroup TAE32F53xx_Startup TAE32F53xx Startup + * @brief TAE32F53xx Startup + * @{ + */ + + +/* Private define ------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/** @defgroup TAE32F53xx_Startup_Private_Types TAE32F53xx Startup Private Types + * @brief TAE32F53xx Startup Private Types + * @{ + */ + +/** + * @brief Exception / Interrupt Handler Function Prototype + */ +typedef void(*VECTOR_TABLE_Type)(void); + +/** + * @} + */ + +/* Private macro -------------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/** @defgroup TAE32F53xx_Startup_Private_Functions TAE32F53xx Startup Private Functions + * @brief TAE32F53xx Startup Private Functions + * @{ + */ + +/** + * @brief Default empty handler + */ +void __NO_RETURN Default_Handler(void); + +/** + * @brief Reset handler + */ +void __NO_RETURN Reset_Handler(void); + +/** + * @brief Enter PreMain (C library entry point) + */ +void __NO_RETURN __PROGRAM_START(void); + +/** + * @brief Cortex-M3 core exceptions handlers + */ +__WEAK_ALIAS_FUNC(NMI_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(HardFault_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(MemManage_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(BusFault_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(UsageFault_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(SVC_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(DebugMon_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(PendSV_Handler, Default_Handler) +__WEAK_ALIAS_FUNC(SysTick_Handler, Default_Handler) + +/** + * @brief Peripherals interrupt handlers + */ +__WEAK_ALIAS_FUNC(I2C0_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(I2C1_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(UART0_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(UART1_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR0_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR1_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR2_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR3_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(LVD_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR4_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR5_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR6_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(TMR7_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(IWDG_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(WWDG_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(IIR0_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(IIR1_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(IIR2_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(IIR3_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(IIR4_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ECU_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(DMA_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(CAN_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(GPIOA_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(GPIOB_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(GPIOC_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(GPIOD_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(FLASH_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(DFLASH_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_MSTR_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_SLV0_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_SLV1_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_SLV2_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_SLV3_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_SLV4_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_SLV5_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(HRPWM_FLT_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC0_NORM_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC0_HALF_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC0_FULL_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC0_SAMP_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC1_NORM_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC1_HALF_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC1_FULL_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(ADC1_SAMP_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(DAC_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(CMP_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(USB_STA_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(USB_DET_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(USB_LPM_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(USB_EP_IRQHandler, Default_Handler) +__WEAK_ALIAS_FUNC(DALI_IRQHandler, Default_Handler) + +/** + * @} + */ + +/* Private variables ---------------------------------------------------------*/ +/** @defgroup TAE32F53xx_Startup_Private_Variables TAE32F53xx Startup Private Variables + * @brief TAE32F53xx Startup Private Variables + * @{ + */ + +/** + * @brief Stack pointer statement + */ +extern uint32_t __INITIAL_SP; + + +#if defined (__GNUC__) /*!< GCC Compiler */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpedantic" +#endif + +/** + * @brief TAE32F53xx Vector Table Definition + */ +const VECTOR_TABLE_Type __VECTOR_TABLE[] __VECTOR_TABLE_ATTRIBUTE = { + + (VECTOR_TABLE_Type) &__INITIAL_SP, /*!< Initial Stack Pointer */ + + /* Processor Exceptions */ + Reset_Handler, /*!< Reset Handler */ + NMI_Handler, /*!< -14 NMI Handler */ + HardFault_Handler, /*!< -13 Hard Fault Handler */ + MemManage_Handler, /*!< -12 MPU Fault Handler */ + BusFault_Handler, /*!< -11 Bus Fault Handler */ + UsageFault_Handler, /*!< -10 Usage Fault Handler */ + 0, /*!< Reserved */ + 0, /*!< Reserved */ + 0, /*!< Reserved */ + 0, /*!< Reserved */ + SVC_Handler, /*!< -5 SVCall Handler */ + DebugMon_Handler, /*!< -4 Debug Monitor Handler */ + 0, /*!< Reserved */ + PendSV_Handler, /*!< -2 PendSV Handler */ + SysTick_Handler, /*!< -1 SysTick Handler */ + + /* Processor Interrupt */ + I2C0_IRQHandler, /*!< 0 I2C0 Interrupt Handler */ + I2C1_IRQHandler, /*!< 1 I2C1 Interrupt Handler */ + UART0_IRQHandler, /*!< 2 UART0 Interrupt Handler */ + UART1_IRQHandler, /*!< 3 UART1 Interrupt Handler */ + TMR0_IRQHandler, /*!< 4 TIMER0 Interrupt Handler */ + TMR1_IRQHandler, /*!< 5 TIMER1 Interrupt Handler */ + TMR2_IRQHandler, /*!< 6 TIMER2 Interrupt Handler */ + TMR3_IRQHandler, /*!< 7 TIMER3 Interrupt Handler */ + LVD_IRQHandler, /*!< 8 LVD Interrupt Handler */ + TMR4_IRQHandler, /*!< 9 TIMER4 Interrupt Handler */ + TMR5_IRQHandler, /*!< 10 TIMER5 Interrupt Handler */ + TMR6_IRQHandler, /*!< 11 TIMER6 Interrupt Handler */ + TMR7_IRQHandler, /*!< 12 TIMER7 Interrupt Handler */ + IWDG_IRQHandler, /*!< 13 IWDG Interrupt Handler */ + WWDG_IRQHandler, /*!< 14 WWDG Interrupt Handler */ + IIR0_IRQHandler, /*!< 15 IIR0 Interrupt Handler */ + IIR1_IRQHandler, /*!< 16 IIR1 Interrupt Handler */ + IIR2_IRQHandler, /*!< 17 IIR2 Interrupt Handler */ + IIR3_IRQHandler, /*!< 18 IIR3 Interrupt Handler */ + IIR4_IRQHandler, /*!< 19 IIR4 Interrupt Handler */ + ECU_IRQHandler, /*!< 20 ECU Interrupt Handler */ + DMA_IRQHandler, /*!< 21 DMA Interrupt Handler */ + CAN_IRQHandler, /*!< 22 CAN Interrupt Handler */ + GPIOA_IRQHandler, /*!< 23 GPIOA Interrupt Handler */ + GPIOB_IRQHandler, /*!< 24 GPIOB Interrupt Handler */ + GPIOC_IRQHandler, /*!< 25 GPIOC Interrupt Handler */ + GPIOD_IRQHandler, /*!< 26 GPIOD Interrupt Handler */ + FLASH_IRQHandler, /*!< 27 FLASH Interrupt Handler */ + DFLASH_IRQHandler, /*!< 28 DFLASH Interrupt Handler */ + HRPWM_MSTR_IRQHandler, /*!< 29 HRPWM Master Interrupt Handler */ + HRPWM_SLV0_IRQHandler, /*!< 30 HRPWM Slave0 Interrupt Handler */ + HRPWM_SLV1_IRQHandler, /*!< 31 HRPWM Slave1 Interrupt Handler */ + HRPWM_SLV2_IRQHandler, /*!< 32 HRPWM Slave2 Interrupt Handler */ + HRPWM_SLV3_IRQHandler, /*!< 33 HRPWM Slave3 Interrupt Handler */ + HRPWM_SLV4_IRQHandler, /*!< 34 HRPWM Slave4 Interrupt Handler */ + HRPWM_SLV5_IRQHandler, /*!< 35 HRPWM Slave5 Interrupt Handler */ + HRPWM_FLT_IRQHandler, /*!< 36 HRPWM Fault Interrupt Handler */ + ADC0_NORM_IRQHandler, /*!< 37 ADC0 Normal Interrupt Handler */ + ADC0_HALF_IRQHandler, /*!< 38 ADC0 Half Interrupt Handler */ + ADC0_FULL_IRQHandler, /*!< 39 ADC0 Full Interrupt Handler */ + ADC0_SAMP_IRQHandler, /*!< 40 ADC0 Sample Interrupt Handler */ + ADC1_NORM_IRQHandler, /*!< 41 ADC1 Normal Interrupt Handler */ + ADC1_HALF_IRQHandler, /*!< 42 ADC1 Half Interrupt Handler */ + ADC1_FULL_IRQHandler, /*!< 43 ADC1 Full Interrupt Handler */ + ADC1_SAMP_IRQHandler, /*!< 44 ADC1 Sample Interrupt Handler */ + DAC_IRQHandler, /*!< 45 DAC Interrupt Handler */ + CMP_IRQHandler, /*!< 46 CMP Interrupt Handler */ + USB_STA_IRQHandler, /*!< 47 USB Status Interrupt Handler */ + USB_DET_IRQHandler, /*!< 48 USB Detect Interrupt Handler */ + USB_LPM_IRQHandler, /*!< 49 USB LPM Interrupt Handler */ + USB_EP_IRQHandler, /*!< 50 USB Endpoint Interrupt Handler */ + DALI_IRQHandler, /*!< 51 DALI Interrupt Handler */ +}; + +#if defined (__GNUC__) /*!< GCC Compiler */ + #pragma GCC diagnostic pop +#endif + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ +/** @defgroup TAE32F53xx_Startup_Private_Functions TAE32F53xx Startup Private Functions + * @brief TAE32F53xx Startup Private Functions + * @{ + */ + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + +/** + * @brief Reset Handler called on controller reset + * @param None + * @return None + */ +void Reset_Handler(void) +{ + SystemInit(); /* CMSIS System Initialization */ + __PROGRAM_START(); /* Enter PreMain (C library entry point) */ +} + +/** + * @brief Default Handler for Exceptions / Interrupts + * @param None + * @return None + */ +void Default_Handler(void) +{ + while (1); +} + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#endif + +/** + * @} + */ + + + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/system_tae32f53xx.c b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/system_tae32f53xx.c new file mode 100644 index 0000000000..d391ba4c97 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Device/Tai_action/TAE32F53xx/Source/system_tae32f53xx.c @@ -0,0 +1,146 @@ +/** + ****************************************************************************** + * @file system_tae32f53xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. + * + * + * 1. This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): Setups the system interrupt vector. + * This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_tae32f53xx.c" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * 2. After each device reset the LSI (32 KHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_tae32f53xx.c" file, to + * configure the system clock before to branch to main program. + * + * 3. The default value of HSE crystal is set to 8 MHz, refer to "HSE_VALUE". + * When HSE is used as system clock source, directly or through PLL, and you + * are using different crystal you have to adapt the HSE value to your own + * configuration. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx.h" + + +/** @addtogroup TAE_CMSIS + * @{ + */ + +/** @defgroup TAE32F53xx_System TAE32F53xx System + * @brief TAE32F53xx System + * @{ + */ + + +/* Private typedef -----------------------------------------------------------*/ +/* Private defines -----------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/** @defgroup TAE32F53xx_System_Private_Variables TAE32F53xx System Private Variables + * @brief TAE32F53xx System Private Variables + * @{ + */ + +/** + * @brief Import the Interrupt Vector Table + */ +extern void (* const __VECTOR_TABLE[])(void) ; + +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------*/ +/* Exported variables --------------------------------------------------------*/ +/** @defgroup TAE32F53xx_System_Exported_Variables TAE32F53xx System Exported Variables + * @brief TAE32F53xx System Exported Variables + * @{ + */ + +/** + * @brief SYSCLK System Clock Frequency (Core Clock), default value 32K. + * @note This variable is updated by calling SystemCoreClockUpdate() + */ +uint32_t SystemCoreClock = 32000UL; + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup TAE32F53xx_System_Exported_Functions TAE32F53xx System Exported Functions + * @brief TAE32F53xx System Exported Functions + * @{ + */ + +/** + * @brief Initialize the Interrupt Vector. + * @note This function should be used only after reset. + * @param None + * @return None + */ +void SystemInit(void) +{ + //Interrupt Vector Config + SCB->VTOR = (uint32_t)__VECTOR_TABLE; +} + +/** + * @brief Update SystemCoreClock variable + * @note Each time the system core clock changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * @note The system frequency update by this function is not the real + * frequency in the chip. + * @param None + * @retval None + */ +void SystemCoreClockUpdate(uint32_t sysclk) +{ + if (sysclk) { + SystemCoreClock = sysclk; + } +} + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/arm_common_tables.h b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_common_tables.h new file mode 100644 index 0000000000..721b18dd2d --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_common_tables.h @@ -0,0 +1,517 @@ +/* ---------------------------------------------------------------------- + * Project: CMSIS DSP Library + * Title: arm_common_tables.h + * Description: Extern declaration for common tables + * + * $Date: 27. January 2017 + * $Revision: V.1.5.1 + * + * Target Processor: Cortex-M cores + * -------------------------------------------------------------------- */ +/* + * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ARM_COMMON_TABLES_H +#define _ARM_COMMON_TABLES_H + +#include "arm_math.h" + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) + /* Double Precision Float CFFT twiddles */ + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREV_1024) + extern const uint16_t armBitRevTable[1024]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_16) + extern const uint64_t twiddleCoefF64_16[32]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_32) + extern const uint64_t twiddleCoefF64_32[64]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_64) + extern const uint64_t twiddleCoefF64_64[128]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_128) + extern const uint64_t twiddleCoefF64_128[256]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_256) + extern const uint64_t twiddleCoefF64_256[512]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_512) + extern const uint64_t twiddleCoefF64_512[1024]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_1024) + extern const uint64_t twiddleCoefF64_1024[2048]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_2048) + extern const uint64_t twiddleCoefF64_2048[4096]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F64_4096) + extern const uint64_t twiddleCoefF64_4096[8192]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_16) + extern const float32_t twiddleCoef_16[32]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_32) + extern const float32_t twiddleCoef_32[64]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_64) + extern const float32_t twiddleCoef_64[128]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_128) + extern const float32_t twiddleCoef_128[256]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_256) + extern const float32_t twiddleCoef_256[512]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_512) + extern const float32_t twiddleCoef_512[1024]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_1024) + extern const float32_t twiddleCoef_1024[2048]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_2048) + extern const float32_t twiddleCoef_2048[4096]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_4096) + extern const float32_t twiddleCoef_4096[8192]; + #define twiddleCoef twiddleCoef_4096 + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_16) + extern const q31_t twiddleCoef_16_q31[24]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_32) + extern const q31_t twiddleCoef_32_q31[48]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_64) + extern const q31_t twiddleCoef_64_q31[96]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_128) + extern const q31_t twiddleCoef_128_q31[192]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_256) + extern const q31_t twiddleCoef_256_q31[384]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_512) + extern const q31_t twiddleCoef_512_q31[768]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_1024) + extern const q31_t twiddleCoef_1024_q31[1536]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_2048) + extern const q31_t twiddleCoef_2048_q31[3072]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_4096) + extern const q31_t twiddleCoef_4096_q31[6144]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_16) + extern const q15_t twiddleCoef_16_q15[24]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_32) + extern const q15_t twiddleCoef_32_q15[48]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_64) + extern const q15_t twiddleCoef_64_q15[96]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_128) + extern const q15_t twiddleCoef_128_q15[192]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_256) + extern const q15_t twiddleCoef_256_q15[384]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_512) + extern const q15_t twiddleCoef_512_q15[768]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_1024) + extern const q15_t twiddleCoef_1024_q15[1536]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_2048) + extern const q15_t twiddleCoef_2048_q15[3072]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_4096) + extern const q15_t twiddleCoef_4096_q15[6144]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + /* Double Precision Float RFFT twiddles */ + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_32) + extern const uint64_t twiddleCoefF64_rfft_32[32]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_64) + extern const uint64_t twiddleCoefF64_rfft_64[64]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_128) + extern const uint64_t twiddleCoefF64_rfft_128[128]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_256) + extern const uint64_t twiddleCoefF64_rfft_256[256]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_512) + extern const uint64_t twiddleCoefF64_rfft_512[512]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_1024) + extern const uint64_t twiddleCoefF64_rfft_1024[1024]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_2048) + extern const uint64_t twiddleCoefF64_rfft_2048[2048]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F64_4096) + extern const uint64_t twiddleCoefF64_rfft_4096[4096]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_32) + extern const float32_t twiddleCoef_rfft_32[32]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_64) + extern const float32_t twiddleCoef_rfft_64[64]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_128) + extern const float32_t twiddleCoef_rfft_128[128]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_256) + extern const float32_t twiddleCoef_rfft_256[256]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_512) + extern const float32_t twiddleCoef_rfft_512[512]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_1024) + extern const float32_t twiddleCoef_rfft_1024[1024]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_2048) + extern const float32_t twiddleCoef_rfft_2048[2048]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_RFFT_F32_4096) + extern const float32_t twiddleCoef_rfft_4096[4096]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + + /* Double precision floating-point bit reversal tables */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_16) + #define ARMBITREVINDEXTABLEF64_16_TABLE_LENGTH ((uint16_t)12) + extern const uint16_t armBitRevIndexTableF64_16[ARMBITREVINDEXTABLEF64_16_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_32) + #define ARMBITREVINDEXTABLEF64_32_TABLE_LENGTH ((uint16_t)24) + extern const uint16_t armBitRevIndexTableF64_32[ARMBITREVINDEXTABLEF64_32_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_64) + #define ARMBITREVINDEXTABLEF64_64_TABLE_LENGTH ((uint16_t)56) + extern const uint16_t armBitRevIndexTableF64_64[ARMBITREVINDEXTABLEF64_64_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_128) + #define ARMBITREVINDEXTABLEF64_128_TABLE_LENGTH ((uint16_t)112) + extern const uint16_t armBitRevIndexTableF64_128[ARMBITREVINDEXTABLEF64_128_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_256) + #define ARMBITREVINDEXTABLEF64_256_TABLE_LENGTH ((uint16_t)240) + extern const uint16_t armBitRevIndexTableF64_256[ARMBITREVINDEXTABLEF64_256_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_512) + #define ARMBITREVINDEXTABLEF64_512_TABLE_LENGTH ((uint16_t)480) + extern const uint16_t armBitRevIndexTableF64_512[ARMBITREVINDEXTABLEF64_512_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_1024) + #define ARMBITREVINDEXTABLEF64_1024_TABLE_LENGTH ((uint16_t)992) + extern const uint16_t armBitRevIndexTableF64_1024[ARMBITREVINDEXTABLEF64_1024_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_2048) + #define ARMBITREVINDEXTABLEF64_2048_TABLE_LENGTH ((uint16_t)1984) + extern const uint16_t armBitRevIndexTableF64_2048[ARMBITREVINDEXTABLEF64_2048_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT64_4096) + #define ARMBITREVINDEXTABLEF64_4096_TABLE_LENGTH ((uint16_t)4032) + extern const uint16_t armBitRevIndexTableF64_4096[ARMBITREVINDEXTABLEF64_4096_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + /* floating-point bit reversal tables */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_16) + #define ARMBITREVINDEXTABLE_16_TABLE_LENGTH ((uint16_t)20) + extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE_16_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_32) + #define ARMBITREVINDEXTABLE_32_TABLE_LENGTH ((uint16_t)48) + extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE_32_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_64) + #define ARMBITREVINDEXTABLE_64_TABLE_LENGTH ((uint16_t)56) + extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE_64_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_128) + #define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208) + extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_256) + #define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440) + extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_512) + #define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448) + extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_1024) + #define ARMBITREVINDEXTABLE_1024_TABLE_LENGTH ((uint16_t)1800) + extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE_1024_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_2048) + #define ARMBITREVINDEXTABLE_2048_TABLE_LENGTH ((uint16_t)3808) + extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE_2048_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FLT_4096) + #define ARMBITREVINDEXTABLE_4096_TABLE_LENGTH ((uint16_t)4032) + extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE_4096_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + + /* fixed-point bit reversal tables */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_16) + #define ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH ((uint16_t)12) + extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_32) + #define ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH ((uint16_t)24) + extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_64) + #define ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH ((uint16_t)56) + extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_128) + #define ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH ((uint16_t)112) + extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_256) + #define ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH ((uint16_t)240) + extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_512) + #define ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH ((uint16_t)480) + extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_1024) + #define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992) + extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_2048) + #define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) + extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_BITREVIDX_FXT_4096) + #define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) + extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_F32) + extern const float32_t realCoefA[8192]; + extern const float32_t realCoefB[8192]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_Q31) + extern const q31_t realCoefAQ31[8192]; + extern const q31_t realCoefBQ31[8192]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_REALCOEF_Q15) + extern const q15_t realCoefAQ15[8192]; + extern const q15_t realCoefBQ15[8192]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_128) + extern const float32_t Weights_128[256]; + extern const float32_t cos_factors_128[128]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_512) + extern const float32_t Weights_512[1024]; + extern const float32_t cos_factors_512[512]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_2048) + extern const float32_t Weights_2048[4096]; + extern const float32_t cos_factors_2048[2048]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_F32_8192) + extern const float32_t Weights_8192[16384]; + extern const float32_t cos_factors_8192[8192]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_128) + extern const q15_t WeightsQ15_128[256]; + extern const q15_t cos_factorsQ15_128[128]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_512) + extern const q15_t WeightsQ15_512[1024]; + extern const q15_t cos_factorsQ15_512[512]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_2048) + extern const q15_t WeightsQ15_2048[4096]; + extern const q15_t cos_factorsQ15_2048[2048]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q15_8192) + extern const q15_t WeightsQ15_8192[16384]; + extern const q15_t cos_factorsQ15_8192[8192]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_128) + extern const q31_t WeightsQ31_128[256]; + extern const q31_t cos_factorsQ31_128[128]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_512) + extern const q31_t WeightsQ31_512[1024]; + extern const q31_t cos_factorsQ31_512[512]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_2048) + extern const q31_t WeightsQ31_2048[4096]; + extern const q31_t cos_factorsQ31_2048[2048]; + #endif + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_DCT4_Q31_8192) + extern const q31_t WeightsQ31_8192[16384]; + extern const q31_t cos_factorsQ31_8192[8192]; + #endif + +#endif /* if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_TABLES) */ + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FAST_ALLOW_TABLES) + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_RECIP_Q15) + extern const q15_t armRecipTableQ15[64]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_RECIP_Q31) + extern const q31_t armRecipTableQ31[64]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ + + /* Tables for Fast Math Sine and Cosine */ + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_F32) + extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_Q31) + extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ + + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_SIN_Q15) + extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ + + #if defined(ARM_MATH_MVEI) + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_FAST_SQRT_Q31_MVE) + extern const q31_t sqrtTable_Q31[256]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ + #endif + + #if defined(ARM_MATH_MVEI) + #if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_FAST_SQRT_Q15_MVE) + extern const q15_t sqrtTable_Q15[256]; + #endif /* !defined(ARM_DSP_CONFIG_TABLES) defined(ARM_ALL_FAST_TABLES) */ + #endif + +#endif /* if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FAST_TABLES) */ + +#if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE) + extern const float32_t exp_tab[8]; + extern const float32_t __logf_lut_f32[8]; +#endif /* (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE) */ + +#if (defined(ARM_MATH_MVEI) || defined(ARM_MATH_HELIUM)) +extern const unsigned char hwLUT[256]; +#endif /* (defined(ARM_MATH_MVEI) || defined(ARM_MATH_HELIUM)) */ + +#endif /* ARM_COMMON_TABLES_H */ + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/arm_const_structs.h b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_const_structs.h new file mode 100644 index 0000000000..83984c40cd --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_const_structs.h @@ -0,0 +1,76 @@ +/* ---------------------------------------------------------------------- + * Project: CMSIS DSP Library + * Title: arm_const_structs.h + * Description: Constant structs that are initialized for user convenience. + * For example, some can be given as arguments to the arm_cfft_f32() function. + * + * $Date: 27. January 2017 + * $Revision: V.1.5.1 + * + * Target Processor: Cortex-M cores + * -------------------------------------------------------------------- */ +/* + * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ARM_CONST_STRUCTS_H +#define _ARM_CONST_STRUCTS_H + +#include "arm_math.h" +#include "arm_common_tables.h" + + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len16; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len32; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len64; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len128; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len256; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len512; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len1024; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len2048; + extern const arm_cfft_instance_f64 arm_cfft_sR_f64_len4096; + + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048; + extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096; + + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048; + extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096; + + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048; + extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096; + +#endif diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/arm_helium_utils.h b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_helium_utils.h new file mode 100644 index 0000000000..7609d329f0 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_helium_utils.h @@ -0,0 +1,348 @@ +/* ---------------------------------------------------------------------- + * Project: CMSIS DSP Library + * Title: arm_helium_utils.h + * Description: Utility functions for Helium development + * + * $Date: 09. September 2019 + * $Revision: V.1.5.1 + * + * Target Processor: Cortex-M cores + * -------------------------------------------------------------------- */ +/* + * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ARM_UTILS_HELIUM_H_ +#define _ARM_UTILS_HELIUM_H_ + +/*************************************** + +Definitions available for MVEF and MVEI + +***************************************/ +#if defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) || defined(ARM_MATH_MVEI) + +#define INACTIVELANE 0 /* inactive lane content */ + + +#endif /* defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) || defined(ARM_MATH_MVEI) */ + +/*************************************** + +Definitions available for MVEF only + +***************************************/ +#if defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) + +__STATIC_FORCEINLINE float32_t vecAddAcrossF32Mve(float32x4_t in) +{ + float32_t acc; + + acc = vgetq_lane(in, 0) + vgetq_lane(in, 1) + + vgetq_lane(in, 2) + vgetq_lane(in, 3); + + return acc; +} + +/* newton initial guess */ +#define INVSQRT_MAGIC_F32 0x5f3759df + +#define INVSQRT_NEWTON_MVE_F32(invSqrt, xHalf, xStart)\ +{ \ + float32x4_t tmp; \ + \ + /* tmp = xhalf * x * x */ \ + tmp = vmulq(xStart, xStart); \ + tmp = vmulq(tmp, xHalf); \ + /* (1.5f - xhalf * x * x) */ \ + tmp = vsubq(vdupq_n_f32(1.5f), tmp); \ + /* x = x*(1.5f-xhalf*x*x); */ \ + invSqrt = vmulq(tmp, xStart); \ +} +#endif /* defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) */ + +/*************************************** + +Definitions available for MVEI only + +***************************************/ +#if defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEI) + + +#include "arm_common_tables.h" + +/* Following functions are used to transpose matrix in f32 and q31 cases */ +__STATIC_INLINE arm_status arm_mat_trans_32bit_2x2_mve( + uint32_t * pDataSrc, + uint32_t * pDataDest) +{ + static const uint32x4_t vecOffs = { 0, 2, 1, 3 }; + /* + * + * | 0 1 | => | 0 2 | + * | 2 3 | | 1 3 | + * + */ + uint32x4_t vecIn = vldrwq_u32((uint32_t const *)pDataSrc); + vstrwq_scatter_shifted_offset_u32(pDataDest, vecOffs, vecIn); + + return (ARM_MATH_SUCCESS); +} + +__STATIC_INLINE arm_status arm_mat_trans_32bit_3x3_mve( + uint32_t * pDataSrc, + uint32_t * pDataDest) +{ + const uint32x4_t vecOffs1 = { 0, 3, 6, 1}; + const uint32x4_t vecOffs2 = { 4, 7, 2, 5}; + /* + * + * | 0 1 2 | | 0 3 6 | 4 x 32 flattened version | 0 3 6 1 | + * | 3 4 5 | => | 1 4 7 | => | 4 7 2 5 | + * | 6 7 8 | | 2 5 8 | (row major) | 8 . . . | + * + */ + uint32x4_t vecIn1 = vldrwq_u32((uint32_t const *) pDataSrc); + uint32x4_t vecIn2 = vldrwq_u32((uint32_t const *) &pDataSrc[4]); + + vstrwq_scatter_shifted_offset_u32(pDataDest, vecOffs1, vecIn1); + vstrwq_scatter_shifted_offset_u32(pDataDest, vecOffs2, vecIn2); + + pDataDest[8] = pDataSrc[8]; + + return (ARM_MATH_SUCCESS); +} + +__STATIC_INLINE arm_status arm_mat_trans_32bit_4x4_mve(uint32_t * pDataSrc, uint32_t * pDataDest) +{ + /* + * 4x4 Matrix transposition + * is 4 x de-interleave operation + * + * 0 1 2 3 0 4 8 12 + * 4 5 6 7 1 5 9 13 + * 8 9 10 11 2 6 10 14 + * 12 13 14 15 3 7 11 15 + */ + + uint32x4x4_t vecIn; + + vecIn = vld4q((uint32_t const *) pDataSrc); + vstrwq(pDataDest, vecIn.val[0]); + pDataDest += 4; + vstrwq(pDataDest, vecIn.val[1]); + pDataDest += 4; + vstrwq(pDataDest, vecIn.val[2]); + pDataDest += 4; + vstrwq(pDataDest, vecIn.val[3]); + + return (ARM_MATH_SUCCESS); +} + + +__STATIC_INLINE arm_status arm_mat_trans_32bit_generic_mve( + uint16_t srcRows, + uint16_t srcCols, + uint32_t * pDataSrc, + uint32_t * pDataDest) +{ + uint32x4_t vecOffs; + uint32_t i; + uint32_t blkCnt; + uint32_t const *pDataC; + uint32_t *pDataDestR; + uint32x4_t vecIn; + + vecOffs = vidupq_u32((uint32_t)0, 1); + vecOffs = vecOffs * srcCols; + + i = srcCols; + do + { + pDataC = (uint32_t const *) pDataSrc; + pDataDestR = pDataDest; + + blkCnt = srcRows >> 2; + while (blkCnt > 0U) + { + vecIn = vldrwq_gather_shifted_offset_u32(pDataC, vecOffs); + vstrwq(pDataDestR, vecIn); + pDataDestR += 4; + pDataC = pDataC + srcCols * 4; + /* + * Decrement the blockSize loop counter + */ + blkCnt--; + } + + /* + * tail + */ + blkCnt = srcRows & 3; + if (blkCnt > 0U) + { + mve_pred16_t p0 = vctp32q(blkCnt); + vecIn = vldrwq_gather_shifted_offset_u32(pDataC, vecOffs); + vstrwq_p(pDataDestR, vecIn, p0); + } + + pDataSrc += 1; + pDataDest += srcRows; + } + while (--i); + + return (ARM_MATH_SUCCESS); +} + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_FAST_SQRT_Q31_MVE) +__STATIC_INLINE q31x4_t FAST_VSQRT_Q31(q31x4_t vecIn) +{ + q63x2_t vecTmpLL; + q31x4_t vecTmp0, vecTmp1; + q31_t scale; + q63_t tmp64; + q31x4_t vecNrm, vecDst, vecIdx, vecSignBits; + + + vecSignBits = vclsq(vecIn); + vecSignBits = vbicq(vecSignBits, 1); + /* + * in = in << no_of_sign_bits; + */ + vecNrm = vshlq(vecIn, vecSignBits); + /* + * index = in >> 24; + */ + vecIdx = vecNrm >> 24; + vecIdx = vecIdx << 1; + + vecTmp0 = vldrwq_gather_shifted_offset_s32(sqrtTable_Q31, vecIdx); + + vecIdx = vecIdx + 1; + + vecTmp1 = vldrwq_gather_shifted_offset_s32(sqrtTable_Q31, vecIdx); + + vecTmp1 = vqrdmulhq(vecTmp1, vecNrm); + vecTmp0 = vecTmp0 - vecTmp1; + vecTmp1 = vqrdmulhq(vecTmp0, vecTmp0); + vecTmp1 = vqrdmulhq(vecNrm, vecTmp1); + vecTmp1 = vdupq_n_s32(0x18000000) - vecTmp1; + vecTmp0 = vqrdmulhq(vecTmp0, vecTmp1); + vecTmpLL = vmullbq_int(vecNrm, vecTmp0); + + /* + * scale elements 0, 2 + */ + scale = 26 + (vecSignBits[0] >> 1); + tmp64 = asrl(vecTmpLL[0], scale); + vecDst[0] = (q31_t) tmp64; + + scale = 26 + (vecSignBits[2] >> 1); + tmp64 = asrl(vecTmpLL[1], scale); + vecDst[2] = (q31_t) tmp64; + + vecTmpLL = vmulltq_int(vecNrm, vecTmp0); + + /* + * scale elements 1, 3 + */ + scale = 26 + (vecSignBits[1] >> 1); + tmp64 = asrl(vecTmpLL[0], scale); + vecDst[1] = (q31_t) tmp64; + + scale = 26 + (vecSignBits[3] >> 1); + tmp64 = asrl(vecTmpLL[1], scale); + vecDst[3] = (q31_t) tmp64; + /* + * set negative values to 0 + */ + vecDst = vdupq_m(vecDst, 0, vcmpltq_n_s32(vecIn, 0)); + + return vecDst; +} +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FAST_TABLES) || defined(ARM_TABLE_FAST_SQRT_Q15_MVE) +__STATIC_INLINE q15x8_t FAST_VSQRT_Q15(q15x8_t vecIn) +{ + q31x4_t vecTmpLev, vecTmpLodd, vecSignL; + q15x8_t vecTmp0, vecTmp1; + q15x8_t vecNrm, vecDst, vecIdx, vecSignBits; + + vecDst = vuninitializedq_s16(); + + vecSignBits = vclsq(vecIn); + vecSignBits = vbicq(vecSignBits, 1); + /* + * in = in << no_of_sign_bits; + */ + vecNrm = vshlq(vecIn, vecSignBits); + + vecIdx = vecNrm >> 8; + vecIdx = vecIdx << 1; + + vecTmp0 = vldrhq_gather_shifted_offset_s16(sqrtTable_Q15, vecIdx); + + vecIdx = vecIdx + 1; + + vecTmp1 = vldrhq_gather_shifted_offset_s16(sqrtTable_Q15, vecIdx); + + vecTmp1 = vqrdmulhq(vecTmp1, vecNrm); + vecTmp0 = vecTmp0 - vecTmp1; + vecTmp1 = vqrdmulhq(vecTmp0, vecTmp0); + vecTmp1 = vqrdmulhq(vecNrm, vecTmp1); + vecTmp1 = vdupq_n_s16(0x1800) - vecTmp1; + vecTmp0 = vqrdmulhq(vecTmp0, vecTmp1); + + vecSignBits = vecSignBits >> 1; + + vecTmpLev = vmullbq_int(vecNrm, vecTmp0); + vecTmpLodd = vmulltq_int(vecNrm, vecTmp0); + + vecTmp0 = vecSignBits + 10; + /* + * negate sign to apply register based vshl + */ + vecTmp0 = -vecTmp0; + + /* + * shift even elements + */ + vecSignL = vmovlbq(vecTmp0); + vecTmpLev = vshlq(vecTmpLev, vecSignL); + /* + * shift odd elements + */ + vecSignL = vmovltq(vecTmp0); + vecTmpLodd = vshlq(vecTmpLodd, vecSignL); + /* + * merge and narrow odd and even parts + */ + vecDst = vmovnbq_s32(vecDst, vecTmpLev); + vecDst = vmovntq_s32(vecDst, vecTmpLodd); + /* + * set negative values to 0 + */ + vecDst = vdupq_m(vecDst, 0, vcmpltq_n_s16(vecIn, 0)); + + return vecDst; +} +#endif + +#endif /* defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEI) */ + +#endif diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/arm_math.h b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_math.h new file mode 100644 index 0000000000..48bee62cd9 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_math.h @@ -0,0 +1,8970 @@ +/****************************************************************************** + * @file arm_math.h + * @brief Public header file for CMSIS DSP Library + * @version V1.7.0 + * @date 18. March 2019 + ******************************************************************************/ +/* + * Copyright (c) 2010-2019 Arm Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + \mainpage CMSIS DSP Software Library + * + * Introduction + * ------------ + * + * This user manual describes the CMSIS DSP software library, + * a suite of common signal processing functions for use on Cortex-M and Cortex-A processor + * based devices. + * + * The library is divided into a number of functions each covering a specific category: + * - Basic math functions + * - Fast math functions + * - Complex math functions + * - Filtering functions + * - Matrix functions + * - Transform functions + * - Motor control functions + * - Statistical functions + * - Support functions + * - Interpolation functions + * - Support Vector Machine functions (SVM) + * - Bayes classifier functions + * - Distance functions + * + * The library has generally separate functions for operating on 8-bit integers, 16-bit integers, + * 32-bit integer and 32-bit floating-point values. + * + * Using the Library + * ------------ + * + * The library installer contains prebuilt versions of the libraries in the Lib folder. + * + * Here is the list of pre-built libraries : + * - arm_cortexM7lfdp_math.lib (Cortex-M7, Little endian, Double Precision Floating Point Unit) + * - arm_cortexM7bfdp_math.lib (Cortex-M7, Big endian, Double Precision Floating Point Unit) + * - arm_cortexM7lfsp_math.lib (Cortex-M7, Little endian, Single Precision Floating Point Unit) + * - arm_cortexM7bfsp_math.lib (Cortex-M7, Big endian and Single Precision Floating Point Unit on) + * - arm_cortexM7l_math.lib (Cortex-M7, Little endian) + * - arm_cortexM7b_math.lib (Cortex-M7, Big endian) + * - arm_cortexM4lf_math.lib (Cortex-M4, Little endian, Floating Point Unit) + * - arm_cortexM4bf_math.lib (Cortex-M4, Big endian, Floating Point Unit) + * - arm_cortexM4l_math.lib (Cortex-M4, Little endian) + * - arm_cortexM4b_math.lib (Cortex-M4, Big endian) + * - arm_cortexM3l_math.lib (Cortex-M3, Little endian) + * - arm_cortexM3b_math.lib (Cortex-M3, Big endian) + * - arm_cortexM0l_math.lib (Cortex-M0 / Cortex-M0+, Little endian) + * - arm_cortexM0b_math.lib (Cortex-M0 / Cortex-M0+, Big endian) + * - arm_ARMv8MBLl_math.lib (Armv8-M Baseline, Little endian) + * - arm_ARMv8MMLl_math.lib (Armv8-M Mainline, Little endian) + * - arm_ARMv8MMLlfsp_math.lib (Armv8-M Mainline, Little endian, Single Precision Floating Point Unit) + * - arm_ARMv8MMLld_math.lib (Armv8-M Mainline, Little endian, DSP instructions) + * - arm_ARMv8MMLldfsp_math.lib (Armv8-M Mainline, Little endian, DSP instructions, Single Precision Floating Point Unit) + * + * The library functions are declared in the public file arm_math.h which is placed in the Include folder. + * Simply include this file and link the appropriate library in the application and begin calling the library functions. The Library supports single + * public header file arm_math.h for Cortex-M cores with little endian and big endian. Same header file will be used for floating point unit(FPU) variants. + * + * + * Examples + * -------- + * + * The library ships with a number of examples which demonstrate how to use the library functions. + * + * Toolchain Support + * ------------ + * + * The library is now tested on Fast Models building with cmake. + * Core M0, M7, A5 are tested. + * + * + * + * Building the Library + * ------------ + * + * The library installer contains a project file to rebuild libraries on MDK toolchain in the CMSIS\\DSP\\Projects\\ARM folder. + * - arm_cortexM_math.uvprojx + * + * + * The libraries can be built by opening the arm_cortexM_math.uvprojx project in MDK-ARM, selecting a specific target, and defining the optional preprocessor macros detailed above. + * + * There is also a work in progress cmake build. The README file is giving more details. + * + * Preprocessor Macros + * ------------ + * + * Each library project have different preprocessor macros. + * + * - ARM_MATH_BIG_ENDIAN: + * + * Define macro ARM_MATH_BIG_ENDIAN to build the library for big endian targets. By default library builds for little endian targets. + * + * - ARM_MATH_MATRIX_CHECK: + * + * Define macro ARM_MATH_MATRIX_CHECK for checking on the input and output sizes of matrices + * + * - ARM_MATH_ROUNDING: + * + * Define macro ARM_MATH_ROUNDING for rounding on support functions + * + * - ARM_MATH_LOOPUNROLL: + * + * Define macro ARM_MATH_LOOPUNROLL to enable manual loop unrolling in DSP functions + * + * - ARM_MATH_NEON: + * + * Define macro ARM_MATH_NEON to enable Neon versions of the DSP functions. + * It is not enabled by default when Neon is available because performances are + * dependent on the compiler and target architecture. + * + * - ARM_MATH_NEON_EXPERIMENTAL: + * + * Define macro ARM_MATH_NEON_EXPERIMENTAL to enable experimental Neon versions of + * of some DSP functions. Experimental Neon versions currently do not have better + * performances than the scalar versions. + * + * - ARM_MATH_HELIUM: + * + * It implies the flags ARM_MATH_MVEF and ARM_MATH_MVEI and ARM_MATH_FLOAT16. + * + * - ARM_MATH_MVEF: + * + * Select Helium versions of the f32 algorithms. + * It implies ARM_MATH_FLOAT16 and ARM_MATH_MVEI. + * + * - ARM_MATH_MVEI: + * + * Select Helium versions of the int and fixed point algorithms. + * + * - ARM_MATH_FLOAT16: + * + * Float16 implementations of some algorithms (Requires MVE extension). + * + *
+ * CMSIS-DSP in ARM::CMSIS Pack + * ----------------------------- + * + * The following files relevant to CMSIS-DSP are present in the ARM::CMSIS Pack directories: + * |File/Folder |Content | + * |---------------------------------|------------------------------------------------------------------------| + * |\b CMSIS\\Documentation\\DSP | This documentation | + * |\b CMSIS\\DSP\\DSP_Lib_TestSuite | DSP_Lib test suite | + * |\b CMSIS\\DSP\\Examples | Example projects demonstrating the usage of the library functions | + * |\b CMSIS\\DSP\\Include | DSP_Lib include files | + * |\b CMSIS\\DSP\\Lib | DSP_Lib binaries | + * |\b CMSIS\\DSP\\Projects | Projects to rebuild DSP_Lib binaries | + * |\b CMSIS\\DSP\\Source | DSP_Lib source files | + * + *
+ * Revision History of CMSIS-DSP + * ------------ + * Please refer to \ref ChangeLog_pg. + */ + + +/** + * @defgroup groupMath Basic Math Functions + */ + +/** + * @defgroup groupFastMath Fast Math Functions + * This set of functions provides a fast approximation to sine, cosine, and square root. + * As compared to most of the other functions in the CMSIS math library, the fast math functions + * operate on individual values and not arrays. + * There are separate functions for Q15, Q31, and floating-point data. + * + */ + +/** + * @defgroup groupCmplxMath Complex Math Functions + * This set of functions operates on complex data vectors. + * The data in the complex arrays is stored in an interleaved fashion + * (real, imag, real, imag, ...). + * In the API functions, the number of samples in a complex array refers + * to the number of complex values; the array contains twice this number of + * real values. + */ + +/** + * @defgroup groupFilters Filtering Functions + */ + +/** + * @defgroup groupMatrix Matrix Functions + * + * This set of functions provides basic matrix math operations. + * The functions operate on matrix data structures. For example, + * the type + * definition for the floating-point matrix structure is shown + * below: + *
+ *     typedef struct
+ *     {
+ *       uint16_t numRows;     // number of rows of the matrix.
+ *       uint16_t numCols;     // number of columns of the matrix.
+ *       float32_t *pData;     // points to the data of the matrix.
+ *     } arm_matrix_instance_f32;
+ * 
+ * There are similar definitions for Q15 and Q31 data types. + * + * The structure specifies the size of the matrix and then points to + * an array of data. The array is of size numRows X numCols + * and the values are arranged in row order. That is, the + * matrix element (i, j) is stored at: + *
+ *     pData[i*numCols + j]
+ * 
+ * + * \par Init Functions + * There is an associated initialization function for each type of matrix + * data structure. + * The initialization function sets the values of the internal structure fields. + * Refer to \ref arm_mat_init_f32(), \ref arm_mat_init_q31() and \ref arm_mat_init_q15() + * for floating-point, Q31 and Q15 types, respectively. + * + * \par + * Use of the initialization function is optional. However, if initialization function is used + * then the instance structure cannot be placed into a const data section. + * To place the instance structure in a const data + * section, manually initialize the data structure. For example: + *
+ * arm_matrix_instance_f32 S = {nRows, nColumns, pData};
+ * arm_matrix_instance_q31 S = {nRows, nColumns, pData};
+ * arm_matrix_instance_q15 S = {nRows, nColumns, pData};
+ * 
+ * where nRows specifies the number of rows, nColumns + * specifies the number of columns, and pData points to the + * data array. + * + * \par Size Checking + * By default all of the matrix functions perform size checking on the input and + * output matrices. For example, the matrix addition function verifies that the + * two input matrices and the output matrix all have the same number of rows and + * columns. If the size check fails the functions return: + *
+ *     ARM_MATH_SIZE_MISMATCH
+ * 
+ * Otherwise the functions return + *
+ *     ARM_MATH_SUCCESS
+ * 
+ * There is some overhead associated with this matrix size checking. + * The matrix size checking is enabled via the \#define + *
+ *     ARM_MATH_MATRIX_CHECK
+ * 
+ * within the library project settings. By default this macro is defined + * and size checking is enabled. By changing the project settings and + * undefining this macro size checking is eliminated and the functions + * run a bit faster. With size checking disabled the functions always + * return ARM_MATH_SUCCESS. + */ + +/** + * @defgroup groupTransforms Transform Functions + */ + +/** + * @defgroup groupController Controller Functions + */ + +/** + * @defgroup groupStats Statistics Functions + */ + +/** + * @defgroup groupSupport Support Functions + */ + +/** + * @defgroup groupInterpolation Interpolation Functions + * These functions perform 1- and 2-dimensional interpolation of data. + * Linear interpolation is used for 1-dimensional data and + * bilinear interpolation is used for 2-dimensional data. + */ + +/** + * @defgroup groupExamples Examples + */ + +/** + * @defgroup groupSVM SVM Functions + * This set of functions is implementing SVM classification on 2 classes. + * The training must be done from scikit-learn. The parameters can be easily + * generated from the scikit-learn object. Some examples are given in + * DSP/Testing/PatternGeneration/SVM.py + * + * If more than 2 classes are needed, the functions in this folder + * will have to be used, as building blocks, to do multi-class classification. + * + * No multi-class classification is provided in this SVM folder. + * + */ + + +/** + * @defgroup groupBayes Bayesian estimators + * + * Implement the naive gaussian Bayes estimator. + * The training must be done from scikit-learn. + * + * The parameters can be easily + * generated from the scikit-learn object. Some examples are given in + * DSP/Testing/PatternGeneration/Bayes.py + */ + +/** + * @defgroup groupDistance Distance functions + * + * Distance functions for use with clustering algorithms. + * There are distance functions for float vectors and boolean vectors. + * + */ + + +#ifndef _ARM_MATH_H +#define _ARM_MATH_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Compiler specific diagnostic adjustment */ +#if defined ( __CC_ARM ) + +#elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) + +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wsign-conversion" + #pragma GCC diagnostic ignored "-Wconversion" + #pragma GCC diagnostic ignored "-Wunused-parameter" + +#elif defined ( __ICCARM__ ) + +#elif defined ( __TI_ARM__ ) + +#elif defined ( __CSMC__ ) + +#elif defined ( __TASKING__ ) + +#elif defined ( _MSC_VER ) + +#else + #error Unknown compiler +#endif + + +/* Included for instrinsics definitions */ +#if defined (_MSC_VER ) +#include +#define __STATIC_FORCEINLINE static __forceinline +#define __STATIC_INLINE static __inline +#define __ALIGNED(x) __declspec(align(x)) + +#elif defined (__GNUC_PYTHON__) +#include +#define __ALIGNED(x) __attribute__((aligned(x))) +#define __STATIC_FORCEINLINE static __attribute__((inline)) +#define __STATIC_INLINE static __attribute__((inline)) +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wattributes" + +#else +#include "cmsis_compiler.h" +#endif + + + +#include +#include +#include +#include + + +#define F64_MAX ((float64_t)DBL_MAX) +#define F32_MAX ((float32_t)FLT_MAX) + +#if defined(ARM_MATH_FLOAT16) +#define F16_MAX ((float16_t)FLT_MAX) +#endif + +#define F64_MIN (-DBL_MAX) +#define F32_MIN (-FLT_MAX) + +#if defined(ARM_MATH_FLOAT16) +#define F16_MIN (-(float16_t)FLT_MAX) +#endif + +#define F64_ABSMAX ((float64_t)DBL_MAX) +#define F32_ABSMAX ((float32_t)FLT_MAX) + +#if defined(ARM_MATH_FLOAT16) +#define F16_ABSMAX ((float16_t)FLT_MAX) +#endif + +#define F64_ABSMIN ((float64_t)0.0) +#define F32_ABSMIN ((float32_t)0.0) + +#if defined(ARM_MATH_FLOAT16) +#define F16_ABSMIN ((float16_t)0.0) +#endif + +#define Q31_MAX ((q31_t)(0x7FFFFFFFL)) +#define Q15_MAX ((q15_t)(0x7FFF)) +#define Q7_MAX ((q7_t)(0x7F)) +#define Q31_MIN ((q31_t)(0x80000000L)) +#define Q15_MIN ((q15_t)(0x8000)) +#define Q7_MIN ((q7_t)(0x80)) + +#define Q31_ABSMAX ((q31_t)(0x7FFFFFFFL)) +#define Q15_ABSMAX ((q15_t)(0x7FFF)) +#define Q7_ABSMAX ((q7_t)(0x7F)) +#define Q31_ABSMIN ((q31_t)0) +#define Q15_ABSMIN ((q15_t)0) +#define Q7_ABSMIN ((q7_t)0) + +/* evaluate ARM DSP feature */ +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + #define ARM_MATH_DSP 1 +#endif + +#if defined(ARM_MATH_NEON) +#include +#endif + +#if defined (ARM_MATH_HELIUM) + #define ARM_MATH_MVEF + #define ARM_MATH_FLOAT16 +#endif + +#if defined (ARM_MATH_MVEF) + #define ARM_MATH_MVEI + #define ARM_MATH_FLOAT16 +#endif + +#if defined (ARM_MATH_HELIUM) || defined(ARM_MATH_MVEF) || defined(ARM_MATH_MVEI) +#include +#endif + + + /** + * @brief Macros required for reciprocal calculation in Normalized LMS + */ + +#define DELTA_Q31 ((q31_t)(0x100)) +#define DELTA_Q15 ((q15_t)0x5) +#define INDEX_MASK 0x0000003F +#ifndef PI + #define PI 3.14159265358979f +#endif + + /** + * @brief Macros required for SINE and COSINE Fast math approximations + */ + +#define FAST_MATH_TABLE_SIZE 512 +#define FAST_MATH_Q31_SHIFT (32 - 10) +#define FAST_MATH_Q15_SHIFT (16 - 10) +#define CONTROLLER_Q31_SHIFT (32 - 9) +#define TABLE_SPACING_Q31 0x400000 +#define TABLE_SPACING_Q15 0x80 + + /** + * @brief Macros required for SINE and COSINE Controller functions + */ + /* 1.31(q31) Fixed value of 2/360 */ + /* -1 to +1 is divided into 360 values so total spacing is (2/360) */ +#define INPUT_SPACING 0xB60B61 + + /** + * @brief Macros for complex numbers + */ + + /* Dimension C vector space */ + #define CMPLX_DIM 2 + + /** + * @brief Error status returned by some functions in the library. + */ + + typedef enum + { + ARM_MATH_SUCCESS = 0, /**< No error */ + ARM_MATH_ARGUMENT_ERROR = -1, /**< One or more arguments are incorrect */ + ARM_MATH_LENGTH_ERROR = -2, /**< Length of data buffer is incorrect */ + ARM_MATH_SIZE_MISMATCH = -3, /**< Size of matrices is not compatible with the operation */ + ARM_MATH_NANINF = -4, /**< Not-a-number (NaN) or infinity is generated */ + ARM_MATH_SINGULAR = -5, /**< Input matrix is singular and cannot be inverted */ + ARM_MATH_TEST_FAILURE = -6 /**< Test Failed */ + } arm_status; + + /** + * @brief 8-bit fractional data type in 1.7 format. + */ + typedef int8_t q7_t; + + /** + * @brief 16-bit fractional data type in 1.15 format. + */ + typedef int16_t q15_t; + + /** + * @brief 32-bit fractional data type in 1.31 format. + */ + typedef int32_t q31_t; + + /** + * @brief 64-bit fractional data type in 1.63 format. + */ + typedef int64_t q63_t; + + /** + * @brief 32-bit floating-point type definition. + */ + typedef float float32_t; + + /** + * @brief 64-bit floating-point type definition. + */ + typedef double float64_t; + + /** + * @brief vector types + */ +#if defined(ARM_MATH_NEON) || defined (ARM_MATH_MVEI) + /** + * @brief 64-bit fractional 128-bit vector data type in 1.63 format + */ + typedef int64x2_t q63x2_t; + + /** + * @brief 32-bit fractional 128-bit vector data type in 1.31 format. + */ + typedef int32x4_t q31x4_t; + + /** + * @brief 16-bit fractional 128-bit vector data type with 16-bit alignement in 1.15 format. + */ + typedef __ALIGNED(2) int16x8_t q15x8_t; + + /** + * @brief 8-bit fractional 128-bit vector data type with 8-bit alignement in 1.7 format. + */ + typedef __ALIGNED(1) int8x16_t q7x16_t; + + /** + * @brief 32-bit fractional 128-bit vector pair data type in 1.31 format. + */ + typedef int32x4x2_t q31x4x2_t; + + /** + * @brief 32-bit fractional 128-bit vector quadruplet data type in 1.31 format. + */ + typedef int32x4x4_t q31x4x4_t; + + /** + * @brief 16-bit fractional 128-bit vector pair data type in 1.15 format. + */ + typedef int16x8x2_t q15x8x2_t; + + /** + * @brief 16-bit fractional 128-bit vector quadruplet data type in 1.15 format. + */ + typedef int16x8x4_t q15x8x4_t; + + /** + * @brief 8-bit fractional 128-bit vector pair data type in 1.7 format. + */ + typedef int8x16x2_t q7x16x2_t; + + /** + * @brief 8-bit fractional 128-bit vector quadruplet data type in 1.7 format. + */ + typedef int8x16x4_t q7x16x4_t; + + /** + * @brief 32-bit fractional data type in 9.23 format. + */ + typedef int32_t q23_t; + + /** + * @brief 32-bit fractional 128-bit vector data type in 9.23 format. + */ + typedef int32x4_t q23x4_t; + + /** + * @brief 64-bit status 128-bit vector data type. + */ + typedef int64x2_t status64x2_t; + + /** + * @brief 32-bit status 128-bit vector data type. + */ + typedef int32x4_t status32x4_t; + + /** + * @brief 16-bit status 128-bit vector data type. + */ + typedef int16x8_t status16x8_t; + + /** + * @brief 8-bit status 128-bit vector data type. + */ + typedef int8x16_t status8x16_t; + + +#endif + +#if defined(ARM_MATH_NEON) || defined(ARM_MATH_MVEF) /* floating point vector*/ + /** + * @brief 32-bit floating-point 128-bit vector type + */ + typedef float32x4_t f32x4_t; + +#if defined(ARM_MATH_FLOAT16) + /** + * @brief 16-bit floating-point 128-bit vector data type + */ + typedef __ALIGNED(2) float16x8_t f16x8_t; +#endif + + /** + * @brief 32-bit floating-point 128-bit vector pair data type + */ + typedef float32x4x2_t f32x4x2_t; + + /** + * @brief 32-bit floating-point 128-bit vector quadruplet data type + */ + typedef float32x4x4_t f32x4x4_t; + +#if defined(ARM_MATH_FLOAT16) + /** + * @brief 16-bit floating-point 128-bit vector pair data type + */ + typedef float16x8x2_t f16x8x2_t; + + /** + * @brief 16-bit floating-point 128-bit vector quadruplet data type + */ + typedef float16x8x4_t f16x8x4_t; +#endif + + /** + * @brief 32-bit ubiquitous 128-bit vector data type + */ + typedef union _any32x4_t + { + float32x4_t f; + int32x4_t i; + } any32x4_t; + +#if defined(ARM_MATH_FLOAT16) + /** + * @brief 16-bit ubiquitous 128-bit vector data type + */ + typedef union _any16x8_t + { + float16x8_t f; + int16x8_t i; + } any16x8_t; +#endif + +#endif + +#if defined(ARM_MATH_NEON) + /** + * @brief 32-bit fractional 64-bit vector data type in 1.31 format. + */ + typedef int32x2_t q31x2_t; + + /** + * @brief 16-bit fractional 64-bit vector data type in 1.15 format. + */ + typedef __ALIGNED(2) int16x4_t q15x4_t; + + /** + * @brief 8-bit fractional 64-bit vector data type in 1.7 format. + */ + typedef __ALIGNED(1) int8x8_t q7x8_t; + + /** + * @brief 32-bit float 64-bit vector data type. + */ + typedef float32x2_t f32x2_t; + +#if defined(ARM_MATH_FLOAT16) + /** + * @brief 16-bit float 64-bit vector data type. + */ + typedef __ALIGNED(2) float16x4_t f16x4_t; +#endif + + /** + * @brief 32-bit floating-point 128-bit vector triplet data type + */ + typedef float32x4x3_t f32x4x3_t; + +#if defined(ARM_MATH_FLOAT16) + /** + * @brief 16-bit floating-point 128-bit vector triplet data type + */ + typedef float16x8x3_t f16x8x3_t; +#endif + + /** + * @brief 32-bit fractional 128-bit vector triplet data type in 1.31 format + */ + typedef int32x4x3_t q31x4x3_t; + + /** + * @brief 16-bit fractional 128-bit vector triplet data type in 1.15 format + */ + typedef int16x8x3_t q15x8x3_t; + + /** + * @brief 8-bit fractional 128-bit vector triplet data type in 1.7 format + */ + typedef int8x16x3_t q7x16x3_t; + + /** + * @brief 32-bit floating-point 64-bit vector pair data type + */ + typedef float32x2x2_t f32x2x2_t; + + /** + * @brief 32-bit floating-point 64-bit vector triplet data type + */ + typedef float32x2x3_t f32x2x3_t; + + /** + * @brief 32-bit floating-point 64-bit vector quadruplet data type + */ + typedef float32x2x4_t f32x2x4_t; + +#if defined(ARM_MATH_FLOAT16) + /** + * @brief 16-bit floating-point 64-bit vector pair data type + */ + typedef float16x4x2_t f16x4x2_t; + + /** + * @brief 16-bit floating-point 64-bit vector triplet data type + */ + typedef float16x4x3_t f16x4x3_t; + + /** + * @brief 16-bit floating-point 64-bit vector quadruplet data type + */ + typedef float16x4x4_t f16x4x4_t; +#endif + + /** + * @brief 32-bit fractional 64-bit vector pair data type in 1.31 format + */ + typedef int32x2x2_t q31x2x2_t; + + /** + * @brief 32-bit fractional 64-bit vector triplet data type in 1.31 format + */ + typedef int32x2x3_t q31x2x3_t; + + /** + * @brief 32-bit fractional 64-bit vector quadruplet data type in 1.31 format + */ + typedef int32x4x3_t q31x2x4_t; + + /** + * @brief 16-bit fractional 64-bit vector pair data type in 1.15 format + */ + typedef int16x4x2_t q15x4x2_t; + + /** + * @brief 16-bit fractional 64-bit vector triplet data type in 1.15 format + */ + typedef int16x4x2_t q15x4x3_t; + + /** + * @brief 16-bit fractional 64-bit vector quadruplet data type in 1.15 format + */ + typedef int16x4x3_t q15x4x4_t; + + /** + * @brief 8-bit fractional 64-bit vector pair data type in 1.7 format + */ + typedef int8x8x2_t q7x8x2_t; + + /** + * @brief 8-bit fractional 64-bit vector triplet data type in 1.7 format + */ + typedef int8x8x3_t q7x8x3_t; + + /** + * @brief 8-bit fractional 64-bit vector quadruplet data type in 1.7 format + */ + typedef int8x8x4_t q7x8x4_t; + + /** + * @brief 32-bit ubiquitous 64-bit vector data type + */ + typedef union _any32x2_t + { + float32x2_t f; + int32x2_t i; + } any32x2_t; + +#if defined(ARM_MATH_FLOAT16) + /** + * @brief 16-bit ubiquitous 64-bit vector data type + */ + typedef union _any16x4_t + { + float16x4_t f; + int16x4_t i; + } any16x4_t; +#endif + + /** + * @brief 32-bit status 64-bit vector data type. + */ + typedef int32x4_t status32x2_t; + + /** + * @brief 16-bit status 64-bit vector data type. + */ + typedef int16x8_t status16x4_t; + + /** + * @brief 8-bit status 64-bit vector data type. + */ + typedef int8x16_t status8x8_t; + +#endif + + + +/** + @brief definition to read/write two 16 bit values. + @deprecated + */ +#if defined ( __CC_ARM ) + #define __SIMD32_TYPE int32_t __packed +#elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) + #define __SIMD32_TYPE int32_t +#elif defined ( __GNUC__ ) + #define __SIMD32_TYPE int32_t +#elif defined ( __ICCARM__ ) + #define __SIMD32_TYPE int32_t __packed +#elif defined ( __TI_ARM__ ) + #define __SIMD32_TYPE int32_t +#elif defined ( __CSMC__ ) + #define __SIMD32_TYPE int32_t +#elif defined ( __TASKING__ ) + #define __SIMD32_TYPE __un(aligned) int32_t +#elif defined(_MSC_VER ) + #define __SIMD32_TYPE int32_t +#else + #error Unknown compiler +#endif + +#define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr)) +#define __SIMD32_CONST(addr) ( (__SIMD32_TYPE * ) (addr)) +#define _SIMD32_OFFSET(addr) (*(__SIMD32_TYPE * ) (addr)) +#define __SIMD64(addr) (*( int64_t **) & (addr)) + +#define STEP(x) (x) <= 0 ? 0 : 1 +#define SQ(x) ((x) * (x)) + +/* SIMD replacement */ + + +/** + @brief Read 2 Q15 from Q15 pointer. + @param[in] pQ15 points to input value + @return Q31 value + */ +__STATIC_FORCEINLINE q31_t read_q15x2 ( + q15_t * pQ15) +{ + q31_t val; + +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (&val, pQ15, 4); +#else + val = (pQ15[1] << 16) | (pQ15[0] & 0x0FFFF) ; +#endif + + return (val); +} + +/** + @brief Read 2 Q15 from Q15 pointer and increment pointer afterwards. + @param[in] pQ15 points to input value + @return Q31 value + */ +__STATIC_FORCEINLINE q31_t read_q15x2_ia ( + q15_t ** pQ15) +{ + q31_t val; + +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (&val, *pQ15, 4); +#else + val = ((*pQ15)[1] << 16) | ((*pQ15)[0] & 0x0FFFF); +#endif + + *pQ15 += 2; + return (val); +} + +/** + @brief Read 2 Q15 from Q15 pointer and decrement pointer afterwards. + @param[in] pQ15 points to input value + @return Q31 value + */ +__STATIC_FORCEINLINE q31_t read_q15x2_da ( + q15_t ** pQ15) +{ + q31_t val; + +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (&val, *pQ15, 4); +#else + val = ((*pQ15)[1] << 16) | ((*pQ15)[0] & 0x0FFFF); +#endif + + *pQ15 -= 2; + return (val); +} + +/** + @brief Write 2 Q15 to Q15 pointer and increment pointer afterwards. + @param[in] pQ15 points to input value + @param[in] value Q31 value + @return none + */ +__STATIC_FORCEINLINE void write_q15x2_ia ( + q15_t ** pQ15, + q31_t value) +{ + q31_t val = value; +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (*pQ15, &val, 4); +#else + (*pQ15)[0] = (val & 0x0FFFF); + (*pQ15)[1] = (val >> 16) & 0x0FFFF; +#endif + + *pQ15 += 2; +} + +/** + @brief Write 2 Q15 to Q15 pointer. + @param[in] pQ15 points to input value + @param[in] value Q31 value + @return none + */ +__STATIC_FORCEINLINE void write_q15x2 ( + q15_t * pQ15, + q31_t value) +{ + q31_t val = value; + +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (pQ15, &val, 4); +#else + pQ15[0] = val & 0x0FFFF; + pQ15[1] = val >> 16; +#endif +} + + +/** + @brief Read 4 Q7 from Q7 pointer and increment pointer afterwards. + @param[in] pQ7 points to input value + @return Q31 value + */ +__STATIC_FORCEINLINE q31_t read_q7x4_ia ( + q7_t ** pQ7) +{ + q31_t val; + + +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (&val, *pQ7, 4); +#else + val =(((*pQ7)[3] & 0x0FF) << 24) | (((*pQ7)[2] & 0x0FF) << 16) | (((*pQ7)[1] & 0x0FF) << 8) | ((*pQ7)[0] & 0x0FF); +#endif + + *pQ7 += 4; + + return (val); +} + +/** + @brief Read 4 Q7 from Q7 pointer and decrement pointer afterwards. + @param[in] pQ7 points to input value + @return Q31 value + */ +__STATIC_FORCEINLINE q31_t read_q7x4_da ( + q7_t ** pQ7) +{ + q31_t val; +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (&val, *pQ7, 4); +#else + val = ((((*pQ7)[3]) & 0x0FF) << 24) | ((((*pQ7)[2]) & 0x0FF) << 16) | ((((*pQ7)[1]) & 0x0FF) << 8) | ((*pQ7)[0] & 0x0FF); +#endif + *pQ7 -= 4; + + return (val); +} + +/** + @brief Write 4 Q7 to Q7 pointer and increment pointer afterwards. + @param[in] pQ7 points to input value + @param[in] value Q31 value + @return none + */ +__STATIC_FORCEINLINE void write_q7x4_ia ( + q7_t ** pQ7, + q31_t value) +{ + q31_t val = value; +#ifdef __ARM_FEATURE_UNALIGNED + memcpy (*pQ7, &val, 4); +#else + (*pQ7)[0] = val & 0x0FF; + (*pQ7)[1] = (val >> 8) & 0x0FF; + (*pQ7)[2] = (val >> 16) & 0x0FF; + (*pQ7)[3] = (val >> 24) & 0x0FF; + +#endif + *pQ7 += 4; +} + +/* + +Normally those kind of definitions are in a compiler file +in Core or Core_A. + +But for MSVC compiler it is a bit special. The goal is very specific +to CMSIS-DSP and only to allow the use of this library from other +systems like Python or Matlab. + +MSVC is not going to be used to cross-compile to ARM. So, having a MSVC +compiler file in Core or Core_A would not make sense. + +*/ +#if defined ( _MSC_VER ) || defined(__GNUC_PYTHON__) + __STATIC_FORCEINLINE uint8_t __CLZ(uint32_t data) + { + if (data == 0U) { return 32U; } + + uint32_t count = 0U; + uint32_t mask = 0x80000000U; + + while ((data & mask) == 0U) + { + count += 1U; + mask = mask >> 1U; + } + return count; + } + + __STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) + { + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; + } + + __STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) + { + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; + } +#endif + +#ifndef ARM_MATH_DSP + /** + * @brief definition to pack two 16 bit values. + */ + #define __PKHBT(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0x0000FFFF) | \ + (((int32_t)(ARG2) << ARG3) & (int32_t)0xFFFF0000) ) + #define __PKHTB(ARG1, ARG2, ARG3) ( (((int32_t)(ARG1) << 0) & (int32_t)0xFFFF0000) | \ + (((int32_t)(ARG2) >> ARG3) & (int32_t)0x0000FFFF) ) +#endif + + /** + * @brief definition to pack four 8 bit values. + */ +#ifndef ARM_MATH_BIG_ENDIAN + #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) << 0) & (int32_t)0x000000FF) | \ + (((int32_t)(v1) << 8) & (int32_t)0x0000FF00) | \ + (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \ + (((int32_t)(v3) << 24) & (int32_t)0xFF000000) ) +#else + #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v3) << 0) & (int32_t)0x000000FF) | \ + (((int32_t)(v2) << 8) & (int32_t)0x0000FF00) | \ + (((int32_t)(v1) << 16) & (int32_t)0x00FF0000) | \ + (((int32_t)(v0) << 24) & (int32_t)0xFF000000) ) +#endif + + + /** + * @brief Clips Q63 to Q31 values. + */ + __STATIC_FORCEINLINE q31_t clip_q63_to_q31( + q63_t x) + { + return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? + ((0x7FFFFFFF ^ ((q31_t) (x >> 63)))) : (q31_t) x; + } + + /** + * @brief Clips Q63 to Q15 values. + */ + __STATIC_FORCEINLINE q15_t clip_q63_to_q15( + q63_t x) + { + return ((q31_t) (x >> 32) != ((q31_t) x >> 31)) ? + ((0x7FFF ^ ((q15_t) (x >> 63)))) : (q15_t) (x >> 15); + } + + /** + * @brief Clips Q31 to Q7 values. + */ + __STATIC_FORCEINLINE q7_t clip_q31_to_q7( + q31_t x) + { + return ((q31_t) (x >> 24) != ((q31_t) x >> 23)) ? + ((0x7F ^ ((q7_t) (x >> 31)))) : (q7_t) x; + } + + /** + * @brief Clips Q31 to Q15 values. + */ + __STATIC_FORCEINLINE q15_t clip_q31_to_q15( + q31_t x) + { + return ((q31_t) (x >> 16) != ((q31_t) x >> 15)) ? + ((0x7FFF ^ ((q15_t) (x >> 31)))) : (q15_t) x; + } + + /** + * @brief Multiplies 32 X 64 and returns 32 bit result in 2.30 format. + */ + __STATIC_FORCEINLINE q63_t mult32x64( + q63_t x, + q31_t y) + { + return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) + + (((q63_t) (x >> 32) * y) ) ); + } + + /** + * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type. + */ + __STATIC_FORCEINLINE uint32_t arm_recip_q31( + q31_t in, + q31_t * dst, + const q31_t * pRecipTable) + { + q31_t out; + uint32_t tempVal; + uint32_t index, i; + uint32_t signBits; + + if (in > 0) + { + signBits = ((uint32_t) (__CLZ( in) - 1)); + } + else + { + signBits = ((uint32_t) (__CLZ(-in) - 1)); + } + + /* Convert input sample to 1.31 format */ + in = (in << signBits); + + /* calculation of index for initial approximated Val */ + index = (uint32_t)(in >> 24); + index = (index & INDEX_MASK); + + /* 1.31 with exp 1 */ + out = pRecipTable[index]; + + /* calculation of reciprocal value */ + /* running approximation for two iterations */ + for (i = 0U; i < 2U; i++) + { + tempVal = (uint32_t) (((q63_t) in * out) >> 31); + tempVal = 0x7FFFFFFFu - tempVal; + /* 1.31 with exp 1 */ + /* out = (q31_t) (((q63_t) out * tempVal) >> 30); */ + out = clip_q63_to_q31(((q63_t) out * tempVal) >> 30); + } + + /* write output */ + *dst = out; + + /* return num of signbits of out = 1/in value */ + return (signBits + 1U); + } + + + /** + * @brief Function to Calculates 1/in (reciprocal) value of Q15 Data type. + */ + __STATIC_FORCEINLINE uint32_t arm_recip_q15( + q15_t in, + q15_t * dst, + const q15_t * pRecipTable) + { + q15_t out = 0; + uint32_t tempVal = 0; + uint32_t index = 0, i = 0; + uint32_t signBits = 0; + + if (in > 0) + { + signBits = ((uint32_t)(__CLZ( in) - 17)); + } + else + { + signBits = ((uint32_t)(__CLZ(-in) - 17)); + } + + /* Convert input sample to 1.15 format */ + in = (in << signBits); + + /* calculation of index for initial approximated Val */ + index = (uint32_t)(in >> 8); + index = (index & INDEX_MASK); + + /* 1.15 with exp 1 */ + out = pRecipTable[index]; + + /* calculation of reciprocal value */ + /* running approximation for two iterations */ + for (i = 0U; i < 2U; i++) + { + tempVal = (uint32_t) (((q31_t) in * out) >> 15); + tempVal = 0x7FFFu - tempVal; + /* 1.15 with exp 1 */ + out = (q15_t) (((q31_t) out * tempVal) >> 14); + /* out = clip_q31_to_q15(((q31_t) out * tempVal) >> 14); */ + } + + /* write output */ + *dst = out; + + /* return num of signbits of out = 1/in value */ + return (signBits + 1); + } + +/** + * @brief Integer exponentiation + * @param[in] x value + * @param[in] nb integer exponent >= 1 + * @return x^nb + * + */ +__STATIC_INLINE float32_t arm_exponent_f32(float32_t x, int32_t nb) +{ + float32_t r = x; + nb --; + while(nb > 0) + { + r = r * x; + nb--; + } + return(r); +} + +/** + * @brief 64-bit to 32-bit unsigned normalization + * @param[in] in is input unsigned long long value + * @param[out] normalized is the 32-bit normalized value + * @param[out] norm is norm scale + */ +__STATIC_INLINE void arm_norm_64_to_32u(uint64_t in, int32_t * normalized, int32_t *norm) +{ + int32_t n1; + int32_t hi = (int32_t) (in >> 32); + int32_t lo = (int32_t) ((in << 32) >> 32); + + n1 = __CLZ(hi) - 32; + if (!n1) + { + /* + * input fits in 32-bit + */ + n1 = __CLZ(lo); + if (!n1) + { + /* + * MSB set, need to scale down by 1 + */ + *norm = -1; + *normalized = (((uint32_t) lo) >> 1); + } else + { + if (n1 == 32) + { + /* + * input is zero + */ + *norm = 0; + *normalized = 0; + } else + { + /* + * 32-bit normalization + */ + *norm = n1 - 1; + *normalized = lo << *norm; + } + } + } else + { + /* + * input fits in 64-bit + */ + n1 = 1 - n1; + *norm = -n1; + /* + * 64 bit normalization + */ + *normalized = (((uint32_t) lo) >> n1) | (hi << (32 - n1)); + } +} + +__STATIC_INLINE q31_t arm_div_q63_to_q31(q63_t num, q31_t den) +{ + q31_t result; + uint64_t absNum; + int32_t normalized; + int32_t norm; + + /* + * if sum fits in 32bits + * avoid costly 64-bit division + */ + absNum = num > 0 ? num : -num; + arm_norm_64_to_32u(absNum, &normalized, &norm); + if (norm > 0) + /* + * 32-bit division + */ + result = (q31_t) num / den; + else + /* + * 64-bit division + */ + result = (q31_t) (num / den); + + return result; +} + + +/* + * @brief C custom defined intrinsic functions + */ +#if !defined (ARM_MATH_DSP) + + /* + * @brief C custom defined QADD8 + */ + __STATIC_FORCEINLINE uint32_t __QADD8( + uint32_t x, + uint32_t y) + { + q31_t r, s, t, u; + + r = __SSAT(((((q31_t)x << 24) >> 24) + (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF; + s = __SSAT(((((q31_t)x << 16) >> 24) + (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF; + t = __SSAT(((((q31_t)x << 8) >> 24) + (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF; + u = __SSAT(((((q31_t)x ) >> 24) + (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF; + + return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r ))); + } + + + /* + * @brief C custom defined QSUB8 + */ + __STATIC_FORCEINLINE uint32_t __QSUB8( + uint32_t x, + uint32_t y) + { + q31_t r, s, t, u; + + r = __SSAT(((((q31_t)x << 24) >> 24) - (((q31_t)y << 24) >> 24)), 8) & (int32_t)0x000000FF; + s = __SSAT(((((q31_t)x << 16) >> 24) - (((q31_t)y << 16) >> 24)), 8) & (int32_t)0x000000FF; + t = __SSAT(((((q31_t)x << 8) >> 24) - (((q31_t)y << 8) >> 24)), 8) & (int32_t)0x000000FF; + u = __SSAT(((((q31_t)x ) >> 24) - (((q31_t)y ) >> 24)), 8) & (int32_t)0x000000FF; + + return ((uint32_t)((u << 24) | (t << 16) | (s << 8) | (r ))); + } + + + /* + * @brief C custom defined QADD16 + */ + __STATIC_FORCEINLINE uint32_t __QADD16( + uint32_t x, + uint32_t y) + { +/* q31_t r, s; without initialisation 'arm_offset_q15 test' fails but 'intrinsic' tests pass! for armCC */ + q31_t r = 0, s = 0; + + r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; + s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined SHADD16 + */ + __STATIC_FORCEINLINE uint32_t __SHADD16( + uint32_t x, + uint32_t y) + { + q31_t r, s; + + r = (((((q31_t)x << 16) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; + s = (((((q31_t)x ) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined QSUB16 + */ + __STATIC_FORCEINLINE uint32_t __QSUB16( + uint32_t x, + uint32_t y) + { + q31_t r, s; + + r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; + s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined SHSUB16 + */ + __STATIC_FORCEINLINE uint32_t __SHSUB16( + uint32_t x, + uint32_t y) + { + q31_t r, s; + + r = (((((q31_t)x << 16) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; + s = (((((q31_t)x ) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined QASX + */ + __STATIC_FORCEINLINE uint32_t __QASX( + uint32_t x, + uint32_t y) + { + q31_t r, s; + + r = __SSAT(((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; + s = __SSAT(((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined SHASX + */ + __STATIC_FORCEINLINE uint32_t __SHASX( + uint32_t x, + uint32_t y) + { + q31_t r, s; + + r = (((((q31_t)x << 16) >> 16) - (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; + s = (((((q31_t)x ) >> 16) + (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined QSAX + */ + __STATIC_FORCEINLINE uint32_t __QSAX( + uint32_t x, + uint32_t y) + { + q31_t r, s; + + r = __SSAT(((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)), 16) & (int32_t)0x0000FFFF; + s = __SSAT(((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)), 16) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined SHSAX + */ + __STATIC_FORCEINLINE uint32_t __SHSAX( + uint32_t x, + uint32_t y) + { + q31_t r, s; + + r = (((((q31_t)x << 16) >> 16) + (((q31_t)y ) >> 16)) >> 1) & (int32_t)0x0000FFFF; + s = (((((q31_t)x ) >> 16) - (((q31_t)y << 16) >> 16)) >> 1) & (int32_t)0x0000FFFF; + + return ((uint32_t)((s << 16) | (r ))); + } + + + /* + * @brief C custom defined SMUSDX + */ + __STATIC_FORCEINLINE uint32_t __SMUSDX( + uint32_t x, + uint32_t y) + { + return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) - + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) )); + } + + /* + * @brief C custom defined SMUADX + */ + __STATIC_FORCEINLINE uint32_t __SMUADX( + uint32_t x, + uint32_t y) + { + return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) + + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) )); + } + + + /* + * @brief C custom defined QADD + */ + __STATIC_FORCEINLINE int32_t __QADD( + int32_t x, + int32_t y) + { + return ((int32_t)(clip_q63_to_q31((q63_t)x + (q31_t)y))); + } + + + /* + * @brief C custom defined QSUB + */ + __STATIC_FORCEINLINE int32_t __QSUB( + int32_t x, + int32_t y) + { + return ((int32_t)(clip_q63_to_q31((q63_t)x - (q31_t)y))); + } + + + /* + * @brief C custom defined SMLAD + */ + __STATIC_FORCEINLINE uint32_t __SMLAD( + uint32_t x, + uint32_t y, + uint32_t sum) + { + return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) + + ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) + + ( ((q31_t)sum ) ) )); + } + + + /* + * @brief C custom defined SMLADX + */ + __STATIC_FORCEINLINE uint32_t __SMLADX( + uint32_t x, + uint32_t y, + uint32_t sum) + { + return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) + + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) + + ( ((q31_t)sum ) ) )); + } + + + /* + * @brief C custom defined SMLSDX + */ + __STATIC_FORCEINLINE uint32_t __SMLSDX( + uint32_t x, + uint32_t y, + uint32_t sum) + { + return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) - + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) + + ( ((q31_t)sum ) ) )); + } + + + /* + * @brief C custom defined SMLALD + */ + __STATIC_FORCEINLINE uint64_t __SMLALD( + uint32_t x, + uint32_t y, + uint64_t sum) + { +/* return (sum + ((q15_t) (x >> 16) * (q15_t) (y >> 16)) + ((q15_t) x * (q15_t) y)); */ + return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) + + ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) + + ( ((q63_t)sum ) ) )); + } + + + /* + * @brief C custom defined SMLALDX + */ + __STATIC_FORCEINLINE uint64_t __SMLALDX( + uint32_t x, + uint32_t y, + uint64_t sum) + { +/* return (sum + ((q15_t) (x >> 16) * (q15_t) y)) + ((q15_t) x * (q15_t) (y >> 16)); */ + return ((uint64_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y ) >> 16)) + + ((((q31_t)x ) >> 16) * (((q31_t)y << 16) >> 16)) + + ( ((q63_t)sum ) ) )); + } + + + /* + * @brief C custom defined SMUAD + */ + __STATIC_FORCEINLINE uint32_t __SMUAD( + uint32_t x, + uint32_t y) + { + return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) + + ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) )); + } + + + /* + * @brief C custom defined SMUSD + */ + __STATIC_FORCEINLINE uint32_t __SMUSD( + uint32_t x, + uint32_t y) + { + return ((uint32_t)(((((q31_t)x << 16) >> 16) * (((q31_t)y << 16) >> 16)) - + ((((q31_t)x ) >> 16) * (((q31_t)y ) >> 16)) )); + } + + + /* + * @brief C custom defined SXTB16 + */ + __STATIC_FORCEINLINE uint32_t __SXTB16( + uint32_t x) + { + return ((uint32_t)(((((q31_t)x << 24) >> 24) & (q31_t)0x0000FFFF) | + ((((q31_t)x << 8) >> 8) & (q31_t)0xFFFF0000) )); + } + + /* + * @brief C custom defined SMMLA + */ + __STATIC_FORCEINLINE int32_t __SMMLA( + int32_t x, + int32_t y, + int32_t sum) + { + return (sum + (int32_t) (((int64_t) x * y) >> 32)); + } + +#endif /* !defined (ARM_MATH_DSP) */ + + + /** + * @brief Instance structure for the Q7 FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of filter coefficients in the filter. */ + q7_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + } arm_fir_instance_q7; + + /** + * @brief Instance structure for the Q15 FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of filter coefficients in the filter. */ + q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + } arm_fir_instance_q15; + + /** + * @brief Instance structure for the Q31 FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of filter coefficients in the filter. */ + q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + } arm_fir_instance_q31; + + /** + * @brief Instance structure for the floating-point FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of filter coefficients in the filter. */ + float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + } arm_fir_instance_f32; + + /** + * @brief Processing function for the Q7 FIR filter. + * @param[in] S points to an instance of the Q7 FIR filter structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_fir_q7( + const arm_fir_instance_q7 * S, + const q7_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the Q7 FIR filter. + * @param[in,out] S points to an instance of the Q7 FIR structure. + * @param[in] numTaps Number of filter coefficients in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of samples that are processed. + */ + void arm_fir_init_q7( + arm_fir_instance_q7 * S, + uint16_t numTaps, + const q7_t * pCoeffs, + q7_t * pState, + uint32_t blockSize); + + /** + * @brief Processing function for the Q15 FIR filter. + * @param[in] S points to an instance of the Q15 FIR structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_fir_q15( + const arm_fir_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + /** + * @brief Processing function for the fast Q15 FIR filter (fast version). + * @param[in] S points to an instance of the Q15 FIR filter structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_fir_fast_q15( + const arm_fir_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the Q15 FIR filter. + * @param[in,out] S points to an instance of the Q15 FIR filter structure. + * @param[in] numTaps Number of filter coefficients in the filter. Must be even and greater than or equal to 4. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of samples that are processed at a time. + * @return The function returns either + * ARM_MATH_SUCCESS if initialization was successful or + * ARM_MATH_ARGUMENT_ERROR if numTaps is not a supported value. + */ + arm_status arm_fir_init_q15( + arm_fir_instance_q15 * S, + uint16_t numTaps, + const q15_t * pCoeffs, + q15_t * pState, + uint32_t blockSize); + + /** + * @brief Processing function for the Q31 FIR filter. + * @param[in] S points to an instance of the Q31 FIR filter structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_fir_q31( + const arm_fir_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + /** + * @brief Processing function for the fast Q31 FIR filter (fast version). + * @param[in] S points to an instance of the Q31 FIR filter structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_fir_fast_q31( + const arm_fir_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the Q31 FIR filter. + * @param[in,out] S points to an instance of the Q31 FIR structure. + * @param[in] numTaps Number of filter coefficients in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of samples that are processed at a time. + */ + void arm_fir_init_q31( + arm_fir_instance_q31 * S, + uint16_t numTaps, + const q31_t * pCoeffs, + q31_t * pState, + uint32_t blockSize); + + /** + * @brief Processing function for the floating-point FIR filter. + * @param[in] S points to an instance of the floating-point FIR structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_fir_f32( + const arm_fir_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the floating-point FIR filter. + * @param[in,out] S points to an instance of the floating-point FIR filter structure. + * @param[in] numTaps Number of filter coefficients in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of samples that are processed at a time. + */ + void arm_fir_init_f32( + arm_fir_instance_f32 * S, + uint16_t numTaps, + const float32_t * pCoeffs, + float32_t * pState, + uint32_t blockSize); + + /** + * @brief Instance structure for the Q15 Biquad cascade filter. + */ + typedef struct + { + int8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ + q15_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ + const q15_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ + int8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ + } arm_biquad_casd_df1_inst_q15; + + /** + * @brief Instance structure for the Q31 Biquad cascade filter. + */ + typedef struct + { + uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ + q31_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ + const q31_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ + uint8_t postShift; /**< Additional shift, in bits, applied to each output sample. */ + } arm_biquad_casd_df1_inst_q31; + + /** + * @brief Instance structure for the floating-point Biquad cascade filter. + */ + typedef struct + { + uint32_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ + float32_t *pState; /**< Points to the array of state coefficients. The array is of length 4*numStages. */ + const float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ + } arm_biquad_casd_df1_inst_f32; + +#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) + /** + * @brief Instance structure for the modified Biquad coefs required by vectorized code. + */ + typedef struct + { + float32_t coeffs[8][4]; /**< Points to the array of modified coefficients. The array is of length 32. There is one per stage */ + } arm_biquad_mod_coef_f32; +#endif + + /** + * @brief Processing function for the Q15 Biquad cascade filter. + * @param[in] S points to an instance of the Q15 Biquad cascade structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_df1_q15( + const arm_biquad_casd_df1_inst_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the Q15 Biquad cascade filter. + * @param[in,out] S points to an instance of the Q15 Biquad cascade structure. + * @param[in] numStages number of 2nd order stages in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format + */ + void arm_biquad_cascade_df1_init_q15( + arm_biquad_casd_df1_inst_q15 * S, + uint8_t numStages, + const q15_t * pCoeffs, + q15_t * pState, + int8_t postShift); + + /** + * @brief Fast but less precise processing function for the Q15 Biquad cascade filter for Cortex-M3 and Cortex-M4. + * @param[in] S points to an instance of the Q15 Biquad cascade structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_df1_fast_q15( + const arm_biquad_casd_df1_inst_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + /** + * @brief Processing function for the Q31 Biquad cascade filter + * @param[in] S points to an instance of the Q31 Biquad cascade structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_df1_q31( + const arm_biquad_casd_df1_inst_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + /** + * @brief Fast but less precise processing function for the Q31 Biquad cascade filter for Cortex-M3 and Cortex-M4. + * @param[in] S points to an instance of the Q31 Biquad cascade structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_df1_fast_q31( + const arm_biquad_casd_df1_inst_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the Q31 Biquad cascade filter. + * @param[in,out] S points to an instance of the Q31 Biquad cascade structure. + * @param[in] numStages number of 2nd order stages in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] postShift Shift to be applied to the output. Varies according to the coefficients format + */ + void arm_biquad_cascade_df1_init_q31( + arm_biquad_casd_df1_inst_q31 * S, + uint8_t numStages, + const q31_t * pCoeffs, + q31_t * pState, + int8_t postShift); + + /** + * @brief Processing function for the floating-point Biquad cascade filter. + * @param[in] S points to an instance of the floating-point Biquad cascade structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_df1_f32( + const arm_biquad_casd_df1_inst_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the floating-point Biquad cascade filter. + * @param[in,out] S points to an instance of the floating-point Biquad cascade structure. + * @param[in] numStages number of 2nd order stages in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pCoeffsMod points to the modified filter coefficients (only MVE version). + * @param[in] pState points to the state buffer. + */ +#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) + void arm_biquad_cascade_df1_mve_init_f32( + arm_biquad_casd_df1_inst_f32 * S, + uint8_t numStages, + const float32_t * pCoeffs, + arm_biquad_mod_coef_f32 * pCoeffsMod, + float32_t * pState); +#endif + + void arm_biquad_cascade_df1_init_f32( + arm_biquad_casd_df1_inst_f32 * S, + uint8_t numStages, + const float32_t * pCoeffs, + float32_t * pState); + + + /** + * @brief Compute the logical bitwise AND of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_and_u16( + const uint16_t * pSrcA, + const uint16_t * pSrcB, + uint16_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise AND of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_and_u32( + const uint32_t * pSrcA, + const uint32_t * pSrcB, + uint32_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise AND of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_and_u8( + const uint8_t * pSrcA, + const uint8_t * pSrcB, + uint8_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise OR of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_or_u16( + const uint16_t * pSrcA, + const uint16_t * pSrcB, + uint16_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise OR of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_or_u32( + const uint32_t * pSrcA, + const uint32_t * pSrcB, + uint32_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise OR of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_or_u8( + const uint8_t * pSrcA, + const uint8_t * pSrcB, + uint8_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise NOT of a fixed-point vector. + * @param[in] pSrc points to input vector + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_not_u16( + const uint16_t * pSrc, + uint16_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise NOT of a fixed-point vector. + * @param[in] pSrc points to input vector + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_not_u32( + const uint32_t * pSrc, + uint32_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise NOT of a fixed-point vector. + * @param[in] pSrc points to input vector + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_not_u8( + const uint8_t * pSrc, + uint8_t * pDst, + uint32_t blockSize); + +/** + * @brief Compute the logical bitwise XOR of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_xor_u16( + const uint16_t * pSrcA, + const uint16_t * pSrcB, + uint16_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise XOR of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_xor_u32( + const uint32_t * pSrcA, + const uint32_t * pSrcB, + uint32_t * pDst, + uint32_t blockSize); + + /** + * @brief Compute the logical bitwise XOR of two fixed-point vectors. + * @param[in] pSrcA points to input vector A + * @param[in] pSrcB points to input vector B + * @param[out] pDst points to output vector + * @param[in] blockSize number of samples in each vector + * @return none + */ + void arm_xor_u8( + const uint8_t * pSrcA, + const uint8_t * pSrcB, + uint8_t * pDst, + uint32_t blockSize); + + /** + * @brief Struct for specifying sorting algorithm + */ + typedef enum + { + ARM_SORT_BITONIC = 0, + /**< Bitonic sort */ + ARM_SORT_BUBBLE = 1, + /**< Bubble sort */ + ARM_SORT_HEAP = 2, + /**< Heap sort */ + ARM_SORT_INSERTION = 3, + /**< Insertion sort */ + ARM_SORT_QUICK = 4, + /**< Quick sort */ + ARM_SORT_SELECTION = 5 + /**< Selection sort */ + } arm_sort_alg; + + /** + * @brief Struct for specifying sorting algorithm + */ + typedef enum + { + ARM_SORT_DESCENDING = 0, + /**< Descending order (9 to 0) */ + ARM_SORT_ASCENDING = 1 + /**< Ascending order (0 to 9) */ + } arm_sort_dir; + + /** + * @brief Instance structure for the sorting algorithms. + */ + typedef struct + { + arm_sort_alg alg; /**< Sorting algorithm selected */ + arm_sort_dir dir; /**< Sorting order (direction) */ + } arm_sort_instance_f32; + + /** + * @param[in] S points to an instance of the sorting structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_sort_f32( + const arm_sort_instance_f32 * S, + float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + /** + * @param[in,out] S points to an instance of the sorting structure. + * @param[in] alg Selected algorithm. + * @param[in] dir Sorting order. + */ + void arm_sort_init_f32( + arm_sort_instance_f32 * S, + arm_sort_alg alg, + arm_sort_dir dir); + + /** + * @brief Instance structure for the sorting algorithms. + */ + typedef struct + { + arm_sort_dir dir; /**< Sorting order (direction) */ + float32_t * buffer; /**< Working buffer */ + } arm_merge_sort_instance_f32; + + /** + * @param[in] S points to an instance of the sorting structure. + * @param[in,out] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ + void arm_merge_sort_f32( + const arm_merge_sort_instance_f32 * S, + float32_t *pSrc, + float32_t *pDst, + uint32_t blockSize); + + /** + * @param[in,out] S points to an instance of the sorting structure. + * @param[in] dir Sorting order. + * @param[in] buffer Working buffer. + */ + void arm_merge_sort_init_f32( + arm_merge_sort_instance_f32 * S, + arm_sort_dir dir, + float32_t * buffer); + + /** + * @brief Struct for specifying cubic spline type + */ + typedef enum + { + ARM_SPLINE_NATURAL = 0, /**< Natural spline */ + ARM_SPLINE_PARABOLIC_RUNOUT = 1 /**< Parabolic runout spline */ + } arm_spline_type; + + /** + * @brief Instance structure for the floating-point cubic spline interpolation. + */ + typedef struct + { + arm_spline_type type; /**< Type (boundary conditions) */ + const float32_t * x; /**< x values */ + const float32_t * y; /**< y values */ + uint32_t n_x; /**< Number of known data points */ + float32_t * coeffs; /**< Coefficients buffer (b,c, and d) */ + } arm_spline_instance_f32; + + /** + * @brief Processing function for the floating-point cubic spline interpolation. + * @param[in] S points to an instance of the floating-point spline structure. + * @param[in] xq points to the x values ot the interpolated data points. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples of output data. + */ + void arm_spline_f32( + arm_spline_instance_f32 * S, + const float32_t * xq, + float32_t * pDst, + uint32_t blockSize); + + /** + * @brief Initialization function for the floating-point cubic spline interpolation. + * @param[in,out] S points to an instance of the floating-point spline structure. + * @param[in] type type of cubic spline interpolation (boundary conditions) + * @param[in] x points to the x values of the known data points. + * @param[in] y points to the y values of the known data points. + * @param[in] n number of known data points. + * @param[in] coeffs coefficients array for b, c, and d + * @param[in] tempBuffer buffer array for internal computations + */ + void arm_spline_init_f32( + arm_spline_instance_f32 * S, + arm_spline_type type, + const float32_t * x, + const float32_t * y, + uint32_t n, + float32_t * coeffs, + float32_t * tempBuffer); + + /** + * @brief Instance structure for the floating-point matrix structure. + */ + typedef struct + { + uint16_t numRows; /**< number of rows of the matrix. */ + uint16_t numCols; /**< number of columns of the matrix. */ + float32_t *pData; /**< points to the data of the matrix. */ + } arm_matrix_instance_f32; + + /** + * @brief Instance structure for the floating-point matrix structure. + */ + typedef struct + { + uint16_t numRows; /**< number of rows of the matrix. */ + uint16_t numCols; /**< number of columns of the matrix. */ + float64_t *pData; /**< points to the data of the matrix. */ + } arm_matrix_instance_f64; + + /** + * @brief Instance structure for the Q15 matrix structure. + */ + typedef struct + { + uint16_t numRows; /**< number of rows of the matrix. */ + uint16_t numCols; /**< number of columns of the matrix. */ + q15_t *pData; /**< points to the data of the matrix. */ + } arm_matrix_instance_q15; + + /** + * @brief Instance structure for the Q31 matrix structure. + */ + typedef struct + { + uint16_t numRows; /**< number of rows of the matrix. */ + uint16_t numCols; /**< number of columns of the matrix. */ + q31_t *pData; /**< points to the data of the matrix. */ + } arm_matrix_instance_q31; + + /** + * @brief Floating-point matrix addition. + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_add_f32( + const arm_matrix_instance_f32 * pSrcA, + const arm_matrix_instance_f32 * pSrcB, + arm_matrix_instance_f32 * pDst); + + /** + * @brief Q15 matrix addition. + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_add_q15( + const arm_matrix_instance_q15 * pSrcA, + const arm_matrix_instance_q15 * pSrcB, + arm_matrix_instance_q15 * pDst); + + /** + * @brief Q31 matrix addition. + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_add_q31( + const arm_matrix_instance_q31 * pSrcA, + const arm_matrix_instance_q31 * pSrcB, + arm_matrix_instance_q31 * pDst); + + /** + * @brief Floating-point, complex, matrix multiplication. + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_cmplx_mult_f32( + const arm_matrix_instance_f32 * pSrcA, + const arm_matrix_instance_f32 * pSrcB, + arm_matrix_instance_f32 * pDst); + + /** + * @brief Q15, complex, matrix multiplication. + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_cmplx_mult_q15( + const arm_matrix_instance_q15 * pSrcA, + const arm_matrix_instance_q15 * pSrcB, + arm_matrix_instance_q15 * pDst, + q15_t * pScratch); + + /** + * @brief Q31, complex, matrix multiplication. + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_cmplx_mult_q31( + const arm_matrix_instance_q31 * pSrcA, + const arm_matrix_instance_q31 * pSrcB, + arm_matrix_instance_q31 * pDst); + + /** + * @brief Floating-point matrix transpose. + * @param[in] pSrc points to the input matrix + * @param[out] pDst points to the output matrix + * @return The function returns either ARM_MATH_SIZE_MISMATCH + * or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_trans_f32( + const arm_matrix_instance_f32 * pSrc, + arm_matrix_instance_f32 * pDst); + + /** + * @brief Q15 matrix transpose. + * @param[in] pSrc points to the input matrix + * @param[out] pDst points to the output matrix + * @return The function returns either ARM_MATH_SIZE_MISMATCH + * or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_trans_q15( + const arm_matrix_instance_q15 * pSrc, + arm_matrix_instance_q15 * pDst); + + /** + * @brief Q31 matrix transpose. + * @param[in] pSrc points to the input matrix + * @param[out] pDst points to the output matrix + * @return The function returns either ARM_MATH_SIZE_MISMATCH + * or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_trans_q31( + const arm_matrix_instance_q31 * pSrc, + arm_matrix_instance_q31 * pDst); + + /** + * @brief Floating-point matrix multiplication + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_mult_f32( + const arm_matrix_instance_f32 * pSrcA, + const arm_matrix_instance_f32 * pSrcB, + arm_matrix_instance_f32 * pDst); + + /** + * @brief Q15 matrix multiplication + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @param[in] pState points to the array for storing intermediate results + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_mult_q15( + const arm_matrix_instance_q15 * pSrcA, + const arm_matrix_instance_q15 * pSrcB, + arm_matrix_instance_q15 * pDst, + q15_t * pState); + + /** + * @brief Q15 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @param[in] pState points to the array for storing intermediate results + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_mult_fast_q15( + const arm_matrix_instance_q15 * pSrcA, + const arm_matrix_instance_q15 * pSrcB, + arm_matrix_instance_q15 * pDst, + q15_t * pState); + + /** + * @brief Q31 matrix multiplication + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_mult_q31( + const arm_matrix_instance_q31 * pSrcA, + const arm_matrix_instance_q31 * pSrcB, + arm_matrix_instance_q31 * pDst); + + /** + * @brief Q31 matrix multiplication (fast variant) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_mult_fast_q31( + const arm_matrix_instance_q31 * pSrcA, + const arm_matrix_instance_q31 * pSrcB, + arm_matrix_instance_q31 * pDst); + + /** + * @brief Floating-point matrix subtraction + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_sub_f32( + const arm_matrix_instance_f32 * pSrcA, + const arm_matrix_instance_f32 * pSrcB, + arm_matrix_instance_f32 * pDst); + + /** + * @brief Q15 matrix subtraction + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_sub_q15( + const arm_matrix_instance_q15 * pSrcA, + const arm_matrix_instance_q15 * pSrcB, + arm_matrix_instance_q15 * pDst); + + /** + * @brief Q31 matrix subtraction + * @param[in] pSrcA points to the first input matrix structure + * @param[in] pSrcB points to the second input matrix structure + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_sub_q31( + const arm_matrix_instance_q31 * pSrcA, + const arm_matrix_instance_q31 * pSrcB, + arm_matrix_instance_q31 * pDst); + + /** + * @brief Floating-point matrix scaling. + * @param[in] pSrc points to the input matrix + * @param[in] scale scale factor + * @param[out] pDst points to the output matrix + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_scale_f32( + const arm_matrix_instance_f32 * pSrc, + float32_t scale, + arm_matrix_instance_f32 * pDst); + + /** + * @brief Q15 matrix scaling. + * @param[in] pSrc points to input matrix + * @param[in] scaleFract fractional portion of the scale factor + * @param[in] shift number of bits to shift the result by + * @param[out] pDst points to output matrix + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_scale_q15( + const arm_matrix_instance_q15 * pSrc, + q15_t scaleFract, + int32_t shift, + arm_matrix_instance_q15 * pDst); + + /** + * @brief Q31 matrix scaling. + * @param[in] pSrc points to input matrix + * @param[in] scaleFract fractional portion of the scale factor + * @param[in] shift number of bits to shift the result by + * @param[out] pDst points to output matrix structure + * @return The function returns either + * ARM_MATH_SIZE_MISMATCH or ARM_MATH_SUCCESS based on the outcome of size checking. + */ +arm_status arm_mat_scale_q31( + const arm_matrix_instance_q31 * pSrc, + q31_t scaleFract, + int32_t shift, + arm_matrix_instance_q31 * pDst); + + /** + * @brief Q31 matrix initialization. + * @param[in,out] S points to an instance of the floating-point matrix structure. + * @param[in] nRows number of rows in the matrix. + * @param[in] nColumns number of columns in the matrix. + * @param[in] pData points to the matrix data array. + */ +void arm_mat_init_q31( + arm_matrix_instance_q31 * S, + uint16_t nRows, + uint16_t nColumns, + q31_t * pData); + + /** + * @brief Q15 matrix initialization. + * @param[in,out] S points to an instance of the floating-point matrix structure. + * @param[in] nRows number of rows in the matrix. + * @param[in] nColumns number of columns in the matrix. + * @param[in] pData points to the matrix data array. + */ +void arm_mat_init_q15( + arm_matrix_instance_q15 * S, + uint16_t nRows, + uint16_t nColumns, + q15_t * pData); + + /** + * @brief Floating-point matrix initialization. + * @param[in,out] S points to an instance of the floating-point matrix structure. + * @param[in] nRows number of rows in the matrix. + * @param[in] nColumns number of columns in the matrix. + * @param[in] pData points to the matrix data array. + */ +void arm_mat_init_f32( + arm_matrix_instance_f32 * S, + uint16_t nRows, + uint16_t nColumns, + float32_t * pData); + + + /** + * @brief Instance structure for the Q15 PID Control. + */ + typedef struct + { + q15_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ +#if !defined (ARM_MATH_DSP) + q15_t A1; + q15_t A2; +#else + q31_t A1; /**< The derived gain A1 = -Kp - 2Kd | Kd.*/ +#endif + q15_t state[3]; /**< The state array of length 3. */ + q15_t Kp; /**< The proportional gain. */ + q15_t Ki; /**< The integral gain. */ + q15_t Kd; /**< The derivative gain. */ + } arm_pid_instance_q15; + + /** + * @brief Instance structure for the Q31 PID Control. + */ + typedef struct + { + q31_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ + q31_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ + q31_t A2; /**< The derived gain, A2 = Kd . */ + q31_t state[3]; /**< The state array of length 3. */ + q31_t Kp; /**< The proportional gain. */ + q31_t Ki; /**< The integral gain. */ + q31_t Kd; /**< The derivative gain. */ + } arm_pid_instance_q31; + + /** + * @brief Instance structure for the floating-point PID Control. + */ + typedef struct + { + float32_t A0; /**< The derived gain, A0 = Kp + Ki + Kd . */ + float32_t A1; /**< The derived gain, A1 = -Kp - 2Kd. */ + float32_t A2; /**< The derived gain, A2 = Kd . */ + float32_t state[3]; /**< The state array of length 3. */ + float32_t Kp; /**< The proportional gain. */ + float32_t Ki; /**< The integral gain. */ + float32_t Kd; /**< The derivative gain. */ + } arm_pid_instance_f32; + + + + /** + * @brief Initialization function for the floating-point PID Control. + * @param[in,out] S points to an instance of the PID structure. + * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. + */ + void arm_pid_init_f32( + arm_pid_instance_f32 * S, + int32_t resetStateFlag); + + + /** + * @brief Reset function for the floating-point PID Control. + * @param[in,out] S is an instance of the floating-point PID Control structure + */ + void arm_pid_reset_f32( + arm_pid_instance_f32 * S); + + + /** + * @brief Initialization function for the Q31 PID Control. + * @param[in,out] S points to an instance of the Q15 PID structure. + * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. + */ + void arm_pid_init_q31( + arm_pid_instance_q31 * S, + int32_t resetStateFlag); + + + /** + * @brief Reset function for the Q31 PID Control. + * @param[in,out] S points to an instance of the Q31 PID Control structure + */ + + void arm_pid_reset_q31( + arm_pid_instance_q31 * S); + + + /** + * @brief Initialization function for the Q15 PID Control. + * @param[in,out] S points to an instance of the Q15 PID structure. + * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. + */ + void arm_pid_init_q15( + arm_pid_instance_q15 * S, + int32_t resetStateFlag); + + + /** + * @brief Reset function for the Q15 PID Control. + * @param[in,out] S points to an instance of the q15 PID Control structure + */ + void arm_pid_reset_q15( + arm_pid_instance_q15 * S); + + + /** + * @brief Instance structure for the floating-point Linear Interpolate function. + */ + typedef struct + { + uint32_t nValues; /**< nValues */ + float32_t x1; /**< x1 */ + float32_t xSpacing; /**< xSpacing */ + float32_t *pYData; /**< pointer to the table of Y values */ + } arm_linear_interp_instance_f32; + + /** + * @brief Instance structure for the floating-point bilinear interpolation function. + */ + typedef struct + { + uint16_t numRows; /**< number of rows in the data table. */ + uint16_t numCols; /**< number of columns in the data table. */ + float32_t *pData; /**< points to the data table. */ + } arm_bilinear_interp_instance_f32; + + /** + * @brief Instance structure for the Q31 bilinear interpolation function. + */ + typedef struct + { + uint16_t numRows; /**< number of rows in the data table. */ + uint16_t numCols; /**< number of columns in the data table. */ + q31_t *pData; /**< points to the data table. */ + } arm_bilinear_interp_instance_q31; + + /** + * @brief Instance structure for the Q15 bilinear interpolation function. + */ + typedef struct + { + uint16_t numRows; /**< number of rows in the data table. */ + uint16_t numCols; /**< number of columns in the data table. */ + q15_t *pData; /**< points to the data table. */ + } arm_bilinear_interp_instance_q15; + + /** + * @brief Instance structure for the Q15 bilinear interpolation function. + */ + typedef struct + { + uint16_t numRows; /**< number of rows in the data table. */ + uint16_t numCols; /**< number of columns in the data table. */ + q7_t *pData; /**< points to the data table. */ + } arm_bilinear_interp_instance_q7; + + + /** + * @brief Q7 vector multiplication. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_mult_q7( + const q7_t * pSrcA, + const q7_t * pSrcB, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q15 vector multiplication. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_mult_q15( + const q15_t * pSrcA, + const q15_t * pSrcB, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q31 vector multiplication. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_mult_q31( + const q31_t * pSrcA, + const q31_t * pSrcB, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Floating-point vector multiplication. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_mult_f32( + const float32_t * pSrcA, + const float32_t * pSrcB, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Instance structure for the Q15 CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ + uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ + const q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ + } arm_cfft_radix2_instance_q15; + +/* Deprecated */ + arm_status arm_cfft_radix2_init_q15( + arm_cfft_radix2_instance_q15 * S, + uint16_t fftLen, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + +/* Deprecated */ + void arm_cfft_radix2_q15( + const arm_cfft_radix2_instance_q15 * S, + q15_t * pSrc); + + + /** + * @brief Instance structure for the Q15 CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ + uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ + const q15_t *pTwiddle; /**< points to the twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ + } arm_cfft_radix4_instance_q15; + +/* Deprecated */ + arm_status arm_cfft_radix4_init_q15( + arm_cfft_radix4_instance_q15 * S, + uint16_t fftLen, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + +/* Deprecated */ + void arm_cfft_radix4_q15( + const arm_cfft_radix4_instance_q15 * S, + q15_t * pSrc); + + /** + * @brief Instance structure for the Radix-2 Q31 CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ + uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ + const q31_t *pTwiddle; /**< points to the Twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ + } arm_cfft_radix2_instance_q31; + +/* Deprecated */ + arm_status arm_cfft_radix2_init_q31( + arm_cfft_radix2_instance_q31 * S, + uint16_t fftLen, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + +/* Deprecated */ + void arm_cfft_radix2_q31( + const arm_cfft_radix2_instance_q31 * S, + q31_t * pSrc); + + /** + * @brief Instance structure for the Q31 CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ + uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ + const q31_t *pTwiddle; /**< points to the twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ + } arm_cfft_radix4_instance_q31; + +/* Deprecated */ + void arm_cfft_radix4_q31( + const arm_cfft_radix4_instance_q31 * S, + q31_t * pSrc); + +/* Deprecated */ + arm_status arm_cfft_radix4_init_q31( + arm_cfft_radix4_instance_q31 * S, + uint16_t fftLen, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + + /** + * @brief Instance structure for the floating-point CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ + uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ + const float32_t *pTwiddle; /**< points to the Twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ + float32_t onebyfftLen; /**< value of 1/fftLen. */ + } arm_cfft_radix2_instance_f32; + +/* Deprecated */ + arm_status arm_cfft_radix2_init_f32( + arm_cfft_radix2_instance_f32 * S, + uint16_t fftLen, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + +/* Deprecated */ + void arm_cfft_radix2_f32( + const arm_cfft_radix2_instance_f32 * S, + float32_t * pSrc); + + /** + * @brief Instance structure for the floating-point CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + uint8_t ifftFlag; /**< flag that selects forward (ifftFlag=0) or inverse (ifftFlag=1) transform. */ + uint8_t bitReverseFlag; /**< flag that enables (bitReverseFlag=1) or disables (bitReverseFlag=0) bit reversal of output. */ + const float32_t *pTwiddle; /**< points to the Twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t twidCoefModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + uint16_t bitRevFactor; /**< bit reversal modifier that supports different size FFTs with the same bit reversal table. */ + float32_t onebyfftLen; /**< value of 1/fftLen. */ + } arm_cfft_radix4_instance_f32; + +/* Deprecated */ + arm_status arm_cfft_radix4_init_f32( + arm_cfft_radix4_instance_f32 * S, + uint16_t fftLen, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + +/* Deprecated */ + void arm_cfft_radix4_f32( + const arm_cfft_radix4_instance_f32 * S, + float32_t * pSrc); + + /** + * @brief Instance structure for the fixed-point CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + const q15_t *pTwiddle; /**< points to the Twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t bitRevLength; /**< bit reversal table length. */ +#if defined(ARM_MATH_MVEI) + const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \ + const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \ + const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \ + const q15_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \ + const q15_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \ + const q15_t *rearranged_twiddle_stride3; +#endif + } arm_cfft_instance_q15; + +arm_status arm_cfft_init_q15( + arm_cfft_instance_q15 * S, + uint16_t fftLen); + +void arm_cfft_q15( + const arm_cfft_instance_q15 * S, + q15_t * p1, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + + /** + * @brief Instance structure for the fixed-point CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + const q31_t *pTwiddle; /**< points to the Twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t bitRevLength; /**< bit reversal table length. */ +#if defined(ARM_MATH_MVEI) + const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \ + const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \ + const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \ + const q31_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \ + const q31_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \ + const q31_t *rearranged_twiddle_stride3; +#endif + } arm_cfft_instance_q31; + +arm_status arm_cfft_init_q31( + arm_cfft_instance_q31 * S, + uint16_t fftLen); + +void arm_cfft_q31( + const arm_cfft_instance_q31 * S, + q31_t * p1, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + + /** + * @brief Instance structure for the floating-point CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + const float32_t *pTwiddle; /**< points to the Twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t bitRevLength; /**< bit reversal table length. */ +#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) + const uint32_t *rearranged_twiddle_tab_stride1_arr; /**< Per stage reordered twiddle pointer (offset 1) */ \ + const uint32_t *rearranged_twiddle_tab_stride2_arr; /**< Per stage reordered twiddle pointer (offset 2) */ \ + const uint32_t *rearranged_twiddle_tab_stride3_arr; /**< Per stage reordered twiddle pointer (offset 3) */ \ + const float32_t *rearranged_twiddle_stride1; /**< reordered twiddle offset 1 storage */ \ + const float32_t *rearranged_twiddle_stride2; /**< reordered twiddle offset 2 storage */ \ + const float32_t *rearranged_twiddle_stride3; +#endif + } arm_cfft_instance_f32; + + + arm_status arm_cfft_init_f32( + arm_cfft_instance_f32 * S, + uint16_t fftLen); + + void arm_cfft_f32( + const arm_cfft_instance_f32 * S, + float32_t * p1, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + + + /** + * @brief Instance structure for the Double Precision Floating-point CFFT/CIFFT function. + */ + typedef struct + { + uint16_t fftLen; /**< length of the FFT. */ + const float64_t *pTwiddle; /**< points to the Twiddle factor table. */ + const uint16_t *pBitRevTable; /**< points to the bit reversal table. */ + uint16_t bitRevLength; /**< bit reversal table length. */ + } arm_cfft_instance_f64; + + void arm_cfft_f64( + const arm_cfft_instance_f64 * S, + float64_t * p1, + uint8_t ifftFlag, + uint8_t bitReverseFlag); + + /** + * @brief Instance structure for the Q15 RFFT/RIFFT function. + */ + typedef struct + { + uint32_t fftLenReal; /**< length of the real FFT. */ + uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ + uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ + uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + const q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ + const q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ +#if defined(ARM_MATH_MVEI) + arm_cfft_instance_q15 cfftInst; +#else + const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */ +#endif + } arm_rfft_instance_q15; + + arm_status arm_rfft_init_q15( + arm_rfft_instance_q15 * S, + uint32_t fftLenReal, + uint32_t ifftFlagR, + uint32_t bitReverseFlag); + + void arm_rfft_q15( + const arm_rfft_instance_q15 * S, + q15_t * pSrc, + q15_t * pDst); + + /** + * @brief Instance structure for the Q31 RFFT/RIFFT function. + */ + typedef struct + { + uint32_t fftLenReal; /**< length of the real FFT. */ + uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ + uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ + uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + const q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ + const q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ +#if defined(ARM_MATH_MVEI) + arm_cfft_instance_q31 cfftInst; +#else + const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */ +#endif + } arm_rfft_instance_q31; + + arm_status arm_rfft_init_q31( + arm_rfft_instance_q31 * S, + uint32_t fftLenReal, + uint32_t ifftFlagR, + uint32_t bitReverseFlag); + + void arm_rfft_q31( + const arm_rfft_instance_q31 * S, + q31_t * pSrc, + q31_t * pDst); + + /** + * @brief Instance structure for the floating-point RFFT/RIFFT function. + */ + typedef struct + { + uint32_t fftLenReal; /**< length of the real FFT. */ + uint16_t fftLenBy2; /**< length of the complex FFT. */ + uint8_t ifftFlagR; /**< flag that selects forward (ifftFlagR=0) or inverse (ifftFlagR=1) transform. */ + uint8_t bitReverseFlagR; /**< flag that enables (bitReverseFlagR=1) or disables (bitReverseFlagR=0) bit reversal of output. */ + uint32_t twidCoefRModifier; /**< twiddle coefficient modifier that supports different size FFTs with the same twiddle factor table. */ + const float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ + const float32_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ + arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ + } arm_rfft_instance_f32; + + arm_status arm_rfft_init_f32( + arm_rfft_instance_f32 * S, + arm_cfft_radix4_instance_f32 * S_CFFT, + uint32_t fftLenReal, + uint32_t ifftFlagR, + uint32_t bitReverseFlag); + + void arm_rfft_f32( + const arm_rfft_instance_f32 * S, + float32_t * pSrc, + float32_t * pDst); + + /** + * @brief Instance structure for the Double Precision Floating-point RFFT/RIFFT function. + */ +typedef struct + { + arm_cfft_instance_f64 Sint; /**< Internal CFFT structure. */ + uint16_t fftLenRFFT; /**< length of the real sequence */ + const float64_t * pTwiddleRFFT; /**< Twiddle factors real stage */ + } arm_rfft_fast_instance_f64 ; + +arm_status arm_rfft_fast_init_f64 ( + arm_rfft_fast_instance_f64 * S, + uint16_t fftLen); + + +void arm_rfft_fast_f64( + arm_rfft_fast_instance_f64 * S, + float64_t * p, float64_t * pOut, + uint8_t ifftFlag); + + + /** + * @brief Instance structure for the floating-point RFFT/RIFFT function. + */ +typedef struct + { + arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */ + uint16_t fftLenRFFT; /**< length of the real sequence */ + const float32_t * pTwiddleRFFT; /**< Twiddle factors real stage */ + } arm_rfft_fast_instance_f32 ; + +arm_status arm_rfft_fast_init_f32 ( + arm_rfft_fast_instance_f32 * S, + uint16_t fftLen); + + + void arm_rfft_fast_f32( + const arm_rfft_fast_instance_f32 * S, + float32_t * p, float32_t * pOut, + uint8_t ifftFlag); + + /** + * @brief Instance structure for the floating-point DCT4/IDCT4 function. + */ + typedef struct + { + uint16_t N; /**< length of the DCT4. */ + uint16_t Nby2; /**< half of the length of the DCT4. */ + float32_t normalize; /**< normalizing factor. */ + const float32_t *pTwiddle; /**< points to the twiddle factor table. */ + const float32_t *pCosFactor; /**< points to the cosFactor table. */ + arm_rfft_instance_f32 *pRfft; /**< points to the real FFT instance. */ + arm_cfft_radix4_instance_f32 *pCfft; /**< points to the complex FFT instance. */ + } arm_dct4_instance_f32; + + + /** + * @brief Initialization function for the floating-point DCT4/IDCT4. + * @param[in,out] S points to an instance of floating-point DCT4/IDCT4 structure. + * @param[in] S_RFFT points to an instance of floating-point RFFT/RIFFT structure. + * @param[in] S_CFFT points to an instance of floating-point CFFT/CIFFT structure. + * @param[in] N length of the DCT4. + * @param[in] Nby2 half of the length of the DCT4. + * @param[in] normalize normalizing factor. + * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if fftLenReal is not a supported transform length. + */ + arm_status arm_dct4_init_f32( + arm_dct4_instance_f32 * S, + arm_rfft_instance_f32 * S_RFFT, + arm_cfft_radix4_instance_f32 * S_CFFT, + uint16_t N, + uint16_t Nby2, + float32_t normalize); + + + /** + * @brief Processing function for the floating-point DCT4/IDCT4. + * @param[in] S points to an instance of the floating-point DCT4/IDCT4 structure. + * @param[in] pState points to state buffer. + * @param[in,out] pInlineBuffer points to the in-place input and output buffer. + */ + void arm_dct4_f32( + const arm_dct4_instance_f32 * S, + float32_t * pState, + float32_t * pInlineBuffer); + + + /** + * @brief Instance structure for the Q31 DCT4/IDCT4 function. + */ + typedef struct + { + uint16_t N; /**< length of the DCT4. */ + uint16_t Nby2; /**< half of the length of the DCT4. */ + q31_t normalize; /**< normalizing factor. */ + const q31_t *pTwiddle; /**< points to the twiddle factor table. */ + const q31_t *pCosFactor; /**< points to the cosFactor table. */ + arm_rfft_instance_q31 *pRfft; /**< points to the real FFT instance. */ + arm_cfft_radix4_instance_q31 *pCfft; /**< points to the complex FFT instance. */ + } arm_dct4_instance_q31; + + + /** + * @brief Initialization function for the Q31 DCT4/IDCT4. + * @param[in,out] S points to an instance of Q31 DCT4/IDCT4 structure. + * @param[in] S_RFFT points to an instance of Q31 RFFT/RIFFT structure + * @param[in] S_CFFT points to an instance of Q31 CFFT/CIFFT structure + * @param[in] N length of the DCT4. + * @param[in] Nby2 half of the length of the DCT4. + * @param[in] normalize normalizing factor. + * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if N is not a supported transform length. + */ + arm_status arm_dct4_init_q31( + arm_dct4_instance_q31 * S, + arm_rfft_instance_q31 * S_RFFT, + arm_cfft_radix4_instance_q31 * S_CFFT, + uint16_t N, + uint16_t Nby2, + q31_t normalize); + + + /** + * @brief Processing function for the Q31 DCT4/IDCT4. + * @param[in] S points to an instance of the Q31 DCT4 structure. + * @param[in] pState points to state buffer. + * @param[in,out] pInlineBuffer points to the in-place input and output buffer. + */ + void arm_dct4_q31( + const arm_dct4_instance_q31 * S, + q31_t * pState, + q31_t * pInlineBuffer); + + + /** + * @brief Instance structure for the Q15 DCT4/IDCT4 function. + */ + typedef struct + { + uint16_t N; /**< length of the DCT4. */ + uint16_t Nby2; /**< half of the length of the DCT4. */ + q15_t normalize; /**< normalizing factor. */ + const q15_t *pTwiddle; /**< points to the twiddle factor table. */ + const q15_t *pCosFactor; /**< points to the cosFactor table. */ + arm_rfft_instance_q15 *pRfft; /**< points to the real FFT instance. */ + arm_cfft_radix4_instance_q15 *pCfft; /**< points to the complex FFT instance. */ + } arm_dct4_instance_q15; + + + /** + * @brief Initialization function for the Q15 DCT4/IDCT4. + * @param[in,out] S points to an instance of Q15 DCT4/IDCT4 structure. + * @param[in] S_RFFT points to an instance of Q15 RFFT/RIFFT structure. + * @param[in] S_CFFT points to an instance of Q15 CFFT/CIFFT structure. + * @param[in] N length of the DCT4. + * @param[in] Nby2 half of the length of the DCT4. + * @param[in] normalize normalizing factor. + * @return arm_status function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_ARGUMENT_ERROR if N is not a supported transform length. + */ + arm_status arm_dct4_init_q15( + arm_dct4_instance_q15 * S, + arm_rfft_instance_q15 * S_RFFT, + arm_cfft_radix4_instance_q15 * S_CFFT, + uint16_t N, + uint16_t Nby2, + q15_t normalize); + + + /** + * @brief Processing function for the Q15 DCT4/IDCT4. + * @param[in] S points to an instance of the Q15 DCT4 structure. + * @param[in] pState points to state buffer. + * @param[in,out] pInlineBuffer points to the in-place input and output buffer. + */ + void arm_dct4_q15( + const arm_dct4_instance_q15 * S, + q15_t * pState, + q15_t * pInlineBuffer); + + + /** + * @brief Floating-point vector addition. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_add_f32( + const float32_t * pSrcA, + const float32_t * pSrcB, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q7 vector addition. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_add_q7( + const q7_t * pSrcA, + const q7_t * pSrcB, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q15 vector addition. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_add_q15( + const q15_t * pSrcA, + const q15_t * pSrcB, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q31 vector addition. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_add_q31( + const q31_t * pSrcA, + const q31_t * pSrcB, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Floating-point vector subtraction. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_sub_f32( + const float32_t * pSrcA, + const float32_t * pSrcB, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q7 vector subtraction. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_sub_q7( + const q7_t * pSrcA, + const q7_t * pSrcB, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q15 vector subtraction. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_sub_q15( + const q15_t * pSrcA, + const q15_t * pSrcB, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q31 vector subtraction. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in each vector + */ + void arm_sub_q31( + const q31_t * pSrcA, + const q31_t * pSrcB, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Multiplies a floating-point vector by a scalar. + * @param[in] pSrc points to the input vector + * @param[in] scale scale factor to be applied + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_scale_f32( + const float32_t * pSrc, + float32_t scale, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Multiplies a Q7 vector by a scalar. + * @param[in] pSrc points to the input vector + * @param[in] scaleFract fractional portion of the scale value + * @param[in] shift number of bits to shift the result by + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_scale_q7( + const q7_t * pSrc, + q7_t scaleFract, + int8_t shift, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Multiplies a Q15 vector by a scalar. + * @param[in] pSrc points to the input vector + * @param[in] scaleFract fractional portion of the scale value + * @param[in] shift number of bits to shift the result by + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_scale_q15( + const q15_t * pSrc, + q15_t scaleFract, + int8_t shift, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Multiplies a Q31 vector by a scalar. + * @param[in] pSrc points to the input vector + * @param[in] scaleFract fractional portion of the scale value + * @param[in] shift number of bits to shift the result by + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_scale_q31( + const q31_t * pSrc, + q31_t scaleFract, + int8_t shift, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q7 vector absolute value. + * @param[in] pSrc points to the input buffer + * @param[out] pDst points to the output buffer + * @param[in] blockSize number of samples in each vector + */ + void arm_abs_q7( + const q7_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Floating-point vector absolute value. + * @param[in] pSrc points to the input buffer + * @param[out] pDst points to the output buffer + * @param[in] blockSize number of samples in each vector + */ + void arm_abs_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q15 vector absolute value. + * @param[in] pSrc points to the input buffer + * @param[out] pDst points to the output buffer + * @param[in] blockSize number of samples in each vector + */ + void arm_abs_q15( + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Q31 vector absolute value. + * @param[in] pSrc points to the input buffer + * @param[out] pDst points to the output buffer + * @param[in] blockSize number of samples in each vector + */ + void arm_abs_q31( + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Dot product of floating-point vectors. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] blockSize number of samples in each vector + * @param[out] result output result returned here + */ + void arm_dot_prod_f32( + const float32_t * pSrcA, + const float32_t * pSrcB, + uint32_t blockSize, + float32_t * result); + + + /** + * @brief Dot product of Q7 vectors. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] blockSize number of samples in each vector + * @param[out] result output result returned here + */ + void arm_dot_prod_q7( + const q7_t * pSrcA, + const q7_t * pSrcB, + uint32_t blockSize, + q31_t * result); + + + /** + * @brief Dot product of Q15 vectors. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] blockSize number of samples in each vector + * @param[out] result output result returned here + */ + void arm_dot_prod_q15( + const q15_t * pSrcA, + const q15_t * pSrcB, + uint32_t blockSize, + q63_t * result); + + + /** + * @brief Dot product of Q31 vectors. + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] blockSize number of samples in each vector + * @param[out] result output result returned here + */ + void arm_dot_prod_q31( + const q31_t * pSrcA, + const q31_t * pSrcB, + uint32_t blockSize, + q63_t * result); + + + /** + * @brief Shifts the elements of a Q7 vector a specified number of bits. + * @param[in] pSrc points to the input vector + * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_shift_q7( + const q7_t * pSrc, + int8_t shiftBits, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Shifts the elements of a Q15 vector a specified number of bits. + * @param[in] pSrc points to the input vector + * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_shift_q15( + const q15_t * pSrc, + int8_t shiftBits, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Shifts the elements of a Q31 vector a specified number of bits. + * @param[in] pSrc points to the input vector + * @param[in] shiftBits number of bits to shift. A positive value shifts left; a negative value shifts right. + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_shift_q31( + const q31_t * pSrc, + int8_t shiftBits, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Adds a constant offset to a floating-point vector. + * @param[in] pSrc points to the input vector + * @param[in] offset is the offset to be added + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_offset_f32( + const float32_t * pSrc, + float32_t offset, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Adds a constant offset to a Q7 vector. + * @param[in] pSrc points to the input vector + * @param[in] offset is the offset to be added + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_offset_q7( + const q7_t * pSrc, + q7_t offset, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Adds a constant offset to a Q15 vector. + * @param[in] pSrc points to the input vector + * @param[in] offset is the offset to be added + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_offset_q15( + const q15_t * pSrc, + q15_t offset, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Adds a constant offset to a Q31 vector. + * @param[in] pSrc points to the input vector + * @param[in] offset is the offset to be added + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_offset_q31( + const q31_t * pSrc, + q31_t offset, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Negates the elements of a floating-point vector. + * @param[in] pSrc points to the input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_negate_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Negates the elements of a Q7 vector. + * @param[in] pSrc points to the input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_negate_q7( + const q7_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Negates the elements of a Q15 vector. + * @param[in] pSrc points to the input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_negate_q15( + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Negates the elements of a Q31 vector. + * @param[in] pSrc points to the input vector + * @param[out] pDst points to the output vector + * @param[in] blockSize number of samples in the vector + */ + void arm_negate_q31( + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Copies the elements of a floating-point vector. + * @param[in] pSrc input pointer + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_copy_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Copies the elements of a Q7 vector. + * @param[in] pSrc input pointer + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_copy_q7( + const q7_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Copies the elements of a Q15 vector. + * @param[in] pSrc input pointer + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_copy_q15( + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Copies the elements of a Q31 vector. + * @param[in] pSrc input pointer + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_copy_q31( + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Fills a constant value into a floating-point vector. + * @param[in] value input value to be filled + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_fill_f32( + float32_t value, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Fills a constant value into a Q7 vector. + * @param[in] value input value to be filled + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_fill_q7( + q7_t value, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Fills a constant value into a Q15 vector. + * @param[in] value input value to be filled + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_fill_q15( + q15_t value, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Fills a constant value into a Q31 vector. + * @param[in] value input value to be filled + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_fill_q31( + q31_t value, + q31_t * pDst, + uint32_t blockSize); + + +/** + * @brief Convolution of floating-point sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. + */ + void arm_conv_f32( + const float32_t * pSrcA, + uint32_t srcALen, + const float32_t * pSrcB, + uint32_t srcBLen, + float32_t * pDst); + + + /** + * @brief Convolution of Q15 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. + * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). + */ + void arm_conv_opt_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + q15_t * pScratch1, + q15_t * pScratch2); + + +/** + * @brief Convolution of Q15 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the location where the output result is written. Length srcALen+srcBLen-1. + */ + void arm_conv_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst); + + + /** + * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. + */ + void arm_conv_fast_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst); + + + /** + * @brief Convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. + * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). + */ + void arm_conv_fast_opt_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + q15_t * pScratch1, + q15_t * pScratch2); + + + /** + * @brief Convolution of Q31 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. + */ + void arm_conv_q31( + const q31_t * pSrcA, + uint32_t srcALen, + const q31_t * pSrcB, + uint32_t srcBLen, + q31_t * pDst); + + + /** + * @brief Convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. + */ + void arm_conv_fast_q31( + const q31_t * pSrcA, + uint32_t srcALen, + const q31_t * pSrcB, + uint32_t srcBLen, + q31_t * pDst); + + + /** + * @brief Convolution of Q7 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. + * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). + */ + void arm_conv_opt_q7( + const q7_t * pSrcA, + uint32_t srcALen, + const q7_t * pSrcB, + uint32_t srcBLen, + q7_t * pDst, + q15_t * pScratch1, + q15_t * pScratch2); + + + /** + * @brief Convolution of Q7 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length srcALen+srcBLen-1. + */ + void arm_conv_q7( + const q7_t * pSrcA, + uint32_t srcALen, + const q7_t * pSrcB, + uint32_t srcBLen, + q7_t * pDst); + + + /** + * @brief Partial convolution of floating-point sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_f32( + const float32_t * pSrcA, + uint32_t srcALen, + const float32_t * pSrcB, + uint32_t srcBLen, + float32_t * pDst, + uint32_t firstIndex, + uint32_t numPoints); + + + /** + * @brief Partial convolution of Q15 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_opt_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + uint32_t firstIndex, + uint32_t numPoints, + q15_t * pScratch1, + q15_t * pScratch2); + + + /** + * @brief Partial convolution of Q15 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + uint32_t firstIndex, + uint32_t numPoints); + + + /** + * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_fast_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + uint32_t firstIndex, + uint32_t numPoints); + + + /** + * @brief Partial convolution of Q15 sequences (fast version) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @param[in] pScratch1 points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + * @param[in] pScratch2 points to scratch buffer of size min(srcALen, srcBLen). + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_fast_opt_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + uint32_t firstIndex, + uint32_t numPoints, + q15_t * pScratch1, + q15_t * pScratch2); + + + /** + * @brief Partial convolution of Q31 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_q31( + const q31_t * pSrcA, + uint32_t srcALen, + const q31_t * pSrcB, + uint32_t srcBLen, + q31_t * pDst, + uint32_t firstIndex, + uint32_t numPoints); + + + /** + * @brief Partial convolution of Q31 sequences (fast version) for Cortex-M3 and Cortex-M4 + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_fast_q31( + const q31_t * pSrcA, + uint32_t srcALen, + const q31_t * pSrcB, + uint32_t srcBLen, + q31_t * pDst, + uint32_t firstIndex, + uint32_t numPoints); + + + /** + * @brief Partial convolution of Q7 sequences + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_opt_q7( + const q7_t * pSrcA, + uint32_t srcALen, + const q7_t * pSrcB, + uint32_t srcBLen, + q7_t * pDst, + uint32_t firstIndex, + uint32_t numPoints, + q15_t * pScratch1, + q15_t * pScratch2); + + +/** + * @brief Partial convolution of Q7 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data + * @param[in] firstIndex is the first output sample to start with. + * @param[in] numPoints is the number of output points to be computed. + * @return Returns either ARM_MATH_SUCCESS if the function completed correctly or ARM_MATH_ARGUMENT_ERROR if the requested subset is not in the range [0 srcALen+srcBLen-2]. + */ + arm_status arm_conv_partial_q7( + const q7_t * pSrcA, + uint32_t srcALen, + const q7_t * pSrcB, + uint32_t srcBLen, + q7_t * pDst, + uint32_t firstIndex, + uint32_t numPoints); + + + /** + * @brief Instance structure for the Q15 FIR decimator. + */ + typedef struct + { + uint8_t M; /**< decimation factor. */ + uint16_t numTaps; /**< number of coefficients in the filter. */ + const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + } arm_fir_decimate_instance_q15; + + /** + * @brief Instance structure for the Q31 FIR decimator. + */ + typedef struct + { + uint8_t M; /**< decimation factor. */ + uint16_t numTaps; /**< number of coefficients in the filter. */ + const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + } arm_fir_decimate_instance_q31; + +/** + @brief Instance structure for floating-point FIR decimator. + */ +typedef struct + { + uint8_t M; /**< decimation factor. */ + uint16_t numTaps; /**< number of coefficients in the filter. */ + const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + } arm_fir_decimate_instance_f32; + + +/** + @brief Processing function for floating-point FIR decimator. + @param[in] S points to an instance of the floating-point FIR decimator structure + @param[in] pSrc points to the block of input data + @param[out] pDst points to the block of output data + @param[in] blockSize number of samples to process + */ +void arm_fir_decimate_f32( + const arm_fir_decimate_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + +/** + @brief Initialization function for the floating-point FIR decimator. + @param[in,out] S points to an instance of the floating-point FIR decimator structure + @param[in] numTaps number of coefficients in the filter + @param[in] M decimation factor + @param[in] pCoeffs points to the filter coefficients + @param[in] pState points to the state buffer + @param[in] blockSize number of input samples to process per call + @return execution status + - \ref ARM_MATH_SUCCESS : Operation successful + - \ref ARM_MATH_LENGTH_ERROR : blockSize is not a multiple of M + */ +arm_status arm_fir_decimate_init_f32( + arm_fir_decimate_instance_f32 * S, + uint16_t numTaps, + uint8_t M, + const float32_t * pCoeffs, + float32_t * pState, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q15 FIR decimator. + * @param[in] S points to an instance of the Q15 FIR decimator structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_decimate_q15( + const arm_fir_decimate_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q15 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. + * @param[in] S points to an instance of the Q15 FIR decimator structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_decimate_fast_q15( + const arm_fir_decimate_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q15 FIR decimator. + * @param[in,out] S points to an instance of the Q15 FIR decimator structure. + * @param[in] numTaps number of coefficients in the filter. + * @param[in] M decimation factor. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of input samples to process per call. + * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if + * blockSize is not a multiple of M. + */ + arm_status arm_fir_decimate_init_q15( + arm_fir_decimate_instance_q15 * S, + uint16_t numTaps, + uint8_t M, + const q15_t * pCoeffs, + q15_t * pState, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q31 FIR decimator. + * @param[in] S points to an instance of the Q31 FIR decimator structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_decimate_q31( + const arm_fir_decimate_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + /** + * @brief Processing function for the Q31 FIR decimator (fast variant) for Cortex-M3 and Cortex-M4. + * @param[in] S points to an instance of the Q31 FIR decimator structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_decimate_fast_q31( + const arm_fir_decimate_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q31 FIR decimator. + * @param[in,out] S points to an instance of the Q31 FIR decimator structure. + * @param[in] numTaps number of coefficients in the filter. + * @param[in] M decimation factor. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of input samples to process per call. + * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if + * blockSize is not a multiple of M. + */ + arm_status arm_fir_decimate_init_q31( + arm_fir_decimate_instance_q31 * S, + uint16_t numTaps, + uint8_t M, + const q31_t * pCoeffs, + q31_t * pState, + uint32_t blockSize); + + + /** + * @brief Instance structure for the Q15 FIR interpolator. + */ + typedef struct + { + uint8_t L; /**< upsample factor. */ + uint16_t phaseLength; /**< length of each polyphase filter component. */ + const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ + q15_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ + } arm_fir_interpolate_instance_q15; + + /** + * @brief Instance structure for the Q31 FIR interpolator. + */ + typedef struct + { + uint8_t L; /**< upsample factor. */ + uint16_t phaseLength; /**< length of each polyphase filter component. */ + const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ + q31_t *pState; /**< points to the state variable array. The array is of length blockSize+phaseLength-1. */ + } arm_fir_interpolate_instance_q31; + + /** + * @brief Instance structure for the floating-point FIR interpolator. + */ + typedef struct + { + uint8_t L; /**< upsample factor. */ + uint16_t phaseLength; /**< length of each polyphase filter component. */ + const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length L*phaseLength. */ + float32_t *pState; /**< points to the state variable array. The array is of length phaseLength+numTaps-1. */ + } arm_fir_interpolate_instance_f32; + + + /** + * @brief Processing function for the Q15 FIR interpolator. + * @param[in] S points to an instance of the Q15 FIR interpolator structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_interpolate_q15( + const arm_fir_interpolate_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q15 FIR interpolator. + * @param[in,out] S points to an instance of the Q15 FIR interpolator structure. + * @param[in] L upsample factor. + * @param[in] numTaps number of filter coefficients in the filter. + * @param[in] pCoeffs points to the filter coefficient buffer. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of input samples to process per call. + * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if + * the filter length numTaps is not a multiple of the interpolation factor L. + */ + arm_status arm_fir_interpolate_init_q15( + arm_fir_interpolate_instance_q15 * S, + uint8_t L, + uint16_t numTaps, + const q15_t * pCoeffs, + q15_t * pState, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q31 FIR interpolator. + * @param[in] S points to an instance of the Q15 FIR interpolator structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_interpolate_q31( + const arm_fir_interpolate_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q31 FIR interpolator. + * @param[in,out] S points to an instance of the Q31 FIR interpolator structure. + * @param[in] L upsample factor. + * @param[in] numTaps number of filter coefficients in the filter. + * @param[in] pCoeffs points to the filter coefficient buffer. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of input samples to process per call. + * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if + * the filter length numTaps is not a multiple of the interpolation factor L. + */ + arm_status arm_fir_interpolate_init_q31( + arm_fir_interpolate_instance_q31 * S, + uint8_t L, + uint16_t numTaps, + const q31_t * pCoeffs, + q31_t * pState, + uint32_t blockSize); + + + /** + * @brief Processing function for the floating-point FIR interpolator. + * @param[in] S points to an instance of the floating-point FIR interpolator structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_interpolate_f32( + const arm_fir_interpolate_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the floating-point FIR interpolator. + * @param[in,out] S points to an instance of the floating-point FIR interpolator structure. + * @param[in] L upsample factor. + * @param[in] numTaps number of filter coefficients in the filter. + * @param[in] pCoeffs points to the filter coefficient buffer. + * @param[in] pState points to the state buffer. + * @param[in] blockSize number of input samples to process per call. + * @return The function returns ARM_MATH_SUCCESS if initialization is successful or ARM_MATH_LENGTH_ERROR if + * the filter length numTaps is not a multiple of the interpolation factor L. + */ + arm_status arm_fir_interpolate_init_f32( + arm_fir_interpolate_instance_f32 * S, + uint8_t L, + uint16_t numTaps, + const float32_t * pCoeffs, + float32_t * pState, + uint32_t blockSize); + + + /** + * @brief Instance structure for the high precision Q31 Biquad cascade filter. + */ + typedef struct + { + uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ + q63_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ + const q31_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ + uint8_t postShift; /**< additional shift, in bits, applied to each output sample. */ + } arm_biquad_cas_df1_32x64_ins_q31; + + + /** + * @param[in] S points to an instance of the high precision Q31 Biquad cascade filter structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cas_df1_32x64_q31( + const arm_biquad_cas_df1_32x64_ins_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @param[in,out] S points to an instance of the high precision Q31 Biquad cascade filter structure. + * @param[in] numStages number of 2nd order stages in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] postShift shift to be applied to the output. Varies according to the coefficients format + */ + void arm_biquad_cas_df1_32x64_init_q31( + arm_biquad_cas_df1_32x64_ins_q31 * S, + uint8_t numStages, + const q31_t * pCoeffs, + q63_t * pState, + uint8_t postShift); + + + /** + * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. + */ + typedef struct + { + uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ + float32_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ + const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ + } arm_biquad_cascade_df2T_instance_f32; + + /** + * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. + */ + typedef struct + { + uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ + float32_t *pState; /**< points to the array of state coefficients. The array is of length 4*numStages. */ + const float32_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ + } arm_biquad_cascade_stereo_df2T_instance_f32; + + /** + * @brief Instance structure for the floating-point transposed direct form II Biquad cascade filter. + */ + typedef struct + { + uint8_t numStages; /**< number of 2nd order stages in the filter. Overall order is 2*numStages. */ + float64_t *pState; /**< points to the array of state coefficients. The array is of length 2*numStages. */ + const float64_t *pCoeffs; /**< points to the array of coefficients. The array is of length 5*numStages. */ + } arm_biquad_cascade_df2T_instance_f64; + + + /** + * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. + * @param[in] S points to an instance of the filter data structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_df2T_f32( + const arm_biquad_cascade_df2T_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. 2 channels + * @param[in] S points to an instance of the filter data structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_stereo_df2T_f32( + const arm_biquad_cascade_stereo_df2T_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Processing function for the floating-point transposed direct form II Biquad cascade filter. + * @param[in] S points to an instance of the filter data structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ + void arm_biquad_cascade_df2T_f64( + const arm_biquad_cascade_df2T_instance_f64 * S, + const float64_t * pSrc, + float64_t * pDst, + uint32_t blockSize); + + +#if defined(ARM_MATH_NEON) +void arm_biquad_cascade_df2T_compute_coefs_f32( + arm_biquad_cascade_df2T_instance_f32 * S, + uint8_t numStages, + float32_t * pCoeffs); +#endif + /** + * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. + * @param[in,out] S points to an instance of the filter data structure. + * @param[in] numStages number of 2nd order stages in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + */ + void arm_biquad_cascade_df2T_init_f32( + arm_biquad_cascade_df2T_instance_f32 * S, + uint8_t numStages, + const float32_t * pCoeffs, + float32_t * pState); + + + /** + * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. + * @param[in,out] S points to an instance of the filter data structure. + * @param[in] numStages number of 2nd order stages in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + */ + void arm_biquad_cascade_stereo_df2T_init_f32( + arm_biquad_cascade_stereo_df2T_instance_f32 * S, + uint8_t numStages, + const float32_t * pCoeffs, + float32_t * pState); + + + /** + * @brief Initialization function for the floating-point transposed direct form II Biquad cascade filter. + * @param[in,out] S points to an instance of the filter data structure. + * @param[in] numStages number of 2nd order stages in the filter. + * @param[in] pCoeffs points to the filter coefficients. + * @param[in] pState points to the state buffer. + */ + void arm_biquad_cascade_df2T_init_f64( + arm_biquad_cascade_df2T_instance_f64 * S, + uint8_t numStages, + const float64_t * pCoeffs, + float64_t * pState); + + + /** + * @brief Instance structure for the Q15 FIR lattice filter. + */ + typedef struct + { + uint16_t numStages; /**< number of filter stages. */ + q15_t *pState; /**< points to the state variable array. The array is of length numStages. */ + const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ + } arm_fir_lattice_instance_q15; + + /** + * @brief Instance structure for the Q31 FIR lattice filter. + */ + typedef struct + { + uint16_t numStages; /**< number of filter stages. */ + q31_t *pState; /**< points to the state variable array. The array is of length numStages. */ + const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ + } arm_fir_lattice_instance_q31; + + /** + * @brief Instance structure for the floating-point FIR lattice filter. + */ + typedef struct + { + uint16_t numStages; /**< number of filter stages. */ + float32_t *pState; /**< points to the state variable array. The array is of length numStages. */ + const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numStages. */ + } arm_fir_lattice_instance_f32; + + + /** + * @brief Initialization function for the Q15 FIR lattice filter. + * @param[in] S points to an instance of the Q15 FIR lattice structure. + * @param[in] numStages number of filter stages. + * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. + * @param[in] pState points to the state buffer. The array is of length numStages. + */ + void arm_fir_lattice_init_q15( + arm_fir_lattice_instance_q15 * S, + uint16_t numStages, + const q15_t * pCoeffs, + q15_t * pState); + + + /** + * @brief Processing function for the Q15 FIR lattice filter. + * @param[in] S points to an instance of the Q15 FIR lattice structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_fir_lattice_q15( + const arm_fir_lattice_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q31 FIR lattice filter. + * @param[in] S points to an instance of the Q31 FIR lattice structure. + * @param[in] numStages number of filter stages. + * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. + * @param[in] pState points to the state buffer. The array is of length numStages. + */ + void arm_fir_lattice_init_q31( + arm_fir_lattice_instance_q31 * S, + uint16_t numStages, + const q31_t * pCoeffs, + q31_t * pState); + + + /** + * @brief Processing function for the Q31 FIR lattice filter. + * @param[in] S points to an instance of the Q31 FIR lattice structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ + void arm_fir_lattice_q31( + const arm_fir_lattice_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + +/** + * @brief Initialization function for the floating-point FIR lattice filter. + * @param[in] S points to an instance of the floating-point FIR lattice structure. + * @param[in] numStages number of filter stages. + * @param[in] pCoeffs points to the coefficient buffer. The array is of length numStages. + * @param[in] pState points to the state buffer. The array is of length numStages. + */ + void arm_fir_lattice_init_f32( + arm_fir_lattice_instance_f32 * S, + uint16_t numStages, + const float32_t * pCoeffs, + float32_t * pState); + + + /** + * @brief Processing function for the floating-point FIR lattice filter. + * @param[in] S points to an instance of the floating-point FIR lattice structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] blockSize number of samples to process. + */ + void arm_fir_lattice_f32( + const arm_fir_lattice_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Instance structure for the Q15 IIR lattice filter. + */ + typedef struct + { + uint16_t numStages; /**< number of stages in the filter. */ + q15_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ + q15_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ + q15_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ + } arm_iir_lattice_instance_q15; + + /** + * @brief Instance structure for the Q31 IIR lattice filter. + */ + typedef struct + { + uint16_t numStages; /**< number of stages in the filter. */ + q31_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ + q31_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ + q31_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ + } arm_iir_lattice_instance_q31; + + /** + * @brief Instance structure for the floating-point IIR lattice filter. + */ + typedef struct + { + uint16_t numStages; /**< number of stages in the filter. */ + float32_t *pState; /**< points to the state variable array. The array is of length numStages+blockSize. */ + float32_t *pkCoeffs; /**< points to the reflection coefficient array. The array is of length numStages. */ + float32_t *pvCoeffs; /**< points to the ladder coefficient array. The array is of length numStages+1. */ + } arm_iir_lattice_instance_f32; + + + /** + * @brief Processing function for the floating-point IIR lattice filter. + * @param[in] S points to an instance of the floating-point IIR lattice structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_iir_lattice_f32( + const arm_iir_lattice_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the floating-point IIR lattice filter. + * @param[in] S points to an instance of the floating-point IIR lattice structure. + * @param[in] numStages number of stages in the filter. + * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. + * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. + * @param[in] pState points to the state buffer. The array is of length numStages+blockSize-1. + * @param[in] blockSize number of samples to process. + */ + void arm_iir_lattice_init_f32( + arm_iir_lattice_instance_f32 * S, + uint16_t numStages, + float32_t * pkCoeffs, + float32_t * pvCoeffs, + float32_t * pState, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q31 IIR lattice filter. + * @param[in] S points to an instance of the Q31 IIR lattice structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_iir_lattice_q31( + const arm_iir_lattice_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q31 IIR lattice filter. + * @param[in] S points to an instance of the Q31 IIR lattice structure. + * @param[in] numStages number of stages in the filter. + * @param[in] pkCoeffs points to the reflection coefficient buffer. The array is of length numStages. + * @param[in] pvCoeffs points to the ladder coefficient buffer. The array is of length numStages+1. + * @param[in] pState points to the state buffer. The array is of length numStages+blockSize. + * @param[in] blockSize number of samples to process. + */ + void arm_iir_lattice_init_q31( + arm_iir_lattice_instance_q31 * S, + uint16_t numStages, + q31_t * pkCoeffs, + q31_t * pvCoeffs, + q31_t * pState, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q15 IIR lattice filter. + * @param[in] S points to an instance of the Q15 IIR lattice structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data. + * @param[in] blockSize number of samples to process. + */ + void arm_iir_lattice_q15( + const arm_iir_lattice_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + +/** + * @brief Initialization function for the Q15 IIR lattice filter. + * @param[in] S points to an instance of the fixed-point Q15 IIR lattice structure. + * @param[in] numStages number of stages in the filter. + * @param[in] pkCoeffs points to reflection coefficient buffer. The array is of length numStages. + * @param[in] pvCoeffs points to ladder coefficient buffer. The array is of length numStages+1. + * @param[in] pState points to state buffer. The array is of length numStages+blockSize. + * @param[in] blockSize number of samples to process per call. + */ + void arm_iir_lattice_init_q15( + arm_iir_lattice_instance_q15 * S, + uint16_t numStages, + q15_t * pkCoeffs, + q15_t * pvCoeffs, + q15_t * pState, + uint32_t blockSize); + + + /** + * @brief Instance structure for the floating-point LMS filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + float32_t mu; /**< step size that controls filter coefficient updates. */ + } arm_lms_instance_f32; + + + /** + * @brief Processing function for floating-point LMS filter. + * @param[in] S points to an instance of the floating-point LMS filter structure. + * @param[in] pSrc points to the block of input data. + * @param[in] pRef points to the block of reference data. + * @param[out] pOut points to the block of output data. + * @param[out] pErr points to the block of error data. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_f32( + const arm_lms_instance_f32 * S, + const float32_t * pSrc, + float32_t * pRef, + float32_t * pOut, + float32_t * pErr, + uint32_t blockSize); + + + /** + * @brief Initialization function for floating-point LMS filter. + * @param[in] S points to an instance of the floating-point LMS filter structure. + * @param[in] numTaps number of filter coefficients. + * @param[in] pCoeffs points to the coefficient buffer. + * @param[in] pState points to state buffer. + * @param[in] mu step size that controls filter coefficient updates. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_init_f32( + arm_lms_instance_f32 * S, + uint16_t numTaps, + float32_t * pCoeffs, + float32_t * pState, + float32_t mu, + uint32_t blockSize); + + + /** + * @brief Instance structure for the Q15 LMS filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + q15_t mu; /**< step size that controls filter coefficient updates. */ + uint32_t postShift; /**< bit shift applied to coefficients. */ + } arm_lms_instance_q15; + + + /** + * @brief Initialization function for the Q15 LMS filter. + * @param[in] S points to an instance of the Q15 LMS filter structure. + * @param[in] numTaps number of filter coefficients. + * @param[in] pCoeffs points to the coefficient buffer. + * @param[in] pState points to the state buffer. + * @param[in] mu step size that controls filter coefficient updates. + * @param[in] blockSize number of samples to process. + * @param[in] postShift bit shift applied to coefficients. + */ + void arm_lms_init_q15( + arm_lms_instance_q15 * S, + uint16_t numTaps, + q15_t * pCoeffs, + q15_t * pState, + q15_t mu, + uint32_t blockSize, + uint32_t postShift); + + + /** + * @brief Processing function for Q15 LMS filter. + * @param[in] S points to an instance of the Q15 LMS filter structure. + * @param[in] pSrc points to the block of input data. + * @param[in] pRef points to the block of reference data. + * @param[out] pOut points to the block of output data. + * @param[out] pErr points to the block of error data. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_q15( + const arm_lms_instance_q15 * S, + const q15_t * pSrc, + q15_t * pRef, + q15_t * pOut, + q15_t * pErr, + uint32_t blockSize); + + + /** + * @brief Instance structure for the Q31 LMS filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + q31_t mu; /**< step size that controls filter coefficient updates. */ + uint32_t postShift; /**< bit shift applied to coefficients. */ + } arm_lms_instance_q31; + + + /** + * @brief Processing function for Q31 LMS filter. + * @param[in] S points to an instance of the Q15 LMS filter structure. + * @param[in] pSrc points to the block of input data. + * @param[in] pRef points to the block of reference data. + * @param[out] pOut points to the block of output data. + * @param[out] pErr points to the block of error data. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_q31( + const arm_lms_instance_q31 * S, + const q31_t * pSrc, + q31_t * pRef, + q31_t * pOut, + q31_t * pErr, + uint32_t blockSize); + + + /** + * @brief Initialization function for Q31 LMS filter. + * @param[in] S points to an instance of the Q31 LMS filter structure. + * @param[in] numTaps number of filter coefficients. + * @param[in] pCoeffs points to coefficient buffer. + * @param[in] pState points to state buffer. + * @param[in] mu step size that controls filter coefficient updates. + * @param[in] blockSize number of samples to process. + * @param[in] postShift bit shift applied to coefficients. + */ + void arm_lms_init_q31( + arm_lms_instance_q31 * S, + uint16_t numTaps, + q31_t * pCoeffs, + q31_t * pState, + q31_t mu, + uint32_t blockSize, + uint32_t postShift); + + + /** + * @brief Instance structure for the floating-point normalized LMS filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + float32_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + float32_t mu; /**< step size that control filter coefficient updates. */ + float32_t energy; /**< saves previous frame energy. */ + float32_t x0; /**< saves previous input sample. */ + } arm_lms_norm_instance_f32; + + + /** + * @brief Processing function for floating-point normalized LMS filter. + * @param[in] S points to an instance of the floating-point normalized LMS filter structure. + * @param[in] pSrc points to the block of input data. + * @param[in] pRef points to the block of reference data. + * @param[out] pOut points to the block of output data. + * @param[out] pErr points to the block of error data. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_norm_f32( + arm_lms_norm_instance_f32 * S, + const float32_t * pSrc, + float32_t * pRef, + float32_t * pOut, + float32_t * pErr, + uint32_t blockSize); + + + /** + * @brief Initialization function for floating-point normalized LMS filter. + * @param[in] S points to an instance of the floating-point LMS filter structure. + * @param[in] numTaps number of filter coefficients. + * @param[in] pCoeffs points to coefficient buffer. + * @param[in] pState points to state buffer. + * @param[in] mu step size that controls filter coefficient updates. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_norm_init_f32( + arm_lms_norm_instance_f32 * S, + uint16_t numTaps, + float32_t * pCoeffs, + float32_t * pState, + float32_t mu, + uint32_t blockSize); + + + /** + * @brief Instance structure for the Q31 normalized LMS filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + q31_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + q31_t mu; /**< step size that controls filter coefficient updates. */ + uint8_t postShift; /**< bit shift applied to coefficients. */ + const q31_t *recipTable; /**< points to the reciprocal initial value table. */ + q31_t energy; /**< saves previous frame energy. */ + q31_t x0; /**< saves previous input sample. */ + } arm_lms_norm_instance_q31; + + + /** + * @brief Processing function for Q31 normalized LMS filter. + * @param[in] S points to an instance of the Q31 normalized LMS filter structure. + * @param[in] pSrc points to the block of input data. + * @param[in] pRef points to the block of reference data. + * @param[out] pOut points to the block of output data. + * @param[out] pErr points to the block of error data. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_norm_q31( + arm_lms_norm_instance_q31 * S, + const q31_t * pSrc, + q31_t * pRef, + q31_t * pOut, + q31_t * pErr, + uint32_t blockSize); + + + /** + * @brief Initialization function for Q31 normalized LMS filter. + * @param[in] S points to an instance of the Q31 normalized LMS filter structure. + * @param[in] numTaps number of filter coefficients. + * @param[in] pCoeffs points to coefficient buffer. + * @param[in] pState points to state buffer. + * @param[in] mu step size that controls filter coefficient updates. + * @param[in] blockSize number of samples to process. + * @param[in] postShift bit shift applied to coefficients. + */ + void arm_lms_norm_init_q31( + arm_lms_norm_instance_q31 * S, + uint16_t numTaps, + q31_t * pCoeffs, + q31_t * pState, + q31_t mu, + uint32_t blockSize, + uint8_t postShift); + + + /** + * @brief Instance structure for the Q15 normalized LMS filter. + */ + typedef struct + { + uint16_t numTaps; /**< Number of coefficients in the filter. */ + q15_t *pState; /**< points to the state variable array. The array is of length numTaps+blockSize-1. */ + q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps. */ + q15_t mu; /**< step size that controls filter coefficient updates. */ + uint8_t postShift; /**< bit shift applied to coefficients. */ + const q15_t *recipTable; /**< Points to the reciprocal initial value table. */ + q15_t energy; /**< saves previous frame energy. */ + q15_t x0; /**< saves previous input sample. */ + } arm_lms_norm_instance_q15; + + + /** + * @brief Processing function for Q15 normalized LMS filter. + * @param[in] S points to an instance of the Q15 normalized LMS filter structure. + * @param[in] pSrc points to the block of input data. + * @param[in] pRef points to the block of reference data. + * @param[out] pOut points to the block of output data. + * @param[out] pErr points to the block of error data. + * @param[in] blockSize number of samples to process. + */ + void arm_lms_norm_q15( + arm_lms_norm_instance_q15 * S, + const q15_t * pSrc, + q15_t * pRef, + q15_t * pOut, + q15_t * pErr, + uint32_t blockSize); + + + /** + * @brief Initialization function for Q15 normalized LMS filter. + * @param[in] S points to an instance of the Q15 normalized LMS filter structure. + * @param[in] numTaps number of filter coefficients. + * @param[in] pCoeffs points to coefficient buffer. + * @param[in] pState points to state buffer. + * @param[in] mu step size that controls filter coefficient updates. + * @param[in] blockSize number of samples to process. + * @param[in] postShift bit shift applied to coefficients. + */ + void arm_lms_norm_init_q15( + arm_lms_norm_instance_q15 * S, + uint16_t numTaps, + q15_t * pCoeffs, + q15_t * pState, + q15_t mu, + uint32_t blockSize, + uint8_t postShift); + + + /** + * @brief Correlation of floating-point sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + */ + void arm_correlate_f32( + const float32_t * pSrcA, + uint32_t srcALen, + const float32_t * pSrcB, + uint32_t srcBLen, + float32_t * pDst); + + +/** + @brief Correlation of Q15 sequences + @param[in] pSrcA points to the first input sequence + @param[in] srcALen length of the first input sequence + @param[in] pSrcB points to the second input sequence + @param[in] srcBLen length of the second input sequence + @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. +*/ +void arm_correlate_opt_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + q15_t * pScratch); + + +/** + @brief Correlation of Q15 sequences. + @param[in] pSrcA points to the first input sequence + @param[in] srcALen length of the first input sequence + @param[in] pSrcB points to the second input sequence + @param[in] srcBLen length of the second input sequence + @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + */ + void arm_correlate_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst); + + +/** + @brief Correlation of Q15 sequences (fast version). + @param[in] pSrcA points to the first input sequence + @param[in] srcALen length of the first input sequence + @param[in] pSrcB points to the second input sequence + @param[in] srcBLen length of the second input sequence + @param[out] pDst points to the location where the output result is written. Length 2 * max(srcALen, srcBLen) - 1. + @return none + */ +void arm_correlate_fast_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst); + + +/** + @brief Correlation of Q15 sequences (fast version). + @param[in] pSrcA points to the first input sequence. + @param[in] srcALen length of the first input sequence. + @param[in] pSrcB points to the second input sequence. + @param[in] srcBLen length of the second input sequence. + @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + @param[in] pScratch points to scratch buffer of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + */ +void arm_correlate_fast_opt_q15( + const q15_t * pSrcA, + uint32_t srcALen, + const q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst, + q15_t * pScratch); + + + /** + * @brief Correlation of Q31 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + */ + void arm_correlate_q31( + const q31_t * pSrcA, + uint32_t srcALen, + const q31_t * pSrcB, + uint32_t srcBLen, + q31_t * pDst); + + +/** + @brief Correlation of Q31 sequences (fast version). + @param[in] pSrcA points to the first input sequence + @param[in] srcALen length of the first input sequence + @param[in] pSrcB points to the second input sequence + @param[in] srcBLen length of the second input sequence + @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + */ +void arm_correlate_fast_q31( + const q31_t * pSrcA, + uint32_t srcALen, + const q31_t * pSrcB, + uint32_t srcBLen, + q31_t * pDst); + + + /** + * @brief Correlation of Q7 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + * @param[in] pScratch1 points to scratch buffer(of type q15_t) of size max(srcALen, srcBLen) + 2*min(srcALen, srcBLen) - 2. + * @param[in] pScratch2 points to scratch buffer (of type q15_t) of size min(srcALen, srcBLen). + */ + void arm_correlate_opt_q7( + const q7_t * pSrcA, + uint32_t srcALen, + const q7_t * pSrcB, + uint32_t srcBLen, + q7_t * pDst, + q15_t * pScratch1, + q15_t * pScratch2); + + + /** + * @brief Correlation of Q7 sequences. + * @param[in] pSrcA points to the first input sequence. + * @param[in] srcALen length of the first input sequence. + * @param[in] pSrcB points to the second input sequence. + * @param[in] srcBLen length of the second input sequence. + * @param[out] pDst points to the block of output data Length 2 * max(srcALen, srcBLen) - 1. + */ + void arm_correlate_q7( + const q7_t * pSrcA, + uint32_t srcALen, + const q7_t * pSrcB, + uint32_t srcBLen, + q7_t * pDst); + + + /** + * @brief Instance structure for the floating-point sparse FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ + float32_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ + const float32_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ + int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ + } arm_fir_sparse_instance_f32; + + /** + * @brief Instance structure for the Q31 sparse FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ + q31_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ + const q31_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ + int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ + } arm_fir_sparse_instance_q31; + + /** + * @brief Instance structure for the Q15 sparse FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ + q15_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ + const q15_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ + int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ + } arm_fir_sparse_instance_q15; + + /** + * @brief Instance structure for the Q7 sparse FIR filter. + */ + typedef struct + { + uint16_t numTaps; /**< number of coefficients in the filter. */ + uint16_t stateIndex; /**< state buffer index. Points to the oldest sample in the state buffer. */ + q7_t *pState; /**< points to the state buffer array. The array is of length maxDelay+blockSize-1. */ + const q7_t *pCoeffs; /**< points to the coefficient array. The array is of length numTaps.*/ + uint16_t maxDelay; /**< maximum offset specified by the pTapDelay array. */ + int32_t *pTapDelay; /**< points to the array of delay values. The array is of length numTaps. */ + } arm_fir_sparse_instance_q7; + + + /** + * @brief Processing function for the floating-point sparse FIR filter. + * @param[in] S points to an instance of the floating-point sparse FIR structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] pScratchIn points to a temporary buffer of size blockSize. + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_sparse_f32( + arm_fir_sparse_instance_f32 * S, + const float32_t * pSrc, + float32_t * pDst, + float32_t * pScratchIn, + uint32_t blockSize); + + + /** + * @brief Initialization function for the floating-point sparse FIR filter. + * @param[in,out] S points to an instance of the floating-point sparse FIR structure. + * @param[in] numTaps number of nonzero coefficients in the filter. + * @param[in] pCoeffs points to the array of filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] pTapDelay points to the array of offset times. + * @param[in] maxDelay maximum offset time supported. + * @param[in] blockSize number of samples that will be processed per block. + */ + void arm_fir_sparse_init_f32( + arm_fir_sparse_instance_f32 * S, + uint16_t numTaps, + const float32_t * pCoeffs, + float32_t * pState, + int32_t * pTapDelay, + uint16_t maxDelay, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q31 sparse FIR filter. + * @param[in] S points to an instance of the Q31 sparse FIR structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] pScratchIn points to a temporary buffer of size blockSize. + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_sparse_q31( + arm_fir_sparse_instance_q31 * S, + const q31_t * pSrc, + q31_t * pDst, + q31_t * pScratchIn, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q31 sparse FIR filter. + * @param[in,out] S points to an instance of the Q31 sparse FIR structure. + * @param[in] numTaps number of nonzero coefficients in the filter. + * @param[in] pCoeffs points to the array of filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] pTapDelay points to the array of offset times. + * @param[in] maxDelay maximum offset time supported. + * @param[in] blockSize number of samples that will be processed per block. + */ + void arm_fir_sparse_init_q31( + arm_fir_sparse_instance_q31 * S, + uint16_t numTaps, + const q31_t * pCoeffs, + q31_t * pState, + int32_t * pTapDelay, + uint16_t maxDelay, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q15 sparse FIR filter. + * @param[in] S points to an instance of the Q15 sparse FIR structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] pScratchIn points to a temporary buffer of size blockSize. + * @param[in] pScratchOut points to a temporary buffer of size blockSize. + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_sparse_q15( + arm_fir_sparse_instance_q15 * S, + const q15_t * pSrc, + q15_t * pDst, + q15_t * pScratchIn, + q31_t * pScratchOut, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q15 sparse FIR filter. + * @param[in,out] S points to an instance of the Q15 sparse FIR structure. + * @param[in] numTaps number of nonzero coefficients in the filter. + * @param[in] pCoeffs points to the array of filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] pTapDelay points to the array of offset times. + * @param[in] maxDelay maximum offset time supported. + * @param[in] blockSize number of samples that will be processed per block. + */ + void arm_fir_sparse_init_q15( + arm_fir_sparse_instance_q15 * S, + uint16_t numTaps, + const q15_t * pCoeffs, + q15_t * pState, + int32_t * pTapDelay, + uint16_t maxDelay, + uint32_t blockSize); + + + /** + * @brief Processing function for the Q7 sparse FIR filter. + * @param[in] S points to an instance of the Q7 sparse FIR structure. + * @param[in] pSrc points to the block of input data. + * @param[out] pDst points to the block of output data + * @param[in] pScratchIn points to a temporary buffer of size blockSize. + * @param[in] pScratchOut points to a temporary buffer of size blockSize. + * @param[in] blockSize number of input samples to process per call. + */ + void arm_fir_sparse_q7( + arm_fir_sparse_instance_q7 * S, + const q7_t * pSrc, + q7_t * pDst, + q7_t * pScratchIn, + q31_t * pScratchOut, + uint32_t blockSize); + + + /** + * @brief Initialization function for the Q7 sparse FIR filter. + * @param[in,out] S points to an instance of the Q7 sparse FIR structure. + * @param[in] numTaps number of nonzero coefficients in the filter. + * @param[in] pCoeffs points to the array of filter coefficients. + * @param[in] pState points to the state buffer. + * @param[in] pTapDelay points to the array of offset times. + * @param[in] maxDelay maximum offset time supported. + * @param[in] blockSize number of samples that will be processed per block. + */ + void arm_fir_sparse_init_q7( + arm_fir_sparse_instance_q7 * S, + uint16_t numTaps, + const q7_t * pCoeffs, + q7_t * pState, + int32_t * pTapDelay, + uint16_t maxDelay, + uint32_t blockSize); + + + /** + * @brief Floating-point sin_cos function. + * @param[in] theta input value in degrees + * @param[out] pSinVal points to the processed sine output. + * @param[out] pCosVal points to the processed cos output. + */ + void arm_sin_cos_f32( + float32_t theta, + float32_t * pSinVal, + float32_t * pCosVal); + + + /** + * @brief Q31 sin_cos function. + * @param[in] theta scaled input value in degrees + * @param[out] pSinVal points to the processed sine output. + * @param[out] pCosVal points to the processed cosine output. + */ + void arm_sin_cos_q31( + q31_t theta, + q31_t * pSinVal, + q31_t * pCosVal); + + + /** + * @brief Floating-point complex conjugate. + * @param[in] pSrc points to the input vector + * @param[out] pDst points to the output vector + * @param[in] numSamples number of complex samples in each vector + */ + void arm_cmplx_conj_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t numSamples); + + /** + * @brief Q31 complex conjugate. + * @param[in] pSrc points to the input vector + * @param[out] pDst points to the output vector + * @param[in] numSamples number of complex samples in each vector + */ + void arm_cmplx_conj_q31( + const q31_t * pSrc, + q31_t * pDst, + uint32_t numSamples); + + + /** + * @brief Q15 complex conjugate. + * @param[in] pSrc points to the input vector + * @param[out] pDst points to the output vector + * @param[in] numSamples number of complex samples in each vector + */ + void arm_cmplx_conj_q15( + const q15_t * pSrc, + q15_t * pDst, + uint32_t numSamples); + + + /** + * @brief Floating-point complex magnitude squared + * @param[in] pSrc points to the complex input vector + * @param[out] pDst points to the real output vector + * @param[in] numSamples number of complex samples in the input vector + */ + void arm_cmplx_mag_squared_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t numSamples); + + + /** + * @brief Q31 complex magnitude squared + * @param[in] pSrc points to the complex input vector + * @param[out] pDst points to the real output vector + * @param[in] numSamples number of complex samples in the input vector + */ + void arm_cmplx_mag_squared_q31( + const q31_t * pSrc, + q31_t * pDst, + uint32_t numSamples); + + + /** + * @brief Q15 complex magnitude squared + * @param[in] pSrc points to the complex input vector + * @param[out] pDst points to the real output vector + * @param[in] numSamples number of complex samples in the input vector + */ + void arm_cmplx_mag_squared_q15( + const q15_t * pSrc, + q15_t * pDst, + uint32_t numSamples); + + + /** + * @ingroup groupController + */ + + /** + * @defgroup PID PID Motor Control + * + * A Proportional Integral Derivative (PID) controller is a generic feedback control + * loop mechanism widely used in industrial control systems. + * A PID controller is the most commonly used type of feedback controller. + * + * This set of functions implements (PID) controllers + * for Q15, Q31, and floating-point data types. The functions operate on a single sample + * of data and each call to the function returns a single processed value. + * S points to an instance of the PID control data structure. in + * is the input sample value. The functions return the output value. + * + * \par Algorithm: + *
+   *    y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2]
+   *    A0 = Kp + Ki + Kd
+   *    A1 = (-Kp ) - (2 * Kd )
+   *    A2 = Kd
+   * 
+ * + * \par + * where \c Kp is proportional constant, \c Ki is Integral constant and \c Kd is Derivative constant + * + * \par + * \image html PID.gif "Proportional Integral Derivative Controller" + * + * \par + * The PID controller calculates an "error" value as the difference between + * the measured output and the reference input. + * The controller attempts to minimize the error by adjusting the process control inputs. + * The proportional value determines the reaction to the current error, + * the integral value determines the reaction based on the sum of recent errors, + * and the derivative value determines the reaction based on the rate at which the error has been changing. + * + * \par Instance Structure + * The Gains A0, A1, A2 and state variables for a PID controller are stored together in an instance data structure. + * A separate instance structure must be defined for each PID Controller. + * There are separate instance structure declarations for each of the 3 supported data types. + * + * \par Reset Functions + * There is also an associated reset function for each data type which clears the state array. + * + * \par Initialization Functions + * There is also an associated initialization function for each data type. + * The initialization function performs the following operations: + * - Initializes the Gains A0, A1, A2 from Kp,Ki, Kd gains. + * - Zeros out the values in the state buffer. + * + * \par + * Instance structure cannot be placed into a const data section and it is recommended to use the initialization function. + * + * \par Fixed-Point Behavior + * Care must be taken when using the fixed-point versions of the PID Controller functions. + * In particular, the overflow and saturation behavior of the accumulator used in each function must be considered. + * Refer to the function specific documentation below for usage guidelines. + */ + + /** + * @addtogroup PID + * @{ + */ + + /** + * @brief Process function for the floating-point PID Control. + * @param[in,out] S is an instance of the floating-point PID Control structure + * @param[in] in input sample to process + * @return processed output sample. + */ + __STATIC_FORCEINLINE float32_t arm_pid_f32( + arm_pid_instance_f32 * S, + float32_t in) + { + float32_t out; + + /* y[n] = y[n-1] + A0 * x[n] + A1 * x[n-1] + A2 * x[n-2] */ + out = (S->A0 * in) + + (S->A1 * S->state[0]) + (S->A2 * S->state[1]) + (S->state[2]); + + /* Update state */ + S->state[1] = S->state[0]; + S->state[0] = in; + S->state[2] = out; + + /* return to application */ + return (out); + + } + +/** + @brief Process function for the Q31 PID Control. + @param[in,out] S points to an instance of the Q31 PID Control structure + @param[in] in input sample to process + @return processed output sample. + + \par Scaling and Overflow Behavior + The function is implemented using an internal 64-bit accumulator. + The accumulator has a 2.62 format and maintains full precision of the intermediate multiplication results but provides only a single guard bit. + Thus, if the accumulator result overflows it wraps around rather than clip. + In order to avoid overflows completely the input signal must be scaled down by 2 bits as there are four additions. + After all multiply-accumulates are performed, the 2.62 accumulator is truncated to 1.32 format and then saturated to 1.31 format. + */ +__STATIC_FORCEINLINE q31_t arm_pid_q31( + arm_pid_instance_q31 * S, + q31_t in) + { + q63_t acc; + q31_t out; + + /* acc = A0 * x[n] */ + acc = (q63_t) S->A0 * in; + + /* acc += A1 * x[n-1] */ + acc += (q63_t) S->A1 * S->state[0]; + + /* acc += A2 * x[n-2] */ + acc += (q63_t) S->A2 * S->state[1]; + + /* convert output to 1.31 format to add y[n-1] */ + out = (q31_t) (acc >> 31U); + + /* out += y[n-1] */ + out += S->state[2]; + + /* Update state */ + S->state[1] = S->state[0]; + S->state[0] = in; + S->state[2] = out; + + /* return to application */ + return (out); + } + + +/** + @brief Process function for the Q15 PID Control. + @param[in,out] S points to an instance of the Q15 PID Control structure + @param[in] in input sample to process + @return processed output sample. + + \par Scaling and Overflow Behavior + The function is implemented using a 64-bit internal accumulator. + Both Gains and state variables are represented in 1.15 format and multiplications yield a 2.30 result. + The 2.30 intermediate results are accumulated in a 64-bit accumulator in 34.30 format. + There is no risk of internal overflow with this approach and the full precision of intermediate multiplications is preserved. + After all additions have been performed, the accumulator is truncated to 34.15 format by discarding low 15 bits. + Lastly, the accumulator is saturated to yield a result in 1.15 format. + */ +__STATIC_FORCEINLINE q15_t arm_pid_q15( + arm_pid_instance_q15 * S, + q15_t in) + { + q63_t acc; + q15_t out; + +#if defined (ARM_MATH_DSP) + /* Implementation of PID controller */ + + /* acc = A0 * x[n] */ + acc = (q31_t) __SMUAD((uint32_t)S->A0, (uint32_t)in); + + /* acc += A1 * x[n-1] + A2 * x[n-2] */ + acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)read_q15x2 (S->state), (uint64_t)acc); +#else + /* acc = A0 * x[n] */ + acc = ((q31_t) S->A0) * in; + + /* acc += A1 * x[n-1] + A2 * x[n-2] */ + acc += (q31_t) S->A1 * S->state[0]; + acc += (q31_t) S->A2 * S->state[1]; +#endif + + /* acc += y[n-1] */ + acc += (q31_t) S->state[2] << 15; + + /* saturate the output */ + out = (q15_t) (__SSAT((q31_t)(acc >> 15), 16)); + + /* Update state */ + S->state[1] = S->state[0]; + S->state[0] = in; + S->state[2] = out; + + /* return to application */ + return (out); + } + + /** + * @} end of PID group + */ + + + /** + * @brief Floating-point matrix inverse. + * @param[in] src points to the instance of the input floating-point matrix structure. + * @param[out] dst points to the instance of the output floating-point matrix structure. + * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match. + * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR. + */ + arm_status arm_mat_inverse_f32( + const arm_matrix_instance_f32 * src, + arm_matrix_instance_f32 * dst); + + + /** + * @brief Floating-point matrix inverse. + * @param[in] src points to the instance of the input floating-point matrix structure. + * @param[out] dst points to the instance of the output floating-point matrix structure. + * @return The function returns ARM_MATH_SIZE_MISMATCH, if the dimensions do not match. + * If the input matrix is singular (does not have an inverse), then the algorithm terminates and returns error status ARM_MATH_SINGULAR. + */ + arm_status arm_mat_inverse_f64( + const arm_matrix_instance_f64 * src, + arm_matrix_instance_f64 * dst); + + + + /** + * @ingroup groupController + */ + + /** + * @defgroup clarke Vector Clarke Transform + * Forward Clarke transform converts the instantaneous stator phases into a two-coordinate time invariant vector. + * Generally the Clarke transform uses three-phase currents Ia, Ib and Ic to calculate currents + * in the two-phase orthogonal stator axis Ialpha and Ibeta. + * When Ialpha is superposed with Ia as shown in the figure below + * \image html clarke.gif Stator current space vector and its components in (a,b). + * and Ia + Ib + Ic = 0, in this condition Ialpha and Ibeta + * can be calculated using only Ia and Ib. + * + * The function operates on a single sample of data and each call to the function returns the processed output. + * The library provides separate functions for Q31 and floating-point data types. + * \par Algorithm + * \image html clarkeFormula.gif + * where Ia and Ib are the instantaneous stator phases and + * pIalpha and pIbeta are the two coordinates of time invariant vector. + * \par Fixed-Point Behavior + * Care must be taken when using the Q31 version of the Clarke transform. + * In particular, the overflow and saturation behavior of the accumulator used must be considered. + * Refer to the function specific documentation below for usage guidelines. + */ + + /** + * @addtogroup clarke + * @{ + */ + + /** + * + * @brief Floating-point Clarke transform + * @param[in] Ia input three-phase coordinate a + * @param[in] Ib input three-phase coordinate b + * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha + * @param[out] pIbeta points to output two-phase orthogonal vector axis beta + * @return none + */ + __STATIC_FORCEINLINE void arm_clarke_f32( + float32_t Ia, + float32_t Ib, + float32_t * pIalpha, + float32_t * pIbeta) + { + /* Calculate pIalpha using the equation, pIalpha = Ia */ + *pIalpha = Ia; + + /* Calculate pIbeta using the equation, pIbeta = (1/sqrt(3)) * Ia + (2/sqrt(3)) * Ib */ + *pIbeta = ((float32_t) 0.57735026919 * Ia + (float32_t) 1.15470053838 * Ib); + } + + +/** + @brief Clarke transform for Q31 version + @param[in] Ia input three-phase coordinate a + @param[in] Ib input three-phase coordinate b + @param[out] pIalpha points to output two-phase orthogonal vector axis alpha + @param[out] pIbeta points to output two-phase orthogonal vector axis beta + @return none + + \par Scaling and Overflow Behavior + The function is implemented using an internal 32-bit accumulator. + The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. + There is saturation on the addition, hence there is no risk of overflow. + */ +__STATIC_FORCEINLINE void arm_clarke_q31( + q31_t Ia, + q31_t Ib, + q31_t * pIalpha, + q31_t * pIbeta) + { + q31_t product1, product2; /* Temporary variables used to store intermediate results */ + + /* Calculating pIalpha from Ia by equation pIalpha = Ia */ + *pIalpha = Ia; + + /* Intermediate product is calculated by (1/(sqrt(3)) * Ia) */ + product1 = (q31_t) (((q63_t) Ia * 0x24F34E8B) >> 30); + + /* Intermediate product is calculated by (2/sqrt(3) * Ib) */ + product2 = (q31_t) (((q63_t) Ib * 0x49E69D16) >> 30); + + /* pIbeta is calculated by adding the intermediate products */ + *pIbeta = __QADD(product1, product2); + } + + /** + * @} end of clarke group + */ + + + /** + * @ingroup groupController + */ + + /** + * @defgroup inv_clarke Vector Inverse Clarke Transform + * Inverse Clarke transform converts the two-coordinate time invariant vector into instantaneous stator phases. + * + * The function operates on a single sample of data and each call to the function returns the processed output. + * The library provides separate functions for Q31 and floating-point data types. + * \par Algorithm + * \image html clarkeInvFormula.gif + * where pIa and pIb are the instantaneous stator phases and + * Ialpha and Ibeta are the two coordinates of time invariant vector. + * \par Fixed-Point Behavior + * Care must be taken when using the Q31 version of the Clarke transform. + * In particular, the overflow and saturation behavior of the accumulator used must be considered. + * Refer to the function specific documentation below for usage guidelines. + */ + + /** + * @addtogroup inv_clarke + * @{ + */ + + /** + * @brief Floating-point Inverse Clarke transform + * @param[in] Ialpha input two-phase orthogonal vector axis alpha + * @param[in] Ibeta input two-phase orthogonal vector axis beta + * @param[out] pIa points to output three-phase coordinate a + * @param[out] pIb points to output three-phase coordinate b + * @return none + */ + __STATIC_FORCEINLINE void arm_inv_clarke_f32( + float32_t Ialpha, + float32_t Ibeta, + float32_t * pIa, + float32_t * pIb) + { + /* Calculating pIa from Ialpha by equation pIa = Ialpha */ + *pIa = Ialpha; + + /* Calculating pIb from Ialpha and Ibeta by equation pIb = -(1/2) * Ialpha + (sqrt(3)/2) * Ibeta */ + *pIb = -0.5f * Ialpha + 0.8660254039f * Ibeta; + } + + +/** + @brief Inverse Clarke transform for Q31 version + @param[in] Ialpha input two-phase orthogonal vector axis alpha + @param[in] Ibeta input two-phase orthogonal vector axis beta + @param[out] pIa points to output three-phase coordinate a + @param[out] pIb points to output three-phase coordinate b + @return none + + \par Scaling and Overflow Behavior + The function is implemented using an internal 32-bit accumulator. + The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. + There is saturation on the subtraction, hence there is no risk of overflow. + */ +__STATIC_FORCEINLINE void arm_inv_clarke_q31( + q31_t Ialpha, + q31_t Ibeta, + q31_t * pIa, + q31_t * pIb) + { + q31_t product1, product2; /* Temporary variables used to store intermediate results */ + + /* Calculating pIa from Ialpha by equation pIa = Ialpha */ + *pIa = Ialpha; + + /* Intermediate product is calculated by (1/(2*sqrt(3)) * Ia) */ + product1 = (q31_t) (((q63_t) (Ialpha) * (0x40000000)) >> 31); + + /* Intermediate product is calculated by (1/sqrt(3) * pIb) */ + product2 = (q31_t) (((q63_t) (Ibeta) * (0x6ED9EBA1)) >> 31); + + /* pIb is calculated by subtracting the products */ + *pIb = __QSUB(product2, product1); + } + + /** + * @} end of inv_clarke group + */ + + + + /** + * @ingroup groupController + */ + + /** + * @defgroup park Vector Park Transform + * + * Forward Park transform converts the input two-coordinate vector to flux and torque components. + * The Park transform can be used to realize the transformation of the Ialpha and the Ibeta currents + * from the stationary to the moving reference frame and control the spatial relationship between + * the stator vector current and rotor flux vector. + * If we consider the d axis aligned with the rotor flux, the diagram below shows the + * current vector and the relationship from the two reference frames: + * \image html park.gif "Stator current space vector and its component in (a,b) and in the d,q rotating reference frame" + * + * The function operates on a single sample of data and each call to the function returns the processed output. + * The library provides separate functions for Q31 and floating-point data types. + * \par Algorithm + * \image html parkFormula.gif + * where Ialpha and Ibeta are the stator vector components, + * pId and pIq are rotor vector components and cosVal and sinVal are the + * cosine and sine values of theta (rotor flux position). + * \par Fixed-Point Behavior + * Care must be taken when using the Q31 version of the Park transform. + * In particular, the overflow and saturation behavior of the accumulator used must be considered. + * Refer to the function specific documentation below for usage guidelines. + */ + + /** + * @addtogroup park + * @{ + */ + + /** + * @brief Floating-point Park transform + * @param[in] Ialpha input two-phase vector coordinate alpha + * @param[in] Ibeta input two-phase vector coordinate beta + * @param[out] pId points to output rotor reference frame d + * @param[out] pIq points to output rotor reference frame q + * @param[in] sinVal sine value of rotation angle theta + * @param[in] cosVal cosine value of rotation angle theta + * @return none + * + * The function implements the forward Park transform. + * + */ + __STATIC_FORCEINLINE void arm_park_f32( + float32_t Ialpha, + float32_t Ibeta, + float32_t * pId, + float32_t * pIq, + float32_t sinVal, + float32_t cosVal) + { + /* Calculate pId using the equation, pId = Ialpha * cosVal + Ibeta * sinVal */ + *pId = Ialpha * cosVal + Ibeta * sinVal; + + /* Calculate pIq using the equation, pIq = - Ialpha * sinVal + Ibeta * cosVal */ + *pIq = -Ialpha * sinVal + Ibeta * cosVal; + } + + +/** + @brief Park transform for Q31 version + @param[in] Ialpha input two-phase vector coordinate alpha + @param[in] Ibeta input two-phase vector coordinate beta + @param[out] pId points to output rotor reference frame d + @param[out] pIq points to output rotor reference frame q + @param[in] sinVal sine value of rotation angle theta + @param[in] cosVal cosine value of rotation angle theta + @return none + + \par Scaling and Overflow Behavior + The function is implemented using an internal 32-bit accumulator. + The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. + There is saturation on the addition and subtraction, hence there is no risk of overflow. + */ +__STATIC_FORCEINLINE void arm_park_q31( + q31_t Ialpha, + q31_t Ibeta, + q31_t * pId, + q31_t * pIq, + q31_t sinVal, + q31_t cosVal) + { + q31_t product1, product2; /* Temporary variables used to store intermediate results */ + q31_t product3, product4; /* Temporary variables used to store intermediate results */ + + /* Intermediate product is calculated by (Ialpha * cosVal) */ + product1 = (q31_t) (((q63_t) (Ialpha) * (cosVal)) >> 31); + + /* Intermediate product is calculated by (Ibeta * sinVal) */ + product2 = (q31_t) (((q63_t) (Ibeta) * (sinVal)) >> 31); + + + /* Intermediate product is calculated by (Ialpha * sinVal) */ + product3 = (q31_t) (((q63_t) (Ialpha) * (sinVal)) >> 31); + + /* Intermediate product is calculated by (Ibeta * cosVal) */ + product4 = (q31_t) (((q63_t) (Ibeta) * (cosVal)) >> 31); + + /* Calculate pId by adding the two intermediate products 1 and 2 */ + *pId = __QADD(product1, product2); + + /* Calculate pIq by subtracting the two intermediate products 3 from 4 */ + *pIq = __QSUB(product4, product3); + } + + /** + * @} end of park group + */ + + + /** + * @ingroup groupController + */ + + /** + * @defgroup inv_park Vector Inverse Park transform + * Inverse Park transform converts the input flux and torque components to two-coordinate vector. + * + * The function operates on a single sample of data and each call to the function returns the processed output. + * The library provides separate functions for Q31 and floating-point data types. + * \par Algorithm + * \image html parkInvFormula.gif + * where pIalpha and pIbeta are the stator vector components, + * Id and Iq are rotor vector components and cosVal and sinVal are the + * cosine and sine values of theta (rotor flux position). + * \par Fixed-Point Behavior + * Care must be taken when using the Q31 version of the Park transform. + * In particular, the overflow and saturation behavior of the accumulator used must be considered. + * Refer to the function specific documentation below for usage guidelines. + */ + + /** + * @addtogroup inv_park + * @{ + */ + + /** + * @brief Floating-point Inverse Park transform + * @param[in] Id input coordinate of rotor reference frame d + * @param[in] Iq input coordinate of rotor reference frame q + * @param[out] pIalpha points to output two-phase orthogonal vector axis alpha + * @param[out] pIbeta points to output two-phase orthogonal vector axis beta + * @param[in] sinVal sine value of rotation angle theta + * @param[in] cosVal cosine value of rotation angle theta + * @return none + */ + __STATIC_FORCEINLINE void arm_inv_park_f32( + float32_t Id, + float32_t Iq, + float32_t * pIalpha, + float32_t * pIbeta, + float32_t sinVal, + float32_t cosVal) + { + /* Calculate pIalpha using the equation, pIalpha = Id * cosVal - Iq * sinVal */ + *pIalpha = Id * cosVal - Iq * sinVal; + + /* Calculate pIbeta using the equation, pIbeta = Id * sinVal + Iq * cosVal */ + *pIbeta = Id * sinVal + Iq * cosVal; + } + + +/** + @brief Inverse Park transform for Q31 version + @param[in] Id input coordinate of rotor reference frame d + @param[in] Iq input coordinate of rotor reference frame q + @param[out] pIalpha points to output two-phase orthogonal vector axis alpha + @param[out] pIbeta points to output two-phase orthogonal vector axis beta + @param[in] sinVal sine value of rotation angle theta + @param[in] cosVal cosine value of rotation angle theta + @return none + + @par Scaling and Overflow Behavior + The function is implemented using an internal 32-bit accumulator. + The accumulator maintains 1.31 format by truncating lower 31 bits of the intermediate multiplication in 2.62 format. + There is saturation on the addition, hence there is no risk of overflow. + */ +__STATIC_FORCEINLINE void arm_inv_park_q31( + q31_t Id, + q31_t Iq, + q31_t * pIalpha, + q31_t * pIbeta, + q31_t sinVal, + q31_t cosVal) + { + q31_t product1, product2; /* Temporary variables used to store intermediate results */ + q31_t product3, product4; /* Temporary variables used to store intermediate results */ + + /* Intermediate product is calculated by (Id * cosVal) */ + product1 = (q31_t) (((q63_t) (Id) * (cosVal)) >> 31); + + /* Intermediate product is calculated by (Iq * sinVal) */ + product2 = (q31_t) (((q63_t) (Iq) * (sinVal)) >> 31); + + + /* Intermediate product is calculated by (Id * sinVal) */ + product3 = (q31_t) (((q63_t) (Id) * (sinVal)) >> 31); + + /* Intermediate product is calculated by (Iq * cosVal) */ + product4 = (q31_t) (((q63_t) (Iq) * (cosVal)) >> 31); + + /* Calculate pIalpha by using the two intermediate products 1 and 2 */ + *pIalpha = __QSUB(product1, product2); + + /* Calculate pIbeta by using the two intermediate products 3 and 4 */ + *pIbeta = __QADD(product4, product3); + } + + /** + * @} end of Inverse park group + */ + + + /** + * @ingroup groupInterpolation + */ + + /** + * @defgroup LinearInterpolate Linear Interpolation + * + * Linear interpolation is a method of curve fitting using linear polynomials. + * Linear interpolation works by effectively drawing a straight line between two neighboring samples and returning the appropriate point along that line + * + * \par + * \image html LinearInterp.gif "Linear interpolation" + * + * \par + * A Linear Interpolate function calculates an output value(y), for the input(x) + * using linear interpolation of the input values x0, x1( nearest input values) and the output values y0 and y1(nearest output values) + * + * \par Algorithm: + *
+   *       y = y0 + (x - x0) * ((y1 - y0)/(x1-x0))
+   *       where x0, x1 are nearest values of input x
+   *             y0, y1 are nearest values to output y
+   * 
+ * + * \par + * This set of functions implements Linear interpolation process + * for Q7, Q15, Q31, and floating-point data types. The functions operate on a single + * sample of data and each call to the function returns a single processed value. + * S points to an instance of the Linear Interpolate function data structure. + * x is the input sample value. The functions returns the output value. + * + * \par + * if x is outside of the table boundary, Linear interpolation returns first value of the table + * if x is below input range and returns last value of table if x is above range. + */ + + /** + * @addtogroup LinearInterpolate + * @{ + */ + + /** + * @brief Process function for the floating-point Linear Interpolation Function. + * @param[in,out] S is an instance of the floating-point Linear Interpolation structure + * @param[in] x input sample to process + * @return y processed output sample. + * + */ + __STATIC_FORCEINLINE float32_t arm_linear_interp_f32( + arm_linear_interp_instance_f32 * S, + float32_t x) + { + float32_t y; + float32_t x0, x1; /* Nearest input values */ + float32_t y0, y1; /* Nearest output values */ + float32_t xSpacing = S->xSpacing; /* spacing between input values */ + int32_t i; /* Index variable */ + float32_t *pYData = S->pYData; /* pointer to output table */ + + /* Calculation of index */ + i = (int32_t) ((x - S->x1) / xSpacing); + + if (i < 0) + { + /* Iniatilize output for below specified range as least output value of table */ + y = pYData[0]; + } + else if ((uint32_t)i >= (S->nValues - 1)) + { + /* Iniatilize output for above specified range as last output value of table */ + y = pYData[S->nValues - 1]; + } + else + { + /* Calculation of nearest input values */ + x0 = S->x1 + i * xSpacing; + x1 = S->x1 + (i + 1) * xSpacing; + + /* Read of nearest output values */ + y0 = pYData[i]; + y1 = pYData[i + 1]; + + /* Calculation of output */ + y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0)); + + } + + /* returns output value */ + return (y); + } + + + /** + * + * @brief Process function for the Q31 Linear Interpolation Function. + * @param[in] pYData pointer to Q31 Linear Interpolation table + * @param[in] x input sample to process + * @param[in] nValues number of table values + * @return y processed output sample. + * + * \par + * Input sample x is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. + * This function can support maximum of table size 2^12. + * + */ + __STATIC_FORCEINLINE q31_t arm_linear_interp_q31( + q31_t * pYData, + q31_t x, + uint32_t nValues) + { + q31_t y; /* output */ + q31_t y0, y1; /* Nearest output values */ + q31_t fract; /* fractional part */ + int32_t index; /* Index to read nearest output values */ + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + index = ((x & (q31_t)0xFFF00000) >> 20); + + if (index >= (int32_t)(nValues - 1)) + { + return (pYData[nValues - 1]); + } + else if (index < 0) + { + return (pYData[0]); + } + else + { + /* 20 bits for the fractional part */ + /* shift left by 11 to keep fract in 1.31 format */ + fract = (x & 0x000FFFFF) << 11; + + /* Read two nearest output values from the index in 1.31(q31) format */ + y0 = pYData[index]; + y1 = pYData[index + 1]; + + /* Calculation of y0 * (1-fract) and y is in 2.30 format */ + y = ((q31_t) ((q63_t) y0 * (0x7FFFFFFF - fract) >> 32)); + + /* Calculation of y0 * (1-fract) + y1 *fract and y is in 2.30 format */ + y += ((q31_t) (((q63_t) y1 * fract) >> 32)); + + /* Convert y to 1.31 format */ + return (y << 1U); + } + } + + + /** + * + * @brief Process function for the Q15 Linear Interpolation Function. + * @param[in] pYData pointer to Q15 Linear Interpolation table + * @param[in] x input sample to process + * @param[in] nValues number of table values + * @return y processed output sample. + * + * \par + * Input sample x is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. + * This function can support maximum of table size 2^12. + * + */ + __STATIC_FORCEINLINE q15_t arm_linear_interp_q15( + q15_t * pYData, + q31_t x, + uint32_t nValues) + { + q63_t y; /* output */ + q15_t y0, y1; /* Nearest output values */ + q31_t fract; /* fractional part */ + int32_t index; /* Index to read nearest output values */ + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + index = ((x & (int32_t)0xFFF00000) >> 20); + + if (index >= (int32_t)(nValues - 1)) + { + return (pYData[nValues - 1]); + } + else if (index < 0) + { + return (pYData[0]); + } + else + { + /* 20 bits for the fractional part */ + /* fract is in 12.20 format */ + fract = (x & 0x000FFFFF); + + /* Read two nearest output values from the index */ + y0 = pYData[index]; + y1 = pYData[index + 1]; + + /* Calculation of y0 * (1-fract) and y is in 13.35 format */ + y = ((q63_t) y0 * (0xFFFFF - fract)); + + /* Calculation of (y0 * (1-fract) + y1 * fract) and y is in 13.35 format */ + y += ((q63_t) y1 * (fract)); + + /* convert y to 1.15 format */ + return (q15_t) (y >> 20); + } + } + + + /** + * + * @brief Process function for the Q7 Linear Interpolation Function. + * @param[in] pYData pointer to Q7 Linear Interpolation table + * @param[in] x input sample to process + * @param[in] nValues number of table values + * @return y processed output sample. + * + * \par + * Input sample x is in 12.20 format which contains 12 bits for table index and 20 bits for fractional part. + * This function can support maximum of table size 2^12. + */ + __STATIC_FORCEINLINE q7_t arm_linear_interp_q7( + q7_t * pYData, + q31_t x, + uint32_t nValues) + { + q31_t y; /* output */ + q7_t y0, y1; /* Nearest output values */ + q31_t fract; /* fractional part */ + uint32_t index; /* Index to read nearest output values */ + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + if (x < 0) + { + return (pYData[0]); + } + index = (x >> 20) & 0xfff; + + if (index >= (nValues - 1)) + { + return (pYData[nValues - 1]); + } + else + { + /* 20 bits for the fractional part */ + /* fract is in 12.20 format */ + fract = (x & 0x000FFFFF); + + /* Read two nearest output values from the index and are in 1.7(q7) format */ + y0 = pYData[index]; + y1 = pYData[index + 1]; + + /* Calculation of y0 * (1-fract ) and y is in 13.27(q27) format */ + y = ((y0 * (0xFFFFF - fract))); + + /* Calculation of y1 * fract + y0 * (1-fract) and y is in 13.27(q27) format */ + y += (y1 * fract); + + /* convert y to 1.7(q7) format */ + return (q7_t) (y >> 20); + } + } + + /** + * @} end of LinearInterpolate group + */ + + /** + * @brief Fast approximation to the trigonometric sine function for floating-point data. + * @param[in] x input value in radians. + * @return sin(x). + */ + float32_t arm_sin_f32( + float32_t x); + + + /** + * @brief Fast approximation to the trigonometric sine function for Q31 data. + * @param[in] x Scaled input value in radians. + * @return sin(x). + */ + q31_t arm_sin_q31( + q31_t x); + + + /** + * @brief Fast approximation to the trigonometric sine function for Q15 data. + * @param[in] x Scaled input value in radians. + * @return sin(x). + */ + q15_t arm_sin_q15( + q15_t x); + + + /** + * @brief Fast approximation to the trigonometric cosine function for floating-point data. + * @param[in] x input value in radians. + * @return cos(x). + */ + float32_t arm_cos_f32( + float32_t x); + + + /** + * @brief Fast approximation to the trigonometric cosine function for Q31 data. + * @param[in] x Scaled input value in radians. + * @return cos(x). + */ + q31_t arm_cos_q31( + q31_t x); + + + /** + * @brief Fast approximation to the trigonometric cosine function for Q15 data. + * @param[in] x Scaled input value in radians. + * @return cos(x). + */ + q15_t arm_cos_q15( + q15_t x); + + +/** + @brief Floating-point vector of log values. + @param[in] pSrc points to the input vector + @param[out] pDst points to the output vector + @param[in] blockSize number of samples in each vector + @return none + */ + void arm_vlog_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + +/** + @brief Floating-point vector of exp values. + @param[in] pSrc points to the input vector + @param[out] pDst points to the output vector + @param[in] blockSize number of samples in each vector + @return none + */ + void arm_vexp_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + /** + * @ingroup groupFastMath + */ + + + /** + * @defgroup SQRT Square Root + * + * Computes the square root of a number. + * There are separate functions for Q15, Q31, and floating-point data types. + * The square root function is computed using the Newton-Raphson algorithm. + * This is an iterative algorithm of the form: + *
+   *      x1 = x0 - f(x0)/f'(x0)
+   * 
+ * where x1 is the current estimate, + * x0 is the previous estimate, and + * f'(x0) is the derivative of f() evaluated at x0. + * For the square root function, the algorithm reduces to: + *
+   *     x0 = in/2                         [initial guess]
+   *     x1 = 1/2 * ( x0 + in / x0)        [each iteration]
+   * 
+ */ + + + /** + * @addtogroup SQRT + * @{ + */ + +/** + @brief Floating-point square root function. + @param[in] in input value + @param[out] pOut square root of input value + @return execution status + - \ref ARM_MATH_SUCCESS : input value is positive + - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 + */ +__STATIC_FORCEINLINE arm_status arm_sqrt_f32( + float32_t in, + float32_t * pOut) + { + if (in >= 0.0f) + { +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + *pOut = __sqrtf(in); + #else + *pOut = sqrtf(in); + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in)); + #else + *pOut = sqrtf(in); + #endif + +#else + *pOut = sqrtf(in); +#endif + + return (ARM_MATH_SUCCESS); + } + else + { + *pOut = 0.0f; + return (ARM_MATH_ARGUMENT_ERROR); + } + } + + +/** + @brief Q31 square root function. + @param[in] in input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF + @param[out] pOut points to square root of input value + @return execution status + - \ref ARM_MATH_SUCCESS : input value is positive + - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 + */ +arm_status arm_sqrt_q31( + q31_t in, + q31_t * pOut); + + +/** + @brief Q15 square root function. + @param[in] in input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF + @param[out] pOut points to square root of input value + @return execution status + - \ref ARM_MATH_SUCCESS : input value is positive + - \ref ARM_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0 + */ +arm_status arm_sqrt_q15( + q15_t in, + q15_t * pOut); + + /** + * @brief Vector Floating-point square root function. + * @param[in] pIn input vector. + * @param[out] pOut vector of square roots of input elements. + * @param[in] len length of input vector. + * @return The function returns ARM_MATH_SUCCESS if input value is positive value or ARM_MATH_ARGUMENT_ERROR if + * in is negative value and returns zero output for negative values. + */ + void arm_vsqrt_f32( + float32_t * pIn, + float32_t * pOut, + uint16_t len); + + void arm_vsqrt_q31( + q31_t * pIn, + q31_t * pOut, + uint16_t len); + + void arm_vsqrt_q15( + q15_t * pIn, + q15_t * pOut, + uint16_t len); + + /** + * @} end of SQRT group + */ + + + /** + * @brief floating-point Circular write function. + */ + __STATIC_FORCEINLINE void arm_circularWrite_f32( + int32_t * circBuffer, + int32_t L, + uint16_t * writeOffset, + int32_t bufferInc, + const int32_t * src, + int32_t srcInc, + uint32_t blockSize) + { + uint32_t i = 0U; + int32_t wOffset; + + /* Copy the value of Index pointer that points + * to the current location where the input samples to be copied */ + wOffset = *writeOffset; + + /* Loop over the blockSize */ + i = blockSize; + + while (i > 0U) + { + /* copy the input sample to the circular buffer */ + circBuffer[wOffset] = *src; + + /* Update the input pointer */ + src += srcInc; + + /* Circularly update wOffset. Watch out for positive and negative value */ + wOffset += bufferInc; + if (wOffset >= L) + wOffset -= L; + + /* Decrement the loop counter */ + i--; + } + + /* Update the index pointer */ + *writeOffset = (uint16_t)wOffset; + } + + + + /** + * @brief floating-point Circular Read function. + */ + __STATIC_FORCEINLINE void arm_circularRead_f32( + int32_t * circBuffer, + int32_t L, + int32_t * readOffset, + int32_t bufferInc, + int32_t * dst, + int32_t * dst_base, + int32_t dst_length, + int32_t dstInc, + uint32_t blockSize) + { + uint32_t i = 0U; + int32_t rOffset; + int32_t* dst_end; + + /* Copy the value of Index pointer that points + * to the current location from where the input samples to be read */ + rOffset = *readOffset; + dst_end = dst_base + dst_length; + + /* Loop over the blockSize */ + i = blockSize; + + while (i > 0U) + { + /* copy the sample from the circular buffer to the destination buffer */ + *dst = circBuffer[rOffset]; + + /* Update the input pointer */ + dst += dstInc; + + if (dst == dst_end) + { + dst = dst_base; + } + + /* Circularly update rOffset. Watch out for positive and negative value */ + rOffset += bufferInc; + + if (rOffset >= L) + { + rOffset -= L; + } + + /* Decrement the loop counter */ + i--; + } + + /* Update the index pointer */ + *readOffset = rOffset; + } + + + /** + * @brief Q15 Circular write function. + */ + __STATIC_FORCEINLINE void arm_circularWrite_q15( + q15_t * circBuffer, + int32_t L, + uint16_t * writeOffset, + int32_t bufferInc, + const q15_t * src, + int32_t srcInc, + uint32_t blockSize) + { + uint32_t i = 0U; + int32_t wOffset; + + /* Copy the value of Index pointer that points + * to the current location where the input samples to be copied */ + wOffset = *writeOffset; + + /* Loop over the blockSize */ + i = blockSize; + + while (i > 0U) + { + /* copy the input sample to the circular buffer */ + circBuffer[wOffset] = *src; + + /* Update the input pointer */ + src += srcInc; + + /* Circularly update wOffset. Watch out for positive and negative value */ + wOffset += bufferInc; + if (wOffset >= L) + wOffset -= L; + + /* Decrement the loop counter */ + i--; + } + + /* Update the index pointer */ + *writeOffset = (uint16_t)wOffset; + } + + + /** + * @brief Q15 Circular Read function. + */ + __STATIC_FORCEINLINE void arm_circularRead_q15( + q15_t * circBuffer, + int32_t L, + int32_t * readOffset, + int32_t bufferInc, + q15_t * dst, + q15_t * dst_base, + int32_t dst_length, + int32_t dstInc, + uint32_t blockSize) + { + uint32_t i = 0; + int32_t rOffset; + q15_t* dst_end; + + /* Copy the value of Index pointer that points + * to the current location from where the input samples to be read */ + rOffset = *readOffset; + + dst_end = dst_base + dst_length; + + /* Loop over the blockSize */ + i = blockSize; + + while (i > 0U) + { + /* copy the sample from the circular buffer to the destination buffer */ + *dst = circBuffer[rOffset]; + + /* Update the input pointer */ + dst += dstInc; + + if (dst == dst_end) + { + dst = dst_base; + } + + /* Circularly update wOffset. Watch out for positive and negative value */ + rOffset += bufferInc; + + if (rOffset >= L) + { + rOffset -= L; + } + + /* Decrement the loop counter */ + i--; + } + + /* Update the index pointer */ + *readOffset = rOffset; + } + + + /** + * @brief Q7 Circular write function. + */ + __STATIC_FORCEINLINE void arm_circularWrite_q7( + q7_t * circBuffer, + int32_t L, + uint16_t * writeOffset, + int32_t bufferInc, + const q7_t * src, + int32_t srcInc, + uint32_t blockSize) + { + uint32_t i = 0U; + int32_t wOffset; + + /* Copy the value of Index pointer that points + * to the current location where the input samples to be copied */ + wOffset = *writeOffset; + + /* Loop over the blockSize */ + i = blockSize; + + while (i > 0U) + { + /* copy the input sample to the circular buffer */ + circBuffer[wOffset] = *src; + + /* Update the input pointer */ + src += srcInc; + + /* Circularly update wOffset. Watch out for positive and negative value */ + wOffset += bufferInc; + if (wOffset >= L) + wOffset -= L; + + /* Decrement the loop counter */ + i--; + } + + /* Update the index pointer */ + *writeOffset = (uint16_t)wOffset; + } + + + /** + * @brief Q7 Circular Read function. + */ + __STATIC_FORCEINLINE void arm_circularRead_q7( + q7_t * circBuffer, + int32_t L, + int32_t * readOffset, + int32_t bufferInc, + q7_t * dst, + q7_t * dst_base, + int32_t dst_length, + int32_t dstInc, + uint32_t blockSize) + { + uint32_t i = 0; + int32_t rOffset; + q7_t* dst_end; + + /* Copy the value of Index pointer that points + * to the current location from where the input samples to be read */ + rOffset = *readOffset; + + dst_end = dst_base + dst_length; + + /* Loop over the blockSize */ + i = blockSize; + + while (i > 0U) + { + /* copy the sample from the circular buffer to the destination buffer */ + *dst = circBuffer[rOffset]; + + /* Update the input pointer */ + dst += dstInc; + + if (dst == dst_end) + { + dst = dst_base; + } + + /* Circularly update rOffset. Watch out for positive and negative value */ + rOffset += bufferInc; + + if (rOffset >= L) + { + rOffset -= L; + } + + /* Decrement the loop counter */ + i--; + } + + /* Update the index pointer */ + *readOffset = rOffset; + } + + + /** + * @brief Sum of the squares of the elements of a Q31 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_power_q31( + const q31_t * pSrc, + uint32_t blockSize, + q63_t * pResult); + + + /** + * @brief Sum of the squares of the elements of a floating-point vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_power_f32( + const float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult); + + + /** + * @brief Sum of the squares of the elements of a Q15 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_power_q15( + const q15_t * pSrc, + uint32_t blockSize, + q63_t * pResult); + + + /** + * @brief Sum of the squares of the elements of a Q7 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_power_q7( + const q7_t * pSrc, + uint32_t blockSize, + q31_t * pResult); + + + /** + * @brief Mean value of a Q7 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_mean_q7( + const q7_t * pSrc, + uint32_t blockSize, + q7_t * pResult); + + + /** + * @brief Mean value of a Q15 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_mean_q15( + const q15_t * pSrc, + uint32_t blockSize, + q15_t * pResult); + + + /** + * @brief Mean value of a Q31 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_mean_q31( + const q31_t * pSrc, + uint32_t blockSize, + q31_t * pResult); + + + /** + * @brief Mean value of a floating-point vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_mean_f32( + const float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult); + + + /** + * @brief Variance of the elements of a floating-point vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_var_f32( + const float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult); + + + /** + * @brief Variance of the elements of a Q31 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_var_q31( + const q31_t * pSrc, + uint32_t blockSize, + q31_t * pResult); + + + /** + * @brief Variance of the elements of a Q15 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_var_q15( + const q15_t * pSrc, + uint32_t blockSize, + q15_t * pResult); + + + /** + * @brief Root Mean Square of the elements of a floating-point vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_rms_f32( + const float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult); + + + /** + * @brief Root Mean Square of the elements of a Q31 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_rms_q31( + const q31_t * pSrc, + uint32_t blockSize, + q31_t * pResult); + + + /** + * @brief Root Mean Square of the elements of a Q15 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_rms_q15( + const q15_t * pSrc, + uint32_t blockSize, + q15_t * pResult); + + + /** + * @brief Standard deviation of the elements of a floating-point vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_std_f32( + const float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult); + + + /** + * @brief Standard deviation of the elements of a Q31 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_std_q31( + const q31_t * pSrc, + uint32_t blockSize, + q31_t * pResult); + + + /** + * @brief Standard deviation of the elements of a Q15 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output value. + */ + void arm_std_q15( + const q15_t * pSrc, + uint32_t blockSize, + q15_t * pResult); + + + /** + * @brief Floating-point complex magnitude + * @param[in] pSrc points to the complex input vector + * @param[out] pDst points to the real output vector + * @param[in] numSamples number of complex samples in the input vector + */ + void arm_cmplx_mag_f32( + const float32_t * pSrc, + float32_t * pDst, + uint32_t numSamples); + + + /** + * @brief Q31 complex magnitude + * @param[in] pSrc points to the complex input vector + * @param[out] pDst points to the real output vector + * @param[in] numSamples number of complex samples in the input vector + */ + void arm_cmplx_mag_q31( + const q31_t * pSrc, + q31_t * pDst, + uint32_t numSamples); + + + /** + * @brief Q15 complex magnitude + * @param[in] pSrc points to the complex input vector + * @param[out] pDst points to the real output vector + * @param[in] numSamples number of complex samples in the input vector + */ + void arm_cmplx_mag_q15( + const q15_t * pSrc, + q15_t * pDst, + uint32_t numSamples); + + + /** + * @brief Q15 complex dot product + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] numSamples number of complex samples in each vector + * @param[out] realResult real part of the result returned here + * @param[out] imagResult imaginary part of the result returned here + */ + void arm_cmplx_dot_prod_q15( + const q15_t * pSrcA, + const q15_t * pSrcB, + uint32_t numSamples, + q31_t * realResult, + q31_t * imagResult); + + + /** + * @brief Q31 complex dot product + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] numSamples number of complex samples in each vector + * @param[out] realResult real part of the result returned here + * @param[out] imagResult imaginary part of the result returned here + */ + void arm_cmplx_dot_prod_q31( + const q31_t * pSrcA, + const q31_t * pSrcB, + uint32_t numSamples, + q63_t * realResult, + q63_t * imagResult); + + + /** + * @brief Floating-point complex dot product + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] numSamples number of complex samples in each vector + * @param[out] realResult real part of the result returned here + * @param[out] imagResult imaginary part of the result returned here + */ + void arm_cmplx_dot_prod_f32( + const float32_t * pSrcA, + const float32_t * pSrcB, + uint32_t numSamples, + float32_t * realResult, + float32_t * imagResult); + + + /** + * @brief Q15 complex-by-real multiplication + * @param[in] pSrcCmplx points to the complex input vector + * @param[in] pSrcReal points to the real input vector + * @param[out] pCmplxDst points to the complex output vector + * @param[in] numSamples number of samples in each vector + */ + void arm_cmplx_mult_real_q15( + const q15_t * pSrcCmplx, + const q15_t * pSrcReal, + q15_t * pCmplxDst, + uint32_t numSamples); + + + /** + * @brief Q31 complex-by-real multiplication + * @param[in] pSrcCmplx points to the complex input vector + * @param[in] pSrcReal points to the real input vector + * @param[out] pCmplxDst points to the complex output vector + * @param[in] numSamples number of samples in each vector + */ + void arm_cmplx_mult_real_q31( + const q31_t * pSrcCmplx, + const q31_t * pSrcReal, + q31_t * pCmplxDst, + uint32_t numSamples); + + + /** + * @brief Floating-point complex-by-real multiplication + * @param[in] pSrcCmplx points to the complex input vector + * @param[in] pSrcReal points to the real input vector + * @param[out] pCmplxDst points to the complex output vector + * @param[in] numSamples number of samples in each vector + */ + void arm_cmplx_mult_real_f32( + const float32_t * pSrcCmplx, + const float32_t * pSrcReal, + float32_t * pCmplxDst, + uint32_t numSamples); + + + /** + * @brief Minimum value of a Q7 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] result is output pointer + * @param[in] index is the array index of the minimum value in the input buffer. + */ + void arm_min_q7( + const q7_t * pSrc, + uint32_t blockSize, + q7_t * result, + uint32_t * index); + + + /** + * @brief Minimum value of a Q15 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output pointer + * @param[in] pIndex is the array index of the minimum value in the input buffer. + */ + void arm_min_q15( + const q15_t * pSrc, + uint32_t blockSize, + q15_t * pResult, + uint32_t * pIndex); + + + /** + * @brief Minimum value of a Q31 vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output pointer + * @param[out] pIndex is the array index of the minimum value in the input buffer. + */ + void arm_min_q31( + const q31_t * pSrc, + uint32_t blockSize, + q31_t * pResult, + uint32_t * pIndex); + + + /** + * @brief Minimum value of a floating-point vector. + * @param[in] pSrc is input pointer + * @param[in] blockSize is the number of samples to process + * @param[out] pResult is output pointer + * @param[out] pIndex is the array index of the minimum value in the input buffer. + */ + void arm_min_f32( + const float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult, + uint32_t * pIndex); + + +/** + * @brief Maximum value of a Q7 vector. + * @param[in] pSrc points to the input buffer + * @param[in] blockSize length of the input vector + * @param[out] pResult maximum value returned here + * @param[out] pIndex index of maximum value returned here + */ + void arm_max_q7( + const q7_t * pSrc, + uint32_t blockSize, + q7_t * pResult, + uint32_t * pIndex); + + +/** + * @brief Maximum value of a Q15 vector. + * @param[in] pSrc points to the input buffer + * @param[in] blockSize length of the input vector + * @param[out] pResult maximum value returned here + * @param[out] pIndex index of maximum value returned here + */ + void arm_max_q15( + const q15_t * pSrc, + uint32_t blockSize, + q15_t * pResult, + uint32_t * pIndex); + + +/** + * @brief Maximum value of a Q31 vector. + * @param[in] pSrc points to the input buffer + * @param[in] blockSize length of the input vector + * @param[out] pResult maximum value returned here + * @param[out] pIndex index of maximum value returned here + */ + void arm_max_q31( + const q31_t * pSrc, + uint32_t blockSize, + q31_t * pResult, + uint32_t * pIndex); + + +/** + * @brief Maximum value of a floating-point vector. + * @param[in] pSrc points to the input buffer + * @param[in] blockSize length of the input vector + * @param[out] pResult maximum value returned here + * @param[out] pIndex index of maximum value returned here + */ + void arm_max_f32( + const float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult, + uint32_t * pIndex); + + /** + @brief Maximum value of a floating-point vector. + @param[in] pSrc points to the input vector + @param[in] blockSize number of samples in input vector + @param[out] pResult maximum value returned here + @return none + */ + void arm_max_no_idx_f32( + const float32_t *pSrc, + uint32_t blockSize, + float32_t *pResult); + + /** + * @brief Q15 complex-by-complex multiplication + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] numSamples number of complex samples in each vector + */ + void arm_cmplx_mult_cmplx_q15( + const q15_t * pSrcA, + const q15_t * pSrcB, + q15_t * pDst, + uint32_t numSamples); + + + /** + * @brief Q31 complex-by-complex multiplication + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] numSamples number of complex samples in each vector + */ + void arm_cmplx_mult_cmplx_q31( + const q31_t * pSrcA, + const q31_t * pSrcB, + q31_t * pDst, + uint32_t numSamples); + + + /** + * @brief Floating-point complex-by-complex multiplication + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[out] pDst points to the output vector + * @param[in] numSamples number of complex samples in each vector + */ + void arm_cmplx_mult_cmplx_f32( + const float32_t * pSrcA, + const float32_t * pSrcB, + float32_t * pDst, + uint32_t numSamples); + + + /** + * @brief Converts the elements of the floating-point vector to Q31 vector. + * @param[in] pSrc points to the floating-point input vector + * @param[out] pDst points to the Q31 output vector + * @param[in] blockSize length of the input vector + */ + void arm_float_to_q31( + const float32_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the floating-point vector to Q15 vector. + * @param[in] pSrc points to the floating-point input vector + * @param[out] pDst points to the Q15 output vector + * @param[in] blockSize length of the input vector + */ + void arm_float_to_q15( + const float32_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the floating-point vector to Q7 vector. + * @param[in] pSrc points to the floating-point input vector + * @param[out] pDst points to the Q7 output vector + * @param[in] blockSize length of the input vector + */ + void arm_float_to_q7( + const float32_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q31 vector to floating-point vector. + * @param[in] pSrc is input pointer + * @param[out] pDst is output pointer + * @param[in] blockSize is the number of samples to process + */ + void arm_q31_to_float( + const q31_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q31 vector to Q15 vector. + * @param[in] pSrc is input pointer + * @param[out] pDst is output pointer + * @param[in] blockSize is the number of samples to process + */ + void arm_q31_to_q15( + const q31_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q31 vector to Q7 vector. + * @param[in] pSrc is input pointer + * @param[out] pDst is output pointer + * @param[in] blockSize is the number of samples to process + */ + void arm_q31_to_q7( + const q31_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q15 vector to floating-point vector. + * @param[in] pSrc is input pointer + * @param[out] pDst is output pointer + * @param[in] blockSize is the number of samples to process + */ + void arm_q15_to_float( + const q15_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q15 vector to Q31 vector. + * @param[in] pSrc is input pointer + * @param[out] pDst is output pointer + * @param[in] blockSize is the number of samples to process + */ + void arm_q15_to_q31( + const q15_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q15 vector to Q7 vector. + * @param[in] pSrc is input pointer + * @param[out] pDst is output pointer + * @param[in] blockSize is the number of samples to process + */ + void arm_q15_to_q7( + const q15_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q7 vector to floating-point vector. + * @param[in] pSrc is input pointer + * @param[out] pDst is output pointer + * @param[in] blockSize is the number of samples to process + */ + void arm_q7_to_float( + const q7_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q7 vector to Q31 vector. + * @param[in] pSrc input pointer + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_q7_to_q31( + const q7_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Converts the elements of the Q7 vector to Q15 vector. + * @param[in] pSrc input pointer + * @param[out] pDst output pointer + * @param[in] blockSize number of samples to process + */ + void arm_q7_to_q15( + const q7_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + +/** + * @brief Struct for specifying SVM Kernel + */ +typedef enum +{ + ARM_ML_KERNEL_LINEAR = 0, + /**< Linear kernel */ + ARM_ML_KERNEL_POLYNOMIAL = 1, + /**< Polynomial kernel */ + ARM_ML_KERNEL_RBF = 2, + /**< Radial Basis Function kernel */ + ARM_ML_KERNEL_SIGMOID = 3 + /**< Sigmoid kernel */ +} arm_ml_kernel_type; + + +/** + * @brief Instance structure for linear SVM prediction function. + */ +typedef struct +{ + uint32_t nbOfSupportVectors; /**< Number of support vectors */ + uint32_t vectorDimension; /**< Dimension of vector space */ + float32_t intercept; /**< Intercept */ + const float32_t *dualCoefficients; /**< Dual coefficients */ + const float32_t *supportVectors; /**< Support vectors */ + const int32_t *classes; /**< The two SVM classes */ +} arm_svm_linear_instance_f32; + + +/** + * @brief Instance structure for polynomial SVM prediction function. + */ +typedef struct +{ + uint32_t nbOfSupportVectors; /**< Number of support vectors */ + uint32_t vectorDimension; /**< Dimension of vector space */ + float32_t intercept; /**< Intercept */ + const float32_t *dualCoefficients; /**< Dual coefficients */ + const float32_t *supportVectors; /**< Support vectors */ + const int32_t *classes; /**< The two SVM classes */ + int32_t degree; /**< Polynomial degree */ + float32_t coef0; /**< Polynomial constant */ + float32_t gamma; /**< Gamma factor */ +} arm_svm_polynomial_instance_f32; + +/** + * @brief Instance structure for rbf SVM prediction function. + */ +typedef struct +{ + uint32_t nbOfSupportVectors; /**< Number of support vectors */ + uint32_t vectorDimension; /**< Dimension of vector space */ + float32_t intercept; /**< Intercept */ + const float32_t *dualCoefficients; /**< Dual coefficients */ + const float32_t *supportVectors; /**< Support vectors */ + const int32_t *classes; /**< The two SVM classes */ + float32_t gamma; /**< Gamma factor */ +} arm_svm_rbf_instance_f32; + +/** + * @brief Instance structure for sigmoid SVM prediction function. + */ +typedef struct +{ + uint32_t nbOfSupportVectors; /**< Number of support vectors */ + uint32_t vectorDimension; /**< Dimension of vector space */ + float32_t intercept; /**< Intercept */ + const float32_t *dualCoefficients; /**< Dual coefficients */ + const float32_t *supportVectors; /**< Support vectors */ + const int32_t *classes; /**< The two SVM classes */ + float32_t coef0; /**< Independant constant */ + float32_t gamma; /**< Gamma factor */ +} arm_svm_sigmoid_instance_f32; + +/** + * @brief SVM linear instance init function + * @param[in] S Parameters for SVM functions + * @param[in] nbOfSupportVectors Number of support vectors + * @param[in] vectorDimension Dimension of vector space + * @param[in] intercept Intercept + * @param[in] dualCoefficients Array of dual coefficients + * @param[in] supportVectors Array of support vectors + * @param[in] classes Array of 2 classes ID + * @return none. + * + */ + + +void arm_svm_linear_init_f32(arm_svm_linear_instance_f32 *S, + uint32_t nbOfSupportVectors, + uint32_t vectorDimension, + float32_t intercept, + const float32_t *dualCoefficients, + const float32_t *supportVectors, + const int32_t *classes); + +/** + * @brief SVM linear prediction + * @param[in] S Pointer to an instance of the linear SVM structure. + * @param[in] in Pointer to input vector + * @param[out] pResult Decision value + * @return none. + * + */ + +void arm_svm_linear_predict_f32(const arm_svm_linear_instance_f32 *S, + const float32_t * in, + int32_t * pResult); + + +/** + * @brief SVM polynomial instance init function + * @param[in] S points to an instance of the polynomial SVM structure. + * @param[in] nbOfSupportVectors Number of support vectors + * @param[in] vectorDimension Dimension of vector space + * @param[in] intercept Intercept + * @param[in] dualCoefficients Array of dual coefficients + * @param[in] supportVectors Array of support vectors + * @param[in] classes Array of 2 classes ID + * @param[in] degree Polynomial degree + * @param[in] coef0 coeff0 (scikit-learn terminology) + * @param[in] gamma gamma (scikit-learn terminology) + * @return none. + * + */ + + +void arm_svm_polynomial_init_f32(arm_svm_polynomial_instance_f32 *S, + uint32_t nbOfSupportVectors, + uint32_t vectorDimension, + float32_t intercept, + const float32_t *dualCoefficients, + const float32_t *supportVectors, + const int32_t *classes, + int32_t degree, + float32_t coef0, + float32_t gamma + ); + +/** + * @brief SVM polynomial prediction + * @param[in] S Pointer to an instance of the polynomial SVM structure. + * @param[in] in Pointer to input vector + * @param[out] pResult Decision value + * @return none. + * + */ +void arm_svm_polynomial_predict_f32(const arm_svm_polynomial_instance_f32 *S, + const float32_t * in, + int32_t * pResult); + + +/** + * @brief SVM radial basis function instance init function + * @param[in] S points to an instance of the polynomial SVM structure. + * @param[in] nbOfSupportVectors Number of support vectors + * @param[in] vectorDimension Dimension of vector space + * @param[in] intercept Intercept + * @param[in] dualCoefficients Array of dual coefficients + * @param[in] supportVectors Array of support vectors + * @param[in] classes Array of 2 classes ID + * @param[in] gamma gamma (scikit-learn terminology) + * @return none. + * + */ + +void arm_svm_rbf_init_f32(arm_svm_rbf_instance_f32 *S, + uint32_t nbOfSupportVectors, + uint32_t vectorDimension, + float32_t intercept, + const float32_t *dualCoefficients, + const float32_t *supportVectors, + const int32_t *classes, + float32_t gamma + ); + +/** + * @brief SVM rbf prediction + * @param[in] S Pointer to an instance of the rbf SVM structure. + * @param[in] in Pointer to input vector + * @param[out] pResult decision value + * @return none. + * + */ +void arm_svm_rbf_predict_f32(const arm_svm_rbf_instance_f32 *S, + const float32_t * in, + int32_t * pResult); + +/** + * @brief SVM sigmoid instance init function + * @param[in] S points to an instance of the rbf SVM structure. + * @param[in] nbOfSupportVectors Number of support vectors + * @param[in] vectorDimension Dimension of vector space + * @param[in] intercept Intercept + * @param[in] dualCoefficients Array of dual coefficients + * @param[in] supportVectors Array of support vectors + * @param[in] classes Array of 2 classes ID + * @param[in] coef0 coeff0 (scikit-learn terminology) + * @param[in] gamma gamma (scikit-learn terminology) + * @return none. + * + */ + +void arm_svm_sigmoid_init_f32(arm_svm_sigmoid_instance_f32 *S, + uint32_t nbOfSupportVectors, + uint32_t vectorDimension, + float32_t intercept, + const float32_t *dualCoefficients, + const float32_t *supportVectors, + const int32_t *classes, + float32_t coef0, + float32_t gamma + ); + +/** + * @brief SVM sigmoid prediction + * @param[in] S Pointer to an instance of the rbf SVM structure. + * @param[in] in Pointer to input vector + * @param[out] pResult Decision value + * @return none. + * + */ +void arm_svm_sigmoid_predict_f32(const arm_svm_sigmoid_instance_f32 *S, + const float32_t * in, + int32_t * pResult); + + + +/** + * @brief Instance structure for Naive Gaussian Bayesian estimator. + */ +typedef struct +{ + uint32_t vectorDimension; /**< Dimension of vector space */ + uint32_t numberOfClasses; /**< Number of different classes */ + const float32_t *theta; /**< Mean values for the Gaussians */ + const float32_t *sigma; /**< Variances for the Gaussians */ + const float32_t *classPriors; /**< Class prior probabilities */ + float32_t epsilon; /**< Additive value to variances */ +} arm_gaussian_naive_bayes_instance_f32; + +/** + * @brief Naive Gaussian Bayesian Estimator + * + * @param[in] S points to a naive bayes instance structure + * @param[in] in points to the elements of the input vector. + * @param[in] pBuffer points to a buffer of length numberOfClasses + * @return The predicted class + * + */ + + +uint32_t arm_gaussian_naive_bayes_predict_f32(const arm_gaussian_naive_bayes_instance_f32 *S, + const float32_t * in, + float32_t *pBuffer); + +/** + * @brief Computation of the LogSumExp + * + * In probabilistic computations, the dynamic of the probability values can be very + * wide because they come from gaussian functions. + * To avoid underflow and overflow issues, the values are represented by their log. + * In this representation, multiplying the original exp values is easy : their logs are added. + * But adding the original exp values is requiring some special handling and it is the + * goal of the LogSumExp function. + * + * If the values are x1...xn, the function is computing: + * + * ln(exp(x1) + ... + exp(xn)) and the computation is done in such a way that + * rounding issues are minimised. + * + * The max xm of the values is extracted and the function is computing: + * xm + ln(exp(x1 - xm) + ... + exp(xn - xm)) + * + * @param[in] *in Pointer to an array of input values. + * @param[in] blockSize Number of samples in the input array. + * @return LogSumExp + * + */ + + +float32_t arm_logsumexp_f32(const float32_t *in, uint32_t blockSize); + +/** + * @brief Dot product with log arithmetic + * + * Vectors are containing the log of the samples + * + * @param[in] pSrcA points to the first input vector + * @param[in] pSrcB points to the second input vector + * @param[in] blockSize number of samples in each vector + * @param[in] pTmpBuffer temporary buffer of length blockSize + * @return The log of the dot product . + * + */ + + +float32_t arm_logsumexp_dot_prod_f32(const float32_t * pSrcA, + const float32_t * pSrcB, + uint32_t blockSize, + float32_t *pTmpBuffer); + +/** + * @brief Entropy + * + * @param[in] pSrcA Array of input values. + * @param[in] blockSize Number of samples in the input array. + * @return Entropy -Sum(p ln p) + * + */ + + +float32_t arm_entropy_f32(const float32_t * pSrcA,uint32_t blockSize); + + +/** + * @brief Entropy + * + * @param[in] pSrcA Array of input values. + * @param[in] blockSize Number of samples in the input array. + * @return Entropy -Sum(p ln p) + * + */ + + +float64_t arm_entropy_f64(const float64_t * pSrcA, uint32_t blockSize); + + +/** + * @brief Kullback-Leibler + * + * @param[in] pSrcA Pointer to an array of input values for probability distribution A. + * @param[in] pSrcB Pointer to an array of input values for probability distribution B. + * @param[in] blockSize Number of samples in the input array. + * @return Kullback-Leibler Divergence D(A || B) + * + */ +float32_t arm_kullback_leibler_f32(const float32_t * pSrcA + ,const float32_t * pSrcB + ,uint32_t blockSize); + + +/** + * @brief Kullback-Leibler + * + * @param[in] pSrcA Pointer to an array of input values for probability distribution A. + * @param[in] pSrcB Pointer to an array of input values for probability distribution B. + * @param[in] blockSize Number of samples in the input array. + * @return Kullback-Leibler Divergence D(A || B) + * + */ +float64_t arm_kullback_leibler_f64(const float64_t * pSrcA, + const float64_t * pSrcB, + uint32_t blockSize); + + +/** + * @brief Weighted sum + * + * + * @param[in] *in Array of input values. + * @param[in] *weigths Weights + * @param[in] blockSize Number of samples in the input array. + * @return Weighted sum + * + */ +float32_t arm_weighted_sum_f32(const float32_t *in + , const float32_t *weigths + , uint32_t blockSize); + + +/** + * @brief Barycenter + * + * + * @param[in] in List of vectors + * @param[in] weights Weights of the vectors + * @param[out] out Barycenter + * @param[in] nbVectors Number of vectors + * @param[in] vecDim Dimension of space (vector dimension) + * @return None + * + */ +void arm_barycenter_f32(const float32_t *in + , const float32_t *weights + , float32_t *out + , uint32_t nbVectors + , uint32_t vecDim); + +/** + * @brief Euclidean distance between two vectors + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ + +float32_t arm_euclidean_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize); + +/** + * @brief Bray-Curtis distance between two vectors + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ +float32_t arm_braycurtis_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize); + +/** + * @brief Canberra distance between two vectors + * + * This function may divide by zero when samples pA[i] and pB[i] are both zero. + * The result of the computation will be correct. So the division per zero may be + * ignored. + * + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ +float32_t arm_canberra_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize); + + +/** + * @brief Chebyshev distance between two vectors + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ +float32_t arm_chebyshev_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize); + + +/** + * @brief Cityblock (Manhattan) distance between two vectors + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ +float32_t arm_cityblock_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize); + +/** + * @brief Correlation distance between two vectors + * + * The input vectors are modified in place ! + * + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ +float32_t arm_correlation_distance_f32(float32_t *pA,float32_t *pB, uint32_t blockSize); + +/** + * @brief Cosine distance between two vectors + * + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ + +float32_t arm_cosine_distance_f32(const float32_t *pA,const float32_t *pB, uint32_t blockSize); + +/** + * @brief Jensen-Shannon distance between two vectors + * + * This function is assuming that elements of second vector are > 0 + * and 0 only when the corresponding element of first vector is 0. + * Otherwise the result of the computation does not make sense + * and for speed reasons, the cases returning NaN or Infinity are not + * managed. + * + * When the function is computing x log (x / y) with x 0 and y 0, + * it will compute the right value (0) but a division per zero will occur + * and shoudl be ignored in client code. + * + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] blockSize vector length + * @return distance + * + */ + +float32_t arm_jensenshannon_distance_f32(const float32_t *pA,const float32_t *pB,uint32_t blockSize); + +/** + * @brief Minkowski distance between two vectors + * + * @param[in] pA First vector + * @param[in] pB Second vector + * @param[in] n Norm order (>= 2) + * @param[in] blockSize vector length + * @return distance + * + */ + + + +float32_t arm_minkowski_distance_f32(const float32_t *pA,const float32_t *pB, int32_t order, uint32_t blockSize); + +/** + * @brief Dice distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] order Distance order + * @param[in] blockSize Number of samples + * @return distance + * + */ + + +float32_t arm_dice_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Hamming distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_hamming_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Jaccard distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_jaccard_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Kulsinski distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_kulsinski_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Roger Stanimoto distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_rogerstanimoto_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Russell-Rao distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_russellrao_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Sokal-Michener distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_sokalmichener_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Sokal-Sneath distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_sokalsneath_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + +/** + * @brief Yule distance between two vectors + * + * @param[in] pA First vector of packed booleans + * @param[in] pB Second vector of packed booleans + * @param[in] numberOfBools Number of booleans + * @return distance + * + */ + +float32_t arm_yule_distance(const uint32_t *pA, const uint32_t *pB, uint32_t numberOfBools); + + + /** + * @ingroup groupInterpolation + */ + + /** + * @defgroup BilinearInterpolate Bilinear Interpolation + * + * Bilinear interpolation is an extension of linear interpolation applied to a two dimensional grid. + * The underlying function f(x, y) is sampled on a regular grid and the interpolation process + * determines values between the grid points. + * Bilinear interpolation is equivalent to two step linear interpolation, first in the x-dimension and then in the y-dimension. + * Bilinear interpolation is often used in image processing to rescale images. + * The CMSIS DSP library provides bilinear interpolation functions for Q7, Q15, Q31, and floating-point data types. + * + * Algorithm + * \par + * The instance structure used by the bilinear interpolation functions describes a two dimensional data table. + * For floating-point, the instance structure is defined as: + *
+   *   typedef struct
+   *   {
+   *     uint16_t numRows;
+   *     uint16_t numCols;
+   *     float32_t *pData;
+   * } arm_bilinear_interp_instance_f32;
+   * 
+ * + * \par + * where numRows specifies the number of rows in the table; + * numCols specifies the number of columns in the table; + * and pData points to an array of size numRows*numCols values. + * The data table pTable is organized in row order and the supplied data values fall on integer indexes. + * That is, table element (x,y) is located at pTable[x + y*numCols] where x and y are integers. + * + * \par + * Let (x, y) specify the desired interpolation point. Then define: + *
+   *     XF = floor(x)
+   *     YF = floor(y)
+   * 
+ * \par + * The interpolated output point is computed as: + *
+   *  f(x, y) = f(XF, YF) * (1-(x-XF)) * (1-(y-YF))
+   *           + f(XF+1, YF) * (x-XF)*(1-(y-YF))
+   *           + f(XF, YF+1) * (1-(x-XF))*(y-YF)
+   *           + f(XF+1, YF+1) * (x-XF)*(y-YF)
+   * 
+ * Note that the coordinates (x, y) contain integer and fractional components. + * The integer components specify which portion of the table to use while the + * fractional components control the interpolation processor. + * + * \par + * if (x,y) are outside of the table boundary, Bilinear interpolation returns zero output. + */ + + + /** + * @addtogroup BilinearInterpolate + * @{ + */ + + /** + * @brief Floating-point bilinear interpolation. + * @param[in,out] S points to an instance of the interpolation structure. + * @param[in] X interpolation coordinate. + * @param[in] Y interpolation coordinate. + * @return out interpolated value. + */ + __STATIC_FORCEINLINE float32_t arm_bilinear_interp_f32( + const arm_bilinear_interp_instance_f32 * S, + float32_t X, + float32_t Y) + { + float32_t out; + float32_t f00, f01, f10, f11; + float32_t *pData = S->pData; + int32_t xIndex, yIndex, index; + float32_t xdiff, ydiff; + float32_t b1, b2, b3, b4; + + xIndex = (int32_t) X; + yIndex = (int32_t) Y; + + /* Care taken for table outside boundary */ + /* Returns zero output when values are outside table boundary */ + if (xIndex < 0 || xIndex > (S->numCols - 2) || yIndex < 0 || yIndex > (S->numRows - 2)) + { + return (0); + } + + /* Calculation of index for two nearest points in X-direction */ + index = (xIndex ) + (yIndex ) * S->numCols; + + + /* Read two nearest points in X-direction */ + f00 = pData[index]; + f01 = pData[index + 1]; + + /* Calculation of index for two nearest points in Y-direction */ + index = (xIndex ) + (yIndex+1) * S->numCols; + + + /* Read two nearest points in Y-direction */ + f10 = pData[index]; + f11 = pData[index + 1]; + + /* Calculation of intermediate values */ + b1 = f00; + b2 = f01 - f00; + b3 = f10 - f00; + b4 = f00 - f01 - f10 + f11; + + /* Calculation of fractional part in X */ + xdiff = X - xIndex; + + /* Calculation of fractional part in Y */ + ydiff = Y - yIndex; + + /* Calculation of bi-linear interpolated output */ + out = b1 + b2 * xdiff + b3 * ydiff + b4 * xdiff * ydiff; + + /* return to application */ + return (out); + } + + + /** + * @brief Q31 bilinear interpolation. + * @param[in,out] S points to an instance of the interpolation structure. + * @param[in] X interpolation coordinate in 12.20 format. + * @param[in] Y interpolation coordinate in 12.20 format. + * @return out interpolated value. + */ + __STATIC_FORCEINLINE q31_t arm_bilinear_interp_q31( + arm_bilinear_interp_instance_q31 * S, + q31_t X, + q31_t Y) + { + q31_t out; /* Temporary output */ + q31_t acc = 0; /* output */ + q31_t xfract, yfract; /* X, Y fractional parts */ + q31_t x1, x2, y1, y2; /* Nearest output values */ + int32_t rI, cI; /* Row and column indices */ + q31_t *pYData = S->pData; /* pointer to output table values */ + uint32_t nCols = S->numCols; /* num of rows */ + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + rI = ((X & (q31_t)0xFFF00000) >> 20); + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + cI = ((Y & (q31_t)0xFFF00000) >> 20); + + /* Care taken for table outside boundary */ + /* Returns zero output when values are outside table boundary */ + if (rI < 0 || rI > (S->numCols - 2) || cI < 0 || cI > (S->numRows - 2)) + { + return (0); + } + + /* 20 bits for the fractional part */ + /* shift left xfract by 11 to keep 1.31 format */ + xfract = (X & 0x000FFFFF) << 11U; + + /* Read two nearest output values from the index */ + x1 = pYData[(rI) + (int32_t)nCols * (cI) ]; + x2 = pYData[(rI) + (int32_t)nCols * (cI) + 1]; + + /* 20 bits for the fractional part */ + /* shift left yfract by 11 to keep 1.31 format */ + yfract = (Y & 0x000FFFFF) << 11U; + + /* Read two nearest output values from the index */ + y1 = pYData[(rI) + (int32_t)nCols * (cI + 1) ]; + y2 = pYData[(rI) + (int32_t)nCols * (cI + 1) + 1]; + + /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 3.29(q29) format */ + out = ((q31_t) (((q63_t) x1 * (0x7FFFFFFF - xfract)) >> 32)); + acc = ((q31_t) (((q63_t) out * (0x7FFFFFFF - yfract)) >> 32)); + + /* x2 * (xfract) * (1-yfract) in 3.29(q29) and adding to acc */ + out = ((q31_t) ((q63_t) x2 * (0x7FFFFFFF - yfract) >> 32)); + acc += ((q31_t) ((q63_t) out * (xfract) >> 32)); + + /* y1 * (1 - xfract) * (yfract) in 3.29(q29) and adding to acc */ + out = ((q31_t) ((q63_t) y1 * (0x7FFFFFFF - xfract) >> 32)); + acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); + + /* y2 * (xfract) * (yfract) in 3.29(q29) and adding to acc */ + out = ((q31_t) ((q63_t) y2 * (xfract) >> 32)); + acc += ((q31_t) ((q63_t) out * (yfract) >> 32)); + + /* Convert acc to 1.31(q31) format */ + return ((q31_t)(acc << 2)); + } + + + /** + * @brief Q15 bilinear interpolation. + * @param[in,out] S points to an instance of the interpolation structure. + * @param[in] X interpolation coordinate in 12.20 format. + * @param[in] Y interpolation coordinate in 12.20 format. + * @return out interpolated value. + */ + __STATIC_FORCEINLINE q15_t arm_bilinear_interp_q15( + arm_bilinear_interp_instance_q15 * S, + q31_t X, + q31_t Y) + { + q63_t acc = 0; /* output */ + q31_t out; /* Temporary output */ + q15_t x1, x2, y1, y2; /* Nearest output values */ + q31_t xfract, yfract; /* X, Y fractional parts */ + int32_t rI, cI; /* Row and column indices */ + q15_t *pYData = S->pData; /* pointer to output table values */ + uint32_t nCols = S->numCols; /* num of rows */ + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + rI = ((X & (q31_t)0xFFF00000) >> 20); + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + cI = ((Y & (q31_t)0xFFF00000) >> 20); + + /* Care taken for table outside boundary */ + /* Returns zero output when values are outside table boundary */ + if (rI < 0 || rI > (S->numCols - 2) || cI < 0 || cI > (S->numRows - 2)) + { + return (0); + } + + /* 20 bits for the fractional part */ + /* xfract should be in 12.20 format */ + xfract = (X & 0x000FFFFF); + + /* Read two nearest output values from the index */ + x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ]; + x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1]; + + /* 20 bits for the fractional part */ + /* yfract should be in 12.20 format */ + yfract = (Y & 0x000FFFFF); + + /* Read two nearest output values from the index */ + y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ]; + y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1]; + + /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 13.51 format */ + + /* x1 is in 1.15(q15), xfract in 12.20 format and out is in 13.35 format */ + /* convert 13.35 to 13.31 by right shifting and out is in 1.31 */ + out = (q31_t) (((q63_t) x1 * (0x0FFFFF - xfract)) >> 4U); + acc = ((q63_t) out * (0x0FFFFF - yfract)); + + /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */ + out = (q31_t) (((q63_t) x2 * (0x0FFFFF - yfract)) >> 4U); + acc += ((q63_t) out * (xfract)); + + /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */ + out = (q31_t) (((q63_t) y1 * (0x0FFFFF - xfract)) >> 4U); + acc += ((q63_t) out * (yfract)); + + /* y2 * (xfract) * (yfract) in 1.51 and adding to acc */ + out = (q31_t) (((q63_t) y2 * (xfract)) >> 4U); + acc += ((q63_t) out * (yfract)); + + /* acc is in 13.51 format and down shift acc by 36 times */ + /* Convert out to 1.15 format */ + return ((q15_t)(acc >> 36)); + } + + + /** + * @brief Q7 bilinear interpolation. + * @param[in,out] S points to an instance of the interpolation structure. + * @param[in] X interpolation coordinate in 12.20 format. + * @param[in] Y interpolation coordinate in 12.20 format. + * @return out interpolated value. + */ + __STATIC_FORCEINLINE q7_t arm_bilinear_interp_q7( + arm_bilinear_interp_instance_q7 * S, + q31_t X, + q31_t Y) + { + q63_t acc = 0; /* output */ + q31_t out; /* Temporary output */ + q31_t xfract, yfract; /* X, Y fractional parts */ + q7_t x1, x2, y1, y2; /* Nearest output values */ + int32_t rI, cI; /* Row and column indices */ + q7_t *pYData = S->pData; /* pointer to output table values */ + uint32_t nCols = S->numCols; /* num of rows */ + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + rI = ((X & (q31_t)0xFFF00000) >> 20); + + /* Input is in 12.20 format */ + /* 12 bits for the table index */ + /* Index value calculation */ + cI = ((Y & (q31_t)0xFFF00000) >> 20); + + /* Care taken for table outside boundary */ + /* Returns zero output when values are outside table boundary */ + if (rI < 0 || rI > (S->numCols - 2) || cI < 0 || cI > (S->numRows - 2)) + { + return (0); + } + + /* 20 bits for the fractional part */ + /* xfract should be in 12.20 format */ + xfract = (X & (q31_t)0x000FFFFF); + + /* Read two nearest output values from the index */ + x1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) ]; + x2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI) + 1]; + + /* 20 bits for the fractional part */ + /* yfract should be in 12.20 format */ + yfract = (Y & (q31_t)0x000FFFFF); + + /* Read two nearest output values from the index */ + y1 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) ]; + y2 = pYData[((uint32_t)rI) + nCols * ((uint32_t)cI + 1) + 1]; + + /* Calculation of x1 * (1-xfract ) * (1-yfract) and acc is in 16.47 format */ + out = ((x1 * (0xFFFFF - xfract))); + acc = (((q63_t) out * (0xFFFFF - yfract))); + + /* x2 * (xfract) * (1-yfract) in 2.22 and adding to acc */ + out = ((x2 * (0xFFFFF - yfract))); + acc += (((q63_t) out * (xfract))); + + /* y1 * (1 - xfract) * (yfract) in 2.22 and adding to acc */ + out = ((y1 * (0xFFFFF - xfract))); + acc += (((q63_t) out * (yfract))); + + /* y2 * (xfract) * (yfract) in 2.22 and adding to acc */ + out = ((y2 * (yfract))); + acc += (((q63_t) out * (xfract))); + + /* acc in 16.47 format and down shift by 40 to convert to 1.7 format */ + return ((q7_t)(acc >> 40)); + } + + /** + * @} end of BilinearInterpolate group + */ + + +/* SMMLAR */ +#define multAcc_32x32_keep32_R(a, x, y) \ + a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32) + +/* SMMLSR */ +#define multSub_32x32_keep32_R(a, x, y) \ + a = (q31_t) (((((q63_t) a) << 32) - ((q63_t) x * y) + 0x80000000LL ) >> 32) + +/* SMMULR */ +#define mult_32x32_keep32_R(a, x, y) \ + a = (q31_t) (((q63_t) x * y + 0x80000000LL ) >> 32) + +/* SMMLA */ +#define multAcc_32x32_keep32(a, x, y) \ + a += (q31_t) (((q63_t) x * y) >> 32) + +/* SMMLS */ +#define multSub_32x32_keep32(a, x, y) \ + a -= (q31_t) (((q63_t) x * y) >> 32) + +/* SMMUL */ +#define mult_32x32_keep32(a, x, y) \ + a = (q31_t) (((q63_t) x * y ) >> 32) + + +#if defined ( __CC_ARM ) + /* Enter low optimization region - place directly above function definition */ + #if defined( __ARM_ARCH_7EM__ ) + #define LOW_OPTIMIZATION_ENTER \ + _Pragma ("push") \ + _Pragma ("O1") + #else + #define LOW_OPTIMIZATION_ENTER + #endif + + /* Exit low optimization region - place directly after end of function definition */ + #if defined ( __ARM_ARCH_7EM__ ) + #define LOW_OPTIMIZATION_EXIT \ + _Pragma ("pop") + #else + #define LOW_OPTIMIZATION_EXIT + #endif + + /* Enter low optimization region - place directly above function definition */ + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + + /* Exit low optimization region - place directly after end of function definition */ + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT + +#elif defined (__ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) + #define LOW_OPTIMIZATION_ENTER + #define LOW_OPTIMIZATION_EXIT + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT + +#elif defined ( __GNUC__ ) + #define LOW_OPTIMIZATION_ENTER \ + __attribute__(( optimize("-O1") )) + #define LOW_OPTIMIZATION_EXIT + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT + +#elif defined ( __ICCARM__ ) + /* Enter low optimization region - place directly above function definition */ + #if defined ( __ARM_ARCH_7EM__ ) + #define LOW_OPTIMIZATION_ENTER \ + _Pragma ("optimize=low") + #else + #define LOW_OPTIMIZATION_ENTER + #endif + + /* Exit low optimization region - place directly after end of function definition */ + #define LOW_OPTIMIZATION_EXIT + + /* Enter low optimization region - place directly above function definition */ + #if defined ( __ARM_ARCH_7EM__ ) + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER \ + _Pragma ("optimize=low") + #else + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + #endif + + /* Exit low optimization region - place directly after end of function definition */ + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT + +#elif defined ( __TI_ARM__ ) + #define LOW_OPTIMIZATION_ENTER + #define LOW_OPTIMIZATION_EXIT + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT + +#elif defined ( __CSMC__ ) + #define LOW_OPTIMIZATION_ENTER + #define LOW_OPTIMIZATION_EXIT + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT + +#elif defined ( __TASKING__ ) + #define LOW_OPTIMIZATION_ENTER + #define LOW_OPTIMIZATION_EXIT + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT + +#elif defined ( _MSC_VER ) || defined(__GNUC_PYTHON__) + #define LOW_OPTIMIZATION_ENTER + #define LOW_OPTIMIZATION_EXIT + #define IAR_ONLY_LOW_OPTIMIZATION_ENTER + #define IAR_ONLY_LOW_OPTIMIZATION_EXIT +#endif + + + +/* Compiler specific diagnostic adjustment */ +#if defined ( __CC_ARM ) + +#elif defined ( __ARMCC_VERSION ) && ( __ARMCC_VERSION >= 6010050 ) + +#elif defined ( __GNUC__ ) +#pragma GCC diagnostic pop + +#elif defined ( __ICCARM__ ) + +#elif defined ( __TI_ARM__ ) + +#elif defined ( __CSMC__ ) + +#elif defined ( __TASKING__ ) + +#elif defined ( _MSC_VER ) + +#else + #error Unknown compiler +#endif + +#ifdef __cplusplus +} +#endif + + +#endif /* _ARM_MATH_H */ + +/** + * + * End of file. + */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/arm_mve_tables.h b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_mve_tables.h new file mode 100644 index 0000000000..4d2c135ac6 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_mve_tables.h @@ -0,0 +1,235 @@ +/* ---------------------------------------------------------------------- + * Project: CMSIS DSP Library + * Title: arm_mve_tables.h + * Description: common tables like fft twiddle factors, Bitreverse, reciprocal etc + * used for MVE implementation only + * + * $Date: 08. January 2020 + * $Revision: V1.7.0 + * + * Target Processor: Cortex-M cores + * -------------------------------------------------------------------- */ +/* + * Copyright (C) 2010-2020 ARM Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + #ifndef _ARM_MVE_TABLES_H + #define _ARM_MVE_TABLES_H + + #include "arm_math.h" + + + + + + +#if defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_16) || defined(ARM_TABLE_TWIDDLECOEF_F32_32) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_16_f32[2]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_16_f32[2]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_16_f32[2]; +extern float32_t rearranged_twiddle_stride1_16_f32[8]; +extern float32_t rearranged_twiddle_stride2_16_f32[8]; +extern float32_t rearranged_twiddle_stride3_16_f32[8]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_64) || defined(ARM_TABLE_TWIDDLECOEF_F32_128) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_64_f32[3]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_64_f32[3]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_64_f32[3]; +extern float32_t rearranged_twiddle_stride1_64_f32[40]; +extern float32_t rearranged_twiddle_stride2_64_f32[40]; +extern float32_t rearranged_twiddle_stride3_64_f32[40]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_256) || defined(ARM_TABLE_TWIDDLECOEF_F32_512) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_256_f32[4]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_256_f32[4]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_256_f32[4]; +extern float32_t rearranged_twiddle_stride1_256_f32[168]; +extern float32_t rearranged_twiddle_stride2_256_f32[168]; +extern float32_t rearranged_twiddle_stride3_256_f32[168]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_1024) || defined(ARM_TABLE_TWIDDLECOEF_F32_2048) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_1024_f32[5]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_1024_f32[5]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_1024_f32[5]; +extern float32_t rearranged_twiddle_stride1_1024_f32[680]; +extern float32_t rearranged_twiddle_stride2_1024_f32[680]; +extern float32_t rearranged_twiddle_stride3_1024_f32[680]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_F32_4096) || defined(ARM_TABLE_TWIDDLECOEF_F32_8192) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_4096_f32[6]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_4096_f32[6]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_4096_f32[6]; +extern float32_t rearranged_twiddle_stride1_4096_f32[2728]; +extern float32_t rearranged_twiddle_stride2_4096_f32[2728]; +extern float32_t rearranged_twiddle_stride3_4096_f32[2728]; +#endif + + +#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) */ + +#endif /* defined(ARM_MATH_MVEF) && !defined(ARM_MATH_AUTOVECTORIZE) */ + + + +#if defined(ARM_MATH_MVEI) + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_16) || defined(ARM_TABLE_TWIDDLECOEF_Q31_32) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_16_q31[2]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_16_q31[2]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_16_q31[2]; +extern q31_t rearranged_twiddle_stride1_16_q31[8]; +extern q31_t rearranged_twiddle_stride2_16_q31[8]; +extern q31_t rearranged_twiddle_stride3_16_q31[8]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_64) || defined(ARM_TABLE_TWIDDLECOEF_Q31_128) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_64_q31[3]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_64_q31[3]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_64_q31[3]; +extern q31_t rearranged_twiddle_stride1_64_q31[40]; +extern q31_t rearranged_twiddle_stride2_64_q31[40]; +extern q31_t rearranged_twiddle_stride3_64_q31[40]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_256) || defined(ARM_TABLE_TWIDDLECOEF_Q31_512) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_256_q31[4]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_256_q31[4]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_256_q31[4]; +extern q31_t rearranged_twiddle_stride1_256_q31[168]; +extern q31_t rearranged_twiddle_stride2_256_q31[168]; +extern q31_t rearranged_twiddle_stride3_256_q31[168]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_1024) || defined(ARM_TABLE_TWIDDLECOEF_Q31_2048) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_1024_q31[5]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_1024_q31[5]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_1024_q31[5]; +extern q31_t rearranged_twiddle_stride1_1024_q31[680]; +extern q31_t rearranged_twiddle_stride2_1024_q31[680]; +extern q31_t rearranged_twiddle_stride3_1024_q31[680]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q31_4096) || defined(ARM_TABLE_TWIDDLECOEF_Q31_8192) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_4096_q31[6]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_4096_q31[6]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_4096_q31[6]; +extern q31_t rearranged_twiddle_stride1_4096_q31[2728]; +extern q31_t rearranged_twiddle_stride2_4096_q31[2728]; +extern q31_t rearranged_twiddle_stride3_4096_q31[2728]; +#endif + + +#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) */ + +#endif /* defined(ARM_MATH_MVEI) */ + + + +#if defined(ARM_MATH_MVEI) + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_16) || defined(ARM_TABLE_TWIDDLECOEF_Q15_32) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_16_q15[2]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_16_q15[2]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_16_q15[2]; +extern q15_t rearranged_twiddle_stride1_16_q15[8]; +extern q15_t rearranged_twiddle_stride2_16_q15[8]; +extern q15_t rearranged_twiddle_stride3_16_q15[8]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_64) || defined(ARM_TABLE_TWIDDLECOEF_Q15_128) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_64_q15[3]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_64_q15[3]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_64_q15[3]; +extern q15_t rearranged_twiddle_stride1_64_q15[40]; +extern q15_t rearranged_twiddle_stride2_64_q15[40]; +extern q15_t rearranged_twiddle_stride3_64_q15[40]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_256) || defined(ARM_TABLE_TWIDDLECOEF_Q15_512) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_256_q15[4]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_256_q15[4]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_256_q15[4]; +extern q15_t rearranged_twiddle_stride1_256_q15[168]; +extern q15_t rearranged_twiddle_stride2_256_q15[168]; +extern q15_t rearranged_twiddle_stride3_256_q15[168]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_1024) || defined(ARM_TABLE_TWIDDLECOEF_Q15_2048) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_1024_q15[5]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_1024_q15[5]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_1024_q15[5]; +extern q15_t rearranged_twiddle_stride1_1024_q15[680]; +extern q15_t rearranged_twiddle_stride2_1024_q15[680]; +extern q15_t rearranged_twiddle_stride3_1024_q15[680]; +#endif + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_ALL_FFT_TABLES) || defined(ARM_TABLE_TWIDDLECOEF_Q15_4096) || defined(ARM_TABLE_TWIDDLECOEF_Q15_8192) + +extern uint32_t rearranged_twiddle_tab_stride1_arr_4096_q15[6]; +extern uint32_t rearranged_twiddle_tab_stride2_arr_4096_q15[6]; +extern uint32_t rearranged_twiddle_tab_stride3_arr_4096_q15[6]; +extern q15_t rearranged_twiddle_stride1_4096_q15[2728]; +extern q15_t rearranged_twiddle_stride2_4096_q15[2728]; +extern q15_t rearranged_twiddle_stride3_4096_q15[2728]; +#endif + + +#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) */ + +#endif /* defined(ARM_MATH_MVEI) */ + + + +#if defined(ARM_MATH_MVEI) + +#if !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) + + +#endif /* !defined(ARM_DSP_CONFIG_TABLES) || defined(ARM_FFT_ALLOW_TABLES) */ + +#endif /* defined(ARM_MATH_MVEI) */ + + + +#endif /*_ARM_MVE_TABLES_H*/ + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/arm_vec_math.h b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_vec_math.h new file mode 100644 index 0000000000..0ce9464bcb --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/arm_vec_math.h @@ -0,0 +1,372 @@ +/****************************************************************************** + * @file arm_vec_math.h + * @brief Public header file for CMSIS DSP Library + * @version V1.7.0 + * @date 15. October 2019 + ******************************************************************************/ +/* + * Copyright (c) 2010-2019 Arm Limited or its affiliates. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _ARM_VEC_MATH_H +#define _ARM_VEC_MATH_H + +#include "arm_math.h" +#include "arm_common_tables.h" +#include "arm_helium_utils.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE) + +#define INV_NEWTON_INIT_F32 0x7EF127EA + +static const float32_t __logf_rng_f32=0.693147180f; + + +/* fast inverse approximation (3x newton) */ +__STATIC_INLINE f32x4_t vrecip_medprec_f32( + f32x4_t x) +{ + q31x4_t m; + f32x4_t b; + any32x4_t xinv; + f32x4_t ax = vabsq(x); + + xinv.f = ax; + m = 0x3F800000 - (xinv.i & 0x7F800000); + xinv.i = xinv.i + m; + xinv.f = 1.41176471f - 0.47058824f * xinv.f; + xinv.i = xinv.i + m; + + b = 2.0f - xinv.f * ax; + xinv.f = xinv.f * b; + + b = 2.0f - xinv.f * ax; + xinv.f = xinv.f * b; + + b = 2.0f - xinv.f * ax; + xinv.f = xinv.f * b; + + xinv.f = vdupq_m(xinv.f, INFINITY, vcmpeqq(x, 0.0f)); + /* + * restore sign + */ + xinv.f = vnegq_m(xinv.f, xinv.f, vcmpltq(x, 0.0f)); + + return xinv.f; +} + +/* fast inverse approximation (4x newton) */ +__STATIC_INLINE f32x4_t vrecip_hiprec_f32( + f32x4_t x) +{ + q31x4_t m; + f32x4_t b; + any32x4_t xinv; + f32x4_t ax = vabsq(x); + + xinv.f = ax; + + m = 0x3F800000 - (xinv.i & 0x7F800000); + xinv.i = xinv.i + m; + xinv.f = 1.41176471f - 0.47058824f * xinv.f; + xinv.i = xinv.i + m; + + b = 2.0f - xinv.f * ax; + xinv.f = xinv.f * b; + + b = 2.0f - xinv.f * ax; + xinv.f = xinv.f * b; + + b = 2.0f - xinv.f * ax; + xinv.f = xinv.f * b; + + b = 2.0f - xinv.f * ax; + xinv.f = xinv.f * b; + + xinv.f = vdupq_m(xinv.f, INFINITY, vcmpeqq(x, 0.0f)); + /* + * restore sign + */ + xinv.f = vnegq_m(xinv.f, xinv.f, vcmpltq(x, 0.0f)); + + return xinv.f; +} + +__STATIC_INLINE f32x4_t vdiv_f32( + f32x4_t num, f32x4_t den) +{ + return vmulq(num, vrecip_hiprec_f32(den)); +} + +/** + @brief Single-precision taylor dev. + @param[in] x f32 quad vector input + @param[in] coeffs f32 quad vector coeffs + @return destination f32 quad vector + */ + +__STATIC_INLINE f32x4_t vtaylor_polyq_f32( + f32x4_t x, + const float32_t * coeffs) +{ + f32x4_t A = vfmasq(vdupq_n_f32(coeffs[4]), x, coeffs[0]); + f32x4_t B = vfmasq(vdupq_n_f32(coeffs[6]), x, coeffs[2]); + f32x4_t C = vfmasq(vdupq_n_f32(coeffs[5]), x, coeffs[1]); + f32x4_t D = vfmasq(vdupq_n_f32(coeffs[7]), x, coeffs[3]); + f32x4_t x2 = vmulq(x, x); + f32x4_t x4 = vmulq(x2, x2); + f32x4_t res = vfmaq(vfmaq_f32(A, B, x2), vfmaq_f32(C, D, x2), x4); + + return res; +} + +__STATIC_INLINE f32x4_t vmant_exp_f32( + f32x4_t x, + int32x4_t * e) +{ + any32x4_t r; + int32x4_t n; + + r.f = x; + n = r.i >> 23; + n = n - 127; + r.i = r.i - (n << 23); + + *e = n; + return r.f; +} + + +__STATIC_INLINE f32x4_t vlogq_f32(f32x4_t vecIn) +{ + q31x4_t vecExpUnBiased; + f32x4_t vecTmpFlt0, vecTmpFlt1; + f32x4_t vecAcc0, vecAcc1, vecAcc2, vecAcc3; + f32x4_t vecExpUnBiasedFlt; + + /* + * extract exponent + */ + vecTmpFlt1 = vmant_exp_f32(vecIn, &vecExpUnBiased); + + vecTmpFlt0 = vecTmpFlt1 * vecTmpFlt1; + /* + * a = (__logf_lut_f32[4] * r.f) + (__logf_lut_f32[0]); + */ + vecAcc0 = vdupq_n_f32(__logf_lut_f32[0]); + vecAcc0 = vfmaq(vecAcc0, vecTmpFlt1, __logf_lut_f32[4]); + /* + * b = (__logf_lut_f32[6] * r.f) + (__logf_lut_f32[2]); + */ + vecAcc1 = vdupq_n_f32(__logf_lut_f32[2]); + vecAcc1 = vfmaq(vecAcc1, vecTmpFlt1, __logf_lut_f32[6]); + /* + * c = (__logf_lut_f32[5] * r.f) + (__logf_lut_f32[1]); + */ + vecAcc2 = vdupq_n_f32(__logf_lut_f32[1]); + vecAcc2 = vfmaq(vecAcc2, vecTmpFlt1, __logf_lut_f32[5]); + /* + * d = (__logf_lut_f32[7] * r.f) + (__logf_lut_f32[3]); + */ + vecAcc3 = vdupq_n_f32(__logf_lut_f32[3]); + vecAcc3 = vfmaq(vecAcc3, vecTmpFlt1, __logf_lut_f32[7]); + /* + * a = a + b * xx; + */ + vecAcc0 = vfmaq(vecAcc0, vecAcc1, vecTmpFlt0); + /* + * c = c + d * xx; + */ + vecAcc2 = vfmaq(vecAcc2, vecAcc3, vecTmpFlt0); + /* + * xx = xx * xx; + */ + vecTmpFlt0 = vecTmpFlt0 * vecTmpFlt0; + vecExpUnBiasedFlt = vcvtq_f32_s32(vecExpUnBiased); + /* + * r.f = a + c * xx; + */ + vecAcc0 = vfmaq(vecAcc0, vecAcc2, vecTmpFlt0); + /* + * add exponent + * r.f = r.f + ((float32_t) m) * __logf_rng_f32; + */ + vecAcc0 = vfmaq(vecAcc0, vecExpUnBiasedFlt, __logf_rng_f32); + // set log0 down to -inf + vecAcc0 = vdupq_m(vecAcc0, -INFINITY, vcmpeqq(vecIn, 0.0f)); + return vecAcc0; +} + +__STATIC_INLINE f32x4_t vexpq_f32( + f32x4_t x) +{ + // Perform range reduction [-log(2),log(2)] + int32x4_t m = vcvtq_s32_f32(vmulq_n_f32(x, 1.4426950408f)); + f32x4_t val = vfmsq_f32(x, vcvtq_f32_s32(m), vdupq_n_f32(0.6931471805f)); + + // Polynomial Approximation + f32x4_t poly = vtaylor_polyq_f32(val, exp_tab); + + // Reconstruct + poly = (f32x4_t) (vqaddq_s32((q31x4_t) (poly), vqshlq_n_s32(m, 23))); + + poly = vdupq_m(poly, 0.0f, vcmpltq_n_s32(m, -126)); + return poly; +} + +__STATIC_INLINE f32x4_t arm_vec_exponent_f32(f32x4_t x, int32_t nb) +{ + f32x4_t r = x; + nb--; + while (nb > 0) { + r = vmulq(r, x); + nb--; + } + return (r); +} + +__STATIC_INLINE f32x4_t vrecip_f32(f32x4_t vecIn) +{ + f32x4_t vecSx, vecW, vecTmp; + any32x4_t v; + + vecSx = vabsq(vecIn); + + v.f = vecIn; + v.i = vsubq(vdupq_n_s32(INV_NEWTON_INIT_F32), v.i); + + vecW = vmulq(vecSx, v.f); + + // v.f = v.f * (8 + w * (-28 + w * (56 + w * (-70 + w *(56 + w * (-28 + w * (8 - w))))))); + vecTmp = vsubq(vdupq_n_f32(8.0f), vecW); + vecTmp = vfmasq(vecW, vecTmp, -28.0f); + vecTmp = vfmasq(vecW, vecTmp, 56.0f); + vecTmp = vfmasq(vecW, vecTmp, -70.0f); + vecTmp = vfmasq(vecW, vecTmp, 56.0f); + vecTmp = vfmasq(vecW, vecTmp, -28.0f); + vecTmp = vfmasq(vecW, vecTmp, 8.0f); + v.f = vmulq(v.f, vecTmp); + + v.f = vdupq_m(v.f, INFINITY, vcmpeqq(vecIn, 0.0f)); + /* + * restore sign + */ + v.f = vnegq_m(v.f, v.f, vcmpltq(vecIn, 0.0f)); + return v.f; +} + +__STATIC_INLINE f32x4_t vtanhq_f32( + f32x4_t val) +{ + f32x4_t x = + vminnmq_f32(vmaxnmq_f32(val, vdupq_n_f32(-10.f)), vdupq_n_f32(10.0f)); + f32x4_t exp2x = vexpq_f32(vmulq_n_f32(x, 2.f)); + f32x4_t num = vsubq_n_f32(exp2x, 1.f); + f32x4_t den = vaddq_n_f32(exp2x, 1.f); + f32x4_t tanh = vmulq_f32(num, vrecip_f32(den)); + return tanh; +} + +__STATIC_INLINE f32x4_t vpowq_f32( + f32x4_t val, + f32x4_t n) +{ + return vexpq_f32(vmulq_f32(n, vlogq_f32(val))); +} + +#endif /* (defined(ARM_MATH_MVEF) || defined(ARM_MATH_HELIUM)) && !defined(ARM_MATH_AUTOVECTORIZE)*/ + +#if (defined(ARM_MATH_MVEI) || defined(ARM_MATH_HELIUM)) +#endif /* (defined(ARM_MATH_MVEI) || defined(ARM_MATH_HELIUM)) */ + +#if (defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE) + +#include "NEMath.h" +/** + * @brief Vectorized integer exponentiation + * @param[in] x value + * @param[in] nb integer exponent >= 1 + * @return x^nb + * + */ +__STATIC_INLINE float32x4_t arm_vec_exponent_f32(float32x4_t x, int32_t nb) +{ + float32x4_t r = x; + nb --; + while(nb > 0) + { + r = vmulq_f32(r , x); + nb--; + } + return(r); +} + + +__STATIC_INLINE float32x4_t __arm_vec_sqrt_f32_neon(float32x4_t x) +{ + float32x4_t x1 = vmaxq_f32(x, vdupq_n_f32(FLT_MIN)); + float32x4_t e = vrsqrteq_f32(x1); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); + e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x1, e), e), e); + return vmulq_f32(x, e); +} + +__STATIC_INLINE int16x8_t __arm_vec_sqrt_q15_neon(int16x8_t vec) +{ + float32x4_t tempF; + int32x4_t tempHI,tempLO; + + tempLO = vmovl_s16(vget_low_s16(vec)); + tempF = vcvtq_n_f32_s32(tempLO,15); + tempF = __arm_vec_sqrt_f32_neon(tempF); + tempLO = vcvtq_n_s32_f32(tempF,15); + + tempHI = vmovl_s16(vget_high_s16(vec)); + tempF = vcvtq_n_f32_s32(tempHI,15); + tempF = __arm_vec_sqrt_f32_neon(tempF); + tempHI = vcvtq_n_s32_f32(tempF,15); + + return(vcombine_s16(vqmovn_s32(tempLO),vqmovn_s32(tempHI))); +} + +__STATIC_INLINE int32x4_t __arm_vec_sqrt_q31_neon(int32x4_t vec) +{ + float32x4_t temp; + + temp = vcvtq_n_f32_s32(vec,31); + temp = __arm_vec_sqrt_f32_neon(temp); + return(vcvtq_n_s32_f32(temp,31)); +} + +#endif /* (defined(ARM_MATH_NEON) || defined(ARM_MATH_NEON_EXPERIMENTAL)) && !defined(ARM_MATH_AUTOVECTORIZE) */ + +#ifdef __cplusplus +} +#endif + + +#endif /* _ARM_VEC_MATH_H */ + +/** + * + * End of file. + */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cachel1_armv7.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cachel1_armv7.h new file mode 100644 index 0000000000..d2c3e2291f --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cachel1_armv7.h @@ -0,0 +1,411 @@ +/****************************************************************************** + * @file cachel1_armv7.h + * @brief CMSIS Level 1 Cache API for Armv7-M and later + * @version V1.0.0 + * @date 03. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_CACHEL1_ARMV7_H +#define ARM_CACHEL1_ARMV7_H + +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_CacheFunctions Cache Functions + \brief Functions that configure Instruction and Data cache. + @{ + */ + +/* Cache Size ID Register Macros */ +#define CCSIDR_WAYS(x) (((x) & SCB_CCSIDR_ASSOCIATIVITY_Msk) >> SCB_CCSIDR_ASSOCIATIVITY_Pos) +#define CCSIDR_SETS(x) (((x) & SCB_CCSIDR_NUMSETS_Msk ) >> SCB_CCSIDR_NUMSETS_Pos ) + +#ifndef __SCB_DCACHE_LINE_SIZE +#define __SCB_DCACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#endif + +#ifndef __SCB_ICACHE_LINE_SIZE +#define __SCB_ICACHE_LINE_SIZE 32U /*!< Cortex-M7 cache line size is fixed to 32 bytes (8 words). See also register SCB_CCSIDR */ +#endif + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if (SCB->CCR & SCB_CCR_IC_Msk) return; /* return if ICache is already enabled */ + + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->CCR &= ~(uint32_t)SCB_CCR_IC_Msk; /* disable I-Cache */ + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate I-Cache + \details Invalidates I-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateICache (void) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief I-Cache Invalidate by address + \details Invalidates I-Cache for the given address. + I-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + I-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] isize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateICache_by_Addr (void *addr, int32_t isize) +{ + #if defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U) + if ( isize > 0 ) { + int32_t op_size = isize + (((uint32_t)addr) & (__SCB_ICACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_ICACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->ICIMVAU = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_ICACHE_LINE_SIZE; + op_size -= __SCB_ICACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_FORCEINLINE void SCB_EnableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + if (SCB->CCR & SCB_CCR_DC_Msk) return; /* return if DCache is already enabled */ + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + __DSB(); + + SCB->CCR |= (uint32_t)SCB_CCR_DC_Msk; /* enable D-Cache */ + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable D-Cache + \details Turns off D-Cache + */ +__STATIC_FORCEINLINE void SCB_DisableDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_InvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCISW = (((sets << SCB_DCISW_SET_Pos) & SCB_DCISW_SET_Msk) | + ((ways << SCB_DCISW_WAY_Pos) & SCB_DCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCSW = (((sets << SCB_DCCSW_SET_Pos) & SCB_DCCSW_SET_Msk) | + ((ways << SCB_DCCSW_WAY_Pos) & SCB_DCCSW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache (void) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = 0U; /* select Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + /* clean & invalidate D-Cache */ + sets = (uint32_t)(CCSIDR_SETS(ccsidr)); + do { + ways = (uint32_t)(CCSIDR_WAYS(ccsidr)); + do { + SCB->DCCISW = (((sets << SCB_DCCISW_SET_Pos) & SCB_DCCISW_SET_Msk) | + ((ways << SCB_DCCISW_WAY_Pos) & SCB_DCCISW_WAY_Msk) ); + #if defined ( __CC_ARM ) + __schedule_barrier(); + #endif + } while (ways-- != 0U); + } while(sets-- != 0U); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address. + D-Cache is invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are invalidated. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr (void *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + D-Cache is cleaned starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned. + \param[in] addr address + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + D-Cache is cleaned and invalidated starting from a 32 byte aligned address in 32 byte granularity. + D-Cache memory blocks which are part of given address + given size are cleaned and invalidated. + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_FORCEINLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U) + if ( dsize > 0 ) { + int32_t op_size = dsize + (((uint32_t)addr) & (__SCB_DCACHE_LINE_SIZE - 1U)); + uint32_t op_addr = (uint32_t)addr /* & ~(__SCB_DCACHE_LINE_SIZE - 1U) */; + + __DSB(); + + do { + SCB->DCCIMVAC = op_addr; /* register accepts only 32byte aligned values, only bits 31..5 are valid */ + op_addr += __SCB_DCACHE_LINE_SIZE; + op_size -= __SCB_DCACHE_LINE_SIZE; + } while ( op_size > 0 ); + + __DSB(); + __ISB(); + } + #endif +} + +/*@} end of CMSIS_Core_CacheFunctions */ + +#endif /* ARM_CACHEL1_ARMV7_H */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armcc.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armcc.h new file mode 100644 index 0000000000..237ff6ec3e --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armcc.h @@ -0,0 +1,885 @@ +/**************************************************************************//** + * @file cmsis_armcc.h + * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file + * @version V5.2.1 + * @date 26. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_ARMCC_H +#define __CMSIS_ARMCC_H + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) + #error "Please use Arm Compiler Toolchain V4.0.677 or later!" +#endif + +/* CMSIS compiler control architecture macros */ +#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \ + (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) ) + #define __ARM_ARCH_6M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1)) + #define __ARM_ARCH_7M__ 1 +#endif + +#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1)) + #define __ARM_ARCH_7EM__ 1 +#endif + + /* __ARM_ARCH_8M_BASE__ not applicable */ + /* __ARM_ARCH_8M_MAIN__ not applicable */ + /* __ARM_ARCH_8_1M_MAIN__ not applicable */ + +/* CMSIS compiler control DSP macros */ +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __ARM_FEATURE_DSP 1 +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE static __forceinline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __declspec(noreturn) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed)) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT __packed struct +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION __packed union +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x))) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr))) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __memory_changed() +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +/* intrinsic void __enable_irq(); */ + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +/* intrinsic void __disable_irq(); */ + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_INLINE uint32_t __get_CONTROL(void) +{ + register uint32_t __regControl __ASM("control"); + return(__regControl); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + register uint32_t __regControl __ASM("control"); + __regControl = control; +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_INLINE uint32_t __get_IPSR(void) +{ + register uint32_t __regIPSR __ASM("ipsr"); + return(__regIPSR); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_INLINE uint32_t __get_APSR(void) +{ + register uint32_t __regAPSR __ASM("apsr"); + return(__regAPSR); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_INLINE uint32_t __get_xPSR(void) +{ + register uint32_t __regXPSR __ASM("xpsr"); + return(__regXPSR); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + return(__regProcessStackPointer); +} + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + register uint32_t __regProcessStackPointer __ASM("psp"); + __regProcessStackPointer = topOfProcStack; +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + return(__regMainStackPointer); +} + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + register uint32_t __regMainStackPointer __ASM("msp"); + __regMainStackPointer = topOfMainStack; +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + register uint32_t __regPriMask __ASM("primask"); + return(__regPriMask); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + register uint32_t __regPriMask __ASM("primask"); + __regPriMask = (priMask); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + register uint32_t __regBasePri __ASM("basepri"); + return(__regBasePri); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) +{ + register uint32_t __regBasePri __ASM("basepri"); + __regBasePri = (basePri & 0xFFU); +} + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + register uint32_t __regBasePriMax __ASM("basepri_max"); + __regBasePriMax = (basePri & 0xFFU); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + return(__regFaultMask); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + register uint32_t __regFaultMask __ASM("faultmask"); + __regFaultMask = (faultMask & (uint32_t)1U); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + return(__regfpscr); +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __nop + + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __dsb(0xF) + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) +{ + rev16 r0, r0 + bx lr +} +#endif + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value) +{ + revsh r0, r0 + bx lr +} +#endif + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +#define __ROR __ror + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __breakpoint(value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + #define __RBIT __rbit +#else +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ + return result; +} +#endif + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +#define __CLZ __clz + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) +#else + #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) +#else + #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) +#else + #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXB(value, ptr) __strex(value, ptr) +#else + #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXH(value, ptr) __strex(value, ptr) +#else + #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) + #define __STREXW(value, ptr) __strex(value, ptr) +#else + #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") +#endif + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __clrex + + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) +{ + rrx r0, r0 + bx lr +} +#endif + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRBT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRHT(value, ptr) __strt(value, ptr) + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +#define __STRT(value, ptr) __strt(value, ptr) + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) + +#define __SADD8 __sadd8 +#define __QADD8 __qadd8 +#define __SHADD8 __shadd8 +#define __UADD8 __uadd8 +#define __UQADD8 __uqadd8 +#define __UHADD8 __uhadd8 +#define __SSUB8 __ssub8 +#define __QSUB8 __qsub8 +#define __SHSUB8 __shsub8 +#define __USUB8 __usub8 +#define __UQSUB8 __uqsub8 +#define __UHSUB8 __uhsub8 +#define __SADD16 __sadd16 +#define __QADD16 __qadd16 +#define __SHADD16 __shadd16 +#define __UADD16 __uadd16 +#define __UQADD16 __uqadd16 +#define __UHADD16 __uhadd16 +#define __SSUB16 __ssub16 +#define __QSUB16 __qsub16 +#define __SHSUB16 __shsub16 +#define __USUB16 __usub16 +#define __UQSUB16 __uqsub16 +#define __UHSUB16 __uhsub16 +#define __SASX __sasx +#define __QASX __qasx +#define __SHASX __shasx +#define __UASX __uasx +#define __UQASX __uqasx +#define __UHASX __uhasx +#define __SSAX __ssax +#define __QSAX __qsax +#define __SHSAX __shsax +#define __USAX __usax +#define __UQSAX __uqsax +#define __UHSAX __uhsax +#define __USAD8 __usad8 +#define __USADA8 __usada8 +#define __SSAT16 __ssat16 +#define __USAT16 __usat16 +#define __UXTB16 __uxtb16 +#define __UXTAB16 __uxtab16 +#define __SXTB16 __sxtb16 +#define __SXTAB16 __sxtab16 +#define __SMUAD __smuad +#define __SMUADX __smuadx +#define __SMLAD __smlad +#define __SMLADX __smladx +#define __SMLALD __smlald +#define __SMLALDX __smlaldx +#define __SMUSD __smusd +#define __SMUSDX __smusdx +#define __SMLSD __smlsd +#define __SMLSDX __smlsdx +#define __SMLSLD __smlsld +#define __SMLSLDX __smlsldx +#define __SEL __sel +#define __QADD __qadd +#define __QSUB __qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ + ((int64_t)(ARG3) << 32U) ) >> 32U)) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_H */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armclang.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armclang.h new file mode 100644 index 0000000000..90de9dbf8f --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armclang.h @@ -0,0 +1,1467 @@ +/**************************************************************************//** + * @file cmsis_armclang.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V5.3.1 + * @date 26. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +#ifndef __ARM_COMPAT_H +#include /* Compatibility header for Arm Compiler 5 intrinsics */ +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +/* intrinsic void __enable_irq(); see arm_compat.h */ + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +/* intrinsic void __disable_irq(); see arm_compat.h */ + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq /* see arm_compat.h */ + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq /* see arm_compat.h */ + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) ) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) + +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) || \ + (defined (__ARM_ARCH_8_1M_MAIN__) && (__ARM_ARCH_8_1M_MAIN__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +#define __SADD8 __builtin_arm_sadd8 +#define __QADD8 __builtin_arm_qadd8 +#define __SHADD8 __builtin_arm_shadd8 +#define __UADD8 __builtin_arm_uadd8 +#define __UQADD8 __builtin_arm_uqadd8 +#define __UHADD8 __builtin_arm_uhadd8 +#define __SSUB8 __builtin_arm_ssub8 +#define __QSUB8 __builtin_arm_qsub8 +#define __SHSUB8 __builtin_arm_shsub8 +#define __USUB8 __builtin_arm_usub8 +#define __UQSUB8 __builtin_arm_uqsub8 +#define __UHSUB8 __builtin_arm_uhsub8 +#define __SADD16 __builtin_arm_sadd16 +#define __QADD16 __builtin_arm_qadd16 +#define __SHADD16 __builtin_arm_shadd16 +#define __UADD16 __builtin_arm_uadd16 +#define __UQADD16 __builtin_arm_uqadd16 +#define __UHADD16 __builtin_arm_uhadd16 +#define __SSUB16 __builtin_arm_ssub16 +#define __QSUB16 __builtin_arm_qsub16 +#define __SHSUB16 __builtin_arm_shsub16 +#define __USUB16 __builtin_arm_usub16 +#define __UQSUB16 __builtin_arm_uqsub16 +#define __UHSUB16 __builtin_arm_uhsub16 +#define __SASX __builtin_arm_sasx +#define __QASX __builtin_arm_qasx +#define __SHASX __builtin_arm_shasx +#define __UASX __builtin_arm_uasx +#define __UQASX __builtin_arm_uqasx +#define __UHASX __builtin_arm_uhasx +#define __SSAX __builtin_arm_ssax +#define __QSAX __builtin_arm_qsax +#define __SHSAX __builtin_arm_shsax +#define __USAX __builtin_arm_usax +#define __UQSAX __builtin_arm_uqsax +#define __UHSAX __builtin_arm_uhsax +#define __USAD8 __builtin_arm_usad8 +#define __USADA8 __builtin_arm_usada8 +#define __SSAT16 __builtin_arm_ssat16 +#define __USAT16 __builtin_arm_usat16 +#define __UXTB16 __builtin_arm_uxtb16 +#define __UXTAB16 __builtin_arm_uxtab16 +#define __SXTB16 __builtin_arm_sxtb16 +#define __SXTAB16 __builtin_arm_sxtab16 +#define __SMUAD __builtin_arm_smuad +#define __SMUADX __builtin_arm_smuadx +#define __SMLAD __builtin_arm_smlad +#define __SMLADX __builtin_arm_smladx +#define __SMLALD __builtin_arm_smlald +#define __SMLALDX __builtin_arm_smlaldx +#define __SMUSD __builtin_arm_smusd +#define __SMUSDX __builtin_arm_smusdx +#define __SMLSD __builtin_arm_smlsd +#define __SMLSDX __builtin_arm_smlsdx +#define __SMLSLD __builtin_arm_smlsld +#define __SMLSLDX __builtin_arm_smlsldx +#define __SEL __builtin_arm_sel +#define __QADD __builtin_arm_qadd +#define __QSUB __builtin_arm_qsub + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armclang_ltm.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armclang_ltm.h new file mode 100644 index 0000000000..0e5c7349d3 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_armclang_ltm.h @@ -0,0 +1,1893 @@ +/**************************************************************************//** + * @file cmsis_armclang_ltm.h + * @brief CMSIS compiler armclang (Arm Compiler 6) header file + * @version V1.3.0 + * @date 26. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2018-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*lint -esym(9058, IRQn)*/ /* disable MISRA 2012 Rule 2.4 for IRQn */ + +#ifndef __CMSIS_ARMCLANG_H +#define __CMSIS_ARMCLANG_H + +#pragma clang system_header /* treat file as system include file */ + +#ifndef __ARM_COMPAT_H +#include /* Compatibility header for Arm Compiler 5 intrinsics */ +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE __inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static __inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32 */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_WRITE */ + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT16_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT16_READ */ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wpacked" +/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma clang diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START +#define __PROGRAM_START __main +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET"))) +#endif + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +/* intrinsic void __enable_irq(); see arm_compat.h */ + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +/* intrinsic void __disable_irq(); see arm_compat.h */ + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __enable_fault_irq __enable_fiq /* see arm_compat.h */ + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +#define __disable_fault_irq __disable_fiq /* see arm_compat.h */ + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __get_FPSCR (uint32_t)__builtin_arm_get_fpscr +#else +#define __get_FPSCR() ((uint32_t)0U) +#endif + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#define __set_FPSCR __builtin_arm_set_fpscr +#else +#define __set_FPSCR(x) ((void)(x)) +#endif + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP __builtin_arm_nop + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI __builtin_arm_wfi + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE __builtin_arm_wfe + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV __builtin_arm_sev + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +#define __ISB() __builtin_arm_isb(0xF) + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +#define __DSB() __builtin_arm_dsb(0xF) + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +#define __DMB() __builtin_arm_dmb(0xF) + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV(value) __builtin_bswap32(value) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16(value) __ROR(__REV(value), 16) + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REVSH(value) (int16_t)__builtin_bswap16(value) + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __RBIT __builtin_arm_rbit + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM Compiler 6.10 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDREXB (uint8_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDREXH (uint16_t)__builtin_arm_ldrex + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDREXW (uint32_t)__builtin_arm_ldrex + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXB (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXH (uint32_t)__builtin_arm_strex + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STREXW (uint32_t)__builtin_arm_strex + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +#define __CLREX __builtin_arm_clrex + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT __builtin_arm_ssat + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT __builtin_arm_usat + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +#define __LDAEXB (uint8_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +#define __LDAEXH (uint16_t)__builtin_arm_ldaex + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +#define __LDAEX (uint32_t)__builtin_arm_ldaex + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXB (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEXH (uint32_t)__builtin_arm_stlex + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +#define __STLEX (uint32_t)__builtin_arm_stlex + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +#define __USAT16(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCLANG_H */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_compiler.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_compiler.h new file mode 100644 index 0000000000..adbf296f15 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_compiler.h @@ -0,0 +1,283 @@ +/**************************************************************************//** + * @file cmsis_compiler.h + * @brief CMSIS compiler generic header file + * @version V5.1.0 + * @date 09. October 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_COMPILER_H +#define __CMSIS_COMPILER_H + +#include + +/* + * Arm Compiler 4/5 + */ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + + +/* + * Arm Compiler 6.6 LTM (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100) + #include "cmsis_armclang_ltm.h" + + /* + * Arm Compiler above 6.10.1 (armclang) + */ +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100) + #include "cmsis_armclang.h" + + +/* + * GNU Compiler + */ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + + +/* + * IAR Compiler + */ +#elif defined ( __ICCARM__ ) + #include + + +/* + * TI Arm Compiler + */ +#elif defined ( __TI_ARM__ ) + #include + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __attribute__((packed)) + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed)) + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed)) + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) + #endif + #ifndef __RESTRICT + #define __RESTRICT __restrict + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * TASKING Compiler + */ +#elif defined ( __TASKING__ ) + /* + * The CMSIS functions have been implemented as intrinsics in the compiler. + * Please use "carm -?i" to get an up to date list of all intrinsics, + * Including the CMSIS ones. + */ + + #ifndef __ASM + #define __ASM __asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + #define __NO_RETURN __attribute__((noreturn)) + #endif + #ifndef __USED + #define __USED __attribute__((used)) + #endif + #ifndef __WEAK + #define __WEAK __attribute__((weak)) + #endif + #ifndef __PACKED + #define __PACKED __packed__ + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __packed__ + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION union __packed__ + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + struct __packed__ T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #define __ALIGNED(x) __align(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +/* + * COSMIC Compiler + */ +#elif defined ( __CSMC__ ) + #include + + #ifndef __ASM + #define __ASM _asm + #endif + #ifndef __INLINE + #define __INLINE inline + #endif + #ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline + #endif + #ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __STATIC_INLINE + #endif + #ifndef __NO_RETURN + // NO RETURN is automatically detected hence no warning here + #define __NO_RETURN + #endif + #ifndef __USED + #warning No compiler specific solution for __USED. __USED is ignored. + #define __USED + #endif + #ifndef __WEAK + #define __WEAK __weak + #endif + #ifndef __PACKED + #define __PACKED @packed + #endif + #ifndef __PACKED_STRUCT + #define __PACKED_STRUCT @packed struct + #endif + #ifndef __PACKED_UNION + #define __PACKED_UNION @packed union + #endif + #ifndef __UNALIGNED_UINT32 /* deprecated */ + @packed struct T_UINT32 { uint32_t v; }; + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) + #endif + #ifndef __UNALIGNED_UINT16_WRITE + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT16_READ + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) + #endif + #ifndef __UNALIGNED_UINT32_WRITE + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) + #endif + #ifndef __UNALIGNED_UINT32_READ + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) + #endif + #ifndef __ALIGNED + #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored. + #define __ALIGNED(x) + #endif + #ifndef __RESTRICT + #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored. + #define __RESTRICT + #endif + #ifndef __COMPILER_BARRIER + #warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored. + #define __COMPILER_BARRIER() (void)0 + #endif + + +#else + #error Unknown compiler. +#endif + + +#endif /* __CMSIS_COMPILER_H */ + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_gcc.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_gcc.h new file mode 100644 index 0000000000..a2778f58e8 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_gcc.h @@ -0,0 +1,2177 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS compiler GCC header file + * @version V5.3.0 + * @date 26. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" + +/* Fallback for __has_builtin */ +#ifndef __has_builtin + #define __has_builtin(x) (0) +#endif + +/* CMSIS compiler specific defines */ +#ifndef __ASM + #define __ASM __asm +#endif +#ifndef __INLINE + #define __INLINE inline +#endif +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline +#endif +#ifndef __NO_RETURN + #define __NO_RETURN __attribute__((__noreturn__)) +#endif +#ifndef __USED + #define __USED __attribute__((used)) +#endif +#ifndef __WEAK + #define __WEAK __attribute__((weak)) +#endif +#ifndef __PACKED + #define __PACKED __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_STRUCT + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) +#endif +#ifndef __PACKED_UNION + #define __PACKED_UNION union __attribute__((packed, aligned(1))) +#endif +#ifndef __UNALIGNED_UINT32 /* deprecated */ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + struct __attribute__((packed)) T_UINT32 { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v) +#endif +#ifndef __UNALIGNED_UINT16_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT16_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT16_READ { uint16_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v) +#endif +#ifndef __UNALIGNED_UINT32_WRITE + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) +#endif +#ifndef __UNALIGNED_UINT32_READ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wpacked" + #pragma GCC diagnostic ignored "-Wattributes" + __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; + #pragma GCC diagnostic pop + #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) +#endif +#ifndef __ALIGNED + #define __ALIGNED(x) __attribute__((aligned(x))) +#endif +#ifndef __RESTRICT + #define __RESTRICT __restrict +#endif +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +/* ######################### Startup and Lowlevel Init ######################## */ + +#ifndef __PROGRAM_START + +/** + \brief Initializes data and bss sections + \details This default implementations initialized all data and additional bss + sections relying on .copy.table and .zero.table specified properly + in the used linker script. + + */ +__STATIC_FORCEINLINE __NO_RETURN void __cmsis_start(void) +{ + extern void _start(void) __NO_RETURN; + + typedef struct { + uint32_t const* src; + uint32_t* dest; + uint32_t wlen; + } __copy_table_t; + + typedef struct { + uint32_t* dest; + uint32_t wlen; + } __zero_table_t; + + extern const __copy_table_t __copy_table_start__; + extern const __copy_table_t __copy_table_end__; + extern const __zero_table_t __zero_table_start__; + extern const __zero_table_t __zero_table_end__; + + for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = pTable->src[i]; + } + } + + for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { + for(uint32_t i=0u; iwlen; ++i) { + pTable->dest[i] = 0u; + } + } + + _start(); +} + +#define __PROGRAM_START __cmsis_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP __StackTop +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT __StackLimit +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __Vectors +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section(".vectors"))) +#endif + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/** + \brief Enable IRQ Interrupts + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_irq(void) +{ + __ASM volatile ("cpsie i" : : : "memory"); +} + + +/** + \brief Disable IRQ Interrupts + \details Disables IRQ interrupts by setting the I-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_irq(void) +{ + __ASM volatile ("cpsid i" : : : "memory"); +} + + +/** + \brief Get Control Register + \details Returns the content of the Control Register. + \return Control Register value + */ +__STATIC_FORCEINLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Control Register (non-secure) + \details Returns the content of the non-secure Control Register when in secure mode. + \return non-secure Control Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_CONTROL_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Control Register (non-secure) + \details Writes the given value to the non-secure Control Register when in secure state. + \param [in] control Control Register value to set + */ +__STATIC_FORCEINLINE void __TZ_set_CONTROL_NS(uint32_t control) +{ + __ASM volatile ("MSR control_ns, %0" : : "r" (control) : "memory"); +} +#endif + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__STATIC_FORCEINLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state. + \return PSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, psp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer + \details Assigns the given value to the Process Stack Pointer (PSP). + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state. + \param [in] topOfProcStack Process Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : ); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSP(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state. + \return MSP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, msp_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer + \details Assigns the given value to the Main Stack Pointer (MSP). + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : ); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state. + \param [in] topOfMainStack Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : ); +} +#endif + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Stack Pointer (non-secure) + \details Returns the current value of the non-secure Stack Pointer (SP) when in secure state. + \return SP Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_SP_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, sp_ns" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Stack Pointer (non-secure) + \details Assigns the given value to the non-secure Stack Pointer (SP) when in secure state. + \param [in] topOfStack Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_SP_NS(uint32_t topOfStack) +{ + __ASM volatile ("MSR sp_ns, %0" : : "r" (topOfStack) : ); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Priority Mask (non-secure) + \details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state. + \return Priority Mask value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PRIMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Priority Mask (non-secure) + \details Assigns the given value to the non-secure Priority Mask Register when in secure state. + \param [in] priMask Priority Mask + */ +__STATIC_FORCEINLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __enable_fault_irq(void) +{ + __ASM volatile ("cpsie f" : : : "memory"); +} + + +/** + \brief Disable FIQ + \details Disables FIQ interrupts by setting the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__STATIC_FORCEINLINE void __disable_fault_irq(void) +{ + __ASM volatile ("cpsid f" : : : "memory"); +} + + +/** + \brief Get Base Priority + \details Returns the current value of the Base Priority register. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Base Priority (non-secure) + \details Returns the current value of the non-secure Base Priority register when in secure state. + \return Base Priority register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_BASEPRI_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (basePri) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Base Priority (non-secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __TZ_set_BASEPRI_NS(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (basePri) : "memory"); +} +#endif + + +/** + \brief Set Base Priority with condition + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__STATIC_FORCEINLINE void __set_BASEPRI_MAX(uint32_t basePri) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Fault Mask (non-secure) + \details Returns the current value of the non-secure Fault Mask register when in secure state. + \return Fault Mask register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_FAULTMASK_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Fault Mask (non-secure) + \details Assigns the given value to the non-secure Fault Mask register when in secure state. + \param [in] faultMask Fault Mask value to set + */ +__STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + +/** + \brief Get Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return result; +#endif +} + +#if (defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Process Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Process Stack Pointer (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)ProcStackPtrLimit; +#else + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +#endif +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always in non-secure + mode. + + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + return result; +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Get Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence zero is returned always. + + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + return 0U; +#else + uint32_t result; + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return result; +#endif +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored in non-secure + mode. + + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +#endif +} + + +#if (defined (__ARM_FEATURE_CMSE ) && (__ARM_FEATURE_CMSE == 3)) +/** + \brief Set Main Stack Pointer Limit (non-secure) + Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure + Stack Pointer Limit register hence the write is silently ignored. + + \details Assigns the given value to the non-secure Main Stack Pointer Limit (MSPLIM) when in secure state. + \param [in] MainStackPtrLimit Main Stack Pointer value to set + */ +__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ +#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)MainStackPtrLimit; +#else + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +#endif +} +#endif + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__STATIC_FORCEINLINE uint32_t __get_FPSCR(void) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_get_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + return __builtin_arm_get_fpscr(); +#else + uint32_t result; + + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + return(result); +#endif +#else + return(0U); +#endif +} + + +/** + \brief Set FPSCR + \details Assigns the given value to the Floating Point Status/Control register. + \param [in] fpscr Floating Point Status/Control value to set + */ +__STATIC_FORCEINLINE void __set_FPSCR(uint32_t fpscr) +{ +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) +#if __has_builtin(__builtin_arm_set_fpscr) +// Re-enable using built-in when GCC has been fixed +// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2) + /* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */ + __builtin_arm_set_fpscr(fpscr); +#else + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc", "memory"); +#endif +#else + (void)fpscr; +#endif +} + + +/*@} end of CMSIS_Core_RegAccFunctions */ + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/* Define macros for porting to both thumb1 and thumb2. + * For thumb1, use low register (r0-r7), specified by constraint "l" + * Otherwise, use general registers, specified by constraint "r" */ +#if defined (__thumb__) && !defined (__thumb2__) +#define __CMSIS_GCC_OUT_REG(r) "=l" (r) +#define __CMSIS_GCC_RW_REG(r) "+l" (r) +#define __CMSIS_GCC_USE_REG(r) "l" (r) +#else +#define __CMSIS_GCC_OUT_REG(r) "=r" (r) +#define __CMSIS_GCC_RW_REG(r) "+r" (r) +#define __CMSIS_GCC_USE_REG(r) "r" (r) +#endif + +/** + \brief No Operation + \details No Operation does nothing. This instruction can be used for code alignment purposes. + */ +#define __NOP() __ASM volatile ("nop") + +/** + \brief Wait For Interrupt + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. + */ +#define __WFI() __ASM volatile ("wfi":::"memory") + + +/** + \brief Wait For Event + \details Wait For Event is a hint instruction that permits the processor to enter + a low-power state until one of a number of events occurs. + */ +#define __WFE() __ASM volatile ("wfe":::"memory") + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +#define __SEV() __ASM volatile ("sev") + + +/** + \brief Instruction Synchronization Barrier + \details Instruction Synchronization Barrier flushes the pipeline in the processor, + so that all instructions following the ISB are fetched from cache or memory, + after the instruction has been completed. + */ +__STATIC_FORCEINLINE void __ISB(void) +{ + __ASM volatile ("isb 0xF":::"memory"); +} + + +/** + \brief Data Synchronization Barrier + \details Acts as a special kind of Data Memory Barrier. + It completes when all explicit memory accesses before this instruction complete. + */ +__STATIC_FORCEINLINE void __DSB(void) +{ + __ASM volatile ("dsb 0xF":::"memory"); +} + + +/** + \brief Data Memory Barrier + \details Ensures the apparent order of the explicit memory operations before + and after the instruction, without ensuring their completion. + */ +__STATIC_FORCEINLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +} + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE int16_t __REVSH(int16_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (int16_t)__builtin_bswap16(value); +#else + int16_t result; + + __ASM ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return result; +#endif +} + + +/** + \brief Rotate Right in unsigned value (32 bit) + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. + \param [in] op1 Value to rotate + \param [in] op2 Number of Bits to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + op2 %= 32U; + if (op2 == 0U) + { + return op1; + } + return (op1 >> op2) | (op1 << (32U - op2)); +} + + +/** + \brief Breakpoint + \details Causes the processor to enter Debug state. + Debug tools can use this to investigate system state when the instruction at a particular address is reached. + \param [in] value is ignored by the processor. + If required, a debugger can use it to store additional information about the breakpoint. + */ +#define __BKPT(value) __ASM volatile ("bkpt "#value) + + +/** + \brief Reverse bit order of value + \details Reverses the bit order of the given value. + \param [in] value Value to reverse + \return Reversed value + */ +__STATIC_FORCEINLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) + __ASM ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value != 0U; value >>= 1U) + { + result <<= 1U; + result |= value & 1U; + s--; + } + result <<= s; /* shift when v's highest bits are zero */ +#endif + return result; +} + + +/** + \brief Count leading zeros + \details Counts the number of leading zeros of a data value. + \param [in] value Value to count the leading zeros + \return number of leading zeros in value + */ +__STATIC_FORCEINLINE uint8_t __CLZ(uint32_t value) +{ + /* Even though __builtin_clz produces a CLZ instruction on ARM, formally + __builtin_clz(0) is undefined behaviour, so handle this case specially. + This guarantees ARM-compatible results if happening to compile on a non-ARM + target, and ensures the compiler doesn't decide to activate any + optimisations using the logic "value was passed to __builtin_clz, so it + is non-zero". + ARM GCC 7.3 and possibly earlier will optimise this test away, leaving a + single CLZ instruction. + */ + if (value == 0U) + { + return 32U; + } + return __builtin_clz(value); +} + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief LDR Exclusive (8 bit) + \details Executes a exclusive LDR instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDREXB(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (16 bit) + \details Executes a exclusive LDR instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDREXH(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDR Exclusive (32 bit) + \details Executes a exclusive LDR instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDREXW(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) ); + return(result); +} + + +/** + \brief STR Exclusive (8 bit) + \details Executes a exclusive STR instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (16 bit) + \details Executes a exclusive STR instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr) +{ + uint32_t result; + + __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) ); + return(result); +} + + +/** + \brief STR Exclusive (32 bit) + \details Executes a exclusive STR instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) ); + return(result); +} + + +/** + \brief Remove the exclusive lock + \details Removes the exclusive lock which is created by LDREX. + */ +__STATIC_FORCEINLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (1..32) + \return Saturated value + */ +#define __SSAT(ARG1, ARG2) \ +__extension__ \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] ARG1 Value to be saturated + \param [in] ARG2 Bit position to saturate to (0..31) + \return Saturated value + */ +#define __USAT(ARG1, ARG2) \ + __extension__ \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + + +/** + \brief Rotate Right with Extend (32 bit) + \details Moves each bit of a bitstring right by one bit. + The carry input is shifted in at the left end of the bitstring. + \param [in] value Value to rotate + \return Rotated value + */ +__STATIC_FORCEINLINE uint32_t __RRX(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rrx %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief LDRT Unprivileged (8 bit) + \details Executes a Unprivileged LDRT instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDRBT(volatile uint8_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrbt %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint8_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (16 bit) + \details Executes a Unprivileged LDRT instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDRHT(volatile uint16_t *ptr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) ); +#else + /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not + accepted by assembler. So has to use following less efficient pattern. + */ + __ASM volatile ("ldrht %0, [%1]" : "=r" (result) : "r" (ptr) : "memory" ); +#endif + return ((uint16_t) result); /* Add explicit type cast here */ +} + + +/** + \brief LDRT Unprivileged (32 bit) + \details Executes a Unprivileged LDRT instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDRT(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) ); + return(result); +} + + +/** + \brief STRT Unprivileged (8 bit) + \details Executes a Unprivileged STRT instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRBT(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (16 bit) + \details Executes a Unprivileged STRT instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRHT(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \brief STRT Unprivileged (32 bit) + \details Executes a Unprivileged STRT instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + +/** + \brief Signed Saturate + \details Saturates a signed value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (1..32) + \return Saturated value + */ +__STATIC_FORCEINLINE int32_t __SSAT(int32_t val, uint32_t sat) +{ + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; +} + +/** + \brief Unsigned Saturate + \details Saturates an unsigned value. + \param [in] value Value to be saturated + \param [in] sat Bit position to saturate to (0..31) + \return Saturated value + */ +__STATIC_FORCEINLINE uint32_t __USAT(int32_t val, uint32_t sat) +{ + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; +} + +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ + (defined (__ARM_ARCH_7EM__ ) && (__ARM_ARCH_7EM__ == 1)) || \ + (defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) ) */ + + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) +/** + \brief Load-Acquire (8 bit) + \details Executes a LDAB instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire (16 bit) + \details Executes a LDAH instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire (32 bit) + \details Executes a LDA instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release (8 bit) + \details Executes a STLB instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (16 bit) + \details Executes a STLH instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Store-Release (32 bit) + \details Executes a STL instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + */ +__STATIC_FORCEINLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); +} + + +/** + \brief Load-Acquire Exclusive (8 bit) + \details Executes a LDAB exclusive instruction for 8 bit value. + \param [in] ptr Pointer to data + \return value of type uint8_t at (*ptr) + */ +__STATIC_FORCEINLINE uint8_t __LDAEXB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexb %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint8_t) result); +} + + +/** + \brief Load-Acquire Exclusive (16 bit) + \details Executes a LDAH exclusive instruction for 16 bit values. + \param [in] ptr Pointer to data + \return value of type uint16_t at (*ptr) + */ +__STATIC_FORCEINLINE uint16_t __LDAEXH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaexh %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return ((uint16_t) result); +} + + +/** + \brief Load-Acquire Exclusive (32 bit) + \details Executes a LDA exclusive instruction for 32 bit values. + \param [in] ptr Pointer to data + \return value of type uint32_t at (*ptr) + */ +__STATIC_FORCEINLINE uint32_t __LDAEX(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldaex %0, %1" : "=r" (result) : "Q" (*ptr) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (8 bit) + \details Executes a STLB exclusive instruction for 8 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexb %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (16 bit) + \details Executes a STLH exclusive instruction for 16 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlexh %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + + +/** + \brief Store-Release Exclusive (32 bit) + \details Executes a STL exclusive instruction for 32 bit values. + \param [in] value Value to store + \param [in] ptr Pointer to location + \return 0 Function succeeded + \return 1 Function failed + */ +__STATIC_FORCEINLINE uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("stlex %0, %2, %1" : "=&r" (result), "=Q" (*ptr) : "r" ((uint32_t)value) : "memory" ); + return(result); +} + +#endif /* ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) + +__STATIC_FORCEINLINE uint32_t __SADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + + +__STATIC_FORCEINLINE uint32_t __SADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHADD16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSUB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHASX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __QSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UQSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UHSAX(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USAD8(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#define __SSAT16(ARG1, ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +#define __USAT16(ARG1, ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM volatile ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) : "cc" ); \ + __RES; \ + }) + +__STATIC_FORCEINLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __UXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SXTB16_RORn(uint32_t op1, uint32_t rotate) +{ + uint32_t result; + + __ASM ("sxtb16 %0, %1, ROR %2" : "=r" (result) : "r" (op1), "i" (rotate) ); + + return result; +} + +__STATIC_FORCEINLINE uint32_t __SXTAB16(uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUAD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUADX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SMUSD (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMUSDX (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3) +{ + uint32_t result; + + __ASM volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc) +{ + union llreg_u{ + uint32_t w32[2]; + uint64_t w64; + } llr; + llr.w64 = acc; + +#ifndef __ARMEB__ /* Little endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) ); +#else /* Big endian */ + __ASM volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[1]), "=r" (llr.w32[0]): "r" (op1), "r" (op2) , "0" (llr.w32[1]), "1" (llr.w32[0]) ); +#endif + + return(llr.w64); +} + +__STATIC_FORCEINLINE uint32_t __SEL (uint32_t op1, uint32_t op2) +{ + uint32_t result; + + __ASM volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QADD( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +__STATIC_FORCEINLINE int32_t __QSUB( int32_t op1, int32_t op2) +{ + int32_t result; + + __ASM volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) ); + return(result); +} + +#if 0 +#define __PKHBT(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + __ASM ("pkhbt %0, %1, %2, lsl %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) + +#define __PKHTB(ARG1,ARG2,ARG3) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1), __ARG2 = (ARG2); \ + if (ARG3 == 0) \ + __ASM ("pkhtb %0, %1, %2" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2) ); \ + else \ + __ASM ("pkhtb %0, %1, %2, asr %3" : "=r" (__RES) : "r" (__ARG1), "r" (__ARG2), "I" (ARG3) ); \ + __RES; \ + }) +#endif + +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) + +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) + +__STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3) +{ + int32_t result; + + __ASM ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) ); + return(result); +} + +#endif /* (__ARM_FEATURE_DSP == 1) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#pragma GCC diagnostic pop + +#endif /* __CMSIS_GCC_H */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_iccarm.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_iccarm.h new file mode 100644 index 0000000000..7eeffca5c7 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_iccarm.h @@ -0,0 +1,968 @@ +/**************************************************************************//** + * @file cmsis_iccarm.h + * @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file + * @version V5.2.0 + * @date 28. January 2020 + ******************************************************************************/ + +//------------------------------------------------------------------------------ +// +// Copyright (c) 2017-2019 IAR Systems +// Copyright (c) 2017-2019 Arm Limited. All rights reserved. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License") +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//------------------------------------------------------------------------------ + + +#ifndef __CMSIS_ICCARM_H__ +#define __CMSIS_ICCARM_H__ + +#ifndef __ICCARM__ + #error This file should only be compiled by ICCARM +#endif + +#pragma system_include + +#define __IAR_FT _Pragma("inline=forced") __intrinsic + +#if (__VER__ >= 8000000) + #define __ICCARM_V8 1 +#else + #define __ICCARM_V8 0 +#endif + +#ifndef __ALIGNED + #if __ICCARM_V8 + #define __ALIGNED(x) __attribute__((aligned(x))) + #elif (__VER__ >= 7080000) + /* Needs IAR language extensions */ + #define __ALIGNED(x) __attribute__((aligned(x))) + #else + #warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored. + #define __ALIGNED(x) + #endif +#endif + + +/* Define compiler macros for CPU architecture, used in CMSIS 5. + */ +#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__ +/* Macros already defined */ +#else + #if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M' + #if __ARM_ARCH == 6 + #define __ARM_ARCH_6M__ 1 + #elif __ARM_ARCH == 7 + #if __ARM_FEATURE_DSP + #define __ARM_ARCH_7EM__ 1 + #else + #define __ARM_ARCH_7M__ 1 + #endif + #endif /* __ARM_ARCH */ + #endif /* __ARM_ARCH_PROFILE == 'M' */ +#endif + +/* Alternativ core deduction for older ICCARM's */ +#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \ + !defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__) + #if defined(__ARM6M__) && (__CORE__ == __ARM6M__) + #define __ARM_ARCH_6M__ 1 + #elif defined(__ARM7M__) && (__CORE__ == __ARM7M__) + #define __ARM_ARCH_7M__ 1 + #elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__) + #define __ARM_ARCH_7EM__ 1 + #elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__) + #define __ARM_ARCH_8M_BASE__ 1 + #elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__) + #define __ARM_ARCH_8M_MAIN__ 1 + #else + #error "Unknown target." + #endif +#endif + + + +#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1 + #define __IAR_M0_FAMILY 1 +#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1 + #define __IAR_M0_FAMILY 1 +#else + #define __IAR_M0_FAMILY 0 +#endif + + +#ifndef __ASM + #define __ASM __asm +#endif + +#ifndef __COMPILER_BARRIER + #define __COMPILER_BARRIER() __ASM volatile("":::"memory") +#endif + +#ifndef __INLINE + #define __INLINE inline +#endif + +#ifndef __NO_RETURN + #if __ICCARM_V8 + #define __NO_RETURN __attribute__((__noreturn__)) + #else + #define __NO_RETURN _Pragma("object_attribute=__noreturn") + #endif +#endif + +#ifndef __PACKED + #if __ICCARM_V8 + #define __PACKED __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED __packed + #endif +#endif + +#ifndef __PACKED_STRUCT + #if __ICCARM_V8 + #define __PACKED_STRUCT struct __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_STRUCT __packed struct + #endif +#endif + +#ifndef __PACKED_UNION + #if __ICCARM_V8 + #define __PACKED_UNION union __attribute__((packed, aligned(1))) + #else + /* Needs IAR language extensions */ + #define __PACKED_UNION __packed union + #endif +#endif + +#ifndef __RESTRICT + #if __ICCARM_V8 + #define __RESTRICT __restrict + #else + /* Needs IAR language extensions */ + #define __RESTRICT restrict + #endif +#endif + +#ifndef __STATIC_INLINE + #define __STATIC_INLINE static inline +#endif + +#ifndef __FORCEINLINE + #define __FORCEINLINE _Pragma("inline=forced") +#endif + +#ifndef __STATIC_FORCEINLINE + #define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE +#endif + +#ifndef __UNALIGNED_UINT16_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint16_t __iar_uint16_read(void const *ptr) +{ + return *(__packed uint16_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR) +#endif + + +#ifndef __UNALIGNED_UINT16_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val) +{ + *(__packed uint16_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32_READ +#pragma language=save +#pragma language=extended +__IAR_FT uint32_t __iar_uint32_read(void const *ptr) +{ + return *(__packed uint32_t*)(ptr); +} +#pragma language=restore +#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR) +#endif + +#ifndef __UNALIGNED_UINT32_WRITE +#pragma language=save +#pragma language=extended +__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val) +{ + *(__packed uint32_t*)(ptr) = val;; +} +#pragma language=restore +#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL) +#endif + +#ifndef __UNALIGNED_UINT32 /* deprecated */ +#pragma language=save +#pragma language=extended +__packed struct __iar_u32 { uint32_t v; }; +#pragma language=restore +#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v) +#endif + +#ifndef __USED + #if __ICCARM_V8 + #define __USED __attribute__((used)) + #else + #define __USED _Pragma("__root") + #endif +#endif + +#ifndef __WEAK + #if __ICCARM_V8 + #define __WEAK __attribute__((weak)) + #else + #define __WEAK _Pragma("__weak") + #endif +#endif + +#ifndef __PROGRAM_START +#define __PROGRAM_START __iar_program_start +#endif + +#ifndef __INITIAL_SP +#define __INITIAL_SP CSTACK$$Limit +#endif + +#ifndef __STACK_LIMIT +#define __STACK_LIMIT CSTACK$$Base +#endif + +#ifndef __VECTOR_TABLE +#define __VECTOR_TABLE __vector_table +#endif + +#ifndef __VECTOR_TABLE_ATTRIBUTE +#define __VECTOR_TABLE_ATTRIBUTE @".intvec" +#endif + +#ifndef __ICCARM_INTRINSICS_VERSION__ + #define __ICCARM_INTRINSICS_VERSION__ 0 +#endif + +#if __ICCARM_INTRINSICS_VERSION__ == 2 + + #if defined(__CLZ) + #undef __CLZ + #endif + #if defined(__REVSH) + #undef __REVSH + #endif + #if defined(__RBIT) + #undef __RBIT + #endif + #if defined(__SSAT) + #undef __SSAT + #endif + #if defined(__USAT) + #undef __USAT + #endif + + #include "iccarm_builtin.h" + + #define __disable_fault_irq __iar_builtin_disable_fiq + #define __disable_irq __iar_builtin_disable_interrupt + #define __enable_fault_irq __iar_builtin_enable_fiq + #define __enable_irq __iar_builtin_enable_interrupt + #define __arm_rsr __iar_builtin_rsr + #define __arm_wsr __iar_builtin_wsr + + + #define __get_APSR() (__arm_rsr("APSR")) + #define __get_BASEPRI() (__arm_rsr("BASEPRI")) + #define __get_CONTROL() (__arm_rsr("CONTROL")) + #define __get_FAULTMASK() (__arm_rsr("FAULTMASK")) + + #if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) + #define __get_FPSCR() (__arm_rsr("FPSCR")) + #define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE))) + #else + #define __get_FPSCR() ( 0 ) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #define __get_IPSR() (__arm_rsr("IPSR")) + #define __get_MSP() (__arm_rsr("MSP")) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __get_MSPLIM() (0U) + #else + #define __get_MSPLIM() (__arm_rsr("MSPLIM")) + #endif + #define __get_PRIMASK() (__arm_rsr("PRIMASK")) + #define __get_PSP() (__arm_rsr("PSP")) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __get_PSPLIM() (0U) + #else + #define __get_PSPLIM() (__arm_rsr("PSPLIM")) + #endif + + #define __get_xPSR() (__arm_rsr("xPSR")) + + #define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE))) + #define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE))) + #define __set_CONTROL(VALUE) (__arm_wsr("CONTROL", (VALUE))) + #define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE))) + #define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + #define __set_MSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE))) + #endif + #define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE))) + #define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE))) + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __set_PSPLIM(VALUE) ((void)(VALUE)) + #else + #define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE))) + #endif + + #define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS")) + #define __TZ_set_CONTROL_NS(VALUE) (__arm_wsr("CONTROL_NS", (VALUE))) + #define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS")) + #define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE))) + #define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS")) + #define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE))) + #define __TZ_get_SP_NS() (__arm_rsr("SP_NS")) + #define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE))) + #define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS")) + #define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE))) + #define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS")) + #define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE))) + #define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS")) + #define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE))) + + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + #define __TZ_get_PSPLIM_NS() (0U) + #define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE)) + #else + #define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS")) + #define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE))) + #endif + + #define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS")) + #define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE))) + + #define __NOP __iar_builtin_no_operation + + #define __CLZ __iar_builtin_CLZ + #define __CLREX __iar_builtin_CLREX + + #define __DMB __iar_builtin_DMB + #define __DSB __iar_builtin_DSB + #define __ISB __iar_builtin_ISB + + #define __LDREXB __iar_builtin_LDREXB + #define __LDREXH __iar_builtin_LDREXH + #define __LDREXW __iar_builtin_LDREX + + #define __RBIT __iar_builtin_RBIT + #define __REV __iar_builtin_REV + #define __REV16 __iar_builtin_REV16 + + __IAR_FT int16_t __REVSH(int16_t val) + { + return (int16_t) __iar_builtin_REVSH(val); + } + + #define __ROR __iar_builtin_ROR + #define __RRX __iar_builtin_RRX + + #define __SEV __iar_builtin_SEV + + #if !__IAR_M0_FAMILY + #define __SSAT __iar_builtin_SSAT + #endif + + #define __STREXB __iar_builtin_STREXB + #define __STREXH __iar_builtin_STREXH + #define __STREXW __iar_builtin_STREX + + #if !__IAR_M0_FAMILY + #define __USAT __iar_builtin_USAT + #endif + + #define __WFE __iar_builtin_WFE + #define __WFI __iar_builtin_WFI + + #if __ARM_MEDIA__ + #define __SADD8 __iar_builtin_SADD8 + #define __QADD8 __iar_builtin_QADD8 + #define __SHADD8 __iar_builtin_SHADD8 + #define __UADD8 __iar_builtin_UADD8 + #define __UQADD8 __iar_builtin_UQADD8 + #define __UHADD8 __iar_builtin_UHADD8 + #define __SSUB8 __iar_builtin_SSUB8 + #define __QSUB8 __iar_builtin_QSUB8 + #define __SHSUB8 __iar_builtin_SHSUB8 + #define __USUB8 __iar_builtin_USUB8 + #define __UQSUB8 __iar_builtin_UQSUB8 + #define __UHSUB8 __iar_builtin_UHSUB8 + #define __SADD16 __iar_builtin_SADD16 + #define __QADD16 __iar_builtin_QADD16 + #define __SHADD16 __iar_builtin_SHADD16 + #define __UADD16 __iar_builtin_UADD16 + #define __UQADD16 __iar_builtin_UQADD16 + #define __UHADD16 __iar_builtin_UHADD16 + #define __SSUB16 __iar_builtin_SSUB16 + #define __QSUB16 __iar_builtin_QSUB16 + #define __SHSUB16 __iar_builtin_SHSUB16 + #define __USUB16 __iar_builtin_USUB16 + #define __UQSUB16 __iar_builtin_UQSUB16 + #define __UHSUB16 __iar_builtin_UHSUB16 + #define __SASX __iar_builtin_SASX + #define __QASX __iar_builtin_QASX + #define __SHASX __iar_builtin_SHASX + #define __UASX __iar_builtin_UASX + #define __UQASX __iar_builtin_UQASX + #define __UHASX __iar_builtin_UHASX + #define __SSAX __iar_builtin_SSAX + #define __QSAX __iar_builtin_QSAX + #define __SHSAX __iar_builtin_SHSAX + #define __USAX __iar_builtin_USAX + #define __UQSAX __iar_builtin_UQSAX + #define __UHSAX __iar_builtin_UHSAX + #define __USAD8 __iar_builtin_USAD8 + #define __USADA8 __iar_builtin_USADA8 + #define __SSAT16 __iar_builtin_SSAT16 + #define __USAT16 __iar_builtin_USAT16 + #define __UXTB16 __iar_builtin_UXTB16 + #define __UXTAB16 __iar_builtin_UXTAB16 + #define __SXTB16 __iar_builtin_SXTB16 + #define __SXTAB16 __iar_builtin_SXTAB16 + #define __SMUAD __iar_builtin_SMUAD + #define __SMUADX __iar_builtin_SMUADX + #define __SMMLA __iar_builtin_SMMLA + #define __SMLAD __iar_builtin_SMLAD + #define __SMLADX __iar_builtin_SMLADX + #define __SMLALD __iar_builtin_SMLALD + #define __SMLALDX __iar_builtin_SMLALDX + #define __SMUSD __iar_builtin_SMUSD + #define __SMUSDX __iar_builtin_SMUSDX + #define __SMLSD __iar_builtin_SMLSD + #define __SMLSDX __iar_builtin_SMLSDX + #define __SMLSLD __iar_builtin_SMLSLD + #define __SMLSLDX __iar_builtin_SMLSLDX + #define __SEL __iar_builtin_SEL + #define __QADD __iar_builtin_QADD + #define __QSUB __iar_builtin_QSUB + #define __PKHBT __iar_builtin_PKHBT + #define __PKHTB __iar_builtin_PKHTB + #endif + +#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #define __CLZ __cmsis_iar_clz_not_active + #define __SSAT __cmsis_iar_ssat_not_active + #define __USAT __cmsis_iar_usat_not_active + #define __RBIT __cmsis_iar_rbit_not_active + #define __get_APSR __cmsis_iar_get_APSR_not_active + #endif + + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #define __get_FPSCR __cmsis_iar_get_FPSR_not_active + #define __set_FPSCR __cmsis_iar_set_FPSR_not_active + #endif + + #ifdef __INTRINSICS_INCLUDED + #error intrinsics.h is already included previously! + #endif + + #include + + #if __IAR_M0_FAMILY + /* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */ + #undef __CLZ + #undef __SSAT + #undef __USAT + #undef __RBIT + #undef __get_APSR + + __STATIC_INLINE uint8_t __CLZ(uint32_t data) + { + if (data == 0U) { return 32U; } + + uint32_t count = 0U; + uint32_t mask = 0x80000000U; + + while ((data & mask) == 0U) + { + count += 1U; + mask = mask >> 1U; + } + return count; + } + + __STATIC_INLINE uint32_t __RBIT(uint32_t v) + { + uint8_t sc = 31U; + uint32_t r = v; + for (v >>= 1U; v; v >>= 1U) + { + r <<= 1U; + r |= v & 1U; + sc--; + } + return (r << sc); + } + + __STATIC_INLINE uint32_t __get_APSR(void) + { + uint32_t res; + __asm("MRS %0,APSR" : "=r" (res)); + return res; + } + + #endif + + #if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ + (defined (__FPU_USED ) && (__FPU_USED == 1U)) )) + #undef __get_FPSCR + #undef __set_FPSCR + #define __get_FPSCR() (0) + #define __set_FPSCR(VALUE) ((void)VALUE) + #endif + + #pragma diag_suppress=Pe940 + #pragma diag_suppress=Pe177 + + #define __enable_irq __enable_interrupt + #define __disable_irq __disable_interrupt + #define __NOP __no_operation + + #define __get_xPSR __get_PSR + + #if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0) + + __IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr) + { + return __LDREX((unsigned long *)ptr); + } + + __IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr) + { + return __STREX(value, (unsigned long *)ptr); + } + #endif + + + /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + #if (__CORTEX_M >= 0x03) + + __IAR_FT uint32_t __RRX(uint32_t value) + { + uint32_t result; + __ASM volatile("RRX %0, %1" : "=r"(result) : "r" (value)); + return(result); + } + + __IAR_FT void __set_BASEPRI_MAX(uint32_t value) + { + __asm volatile("MSR BASEPRI_MAX,%0"::"r" (value)); + } + + + #define __enable_fault_irq __enable_fiq + #define __disable_fault_irq __disable_fiq + + + #endif /* (__CORTEX_M >= 0x03) */ + + __IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2) + { + return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2)); + } + + #if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + __IAR_FT uint32_t __get_MSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,MSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_MSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure MSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR MSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __get_PSPLIM(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __set_PSPLIM(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_CONTROL_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,CONTROL_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_CONTROL_NS(uint32_t value) + { + __asm volatile("MSR CONTROL_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PSP_NS(uint32_t value) + { + __asm volatile("MSR PSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_MSP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSP_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSP_NS(uint32_t value) + { + __asm volatile("MSR MSP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_SP_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,SP_NS" : "=r" (res)); + return res; + } + __IAR_FT void __TZ_set_SP_NS(uint32_t value) + { + __asm volatile("MSR SP_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PRIMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,PRIMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value) + { + __asm volatile("MSR PRIMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_BASEPRI_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,BASEPRI_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value) + { + __asm volatile("MSR BASEPRI_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value) + { + __asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value)); + } + + __IAR_FT uint32_t __TZ_get_PSPLIM_NS(void) + { + uint32_t res; + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + res = 0U; + #else + __asm volatile("MRS %0,PSPLIM_NS" : "=r" (res)); + #endif + return res; + } + + __IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value) + { + #if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \ + (!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3))) + // without main extensions, the non-secure PSPLIM is RAZ/WI + (void)value; + #else + __asm volatile("MSR PSPLIM_NS,%0" :: "r" (value)); + #endif + } + + __IAR_FT uint32_t __TZ_get_MSPLIM_NS(void) + { + uint32_t res; + __asm volatile("MRS %0,MSPLIM_NS" : "=r" (res)); + return res; + } + + __IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value) + { + __asm volatile("MSR MSPLIM_NS,%0" :: "r" (value)); + } + + #endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */ + +#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value)) + +#if __IAR_M0_FAMILY + __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) + { + if ((sat >= 1U) && (sat <= 32U)) + { + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); + const int32_t min = -1 - max ; + if (val > max) + { + return max; + } + else if (val < min) + { + return min; + } + } + return val; + } + + __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) + { + if (sat <= 31U) + { + const uint32_t max = ((1U << sat) - 1U); + if (val > (int32_t)max) + { + return max; + } + else if (val < 0) + { + return 0U; + } + } + return (uint32_t)val; + } +#endif + +#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */ + + __IAR_FT uint8_t __LDRBT(volatile uint8_t *addr) + { + uint32_t res; + __ASM volatile ("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDRHT(volatile uint16_t *addr) + { + uint32_t res; + __ASM volatile ("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDRT(volatile uint32_t *addr) + { + uint32_t res; + __ASM volatile ("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory"); + return res; + } + + __IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr) + { + __ASM volatile ("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr) + { + __ASM volatile ("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory"); + } + + __IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr) + { + __ASM volatile ("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory"); + } + +#endif /* (__CORTEX_M >= 0x03) */ + +#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \ + (defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) ) + + + __IAR_FT uint8_t __LDAB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDA(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr) + { + __ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr) + { + __ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr) + { + __ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory"); + } + + __IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint8_t)res); + } + + __IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return ((uint16_t)res); + } + + __IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + + __IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr) + { + uint32_t res; + __ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory"); + return res; + } + +#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */ + +#undef __IAR_FT +#undef __IAR_M0_FAMILY +#undef __ICCARM_V8 + +#pragma diag_default=Pe940 +#pragma diag_default=Pe177 + +#define __SXTB16_RORn(ARG1, ARG2) __SXTB16(__ROR(ARG1, ARG2)) + +#endif /* __CMSIS_ICCARM_H__ */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_version.h b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_version.h new file mode 100644 index 0000000000..2f048e4552 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/cmsis_version.h @@ -0,0 +1,39 @@ +/**************************************************************************//** + * @file cmsis_version.h + * @brief CMSIS Core(M) Version definitions + * @version V5.0.4 + * @date 23. July 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CMSIS_VERSION_H +#define __CMSIS_VERSION_H + +/* CMSIS Version definitions */ +#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ +#define __CM_CMSIS_VERSION_SUB ( 4U) /*!< [15:0] CMSIS Core(M) sub version */ +#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ + __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ +#endif diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv81mml.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv81mml.h new file mode 100644 index 0000000000..1ad19e215a --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv81mml.h @@ -0,0 +1,4191 @@ +/**************************************************************************//** + * @file core_armv81mml.h + * @brief CMSIS Armv8.1-M Mainline Core Peripheral Access Layer Header File + * @version V1.3.1 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2018-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV81MML_H_GENERIC +#define __CORE_ARMV81MML_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMV81MML + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS ARMV81MML definitions */ +#define __ARMv81MML_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv81MML_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv81MML_CMSIS_VERSION ((__ARMv81MML_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv81MML_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (81U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV81MML_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV81MML_H_DEPENDANT +#define __CORE_ARMV81MML_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv81MML_REV + #define __ARMv81MML_REV 0x0000U + #warning "__ARMv81MML_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 2U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 31 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv81MML */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED3[92U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[4]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 3 */ + uint32_t RESERVED14[3]; + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (16UL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (16UL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (8UL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (6UL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV81MML_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv8mbl.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv8mbl.h new file mode 100644 index 0000000000..932d3d188b --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv8mbl.h @@ -0,0 +1,2222 @@ +/**************************************************************************//** + * @file core_armv8mbl.h + * @brief CMSIS Armv8-M Baseline Core Peripheral Access Layer Header File + * @version V5.1.0 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV8MBL_H_GENERIC +#define __CORE_ARMV8MBL_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMv8MBL + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS definitions */ +#define __ARMv8MBL_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv8MBL_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv8MBL_CMSIS_VERSION ((__ARMv8MBL_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv8MBL_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (2U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MBL_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV8MBL_H_DEPENDANT +#define __CORE_ARMV8MBL_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv8MBL_REV + #define __ARMv8MBL_REV 0x0000U + #warning "__ARMv8MBL_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif + + #ifndef __ETM_PRESENT + #define __ETM_PRESENT 0U + #warning "__ETM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MTB_PRESENT + #define __MTB_PRESENT 0U + #warning "__MTB_PRESENT not defined in device header file; using default!" + #endif + +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv8MBL */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint32_t IPR[124U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHPR[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t RESERVED0[6U]; + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x3UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + uint32_t RESERVED0[7U]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: EN Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: EN Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#endif +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_DWTENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: DWTENA Position */ +#define CoreDebug_DEMCR_DWTENA_Msk (1UL << CoreDebug_DEMCR_DWTENA_Pos) /*!< \deprecated CoreDebug DEMCR: DWTENA Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MBL_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv8mml.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv8mml.h new file mode 100644 index 0000000000..71f000bcad --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_armv8mml.h @@ -0,0 +1,3196 @@ +/**************************************************************************//** + * @file core_armv8mml.h + * @brief CMSIS Armv8-M Mainline Core Peripheral Access Layer Header File + * @version V5.2.0 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_ARMV8MML_H_GENERIC +#define __CORE_ARMV8MML_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_ARMv8MML + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS Armv8MML definitions */ +#define __ARMv8MML_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __ARMv8MML_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __ARMv8MML_CMSIS_VERSION ((__ARMv8MML_CMSIS_VERSION_MAIN << 16U) | \ + __ARMv8MML_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (80U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MML_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_ARMV8MML_H_DEPENDANT +#define __CORE_ARMV8MML_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __ARMv8MML_REV + #define __ARMv8MML_REV 0x0000U + #warning "__ARMv8MML_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group ARMv8MML */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED3[92U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_ARMV8MML_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm0.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm0.h new file mode 100644 index 0000000000..6441ff3419 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm0.h @@ -0,0 +1,952 @@ +/**************************************************************************//** + * @file core_cm0.h + * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File + * @version V5.0.8 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0_H_GENERIC +#define __CORE_CM0_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M0 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0 definitions */ +#define __CM0_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ + __CM0_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0_H_DEPENDANT +#define __CORE_CM0_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0_REV + #define __CM0_REV 0x0000U + #warning "__CM0_REV not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M0 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + uint32_t RESERVED0; + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + Address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ + /* ARM Application Note 321 states that the M0 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm0plus.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm0plus.h new file mode 100644 index 0000000000..4e7179a614 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm0plus.h @@ -0,0 +1,1087 @@ +/**************************************************************************//** + * @file core_cm0plus.h + * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File + * @version V5.0.9 + * @date 21. August 2019 + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM0PLUS_H_GENERIC +#define __CORE_CM0PLUS_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex-M0+ + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM0+ definitions */ +#define __CM0PLUS_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM0PLUS_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ + __CM0PLUS_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (0U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM0PLUS_H_DEPENDANT +#define __CORE_CM0PLUS_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM0PLUS_REV + #define __CM0PLUS_REV 0x0000U + #warning "__CM0PLUS_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex-M0+ */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 8U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0xFFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M0+ Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M0+ header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0+ */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + *(vectors + (int32_t)IRQn) = vector; /* use pointer arithmetic to access vector */ +#endif + /* ARM Application Note 321 states that the M0+ does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +#else + uint32_t *vectors = (uint32_t *)(NVIC_USER_IRQ_OFFSET << 2); /* point to 1st user interrupt */ + return *(vectors + (int32_t)IRQn); /* use pointer arithmetic to access vector */ +#endif +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM0PLUS_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm1.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm1.h new file mode 100644 index 0000000000..76b4569743 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm1.h @@ -0,0 +1,979 @@ +/**************************************************************************//** + * @file core_cm1.h + * @brief CMSIS Cortex-M1 Core Peripheral Access Layer Header File + * @version V1.0.1 + * @date 12. November 2018 + ******************************************************************************/ +/* + * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM1_H_GENERIC +#define __CORE_CM1_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M1 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM1 definitions */ +#define __CM1_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM1_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM1_CMSIS_VERSION ((__CM1_CMSIS_VERSION_MAIN << 16U) | \ + __CM1_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (1U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM1_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM1_H_DEPENDANT +#define __CORE_CM1_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM1_REV + #define __CM1_REV 0x0100U + #warning "__CM1_REV not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M1 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + uint32_t RESERVED0; + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_ITCMUAEN_Pos 4U /*!< ACTLR: Instruction TCM Upper Alias Enable Position */ +#define SCnSCB_ACTLR_ITCMUAEN_Msk (1UL << SCnSCB_ACTLR_ITCMUAEN_Pos) /*!< ACTLR: Instruction TCM Upper Alias Enable Mask */ + +#define SCnSCB_ACTLR_ITCMLAEN_Pos 3U /*!< ACTLR: Instruction TCM Lower Alias Enable Position */ +#define SCnSCB_ACTLR_ITCMLAEN_Msk (1UL << SCnSCB_ACTLR_ITCMLAEN_Pos) /*!< ACTLR: Instruction TCM Lower Alias Enable Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Cortex-M1 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the Cortex-M1 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M1 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + Address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)0x0U; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M1 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)0x0U; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM1_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm23.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm23.h new file mode 100644 index 0000000000..55fff99509 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm23.h @@ -0,0 +1,2297 @@ +/**************************************************************************//** + * @file core_cm23.h + * @brief CMSIS Cortex-M23 Core Peripheral Access Layer Header File + * @version V5.1.0 + * @date 11. February 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM23_H_GENERIC +#define __CORE_CM23_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M23 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS definitions */ +#define __CM23_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM23_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM23_CMSIS_VERSION ((__CM23_CMSIS_VERSION_MAIN << 16U) | \ + __CM23_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (23U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM23_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM23_H_DEPENDANT +#define __CORE_CM23_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM23_REV + #define __CM23_REV 0x0000U + #warning "__CM23_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif + + #ifndef __ETM_PRESENT + #define __ETM_PRESENT 0U + #warning "__ETM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MTB_PRESENT + #define __MTB_PRESENT 0U + #warning "__MTB_PRESENT not defined in device header file; using default!" + #endif + +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M23 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint32_t IPR[124U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ +#else + uint32_t RESERVED0; +#endif + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED1; + __IOM uint32_t SHPR[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + uint32_t RESERVED0[6U]; + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x3UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + uint32_t RESERVED0[7U]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 1U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: EN Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: EN Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#endif +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register */ +#define CoreDebug_DEMCR_DWTENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: DWTENA Position */ +#define CoreDebug_DEMCR_DWTENA_Msk (1UL << CoreDebug_DEMCR_DWTENA_Pos) /*!< \deprecated CoreDebug DEMCR: DWTENA Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else +/*#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping not available for Cortex-M23 */ +/*#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping not available for Cortex-M23 */ + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + +#define __NVIC_SetPriorityGrouping(X) (void)(X) +#define __NVIC_GetPriorityGrouping() (0U) + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + If VTOR is not present address 0 must be mapped to SRAM. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ +#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U) + uint32_t *vectors = (uint32_t *)SCB->VTOR; +#else + uint32_t *vectors = (uint32_t *)0x0U; +#endif + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM23_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm3.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm3.h new file mode 100644 index 0000000000..24453a8863 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm3.h @@ -0,0 +1,1943 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V5.1.1 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM3_H_GENERIC +#define __CORE_CM3_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M3 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (3U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM3_H_DEPENDANT +#define __CORE_CM3_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM3_REV + #define __CM3_REV 0x0200U + #warning "__CM3_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M3 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV < 0x0201U) /* core r2p1 */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#else +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ +#endif + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +#else + uint32_t RESERVED1[1U]; +#endif +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#if defined (__CM3_REV) && (__CM3_REV >= 0x200U) +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ +#endif + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM3_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm33.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm33.h new file mode 100644 index 0000000000..13359be3ed --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm33.h @@ -0,0 +1,3264 @@ +/**************************************************************************//** + * @file core_cm33.h + * @brief CMSIS Cortex-M33 Core Peripheral Access Layer Header File + * @version V5.2.0 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM33_H_GENERIC +#define __CORE_CM33_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M33 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM33 definitions */ +#define __CM33_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM33_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM33_CMSIS_VERSION ((__CM33_CMSIS_VERSION_MAIN << 16U) | \ + __CM33_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (33U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM33_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM33_H_DEPENDANT +#define __CORE_CM33_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM33_REV + #define __CM33_REV 0x0000U + #warning "__CM33_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M33 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED3[92U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM33_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm35p.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm35p.h new file mode 100644 index 0000000000..6a5f6ad147 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm35p.h @@ -0,0 +1,3264 @@ +/**************************************************************************//** + * @file core_cm35p.h + * @brief CMSIS Cortex-M35P Core Peripheral Access Layer Header File + * @version V1.1.0 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2018-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM35P_H_GENERIC +#define __CORE_CM35P_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M35P + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM35P definitions */ +#define __CM35P_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM35P_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM35P_CMSIS_VERSION ((__CM35P_CMSIS_VERSION_MAIN << 16U) | \ + __CM35P_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (35U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined (__TARGET_FPU_VFP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined (__ARM_FP) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined (__ARMVFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1U) + #if defined (__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined (__TI_VFP_SUPPORT__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined (__FPU_VFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM35P_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM35P_H_DEPENDANT +#define __CORE_CM35P_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM35P_REV + #define __CM35P_REV 0x0000U + #warning "__CM35P_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M35P */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED3[92U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CPn_Pos 0U /*!< SCB NSACR: CPn Position */ +#define SCB_NSACR_CPn_Msk (1UL /*<< SCB_NSACR_CPn_Pos*/) /*!< SCB NSACR: CPn Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[4U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t ITFTTD0; /*!< Offset: 0xEEC (R/ ) Integration Test FIFO Test Data 0 Register */ + __IOM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/W) Integration Test ATB Control Register 2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) Integration Test ATB Control Register 0 */ + __IM uint32_t ITFTTD1; /*!< Offset: 0xEFC (R/ ) Integration Test FIFO Test Data 1 Register */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) Device Configuration Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Identifier Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration Test FIFO Test Data 0 Register Definitions */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD0: ATB Interface 2 ATVALIDPosition */ +#define TPI_ITFTTD0_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD0: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD0_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD0_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD0: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD0_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD0: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD0_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD0_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD0: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data2_Pos 16U /*!< TPI ITFTTD0: ATB Interface 1 data2 Position */ +#define TPI_ITFTTD0_ATB_IF1_data2_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data2 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data1_Pos 8U /*!< TPI ITFTTD0: ATB Interface 1 data1 Position */ +#define TPI_ITFTTD0_ATB_IF1_data1_Msk (0xFFUL << TPI_ITFTTD0_ATB_IF1_data1_Pos) /*!< TPI ITFTTD0: ATB Interface 1 data1 Mask */ + +#define TPI_ITFTTD0_ATB_IF1_data0_Pos 0U /*!< TPI ITFTTD0: ATB Interface 1 data0 Position */ +#define TPI_ITFTTD0_ATB_IF1_data0_Msk (0xFFUL /*<< TPI_ITFTTD0_ATB_IF1_data0_Pos*/) /*!< TPI ITFTTD0: ATB Interface 1 data0 Mask */ + +/* TPI Integration Test ATB Control Register 2 Register Definitions */ +#define TPI_ITATBCTR2_AFVALID2S_Pos 1U /*!< TPI ITATBCTR2: AFVALID2S Position */ +#define TPI_ITATBCTR2_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID2S_Pos) /*!< TPI ITATBCTR2: AFVALID2SS Mask */ + +#define TPI_ITATBCTR2_AFVALID1S_Pos 1U /*!< TPI ITATBCTR2: AFVALID1S Position */ +#define TPI_ITATBCTR2_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR2_AFVALID1S_Pos) /*!< TPI ITATBCTR2: AFVALID1SS Mask */ + +#define TPI_ITATBCTR2_ATREADY2S_Pos 0U /*!< TPI ITATBCTR2: ATREADY2S Position */ +#define TPI_ITATBCTR2_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2S_Pos*/) /*!< TPI ITATBCTR2: ATREADY2S Mask */ + +#define TPI_ITATBCTR2_ATREADY1S_Pos 0U /*!< TPI ITATBCTR2: ATREADY1S Position */ +#define TPI_ITATBCTR2_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1S_Pos*/) /*!< TPI ITATBCTR2: ATREADY1S Mask */ + +/* TPI Integration Test FIFO Test Data 1 Register Definitions */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Pos 29U /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF2_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 2 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF2_bytecount_Pos 27U /*!< TPI ITFTTD1: ATB Interface 2 byte count Position */ +#define TPI_ITFTTD1_ATB_IF2_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF2_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 2 byte count Mask */ + +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Pos 26U /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Position */ +#define TPI_ITFTTD1_ATB_IF1_ATVALID_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_ATVALID_Pos) /*!< TPI ITFTTD1: ATB Interface 1 ATVALID Mask */ + +#define TPI_ITFTTD1_ATB_IF1_bytecount_Pos 24U /*!< TPI ITFTTD1: ATB Interface 1 byte count Position */ +#define TPI_ITFTTD1_ATB_IF1_bytecount_Msk (0x3UL << TPI_ITFTTD1_ATB_IF1_bytecount_Pos) /*!< TPI ITFTTD1: ATB Interface 1 byte countt Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data2_Pos 16U /*!< TPI ITFTTD1: ATB Interface 2 data2 Position */ +#define TPI_ITFTTD1_ATB_IF2_data2_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data2 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data1_Pos 8U /*!< TPI ITFTTD1: ATB Interface 2 data1 Position */ +#define TPI_ITFTTD1_ATB_IF2_data1_Msk (0xFFUL << TPI_ITFTTD1_ATB_IF2_data1_Pos) /*!< TPI ITFTTD1: ATB Interface 2 data1 Mask */ + +#define TPI_ITFTTD1_ATB_IF2_data0_Pos 0U /*!< TPI ITFTTD1: ATB Interface 2 data0 Position */ +#define TPI_ITFTTD1_ATB_IF2_data0_Msk (0xFFUL /*<< TPI_ITFTTD1_ATB_IF2_data0_Pos*/) /*!< TPI ITFTTD1: ATB Interface 2 data0 Mask */ + +/* TPI Integration Test ATB Control Register 0 Definitions */ +#define TPI_ITATBCTR0_AFVALID2S_Pos 1U /*!< TPI ITATBCTR0: AFVALID2S Position */ +#define TPI_ITATBCTR0_AFVALID2S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID2S_Pos) /*!< TPI ITATBCTR0: AFVALID2SS Mask */ + +#define TPI_ITATBCTR0_AFVALID1S_Pos 1U /*!< TPI ITATBCTR0: AFVALID1S Position */ +#define TPI_ITATBCTR0_AFVALID1S_Msk (0x1UL << TPI_ITATBCTR0_AFVALID1S_Pos) /*!< TPI ITATBCTR0: AFVALID1SS Mask */ + +#define TPI_ITATBCTR0_ATREADY2S_Pos 0U /*!< TPI ITATBCTR0: ATREADY2S Position */ +#define TPI_ITATBCTR0_ATREADY2S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2S_Pos*/) /*!< TPI ITATBCTR0: ATREADY2S Mask */ + +#define TPI_ITATBCTR0_ATREADY1S_Pos 0U /*!< TPI ITATBCTR0: ATREADY1S Position */ +#define TPI_ITATBCTR0_ATREADY1S_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1S_Pos*/) /*!< TPI ITATBCTR0: ATREADY1S Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFOSZ Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFOSZ Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x3FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (0x7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM35P_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm4.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm4.h new file mode 100644 index 0000000000..4e0e886697 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm4.h @@ -0,0 +1,2129 @@ +/**************************************************************************//** + * @file core_cm4.h + * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File + * @version V5.1.1 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM4_H_GENERIC +#define __CORE_CM4_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M4 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM4 definitions */ +#define __CM4_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM4_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ + __CM4_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (4U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM4_H_DEPENDANT +#define __CORE_CM4_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM4_REV + #define __CM4_REV 0x0000U + #warning "__CM4_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M4 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISOOFP_Pos 9U /*!< ACTLR: DISOOFP Position */ +#define SCnSCB_ACTLR_DISOOFP_Msk (1UL << SCnSCB_ACTLR_DISOOFP_Pos) /*!< ACTLR: DISOOFP Mask */ + +#define SCnSCB_ACTLR_DISFPCA_Pos 8U /*!< ACTLR: DISFPCA Position */ +#define SCnSCB_ACTLR_DISFPCA_Msk (1UL << SCnSCB_ACTLR_DISFPCA_Pos) /*!< ACTLR: DISFPCA Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and FP Feature Register 2 Definitions */ + +#define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ +#define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ +#define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M4 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM4_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm55.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm55.h new file mode 100644 index 0000000000..6efaa3f842 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm55.h @@ -0,0 +1,4215 @@ +/**************************************************************************//** + * @file core_cm55.h + * @brief CMSIS Cortex-M55 Core Peripheral Access Layer Header File + * @version V1.0.0 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2018-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#elif defined ( __GNUC__ ) + #pragma GCC diagnostic ignored "-Wpedantic" /* disable pedantic warning due to unnamed structs/unions */ +#endif + +#ifndef __CORE_CM55_H_GENERIC +#define __CORE_CM55_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_CM55 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM55 definitions */ +#define __CM55_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM55_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM55_CMSIS_VERSION ((__CM55_CMSIS_VERSION_MAIN << 16U) | \ + __CM55_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (55U) /*!< Cortex-M Core */ + +#if defined ( __CC_ARM ) + #error Legacy Arm Compiler does not support Armv8.1-M target architecture. +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + + #if defined(__ARM_FEATURE_DSP) + #if defined(__DSP_PRESENT) && (__DSP_PRESENT == 1U) + #define __DSP_USED 1U + #else + #error "Compiler generates DSP (SIMD) instructions for a devices without DSP extensions (check __DSP_PRESENT)" + #define __DSP_USED 0U + #endif + #else + #define __DSP_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM55_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM55_H_DEPENDANT +#define __CORE_CM55_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM55_REV + #define __CM55_REV 0x0000U + #warning "__CM55_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #if __FPU_PRESENT != 0U + #ifndef __FPU_DP + #define __FPU_DP 0U + #warning "__FPU_DP not defined in device header file; using default!" + #endif + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __PMU_PRESENT + #define __PMU_PRESENT 0U + #warning "__PMU_PRESENT not defined in device header file; using default!" + #endif + + #if __PMU_PRESENT != 0U + #ifndef __PMU_NUM_EVENTCNT + #define __PMU_NUM_EVENTCNT 8U + #warning "__PMU_NUM_EVENTCNT not defined in device header file; using default!" + #elif (__PMU_NUM_EVENTCNT > 8 || __PMU_NUM_EVENTCNT < 2) + #error "__PMU_NUM_EVENTCNT is out of range in device header file!" */ + #endif + #endif + + #ifndef __SAUREGION_PRESENT + #define __SAUREGION_PRESENT 0U + #warning "__SAUREGION_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DSP_PRESENT + #define __DSP_PRESENT 0U + #warning "__DSP_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M55 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core SAU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:7; /*!< bit: 9..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t IT:2; /*!< bit: 25..26 saved IT state (read 0) */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_IT_Pos 25U /*!< xPSR: IT Position */ +#define xPSR_IT_Msk (3UL << xPSR_IT_Pos) /*!< xPSR: IT Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack-pointer select */ + uint32_t FPCA:1; /*!< bit: 2 Floating-point context active */ + uint32_t SFPA:1; /*!< bit: 3 Secure floating-point active */ + uint32_t _reserved1:28; /*!< bit: 4..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SFPA_Pos 3U /*!< CONTROL: SFPA Position */ +#define CONTROL_SFPA_Msk (1UL << CONTROL_SFPA_Pos) /*!< CONTROL: SFPA Mask */ + +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[16U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[16U]; + __IOM uint32_t ICER[16U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[16U]; + __IOM uint32_t ISPR[16U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[16U]; + __IOM uint32_t ICPR[16U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[16U]; + __IOM uint32_t IABR[16U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[16U]; + __IOM uint32_t ITNS[16U]; /*!< Offset: 0x280 (R/W) Interrupt Non-Secure State Register */ + uint32_t RESERVED5[16U]; + __IOM uint8_t IPR[496U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED6[580U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[6U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + __IOM uint32_t NSACR; /*!< Offset: 0x08C (R/W) Non-Secure Access Control Register */ + uint32_t RESERVED3[92U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + __IOM uint32_t RFSR; /*!< Offset: 0x204 (R/W) RAS Fault Status Register */ + uint32_t RESERVED4[14U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + __OM uint32_t BPIALL; /*!< Offset: 0x278 ( /W) Branch Predictor Invalidate All */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_PENDNMISET_Pos 31U /*!< SCB ICSR: PENDNMISET Position */ +#define SCB_ICSR_PENDNMISET_Msk (1UL << SCB_ICSR_PENDNMISET_Pos) /*!< SCB ICSR: PENDNMISET Mask */ + +#define SCB_ICSR_NMIPENDSET_Pos SCB_ICSR_PENDNMISET_Pos /*!< SCB ICSR: NMIPENDSET Position, backward compatibility */ +#define SCB_ICSR_NMIPENDSET_Msk SCB_ICSR_PENDNMISET_Msk /*!< SCB ICSR: NMIPENDSET Mask, backward compatibility */ + +#define SCB_ICSR_PENDNMICLR_Pos 30U /*!< SCB ICSR: PENDNMICLR Position */ +#define SCB_ICSR_PENDNMICLR_Msk (1UL << SCB_ICSR_PENDNMICLR_Pos) /*!< SCB ICSR: PENDNMICLR Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_STTNS_Pos 24U /*!< SCB ICSR: STTNS Position (Security Extension) */ +#define SCB_ICSR_STTNS_Msk (1UL << SCB_ICSR_STTNS_Pos) /*!< SCB ICSR: STTNS Mask (Security Extension) */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIS_Pos 14U /*!< SCB AIRCR: PRIS Position */ +#define SCB_AIRCR_PRIS_Msk (1UL << SCB_AIRCR_PRIS_Pos) /*!< SCB AIRCR: PRIS Mask */ + +#define SCB_AIRCR_BFHFNMINS_Pos 13U /*!< SCB AIRCR: BFHFNMINS Position */ +#define SCB_AIRCR_BFHFNMINS_Msk (1UL << SCB_AIRCR_BFHFNMINS_Pos) /*!< SCB AIRCR: BFHFNMINS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_IESB_Pos 5U /*!< SCB AIRCR: Implicit ESB Enable Position */ +#define SCB_AIRCR_IESB_Msk (1UL << SCB_AIRCR_IESB_Pos) /*!< SCB AIRCR: Implicit ESB Enable Mask */ + +#define SCB_AIRCR_DIT_Pos 4U /*!< SCB AIRCR: Data Independent Timing Position */ +#define SCB_AIRCR_DIT_Msk (1UL << SCB_AIRCR_DIT_Pos) /*!< SCB AIRCR: Data Independent Timing Mask */ + +#define SCB_AIRCR_SYSRESETREQS_Pos 3U /*!< SCB AIRCR: SYSRESETREQS Position */ +#define SCB_AIRCR_SYSRESETREQS_Msk (1UL << SCB_AIRCR_SYSRESETREQS_Pos) /*!< SCB AIRCR: SYSRESETREQS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEPS_Pos 3U /*!< SCB SCR: SLEEPDEEPS Position */ +#define SCB_SCR_SLEEPDEEPS_Msk (1UL << SCB_SCR_SLEEPDEEPS_Pos) /*!< SCB SCR: SLEEPDEEPS Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_TRD_Pos 20U /*!< SCB CCR: TRD Position */ +#define SCB_CCR_TRD_Msk (1UL << SCB_CCR_TRD_Pos) /*!< SCB CCR: TRD Mask */ + +#define SCB_CCR_LOB_Pos 19U /*!< SCB CCR: LOB Position */ +#define SCB_CCR_LOB_Msk (1UL << SCB_CCR_LOB_Pos) /*!< SCB CCR: LOB Mask */ + +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: BP Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: BP Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: IC Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: IC Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: DC Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: DC Mask */ + +#define SCB_CCR_STKOFHFNMIGN_Pos 10U /*!< SCB CCR: STKOFHFNMIGN Position */ +#define SCB_CCR_STKOFHFNMIGN_Msk (1UL << SCB_CCR_STKOFHFNMIGN_Pos) /*!< SCB CCR: STKOFHFNMIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_HARDFAULTPENDED_Pos 21U /*!< SCB SHCSR: HARDFAULTPENDED Position */ +#define SCB_SHCSR_HARDFAULTPENDED_Msk (1UL << SCB_SHCSR_HARDFAULTPENDED_Pos) /*!< SCB SHCSR: HARDFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTPENDED_Pos 20U /*!< SCB SHCSR: SECUREFAULTPENDED Position */ +#define SCB_SHCSR_SECUREFAULTPENDED_Msk (1UL << SCB_SHCSR_SECUREFAULTPENDED_Pos) /*!< SCB SHCSR: SECUREFAULTPENDED Mask */ + +#define SCB_SHCSR_SECUREFAULTENA_Pos 19U /*!< SCB SHCSR: SECUREFAULTENA Position */ +#define SCB_SHCSR_SECUREFAULTENA_Msk (1UL << SCB_SHCSR_SECUREFAULTENA_Pos) /*!< SCB SHCSR: SECUREFAULTENA Mask */ + +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_NMIACT_Pos 5U /*!< SCB SHCSR: NMIACT Position */ +#define SCB_SHCSR_NMIACT_Msk (1UL << SCB_SHCSR_NMIACT_Pos) /*!< SCB SHCSR: NMIACT Mask */ + +#define SCB_SHCSR_SECUREFAULTACT_Pos 4U /*!< SCB SHCSR: SECUREFAULTACT Position */ +#define SCB_SHCSR_SECUREFAULTACT_Msk (1UL << SCB_SHCSR_SECUREFAULTACT_Pos) /*!< SCB SHCSR: SECUREFAULTACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_HARDFAULTACT_Pos 2U /*!< SCB SHCSR: HARDFAULTACT Position */ +#define SCB_SHCSR_HARDFAULTACT_Msk (1UL << SCB_SHCSR_HARDFAULTACT_Pos) /*!< SCB SHCSR: HARDFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_STKOF_Pos (SCB_CFSR_USGFAULTSR_Pos + 4U) /*!< SCB CFSR (UFSR): STKOF Position */ +#define SCB_CFSR_STKOF_Msk (1UL << SCB_CFSR_STKOF_Pos) /*!< SCB CFSR (UFSR): STKOF Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_PMU_Pos 5U /*!< SCB DFSR: PMU Position */ +#define SCB_DFSR_PMU_Msk (1UL << SCB_DFSR_PMU_Pos) /*!< SCB DFSR: PMU Mask */ + +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Non-Secure Access Control Register Definitions */ +#define SCB_NSACR_CP11_Pos 11U /*!< SCB NSACR: CP11 Position */ +#define SCB_NSACR_CP11_Msk (1UL << SCB_NSACR_CP11_Pos) /*!< SCB NSACR: CP11 Mask */ + +#define SCB_NSACR_CP10_Pos 10U /*!< SCB NSACR: CP10 Position */ +#define SCB_NSACR_CP10_Msk (1UL << SCB_NSACR_CP10_Pos) /*!< SCB NSACR: CP10 Mask */ + +#define SCB_NSACR_CP7_Pos 7U /*!< SCB NSACR: CP7 Position */ +#define SCB_NSACR_CP7_Msk (1UL << SCB_NSACR_CP7_Pos) /*!< SCB NSACR: CP7 Mask */ + +#define SCB_NSACR_CP6_Pos 6U /*!< SCB NSACR: CP6 Position */ +#define SCB_NSACR_CP6_Msk (1UL << SCB_NSACR_CP6_Pos) /*!< SCB NSACR: CP6 Mask */ + +#define SCB_NSACR_CP5_Pos 5U /*!< SCB NSACR: CP5 Position */ +#define SCB_NSACR_CP5_Msk (1UL << SCB_NSACR_CP5_Pos) /*!< SCB NSACR: CP5 Mask */ + +#define SCB_NSACR_CP4_Pos 4U /*!< SCB NSACR: CP4 Position */ +#define SCB_NSACR_CP4_Msk (1UL << SCB_NSACR_CP4_Pos) /*!< SCB NSACR: CP4 Mask */ + +#define SCB_NSACR_CP3_Pos 3U /*!< SCB NSACR: CP3 Position */ +#define SCB_NSACR_CP3_Msk (1UL << SCB_NSACR_CP3_Pos) /*!< SCB NSACR: CP3 Mask */ + +#define SCB_NSACR_CP2_Pos 2U /*!< SCB NSACR: CP2 Position */ +#define SCB_NSACR_CP2_Msk (1UL << SCB_NSACR_CP2_Pos) /*!< SCB NSACR: CP2 Mask */ + +#define SCB_NSACR_CP1_Pos 1U /*!< SCB NSACR: CP1 Position */ +#define SCB_NSACR_CP1_Msk (1UL << SCB_NSACR_CP1_Pos) /*!< SCB NSACR: CP1 Mask */ + +#define SCB_NSACR_CP0_Pos 0U /*!< SCB NSACR: CP0 Position */ +#define SCB_NSACR_CP0_Msk (1UL /*<< SCB_NSACR_CP0_Pos*/) /*!< SCB NSACR: CP0 Mask */ + +/* SCB Debug Feature Register 0 Definitions */ +#define SCB_ID_DFR_UDE_Pos 28U /*!< SCB ID_DFR: UDE Position */ +#define SCB_ID_DFR_UDE_Msk (0xFUL << SCB_ID_DFR_UDE_Pos) /*!< SCB ID_DFR: UDE Mask */ + +#define SCB_ID_DFR_MProfDbg_Pos 20U /*!< SCB ID_DFR: MProfDbg Position */ +#define SCB_ID_DFR_MProfDbg_Msk (0xFUL << SCB_ID_DFR_MProfDbg_Pos) /*!< SCB ID_DFR: MProfDbg Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB RAS Fault Status Register Definitions */ +#define SCB_RFSR_V_Pos 31U /*!< SCB RFSR: V Position */ +#define SCB_RFSR_V_Msk (1UL << SCB_RFSR_V_Pos) /*!< SCB RFSR: V Mask */ + +#define SCB_RFSR_IS_Pos 16U /*!< SCB RFSR: IS Position */ +#define SCB_RFSR_IS_Msk (0x7FFFUL << SCB_RFSR_IS_Pos) /*!< SCB RFSR: IS Mask */ + +#define SCB_RFSR_UET_Pos 0U /*!< SCB RFSR: UET Position */ +#define SCB_RFSR_UET_Msk (3UL /*<< SCB_RFSR_UET_Pos*/) /*!< SCB RFSR: UET Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ + __IOM uint32_t CPPWR; /*!< Offset: 0x00C (R/W) Coprocessor Power Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) ITM Device Architecture Register */ + uint32_t RESERVED6[3U]; + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) ITM Device Type Register */ + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Stimulus Port Register Definitions */ +#define ITM_STIM_DISABLED_Pos 1U /*!< ITM STIM: DISABLED Position */ +#define ITM_STIM_DISABLED_Msk (0x1UL << ITM_STIM_DISABLED_Pos) /*!< ITM STIM: DISABLED Mask */ + +#define ITM_STIM_FIFOREADY_Pos 0U /*!< ITM STIM: FIFOREADY Position */ +#define ITM_STIM_FIFOREADY_Msk (0x1UL /*<< ITM_STIM_FIFOREADY_Pos*/) /*!< ITM STIM: FIFOREADY Mask */ + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TRACEBUSID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TRACEBUSID_Msk (0x7FUL << ITM_TCR_TRACEBUSID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPRESCALE_Pos 8U /*!< ITM TCR: TSPRESCALE Position */ +#define ITM_TCR_TSPRESCALE_Msk (3UL << ITM_TCR_TSPRESCALE_Pos) /*!< ITM TCR: TSPRESCALE Mask */ + +#define ITM_TCR_STALLENA_Pos 5U /*!< ITM TCR: STALLENA Position */ +#define ITM_TCR_STALLENA_Msk (1UL << ITM_TCR_STALLENA_Pos) /*!< ITM TCR: STALLENA Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + uint32_t RESERVED3[1U]; + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED4[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + uint32_t RESERVED5[1U]; + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED6[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + uint32_t RESERVED7[1U]; + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED8[1U]; + __IOM uint32_t COMP4; /*!< Offset: 0x060 (R/W) Comparator Register 4 */ + uint32_t RESERVED9[1U]; + __IOM uint32_t FUNCTION4; /*!< Offset: 0x068 (R/W) Function Register 4 */ + uint32_t RESERVED10[1U]; + __IOM uint32_t COMP5; /*!< Offset: 0x070 (R/W) Comparator Register 5 */ + uint32_t RESERVED11[1U]; + __IOM uint32_t FUNCTION5; /*!< Offset: 0x078 (R/W) Function Register 5 */ + uint32_t RESERVED12[1U]; + __IOM uint32_t COMP6; /*!< Offset: 0x080 (R/W) Comparator Register 6 */ + uint32_t RESERVED13[1U]; + __IOM uint32_t FUNCTION6; /*!< Offset: 0x088 (R/W) Function Register 6 */ + uint32_t RESERVED14[1U]; + __IOM uint32_t COMP7; /*!< Offset: 0x090 (R/W) Comparator Register 7 */ + uint32_t RESERVED15[1U]; + __IOM uint32_t FUNCTION7; /*!< Offset: 0x098 (R/W) Function Register 7 */ + uint32_t RESERVED16[1U]; + __IOM uint32_t COMP8; /*!< Offset: 0x0A0 (R/W) Comparator Register 8 */ + uint32_t RESERVED17[1U]; + __IOM uint32_t FUNCTION8; /*!< Offset: 0x0A8 (R/W) Function Register 8 */ + uint32_t RESERVED18[1U]; + __IOM uint32_t COMP9; /*!< Offset: 0x0B0 (R/W) Comparator Register 9 */ + uint32_t RESERVED19[1U]; + __IOM uint32_t FUNCTION9; /*!< Offset: 0x0B8 (R/W) Function Register 9 */ + uint32_t RESERVED20[1U]; + __IOM uint32_t COMP10; /*!< Offset: 0x0C0 (R/W) Comparator Register 10 */ + uint32_t RESERVED21[1U]; + __IOM uint32_t FUNCTION10; /*!< Offset: 0x0C8 (R/W) Function Register 10 */ + uint32_t RESERVED22[1U]; + __IOM uint32_t COMP11; /*!< Offset: 0x0D0 (R/W) Comparator Register 11 */ + uint32_t RESERVED23[1U]; + __IOM uint32_t FUNCTION11; /*!< Offset: 0x0D8 (R/W) Function Register 11 */ + uint32_t RESERVED24[1U]; + __IOM uint32_t COMP12; /*!< Offset: 0x0E0 (R/W) Comparator Register 12 */ + uint32_t RESERVED25[1U]; + __IOM uint32_t FUNCTION12; /*!< Offset: 0x0E8 (R/W) Function Register 12 */ + uint32_t RESERVED26[1U]; + __IOM uint32_t COMP13; /*!< Offset: 0x0F0 (R/W) Comparator Register 13 */ + uint32_t RESERVED27[1U]; + __IOM uint32_t FUNCTION13; /*!< Offset: 0x0F8 (R/W) Function Register 13 */ + uint32_t RESERVED28[1U]; + __IOM uint32_t COMP14; /*!< Offset: 0x100 (R/W) Comparator Register 14 */ + uint32_t RESERVED29[1U]; + __IOM uint32_t FUNCTION14; /*!< Offset: 0x108 (R/W) Function Register 14 */ + uint32_t RESERVED30[1U]; + __IOM uint32_t COMP15; /*!< Offset: 0x110 (R/W) Comparator Register 15 */ + uint32_t RESERVED31[1U]; + __IOM uint32_t FUNCTION15; /*!< Offset: 0x118 (R/W) Function Register 15 */ + uint32_t RESERVED32[934U]; + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ + uint32_t RESERVED33[1U]; + __IM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/ ) Device Architecture Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCDISS_Pos 23U /*!< DWT CTRL: CYCDISS Position */ +#define DWT_CTRL_CYCDISS_Msk (0x1UL << DWT_CTRL_CYCDISS_Pos) /*!< DWT CTRL: CYCDISS Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_ID_Pos 27U /*!< DWT FUNCTION: ID Position */ +#define DWT_FUNCTION_ID_Msk (0x1FUL << DWT_FUNCTION_ID_Pos) /*!< DWT FUNCTION: ID Mask */ + +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_ACTION_Pos 4U /*!< DWT FUNCTION: ACTION Position */ +#define DWT_FUNCTION_ACTION_Msk (0x1UL << DWT_FUNCTION_ACTION_Pos) /*!< DWT FUNCTION: ACTION Mask */ + +#define DWT_FUNCTION_MATCH_Pos 0U /*!< DWT FUNCTION: MATCH Position */ +#define DWT_FUNCTION_MATCH_Msk (0xFUL /*<< DWT_FUNCTION_MATCH_Pos*/) /*!< DWT FUNCTION: MATCH Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Sizes Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Sizes Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IOM uint32_t PSCR; /*!< Offset: 0x308 (R/W) Periodic Synchronization Control Register */ + uint32_t RESERVED3[809U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) Software Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) Software Lock Status Register */ + uint32_t RESERVED4[4U]; + __IM uint32_t TYPE; /*!< Offset: 0xFC8 (R/ ) Device Identifier Register */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) Device Type Register */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_SWOSCALER_Pos 0U /*!< TPI ACPR: SWOSCALER Position */ +#define TPI_ACPR_SWOSCALER_Msk (0xFFFFUL /*<< TPI_ACPR_SWOSCALER_Pos*/) /*!< TPI ACPR: SWOSCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_FOnMan_Pos 6U /*!< TPI FFCR: FOnMan Position */ +#define TPI_FFCR_FOnMan_Msk (0x1UL << TPI_FFCR_FOnMan_Pos) /*!< TPI FFCR: FOnMan Mask */ + +#define TPI_FFCR_EnFmt_Pos 0U /*!< TPI FFCR: EnFmt Position */ +#define TPI_FFCR_EnFmt_Msk (0x3UL << /*TPI_FFCR_EnFmt_Pos*/) /*!< TPI FFCR: EnFmt Mask */ + +/* TPI Periodic Synchronization Control Register Definitions */ +#define TPI_PSCR_PSCount_Pos 0U /*!< TPI PSCR: PSCount Position */ +#define TPI_PSCR_PSCount_Msk (0x1FUL /*<< TPI_PSCR_PSCount_Pos*/) /*!< TPI PSCR: TPSCount Mask */ + +/* TPI Software Lock Status Register Definitions */ +#define TPI_LSR_nTT_Pos 1U /*!< TPI LSR: Not thirty-two bit. Position */ +#define TPI_LSR_nTT_Msk (0x1UL << TPI_LSR_nTT_Pos) /*!< TPI LSR: Not thirty-two bit. Mask */ + +#define TPI_LSR_SLK_Pos 1U /*!< TPI LSR: Software Lock status Position */ +#define TPI_LSR_SLK_Msk (0x1UL << TPI_LSR_SLK_Pos) /*!< TPI LSR: Software Lock status Mask */ + +#define TPI_LSR_SLI_Pos 0U /*!< TPI LSR: Software Lock implemented Position */ +#define TPI_LSR_SLI_Msk (0x1UL /*<< TPI_LSR_SLI_Pos*/) /*!< TPI LSR: Software Lock implemented Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_FIFOSZ_Pos 6U /*!< TPI DEVID: FIFO depth Position */ +#define TPI_DEVID_FIFOSZ_Msk (0x7UL << TPI_DEVID_FIFOSZ_Pos) /*!< TPI DEVID: FIFO depth Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_PMU Performance Monitoring Unit (PMU) + \brief Type definitions for the Performance Monitoring Unit (PMU) + @{ + */ + +/** + \brief Structure type to access the Performance Monitoring Unit (PMU). + */ +typedef struct +{ + __IOM uint32_t EVCNTR[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x0 (R/W) PMU Event Counter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED0[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCNTR; /*!< Offset: 0x7C (R/W) PMU Cycle Counter Register */ + uint32_t RESERVED1[224]; + __IOM uint32_t EVTYPER[__PMU_NUM_EVENTCNT]; /*!< Offset: 0x400 (R/W) PMU Event Type and Filter Registers */ +#if __PMU_NUM_EVENTCNT<31 + uint32_t RESERVED2[31U-__PMU_NUM_EVENTCNT]; +#endif + __IOM uint32_t CCFILTR; /*!< Offset: 0x47C (R/W) PMU Cycle Counter Filter Register */ + uint32_t RESERVED3[480]; + __IOM uint32_t CNTENSET; /*!< Offset: 0xC00 (R/W) PMU Count Enable Set Register */ + uint32_t RESERVED4[7]; + __IOM uint32_t CNTENCLR; /*!< Offset: 0xC20 (R/W) PMU Count Enable Clear Register */ + uint32_t RESERVED5[7]; + __IOM uint32_t INTENSET; /*!< Offset: 0xC40 (R/W) PMU Interrupt Enable Set Register */ + uint32_t RESERVED6[7]; + __IOM uint32_t INTENCLR; /*!< Offset: 0xC60 (R/W) PMU Interrupt Enable Clear Register */ + uint32_t RESERVED7[7]; + __IOM uint32_t OVSCLR; /*!< Offset: 0xC80 (R/W) PMU Overflow Flag Status Clear Register */ + uint32_t RESERVED8[7]; + __IOM uint32_t SWINC; /*!< Offset: 0xCA0 (R/W) PMU Software Increment Register */ + uint32_t RESERVED9[7]; + __IOM uint32_t OVSSET; /*!< Offset: 0xCC0 (R/W) PMU Overflow Flag Status Set Register */ + uint32_t RESERVED10[79]; + __IOM uint32_t TYPE; /*!< Offset: 0xE00 (R/W) PMU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0xE04 (R/W) PMU Control Register */ + uint32_t RESERVED11[108]; + __IOM uint32_t AUTHSTATUS; /*!< Offset: 0xFB8 (R/W) PMU Authentication Status Register */ + __IOM uint32_t DEVARCH; /*!< Offset: 0xFBC (R/W) PMU Device Architecture Register */ + uint32_t RESERVED12[4]; + __IOM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/W) PMU Device Type Register */ + __IOM uint32_t PIDR4; /*!< Offset: 0xFD0 (R/W) PMU Peripheral Identification Register 4 */ + uint32_t RESERVED13[3]; + __IOM uint32_t PIDR0; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 0 */ + __IOM uint32_t PIDR1; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 1 */ + __IOM uint32_t PIDR2; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 2 */ + __IOM uint32_t PIDR3; /*!< Offset: 0xFE0 (R/W) PMU Peripheral Identification Register 3 */ + uint32_t RESERVED14[3]; + __IOM uint32_t CIDR0; /*!< Offset: 0xFF0 (R/W) PMU Component Identification Register 0 */ + __IOM uint32_t CIDR1; /*!< Offset: 0xFF4 (R/W) PMU Component Identification Register 1 */ + __IOM uint32_t CIDR2; /*!< Offset: 0xFF8 (R/W) PMU Component Identification Register 2 */ + __IOM uint32_t CIDR3; /*!< Offset: 0xFFC (R/W) PMU Component Identification Register 3 */ +} PMU_Type; + +/** \brief PMU Event Counter Registers (0-30) Definitions */ + +#define PMU_EVCNTR_CNT_Pos 0U /*!< PMU EVCNTR: Counter Position */ +#define PMU_EVCNTR_CNT_Msk (16UL /*<< PMU_EVCNTRx_CNT_Pos*/) /*!< PMU EVCNTR: Counter Mask */ + +/** \brief PMU Event Type and Filter Registers (0-30) Definitions */ + +#define PMU_EVTYPER_EVENTTOCNT_Pos 0U /*!< PMU EVTYPER: Event to Count Position */ +#define PMU_EVTYPER_EVENTTOCNT_Msk (16UL /*<< EVTYPERx_EVENTTOCNT_Pos*/) /*!< PMU EVTYPER: Event to Count Mask */ + +/** \brief PMU Count Enable Set Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENSET: Event Counter 0 Enable Set Position */ +#define PMU_CNTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENSET_CNT0_ENABLE_Pos*/) /*!< PMU CNTENSET: Event Counter 0 Enable Set Mask */ + +#define PMU_CNTENSET_CNT1_ENABLE_Pos 1U /*!< PMU CNTENSET: Event Counter 1 Enable Set Position */ +#define PMU_CNTENSET_CNT1_ENABLE_Msk (1UL << PMU_CNTENSET_CNT1_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 1 Enable Set Mask */ + +#define PMU_CNTENSET_CNT2_ENABLE_Pos 2U /*!< PMU CNTENSET: Event Counter 2 Enable Set Position */ +#define PMU_CNTENSET_CNT2_ENABLE_Msk (1UL << PMU_CNTENSET_CNT2_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 2 Enable Set Mask */ + +#define PMU_CNTENSET_CNT3_ENABLE_Pos 3U /*!< PMU CNTENSET: Event Counter 3 Enable Set Position */ +#define PMU_CNTENSET_CNT3_ENABLE_Msk (1UL << PMU_CNTENSET_CNT3_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 3 Enable Set Mask */ + +#define PMU_CNTENSET_CNT4_ENABLE_Pos 4U /*!< PMU CNTENSET: Event Counter 4 Enable Set Position */ +#define PMU_CNTENSET_CNT4_ENABLE_Msk (1UL << PMU_CNTENSET_CNT4_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 4 Enable Set Mask */ + +#define PMU_CNTENSET_CNT5_ENABLE_Pos 5U /*!< PMU CNTENSET: Event Counter 5 Enable Set Position */ +#define PMU_CNTENSET_CNT5_ENABLE_Msk (1UL << PMU_CNTENSET_CNT5_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 5 Enable Set Mask */ + +#define PMU_CNTENSET_CNT6_ENABLE_Pos 6U /*!< PMU CNTENSET: Event Counter 6 Enable Set Position */ +#define PMU_CNTENSET_CNT6_ENABLE_Msk (1UL << PMU_CNTENSET_CNT6_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 6 Enable Set Mask */ + +#define PMU_CNTENSET_CNT7_ENABLE_Pos 7U /*!< PMU CNTENSET: Event Counter 7 Enable Set Position */ +#define PMU_CNTENSET_CNT7_ENABLE_Msk (1UL << PMU_CNTENSET_CNT7_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 7 Enable Set Mask */ + +#define PMU_CNTENSET_CNT8_ENABLE_Pos 8U /*!< PMU CNTENSET: Event Counter 8 Enable Set Position */ +#define PMU_CNTENSET_CNT8_ENABLE_Msk (1UL << PMU_CNTENSET_CNT8_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 8 Enable Set Mask */ + +#define PMU_CNTENSET_CNT9_ENABLE_Pos 9U /*!< PMU CNTENSET: Event Counter 9 Enable Set Position */ +#define PMU_CNTENSET_CNT9_ENABLE_Msk (1UL << PMU_CNTENSET_CNT9_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 9 Enable Set Mask */ + +#define PMU_CNTENSET_CNT10_ENABLE_Pos 10U /*!< PMU CNTENSET: Event Counter 10 Enable Set Position */ +#define PMU_CNTENSET_CNT10_ENABLE_Msk (1UL << PMU_CNTENSET_CNT10_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 10 Enable Set Mask */ + +#define PMU_CNTENSET_CNT11_ENABLE_Pos 11U /*!< PMU CNTENSET: Event Counter 11 Enable Set Position */ +#define PMU_CNTENSET_CNT11_ENABLE_Msk (1UL << PMU_CNTENSET_CNT11_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 11 Enable Set Mask */ + +#define PMU_CNTENSET_CNT12_ENABLE_Pos 12U /*!< PMU CNTENSET: Event Counter 12 Enable Set Position */ +#define PMU_CNTENSET_CNT12_ENABLE_Msk (1UL << PMU_CNTENSET_CNT12_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 12 Enable Set Mask */ + +#define PMU_CNTENSET_CNT13_ENABLE_Pos 13U /*!< PMU CNTENSET: Event Counter 13 Enable Set Position */ +#define PMU_CNTENSET_CNT13_ENABLE_Msk (1UL << PMU_CNTENSET_CNT13_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 13 Enable Set Mask */ + +#define PMU_CNTENSET_CNT14_ENABLE_Pos 14U /*!< PMU CNTENSET: Event Counter 14 Enable Set Position */ +#define PMU_CNTENSET_CNT14_ENABLE_Msk (1UL << PMU_CNTENSET_CNT14_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 14 Enable Set Mask */ + +#define PMU_CNTENSET_CNT15_ENABLE_Pos 15U /*!< PMU CNTENSET: Event Counter 15 Enable Set Position */ +#define PMU_CNTENSET_CNT15_ENABLE_Msk (1UL << PMU_CNTENSET_CNT15_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 15 Enable Set Mask */ + +#define PMU_CNTENSET_CNT16_ENABLE_Pos 16U /*!< PMU CNTENSET: Event Counter 16 Enable Set Position */ +#define PMU_CNTENSET_CNT16_ENABLE_Msk (1UL << PMU_CNTENSET_CNT16_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 16 Enable Set Mask */ + +#define PMU_CNTENSET_CNT17_ENABLE_Pos 17U /*!< PMU CNTENSET: Event Counter 17 Enable Set Position */ +#define PMU_CNTENSET_CNT17_ENABLE_Msk (1UL << PMU_CNTENSET_CNT17_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 17 Enable Set Mask */ + +#define PMU_CNTENSET_CNT18_ENABLE_Pos 18U /*!< PMU CNTENSET: Event Counter 18 Enable Set Position */ +#define PMU_CNTENSET_CNT18_ENABLE_Msk (1UL << PMU_CNTENSET_CNT18_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 18 Enable Set Mask */ + +#define PMU_CNTENSET_CNT19_ENABLE_Pos 19U /*!< PMU CNTENSET: Event Counter 19 Enable Set Position */ +#define PMU_CNTENSET_CNT19_ENABLE_Msk (1UL << PMU_CNTENSET_CNT19_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 19 Enable Set Mask */ + +#define PMU_CNTENSET_CNT20_ENABLE_Pos 20U /*!< PMU CNTENSET: Event Counter 20 Enable Set Position */ +#define PMU_CNTENSET_CNT20_ENABLE_Msk (1UL << PMU_CNTENSET_CNT20_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 20 Enable Set Mask */ + +#define PMU_CNTENSET_CNT21_ENABLE_Pos 21U /*!< PMU CNTENSET: Event Counter 21 Enable Set Position */ +#define PMU_CNTENSET_CNT21_ENABLE_Msk (1UL << PMU_CNTENSET_CNT21_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 21 Enable Set Mask */ + +#define PMU_CNTENSET_CNT22_ENABLE_Pos 22U /*!< PMU CNTENSET: Event Counter 22 Enable Set Position */ +#define PMU_CNTENSET_CNT22_ENABLE_Msk (1UL << PMU_CNTENSET_CNT22_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 22 Enable Set Mask */ + +#define PMU_CNTENSET_CNT23_ENABLE_Pos 23U /*!< PMU CNTENSET: Event Counter 23 Enable Set Position */ +#define PMU_CNTENSET_CNT23_ENABLE_Msk (1UL << PMU_CNTENSET_CNT23_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 23 Enable Set Mask */ + +#define PMU_CNTENSET_CNT24_ENABLE_Pos 24U /*!< PMU CNTENSET: Event Counter 24 Enable Set Position */ +#define PMU_CNTENSET_CNT24_ENABLE_Msk (1UL << PMU_CNTENSET_CNT24_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 24 Enable Set Mask */ + +#define PMU_CNTENSET_CNT25_ENABLE_Pos 25U /*!< PMU CNTENSET: Event Counter 25 Enable Set Position */ +#define PMU_CNTENSET_CNT25_ENABLE_Msk (1UL << PMU_CNTENSET_CNT25_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 25 Enable Set Mask */ + +#define PMU_CNTENSET_CNT26_ENABLE_Pos 26U /*!< PMU CNTENSET: Event Counter 26 Enable Set Position */ +#define PMU_CNTENSET_CNT26_ENABLE_Msk (1UL << PMU_CNTENSET_CNT26_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 26 Enable Set Mask */ + +#define PMU_CNTENSET_CNT27_ENABLE_Pos 27U /*!< PMU CNTENSET: Event Counter 27 Enable Set Position */ +#define PMU_CNTENSET_CNT27_ENABLE_Msk (1UL << PMU_CNTENSET_CNT27_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 27 Enable Set Mask */ + +#define PMU_CNTENSET_CNT28_ENABLE_Pos 28U /*!< PMU CNTENSET: Event Counter 28 Enable Set Position */ +#define PMU_CNTENSET_CNT28_ENABLE_Msk (1UL << PMU_CNTENSET_CNT28_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 28 Enable Set Mask */ + +#define PMU_CNTENSET_CNT29_ENABLE_Pos 29U /*!< PMU CNTENSET: Event Counter 29 Enable Set Position */ +#define PMU_CNTENSET_CNT29_ENABLE_Msk (1UL << PMU_CNTENSET_CNT29_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 29 Enable Set Mask */ + +#define PMU_CNTENSET_CNT30_ENABLE_Pos 30U /*!< PMU CNTENSET: Event Counter 30 Enable Set Position */ +#define PMU_CNTENSET_CNT30_ENABLE_Msk (1UL << PMU_CNTENSET_CNT30_ENABLE_Pos) /*!< PMU CNTENSET: Event Counter 30 Enable Set Mask */ + +#define PMU_CNTENSET_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENSET: Cycle Counter Enable Set Position */ +#define PMU_CNTENSET_CCNTR_ENABLE_Msk (1UL << PMU_CNTENSET_CCNTR_ENABLE_Pos) /*!< PMU CNTENSET: Cycle Counter Enable Set Mask */ + +/** \brief PMU Count Enable Clear Register Definitions */ + +#define PMU_CNTENSET_CNT0_ENABLE_Pos 0U /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Position */ +#define PMU_CNTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_CNTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU CNTENCLR: Event Counter 0 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU CNTENCLR: Event Counter 1 Enable Clear Position */ +#define PMU_CNTENCLR_CNT1_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT1_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 1 Enable Clear */ + +#define PMU_CNTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Position */ +#define PMU_CNTENCLR_CNT2_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT2_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 2 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Position */ +#define PMU_CNTENCLR_CNT3_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT3_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 3 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Position */ +#define PMU_CNTENCLR_CNT4_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT4_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 4 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Position */ +#define PMU_CNTENCLR_CNT5_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT5_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 5 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Position */ +#define PMU_CNTENCLR_CNT6_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT6_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 6 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Position */ +#define PMU_CNTENCLR_CNT7_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT7_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 7 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Position */ +#define PMU_CNTENCLR_CNT8_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT8_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 8 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Position */ +#define PMU_CNTENCLR_CNT9_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT9_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 9 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Position */ +#define PMU_CNTENCLR_CNT10_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT10_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 10 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Position */ +#define PMU_CNTENCLR_CNT11_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT11_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 11 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Position */ +#define PMU_CNTENCLR_CNT12_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT12_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 12 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Position */ +#define PMU_CNTENCLR_CNT13_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT13_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 13 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Position */ +#define PMU_CNTENCLR_CNT14_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT14_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 14 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Position */ +#define PMU_CNTENCLR_CNT15_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT15_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 15 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Position */ +#define PMU_CNTENCLR_CNT16_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT16_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 16 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Position */ +#define PMU_CNTENCLR_CNT17_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT17_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 17 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Position */ +#define PMU_CNTENCLR_CNT18_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT18_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 18 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Position */ +#define PMU_CNTENCLR_CNT19_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT19_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 19 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Position */ +#define PMU_CNTENCLR_CNT20_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT20_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 20 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Position */ +#define PMU_CNTENCLR_CNT21_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT21_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 21 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Position */ +#define PMU_CNTENCLR_CNT22_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT22_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 22 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Position */ +#define PMU_CNTENCLR_CNT23_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT23_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 23 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Position */ +#define PMU_CNTENCLR_CNT24_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT24_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 24 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Position */ +#define PMU_CNTENCLR_CNT25_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT25_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 25 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Position */ +#define PMU_CNTENCLR_CNT26_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT26_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 26 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Position */ +#define PMU_CNTENCLR_CNT27_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT27_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 27 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Position */ +#define PMU_CNTENCLR_CNT28_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT28_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 28 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Position */ +#define PMU_CNTENCLR_CNT29_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT29_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 29 Enable Clear Mask */ + +#define PMU_CNTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Position */ +#define PMU_CNTENCLR_CNT30_ENABLE_Msk (1UL << PMU_CNTENCLR_CNT30_ENABLE_Pos) /*!< PMU CNTENCLR: Event Counter 30 Enable Clear Mask */ + +#define PMU_CNTENCLR_CCNTR_ENABLE_Pos 31U /*!< PMU CNTENCLR: Cycle Counter Enable Clear Position */ +#define PMU_CNTENCLR_CCNTR_ENABLE_Msk (1UL << PMU_CNTENCLR_CCNTR_ENABLE_Pos) /*!< PMU CNTENCLR: Cycle Counter Enable Clear Mask */ + +/** \brief PMU Interrupt Enable Set Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENSET_CNT0_ENABLE_Pos*/) /*!< PMU INTENSET: Event Counter 0 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT1_ENABLE_Pos 1U /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT1_ENABLE_Msk (1UL << PMU_INTENSET_CNT1_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 1 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT2_ENABLE_Pos 2U /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT2_ENABLE_Msk (1UL << PMU_INTENSET_CNT2_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 2 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT3_ENABLE_Pos 3U /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT3_ENABLE_Msk (1UL << PMU_INTENSET_CNT3_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 3 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT4_ENABLE_Pos 4U /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT4_ENABLE_Msk (1UL << PMU_INTENSET_CNT4_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 4 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT5_ENABLE_Pos 5U /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT5_ENABLE_Msk (1UL << PMU_INTENSET_CNT5_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 5 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT6_ENABLE_Pos 6U /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT6_ENABLE_Msk (1UL << PMU_INTENSET_CNT6_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 6 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT7_ENABLE_Pos 7U /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT7_ENABLE_Msk (1UL << PMU_INTENSET_CNT7_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 7 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT8_ENABLE_Pos 8U /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT8_ENABLE_Msk (1UL << PMU_INTENSET_CNT8_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 8 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT9_ENABLE_Pos 9U /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT9_ENABLE_Msk (1UL << PMU_INTENSET_CNT9_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 9 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT10_ENABLE_Pos 10U /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT10_ENABLE_Msk (1UL << PMU_INTENSET_CNT10_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 10 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT11_ENABLE_Pos 11U /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT11_ENABLE_Msk (1UL << PMU_INTENSET_CNT11_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 11 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT12_ENABLE_Pos 12U /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT12_ENABLE_Msk (1UL << PMU_INTENSET_CNT12_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 12 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT13_ENABLE_Pos 13U /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT13_ENABLE_Msk (1UL << PMU_INTENSET_CNT13_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 13 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT14_ENABLE_Pos 14U /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT14_ENABLE_Msk (1UL << PMU_INTENSET_CNT14_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 14 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT15_ENABLE_Pos 15U /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT15_ENABLE_Msk (1UL << PMU_INTENSET_CNT15_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 15 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT16_ENABLE_Pos 16U /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT16_ENABLE_Msk (1UL << PMU_INTENSET_CNT16_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 16 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT17_ENABLE_Pos 17U /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT17_ENABLE_Msk (1UL << PMU_INTENSET_CNT17_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 17 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT18_ENABLE_Pos 18U /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT18_ENABLE_Msk (1UL << PMU_INTENSET_CNT18_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 18 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT19_ENABLE_Pos 19U /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT19_ENABLE_Msk (1UL << PMU_INTENSET_CNT19_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 19 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT20_ENABLE_Pos 20U /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT20_ENABLE_Msk (1UL << PMU_INTENSET_CNT20_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 20 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT21_ENABLE_Pos 21U /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT21_ENABLE_Msk (1UL << PMU_INTENSET_CNT21_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 21 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT22_ENABLE_Pos 22U /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT22_ENABLE_Msk (1UL << PMU_INTENSET_CNT22_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 22 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT23_ENABLE_Pos 23U /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT23_ENABLE_Msk (1UL << PMU_INTENSET_CNT23_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 23 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT24_ENABLE_Pos 24U /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT24_ENABLE_Msk (1UL << PMU_INTENSET_CNT24_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 24 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT25_ENABLE_Pos 25U /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT25_ENABLE_Msk (1UL << PMU_INTENSET_CNT25_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 25 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT26_ENABLE_Pos 26U /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT26_ENABLE_Msk (1UL << PMU_INTENSET_CNT26_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 26 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT27_ENABLE_Pos 27U /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT27_ENABLE_Msk (1UL << PMU_INTENSET_CNT27_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 27 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT28_ENABLE_Pos 28U /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT28_ENABLE_Msk (1UL << PMU_INTENSET_CNT28_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 28 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT29_ENABLE_Pos 29U /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT29_ENABLE_Msk (1UL << PMU_INTENSET_CNT29_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 29 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CNT30_ENABLE_Pos 30U /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Position */ +#define PMU_INTENSET_CNT30_ENABLE_Msk (1UL << PMU_INTENSET_CNT30_ENABLE_Pos) /*!< PMU INTENSET: Event Counter 30 Interrupt Enable Set Mask */ + +#define PMU_INTENSET_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Position */ +#define PMU_INTENSET_CCYCNT_ENABLE_Msk (1UL << PMU_INTENSET_CYCCNT_ENABLE_Pos) /*!< PMU INTENSET: Cycle Counter Interrupt Enable Set Mask */ + +/** \brief PMU Interrupt Enable Clear Register Definitions */ + +#define PMU_INTENSET_CNT0_ENABLE_Pos 0U /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT0_ENABLE_Msk (1UL /*<< PMU_INTENCLR_CNT0_ENABLE_Pos*/) /*!< PMU INTENCLR: Event Counter 0 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT1_ENABLE_Pos 1U /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT1_ENABLE_Msk (1UL << PMU_INTENCLR_CNT1_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 1 Interrupt Enable Clear */ + +#define PMU_INTENCLR_CNT2_ENABLE_Pos 2U /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT2_ENABLE_Msk (1UL << PMU_INTENCLR_CNT2_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 2 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT3_ENABLE_Pos 3U /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT3_ENABLE_Msk (1UL << PMU_INTENCLR_CNT3_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 3 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT4_ENABLE_Pos 4U /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT4_ENABLE_Msk (1UL << PMU_INTENCLR_CNT4_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 4 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT5_ENABLE_Pos 5U /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT5_ENABLE_Msk (1UL << PMU_INTENCLR_CNT5_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 5 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT6_ENABLE_Pos 6U /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT6_ENABLE_Msk (1UL << PMU_INTENCLR_CNT6_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 6 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT7_ENABLE_Pos 7U /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT7_ENABLE_Msk (1UL << PMU_INTENCLR_CNT7_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 7 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT8_ENABLE_Pos 8U /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT8_ENABLE_Msk (1UL << PMU_INTENCLR_CNT8_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 8 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT9_ENABLE_Pos 9U /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT9_ENABLE_Msk (1UL << PMU_INTENCLR_CNT9_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 9 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT10_ENABLE_Pos 10U /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT10_ENABLE_Msk (1UL << PMU_INTENCLR_CNT10_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 10 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT11_ENABLE_Pos 11U /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT11_ENABLE_Msk (1UL << PMU_INTENCLR_CNT11_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 11 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT12_ENABLE_Pos 12U /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT12_ENABLE_Msk (1UL << PMU_INTENCLR_CNT12_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 12 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT13_ENABLE_Pos 13U /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT13_ENABLE_Msk (1UL << PMU_INTENCLR_CNT13_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 13 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT14_ENABLE_Pos 14U /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT14_ENABLE_Msk (1UL << PMU_INTENCLR_CNT14_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 14 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT15_ENABLE_Pos 15U /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT15_ENABLE_Msk (1UL << PMU_INTENCLR_CNT15_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 15 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT16_ENABLE_Pos 16U /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT16_ENABLE_Msk (1UL << PMU_INTENCLR_CNT16_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 16 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT17_ENABLE_Pos 17U /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT17_ENABLE_Msk (1UL << PMU_INTENCLR_CNT17_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 17 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT18_ENABLE_Pos 18U /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT18_ENABLE_Msk (1UL << PMU_INTENCLR_CNT18_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 18 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT19_ENABLE_Pos 19U /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT19_ENABLE_Msk (1UL << PMU_INTENCLR_CNT19_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 19 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT20_ENABLE_Pos 20U /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT20_ENABLE_Msk (1UL << PMU_INTENCLR_CNT20_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 20 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT21_ENABLE_Pos 21U /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT21_ENABLE_Msk (1UL << PMU_INTENCLR_CNT21_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 21 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT22_ENABLE_Pos 22U /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT22_ENABLE_Msk (1UL << PMU_INTENCLR_CNT22_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 22 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT23_ENABLE_Pos 23U /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT23_ENABLE_Msk (1UL << PMU_INTENCLR_CNT23_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 23 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT24_ENABLE_Pos 24U /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT24_ENABLE_Msk (1UL << PMU_INTENCLR_CNT24_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 24 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT25_ENABLE_Pos 25U /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT25_ENABLE_Msk (1UL << PMU_INTENCLR_CNT25_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 25 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT26_ENABLE_Pos 26U /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT26_ENABLE_Msk (1UL << PMU_INTENCLR_CNT26_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 26 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT27_ENABLE_Pos 27U /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT27_ENABLE_Msk (1UL << PMU_INTENCLR_CNT27_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 27 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT28_ENABLE_Pos 28U /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT28_ENABLE_Msk (1UL << PMU_INTENCLR_CNT28_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 28 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT29_ENABLE_Pos 29U /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT29_ENABLE_Msk (1UL << PMU_INTENCLR_CNT29_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 29 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CNT30_ENABLE_Pos 30U /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CNT30_ENABLE_Msk (1UL << PMU_INTENCLR_CNT30_ENABLE_Pos) /*!< PMU INTENCLR: Event Counter 30 Interrupt Enable Clear Mask */ + +#define PMU_INTENCLR_CYCCNT_ENABLE_Pos 31U /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Position */ +#define PMU_INTENCLR_CYCCNT_ENABLE_Msk (1UL << PMU_INTENCLR_CYCCNT_ENABLE_Pos) /*!< PMU INTENCLR: Cycle Counter Interrupt Enable Clear Mask */ + +/** \brief PMU Overflow Flag Status Set Register Definitions */ + +#define PMU_OVSSET_CNT0_STATUS_Pos 0U /*!< PMU OVSSET: Event Counter 0 Overflow Set Position */ +#define PMU_OVSSET_CNT0_STATUS_Msk (1UL /*<< PMU_OVSSET_CNT0_STATUS_Pos*/) /*!< PMU OVSSET: Event Counter 0 Overflow Set Mask */ + +#define PMU_OVSSET_CNT1_STATUS_Pos 1U /*!< PMU OVSSET: Event Counter 1 Overflow Set Position */ +#define PMU_OVSSET_CNT1_STATUS_Msk (1UL << PMU_OVSSET_CNT1_STATUS_Pos) /*!< PMU OVSSET: Event Counter 1 Overflow Set Mask */ + +#define PMU_OVSSET_CNT2_STATUS_Pos 2U /*!< PMU OVSSET: Event Counter 2 Overflow Set Position */ +#define PMU_OVSSET_CNT2_STATUS_Msk (1UL << PMU_OVSSET_CNT2_STATUS_Pos) /*!< PMU OVSSET: Event Counter 2 Overflow Set Mask */ + +#define PMU_OVSSET_CNT3_STATUS_Pos 3U /*!< PMU OVSSET: Event Counter 3 Overflow Set Position */ +#define PMU_OVSSET_CNT3_STATUS_Msk (1UL << PMU_OVSSET_CNT3_STATUS_Pos) /*!< PMU OVSSET: Event Counter 3 Overflow Set Mask */ + +#define PMU_OVSSET_CNT4_STATUS_Pos 4U /*!< PMU OVSSET: Event Counter 4 Overflow Set Position */ +#define PMU_OVSSET_CNT4_STATUS_Msk (1UL << PMU_OVSSET_CNT4_STATUS_Pos) /*!< PMU OVSSET: Event Counter 4 Overflow Set Mask */ + +#define PMU_OVSSET_CNT5_STATUS_Pos 5U /*!< PMU OVSSET: Event Counter 5 Overflow Set Position */ +#define PMU_OVSSET_CNT5_STATUS_Msk (1UL << PMU_OVSSET_CNT5_STATUS_Pos) /*!< PMU OVSSET: Event Counter 5 Overflow Set Mask */ + +#define PMU_OVSSET_CNT6_STATUS_Pos 6U /*!< PMU OVSSET: Event Counter 6 Overflow Set Position */ +#define PMU_OVSSET_CNT6_STATUS_Msk (1UL << PMU_OVSSET_CNT6_STATUS_Pos) /*!< PMU OVSSET: Event Counter 6 Overflow Set Mask */ + +#define PMU_OVSSET_CNT7_STATUS_Pos 7U /*!< PMU OVSSET: Event Counter 7 Overflow Set Position */ +#define PMU_OVSSET_CNT7_STATUS_Msk (1UL << PMU_OVSSET_CNT7_STATUS_Pos) /*!< PMU OVSSET: Event Counter 7 Overflow Set Mask */ + +#define PMU_OVSSET_CNT8_STATUS_Pos 8U /*!< PMU OVSSET: Event Counter 8 Overflow Set Position */ +#define PMU_OVSSET_CNT8_STATUS_Msk (1UL << PMU_OVSSET_CNT8_STATUS_Pos) /*!< PMU OVSSET: Event Counter 8 Overflow Set Mask */ + +#define PMU_OVSSET_CNT9_STATUS_Pos 9U /*!< PMU OVSSET: Event Counter 9 Overflow Set Position */ +#define PMU_OVSSET_CNT9_STATUS_Msk (1UL << PMU_OVSSET_CNT9_STATUS_Pos) /*!< PMU OVSSET: Event Counter 9 Overflow Set Mask */ + +#define PMU_OVSSET_CNT10_STATUS_Pos 10U /*!< PMU OVSSET: Event Counter 10 Overflow Set Position */ +#define PMU_OVSSET_CNT10_STATUS_Msk (1UL << PMU_OVSSET_CNT10_STATUS_Pos) /*!< PMU OVSSET: Event Counter 10 Overflow Set Mask */ + +#define PMU_OVSSET_CNT11_STATUS_Pos 11U /*!< PMU OVSSET: Event Counter 11 Overflow Set Position */ +#define PMU_OVSSET_CNT11_STATUS_Msk (1UL << PMU_OVSSET_CNT11_STATUS_Pos) /*!< PMU OVSSET: Event Counter 11 Overflow Set Mask */ + +#define PMU_OVSSET_CNT12_STATUS_Pos 12U /*!< PMU OVSSET: Event Counter 12 Overflow Set Position */ +#define PMU_OVSSET_CNT12_STATUS_Msk (1UL << PMU_OVSSET_CNT12_STATUS_Pos) /*!< PMU OVSSET: Event Counter 12 Overflow Set Mask */ + +#define PMU_OVSSET_CNT13_STATUS_Pos 13U /*!< PMU OVSSET: Event Counter 13 Overflow Set Position */ +#define PMU_OVSSET_CNT13_STATUS_Msk (1UL << PMU_OVSSET_CNT13_STATUS_Pos) /*!< PMU OVSSET: Event Counter 13 Overflow Set Mask */ + +#define PMU_OVSSET_CNT14_STATUS_Pos 14U /*!< PMU OVSSET: Event Counter 14 Overflow Set Position */ +#define PMU_OVSSET_CNT14_STATUS_Msk (1UL << PMU_OVSSET_CNT14_STATUS_Pos) /*!< PMU OVSSET: Event Counter 14 Overflow Set Mask */ + +#define PMU_OVSSET_CNT15_STATUS_Pos 15U /*!< PMU OVSSET: Event Counter 15 Overflow Set Position */ +#define PMU_OVSSET_CNT15_STATUS_Msk (1UL << PMU_OVSSET_CNT15_STATUS_Pos) /*!< PMU OVSSET: Event Counter 15 Overflow Set Mask */ + +#define PMU_OVSSET_CNT16_STATUS_Pos 16U /*!< PMU OVSSET: Event Counter 16 Overflow Set Position */ +#define PMU_OVSSET_CNT16_STATUS_Msk (1UL << PMU_OVSSET_CNT16_STATUS_Pos) /*!< PMU OVSSET: Event Counter 16 Overflow Set Mask */ + +#define PMU_OVSSET_CNT17_STATUS_Pos 17U /*!< PMU OVSSET: Event Counter 17 Overflow Set Position */ +#define PMU_OVSSET_CNT17_STATUS_Msk (1UL << PMU_OVSSET_CNT17_STATUS_Pos) /*!< PMU OVSSET: Event Counter 17 Overflow Set Mask */ + +#define PMU_OVSSET_CNT18_STATUS_Pos 18U /*!< PMU OVSSET: Event Counter 18 Overflow Set Position */ +#define PMU_OVSSET_CNT18_STATUS_Msk (1UL << PMU_OVSSET_CNT18_STATUS_Pos) /*!< PMU OVSSET: Event Counter 18 Overflow Set Mask */ + +#define PMU_OVSSET_CNT19_STATUS_Pos 19U /*!< PMU OVSSET: Event Counter 19 Overflow Set Position */ +#define PMU_OVSSET_CNT19_STATUS_Msk (1UL << PMU_OVSSET_CNT19_STATUS_Pos) /*!< PMU OVSSET: Event Counter 19 Overflow Set Mask */ + +#define PMU_OVSSET_CNT20_STATUS_Pos 20U /*!< PMU OVSSET: Event Counter 20 Overflow Set Position */ +#define PMU_OVSSET_CNT20_STATUS_Msk (1UL << PMU_OVSSET_CNT20_STATUS_Pos) /*!< PMU OVSSET: Event Counter 20 Overflow Set Mask */ + +#define PMU_OVSSET_CNT21_STATUS_Pos 21U /*!< PMU OVSSET: Event Counter 21 Overflow Set Position */ +#define PMU_OVSSET_CNT21_STATUS_Msk (1UL << PMU_OVSSET_CNT21_STATUS_Pos) /*!< PMU OVSSET: Event Counter 21 Overflow Set Mask */ + +#define PMU_OVSSET_CNT22_STATUS_Pos 22U /*!< PMU OVSSET: Event Counter 22 Overflow Set Position */ +#define PMU_OVSSET_CNT22_STATUS_Msk (1UL << PMU_OVSSET_CNT22_STATUS_Pos) /*!< PMU OVSSET: Event Counter 22 Overflow Set Mask */ + +#define PMU_OVSSET_CNT23_STATUS_Pos 23U /*!< PMU OVSSET: Event Counter 23 Overflow Set Position */ +#define PMU_OVSSET_CNT23_STATUS_Msk (1UL << PMU_OVSSET_CNT23_STATUS_Pos) /*!< PMU OVSSET: Event Counter 23 Overflow Set Mask */ + +#define PMU_OVSSET_CNT24_STATUS_Pos 24U /*!< PMU OVSSET: Event Counter 24 Overflow Set Position */ +#define PMU_OVSSET_CNT24_STATUS_Msk (1UL << PMU_OVSSET_CNT24_STATUS_Pos) /*!< PMU OVSSET: Event Counter 24 Overflow Set Mask */ + +#define PMU_OVSSET_CNT25_STATUS_Pos 25U /*!< PMU OVSSET: Event Counter 25 Overflow Set Position */ +#define PMU_OVSSET_CNT25_STATUS_Msk (1UL << PMU_OVSSET_CNT25_STATUS_Pos) /*!< PMU OVSSET: Event Counter 25 Overflow Set Mask */ + +#define PMU_OVSSET_CNT26_STATUS_Pos 26U /*!< PMU OVSSET: Event Counter 26 Overflow Set Position */ +#define PMU_OVSSET_CNT26_STATUS_Msk (1UL << PMU_OVSSET_CNT26_STATUS_Pos) /*!< PMU OVSSET: Event Counter 26 Overflow Set Mask */ + +#define PMU_OVSSET_CNT27_STATUS_Pos 27U /*!< PMU OVSSET: Event Counter 27 Overflow Set Position */ +#define PMU_OVSSET_CNT27_STATUS_Msk (1UL << PMU_OVSSET_CNT27_STATUS_Pos) /*!< PMU OVSSET: Event Counter 27 Overflow Set Mask */ + +#define PMU_OVSSET_CNT28_STATUS_Pos 28U /*!< PMU OVSSET: Event Counter 28 Overflow Set Position */ +#define PMU_OVSSET_CNT28_STATUS_Msk (1UL << PMU_OVSSET_CNT28_STATUS_Pos) /*!< PMU OVSSET: Event Counter 28 Overflow Set Mask */ + +#define PMU_OVSSET_CNT29_STATUS_Pos 29U /*!< PMU OVSSET: Event Counter 29 Overflow Set Position */ +#define PMU_OVSSET_CNT29_STATUS_Msk (1UL << PMU_OVSSET_CNT29_STATUS_Pos) /*!< PMU OVSSET: Event Counter 29 Overflow Set Mask */ + +#define PMU_OVSSET_CNT30_STATUS_Pos 30U /*!< PMU OVSSET: Event Counter 30 Overflow Set Position */ +#define PMU_OVSSET_CNT30_STATUS_Msk (1UL << PMU_OVSSET_CNT30_STATUS_Pos) /*!< PMU OVSSET: Event Counter 30 Overflow Set Mask */ + +#define PMU_OVSSET_CYCCNT_STATUS_Pos 31U /*!< PMU OVSSET: Cycle Counter Overflow Set Position */ +#define PMU_OVSSET_CYCCNT_STATUS_Msk (1UL << PMU_OVSSET_CYCCNT_STATUS_Pos) /*!< PMU OVSSET: Cycle Counter Overflow Set Mask */ + +/** \brief PMU Overflow Flag Status Clear Register Definitions */ + +#define PMU_OVSCLR_CNT0_STATUS_Pos 0U /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Position */ +#define PMU_OVSCLR_CNT0_STATUS_Msk (1UL /*<< PMU_OVSCLR_CNT0_STATUS_Pos*/) /*!< PMU OVSCLR: Event Counter 0 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT1_STATUS_Pos 1U /*!< PMU OVSCLR: Event Counter 1 Overflow Clear Position */ +#define PMU_OVSCLR_CNT1_STATUS_Msk (1UL << PMU_OVSCLR_CNT1_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 1 Overflow Clear */ + +#define PMU_OVSCLR_CNT2_STATUS_Pos 2U /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Position */ +#define PMU_OVSCLR_CNT2_STATUS_Msk (1UL << PMU_OVSCLR_CNT2_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 2 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT3_STATUS_Pos 3U /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Position */ +#define PMU_OVSCLR_CNT3_STATUS_Msk (1UL << PMU_OVSCLR_CNT3_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 3 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT4_STATUS_Pos 4U /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Position */ +#define PMU_OVSCLR_CNT4_STATUS_Msk (1UL << PMU_OVSCLR_CNT4_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 4 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT5_STATUS_Pos 5U /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Position */ +#define PMU_OVSCLR_CNT5_STATUS_Msk (1UL << PMU_OVSCLR_CNT5_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 5 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT6_STATUS_Pos 6U /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Position */ +#define PMU_OVSCLR_CNT6_STATUS_Msk (1UL << PMU_OVSCLR_CNT6_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 6 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT7_STATUS_Pos 7U /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Position */ +#define PMU_OVSCLR_CNT7_STATUS_Msk (1UL << PMU_OVSCLR_CNT7_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 7 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT8_STATUS_Pos 8U /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Position */ +#define PMU_OVSCLR_CNT8_STATUS_Msk (1UL << PMU_OVSCLR_CNT8_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 8 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT9_STATUS_Pos 9U /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Position */ +#define PMU_OVSCLR_CNT9_STATUS_Msk (1UL << PMU_OVSCLR_CNT9_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 9 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT10_STATUS_Pos 10U /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Position */ +#define PMU_OVSCLR_CNT10_STATUS_Msk (1UL << PMU_OVSCLR_CNT10_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 10 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT11_STATUS_Pos 11U /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Position */ +#define PMU_OVSCLR_CNT11_STATUS_Msk (1UL << PMU_OVSCLR_CNT11_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 11 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT12_STATUS_Pos 12U /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Position */ +#define PMU_OVSCLR_CNT12_STATUS_Msk (1UL << PMU_OVSCLR_CNT12_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 12 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT13_STATUS_Pos 13U /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Position */ +#define PMU_OVSCLR_CNT13_STATUS_Msk (1UL << PMU_OVSCLR_CNT13_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 13 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT14_STATUS_Pos 14U /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Position */ +#define PMU_OVSCLR_CNT14_STATUS_Msk (1UL << PMU_OVSCLR_CNT14_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 14 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT15_STATUS_Pos 15U /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Position */ +#define PMU_OVSCLR_CNT15_STATUS_Msk (1UL << PMU_OVSCLR_CNT15_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 15 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT16_STATUS_Pos 16U /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Position */ +#define PMU_OVSCLR_CNT16_STATUS_Msk (1UL << PMU_OVSCLR_CNT16_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 16 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT17_STATUS_Pos 17U /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Position */ +#define PMU_OVSCLR_CNT17_STATUS_Msk (1UL << PMU_OVSCLR_CNT17_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 17 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT18_STATUS_Pos 18U /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Position */ +#define PMU_OVSCLR_CNT18_STATUS_Msk (1UL << PMU_OVSCLR_CNT18_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 18 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT19_STATUS_Pos 19U /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Position */ +#define PMU_OVSCLR_CNT19_STATUS_Msk (1UL << PMU_OVSCLR_CNT19_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 19 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT20_STATUS_Pos 20U /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Position */ +#define PMU_OVSCLR_CNT20_STATUS_Msk (1UL << PMU_OVSCLR_CNT20_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 20 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT21_STATUS_Pos 21U /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Position */ +#define PMU_OVSCLR_CNT21_STATUS_Msk (1UL << PMU_OVSCLR_CNT21_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 21 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT22_STATUS_Pos 22U /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Position */ +#define PMU_OVSCLR_CNT22_STATUS_Msk (1UL << PMU_OVSCLR_CNT22_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 22 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT23_STATUS_Pos 23U /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Position */ +#define PMU_OVSCLR_CNT23_STATUS_Msk (1UL << PMU_OVSCLR_CNT23_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 23 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT24_STATUS_Pos 24U /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Position */ +#define PMU_OVSCLR_CNT24_STATUS_Msk (1UL << PMU_OVSCLR_CNT24_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 24 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT25_STATUS_Pos 25U /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Position */ +#define PMU_OVSCLR_CNT25_STATUS_Msk (1UL << PMU_OVSCLR_CNT25_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 25 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT26_STATUS_Pos 26U /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Position */ +#define PMU_OVSCLR_CNT26_STATUS_Msk (1UL << PMU_OVSCLR_CNT26_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 26 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT27_STATUS_Pos 27U /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Position */ +#define PMU_OVSCLR_CNT27_STATUS_Msk (1UL << PMU_OVSCLR_CNT27_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 27 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT28_STATUS_Pos 28U /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Position */ +#define PMU_OVSCLR_CNT28_STATUS_Msk (1UL << PMU_OVSCLR_CNT28_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 28 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT29_STATUS_Pos 29U /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Position */ +#define PMU_OVSCLR_CNT29_STATUS_Msk (1UL << PMU_OVSCLR_CNT29_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 29 Overflow Clear Mask */ + +#define PMU_OVSCLR_CNT30_STATUS_Pos 30U /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Position */ +#define PMU_OVSCLR_CNT30_STATUS_Msk (1UL << PMU_OVSCLR_CNT30_STATUS_Pos) /*!< PMU OVSCLR: Event Counter 30 Overflow Clear Mask */ + +#define PMU_OVSCLR_CYCCNT_STATUS_Pos 31U /*!< PMU OVSCLR: Cycle Counter Overflow Clear Position */ +#define PMU_OVSCLR_CYCCNT_STATUS_Msk (1UL << PMU_OVSCLR_CYCCNT_STATUS_Pos) /*!< PMU OVSCLR: Cycle Counter Overflow Clear Mask */ + +/** \brief PMU Software Increment Counter */ + +#define PMU_SWINC_CNT0_Pos 0U /*!< PMU SWINC: Event Counter 0 Software Increment Position */ +#define PMU_SWINC_CNT0_Msk (1UL /*<< PMU_SWINC_CNT0_Pos */) /*!< PMU SWINC: Event Counter 0 Software Increment Mask */ + +#define PMU_SWINC_CNT1_Pos 1U /*!< PMU SWINC: Event Counter 1 Software Increment Position */ +#define PMU_SWINC_CNT1_Msk (1UL << PMU_SWINC_CNT1_Pos) /*!< PMU SWINC: Event Counter 1 Software Increment Mask */ + +#define PMU_SWINC_CNT2_Pos 2U /*!< PMU SWINC: Event Counter 2 Software Increment Position */ +#define PMU_SWINC_CNT2_Msk (1UL << PMU_SWINC_CNT2_Pos) /*!< PMU SWINC: Event Counter 2 Software Increment Mask */ + +#define PMU_SWINC_CNT3_Pos 3U /*!< PMU SWINC: Event Counter 3 Software Increment Position */ +#define PMU_SWINC_CNT3_Msk (1UL << PMU_SWINC_CNT3_Pos) /*!< PMU SWINC: Event Counter 3 Software Increment Mask */ + +#define PMU_SWINC_CNT4_Pos 4U /*!< PMU SWINC: Event Counter 4 Software Increment Position */ +#define PMU_SWINC_CNT4_Msk (1UL << PMU_SWINC_CNT4_Pos) /*!< PMU SWINC: Event Counter 4 Software Increment Mask */ + +#define PMU_SWINC_CNT5_Pos 5U /*!< PMU SWINC: Event Counter 5 Software Increment Position */ +#define PMU_SWINC_CNT5_Msk (1UL << PMU_SWINC_CNT5_Pos) /*!< PMU SWINC: Event Counter 5 Software Increment Mask */ + +#define PMU_SWINC_CNT6_Pos 6U /*!< PMU SWINC: Event Counter 6 Software Increment Position */ +#define PMU_SWINC_CNT6_Msk (1UL << PMU_SWINC_CNT6_Pos) /*!< PMU SWINC: Event Counter 6 Software Increment Mask */ + +#define PMU_SWINC_CNT7_Pos 7U /*!< PMU SWINC: Event Counter 7 Software Increment Position */ +#define PMU_SWINC_CNT7_Msk (1UL << PMU_SWINC_CNT7_Pos) /*!< PMU SWINC: Event Counter 7 Software Increment Mask */ + +#define PMU_SWINC_CNT8_Pos 8U /*!< PMU SWINC: Event Counter 8 Software Increment Position */ +#define PMU_SWINC_CNT8_Msk (1UL << PMU_SWINC_CNT8_Pos) /*!< PMU SWINC: Event Counter 8 Software Increment Mask */ + +#define PMU_SWINC_CNT9_Pos 9U /*!< PMU SWINC: Event Counter 9 Software Increment Position */ +#define PMU_SWINC_CNT9_Msk (1UL << PMU_SWINC_CNT9_Pos) /*!< PMU SWINC: Event Counter 9 Software Increment Mask */ + +#define PMU_SWINC_CNT10_Pos 10U /*!< PMU SWINC: Event Counter 10 Software Increment Position */ +#define PMU_SWINC_CNT10_Msk (1UL << PMU_SWINC_CNT10_Pos) /*!< PMU SWINC: Event Counter 10 Software Increment Mask */ + +#define PMU_SWINC_CNT11_Pos 11U /*!< PMU SWINC: Event Counter 11 Software Increment Position */ +#define PMU_SWINC_CNT11_Msk (1UL << PMU_SWINC_CNT11_Pos) /*!< PMU SWINC: Event Counter 11 Software Increment Mask */ + +#define PMU_SWINC_CNT12_Pos 12U /*!< PMU SWINC: Event Counter 12 Software Increment Position */ +#define PMU_SWINC_CNT12_Msk (1UL << PMU_SWINC_CNT12_Pos) /*!< PMU SWINC: Event Counter 12 Software Increment Mask */ + +#define PMU_SWINC_CNT13_Pos 13U /*!< PMU SWINC: Event Counter 13 Software Increment Position */ +#define PMU_SWINC_CNT13_Msk (1UL << PMU_SWINC_CNT13_Pos) /*!< PMU SWINC: Event Counter 13 Software Increment Mask */ + +#define PMU_SWINC_CNT14_Pos 14U /*!< PMU SWINC: Event Counter 14 Software Increment Position */ +#define PMU_SWINC_CNT14_Msk (1UL << PMU_SWINC_CNT14_Pos) /*!< PMU SWINC: Event Counter 14 Software Increment Mask */ + +#define PMU_SWINC_CNT15_Pos 15U /*!< PMU SWINC: Event Counter 15 Software Increment Position */ +#define PMU_SWINC_CNT15_Msk (1UL << PMU_SWINC_CNT15_Pos) /*!< PMU SWINC: Event Counter 15 Software Increment Mask */ + +#define PMU_SWINC_CNT16_Pos 16U /*!< PMU SWINC: Event Counter 16 Software Increment Position */ +#define PMU_SWINC_CNT16_Msk (1UL << PMU_SWINC_CNT16_Pos) /*!< PMU SWINC: Event Counter 16 Software Increment Mask */ + +#define PMU_SWINC_CNT17_Pos 17U /*!< PMU SWINC: Event Counter 17 Software Increment Position */ +#define PMU_SWINC_CNT17_Msk (1UL << PMU_SWINC_CNT17_Pos) /*!< PMU SWINC: Event Counter 17 Software Increment Mask */ + +#define PMU_SWINC_CNT18_Pos 18U /*!< PMU SWINC: Event Counter 18 Software Increment Position */ +#define PMU_SWINC_CNT18_Msk (1UL << PMU_SWINC_CNT18_Pos) /*!< PMU SWINC: Event Counter 18 Software Increment Mask */ + +#define PMU_SWINC_CNT19_Pos 19U /*!< PMU SWINC: Event Counter 19 Software Increment Position */ +#define PMU_SWINC_CNT19_Msk (1UL << PMU_SWINC_CNT19_Pos) /*!< PMU SWINC: Event Counter 19 Software Increment Mask */ + +#define PMU_SWINC_CNT20_Pos 20U /*!< PMU SWINC: Event Counter 20 Software Increment Position */ +#define PMU_SWINC_CNT20_Msk (1UL << PMU_SWINC_CNT20_Pos) /*!< PMU SWINC: Event Counter 20 Software Increment Mask */ + +#define PMU_SWINC_CNT21_Pos 21U /*!< PMU SWINC: Event Counter 21 Software Increment Position */ +#define PMU_SWINC_CNT21_Msk (1UL << PMU_SWINC_CNT21_Pos) /*!< PMU SWINC: Event Counter 21 Software Increment Mask */ + +#define PMU_SWINC_CNT22_Pos 22U /*!< PMU SWINC: Event Counter 22 Software Increment Position */ +#define PMU_SWINC_CNT22_Msk (1UL << PMU_SWINC_CNT22_Pos) /*!< PMU SWINC: Event Counter 22 Software Increment Mask */ + +#define PMU_SWINC_CNT23_Pos 23U /*!< PMU SWINC: Event Counter 23 Software Increment Position */ +#define PMU_SWINC_CNT23_Msk (1UL << PMU_SWINC_CNT23_Pos) /*!< PMU SWINC: Event Counter 23 Software Increment Mask */ + +#define PMU_SWINC_CNT24_Pos 24U /*!< PMU SWINC: Event Counter 24 Software Increment Position */ +#define PMU_SWINC_CNT24_Msk (1UL << PMU_SWINC_CNT24_Pos) /*!< PMU SWINC: Event Counter 24 Software Increment Mask */ + +#define PMU_SWINC_CNT25_Pos 25U /*!< PMU SWINC: Event Counter 25 Software Increment Position */ +#define PMU_SWINC_CNT25_Msk (1UL << PMU_SWINC_CNT25_Pos) /*!< PMU SWINC: Event Counter 25 Software Increment Mask */ + +#define PMU_SWINC_CNT26_Pos 26U /*!< PMU SWINC: Event Counter 26 Software Increment Position */ +#define PMU_SWINC_CNT26_Msk (1UL << PMU_SWINC_CNT26_Pos) /*!< PMU SWINC: Event Counter 26 Software Increment Mask */ + +#define PMU_SWINC_CNT27_Pos 27U /*!< PMU SWINC: Event Counter 27 Software Increment Position */ +#define PMU_SWINC_CNT27_Msk (1UL << PMU_SWINC_CNT27_Pos) /*!< PMU SWINC: Event Counter 27 Software Increment Mask */ + +#define PMU_SWINC_CNT28_Pos 28U /*!< PMU SWINC: Event Counter 28 Software Increment Position */ +#define PMU_SWINC_CNT28_Msk (1UL << PMU_SWINC_CNT28_Pos) /*!< PMU SWINC: Event Counter 28 Software Increment Mask */ + +#define PMU_SWINC_CNT29_Pos 29U /*!< PMU SWINC: Event Counter 29 Software Increment Position */ +#define PMU_SWINC_CNT29_Msk (1UL << PMU_SWINC_CNT29_Pos) /*!< PMU SWINC: Event Counter 29 Software Increment Mask */ + +#define PMU_SWINC_CNT30_Pos 30U /*!< PMU SWINC: Event Counter 30 Software Increment Position */ +#define PMU_SWINC_CNT30_Msk (1UL << PMU_SWINC_CNT30_Pos) /*!< PMU SWINC: Event Counter 30 Software Increment Mask */ + +/** \brief PMU Control Register Definitions */ + +#define PMU_CTRL_ENABLE_Pos 0U /*!< PMU CTRL: ENABLE Position */ +#define PMU_CTRL_ENABLE_Msk (1UL /*<< PMU_CTRL_ENABLE_Pos*/) /*!< PMU CTRL: ENABLE Mask */ + +#define PMU_CTRL_EVENTCNT_RESET_Pos 1U /*!< PMU CTRL: Event Counter Reset Position */ +#define PMU_CTRL_EVENTCNT_RESET_Msk (1UL << PMU_CTRL_EVENTCNT_RESET_Pos) /*!< PMU CTRL: Event Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_RESET_Pos 2U /*!< PMU CTRL: Cycle Counter Reset Position */ +#define PMU_CTRL_CYCCNT_RESET_Msk (1UL << PMU_CTRL_CYCCNT_RESET_Pos) /*!< PMU CTRL: Cycle Counter Reset Mask */ + +#define PMU_CTRL_CYCCNT_DISABLE_Pos 5U /*!< PMU CTRL: Disable Cycle Counter Position */ +#define PMU_CTRL_CYCCNT_DISABLE_Msk (1UL << PMU_CTRL_CYCCNT_DISABLE_Pos) /*!< PMU CTRL: Disable Cycle Counter Mask */ + +#define PMU_CTRL_FRZ_ON_OV_Pos 9U /*!< PMU CTRL: Freeze-on-overflow Position */ +#define PMU_CTRL_FRZ_ON_OV_Msk (1UL << PMU_CTRL_FRZ_ON_OVERFLOW_Pos) /*!< PMU CTRL: Freeze-on-overflow Mask */ + +#define PMU_CTRL_TRACE_ON_OV_Pos 11U /*!< PMU CTRL: Trace-on-overflow Position */ +#define PMU_CTRL_TRACE_ON_OV_Msk (1UL << PMU_CTRL_TRACE_ON_OVERFLOW_Pos) /*!< PMU CTRL: Trace-on-overflow Mask */ + +/** \brief PMU Type Register Definitions */ + +#define PMU_TYPE_NUM_CNTS_Pos 0U /*!< PMU TYPE: Number of Counters Position */ +#define PMU_TYPE_NUM_CNTS_Msk (8UL /*<< PMU_TYPE_NUM_CNTS_Pos*/) /*!< PMU TYPE: Number of Counters Mask */ + +#define PMU_TYPE_SIZE_CNTS_Pos 8U /*!< PMU TYPE: Size of Counters Position */ +#define PMU_TYPE_SIZE_CNTS_Msk (6UL << PMU_TYPE_SIZE_CNTS_Pos) /*!< PMU TYPE: Size of Counters Mask */ + +#define PMU_TYPE_CYCCNT_PRESENT_Pos 14U /*!< PMU TYPE: Cycle Counter Present Position */ +#define PMU_TYPE_CYCCNT_PRESENT_Msk (1UL << PMU_TYPE_CYCCNT_PRESENT_Pos) /*!< PMU TYPE: Cycle Counter Present Mask */ + +#define PMU_TYPE_FRZ_OV_SUPPORT_Pos 21U /*!< PMU TYPE: Freeze-on-overflow Support Position */ +#define PMU_TYPE_FRZ_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Freeze-on-overflow Support Mask */ + +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Pos 23U /*!< PMU TYPE: Trace-on-overflow Support Position */ +#define PMU_TYPE_TRACE_ON_OV_SUPPORT_Msk (1UL << PMU_TYPE_FRZ_OV_SUPPORT_Pos) /*!< PMU TYPE: Trace-on-overflow Support Mask */ + +/*@} end of group CMSIS_PMU */ +#endif + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) MPU Region Limit Address Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Region Base Address Register Alias 1 */ + __IOM uint32_t RLAR_A1; /*!< Offset: 0x018 (R/W) MPU Region Limit Address Register Alias 1 */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Region Base Address Register Alias 2 */ + __IOM uint32_t RLAR_A2; /*!< Offset: 0x020 (R/W) MPU Region Limit Address Register Alias 2 */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Region Base Address Register Alias 3 */ + __IOM uint32_t RLAR_A3; /*!< Offset: 0x028 (R/W) MPU Region Limit Address Register Alias 3 */ + uint32_t RESERVED0[1]; + union { + __IOM uint32_t MAIR[2]; + struct { + __IOM uint32_t MAIR0; /*!< Offset: 0x030 (R/W) MPU Memory Attribute Indirection Register 0 */ + __IOM uint32_t MAIR1; /*!< Offset: 0x034 (R/W) MPU Memory Attribute Indirection Register 1 */ + }; + }; +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_BASE_Pos 5U /*!< MPU RBAR: BASE Position */ +#define MPU_RBAR_BASE_Msk (0x7FFFFFFUL << MPU_RBAR_BASE_Pos) /*!< MPU RBAR: BASE Mask */ + +#define MPU_RBAR_SH_Pos 3U /*!< MPU RBAR: SH Position */ +#define MPU_RBAR_SH_Msk (0x3UL << MPU_RBAR_SH_Pos) /*!< MPU RBAR: SH Mask */ + +#define MPU_RBAR_AP_Pos 1U /*!< MPU RBAR: AP Position */ +#define MPU_RBAR_AP_Msk (0x3UL << MPU_RBAR_AP_Pos) /*!< MPU RBAR: AP Mask */ + +#define MPU_RBAR_XN_Pos 0U /*!< MPU RBAR: XN Position */ +#define MPU_RBAR_XN_Msk (01UL /*<< MPU_RBAR_XN_Pos*/) /*!< MPU RBAR: XN Mask */ + +/* MPU Region Limit Address Register Definitions */ +#define MPU_RLAR_LIMIT_Pos 5U /*!< MPU RLAR: LIMIT Position */ +#define MPU_RLAR_LIMIT_Msk (0x7FFFFFFUL << MPU_RLAR_LIMIT_Pos) /*!< MPU RLAR: LIMIT Mask */ + +#define MPU_RLAR_PXN_Pos 4U /*!< MPU RLAR: PXN Position */ +#define MPU_RLAR_PXN_Msk (1UL << MPU_RLAR_PXN_Pos) /*!< MPU RLAR: PXN Mask */ + +#define MPU_RLAR_AttrIndx_Pos 1U /*!< MPU RLAR: AttrIndx Position */ +#define MPU_RLAR_AttrIndx_Msk (7UL << MPU_RLAR_AttrIndx_Pos) /*!< MPU RLAR: AttrIndx Mask */ + +#define MPU_RLAR_EN_Pos 0U /*!< MPU RLAR: Region enable bit Position */ +#define MPU_RLAR_EN_Msk (1UL /*<< MPU_RLAR_EN_Pos*/) /*!< MPU RLAR: Region enable bit Disable Mask */ + +/* MPU Memory Attribute Indirection Register 0 Definitions */ +#define MPU_MAIR0_Attr3_Pos 24U /*!< MPU MAIR0: Attr3 Position */ +#define MPU_MAIR0_Attr3_Msk (0xFFUL << MPU_MAIR0_Attr3_Pos) /*!< MPU MAIR0: Attr3 Mask */ + +#define MPU_MAIR0_Attr2_Pos 16U /*!< MPU MAIR0: Attr2 Position */ +#define MPU_MAIR0_Attr2_Msk (0xFFUL << MPU_MAIR0_Attr2_Pos) /*!< MPU MAIR0: Attr2 Mask */ + +#define MPU_MAIR0_Attr1_Pos 8U /*!< MPU MAIR0: Attr1 Position */ +#define MPU_MAIR0_Attr1_Msk (0xFFUL << MPU_MAIR0_Attr1_Pos) /*!< MPU MAIR0: Attr1 Mask */ + +#define MPU_MAIR0_Attr0_Pos 0U /*!< MPU MAIR0: Attr0 Position */ +#define MPU_MAIR0_Attr0_Msk (0xFFUL /*<< MPU_MAIR0_Attr0_Pos*/) /*!< MPU MAIR0: Attr0 Mask */ + +/* MPU Memory Attribute Indirection Register 1 Definitions */ +#define MPU_MAIR1_Attr7_Pos 24U /*!< MPU MAIR1: Attr7 Position */ +#define MPU_MAIR1_Attr7_Msk (0xFFUL << MPU_MAIR1_Attr7_Pos) /*!< MPU MAIR1: Attr7 Mask */ + +#define MPU_MAIR1_Attr6_Pos 16U /*!< MPU MAIR1: Attr6 Position */ +#define MPU_MAIR1_Attr6_Msk (0xFFUL << MPU_MAIR1_Attr6_Pos) /*!< MPU MAIR1: Attr6 Mask */ + +#define MPU_MAIR1_Attr5_Pos 8U /*!< MPU MAIR1: Attr5 Position */ +#define MPU_MAIR1_Attr5_Msk (0xFFUL << MPU_MAIR1_Attr5_Pos) /*!< MPU MAIR1: Attr5 Mask */ + +#define MPU_MAIR1_Attr4_Pos 0U /*!< MPU MAIR1: Attr4 Position */ +#define MPU_MAIR1_Attr4_Msk (0xFFUL /*<< MPU_MAIR1_Attr4_Pos*/) /*!< MPU MAIR1: Attr4 Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SAU Security Attribution Unit (SAU) + \brief Type definitions for the Security Attribution Unit (SAU) + @{ + */ + +/** + \brief Structure type to access the Security Attribution Unit (SAU). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SAU Control Register */ + __IM uint32_t TYPE; /*!< Offset: 0x004 (R/ ) SAU Type Register */ +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) SAU Region Number Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) SAU Region Base Address Register */ + __IOM uint32_t RLAR; /*!< Offset: 0x010 (R/W) SAU Region Limit Address Register */ +#else + uint32_t RESERVED0[3]; +#endif + __IOM uint32_t SFSR; /*!< Offset: 0x014 (R/W) Secure Fault Status Register */ + __IOM uint32_t SFAR; /*!< Offset: 0x018 (R/W) Secure Fault Address Register */ +} SAU_Type; + +/* SAU Control Register Definitions */ +#define SAU_CTRL_ALLNS_Pos 1U /*!< SAU CTRL: ALLNS Position */ +#define SAU_CTRL_ALLNS_Msk (1UL << SAU_CTRL_ALLNS_Pos) /*!< SAU CTRL: ALLNS Mask */ + +#define SAU_CTRL_ENABLE_Pos 0U /*!< SAU CTRL: ENABLE Position */ +#define SAU_CTRL_ENABLE_Msk (1UL /*<< SAU_CTRL_ENABLE_Pos*/) /*!< SAU CTRL: ENABLE Mask */ + +/* SAU Type Register Definitions */ +#define SAU_TYPE_SREGION_Pos 0U /*!< SAU TYPE: SREGION Position */ +#define SAU_TYPE_SREGION_Msk (0xFFUL /*<< SAU_TYPE_SREGION_Pos*/) /*!< SAU TYPE: SREGION Mask */ + +#if defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) +/* SAU Region Number Register Definitions */ +#define SAU_RNR_REGION_Pos 0U /*!< SAU RNR: REGION Position */ +#define SAU_RNR_REGION_Msk (0xFFUL /*<< SAU_RNR_REGION_Pos*/) /*!< SAU RNR: REGION Mask */ + +/* SAU Region Base Address Register Definitions */ +#define SAU_RBAR_BADDR_Pos 5U /*!< SAU RBAR: BADDR Position */ +#define SAU_RBAR_BADDR_Msk (0x7FFFFFFUL << SAU_RBAR_BADDR_Pos) /*!< SAU RBAR: BADDR Mask */ + +/* SAU Region Limit Address Register Definitions */ +#define SAU_RLAR_LADDR_Pos 5U /*!< SAU RLAR: LADDR Position */ +#define SAU_RLAR_LADDR_Msk (0x7FFFFFFUL << SAU_RLAR_LADDR_Pos) /*!< SAU RLAR: LADDR Mask */ + +#define SAU_RLAR_NSC_Pos 1U /*!< SAU RLAR: NSC Position */ +#define SAU_RLAR_NSC_Msk (1UL << SAU_RLAR_NSC_Pos) /*!< SAU RLAR: NSC Mask */ + +#define SAU_RLAR_ENABLE_Pos 0U /*!< SAU RLAR: ENABLE Position */ +#define SAU_RLAR_ENABLE_Msk (1UL /*<< SAU_RLAR_ENABLE_Pos*/) /*!< SAU RLAR: ENABLE Mask */ + +#endif /* defined (__SAUREGION_PRESENT) && (__SAUREGION_PRESENT == 1U) */ + +/* Secure Fault Status Register Definitions */ +#define SAU_SFSR_LSERR_Pos 7U /*!< SAU SFSR: LSERR Position */ +#define SAU_SFSR_LSERR_Msk (1UL << SAU_SFSR_LSERR_Pos) /*!< SAU SFSR: LSERR Mask */ + +#define SAU_SFSR_SFARVALID_Pos 6U /*!< SAU SFSR: SFARVALID Position */ +#define SAU_SFSR_SFARVALID_Msk (1UL << SAU_SFSR_SFARVALID_Pos) /*!< SAU SFSR: SFARVALID Mask */ + +#define SAU_SFSR_LSPERR_Pos 5U /*!< SAU SFSR: LSPERR Position */ +#define SAU_SFSR_LSPERR_Msk (1UL << SAU_SFSR_LSPERR_Pos) /*!< SAU SFSR: LSPERR Mask */ + +#define SAU_SFSR_INVTRAN_Pos 4U /*!< SAU SFSR: INVTRAN Position */ +#define SAU_SFSR_INVTRAN_Msk (1UL << SAU_SFSR_INVTRAN_Pos) /*!< SAU SFSR: INVTRAN Mask */ + +#define SAU_SFSR_AUVIOL_Pos 3U /*!< SAU SFSR: AUVIOL Position */ +#define SAU_SFSR_AUVIOL_Msk (1UL << SAU_SFSR_AUVIOL_Pos) /*!< SAU SFSR: AUVIOL Mask */ + +#define SAU_SFSR_INVER_Pos 2U /*!< SAU SFSR: INVER Position */ +#define SAU_SFSR_INVER_Msk (1UL << SAU_SFSR_INVER_Pos) /*!< SAU SFSR: INVER Mask */ + +#define SAU_SFSR_INVIS_Pos 1U /*!< SAU SFSR: INVIS Position */ +#define SAU_SFSR_INVIS_Msk (1UL << SAU_SFSR_INVIS_Pos) /*!< SAU SFSR: INVIS Mask */ + +#define SAU_SFSR_INVEP_Pos 0U /*!< SAU SFSR: INVEP Position */ +#define SAU_SFSR_INVEP_Msk (1UL /*<< SAU_SFSR_INVEP_Pos*/) /*!< SAU SFSR: INVEP Mask */ + +/*@} end of group CMSIS_SAU */ +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and VFP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_LSPENS_Pos 29U /*!< FPCCR: LSPENS Position */ +#define FPU_FPCCR_LSPENS_Msk (1UL << FPU_FPCCR_LSPENS_Pos) /*!< FPCCR: LSPENS bit Mask */ + +#define FPU_FPCCR_CLRONRET_Pos 28U /*!< FPCCR: CLRONRET Position */ +#define FPU_FPCCR_CLRONRET_Msk (1UL << FPU_FPCCR_CLRONRET_Pos) /*!< FPCCR: CLRONRET bit Mask */ + +#define FPU_FPCCR_CLRONRETS_Pos 27U /*!< FPCCR: CLRONRETS Position */ +#define FPU_FPCCR_CLRONRETS_Msk (1UL << FPU_FPCCR_CLRONRETS_Pos) /*!< FPCCR: CLRONRETS bit Mask */ + +#define FPU_FPCCR_TS_Pos 26U /*!< FPCCR: TS Position */ +#define FPU_FPCCR_TS_Msk (1UL << FPU_FPCCR_TS_Pos) /*!< FPCCR: TS bit Mask */ + +#define FPU_FPCCR_UFRDY_Pos 10U /*!< FPCCR: UFRDY Position */ +#define FPU_FPCCR_UFRDY_Msk (1UL << FPU_FPCCR_UFRDY_Pos) /*!< FPCCR: UFRDY bit Mask */ + +#define FPU_FPCCR_SPLIMVIOL_Pos 9U /*!< FPCCR: SPLIMVIOL Position */ +#define FPU_FPCCR_SPLIMVIOL_Msk (1UL << FPU_FPCCR_SPLIMVIOL_Pos) /*!< FPCCR: SPLIMVIOL bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_SFRDY_Pos 7U /*!< FPCCR: SFRDY Position */ +#define FPU_FPCCR_SFRDY_Msk (1UL << FPU_FPCCR_SFRDY_Pos) /*!< FPCCR: SFRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_S_Pos 2U /*!< FPCCR: Security status of the FP context bit Position */ +#define FPU_FPCCR_S_Msk (1UL << FPU_FPCCR_S_Pos) /*!< FPCCR: Security status of the FP context bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +#define FPU_FPDSCR_FZ16_Pos 19U /*!< FPDSCR: FZ16 bit Position */ +#define FPU_FPDSCR_FZ16_Msk (1UL << FPU_FPDSCR_FZ16_Pos) /*!< FPDSCR: FZ16 bit Mask */ + +#define FPU_FPDSCR_LTPSIZE_Pos 16U /*!< FPDSCR: LTPSIZE bit Position */ +#define FPU_FPDSCR_LTPSIZE_Msk (7UL << FPU_FPDSCR_LTPSIZE_Pos) /*!< FPDSCR: LTPSIZE bit Mask */ + +/* Media and VFP Feature Register 0 Definitions */ +#define FPU_MVFR0_FPRound_Pos 28U /*!< MVFR0: FPRound bits Position */ +#define FPU_MVFR0_FPRound_Msk (0xFUL << FPU_MVFR0_FPRound_Pos) /*!< MVFR0: FPRound bits Mask */ + +#define FPU_MVFR0_FPSqrt_Pos 20U /*!< MVFR0: FPSqrt bits Position */ +#define FPU_MVFR0_FPSqrt_Msk (0xFUL << FPU_MVFR0_FPSqrt_Pos) /*!< MVFR0: FPSqrt bits Mask */ + +#define FPU_MVFR0_FPDivide_Pos 16U /*!< MVFR0: FPDivide bits Position */ +#define FPU_MVFR0_FPDivide_Msk (0xFUL << FPU_MVFR0_FPDivide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FPDP_Pos 8U /*!< MVFR0: FPDP bits Position */ +#define FPU_MVFR0_FPDP_Msk (0xFUL << FPU_MVFR0_FPDP_Pos) /*!< MVFR0: FPDP bits Mask */ + +#define FPU_MVFR0_FPSP_Pos 4U /*!< MVFR0: FPSP bits Position */ +#define FPU_MVFR0_FPSP_Msk (0xFUL << FPU_MVFR0_FPSP_Pos) /*!< MVFR0: FPSP bits Mask */ + +#define FPU_MVFR0_SIMDReg_Pos 0U /*!< MVFR0: SIMDReg bits Position */ +#define FPU_MVFR0_SIMDReg_Msk (0xFUL /*<< FPU_MVFR0_SIMDReg_Pos*/) /*!< MVFR0: SIMDReg bits Mask */ + +/* Media and VFP Feature Register 1 Definitions */ +#define FPU_MVFR1_FMAC_Pos 28U /*!< MVFR1: FMAC bits Position */ +#define FPU_MVFR1_FMAC_Msk (0xFUL << FPU_MVFR1_FMAC_Pos) /*!< MVFR1: FMAC bits Mask */ + +#define FPU_MVFR1_FPHP_Pos 24U /*!< MVFR1: FPHP bits Position */ +#define FPU_MVFR1_FPHP_Msk (0xFUL << FPU_MVFR1_FPHP_Pos) /*!< MVFR1: FPHP bits Mask */ + +#define FPU_MVFR1_FP16_Pos 20U /*!< MVFR1: FP16 bits Position */ +#define FPU_MVFR1_FP16_Msk (0xFUL << FPU_MVFR1_FP16_Pos) /*!< MVFR1: FP16 bits Mask */ + +#define FPU_MVFR1_MVE_Pos 8U /*!< MVFR1: MVE bits Position */ +#define FPU_MVFR1_MVE_Msk (0xFUL << FPU_MVFR1_MVE_Pos) /*!< MVFR1: MVE bits Mask */ + +#define FPU_MVFR1_FPDNaN_Pos 4U /*!< MVFR1: FPDNaN bits Position */ +#define FPU_MVFR1_FPDNaN_Msk (0xFUL << FPU_MVFR1_FPDNaN_Pos) /*!< MVFR1: FPDNaN bits Mask */ + +#define FPU_MVFR1_FPFtZ_Pos 0U /*!< MVFR1: FPFtZ bits Position */ +#define FPU_MVFR1_FPFtZ_Msk (0xFUL /*<< FPU_MVFR1_FPFtZ_Pos*/) /*!< MVFR1: FPFtZ bits Mask */ + +/* Media and VFP Feature Register 2 Definitions */ +#define FPU_MVFR2_FPMisc_Pos 4U /*!< MVFR2: FPMisc bits Position */ +#define FPU_MVFR2_FPMisc_Msk (0xFUL << FPU_MVFR2_FPMisc_Pos) /*!< MVFR2: FPMisc bits Mask */ + +/*@} end of group CMSIS_FPU */ + +/* CoreDebug is deprecated. replaced by DCB (Debug Control Block) */ +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief \deprecated Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< \deprecated CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< \deprecated CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESTART_ST_Pos 26U /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Position */ +#define CoreDebug_DHCSR_S_RESTART_ST_Msk (1UL << CoreDebug_DHCSR_S_RESTART_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESTART_ST Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< \deprecated CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_FPD_Pos 23U /*!< \deprecated CoreDebug DHCSR: S_FPD Position */ +#define CoreDebug_DHCSR_S_FPD_Msk (1UL << CoreDebug_DHCSR_S_FPD_Pos) /*!< \deprecated CoreDebug DHCSR: S_FPD Mask */ + +#define CoreDebug_DHCSR_S_SUIDE_Pos 22U /*!< \deprecated CoreDebug DHCSR: S_SUIDE Position */ +#define CoreDebug_DHCSR_S_SUIDE_Msk (1UL << CoreDebug_DHCSR_S_SUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SUIDE Mask */ + +#define CoreDebug_DHCSR_S_NSUIDE_Pos 21U /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Position */ +#define CoreDebug_DHCSR_S_NSUIDE_Msk (1UL << CoreDebug_DHCSR_S_NSUIDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_NSUIDE Mask */ + +#define CoreDebug_DHCSR_S_SDE_Pos 20U /*!< \deprecated CoreDebug DHCSR: S_SDE Position */ +#define CoreDebug_DHCSR_S_SDE_Msk (1UL << CoreDebug_DHCSR_S_SDE_Pos) /*!< \deprecated CoreDebug DHCSR: S_SDE Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< \deprecated CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< \deprecated CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< \deprecated CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< \deprecated CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< \deprecated CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< \deprecated CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_PMOV_Pos 6U /*!< \deprecated CoreDebug DHCSR: C_PMOV Position */ +#define CoreDebug_DHCSR_C_PMOV_Msk (1UL << CoreDebug_DHCSR_C_PMOV_Pos) /*!< \deprecated CoreDebug DHCSR: C_PMOV Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< \deprecated CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< \deprecated CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< \deprecated CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< \deprecated CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< \deprecated CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< \deprecated CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< \deprecated CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< \deprecated CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< \deprecated CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< \deprecated CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< \deprecated CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< \deprecated CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< \deprecated CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< \deprecated CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< \deprecated CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< \deprecated CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< \deprecated CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< \deprecated CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< \deprecated CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< \deprecated CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< \deprecated CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< \deprecated CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< \deprecated CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< \deprecated CoreDebug DEMCR: VC_CORERESET Mask */ + +/* Debug Set Clear Exception and Monitor Control Register Definitions */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_CLR_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_CLR_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: CLR_MON_PEND, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_REQ_Pos 3U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Position */ +#define CoreDebug_DSCEMCR_SET_MON_REQ_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_REQ_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_REQ, Mask */ + +#define CoreDebug_DSCEMCR_SET_MON_PEND_Pos 1U /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Position */ +#define CoreDebug_DSCEMCR_SET_MON_PEND_Msk (1UL << CoreDebug_DSCEMCR_SET_MON_PEND_Pos) /*!< \deprecated CoreDebug DSCEMCR: SET_MON_PEND, Mask */ + +/* Debug Authentication Control Register Definitions */ +#define CoreDebug_DAUTHCTRL_UIDEN_Pos 10U /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_UIDAPEN_Pos 9U /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Position */ +#define CoreDebug_DAUTHCTRL_UIDAPEN_Msk (1UL << CoreDebug_DAUTHCTRL_UIDAPEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: UIDAPEN, Mask */ + +#define CoreDebug_DAUTHCTRL_FSDMA_Pos 8U /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Position */ +#define CoreDebug_DAUTHCTRL_FSDMA_Msk (1UL << CoreDebug_DAUTHCTRL_FSDMA_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: FSDMA, Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Position */ +#define CoreDebug_DAUTHCTRL_INTSPNIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPNIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPNIDEN, Mask */ + +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPNIDENSEL_Msk (1UL << CoreDebug_DAUTHCTRL_SPNIDENSEL_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: SPNIDENSEL Mask */ + +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Position */ +#define CoreDebug_DAUTHCTRL_INTSPIDEN_Msk (1UL << CoreDebug_DAUTHCTRL_INTSPIDEN_Pos) /*!< \deprecated CoreDebug DAUTHCTRL: INTSPIDEN Mask */ + +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Position */ +#define CoreDebug_DAUTHCTRL_SPIDENSEL_Msk (1UL /*<< CoreDebug_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< \deprecated CoreDebug DAUTHCTRL: SPIDENSEL Mask */ + +/* Debug Security Control and Status Register Definitions */ +#define CoreDebug_DSCSR_CDS_Pos 16U /*!< \deprecated CoreDebug DSCSR: CDS Position */ +#define CoreDebug_DSCSR_CDS_Msk (1UL << CoreDebug_DSCSR_CDS_Pos) /*!< \deprecated CoreDebug DSCSR: CDS Mask */ + +#define CoreDebug_DSCSR_SBRSEL_Pos 1U /*!< \deprecated CoreDebug DSCSR: SBRSEL Position */ +#define CoreDebug_DSCSR_SBRSEL_Msk (1UL << CoreDebug_DSCSR_SBRSEL_Pos) /*!< \deprecated CoreDebug DSCSR: SBRSEL Mask */ + +#define CoreDebug_DSCSR_SBRSELEN_Pos 0U /*!< \deprecated CoreDebug DSCSR: SBRSELEN Position */ +#define CoreDebug_DSCSR_SBRSELEN_Msk (1UL /*<< CoreDebug_DSCSR_SBRSELEN_Pos*/) /*!< \deprecated CoreDebug DSCSR: SBRSELEN Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DCB Debug Control Block + \brief Type definitions for the Debug Control Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Control Block Registers (DCB). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ + __OM uint32_t DSCEMCR; /*!< Offset: 0x010 ( /W) Debug Set Clear Exception and Monitor Control Register */ + __IOM uint32_t DAUTHCTRL; /*!< Offset: 0x014 (R/W) Debug Authentication Control Register */ + __IOM uint32_t DSCSR; /*!< Offset: 0x018 (R/W) Debug Security Control and Status Register */ +} DCB_Type; + +/* DHCSR, Debug Halting Control and Status Register Definitions */ +#define DCB_DHCSR_DBGKEY_Pos 16U /*!< DCB DHCSR: Debug key Position */ +#define DCB_DHCSR_DBGKEY_Msk (0xFFFFUL << DCB_DHCSR_DBGKEY_Pos) /*!< DCB DHCSR: Debug key Mask */ + +#define DCB_DHCSR_S_RESTART_ST_Pos 26U /*!< DCB DHCSR: Restart sticky status Position */ +#define DCB_DHCSR_S_RESTART_ST_Msk (0x1UL << DCB_DHCSR_S_RESTART_ST_Pos) /*!< DCB DHCSR: Restart sticky status Mask */ + +#define DCB_DHCSR_S_RESET_ST_Pos 25U /*!< DCB DHCSR: Reset sticky status Position */ +#define DCB_DHCSR_S_RESET_ST_Msk (0x1UL << DCB_DHCSR_S_RESET_ST_Pos) /*!< DCB DHCSR: Reset sticky status Mask */ + +#define DCB_DHCSR_S_RETIRE_ST_Pos 24U /*!< DCB DHCSR: Retire sticky status Position */ +#define DCB_DHCSR_S_RETIRE_ST_Msk (0x1UL << DCB_DHCSR_S_RETIRE_ST_Pos) /*!< DCB DHCSR: Retire sticky status Mask */ + +#define DCB_DHCSR_S_FPD_Pos 23U /*!< DCB DHCSR: Floating-point registers Debuggable Position */ +#define DCB_DHCSR_S_FPD_Msk (0x1UL << DCB_DHCSR_S_FPD_Pos) /*!< DCB DHCSR: Floating-point registers Debuggable Mask */ + +#define DCB_DHCSR_S_SUIDE_Pos 22U /*!< DCB DHCSR: Secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_SUIDE_Msk (0x1UL << DCB_DHCSR_S_SUIDE_Pos) /*!< DCB DHCSR: Secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_NSUIDE_Pos 21U /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Position */ +#define DCB_DHCSR_S_NSUIDE_Msk (0x1UL << DCB_DHCSR_S_NSUIDE_Pos) /*!< DCB DHCSR: Non-secure unprivileged halting debug enabled Mask */ + +#define DCB_DHCSR_S_SDE_Pos 20U /*!< DCB DHCSR: Secure debug enabled Position */ +#define DCB_DHCSR_S_SDE_Msk (0x1UL << DCB_DHCSR_S_SDE_Pos) /*!< DCB DHCSR: Secure debug enabled Mask */ + +#define DCB_DHCSR_S_LOCKUP_Pos 19U /*!< DCB DHCSR: Lockup status Position */ +#define DCB_DHCSR_S_LOCKUP_Msk (0x1UL << DCB_DHCSR_S_LOCKUP_Pos) /*!< DCB DHCSR: Lockup status Mask */ + +#define DCB_DHCSR_S_SLEEP_Pos 18U /*!< DCB DHCSR: Sleeping status Position */ +#define DCB_DHCSR_S_SLEEP_Msk (0x1UL << DCB_DHCSR_S_SLEEP_Pos) /*!< DCB DHCSR: Sleeping status Mask */ + +#define DCB_DHCSR_S_HALT_Pos 17U /*!< DCB DHCSR: Halted status Position */ +#define DCB_DHCSR_S_HALT_Msk (0x1UL << DCB_DHCSR_S_HALT_Pos) /*!< DCB DHCSR: Halted status Mask */ + +#define DCB_DHCSR_S_REGRDY_Pos 16U /*!< DCB DHCSR: Register ready status Position */ +#define DCB_DHCSR_S_REGRDY_Msk (0x1UL << DCB_DHCSR_S_REGRDY_Pos) /*!< DCB DHCSR: Register ready status Mask */ + +#define DCB_DHCSR_C_PMOV_Pos 6U /*!< DCB DHCSR: Halt on PMU overflow control Position */ +#define DCB_DHCSR_C_PMOV_Msk (0x1UL << DCB_DHCSR_C_PMOV_Pos) /*!< DCB DHCSR: Halt on PMU overflow control Mask */ + +#define DCB_DHCSR_C_SNAPSTALL_Pos 5U /*!< DCB DHCSR: Snap stall control Position */ +#define DCB_DHCSR_C_SNAPSTALL_Msk (0x1UL << DCB_DHCSR_C_SNAPSTALL_Pos) /*!< DCB DHCSR: Snap stall control Mask */ + +#define DCB_DHCSR_C_MASKINTS_Pos 3U /*!< DCB DHCSR: Mask interrupts control Position */ +#define DCB_DHCSR_C_MASKINTS_Msk (0x1UL << DCB_DHCSR_C_MASKINTS_Pos) /*!< DCB DHCSR: Mask interrupts control Mask */ + +#define DCB_DHCSR_C_STEP_Pos 2U /*!< DCB DHCSR: Step control Position */ +#define DCB_DHCSR_C_STEP_Msk (0x1UL << DCB_DHCSR_C_STEP_Pos) /*!< DCB DHCSR: Step control Mask */ + +#define DCB_DHCSR_C_HALT_Pos 1U /*!< DCB DHCSR: Halt control Position */ +#define DCB_DHCSR_C_HALT_Msk (0x1UL << DCB_DHCSR_C_HALT_Pos) /*!< DCB DHCSR: Halt control Mask */ + +#define DCB_DHCSR_C_DEBUGEN_Pos 0U /*!< DCB DHCSR: Debug enable control Position */ +#define DCB_DHCSR_C_DEBUGEN_Msk (0x1UL /*<< DCB_DHCSR_C_DEBUGEN_Pos*/) /*!< DCB DHCSR: Debug enable control Mask */ + +/* DCRSR, Debug Core Register Select Register Definitions */ +#define DCB_DCRSR_REGWnR_Pos 16U /*!< DCB DCRSR: Register write/not-read Position */ +#define DCB_DCRSR_REGWnR_Msk (0x1UL << DCB_DCRSR_REGWnR_Pos) /*!< DCB DCRSR: Register write/not-read Mask */ + +#define DCB_DCRSR_REGSEL_Pos 0U /*!< DCB DCRSR: Register selector Position */ +#define DCB_DCRSR_REGSEL_Msk (0x7FUL /*<< DCB_DCRSR_REGSEL_Pos*/) /*!< DCB DCRSR: Register selector Mask */ + +/* DCRDR, Debug Core Register Data Register Definitions */ +#define DCB_DCRDR_DBGTMP_Pos 0U /*!< DCB DCRDR: Data temporary buffer Position */ +#define DCB_DCRDR_DBGTMP_Msk (0xFFFFFFFFUL /*<< DCB_DCRDR_DBGTMP_Pos*/) /*!< DCB DCRDR: Data temporary buffer Mask */ + +/* DEMCR, Debug Exception and Monitor Control Register Definitions */ +#define DCB_DEMCR_TRCENA_Pos 24U /*!< DCB DEMCR: Trace enable Position */ +#define DCB_DEMCR_TRCENA_Msk (0x1UL << DCB_DEMCR_TRCENA_Pos) /*!< DCB DEMCR: Trace enable Mask */ + +#define DCB_DEMCR_MONPRKEY_Pos 23U /*!< DCB DEMCR: Monitor pend req key Position */ +#define DCB_DEMCR_MONPRKEY_Msk (0x1UL << DCB_DEMCR_MONPRKEY_Pos) /*!< DCB DEMCR: Monitor pend req key Mask */ + +#define DCB_DEMCR_UMON_EN_Pos 21U /*!< DCB DEMCR: Unprivileged monitor enable Position */ +#define DCB_DEMCR_UMON_EN_Msk (0x1UL << DCB_DEMCR_UMON_EN_Pos) /*!< DCB DEMCR: Unprivileged monitor enable Mask */ + +#define DCB_DEMCR_SDME_Pos 20U /*!< DCB DEMCR: Secure DebugMonitor enable Position */ +#define DCB_DEMCR_SDME_Msk (0x1UL << DCB_DEMCR_SDME_Pos) /*!< DCB DEMCR: Secure DebugMonitor enable Mask */ + +#define DCB_DEMCR_MON_REQ_Pos 19U /*!< DCB DEMCR: Monitor request Position */ +#define DCB_DEMCR_MON_REQ_Msk (0x1UL << DCB_DEMCR_MON_REQ_Pos) /*!< DCB DEMCR: Monitor request Mask */ + +#define DCB_DEMCR_MON_STEP_Pos 18U /*!< DCB DEMCR: Monitor step Position */ +#define DCB_DEMCR_MON_STEP_Msk (0x1UL << DCB_DEMCR_MON_STEP_Pos) /*!< DCB DEMCR: Monitor step Mask */ + +#define DCB_DEMCR_MON_PEND_Pos 17U /*!< DCB DEMCR: Monitor pend Position */ +#define DCB_DEMCR_MON_PEND_Msk (0x1UL << DCB_DEMCR_MON_PEND_Pos) /*!< DCB DEMCR: Monitor pend Mask */ + +#define DCB_DEMCR_MON_EN_Pos 16U /*!< DCB DEMCR: Monitor enable Position */ +#define DCB_DEMCR_MON_EN_Msk (0x1UL << DCB_DEMCR_MON_EN_Pos) /*!< DCB DEMCR: Monitor enable Mask */ + +#define DCB_DEMCR_VC_SFERR_Pos 11U /*!< DCB DEMCR: Vector Catch SecureFault Position */ +#define DCB_DEMCR_VC_SFERR_Msk (0x1UL << DCB_DEMCR_VC_SFERR_Pos) /*!< DCB DEMCR: Vector Catch SecureFault Mask */ + +#define DCB_DEMCR_VC_HARDERR_Pos 10U /*!< DCB DEMCR: Vector Catch HardFault errors Position */ +#define DCB_DEMCR_VC_HARDERR_Msk (0x1UL << DCB_DEMCR_VC_HARDERR_Pos) /*!< DCB DEMCR: Vector Catch HardFault errors Mask */ + +#define DCB_DEMCR_VC_INTERR_Pos 9U /*!< DCB DEMCR: Vector Catch interrupt errors Position */ +#define DCB_DEMCR_VC_INTERR_Msk (0x1UL << DCB_DEMCR_VC_INTERR_Pos) /*!< DCB DEMCR: Vector Catch interrupt errors Mask */ + +#define DCB_DEMCR_VC_BUSERR_Pos 8U /*!< DCB DEMCR: Vector Catch BusFault errors Position */ +#define DCB_DEMCR_VC_BUSERR_Msk (0x1UL << DCB_DEMCR_VC_BUSERR_Pos) /*!< DCB DEMCR: Vector Catch BusFault errors Mask */ + +#define DCB_DEMCR_VC_STATERR_Pos 7U /*!< DCB DEMCR: Vector Catch state errors Position */ +#define DCB_DEMCR_VC_STATERR_Msk (0x1UL << DCB_DEMCR_VC_STATERR_Pos) /*!< DCB DEMCR: Vector Catch state errors Mask */ + +#define DCB_DEMCR_VC_CHKERR_Pos 6U /*!< DCB DEMCR: Vector Catch check errors Position */ +#define DCB_DEMCR_VC_CHKERR_Msk (0x1UL << DCB_DEMCR_VC_CHKERR_Pos) /*!< DCB DEMCR: Vector Catch check errors Mask */ + +#define DCB_DEMCR_VC_NOCPERR_Pos 5U /*!< DCB DEMCR: Vector Catch NOCP errors Position */ +#define DCB_DEMCR_VC_NOCPERR_Msk (0x1UL << DCB_DEMCR_VC_NOCPERR_Pos) /*!< DCB DEMCR: Vector Catch NOCP errors Mask */ + +#define DCB_DEMCR_VC_MMERR_Pos 4U /*!< DCB DEMCR: Vector Catch MemManage errors Position */ +#define DCB_DEMCR_VC_MMERR_Msk (0x1UL << DCB_DEMCR_VC_MMERR_Pos) /*!< DCB DEMCR: Vector Catch MemManage errors Mask */ + +#define DCB_DEMCR_VC_CORERESET_Pos 0U /*!< DCB DEMCR: Vector Catch Core reset Position */ +#define DCB_DEMCR_VC_CORERESET_Msk (0x1UL /*<< DCB_DEMCR_VC_CORERESET_Pos*/) /*!< DCB DEMCR: Vector Catch Core reset Mask */ + +/* DSCEMCR, Debug Set Clear Exception and Monitor Control Register Definitions */ +#define DCB_DSCEMCR_CLR_MON_REQ_Pos 19U /*!< DCB DSCEMCR: Clear monitor request Position */ +#define DCB_DSCEMCR_CLR_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_REQ_Pos) /*!< DCB DSCEMCR: Clear monitor request Mask */ + +#define DCB_DSCEMCR_CLR_MON_PEND_Pos 17U /*!< DCB DSCEMCR: Clear monitor pend Position */ +#define DCB_DSCEMCR_CLR_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_CLR_MON_PEND_Pos) /*!< DCB DSCEMCR: Clear monitor pend Mask */ + +#define DCB_DSCEMCR_SET_MON_REQ_Pos 3U /*!< DCB DSCEMCR: Set monitor request Position */ +#define DCB_DSCEMCR_SET_MON_REQ_Msk (0x1UL << DCB_DSCEMCR_SET_MON_REQ_Pos) /*!< DCB DSCEMCR: Set monitor request Mask */ + +#define DCB_DSCEMCR_SET_MON_PEND_Pos 1U /*!< DCB DSCEMCR: Set monitor pend Position */ +#define DCB_DSCEMCR_SET_MON_PEND_Msk (0x1UL << DCB_DSCEMCR_SET_MON_PEND_Pos) /*!< DCB DSCEMCR: Set monitor pend Mask */ + +/* DAUTHCTRL, Debug Authentication Control Register Definitions */ +#define DCB_DAUTHCTRL_UIDEN_Pos 10U /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Position */ +#define DCB_DAUTHCTRL_UIDEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive Debug Enable Mask */ + +#define DCB_DAUTHCTRL_UIDAPEN_Pos 9U /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Position */ +#define DCB_DAUTHCTRL_UIDAPEN_Msk (0x1UL << DCB_DAUTHCTRL_UIDAPEN_Pos) /*!< DCB DAUTHCTRL: Unprivileged Invasive DAP Access Enable Mask */ + +#define DCB_DAUTHCTRL_FSDMA_Pos 8U /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Position */ +#define DCB_DAUTHCTRL_FSDMA_Msk (0x1UL << DCB_DAUTHCTRL_FSDMA_Pos) /*!< DCB DAUTHCTRL: Force Secure DebugMonitor Allowed Mask */ + +#define DCB_DAUTHCTRL_INTSPNIDEN_Pos 3U /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPNIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPNIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure non-invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPNIDENSEL_Pos 2U /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPNIDENSEL_Msk (0x1UL << DCB_DAUTHCTRL_SPNIDENSEL_Pos) /*!< DCB DAUTHCTRL: Secure non-invasive debug enable select Mask */ + +#define DCB_DAUTHCTRL_INTSPIDEN_Pos 1U /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Position */ +#define DCB_DAUTHCTRL_INTSPIDEN_Msk (0x1UL << DCB_DAUTHCTRL_INTSPIDEN_Pos) /*!< DCB DAUTHCTRL: Internal Secure invasive debug enable Mask */ + +#define DCB_DAUTHCTRL_SPIDENSEL_Pos 0U /*!< DCB DAUTHCTRL: Secure invasive debug enable select Position */ +#define DCB_DAUTHCTRL_SPIDENSEL_Msk (0x1UL /*<< DCB_DAUTHCTRL_SPIDENSEL_Pos*/) /*!< DCB DAUTHCTRL: Secure invasive debug enable select Mask */ + +/* DSCSR, Debug Security Control and Status Register Definitions */ +#define DCB_DSCSR_CDSKEY_Pos 17U /*!< DCB DSCSR: CDS write-enable key Position */ +#define DCB_DSCSR_CDSKEY_Msk (0x1UL << DCB_DSCSR_CDSKEY_Pos) /*!< DCB DSCSR: CDS write-enable key Mask */ + +#define DCB_DSCSR_CDS_Pos 16U /*!< DCB DSCSR: Current domain Secure Position */ +#define DCB_DSCSR_CDS_Msk (0x1UL << DCB_DSCSR_CDS_Pos) /*!< DCB DSCSR: Current domain Secure Mask */ + +#define DCB_DSCSR_SBRSEL_Pos 1U /*!< DCB DSCSR: Secure banked register select Position */ +#define DCB_DSCSR_SBRSEL_Msk (0x1UL << DCB_DSCSR_SBRSEL_Pos) /*!< DCB DSCSR: Secure banked register select Mask */ + +#define DCB_DSCSR_SBRSELEN_Pos 0U /*!< DCB DSCSR: Secure banked register select enable Position */ +#define DCB_DSCSR_SBRSELEN_Msk (0x1UL /*<< DCB_DSCSR_SBRSELEN_Pos*/) /*!< DCB DSCSR: Secure banked register select enable Mask */ + +/*@} end of group CMSIS_DCB */ + + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DIB Debug Identification Block + \brief Type definitions for the Debug Identification Block Registers + @{ + */ + +/** + \brief Structure type to access the Debug Identification Block Registers (DIB). + */ +typedef struct +{ + __OM uint32_t DLAR; /*!< Offset: 0x000 ( /W) SCS Software Lock Access Register */ + __IM uint32_t DLSR; /*!< Offset: 0x004 (R/ ) SCS Software Lock Status Register */ + __IM uint32_t DAUTHSTATUS; /*!< Offset: 0x008 (R/ ) Debug Authentication Status Register */ + __IM uint32_t DDEVARCH; /*!< Offset: 0x00C (R/ ) SCS Device Architecture Register */ + __IM uint32_t DDEVTYPE; /*!< Offset: 0x010 (R/ ) SCS Device Type Register */ +} DIB_Type; + +/* DLAR, SCS Software Lock Access Register Definitions */ +#define DIB_DLAR_KEY_Pos 0U /*!< DIB DLAR: KEY Position */ +#define DIB_DLAR_KEY_Msk (0xFFFFFFFFUL /*<< DIB_DLAR_KEY_Pos */) /*!< DIB DLAR: KEY Mask */ + +/* DLSR, SCS Software Lock Status Register Definitions */ +#define DIB_DLSR_nTT_Pos 2U /*!< DIB DLSR: Not thirty-two bit Position */ +#define DIB_DLSR_nTT_Msk (0x1UL << DIB_DLSR_nTT_Pos ) /*!< DIB DLSR: Not thirty-two bit Mask */ + +#define DIB_DLSR_SLK_Pos 1U /*!< DIB DLSR: Software Lock status Position */ +#define DIB_DLSR_SLK_Msk (0x1UL << DIB_DLSR_SLK_Pos ) /*!< DIB DLSR: Software Lock status Mask */ + +#define DIB_DLSR_SLI_Pos 0U /*!< DIB DLSR: Software Lock implemented Position */ +#define DIB_DLSR_SLI_Msk (0x1UL /*<< DIB_DLSR_SLI_Pos*/) /*!< DIB DLSR: Software Lock implemented Mask */ + +/* DAUTHSTATUS, Debug Authentication Status Register Definitions */ +#define DIB_DAUTHSTATUS_SUNID_Pos 22U /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUNID_Msk (0x3UL << DIB_DAUTHSTATUS_SUNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Non-invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SUID_Pos 20U /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_SUID_Msk (0x3UL << DIB_DAUTHSTATUS_SUID_Pos ) /*!< DIB DAUTHSTATUS: Secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_NSUNID_Pos 18U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Position */ +#define DIB_DAUTHSTATUS_NSUNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Non-invasive Debug Allo Mask */ + +#define DIB_DAUTHSTATUS_NSUID_Pos 16U /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Position */ +#define DIB_DAUTHSTATUS_NSUID_Msk (0x3UL << DIB_DAUTHSTATUS_NSUID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Unprivileged Invasive Debug Allowed Mask */ + +#define DIB_DAUTHSTATUS_SNID_Pos 6U /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_SNID_Msk (0x3UL << DIB_DAUTHSTATUS_SNID_Pos ) /*!< DIB DAUTHSTATUS: Secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_SID_Pos 4U /*!< DIB DAUTHSTATUS: Secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_SID_Msk (0x3UL << DIB_DAUTHSTATUS_SID_Pos ) /*!< DIB DAUTHSTATUS: Secure Invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSNID_Pos 2U /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSNID_Msk (0x3UL << DIB_DAUTHSTATUS_NSNID_Pos ) /*!< DIB DAUTHSTATUS: Non-secure Non-invasive Debug Mask */ + +#define DIB_DAUTHSTATUS_NSID_Pos 0U /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Position */ +#define DIB_DAUTHSTATUS_NSID_Msk (0x3UL /*<< DIB_DAUTHSTATUS_NSID_Pos*/) /*!< DIB DAUTHSTATUS: Non-secure Invasive Debug Mask */ + +/* DDEVARCH, SCS Device Architecture Register Definitions */ +#define DIB_DDEVARCH_ARCHITECT_Pos 21U /*!< DIB DDEVARCH: Architect Position */ +#define DIB_DDEVARCH_ARCHITECT_Msk (0x7FFUL << DIB_DDEVARCH_ARCHITECT_Pos ) /*!< DIB DDEVARCH: Architect Mask */ + +#define DIB_DDEVARCH_PRESENT_Pos 20U /*!< DIB DDEVARCH: DEVARCH Present Position */ +#define DIB_DDEVARCH_PRESENT_Msk (0x1FUL << DIB_DDEVARCH_PRESENT_Pos ) /*!< DIB DDEVARCH: DEVARCH Present Mask */ + +#define DIB_DDEVARCH_REVISION_Pos 16U /*!< DIB DDEVARCH: Revision Position */ +#define DIB_DDEVARCH_REVISION_Msk (0xFUL << DIB_DDEVARCH_REVISION_Pos ) /*!< DIB DDEVARCH: Revision Mask */ + +#define DIB_DDEVARCH_ARCHVER_Pos 12U /*!< DIB DDEVARCH: Architecture Version Position */ +#define DIB_DDEVARCH_ARCHVER_Msk (0xFUL << DIB_DDEVARCH_ARCHVER_Pos ) /*!< DIB DDEVARCH: Architecture Version Mask */ + +#define DIB_DDEVARCH_ARCHPART_Pos 0U /*!< DIB DDEVARCH: Architecture Part Position */ +#define DIB_DDEVARCH_ARCHPART_Msk (0xFFFUL /*<< DIB_DDEVARCH_ARCHPART_Pos*/) /*!< DIB DDEVARCH: Architecture Part Mask */ + +/* DDEVTYPE, SCS Device Type Register Definitions */ +#define DIB_DDEVTYPE_SUB_Pos 4U /*!< DIB DDEVTYPE: Sub-type Position */ +#define DIB_DDEVTYPE_SUB_Msk (0xFUL << DIB_DDEVTYPE_SUB_Pos ) /*!< DIB DDEVTYPE: Sub-type Mask */ + +#define DIB_DDEVTYPE_MAJOR_Pos 0U /*!< DIB DDEVTYPE: Major type Position */ +#define DIB_DDEVTYPE_MAJOR_Msk (0xFUL /*<< DIB_DDEVTYPE_MAJOR_Pos*/) /*!< DIB DDEVTYPE: Major type Mask */ + + +/*@} end of group CMSIS_DIB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ + #define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ + #define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ + #define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ + #define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ + #define CoreDebug_BASE (0xE000EDF0UL) /*!< \deprecated Core Debug Base Address */ + #define DCB_BASE (0xE000EDF0UL) /*!< DCB Base Address */ + #define DIB_BASE (0xE000EFB0UL) /*!< DIB Base Address */ + #define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ + #define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ + #define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + + #define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ + #define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ + #define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ + #define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + #define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ + #define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ + #define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ + #define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE ) /*!< \deprecated Core Debug configuration struct */ + #define DCB ((DCB_Type *) DCB_BASE ) /*!< DCB configuration struct */ + #define DIB ((DIB_Type *) DIB_BASE ) /*!< DIB configuration struct */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ + #endif + + #if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + #define PMU_BASE (0xE0003000UL) /*!< PMU Base Address */ + #define PMU ((PMU_Type *) PMU_BASE ) /*!< PMU configuration struct */ + #endif + + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SAU_BASE (SCS_BASE + 0x0DD0UL) /*!< Security Attribution Unit */ + #define SAU ((SAU_Type *) SAU_BASE ) /*!< Security Attribution Unit */ + #endif + + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + #define SCS_BASE_NS (0xE002E000UL) /*!< System Control Space Base Address (non-secure address space) */ + #define CoreDebug_BASE_NS (0xE002EDF0UL) /*!< \deprecated Core Debug Base Address (non-secure address space) */ + #define DCB_BASE_NS (0xE002EDF0UL) /*!< DCB Base Address (non-secure address space) */ + #define DIB_BASE_NS (0xE002EFB0UL) /*!< DIB Base Address (non-secure address space) */ + #define SysTick_BASE_NS (SCS_BASE_NS + 0x0010UL) /*!< SysTick Base Address (non-secure address space) */ + #define NVIC_BASE_NS (SCS_BASE_NS + 0x0100UL) /*!< NVIC Base Address (non-secure address space) */ + #define SCB_BASE_NS (SCS_BASE_NS + 0x0D00UL) /*!< System Control Block Base Address (non-secure address space) */ + + #define SCnSCB_NS ((SCnSCB_Type *) SCS_BASE_NS ) /*!< System control Register not in SCB(non-secure address space) */ + #define SCB_NS ((SCB_Type *) SCB_BASE_NS ) /*!< SCB configuration struct (non-secure address space) */ + #define SysTick_NS ((SysTick_Type *) SysTick_BASE_NS ) /*!< SysTick configuration struct (non-secure address space) */ + #define NVIC_NS ((NVIC_Type *) NVIC_BASE_NS ) /*!< NVIC configuration struct (non-secure address space) */ + #define CoreDebug_NS ((CoreDebug_Type *) CoreDebug_BASE_NS) /*!< \deprecated Core Debug configuration struct (non-secure address space) */ + #define DCB_NS ((DCB_Type *) DCB_BASE_NS ) /*!< DCB configuration struct (non-secure address space) */ + #define DIB_NS ((DIB_Type *) DIB_BASE_NS ) /*!< DIB configuration struct (non-secure address space) */ + + #if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE_NS (SCS_BASE_NS + 0x0D90UL) /*!< Memory Protection Unit (non-secure address space) */ + #define MPU_NS ((MPU_Type *) MPU_BASE_NS ) /*!< Memory Protection Unit (non-secure address space) */ + #endif + + #define FPU_BASE_NS (SCS_BASE_NS + 0x0F30UL) /*!< Floating Point Unit (non-secure address space) */ + #define FPU_NS ((FPU_Type *) FPU_BASE_NS ) /*!< Floating Point Unit (non-secure address space) */ + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* Special LR values for Secure/Non-Secure call handling and exception handling */ + +/* Function Return Payload (from ARMv8-M Architecture Reference Manual) LR value on entry from Secure BLXNS */ +#define FNC_RETURN (0xFEFFFFFFUL) /* bit [0] ignored when processing a branch */ + +/* The following EXC_RETURN mask values are used to evaluate the LR on exception entry */ +#define EXC_RETURN_PREFIX (0xFF000000UL) /* bits [31:24] set to indicate an EXC_RETURN value */ +#define EXC_RETURN_S (0x00000040UL) /* bit [6] stack used to push registers: 0=Non-secure 1=Secure */ +#define EXC_RETURN_DCRS (0x00000020UL) /* bit [5] stacking rules for called registers: 0=skipped 1=saved */ +#define EXC_RETURN_FTYPE (0x00000010UL) /* bit [4] allocate stack for floating-point context: 0=done 1=skipped */ +#define EXC_RETURN_MODE (0x00000008UL) /* bit [3] processor mode for return: 0=Handler mode 1=Thread mode */ +#define EXC_RETURN_SPSEL (0x00000004UL) /* bit [2] stack pointer used to restore context: 0=MSP 1=PSP */ +#define EXC_RETURN_ES (0x00000001UL) /* bit [0] security state exception was taken to: 0=Non-secure 1=Secure */ + +/* Integrity Signature (from ARMv8-M Architecture Reference Manual) for exception context stacking */ +#if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) /* Value for processors with floating-point extension: */ +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125AUL) /* bit [0] SFTC must match LR bit[4] EXC_RETURN_FTYPE */ +#else +#define EXC_INTEGRITY_SIGNATURE (0xFEFA125BUL) /* Value for processors without floating-point extension */ +#endif + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Interrupt Target State + \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + \return 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Target State + \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Clear Interrupt Target State + \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 if interrupt is assigned to Secure + 1 if interrupt is assigned to Non Secure + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL))); + return((uint32_t)(((NVIC->ITNS[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Priority Grouping (non-secure) + \details Sets the non-secure priority grouping field when in secure state using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void TZ_NVIC_SetPriorityGrouping_NS(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB_NS->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB_NS->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping (non-secure) + \details Reads the priority grouping field from the non-secure NVIC when in secure state. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriorityGrouping_NS(void) +{ + return ((uint32_t)((SCB_NS->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt (non-secure) + \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Interrupt Enable status (non-secure) + \details Returns a device specific interrupt enable status from the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetEnableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt (non-secure) + \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Pending Interrupt (non-secure) + \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt (non-secure) + \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt (non-secure) + \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt (non-secure) + \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority (non-secure) + \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every non-secure processor exception. + */ +__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC_NS->IPR[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority (non-secure) + \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC_NS->IPR[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB_NS->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} +#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_NVICFunctions */ + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv8.h" + +#endif + +/* ########################## PMU functions and events #################################### */ + +#if defined (__PMU_PRESENT) && (__PMU_PRESENT == 1U) + +#include "pmu_armv8.h" + +/** + \brief Cortex-M55 PMU events + \note Architectural PMU events can be found in pmu_armv8.h +*/ + +#define ARMCM55_PMU_ECC_ERR 0xC000 /*!< Any ECC error */ +#define ARMCM55_PMU_ECC_ERR_FATAL 0xC001 /*!< Any fatal ECC error */ +#define ARMCM55_PMU_ECC_ERR_DCACHE 0xC010 /*!< Any ECC error in the data cache */ +#define ARMCM55_PMU_ECC_ERR_ICACHE 0xC011 /*!< Any ECC error in the instruction cache */ +#define ARMCM55_PMU_ECC_ERR_FATAL_DCACHE 0xC012 /*!< Any fatal ECC error in the data cache */ +#define ARMCM55_PMU_ECC_ERR_FATAL_ICACHE 0xC013 /*!< Any fatal ECC error in the instruction cache*/ +#define ARMCM55_PMU_ECC_ERR_DTCM 0xC020 /*!< Any ECC error in the DTCM */ +#define ARMCM55_PMU_ECC_ERR_ITCM 0xC021 /*!< Any ECC error in the ITCM */ +#define ARMCM55_PMU_ECC_ERR_FATAL_DTCM 0xC022 /*!< Any fatal ECC error in the DTCM */ +#define ARMCM55_PMU_ECC_ERR_FATAL_ITCM 0xC023 /*!< Any fatal ECC error in the ITCM */ +#define ARMCM55_PMU_PF_LINEFILL 0xC100 /*!< A prefetcher starts a line-fill */ +#define ARMCM55_PMU_PF_CANCEL 0xC101 /*!< A prefetcher stops prefetching */ +#define ARMCM55_PMU_PF_DROP_LINEFILL 0xC102 /*!< A linefill triggered by a prefetcher has been dropped because of lack of buffering */ +#define ARMCM55_PMU_NWAMODE_ENTER 0xC200 /*!< No write-allocate mode entry */ +#define ARMCM55_PMU_NWAMODE 0xC201 /*!< Write-allocate store is not allocated into the data cache due to no-write-allocate mode */ +#define ARMCM55_PMU_SAHB_ACCESS 0xC300 /*!< Read or write access on the S-AHB interface to the TCM */ +#define ARMCM55_PMU_DOSTIMEOUT_DOUBLE 0xC400 /*!< Denial of Service timeout has fired twice and caused buffers to drain to allow forward progress */ +#define ARMCM55_PMU_DOSTIMEOUT_TRIPLE 0xC401 /*!< Denial of Service timeout has fired three times and blocked the LSU to force forward progress */ + +#endif + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = FPU->MVFR0; + if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_FPSP_Msk | FPU_MVFR0_FPDP_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + +/* ########################## MVE functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_MveFunctions MVE Functions + \brief Function that provides MVE type. + @{ + */ + +/** + \brief get MVE type + \details returns the MVE type + \returns + - \b 0: No Vector Extension (MVE) + - \b 1: Integer Vector Extension (MVE-I) + - \b 2: Floating-point Vector Extension (MVE-F) + */ +__STATIC_INLINE uint32_t SCB_GetMVEType(void) +{ + const uint32_t mvfr1 = FPU->MVFR1; + if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x2U << FPU_MVFR1_MVE_Pos)) + { + return 2U; + } + else if ((mvfr1 & FPU_MVFR1_MVE_Msk) == (0x1U << FPU_MVFR1_MVE_Pos)) + { + return 1U; + } + else + { + return 0U; + } +} + + +/*@} end of CMSIS_Core_MveFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ########################## SAU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SAUFunctions SAU Functions + \brief Functions that configure the SAU. + @{ + */ + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + +/** + \brief Enable SAU + \details Enables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Enable(void) +{ + SAU->CTRL |= (SAU_CTRL_ENABLE_Msk); +} + + + +/** + \brief Disable SAU + \details Disables the Security Attribution Unit (SAU). + */ +__STATIC_INLINE void TZ_SAU_Disable(void) +{ + SAU->CTRL &= ~(SAU_CTRL_ENABLE_Msk); +} + +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_SAUFunctions */ + + + + +/* ################################## Debug Control function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DCBFunctions Debug Control Functions + \brief Functions that access the Debug Control Block. + @{ + */ + + +/** + \brief Set Debug Authentication Control Register + \details writes to Debug Authentication Control register. + \param [in] value value to be writen. + */ +__STATIC_INLINE void DCB_SetAuthCtrl(uint32_t value) +{ + __DSB(); + __ISB(); + DCB->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register + \details Reads Debug Authentication Control register. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t DCB_GetAuthCtrl(void) +{ + return (DCB->DAUTHCTRL); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Debug Authentication Control Register (non-secure) + \details writes to non-secure Debug Authentication Control register when in secure state. + \param [in] value value to be writen + */ +__STATIC_INLINE void TZ_DCB_SetAuthCtrl_NS(uint32_t value) +{ + __DSB(); + __ISB(); + DCB_NS->DAUTHCTRL = value; + __DSB(); + __ISB(); +} + + +/** + \brief Get Debug Authentication Control Register (non-secure) + \details Reads non-secure Debug Authentication Control register when in secure state. + \return Debug Authentication Control Register. + */ +__STATIC_INLINE uint32_t TZ_DCB_GetAuthCtrl_NS(void) +{ + return (DCB_NS->DAUTHCTRL); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## Debug Identification function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_DIBFunctions Debug Identification Functions + \brief Functions that access the Debug Identification Block. + @{ + */ + + +/** + \brief Get Debug Authentication Status Register + \details Reads Debug Authentication Status register. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t DIB_GetAuthStatus(void) +{ + return (DIB->DAUTHSTATUS); +} + + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get Debug Authentication Status Register (non-secure) + \details Reads non-secure Debug Authentication Status register when in secure state. + \return Debug Authentication Status Register. + */ +__STATIC_INLINE uint32_t TZ_DIB_GetAuthStatus_NS(void) +{ + return (DIB_NS->DAUTHSTATUS); +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +/*@} end of CMSIS_Core_DCBFunctions */ + + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) +/** + \brief System Tick Configuration (non-secure) + \details Initializes the non-secure System Timer and its interrupt when in secure state, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function TZ_SysTick_Config_NS is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + + */ +__STATIC_INLINE uint32_t TZ_SysTick_Config_NS(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick_NS->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + TZ_NVIC_SetPriority_NS (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick_NS->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick_NS->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} +#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM55_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm7.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm7.h new file mode 100644 index 0000000000..e1c31c275d --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_cm7.h @@ -0,0 +1,2362 @@ +/**************************************************************************//** + * @file core_cm7.h + * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File + * @version V5.1.2 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CM7_H_GENERIC +#define __CORE_CM7_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup Cortex_M7 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS CM7 definitions */ +#define __CM7_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __CM7_CMSIS_VERSION_SUB ( __CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ + __CM7_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_M (7U) /*!< Cortex-M Core */ + +/** __FPU_USED indicates whether an FPU is used or not. + For this, __FPU_PRESENT has to be checked prior to making use of FPU specific registers and functions. +*/ +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #warning "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #if defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U) + #define __FPU_USED 1U + #else + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #define __FPU_USED 0U + #endif + #else + #define __FPU_USED 0U + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_CM7_H_DEPENDANT +#define __CORE_CM7_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __CM7_REV + #define __CM7_REV 0x0000U + #warning "__CM7_REV not defined in device header file; using default!" + #endif + + #ifndef __FPU_PRESENT + #define __FPU_PRESENT 0U + #warning "__FPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __ICACHE_PRESENT + #define __ICACHE_PRESENT 0U + #warning "__ICACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DCACHE_PRESENT + #define __DCACHE_PRESENT 0U + #warning "__DCACHE_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __DTCM_PRESENT + #define __DTCM_PRESENT 0U + #warning "__DTCM_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group Cortex_M7 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + - Core FPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:16; /*!< bit: 0..15 Reserved */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:7; /*!< bit: 20..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + +#define APSR_GE_Pos 16U /*!< APSR: GE Position */ +#define APSR_GE_Msk (0xFUL << APSR_GE_Pos) /*!< APSR: GE Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t GE:4; /*!< bit: 16..19 Greater than or Equal flags */ + uint32_t _reserved1:4; /*!< bit: 20..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_GE_Pos 16U /*!< xPSR: GE Position */ +#define xPSR_GE_Msk (0xFUL << xPSR_GE_Pos) /*!< xPSR: GE Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t FPCA:1; /*!< bit: 2 FP extension active flag */ + uint32_t _reserved0:29; /*!< bit: 3..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_FPCA_Pos 2U /*!< CONTROL: FPCA Position */ +#define CONTROL_FPCA_Msk (1UL << CONTROL_FPCA_Pos) /*!< CONTROL: FPCA Mask */ + +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHPR[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t ID_PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t ID_DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ID_AFR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t ID_MFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ID_ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[1U]; + __IM uint32_t CLIDR; /*!< Offset: 0x078 (R/ ) Cache Level ID register */ + __IM uint32_t CTR; /*!< Offset: 0x07C (R/ ) Cache Type register */ + __IM uint32_t CCSIDR; /*!< Offset: 0x080 (R/ ) Cache Size ID Register */ + __IOM uint32_t CSSELR; /*!< Offset: 0x084 (R/W) Cache Size Selection Register */ + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED3[93U]; + __OM uint32_t STIR; /*!< Offset: 0x200 ( /W) Software Triggered Interrupt Register */ + uint32_t RESERVED4[15U]; + __IM uint32_t MVFR0; /*!< Offset: 0x240 (R/ ) Media and VFP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x244 (R/ ) Media and VFP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x248 (R/ ) Media and VFP Feature Register 2 */ + uint32_t RESERVED5[1U]; + __OM uint32_t ICIALLU; /*!< Offset: 0x250 ( /W) I-Cache Invalidate All to PoU */ + uint32_t RESERVED6[1U]; + __OM uint32_t ICIMVAU; /*!< Offset: 0x258 ( /W) I-Cache Invalidate by MVA to PoU */ + __OM uint32_t DCIMVAC; /*!< Offset: 0x25C ( /W) D-Cache Invalidate by MVA to PoC */ + __OM uint32_t DCISW; /*!< Offset: 0x260 ( /W) D-Cache Invalidate by Set-way */ + __OM uint32_t DCCMVAU; /*!< Offset: 0x264 ( /W) D-Cache Clean by MVA to PoU */ + __OM uint32_t DCCMVAC; /*!< Offset: 0x268 ( /W) D-Cache Clean by MVA to PoC */ + __OM uint32_t DCCSW; /*!< Offset: 0x26C ( /W) D-Cache Clean by Set-way */ + __OM uint32_t DCCIMVAC; /*!< Offset: 0x270 ( /W) D-Cache Clean and Invalidate by MVA to PoC */ + __OM uint32_t DCCISW; /*!< Offset: 0x274 ( /W) D-Cache Clean and Invalidate by Set-way */ + uint32_t RESERVED7[6U]; + __IOM uint32_t ITCMCR; /*!< Offset: 0x290 (R/W) Instruction Tightly-Coupled Memory Control Register */ + __IOM uint32_t DTCMCR; /*!< Offset: 0x294 (R/W) Data Tightly-Coupled Memory Control Registers */ + __IOM uint32_t AHBPCR; /*!< Offset: 0x298 (R/W) AHBP Control Register */ + __IOM uint32_t CACR; /*!< Offset: 0x29C (R/W) L1 Cache Control Register */ + __IOM uint32_t AHBSCR; /*!< Offset: 0x2A0 (R/W) AHB Slave Control Register */ + uint32_t RESERVED8[1U]; + __IOM uint32_t ABFSR; /*!< Offset: 0x2A8 (R/W) Auxiliary Bus Fault Status Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_BP_Pos 18U /*!< SCB CCR: Branch prediction enable bit Position */ +#define SCB_CCR_BP_Msk (1UL << SCB_CCR_BP_Pos) /*!< SCB CCR: Branch prediction enable bit Mask */ + +#define SCB_CCR_IC_Pos 17U /*!< SCB CCR: Instruction cache enable bit Position */ +#define SCB_CCR_IC_Msk (1UL << SCB_CCR_IC_Pos) /*!< SCB CCR: Instruction cache enable bit Mask */ + +#define SCB_CCR_DC_Pos 16U /*!< SCB CCR: Cache enable bit Position */ +#define SCB_CCR_DC_Msk (1UL << SCB_CCR_DC_Pos) /*!< SCB CCR: Cache enable bit Mask */ + +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MLSPERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 5U) /*!< SCB CFSR (MMFSR): MLSPERR Position */ +#define SCB_CFSR_MLSPERR_Msk (1UL << SCB_CFSR_MLSPERR_Pos) /*!< SCB CFSR (MMFSR): MLSPERR Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_LSPERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 5U) /*!< SCB CFSR (BFSR): LSPERR Position */ +#define SCB_CFSR_LSPERR_Msk (1UL << SCB_CFSR_LSPERR_Pos) /*!< SCB CFSR (BFSR): LSPERR Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/* SCB Cache Level ID Register Definitions */ +#define SCB_CLIDR_LOUU_Pos 27U /*!< SCB CLIDR: LoUU Position */ +#define SCB_CLIDR_LOUU_Msk (7UL << SCB_CLIDR_LOUU_Pos) /*!< SCB CLIDR: LoUU Mask */ + +#define SCB_CLIDR_LOC_Pos 24U /*!< SCB CLIDR: LoC Position */ +#define SCB_CLIDR_LOC_Msk (7UL << SCB_CLIDR_LOC_Pos) /*!< SCB CLIDR: LoC Mask */ + +/* SCB Cache Type Register Definitions */ +#define SCB_CTR_FORMAT_Pos 29U /*!< SCB CTR: Format Position */ +#define SCB_CTR_FORMAT_Msk (7UL << SCB_CTR_FORMAT_Pos) /*!< SCB CTR: Format Mask */ + +#define SCB_CTR_CWG_Pos 24U /*!< SCB CTR: CWG Position */ +#define SCB_CTR_CWG_Msk (0xFUL << SCB_CTR_CWG_Pos) /*!< SCB CTR: CWG Mask */ + +#define SCB_CTR_ERG_Pos 20U /*!< SCB CTR: ERG Position */ +#define SCB_CTR_ERG_Msk (0xFUL << SCB_CTR_ERG_Pos) /*!< SCB CTR: ERG Mask */ + +#define SCB_CTR_DMINLINE_Pos 16U /*!< SCB CTR: DminLine Position */ +#define SCB_CTR_DMINLINE_Msk (0xFUL << SCB_CTR_DMINLINE_Pos) /*!< SCB CTR: DminLine Mask */ + +#define SCB_CTR_IMINLINE_Pos 0U /*!< SCB CTR: ImInLine Position */ +#define SCB_CTR_IMINLINE_Msk (0xFUL /*<< SCB_CTR_IMINLINE_Pos*/) /*!< SCB CTR: ImInLine Mask */ + +/* SCB Cache Size ID Register Definitions */ +#define SCB_CCSIDR_WT_Pos 31U /*!< SCB CCSIDR: WT Position */ +#define SCB_CCSIDR_WT_Msk (1UL << SCB_CCSIDR_WT_Pos) /*!< SCB CCSIDR: WT Mask */ + +#define SCB_CCSIDR_WB_Pos 30U /*!< SCB CCSIDR: WB Position */ +#define SCB_CCSIDR_WB_Msk (1UL << SCB_CCSIDR_WB_Pos) /*!< SCB CCSIDR: WB Mask */ + +#define SCB_CCSIDR_RA_Pos 29U /*!< SCB CCSIDR: RA Position */ +#define SCB_CCSIDR_RA_Msk (1UL << SCB_CCSIDR_RA_Pos) /*!< SCB CCSIDR: RA Mask */ + +#define SCB_CCSIDR_WA_Pos 28U /*!< SCB CCSIDR: WA Position */ +#define SCB_CCSIDR_WA_Msk (1UL << SCB_CCSIDR_WA_Pos) /*!< SCB CCSIDR: WA Mask */ + +#define SCB_CCSIDR_NUMSETS_Pos 13U /*!< SCB CCSIDR: NumSets Position */ +#define SCB_CCSIDR_NUMSETS_Msk (0x7FFFUL << SCB_CCSIDR_NUMSETS_Pos) /*!< SCB CCSIDR: NumSets Mask */ + +#define SCB_CCSIDR_ASSOCIATIVITY_Pos 3U /*!< SCB CCSIDR: Associativity Position */ +#define SCB_CCSIDR_ASSOCIATIVITY_Msk (0x3FFUL << SCB_CCSIDR_ASSOCIATIVITY_Pos) /*!< SCB CCSIDR: Associativity Mask */ + +#define SCB_CCSIDR_LINESIZE_Pos 0U /*!< SCB CCSIDR: LineSize Position */ +#define SCB_CCSIDR_LINESIZE_Msk (7UL /*<< SCB_CCSIDR_LINESIZE_Pos*/) /*!< SCB CCSIDR: LineSize Mask */ + +/* SCB Cache Size Selection Register Definitions */ +#define SCB_CSSELR_LEVEL_Pos 1U /*!< SCB CSSELR: Level Position */ +#define SCB_CSSELR_LEVEL_Msk (7UL << SCB_CSSELR_LEVEL_Pos) /*!< SCB CSSELR: Level Mask */ + +#define SCB_CSSELR_IND_Pos 0U /*!< SCB CSSELR: InD Position */ +#define SCB_CSSELR_IND_Msk (1UL /*<< SCB_CSSELR_IND_Pos*/) /*!< SCB CSSELR: InD Mask */ + +/* SCB Software Triggered Interrupt Register Definitions */ +#define SCB_STIR_INTID_Pos 0U /*!< SCB STIR: INTID Position */ +#define SCB_STIR_INTID_Msk (0x1FFUL /*<< SCB_STIR_INTID_Pos*/) /*!< SCB STIR: INTID Mask */ + +/* SCB D-Cache Invalidate by Set-way Register Definitions */ +#define SCB_DCISW_WAY_Pos 30U /*!< SCB DCISW: Way Position */ +#define SCB_DCISW_WAY_Msk (3UL << SCB_DCISW_WAY_Pos) /*!< SCB DCISW: Way Mask */ + +#define SCB_DCISW_SET_Pos 5U /*!< SCB DCISW: Set Position */ +#define SCB_DCISW_SET_Msk (0x1FFUL << SCB_DCISW_SET_Pos) /*!< SCB DCISW: Set Mask */ + +/* SCB D-Cache Clean by Set-way Register Definitions */ +#define SCB_DCCSW_WAY_Pos 30U /*!< SCB DCCSW: Way Position */ +#define SCB_DCCSW_WAY_Msk (3UL << SCB_DCCSW_WAY_Pos) /*!< SCB DCCSW: Way Mask */ + +#define SCB_DCCSW_SET_Pos 5U /*!< SCB DCCSW: Set Position */ +#define SCB_DCCSW_SET_Msk (0x1FFUL << SCB_DCCSW_SET_Pos) /*!< SCB DCCSW: Set Mask */ + +/* SCB D-Cache Clean and Invalidate by Set-way Register Definitions */ +#define SCB_DCCISW_WAY_Pos 30U /*!< SCB DCCISW: Way Position */ +#define SCB_DCCISW_WAY_Msk (3UL << SCB_DCCISW_WAY_Pos) /*!< SCB DCCISW: Way Mask */ + +#define SCB_DCCISW_SET_Pos 5U /*!< SCB DCCISW: Set Position */ +#define SCB_DCCISW_SET_Msk (0x1FFUL << SCB_DCCISW_SET_Pos) /*!< SCB DCCISW: Set Mask */ + +/* Instruction Tightly-Coupled Memory Control Register Definitions */ +#define SCB_ITCMCR_SZ_Pos 3U /*!< SCB ITCMCR: SZ Position */ +#define SCB_ITCMCR_SZ_Msk (0xFUL << SCB_ITCMCR_SZ_Pos) /*!< SCB ITCMCR: SZ Mask */ + +#define SCB_ITCMCR_RETEN_Pos 2U /*!< SCB ITCMCR: RETEN Position */ +#define SCB_ITCMCR_RETEN_Msk (1UL << SCB_ITCMCR_RETEN_Pos) /*!< SCB ITCMCR: RETEN Mask */ + +#define SCB_ITCMCR_RMW_Pos 1U /*!< SCB ITCMCR: RMW Position */ +#define SCB_ITCMCR_RMW_Msk (1UL << SCB_ITCMCR_RMW_Pos) /*!< SCB ITCMCR: RMW Mask */ + +#define SCB_ITCMCR_EN_Pos 0U /*!< SCB ITCMCR: EN Position */ +#define SCB_ITCMCR_EN_Msk (1UL /*<< SCB_ITCMCR_EN_Pos*/) /*!< SCB ITCMCR: EN Mask */ + +/* Data Tightly-Coupled Memory Control Register Definitions */ +#define SCB_DTCMCR_SZ_Pos 3U /*!< SCB DTCMCR: SZ Position */ +#define SCB_DTCMCR_SZ_Msk (0xFUL << SCB_DTCMCR_SZ_Pos) /*!< SCB DTCMCR: SZ Mask */ + +#define SCB_DTCMCR_RETEN_Pos 2U /*!< SCB DTCMCR: RETEN Position */ +#define SCB_DTCMCR_RETEN_Msk (1UL << SCB_DTCMCR_RETEN_Pos) /*!< SCB DTCMCR: RETEN Mask */ + +#define SCB_DTCMCR_RMW_Pos 1U /*!< SCB DTCMCR: RMW Position */ +#define SCB_DTCMCR_RMW_Msk (1UL << SCB_DTCMCR_RMW_Pos) /*!< SCB DTCMCR: RMW Mask */ + +#define SCB_DTCMCR_EN_Pos 0U /*!< SCB DTCMCR: EN Position */ +#define SCB_DTCMCR_EN_Msk (1UL /*<< SCB_DTCMCR_EN_Pos*/) /*!< SCB DTCMCR: EN Mask */ + +/* AHBP Control Register Definitions */ +#define SCB_AHBPCR_SZ_Pos 1U /*!< SCB AHBPCR: SZ Position */ +#define SCB_AHBPCR_SZ_Msk (7UL << SCB_AHBPCR_SZ_Pos) /*!< SCB AHBPCR: SZ Mask */ + +#define SCB_AHBPCR_EN_Pos 0U /*!< SCB AHBPCR: EN Position */ +#define SCB_AHBPCR_EN_Msk (1UL /*<< SCB_AHBPCR_EN_Pos*/) /*!< SCB AHBPCR: EN Mask */ + +/* L1 Cache Control Register Definitions */ +#define SCB_CACR_FORCEWT_Pos 2U /*!< SCB CACR: FORCEWT Position */ +#define SCB_CACR_FORCEWT_Msk (1UL << SCB_CACR_FORCEWT_Pos) /*!< SCB CACR: FORCEWT Mask */ + +#define SCB_CACR_ECCEN_Pos 1U /*!< SCB CACR: ECCEN Position */ +#define SCB_CACR_ECCEN_Msk (1UL << SCB_CACR_ECCEN_Pos) /*!< SCB CACR: ECCEN Mask */ + +#define SCB_CACR_SIWT_Pos 0U /*!< SCB CACR: SIWT Position */ +#define SCB_CACR_SIWT_Msk (1UL /*<< SCB_CACR_SIWT_Pos*/) /*!< SCB CACR: SIWT Mask */ + +/* AHBS Control Register Definitions */ +#define SCB_AHBSCR_INITCOUNT_Pos 11U /*!< SCB AHBSCR: INITCOUNT Position */ +#define SCB_AHBSCR_INITCOUNT_Msk (0x1FUL << SCB_AHBPCR_INITCOUNT_Pos) /*!< SCB AHBSCR: INITCOUNT Mask */ + +#define SCB_AHBSCR_TPRI_Pos 2U /*!< SCB AHBSCR: TPRI Position */ +#define SCB_AHBSCR_TPRI_Msk (0x1FFUL << SCB_AHBPCR_TPRI_Pos) /*!< SCB AHBSCR: TPRI Mask */ + +#define SCB_AHBSCR_CTL_Pos 0U /*!< SCB AHBSCR: CTL Position*/ +#define SCB_AHBSCR_CTL_Msk (3UL /*<< SCB_AHBPCR_CTL_Pos*/) /*!< SCB AHBSCR: CTL Mask */ + +/* Auxiliary Bus Fault Status Register Definitions */ +#define SCB_ABFSR_AXIMTYPE_Pos 8U /*!< SCB ABFSR: AXIMTYPE Position*/ +#define SCB_ABFSR_AXIMTYPE_Msk (3UL << SCB_ABFSR_AXIMTYPE_Pos) /*!< SCB ABFSR: AXIMTYPE Mask */ + +#define SCB_ABFSR_EPPB_Pos 4U /*!< SCB ABFSR: EPPB Position*/ +#define SCB_ABFSR_EPPB_Msk (1UL << SCB_ABFSR_EPPB_Pos) /*!< SCB ABFSR: EPPB Mask */ + +#define SCB_ABFSR_AXIM_Pos 3U /*!< SCB ABFSR: AXIM Position*/ +#define SCB_ABFSR_AXIM_Msk (1UL << SCB_ABFSR_AXIM_Pos) /*!< SCB ABFSR: AXIM Mask */ + +#define SCB_ABFSR_AHBP_Pos 2U /*!< SCB ABFSR: AHBP Position*/ +#define SCB_ABFSR_AHBP_Msk (1UL << SCB_ABFSR_AHBP_Pos) /*!< SCB ABFSR: AHBP Mask */ + +#define SCB_ABFSR_DTCM_Pos 1U /*!< SCB ABFSR: DTCM Position*/ +#define SCB_ABFSR_DTCM_Msk (1UL << SCB_ABFSR_DTCM_Pos) /*!< SCB ABFSR: DTCM Mask */ + +#define SCB_ABFSR_ITCM_Pos 0U /*!< SCB ABFSR: ITCM Position*/ +#define SCB_ABFSR_ITCM_Msk (1UL /*<< SCB_ABFSR_ITCM_Pos*/) /*!< SCB ABFSR: ITCM Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISDYNADD_Pos 26U /*!< ACTLR: DISDYNADD Position */ +#define SCnSCB_ACTLR_DISDYNADD_Msk (1UL << SCnSCB_ACTLR_DISDYNADD_Pos) /*!< ACTLR: DISDYNADD Mask */ + +#define SCnSCB_ACTLR_DISISSCH1_Pos 21U /*!< ACTLR: DISISSCH1 Position */ +#define SCnSCB_ACTLR_DISISSCH1_Msk (0x1FUL << SCnSCB_ACTLR_DISISSCH1_Pos) /*!< ACTLR: DISISSCH1 Mask */ + +#define SCnSCB_ACTLR_DISDI_Pos 16U /*!< ACTLR: DISDI Position */ +#define SCnSCB_ACTLR_DISDI_Msk (0x1FUL << SCnSCB_ACTLR_DISDI_Pos) /*!< ACTLR: DISDI Mask */ + +#define SCnSCB_ACTLR_DISCRITAXIRUR_Pos 15U /*!< ACTLR: DISCRITAXIRUR Position */ +#define SCnSCB_ACTLR_DISCRITAXIRUR_Msk (1UL << SCnSCB_ACTLR_DISCRITAXIRUR_Pos) /*!< ACTLR: DISCRITAXIRUR Mask */ + +#define SCnSCB_ACTLR_DISBTACALLOC_Pos 14U /*!< ACTLR: DISBTACALLOC Position */ +#define SCnSCB_ACTLR_DISBTACALLOC_Msk (1UL << SCnSCB_ACTLR_DISBTACALLOC_Pos) /*!< ACTLR: DISBTACALLOC Mask */ + +#define SCnSCB_ACTLR_DISBTACREAD_Pos 13U /*!< ACTLR: DISBTACREAD Position */ +#define SCnSCB_ACTLR_DISBTACREAD_Msk (1UL << SCnSCB_ACTLR_DISBTACREAD_Pos) /*!< ACTLR: DISBTACREAD Mask */ + +#define SCnSCB_ACTLR_DISITMATBFLUSH_Pos 12U /*!< ACTLR: DISITMATBFLUSH Position */ +#define SCnSCB_ACTLR_DISITMATBFLUSH_Msk (1UL << SCnSCB_ACTLR_DISITMATBFLUSH_Pos) /*!< ACTLR: DISITMATBFLUSH Mask */ + +#define SCnSCB_ACTLR_DISRAMODE_Pos 11U /*!< ACTLR: DISRAMODE Position */ +#define SCnSCB_ACTLR_DISRAMODE_Msk (1UL << SCnSCB_ACTLR_DISRAMODE_Pos) /*!< ACTLR: DISRAMODE Mask */ + +#define SCnSCB_ACTLR_FPEXCODIS_Pos 10U /*!< ACTLR: FPEXCODIS Position */ +#define SCnSCB_ACTLR_FPEXCODIS_Msk (1UL << SCnSCB_ACTLR_FPEXCODIS_Pos) /*!< ACTLR: FPEXCODIS Mask */ + +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFFFFFFFFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ + uint32_t RESERVED3[981U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( W) Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R ) Lock Status Register */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +#define MPU_TYPE_RALIASES 4U + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif /* defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_FPU Floating Point Unit (FPU) + \brief Type definitions for the Floating Point Unit (FPU) + @{ + */ + +/** + \brief Structure type to access the Floating Point Unit (FPU). + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IOM uint32_t FPCCR; /*!< Offset: 0x004 (R/W) Floating-Point Context Control Register */ + __IOM uint32_t FPCAR; /*!< Offset: 0x008 (R/W) Floating-Point Context Address Register */ + __IOM uint32_t FPDSCR; /*!< Offset: 0x00C (R/W) Floating-Point Default Status Control Register */ + __IM uint32_t MVFR0; /*!< Offset: 0x010 (R/ ) Media and FP Feature Register 0 */ + __IM uint32_t MVFR1; /*!< Offset: 0x014 (R/ ) Media and FP Feature Register 1 */ + __IM uint32_t MVFR2; /*!< Offset: 0x018 (R/ ) Media and FP Feature Register 2 */ +} FPU_Type; + +/* Floating-Point Context Control Register Definitions */ +#define FPU_FPCCR_ASPEN_Pos 31U /*!< FPCCR: ASPEN bit Position */ +#define FPU_FPCCR_ASPEN_Msk (1UL << FPU_FPCCR_ASPEN_Pos) /*!< FPCCR: ASPEN bit Mask */ + +#define FPU_FPCCR_LSPEN_Pos 30U /*!< FPCCR: LSPEN Position */ +#define FPU_FPCCR_LSPEN_Msk (1UL << FPU_FPCCR_LSPEN_Pos) /*!< FPCCR: LSPEN bit Mask */ + +#define FPU_FPCCR_MONRDY_Pos 8U /*!< FPCCR: MONRDY Position */ +#define FPU_FPCCR_MONRDY_Msk (1UL << FPU_FPCCR_MONRDY_Pos) /*!< FPCCR: MONRDY bit Mask */ + +#define FPU_FPCCR_BFRDY_Pos 6U /*!< FPCCR: BFRDY Position */ +#define FPU_FPCCR_BFRDY_Msk (1UL << FPU_FPCCR_BFRDY_Pos) /*!< FPCCR: BFRDY bit Mask */ + +#define FPU_FPCCR_MMRDY_Pos 5U /*!< FPCCR: MMRDY Position */ +#define FPU_FPCCR_MMRDY_Msk (1UL << FPU_FPCCR_MMRDY_Pos) /*!< FPCCR: MMRDY bit Mask */ + +#define FPU_FPCCR_HFRDY_Pos 4U /*!< FPCCR: HFRDY Position */ +#define FPU_FPCCR_HFRDY_Msk (1UL << FPU_FPCCR_HFRDY_Pos) /*!< FPCCR: HFRDY bit Mask */ + +#define FPU_FPCCR_THREAD_Pos 3U /*!< FPCCR: processor mode bit Position */ +#define FPU_FPCCR_THREAD_Msk (1UL << FPU_FPCCR_THREAD_Pos) /*!< FPCCR: processor mode active bit Mask */ + +#define FPU_FPCCR_USER_Pos 1U /*!< FPCCR: privilege level bit Position */ +#define FPU_FPCCR_USER_Msk (1UL << FPU_FPCCR_USER_Pos) /*!< FPCCR: privilege level bit Mask */ + +#define FPU_FPCCR_LSPACT_Pos 0U /*!< FPCCR: Lazy state preservation active bit Position */ +#define FPU_FPCCR_LSPACT_Msk (1UL /*<< FPU_FPCCR_LSPACT_Pos*/) /*!< FPCCR: Lazy state preservation active bit Mask */ + +/* Floating-Point Context Address Register Definitions */ +#define FPU_FPCAR_ADDRESS_Pos 3U /*!< FPCAR: ADDRESS bit Position */ +#define FPU_FPCAR_ADDRESS_Msk (0x1FFFFFFFUL << FPU_FPCAR_ADDRESS_Pos) /*!< FPCAR: ADDRESS bit Mask */ + +/* Floating-Point Default Status Control Register Definitions */ +#define FPU_FPDSCR_AHP_Pos 26U /*!< FPDSCR: AHP bit Position */ +#define FPU_FPDSCR_AHP_Msk (1UL << FPU_FPDSCR_AHP_Pos) /*!< FPDSCR: AHP bit Mask */ + +#define FPU_FPDSCR_DN_Pos 25U /*!< FPDSCR: DN bit Position */ +#define FPU_FPDSCR_DN_Msk (1UL << FPU_FPDSCR_DN_Pos) /*!< FPDSCR: DN bit Mask */ + +#define FPU_FPDSCR_FZ_Pos 24U /*!< FPDSCR: FZ bit Position */ +#define FPU_FPDSCR_FZ_Msk (1UL << FPU_FPDSCR_FZ_Pos) /*!< FPDSCR: FZ bit Mask */ + +#define FPU_FPDSCR_RMode_Pos 22U /*!< FPDSCR: RMode bit Position */ +#define FPU_FPDSCR_RMode_Msk (3UL << FPU_FPDSCR_RMode_Pos) /*!< FPDSCR: RMode bit Mask */ + +/* Media and FP Feature Register 0 Definitions */ +#define FPU_MVFR0_FP_rounding_modes_Pos 28U /*!< MVFR0: FP rounding modes bits Position */ +#define FPU_MVFR0_FP_rounding_modes_Msk (0xFUL << FPU_MVFR0_FP_rounding_modes_Pos) /*!< MVFR0: FP rounding modes bits Mask */ + +#define FPU_MVFR0_Short_vectors_Pos 24U /*!< MVFR0: Short vectors bits Position */ +#define FPU_MVFR0_Short_vectors_Msk (0xFUL << FPU_MVFR0_Short_vectors_Pos) /*!< MVFR0: Short vectors bits Mask */ + +#define FPU_MVFR0_Square_root_Pos 20U /*!< MVFR0: Square root bits Position */ +#define FPU_MVFR0_Square_root_Msk (0xFUL << FPU_MVFR0_Square_root_Pos) /*!< MVFR0: Square root bits Mask */ + +#define FPU_MVFR0_Divide_Pos 16U /*!< MVFR0: Divide bits Position */ +#define FPU_MVFR0_Divide_Msk (0xFUL << FPU_MVFR0_Divide_Pos) /*!< MVFR0: Divide bits Mask */ + +#define FPU_MVFR0_FP_excep_trapping_Pos 12U /*!< MVFR0: FP exception trapping bits Position */ +#define FPU_MVFR0_FP_excep_trapping_Msk (0xFUL << FPU_MVFR0_FP_excep_trapping_Pos) /*!< MVFR0: FP exception trapping bits Mask */ + +#define FPU_MVFR0_Double_precision_Pos 8U /*!< MVFR0: Double-precision bits Position */ +#define FPU_MVFR0_Double_precision_Msk (0xFUL << FPU_MVFR0_Double_precision_Pos) /*!< MVFR0: Double-precision bits Mask */ + +#define FPU_MVFR0_Single_precision_Pos 4U /*!< MVFR0: Single-precision bits Position */ +#define FPU_MVFR0_Single_precision_Msk (0xFUL << FPU_MVFR0_Single_precision_Pos) /*!< MVFR0: Single-precision bits Mask */ + +#define FPU_MVFR0_A_SIMD_registers_Pos 0U /*!< MVFR0: A_SIMD registers bits Position */ +#define FPU_MVFR0_A_SIMD_registers_Msk (0xFUL /*<< FPU_MVFR0_A_SIMD_registers_Pos*/) /*!< MVFR0: A_SIMD registers bits Mask */ + +/* Media and FP Feature Register 1 Definitions */ +#define FPU_MVFR1_FP_fused_MAC_Pos 28U /*!< MVFR1: FP fused MAC bits Position */ +#define FPU_MVFR1_FP_fused_MAC_Msk (0xFUL << FPU_MVFR1_FP_fused_MAC_Pos) /*!< MVFR1: FP fused MAC bits Mask */ + +#define FPU_MVFR1_FP_HPFP_Pos 24U /*!< MVFR1: FP HPFP bits Position */ +#define FPU_MVFR1_FP_HPFP_Msk (0xFUL << FPU_MVFR1_FP_HPFP_Pos) /*!< MVFR1: FP HPFP bits Mask */ + +#define FPU_MVFR1_D_NaN_mode_Pos 4U /*!< MVFR1: D_NaN mode bits Position */ +#define FPU_MVFR1_D_NaN_mode_Msk (0xFUL << FPU_MVFR1_D_NaN_mode_Pos) /*!< MVFR1: D_NaN mode bits Mask */ + +#define FPU_MVFR1_FtZ_mode_Pos 0U /*!< MVFR1: FtZ mode bits Position */ +#define FPU_MVFR1_FtZ_mode_Msk (0xFUL /*<< FPU_MVFR1_FtZ_mode_Pos*/) /*!< MVFR1: FtZ mode bits Mask */ + +/* Media and FP Feature Register 2 Definitions */ + +#define FPU_MVFR2_VFP_Misc_Pos 4U /*!< MVFR2: VFP Misc bits Position */ +#define FPU_MVFR2_VFP_Misc_Msk (0xFUL << FPU_MVFR2_VFP_Misc_Pos) /*!< MVFR2: VFP Misc bits Mask */ + +/*@} end of group CMSIS_FPU */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ +#define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point Unit */ + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ +#define EXC_RETURN_HANDLER_FPU (0xFFFFFFE1UL) /* return to Handler mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_MSP_FPU (0xFFFFFFE9UL) /* return to Thread mode, uses MSP after return, restore floating-point state */ +#define EXC_RETURN_THREAD_PSP_FPU (0xFFFFFFEDUL) /* return to Thread mode, uses PSP after return, restore floating-point state */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHPR[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + __DSB(); +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## MPU functions #################################### */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + +#include "mpu_armv7.h" + +#endif + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + uint32_t mvfr0; + + mvfr0 = SCB->MVFR0; + if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x220U) + { + return 2U; /* Double + Single precision FPU */ + } + else if ((mvfr0 & (FPU_MVFR0_Single_precision_Msk | FPU_MVFR0_Double_precision_Msk)) == 0x020U) + { + return 1U; /* Single precision FPU */ + } + else + { + return 0U; /* No FPU */ + } +} + +/*@} end of CMSIS_Core_FpuFunctions */ + + +/* ########################## Cache functions #################################### */ + +#if ((defined (__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)) || \ + (defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U))) +#include "cachel1_armv7.h" +#endif + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CM7_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_sc000.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_sc000.h new file mode 100644 index 0000000000..dbc755fff3 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_sc000.h @@ -0,0 +1,1030 @@ +/**************************************************************************//** + * @file core_sc000.h + * @brief CMSIS SC000 Core Peripheral Access Layer Header File + * @version V5.0.7 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC000_H_GENERIC +#define __CORE_SC000_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC000 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS SC000 definitions */ +#define __SC000_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __SC000_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \ + __SC000_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_SC (000U) /*!< Cortex secure core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC000_H_DEPENDANT +#define __CORE_SC000_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC000_REV + #define __SC000_REV 0x0000U + #warning "__SC000_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 0U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 2U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC000 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */ + uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t _reserved0:1; /*!< bit: 0 Reserved */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[31U]; + __IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RSERVED1[31U]; + __IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[31U]; + __IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[31U]; + uint32_t RESERVED4[64U]; + __IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */ +} NVIC_Type; + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + uint32_t RESERVED0[1U]; + __IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + uint32_t RESERVED1[154U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x1FFFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 8U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0xFFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief SC000 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor. + Therefore they are not covered by the SC000 header file. + @{ + */ +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else +/*#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping not available for SC000 */ +/*#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping not available for SC000 */ + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ +/*#define NVIC_GetActive __NVIC_GetActive not available for SC000 */ + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/* Interrupt Priorities are WORD accessible only under Armv6-M */ +/* The following MACROS handle generation of the register offset and byte masks */ +#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL) +#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) ) +#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) ) + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } + else + { + SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) | + (((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M0 and M0+ do not require the architectural barrier - assume SC000 is the same */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + SCB_AIRCR_SYSRESETREQ_Msk); + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC000_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/core_sc300.h b/bsp/tae32f5300/Libraries/CMSIS/Include/core_sc300.h new file mode 100644 index 0000000000..e8914ba601 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/core_sc300.h @@ -0,0 +1,1917 @@ +/**************************************************************************//** + * @file core_sc300.h + * @brief CMSIS SC300 Core Peripheral Access Layer Header File + * @version V5.0.9 + * @date 27. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_SC300_H_GENERIC +#define __CORE_SC300_H_GENERIC + +#include + +#ifdef __cplusplus + extern "C" { +#endif + +/** + \page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions + CMSIS violates the following MISRA-C:2004 rules: + + \li Required Rule 8.5, object/function definition in header file.
+ Function definitions in header files are used to allow 'inlining'. + + \li Required Rule 18.4, declaration of union type or object of union type: '{...}'.
+ Unions are used for effective representation of core registers. + + \li Advisory Rule 19.7, Function-like macro defined.
+ Function-like macros are used to allow more efficient code. + */ + + +/******************************************************************************* + * CMSIS definitions + ******************************************************************************/ +/** + \ingroup SC3000 + @{ + */ + +#include "cmsis_version.h" + +/* CMSIS SC300 definitions */ +#define __SC300_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */ +#define __SC300_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */ +#define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16U) | \ + __SC300_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */ + +#define __CORTEX_SC (300U) /*!< Cortex secure core */ + +/** __FPU_USED indicates whether an FPU is used or not. + This core does not support an FPU at all +*/ +#define __FPU_USED 0U + +#if defined ( __CC_ARM ) + #if defined __TARGET_FPU_VFP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #if defined __ARM_FP + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __GNUC__ ) + #if defined (__VFP_FP__) && !defined(__SOFTFP__) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __ICCARM__ ) + #if defined __ARMVFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TI_ARM__ ) + #if defined __TI_VFP_SUPPORT__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __TASKING__ ) + #if defined __FPU_VFP__ + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#elif defined ( __CSMC__ ) + #if ( __CSMC__ & 0x400U) + #error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)" + #endif + +#endif + +#include "cmsis_compiler.h" /* CMSIS compiler specific defines */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_GENERIC */ + +#ifndef __CMSIS_GENERIC + +#ifndef __CORE_SC300_H_DEPENDANT +#define __CORE_SC300_H_DEPENDANT + +#ifdef __cplusplus + extern "C" { +#endif + +/* check device defines and use defaults */ +#if defined __CHECK_DEVICE_DEFINES + #ifndef __SC300_REV + #define __SC300_REV 0x0000U + #warning "__SC300_REV not defined in device header file; using default!" + #endif + + #ifndef __MPU_PRESENT + #define __MPU_PRESENT 0U + #warning "__MPU_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __VTOR_PRESENT + #define __VTOR_PRESENT 1U + #warning "__VTOR_PRESENT not defined in device header file; using default!" + #endif + + #ifndef __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 3U + #warning "__NVIC_PRIO_BITS not defined in device header file; using default!" + #endif + + #ifndef __Vendor_SysTickConfig + #define __Vendor_SysTickConfig 0U + #warning "__Vendor_SysTickConfig not defined in device header file; using default!" + #endif +#endif + +/* IO definitions (access restrictions to peripheral registers) */ +/** + \defgroup CMSIS_glob_defs CMSIS Global Defines + + IO Type Qualifiers are used + \li to specify the access to peripheral variables. + \li for automatic generation of peripheral register debug information. +*/ +#ifdef __cplusplus + #define __I volatile /*!< Defines 'read only' permissions */ +#else + #define __I volatile const /*!< Defines 'read only' permissions */ +#endif +#define __O volatile /*!< Defines 'write only' permissions */ +#define __IO volatile /*!< Defines 'read / write' permissions */ + +/* following defines should be used for structure members */ +#define __IM volatile const /*! Defines 'read only' structure member permissions */ +#define __OM volatile /*! Defines 'write only' structure member permissions */ +#define __IOM volatile /*! Defines 'read / write' structure member permissions */ + +/*@} end of group SC300 */ + + + +/******************************************************************************* + * Register Abstraction + Core Register contain: + - Core Register + - Core NVIC Register + - Core SCB Register + - Core SysTick Register + - Core Debug Register + - Core MPU Register + ******************************************************************************/ +/** + \defgroup CMSIS_core_register Defines and Type Definitions + \brief Type definitions and defines for Cortex-M processor based devices. +*/ + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CORE Status and Control Registers + \brief Core Register type definitions. + @{ + */ + +/** + \brief Union type to access the Application Program Status Register (APSR). + */ +typedef union +{ + struct + { + uint32_t _reserved0:27; /*!< bit: 0..26 Reserved */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} APSR_Type; + +/* APSR Register Definitions */ +#define APSR_N_Pos 31U /*!< APSR: N Position */ +#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */ + +#define APSR_Z_Pos 30U /*!< APSR: Z Position */ +#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */ + +#define APSR_C_Pos 29U /*!< APSR: C Position */ +#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */ + +#define APSR_V_Pos 28U /*!< APSR: V Position */ +#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */ + +#define APSR_Q_Pos 27U /*!< APSR: Q Position */ +#define APSR_Q_Msk (1UL << APSR_Q_Pos) /*!< APSR: Q Mask */ + + +/** + \brief Union type to access the Interrupt Program Status Register (IPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} IPSR_Type; + +/* IPSR Register Definitions */ +#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */ +#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */ + + +/** + \brief Union type to access the Special-Purpose Program Status Registers (xPSR). + */ +typedef union +{ + struct + { + uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */ + uint32_t _reserved0:1; /*!< bit: 9 Reserved */ + uint32_t ICI_IT_1:6; /*!< bit: 10..15 ICI/IT part 1 */ + uint32_t _reserved1:8; /*!< bit: 16..23 Reserved */ + uint32_t T:1; /*!< bit: 24 Thumb bit */ + uint32_t ICI_IT_2:2; /*!< bit: 25..26 ICI/IT part 2 */ + uint32_t Q:1; /*!< bit: 27 Saturation condition flag */ + uint32_t V:1; /*!< bit: 28 Overflow condition code flag */ + uint32_t C:1; /*!< bit: 29 Carry condition code flag */ + uint32_t Z:1; /*!< bit: 30 Zero condition code flag */ + uint32_t N:1; /*!< bit: 31 Negative condition code flag */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} xPSR_Type; + +/* xPSR Register Definitions */ +#define xPSR_N_Pos 31U /*!< xPSR: N Position */ +#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */ + +#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */ +#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */ + +#define xPSR_C_Pos 29U /*!< xPSR: C Position */ +#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */ + +#define xPSR_V_Pos 28U /*!< xPSR: V Position */ +#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */ + +#define xPSR_Q_Pos 27U /*!< xPSR: Q Position */ +#define xPSR_Q_Msk (1UL << xPSR_Q_Pos) /*!< xPSR: Q Mask */ + +#define xPSR_ICI_IT_2_Pos 25U /*!< xPSR: ICI/IT part 2 Position */ +#define xPSR_ICI_IT_2_Msk (3UL << xPSR_ICI_IT_2_Pos) /*!< xPSR: ICI/IT part 2 Mask */ + +#define xPSR_T_Pos 24U /*!< xPSR: T Position */ +#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */ + +#define xPSR_ICI_IT_1_Pos 10U /*!< xPSR: ICI/IT part 1 Position */ +#define xPSR_ICI_IT_1_Msk (0x3FUL << xPSR_ICI_IT_1_Pos) /*!< xPSR: ICI/IT part 1 Mask */ + +#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */ +#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */ + + +/** + \brief Union type to access the Control Registers (CONTROL). + */ +typedef union +{ + struct + { + uint32_t nPRIV:1; /*!< bit: 0 Execution privilege in Thread mode */ + uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */ + uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */ + } b; /*!< Structure used for bit access */ + uint32_t w; /*!< Type used for word access */ +} CONTROL_Type; + +/* CONTROL Register Definitions */ +#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */ +#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */ + +#define CONTROL_nPRIV_Pos 0U /*!< CONTROL: nPRIV Position */ +#define CONTROL_nPRIV_Msk (1UL /*<< CONTROL_nPRIV_Pos*/) /*!< CONTROL: nPRIV Mask */ + +/*@} end of group CMSIS_CORE */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC) + \brief Type definitions for the NVIC Registers + @{ + */ + +/** + \brief Structure type to access the Nested Vectored Interrupt Controller (NVIC). + */ +typedef struct +{ + __IOM uint32_t ISER[8U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */ + uint32_t RESERVED0[24U]; + __IOM uint32_t ICER[8U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */ + uint32_t RESERVED1[24U]; + __IOM uint32_t ISPR[8U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */ + uint32_t RESERVED2[24U]; + __IOM uint32_t ICPR[8U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */ + uint32_t RESERVED3[24U]; + __IOM uint32_t IABR[8U]; /*!< Offset: 0x200 (R/W) Interrupt Active bit Register */ + uint32_t RESERVED4[56U]; + __IOM uint8_t IP[240U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register (8Bit wide) */ + uint32_t RESERVED5[644U]; + __OM uint32_t STIR; /*!< Offset: 0xE00 ( /W) Software Trigger Interrupt Register */ +} NVIC_Type; + +/* Software Triggered Interrupt Register Definitions */ +#define NVIC_STIR_INTID_Pos 0U /*!< STIR: INTLINESNUM Position */ +#define NVIC_STIR_INTID_Msk (0x1FFUL /*<< NVIC_STIR_INTID_Pos*/) /*!< STIR: INTLINESNUM Mask */ + +/*@} end of group CMSIS_NVIC */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCB System Control Block (SCB) + \brief Type definitions for the System Control Block Registers + @{ + */ + +/** + \brief Structure type to access the System Control Block (SCB). + */ +typedef struct +{ + __IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */ + __IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */ + __IOM uint32_t VTOR; /*!< Offset: 0x008 (R/W) Vector Table Offset Register */ + __IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */ + __IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */ + __IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */ + __IOM uint8_t SHP[12U]; /*!< Offset: 0x018 (R/W) System Handlers Priority Registers (4-7, 8-11, 12-15) */ + __IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */ + __IOM uint32_t CFSR; /*!< Offset: 0x028 (R/W) Configurable Fault Status Register */ + __IOM uint32_t HFSR; /*!< Offset: 0x02C (R/W) HardFault Status Register */ + __IOM uint32_t DFSR; /*!< Offset: 0x030 (R/W) Debug Fault Status Register */ + __IOM uint32_t MMFAR; /*!< Offset: 0x034 (R/W) MemManage Fault Address Register */ + __IOM uint32_t BFAR; /*!< Offset: 0x038 (R/W) BusFault Address Register */ + __IOM uint32_t AFSR; /*!< Offset: 0x03C (R/W) Auxiliary Fault Status Register */ + __IM uint32_t PFR[2U]; /*!< Offset: 0x040 (R/ ) Processor Feature Register */ + __IM uint32_t DFR; /*!< Offset: 0x048 (R/ ) Debug Feature Register */ + __IM uint32_t ADR; /*!< Offset: 0x04C (R/ ) Auxiliary Feature Register */ + __IM uint32_t MMFR[4U]; /*!< Offset: 0x050 (R/ ) Memory Model Feature Register */ + __IM uint32_t ISAR[5U]; /*!< Offset: 0x060 (R/ ) Instruction Set Attributes Register */ + uint32_t RESERVED0[5U]; + __IOM uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */ + uint32_t RESERVED1[129U]; + __IOM uint32_t SFCR; /*!< Offset: 0x290 (R/W) Security Features Control Register */ +} SCB_Type; + +/* SCB CPUID Register Definitions */ +#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */ +#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */ + +#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */ +#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */ + +#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */ +#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */ + +#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */ +#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */ + +#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */ +#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */ + +/* SCB Interrupt Control State Register Definitions */ +#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */ +#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */ + +#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */ +#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */ + +#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */ +#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */ + +#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */ +#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */ + +#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */ +#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */ + +#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */ +#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */ + +#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */ +#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */ + +#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */ +#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */ + +#define SCB_ICSR_RETTOBASE_Pos 11U /*!< SCB ICSR: RETTOBASE Position */ +#define SCB_ICSR_RETTOBASE_Msk (1UL << SCB_ICSR_RETTOBASE_Pos) /*!< SCB ICSR: RETTOBASE Mask */ + +#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */ +#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */ + +/* SCB Vector Table Offset Register Definitions */ +#define SCB_VTOR_TBLBASE_Pos 29U /*!< SCB VTOR: TBLBASE Position */ +#define SCB_VTOR_TBLBASE_Msk (1UL << SCB_VTOR_TBLBASE_Pos) /*!< SCB VTOR: TBLBASE Mask */ + +#define SCB_VTOR_TBLOFF_Pos 7U /*!< SCB VTOR: TBLOFF Position */ +#define SCB_VTOR_TBLOFF_Msk (0x3FFFFFUL << SCB_VTOR_TBLOFF_Pos) /*!< SCB VTOR: TBLOFF Mask */ + +/* SCB Application Interrupt and Reset Control Register Definitions */ +#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */ +#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */ + +#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */ +#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */ + +#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */ +#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */ + +#define SCB_AIRCR_PRIGROUP_Pos 8U /*!< SCB AIRCR: PRIGROUP Position */ +#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */ + +#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */ +#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */ + +#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */ +#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */ + +#define SCB_AIRCR_VECTRESET_Pos 0U /*!< SCB AIRCR: VECTRESET Position */ +#define SCB_AIRCR_VECTRESET_Msk (1UL /*<< SCB_AIRCR_VECTRESET_Pos*/) /*!< SCB AIRCR: VECTRESET Mask */ + +/* SCB System Control Register Definitions */ +#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */ +#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */ + +#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */ +#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */ + +#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */ +#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */ + +/* SCB Configuration Control Register Definitions */ +#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */ +#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */ + +#define SCB_CCR_BFHFNMIGN_Pos 8U /*!< SCB CCR: BFHFNMIGN Position */ +#define SCB_CCR_BFHFNMIGN_Msk (1UL << SCB_CCR_BFHFNMIGN_Pos) /*!< SCB CCR: BFHFNMIGN Mask */ + +#define SCB_CCR_DIV_0_TRP_Pos 4U /*!< SCB CCR: DIV_0_TRP Position */ +#define SCB_CCR_DIV_0_TRP_Msk (1UL << SCB_CCR_DIV_0_TRP_Pos) /*!< SCB CCR: DIV_0_TRP Mask */ + +#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */ +#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */ + +#define SCB_CCR_USERSETMPEND_Pos 1U /*!< SCB CCR: USERSETMPEND Position */ +#define SCB_CCR_USERSETMPEND_Msk (1UL << SCB_CCR_USERSETMPEND_Pos) /*!< SCB CCR: USERSETMPEND Mask */ + +#define SCB_CCR_NONBASETHRDENA_Pos 0U /*!< SCB CCR: NONBASETHRDENA Position */ +#define SCB_CCR_NONBASETHRDENA_Msk (1UL /*<< SCB_CCR_NONBASETHRDENA_Pos*/) /*!< SCB CCR: NONBASETHRDENA Mask */ + +/* SCB System Handler Control and State Register Definitions */ +#define SCB_SHCSR_USGFAULTENA_Pos 18U /*!< SCB SHCSR: USGFAULTENA Position */ +#define SCB_SHCSR_USGFAULTENA_Msk (1UL << SCB_SHCSR_USGFAULTENA_Pos) /*!< SCB SHCSR: USGFAULTENA Mask */ + +#define SCB_SHCSR_BUSFAULTENA_Pos 17U /*!< SCB SHCSR: BUSFAULTENA Position */ +#define SCB_SHCSR_BUSFAULTENA_Msk (1UL << SCB_SHCSR_BUSFAULTENA_Pos) /*!< SCB SHCSR: BUSFAULTENA Mask */ + +#define SCB_SHCSR_MEMFAULTENA_Pos 16U /*!< SCB SHCSR: MEMFAULTENA Position */ +#define SCB_SHCSR_MEMFAULTENA_Msk (1UL << SCB_SHCSR_MEMFAULTENA_Pos) /*!< SCB SHCSR: MEMFAULTENA Mask */ + +#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */ +#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */ + +#define SCB_SHCSR_BUSFAULTPENDED_Pos 14U /*!< SCB SHCSR: BUSFAULTPENDED Position */ +#define SCB_SHCSR_BUSFAULTPENDED_Msk (1UL << SCB_SHCSR_BUSFAULTPENDED_Pos) /*!< SCB SHCSR: BUSFAULTPENDED Mask */ + +#define SCB_SHCSR_MEMFAULTPENDED_Pos 13U /*!< SCB SHCSR: MEMFAULTPENDED Position */ +#define SCB_SHCSR_MEMFAULTPENDED_Msk (1UL << SCB_SHCSR_MEMFAULTPENDED_Pos) /*!< SCB SHCSR: MEMFAULTPENDED Mask */ + +#define SCB_SHCSR_USGFAULTPENDED_Pos 12U /*!< SCB SHCSR: USGFAULTPENDED Position */ +#define SCB_SHCSR_USGFAULTPENDED_Msk (1UL << SCB_SHCSR_USGFAULTPENDED_Pos) /*!< SCB SHCSR: USGFAULTPENDED Mask */ + +#define SCB_SHCSR_SYSTICKACT_Pos 11U /*!< SCB SHCSR: SYSTICKACT Position */ +#define SCB_SHCSR_SYSTICKACT_Msk (1UL << SCB_SHCSR_SYSTICKACT_Pos) /*!< SCB SHCSR: SYSTICKACT Mask */ + +#define SCB_SHCSR_PENDSVACT_Pos 10U /*!< SCB SHCSR: PENDSVACT Position */ +#define SCB_SHCSR_PENDSVACT_Msk (1UL << SCB_SHCSR_PENDSVACT_Pos) /*!< SCB SHCSR: PENDSVACT Mask */ + +#define SCB_SHCSR_MONITORACT_Pos 8U /*!< SCB SHCSR: MONITORACT Position */ +#define SCB_SHCSR_MONITORACT_Msk (1UL << SCB_SHCSR_MONITORACT_Pos) /*!< SCB SHCSR: MONITORACT Mask */ + +#define SCB_SHCSR_SVCALLACT_Pos 7U /*!< SCB SHCSR: SVCALLACT Position */ +#define SCB_SHCSR_SVCALLACT_Msk (1UL << SCB_SHCSR_SVCALLACT_Pos) /*!< SCB SHCSR: SVCALLACT Mask */ + +#define SCB_SHCSR_USGFAULTACT_Pos 3U /*!< SCB SHCSR: USGFAULTACT Position */ +#define SCB_SHCSR_USGFAULTACT_Msk (1UL << SCB_SHCSR_USGFAULTACT_Pos) /*!< SCB SHCSR: USGFAULTACT Mask */ + +#define SCB_SHCSR_BUSFAULTACT_Pos 1U /*!< SCB SHCSR: BUSFAULTACT Position */ +#define SCB_SHCSR_BUSFAULTACT_Msk (1UL << SCB_SHCSR_BUSFAULTACT_Pos) /*!< SCB SHCSR: BUSFAULTACT Mask */ + +#define SCB_SHCSR_MEMFAULTACT_Pos 0U /*!< SCB SHCSR: MEMFAULTACT Position */ +#define SCB_SHCSR_MEMFAULTACT_Msk (1UL /*<< SCB_SHCSR_MEMFAULTACT_Pos*/) /*!< SCB SHCSR: MEMFAULTACT Mask */ + +/* SCB Configurable Fault Status Register Definitions */ +#define SCB_CFSR_USGFAULTSR_Pos 16U /*!< SCB CFSR: Usage Fault Status Register Position */ +#define SCB_CFSR_USGFAULTSR_Msk (0xFFFFUL << SCB_CFSR_USGFAULTSR_Pos) /*!< SCB CFSR: Usage Fault Status Register Mask */ + +#define SCB_CFSR_BUSFAULTSR_Pos 8U /*!< SCB CFSR: Bus Fault Status Register Position */ +#define SCB_CFSR_BUSFAULTSR_Msk (0xFFUL << SCB_CFSR_BUSFAULTSR_Pos) /*!< SCB CFSR: Bus Fault Status Register Mask */ + +#define SCB_CFSR_MEMFAULTSR_Pos 0U /*!< SCB CFSR: Memory Manage Fault Status Register Position */ +#define SCB_CFSR_MEMFAULTSR_Msk (0xFFUL /*<< SCB_CFSR_MEMFAULTSR_Pos*/) /*!< SCB CFSR: Memory Manage Fault Status Register Mask */ + +/* MemManage Fault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_MMARVALID_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 7U) /*!< SCB CFSR (MMFSR): MMARVALID Position */ +#define SCB_CFSR_MMARVALID_Msk (1UL << SCB_CFSR_MMARVALID_Pos) /*!< SCB CFSR (MMFSR): MMARVALID Mask */ + +#define SCB_CFSR_MSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 4U) /*!< SCB CFSR (MMFSR): MSTKERR Position */ +#define SCB_CFSR_MSTKERR_Msk (1UL << SCB_CFSR_MSTKERR_Pos) /*!< SCB CFSR (MMFSR): MSTKERR Mask */ + +#define SCB_CFSR_MUNSTKERR_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 3U) /*!< SCB CFSR (MMFSR): MUNSTKERR Position */ +#define SCB_CFSR_MUNSTKERR_Msk (1UL << SCB_CFSR_MUNSTKERR_Pos) /*!< SCB CFSR (MMFSR): MUNSTKERR Mask */ + +#define SCB_CFSR_DACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 1U) /*!< SCB CFSR (MMFSR): DACCVIOL Position */ +#define SCB_CFSR_DACCVIOL_Msk (1UL << SCB_CFSR_DACCVIOL_Pos) /*!< SCB CFSR (MMFSR): DACCVIOL Mask */ + +#define SCB_CFSR_IACCVIOL_Pos (SCB_SHCSR_MEMFAULTACT_Pos + 0U) /*!< SCB CFSR (MMFSR): IACCVIOL Position */ +#define SCB_CFSR_IACCVIOL_Msk (1UL /*<< SCB_CFSR_IACCVIOL_Pos*/) /*!< SCB CFSR (MMFSR): IACCVIOL Mask */ + +/* BusFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_BFARVALID_Pos (SCB_CFSR_BUSFAULTSR_Pos + 7U) /*!< SCB CFSR (BFSR): BFARVALID Position */ +#define SCB_CFSR_BFARVALID_Msk (1UL << SCB_CFSR_BFARVALID_Pos) /*!< SCB CFSR (BFSR): BFARVALID Mask */ + +#define SCB_CFSR_STKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 4U) /*!< SCB CFSR (BFSR): STKERR Position */ +#define SCB_CFSR_STKERR_Msk (1UL << SCB_CFSR_STKERR_Pos) /*!< SCB CFSR (BFSR): STKERR Mask */ + +#define SCB_CFSR_UNSTKERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 3U) /*!< SCB CFSR (BFSR): UNSTKERR Position */ +#define SCB_CFSR_UNSTKERR_Msk (1UL << SCB_CFSR_UNSTKERR_Pos) /*!< SCB CFSR (BFSR): UNSTKERR Mask */ + +#define SCB_CFSR_IMPRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 2U) /*!< SCB CFSR (BFSR): IMPRECISERR Position */ +#define SCB_CFSR_IMPRECISERR_Msk (1UL << SCB_CFSR_IMPRECISERR_Pos) /*!< SCB CFSR (BFSR): IMPRECISERR Mask */ + +#define SCB_CFSR_PRECISERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 1U) /*!< SCB CFSR (BFSR): PRECISERR Position */ +#define SCB_CFSR_PRECISERR_Msk (1UL << SCB_CFSR_PRECISERR_Pos) /*!< SCB CFSR (BFSR): PRECISERR Mask */ + +#define SCB_CFSR_IBUSERR_Pos (SCB_CFSR_BUSFAULTSR_Pos + 0U) /*!< SCB CFSR (BFSR): IBUSERR Position */ +#define SCB_CFSR_IBUSERR_Msk (1UL << SCB_CFSR_IBUSERR_Pos) /*!< SCB CFSR (BFSR): IBUSERR Mask */ + +/* UsageFault Status Register (part of SCB Configurable Fault Status Register) */ +#define SCB_CFSR_DIVBYZERO_Pos (SCB_CFSR_USGFAULTSR_Pos + 9U) /*!< SCB CFSR (UFSR): DIVBYZERO Position */ +#define SCB_CFSR_DIVBYZERO_Msk (1UL << SCB_CFSR_DIVBYZERO_Pos) /*!< SCB CFSR (UFSR): DIVBYZERO Mask */ + +#define SCB_CFSR_UNALIGNED_Pos (SCB_CFSR_USGFAULTSR_Pos + 8U) /*!< SCB CFSR (UFSR): UNALIGNED Position */ +#define SCB_CFSR_UNALIGNED_Msk (1UL << SCB_CFSR_UNALIGNED_Pos) /*!< SCB CFSR (UFSR): UNALIGNED Mask */ + +#define SCB_CFSR_NOCP_Pos (SCB_CFSR_USGFAULTSR_Pos + 3U) /*!< SCB CFSR (UFSR): NOCP Position */ +#define SCB_CFSR_NOCP_Msk (1UL << SCB_CFSR_NOCP_Pos) /*!< SCB CFSR (UFSR): NOCP Mask */ + +#define SCB_CFSR_INVPC_Pos (SCB_CFSR_USGFAULTSR_Pos + 2U) /*!< SCB CFSR (UFSR): INVPC Position */ +#define SCB_CFSR_INVPC_Msk (1UL << SCB_CFSR_INVPC_Pos) /*!< SCB CFSR (UFSR): INVPC Mask */ + +#define SCB_CFSR_INVSTATE_Pos (SCB_CFSR_USGFAULTSR_Pos + 1U) /*!< SCB CFSR (UFSR): INVSTATE Position */ +#define SCB_CFSR_INVSTATE_Msk (1UL << SCB_CFSR_INVSTATE_Pos) /*!< SCB CFSR (UFSR): INVSTATE Mask */ + +#define SCB_CFSR_UNDEFINSTR_Pos (SCB_CFSR_USGFAULTSR_Pos + 0U) /*!< SCB CFSR (UFSR): UNDEFINSTR Position */ +#define SCB_CFSR_UNDEFINSTR_Msk (1UL << SCB_CFSR_UNDEFINSTR_Pos) /*!< SCB CFSR (UFSR): UNDEFINSTR Mask */ + +/* SCB Hard Fault Status Register Definitions */ +#define SCB_HFSR_DEBUGEVT_Pos 31U /*!< SCB HFSR: DEBUGEVT Position */ +#define SCB_HFSR_DEBUGEVT_Msk (1UL << SCB_HFSR_DEBUGEVT_Pos) /*!< SCB HFSR: DEBUGEVT Mask */ + +#define SCB_HFSR_FORCED_Pos 30U /*!< SCB HFSR: FORCED Position */ +#define SCB_HFSR_FORCED_Msk (1UL << SCB_HFSR_FORCED_Pos) /*!< SCB HFSR: FORCED Mask */ + +#define SCB_HFSR_VECTTBL_Pos 1U /*!< SCB HFSR: VECTTBL Position */ +#define SCB_HFSR_VECTTBL_Msk (1UL << SCB_HFSR_VECTTBL_Pos) /*!< SCB HFSR: VECTTBL Mask */ + +/* SCB Debug Fault Status Register Definitions */ +#define SCB_DFSR_EXTERNAL_Pos 4U /*!< SCB DFSR: EXTERNAL Position */ +#define SCB_DFSR_EXTERNAL_Msk (1UL << SCB_DFSR_EXTERNAL_Pos) /*!< SCB DFSR: EXTERNAL Mask */ + +#define SCB_DFSR_VCATCH_Pos 3U /*!< SCB DFSR: VCATCH Position */ +#define SCB_DFSR_VCATCH_Msk (1UL << SCB_DFSR_VCATCH_Pos) /*!< SCB DFSR: VCATCH Mask */ + +#define SCB_DFSR_DWTTRAP_Pos 2U /*!< SCB DFSR: DWTTRAP Position */ +#define SCB_DFSR_DWTTRAP_Msk (1UL << SCB_DFSR_DWTTRAP_Pos) /*!< SCB DFSR: DWTTRAP Mask */ + +#define SCB_DFSR_BKPT_Pos 1U /*!< SCB DFSR: BKPT Position */ +#define SCB_DFSR_BKPT_Msk (1UL << SCB_DFSR_BKPT_Pos) /*!< SCB DFSR: BKPT Mask */ + +#define SCB_DFSR_HALTED_Pos 0U /*!< SCB DFSR: HALTED Position */ +#define SCB_DFSR_HALTED_Msk (1UL /*<< SCB_DFSR_HALTED_Pos*/) /*!< SCB DFSR: HALTED Mask */ + +/*@} end of group CMSIS_SCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB) + \brief Type definitions for the System Control and ID Register not in the SCB + @{ + */ + +/** + \brief Structure type to access the System Control and ID Register not in the SCB. + */ +typedef struct +{ + uint32_t RESERVED0[1U]; + __IM uint32_t ICTR; /*!< Offset: 0x004 (R/ ) Interrupt Controller Type Register */ + __IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */ +} SCnSCB_Type; + +/* Interrupt Controller Type Register Definitions */ +#define SCnSCB_ICTR_INTLINESNUM_Pos 0U /*!< ICTR: INTLINESNUM Position */ +#define SCnSCB_ICTR_INTLINESNUM_Msk (0xFUL /*<< SCnSCB_ICTR_INTLINESNUM_Pos*/) /*!< ICTR: INTLINESNUM Mask */ + +/* Auxiliary Control Register Definitions */ +#define SCnSCB_ACTLR_DISFOLD_Pos 2U /*!< ACTLR: DISFOLD Position */ +#define SCnSCB_ACTLR_DISFOLD_Msk (1UL << SCnSCB_ACTLR_DISFOLD_Pos) /*!< ACTLR: DISFOLD Mask */ + +#define SCnSCB_ACTLR_DISDEFWBUF_Pos 1U /*!< ACTLR: DISDEFWBUF Position */ +#define SCnSCB_ACTLR_DISDEFWBUF_Msk (1UL << SCnSCB_ACTLR_DISDEFWBUF_Pos) /*!< ACTLR: DISDEFWBUF Mask */ + +#define SCnSCB_ACTLR_DISMCYCINT_Pos 0U /*!< ACTLR: DISMCYCINT Position */ +#define SCnSCB_ACTLR_DISMCYCINT_Msk (1UL /*<< SCnSCB_ACTLR_DISMCYCINT_Pos*/) /*!< ACTLR: DISMCYCINT Mask */ + +/*@} end of group CMSIS_SCnotSCB */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_SysTick System Tick Timer (SysTick) + \brief Type definitions for the System Timer Registers. + @{ + */ + +/** + \brief Structure type to access the System Timer (SysTick). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */ + __IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */ + __IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */ + __IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */ +} SysTick_Type; + +/* SysTick Control / Status Register Definitions */ +#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */ +#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */ + +#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */ +#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */ + +#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */ +#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */ + +#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */ +#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */ + +/* SysTick Reload Register Definitions */ +#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */ +#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */ + +/* SysTick Current Register Definitions */ +#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */ +#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */ + +/* SysTick Calibration Register Definitions */ +#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */ +#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */ + +#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */ +#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */ + +#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */ +#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */ + +/*@} end of group CMSIS_SysTick */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_ITM Instrumentation Trace Macrocell (ITM) + \brief Type definitions for the Instrumentation Trace Macrocell (ITM) + @{ + */ + +/** + \brief Structure type to access the Instrumentation Trace Macrocell Register (ITM). + */ +typedef struct +{ + __OM union + { + __OM uint8_t u8; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 8-bit */ + __OM uint16_t u16; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 16-bit */ + __OM uint32_t u32; /*!< Offset: 0x000 ( /W) ITM Stimulus Port 32-bit */ + } PORT [32U]; /*!< Offset: 0x000 ( /W) ITM Stimulus Port Registers */ + uint32_t RESERVED0[864U]; + __IOM uint32_t TER; /*!< Offset: 0xE00 (R/W) ITM Trace Enable Register */ + uint32_t RESERVED1[15U]; + __IOM uint32_t TPR; /*!< Offset: 0xE40 (R/W) ITM Trace Privilege Register */ + uint32_t RESERVED2[15U]; + __IOM uint32_t TCR; /*!< Offset: 0xE80 (R/W) ITM Trace Control Register */ + uint32_t RESERVED3[32U]; + uint32_t RESERVED4[43U]; + __OM uint32_t LAR; /*!< Offset: 0xFB0 ( /W) ITM Lock Access Register */ + __IM uint32_t LSR; /*!< Offset: 0xFB4 (R/ ) ITM Lock Status Register */ + uint32_t RESERVED5[6U]; + __IM uint32_t PID4; /*!< Offset: 0xFD0 (R/ ) ITM Peripheral Identification Register #4 */ + __IM uint32_t PID5; /*!< Offset: 0xFD4 (R/ ) ITM Peripheral Identification Register #5 */ + __IM uint32_t PID6; /*!< Offset: 0xFD8 (R/ ) ITM Peripheral Identification Register #6 */ + __IM uint32_t PID7; /*!< Offset: 0xFDC (R/ ) ITM Peripheral Identification Register #7 */ + __IM uint32_t PID0; /*!< Offset: 0xFE0 (R/ ) ITM Peripheral Identification Register #0 */ + __IM uint32_t PID1; /*!< Offset: 0xFE4 (R/ ) ITM Peripheral Identification Register #1 */ + __IM uint32_t PID2; /*!< Offset: 0xFE8 (R/ ) ITM Peripheral Identification Register #2 */ + __IM uint32_t PID3; /*!< Offset: 0xFEC (R/ ) ITM Peripheral Identification Register #3 */ + __IM uint32_t CID0; /*!< Offset: 0xFF0 (R/ ) ITM Component Identification Register #0 */ + __IM uint32_t CID1; /*!< Offset: 0xFF4 (R/ ) ITM Component Identification Register #1 */ + __IM uint32_t CID2; /*!< Offset: 0xFF8 (R/ ) ITM Component Identification Register #2 */ + __IM uint32_t CID3; /*!< Offset: 0xFFC (R/ ) ITM Component Identification Register #3 */ +} ITM_Type; + +/* ITM Trace Privilege Register Definitions */ +#define ITM_TPR_PRIVMASK_Pos 0U /*!< ITM TPR: PRIVMASK Position */ +#define ITM_TPR_PRIVMASK_Msk (0xFUL /*<< ITM_TPR_PRIVMASK_Pos*/) /*!< ITM TPR: PRIVMASK Mask */ + +/* ITM Trace Control Register Definitions */ +#define ITM_TCR_BUSY_Pos 23U /*!< ITM TCR: BUSY Position */ +#define ITM_TCR_BUSY_Msk (1UL << ITM_TCR_BUSY_Pos) /*!< ITM TCR: BUSY Mask */ + +#define ITM_TCR_TraceBusID_Pos 16U /*!< ITM TCR: ATBID Position */ +#define ITM_TCR_TraceBusID_Msk (0x7FUL << ITM_TCR_TraceBusID_Pos) /*!< ITM TCR: ATBID Mask */ + +#define ITM_TCR_GTSFREQ_Pos 10U /*!< ITM TCR: Global timestamp frequency Position */ +#define ITM_TCR_GTSFREQ_Msk (3UL << ITM_TCR_GTSFREQ_Pos) /*!< ITM TCR: Global timestamp frequency Mask */ + +#define ITM_TCR_TSPrescale_Pos 8U /*!< ITM TCR: TSPrescale Position */ +#define ITM_TCR_TSPrescale_Msk (3UL << ITM_TCR_TSPrescale_Pos) /*!< ITM TCR: TSPrescale Mask */ + +#define ITM_TCR_SWOENA_Pos 4U /*!< ITM TCR: SWOENA Position */ +#define ITM_TCR_SWOENA_Msk (1UL << ITM_TCR_SWOENA_Pos) /*!< ITM TCR: SWOENA Mask */ + +#define ITM_TCR_DWTENA_Pos 3U /*!< ITM TCR: DWTENA Position */ +#define ITM_TCR_DWTENA_Msk (1UL << ITM_TCR_DWTENA_Pos) /*!< ITM TCR: DWTENA Mask */ + +#define ITM_TCR_SYNCENA_Pos 2U /*!< ITM TCR: SYNCENA Position */ +#define ITM_TCR_SYNCENA_Msk (1UL << ITM_TCR_SYNCENA_Pos) /*!< ITM TCR: SYNCENA Mask */ + +#define ITM_TCR_TSENA_Pos 1U /*!< ITM TCR: TSENA Position */ +#define ITM_TCR_TSENA_Msk (1UL << ITM_TCR_TSENA_Pos) /*!< ITM TCR: TSENA Mask */ + +#define ITM_TCR_ITMENA_Pos 0U /*!< ITM TCR: ITM Enable bit Position */ +#define ITM_TCR_ITMENA_Msk (1UL /*<< ITM_TCR_ITMENA_Pos*/) /*!< ITM TCR: ITM Enable bit Mask */ + +/* ITM Lock Status Register Definitions */ +#define ITM_LSR_ByteAcc_Pos 2U /*!< ITM LSR: ByteAcc Position */ +#define ITM_LSR_ByteAcc_Msk (1UL << ITM_LSR_ByteAcc_Pos) /*!< ITM LSR: ByteAcc Mask */ + +#define ITM_LSR_Access_Pos 1U /*!< ITM LSR: Access Position */ +#define ITM_LSR_Access_Msk (1UL << ITM_LSR_Access_Pos) /*!< ITM LSR: Access Mask */ + +#define ITM_LSR_Present_Pos 0U /*!< ITM LSR: Present Position */ +#define ITM_LSR_Present_Msk (1UL /*<< ITM_LSR_Present_Pos*/) /*!< ITM LSR: Present Mask */ + +/*@}*/ /* end of group CMSIS_ITM */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_DWT Data Watchpoint and Trace (DWT) + \brief Type definitions for the Data Watchpoint and Trace (DWT) + @{ + */ + +/** + \brief Structure type to access the Data Watchpoint and Trace Register (DWT). + */ +typedef struct +{ + __IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) Control Register */ + __IOM uint32_t CYCCNT; /*!< Offset: 0x004 (R/W) Cycle Count Register */ + __IOM uint32_t CPICNT; /*!< Offset: 0x008 (R/W) CPI Count Register */ + __IOM uint32_t EXCCNT; /*!< Offset: 0x00C (R/W) Exception Overhead Count Register */ + __IOM uint32_t SLEEPCNT; /*!< Offset: 0x010 (R/W) Sleep Count Register */ + __IOM uint32_t LSUCNT; /*!< Offset: 0x014 (R/W) LSU Count Register */ + __IOM uint32_t FOLDCNT; /*!< Offset: 0x018 (R/W) Folded-instruction Count Register */ + __IM uint32_t PCSR; /*!< Offset: 0x01C (R/ ) Program Counter Sample Register */ + __IOM uint32_t COMP0; /*!< Offset: 0x020 (R/W) Comparator Register 0 */ + __IOM uint32_t MASK0; /*!< Offset: 0x024 (R/W) Mask Register 0 */ + __IOM uint32_t FUNCTION0; /*!< Offset: 0x028 (R/W) Function Register 0 */ + uint32_t RESERVED0[1U]; + __IOM uint32_t COMP1; /*!< Offset: 0x030 (R/W) Comparator Register 1 */ + __IOM uint32_t MASK1; /*!< Offset: 0x034 (R/W) Mask Register 1 */ + __IOM uint32_t FUNCTION1; /*!< Offset: 0x038 (R/W) Function Register 1 */ + uint32_t RESERVED1[1U]; + __IOM uint32_t COMP2; /*!< Offset: 0x040 (R/W) Comparator Register 2 */ + __IOM uint32_t MASK2; /*!< Offset: 0x044 (R/W) Mask Register 2 */ + __IOM uint32_t FUNCTION2; /*!< Offset: 0x048 (R/W) Function Register 2 */ + uint32_t RESERVED2[1U]; + __IOM uint32_t COMP3; /*!< Offset: 0x050 (R/W) Comparator Register 3 */ + __IOM uint32_t MASK3; /*!< Offset: 0x054 (R/W) Mask Register 3 */ + __IOM uint32_t FUNCTION3; /*!< Offset: 0x058 (R/W) Function Register 3 */ +} DWT_Type; + +/* DWT Control Register Definitions */ +#define DWT_CTRL_NUMCOMP_Pos 28U /*!< DWT CTRL: NUMCOMP Position */ +#define DWT_CTRL_NUMCOMP_Msk (0xFUL << DWT_CTRL_NUMCOMP_Pos) /*!< DWT CTRL: NUMCOMP Mask */ + +#define DWT_CTRL_NOTRCPKT_Pos 27U /*!< DWT CTRL: NOTRCPKT Position */ +#define DWT_CTRL_NOTRCPKT_Msk (0x1UL << DWT_CTRL_NOTRCPKT_Pos) /*!< DWT CTRL: NOTRCPKT Mask */ + +#define DWT_CTRL_NOEXTTRIG_Pos 26U /*!< DWT CTRL: NOEXTTRIG Position */ +#define DWT_CTRL_NOEXTTRIG_Msk (0x1UL << DWT_CTRL_NOEXTTRIG_Pos) /*!< DWT CTRL: NOEXTTRIG Mask */ + +#define DWT_CTRL_NOCYCCNT_Pos 25U /*!< DWT CTRL: NOCYCCNT Position */ +#define DWT_CTRL_NOCYCCNT_Msk (0x1UL << DWT_CTRL_NOCYCCNT_Pos) /*!< DWT CTRL: NOCYCCNT Mask */ + +#define DWT_CTRL_NOPRFCNT_Pos 24U /*!< DWT CTRL: NOPRFCNT Position */ +#define DWT_CTRL_NOPRFCNT_Msk (0x1UL << DWT_CTRL_NOPRFCNT_Pos) /*!< DWT CTRL: NOPRFCNT Mask */ + +#define DWT_CTRL_CYCEVTENA_Pos 22U /*!< DWT CTRL: CYCEVTENA Position */ +#define DWT_CTRL_CYCEVTENA_Msk (0x1UL << DWT_CTRL_CYCEVTENA_Pos) /*!< DWT CTRL: CYCEVTENA Mask */ + +#define DWT_CTRL_FOLDEVTENA_Pos 21U /*!< DWT CTRL: FOLDEVTENA Position */ +#define DWT_CTRL_FOLDEVTENA_Msk (0x1UL << DWT_CTRL_FOLDEVTENA_Pos) /*!< DWT CTRL: FOLDEVTENA Mask */ + +#define DWT_CTRL_LSUEVTENA_Pos 20U /*!< DWT CTRL: LSUEVTENA Position */ +#define DWT_CTRL_LSUEVTENA_Msk (0x1UL << DWT_CTRL_LSUEVTENA_Pos) /*!< DWT CTRL: LSUEVTENA Mask */ + +#define DWT_CTRL_SLEEPEVTENA_Pos 19U /*!< DWT CTRL: SLEEPEVTENA Position */ +#define DWT_CTRL_SLEEPEVTENA_Msk (0x1UL << DWT_CTRL_SLEEPEVTENA_Pos) /*!< DWT CTRL: SLEEPEVTENA Mask */ + +#define DWT_CTRL_EXCEVTENA_Pos 18U /*!< DWT CTRL: EXCEVTENA Position */ +#define DWT_CTRL_EXCEVTENA_Msk (0x1UL << DWT_CTRL_EXCEVTENA_Pos) /*!< DWT CTRL: EXCEVTENA Mask */ + +#define DWT_CTRL_CPIEVTENA_Pos 17U /*!< DWT CTRL: CPIEVTENA Position */ +#define DWT_CTRL_CPIEVTENA_Msk (0x1UL << DWT_CTRL_CPIEVTENA_Pos) /*!< DWT CTRL: CPIEVTENA Mask */ + +#define DWT_CTRL_EXCTRCENA_Pos 16U /*!< DWT CTRL: EXCTRCENA Position */ +#define DWT_CTRL_EXCTRCENA_Msk (0x1UL << DWT_CTRL_EXCTRCENA_Pos) /*!< DWT CTRL: EXCTRCENA Mask */ + +#define DWT_CTRL_PCSAMPLENA_Pos 12U /*!< DWT CTRL: PCSAMPLENA Position */ +#define DWT_CTRL_PCSAMPLENA_Msk (0x1UL << DWT_CTRL_PCSAMPLENA_Pos) /*!< DWT CTRL: PCSAMPLENA Mask */ + +#define DWT_CTRL_SYNCTAP_Pos 10U /*!< DWT CTRL: SYNCTAP Position */ +#define DWT_CTRL_SYNCTAP_Msk (0x3UL << DWT_CTRL_SYNCTAP_Pos) /*!< DWT CTRL: SYNCTAP Mask */ + +#define DWT_CTRL_CYCTAP_Pos 9U /*!< DWT CTRL: CYCTAP Position */ +#define DWT_CTRL_CYCTAP_Msk (0x1UL << DWT_CTRL_CYCTAP_Pos) /*!< DWT CTRL: CYCTAP Mask */ + +#define DWT_CTRL_POSTINIT_Pos 5U /*!< DWT CTRL: POSTINIT Position */ +#define DWT_CTRL_POSTINIT_Msk (0xFUL << DWT_CTRL_POSTINIT_Pos) /*!< DWT CTRL: POSTINIT Mask */ + +#define DWT_CTRL_POSTPRESET_Pos 1U /*!< DWT CTRL: POSTPRESET Position */ +#define DWT_CTRL_POSTPRESET_Msk (0xFUL << DWT_CTRL_POSTPRESET_Pos) /*!< DWT CTRL: POSTPRESET Mask */ + +#define DWT_CTRL_CYCCNTENA_Pos 0U /*!< DWT CTRL: CYCCNTENA Position */ +#define DWT_CTRL_CYCCNTENA_Msk (0x1UL /*<< DWT_CTRL_CYCCNTENA_Pos*/) /*!< DWT CTRL: CYCCNTENA Mask */ + +/* DWT CPI Count Register Definitions */ +#define DWT_CPICNT_CPICNT_Pos 0U /*!< DWT CPICNT: CPICNT Position */ +#define DWT_CPICNT_CPICNT_Msk (0xFFUL /*<< DWT_CPICNT_CPICNT_Pos*/) /*!< DWT CPICNT: CPICNT Mask */ + +/* DWT Exception Overhead Count Register Definitions */ +#define DWT_EXCCNT_EXCCNT_Pos 0U /*!< DWT EXCCNT: EXCCNT Position */ +#define DWT_EXCCNT_EXCCNT_Msk (0xFFUL /*<< DWT_EXCCNT_EXCCNT_Pos*/) /*!< DWT EXCCNT: EXCCNT Mask */ + +/* DWT Sleep Count Register Definitions */ +#define DWT_SLEEPCNT_SLEEPCNT_Pos 0U /*!< DWT SLEEPCNT: SLEEPCNT Position */ +#define DWT_SLEEPCNT_SLEEPCNT_Msk (0xFFUL /*<< DWT_SLEEPCNT_SLEEPCNT_Pos*/) /*!< DWT SLEEPCNT: SLEEPCNT Mask */ + +/* DWT LSU Count Register Definitions */ +#define DWT_LSUCNT_LSUCNT_Pos 0U /*!< DWT LSUCNT: LSUCNT Position */ +#define DWT_LSUCNT_LSUCNT_Msk (0xFFUL /*<< DWT_LSUCNT_LSUCNT_Pos*/) /*!< DWT LSUCNT: LSUCNT Mask */ + +/* DWT Folded-instruction Count Register Definitions */ +#define DWT_FOLDCNT_FOLDCNT_Pos 0U /*!< DWT FOLDCNT: FOLDCNT Position */ +#define DWT_FOLDCNT_FOLDCNT_Msk (0xFFUL /*<< DWT_FOLDCNT_FOLDCNT_Pos*/) /*!< DWT FOLDCNT: FOLDCNT Mask */ + +/* DWT Comparator Mask Register Definitions */ +#define DWT_MASK_MASK_Pos 0U /*!< DWT MASK: MASK Position */ +#define DWT_MASK_MASK_Msk (0x1FUL /*<< DWT_MASK_MASK_Pos*/) /*!< DWT MASK: MASK Mask */ + +/* DWT Comparator Function Register Definitions */ +#define DWT_FUNCTION_MATCHED_Pos 24U /*!< DWT FUNCTION: MATCHED Position */ +#define DWT_FUNCTION_MATCHED_Msk (0x1UL << DWT_FUNCTION_MATCHED_Pos) /*!< DWT FUNCTION: MATCHED Mask */ + +#define DWT_FUNCTION_DATAVADDR1_Pos 16U /*!< DWT FUNCTION: DATAVADDR1 Position */ +#define DWT_FUNCTION_DATAVADDR1_Msk (0xFUL << DWT_FUNCTION_DATAVADDR1_Pos) /*!< DWT FUNCTION: DATAVADDR1 Mask */ + +#define DWT_FUNCTION_DATAVADDR0_Pos 12U /*!< DWT FUNCTION: DATAVADDR0 Position */ +#define DWT_FUNCTION_DATAVADDR0_Msk (0xFUL << DWT_FUNCTION_DATAVADDR0_Pos) /*!< DWT FUNCTION: DATAVADDR0 Mask */ + +#define DWT_FUNCTION_DATAVSIZE_Pos 10U /*!< DWT FUNCTION: DATAVSIZE Position */ +#define DWT_FUNCTION_DATAVSIZE_Msk (0x3UL << DWT_FUNCTION_DATAVSIZE_Pos) /*!< DWT FUNCTION: DATAVSIZE Mask */ + +#define DWT_FUNCTION_LNK1ENA_Pos 9U /*!< DWT FUNCTION: LNK1ENA Position */ +#define DWT_FUNCTION_LNK1ENA_Msk (0x1UL << DWT_FUNCTION_LNK1ENA_Pos) /*!< DWT FUNCTION: LNK1ENA Mask */ + +#define DWT_FUNCTION_DATAVMATCH_Pos 8U /*!< DWT FUNCTION: DATAVMATCH Position */ +#define DWT_FUNCTION_DATAVMATCH_Msk (0x1UL << DWT_FUNCTION_DATAVMATCH_Pos) /*!< DWT FUNCTION: DATAVMATCH Mask */ + +#define DWT_FUNCTION_CYCMATCH_Pos 7U /*!< DWT FUNCTION: CYCMATCH Position */ +#define DWT_FUNCTION_CYCMATCH_Msk (0x1UL << DWT_FUNCTION_CYCMATCH_Pos) /*!< DWT FUNCTION: CYCMATCH Mask */ + +#define DWT_FUNCTION_EMITRANGE_Pos 5U /*!< DWT FUNCTION: EMITRANGE Position */ +#define DWT_FUNCTION_EMITRANGE_Msk (0x1UL << DWT_FUNCTION_EMITRANGE_Pos) /*!< DWT FUNCTION: EMITRANGE Mask */ + +#define DWT_FUNCTION_FUNCTION_Pos 0U /*!< DWT FUNCTION: FUNCTION Position */ +#define DWT_FUNCTION_FUNCTION_Msk (0xFUL /*<< DWT_FUNCTION_FUNCTION_Pos*/) /*!< DWT FUNCTION: FUNCTION Mask */ + +/*@}*/ /* end of group CMSIS_DWT */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_TPI Trace Port Interface (TPI) + \brief Type definitions for the Trace Port Interface (TPI) + @{ + */ + +/** + \brief Structure type to access the Trace Port Interface Register (TPI). + */ +typedef struct +{ + __IM uint32_t SSPSR; /*!< Offset: 0x000 (R/ ) Supported Parallel Port Size Register */ + __IOM uint32_t CSPSR; /*!< Offset: 0x004 (R/W) Current Parallel Port Size Register */ + uint32_t RESERVED0[2U]; + __IOM uint32_t ACPR; /*!< Offset: 0x010 (R/W) Asynchronous Clock Prescaler Register */ + uint32_t RESERVED1[55U]; + __IOM uint32_t SPPR; /*!< Offset: 0x0F0 (R/W) Selected Pin Protocol Register */ + uint32_t RESERVED2[131U]; + __IM uint32_t FFSR; /*!< Offset: 0x300 (R/ ) Formatter and Flush Status Register */ + __IOM uint32_t FFCR; /*!< Offset: 0x304 (R/W) Formatter and Flush Control Register */ + __IM uint32_t FSCR; /*!< Offset: 0x308 (R/ ) Formatter Synchronization Counter Register */ + uint32_t RESERVED3[759U]; + __IM uint32_t TRIGGER; /*!< Offset: 0xEE8 (R/ ) TRIGGER Register */ + __IM uint32_t FIFO0; /*!< Offset: 0xEEC (R/ ) Integration ETM Data */ + __IM uint32_t ITATBCTR2; /*!< Offset: 0xEF0 (R/ ) ITATBCTR2 */ + uint32_t RESERVED4[1U]; + __IM uint32_t ITATBCTR0; /*!< Offset: 0xEF8 (R/ ) ITATBCTR0 */ + __IM uint32_t FIFO1; /*!< Offset: 0xEFC (R/ ) Integration ITM Data */ + __IOM uint32_t ITCTRL; /*!< Offset: 0xF00 (R/W) Integration Mode Control */ + uint32_t RESERVED5[39U]; + __IOM uint32_t CLAIMSET; /*!< Offset: 0xFA0 (R/W) Claim tag set */ + __IOM uint32_t CLAIMCLR; /*!< Offset: 0xFA4 (R/W) Claim tag clear */ + uint32_t RESERVED7[8U]; + __IM uint32_t DEVID; /*!< Offset: 0xFC8 (R/ ) TPIU_DEVID */ + __IM uint32_t DEVTYPE; /*!< Offset: 0xFCC (R/ ) TPIU_DEVTYPE */ +} TPI_Type; + +/* TPI Asynchronous Clock Prescaler Register Definitions */ +#define TPI_ACPR_PRESCALER_Pos 0U /*!< TPI ACPR: PRESCALER Position */ +#define TPI_ACPR_PRESCALER_Msk (0x1FFFUL /*<< TPI_ACPR_PRESCALER_Pos*/) /*!< TPI ACPR: PRESCALER Mask */ + +/* TPI Selected Pin Protocol Register Definitions */ +#define TPI_SPPR_TXMODE_Pos 0U /*!< TPI SPPR: TXMODE Position */ +#define TPI_SPPR_TXMODE_Msk (0x3UL /*<< TPI_SPPR_TXMODE_Pos*/) /*!< TPI SPPR: TXMODE Mask */ + +/* TPI Formatter and Flush Status Register Definitions */ +#define TPI_FFSR_FtNonStop_Pos 3U /*!< TPI FFSR: FtNonStop Position */ +#define TPI_FFSR_FtNonStop_Msk (0x1UL << TPI_FFSR_FtNonStop_Pos) /*!< TPI FFSR: FtNonStop Mask */ + +#define TPI_FFSR_TCPresent_Pos 2U /*!< TPI FFSR: TCPresent Position */ +#define TPI_FFSR_TCPresent_Msk (0x1UL << TPI_FFSR_TCPresent_Pos) /*!< TPI FFSR: TCPresent Mask */ + +#define TPI_FFSR_FtStopped_Pos 1U /*!< TPI FFSR: FtStopped Position */ +#define TPI_FFSR_FtStopped_Msk (0x1UL << TPI_FFSR_FtStopped_Pos) /*!< TPI FFSR: FtStopped Mask */ + +#define TPI_FFSR_FlInProg_Pos 0U /*!< TPI FFSR: FlInProg Position */ +#define TPI_FFSR_FlInProg_Msk (0x1UL /*<< TPI_FFSR_FlInProg_Pos*/) /*!< TPI FFSR: FlInProg Mask */ + +/* TPI Formatter and Flush Control Register Definitions */ +#define TPI_FFCR_TrigIn_Pos 8U /*!< TPI FFCR: TrigIn Position */ +#define TPI_FFCR_TrigIn_Msk (0x1UL << TPI_FFCR_TrigIn_Pos) /*!< TPI FFCR: TrigIn Mask */ + +#define TPI_FFCR_EnFCont_Pos 1U /*!< TPI FFCR: EnFCont Position */ +#define TPI_FFCR_EnFCont_Msk (0x1UL << TPI_FFCR_EnFCont_Pos) /*!< TPI FFCR: EnFCont Mask */ + +/* TPI TRIGGER Register Definitions */ +#define TPI_TRIGGER_TRIGGER_Pos 0U /*!< TPI TRIGGER: TRIGGER Position */ +#define TPI_TRIGGER_TRIGGER_Msk (0x1UL /*<< TPI_TRIGGER_TRIGGER_Pos*/) /*!< TPI TRIGGER: TRIGGER Mask */ + +/* TPI Integration ETM Data Register Definitions (FIFO0) */ +#define TPI_FIFO0_ITM_ATVALID_Pos 29U /*!< TPI FIFO0: ITM_ATVALID Position */ +#define TPI_FIFO0_ITM_ATVALID_Msk (0x1UL << TPI_FIFO0_ITM_ATVALID_Pos) /*!< TPI FIFO0: ITM_ATVALID Mask */ + +#define TPI_FIFO0_ITM_bytecount_Pos 27U /*!< TPI FIFO0: ITM_bytecount Position */ +#define TPI_FIFO0_ITM_bytecount_Msk (0x3UL << TPI_FIFO0_ITM_bytecount_Pos) /*!< TPI FIFO0: ITM_bytecount Mask */ + +#define TPI_FIFO0_ETM_ATVALID_Pos 26U /*!< TPI FIFO0: ETM_ATVALID Position */ +#define TPI_FIFO0_ETM_ATVALID_Msk (0x1UL << TPI_FIFO0_ETM_ATVALID_Pos) /*!< TPI FIFO0: ETM_ATVALID Mask */ + +#define TPI_FIFO0_ETM_bytecount_Pos 24U /*!< TPI FIFO0: ETM_bytecount Position */ +#define TPI_FIFO0_ETM_bytecount_Msk (0x3UL << TPI_FIFO0_ETM_bytecount_Pos) /*!< TPI FIFO0: ETM_bytecount Mask */ + +#define TPI_FIFO0_ETM2_Pos 16U /*!< TPI FIFO0: ETM2 Position */ +#define TPI_FIFO0_ETM2_Msk (0xFFUL << TPI_FIFO0_ETM2_Pos) /*!< TPI FIFO0: ETM2 Mask */ + +#define TPI_FIFO0_ETM1_Pos 8U /*!< TPI FIFO0: ETM1 Position */ +#define TPI_FIFO0_ETM1_Msk (0xFFUL << TPI_FIFO0_ETM1_Pos) /*!< TPI FIFO0: ETM1 Mask */ + +#define TPI_FIFO0_ETM0_Pos 0U /*!< TPI FIFO0: ETM0 Position */ +#define TPI_FIFO0_ETM0_Msk (0xFFUL /*<< TPI_FIFO0_ETM0_Pos*/) /*!< TPI FIFO0: ETM0 Mask */ + +/* TPI ITATBCTR2 Register Definitions */ +#define TPI_ITATBCTR2_ATREADY2_Pos 0U /*!< TPI ITATBCTR2: ATREADY2 Position */ +#define TPI_ITATBCTR2_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY2_Pos*/) /*!< TPI ITATBCTR2: ATREADY2 Mask */ + +#define TPI_ITATBCTR2_ATREADY1_Pos 0U /*!< TPI ITATBCTR2: ATREADY1 Position */ +#define TPI_ITATBCTR2_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY1_Pos*/) /*!< TPI ITATBCTR2: ATREADY1 Mask */ + +/* TPI Integration ITM Data Register Definitions (FIFO1) */ +#define TPI_FIFO1_ITM_ATVALID_Pos 29U /*!< TPI FIFO1: ITM_ATVALID Position */ +#define TPI_FIFO1_ITM_ATVALID_Msk (0x1UL << TPI_FIFO1_ITM_ATVALID_Pos) /*!< TPI FIFO1: ITM_ATVALID Mask */ + +#define TPI_FIFO1_ITM_bytecount_Pos 27U /*!< TPI FIFO1: ITM_bytecount Position */ +#define TPI_FIFO1_ITM_bytecount_Msk (0x3UL << TPI_FIFO1_ITM_bytecount_Pos) /*!< TPI FIFO1: ITM_bytecount Mask */ + +#define TPI_FIFO1_ETM_ATVALID_Pos 26U /*!< TPI FIFO1: ETM_ATVALID Position */ +#define TPI_FIFO1_ETM_ATVALID_Msk (0x1UL << TPI_FIFO1_ETM_ATVALID_Pos) /*!< TPI FIFO1: ETM_ATVALID Mask */ + +#define TPI_FIFO1_ETM_bytecount_Pos 24U /*!< TPI FIFO1: ETM_bytecount Position */ +#define TPI_FIFO1_ETM_bytecount_Msk (0x3UL << TPI_FIFO1_ETM_bytecount_Pos) /*!< TPI FIFO1: ETM_bytecount Mask */ + +#define TPI_FIFO1_ITM2_Pos 16U /*!< TPI FIFO1: ITM2 Position */ +#define TPI_FIFO1_ITM2_Msk (0xFFUL << TPI_FIFO1_ITM2_Pos) /*!< TPI FIFO1: ITM2 Mask */ + +#define TPI_FIFO1_ITM1_Pos 8U /*!< TPI FIFO1: ITM1 Position */ +#define TPI_FIFO1_ITM1_Msk (0xFFUL << TPI_FIFO1_ITM1_Pos) /*!< TPI FIFO1: ITM1 Mask */ + +#define TPI_FIFO1_ITM0_Pos 0U /*!< TPI FIFO1: ITM0 Position */ +#define TPI_FIFO1_ITM0_Msk (0xFFUL /*<< TPI_FIFO1_ITM0_Pos*/) /*!< TPI FIFO1: ITM0 Mask */ + +/* TPI ITATBCTR0 Register Definitions */ +#define TPI_ITATBCTR0_ATREADY2_Pos 0U /*!< TPI ITATBCTR0: ATREADY2 Position */ +#define TPI_ITATBCTR0_ATREADY2_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY2_Pos*/) /*!< TPI ITATBCTR0: ATREADY2 Mask */ + +#define TPI_ITATBCTR0_ATREADY1_Pos 0U /*!< TPI ITATBCTR0: ATREADY1 Position */ +#define TPI_ITATBCTR0_ATREADY1_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY1_Pos*/) /*!< TPI ITATBCTR0: ATREADY1 Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x3UL /*<< TPI_ITCTRL_Mode_Pos*/) /*!< TPI ITCTRL: Mode Mask */ + +/* TPI DEVID Register Definitions */ +#define TPI_DEVID_NRZVALID_Pos 11U /*!< TPI DEVID: NRZVALID Position */ +#define TPI_DEVID_NRZVALID_Msk (0x1UL << TPI_DEVID_NRZVALID_Pos) /*!< TPI DEVID: NRZVALID Mask */ + +#define TPI_DEVID_MANCVALID_Pos 10U /*!< TPI DEVID: MANCVALID Position */ +#define TPI_DEVID_MANCVALID_Msk (0x1UL << TPI_DEVID_MANCVALID_Pos) /*!< TPI DEVID: MANCVALID Mask */ + +#define TPI_DEVID_PTINVALID_Pos 9U /*!< TPI DEVID: PTINVALID Position */ +#define TPI_DEVID_PTINVALID_Msk (0x1UL << TPI_DEVID_PTINVALID_Pos) /*!< TPI DEVID: PTINVALID Mask */ + +#define TPI_DEVID_MinBufSz_Pos 6U /*!< TPI DEVID: MinBufSz Position */ +#define TPI_DEVID_MinBufSz_Msk (0x7UL << TPI_DEVID_MinBufSz_Pos) /*!< TPI DEVID: MinBufSz Mask */ + +#define TPI_DEVID_AsynClkIn_Pos 5U /*!< TPI DEVID: AsynClkIn Position */ +#define TPI_DEVID_AsynClkIn_Msk (0x1UL << TPI_DEVID_AsynClkIn_Pos) /*!< TPI DEVID: AsynClkIn Mask */ + +#define TPI_DEVID_NrTraceInput_Pos 0U /*!< TPI DEVID: NrTraceInput Position */ +#define TPI_DEVID_NrTraceInput_Msk (0x1FUL /*<< TPI_DEVID_NrTraceInput_Pos*/) /*!< TPI DEVID: NrTraceInput Mask */ + +/* TPI DEVTYPE Register Definitions */ +#define TPI_DEVTYPE_SubType_Pos 4U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +#define TPI_DEVTYPE_MajorType_Pos 0U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_MPU Memory Protection Unit (MPU) + \brief Type definitions for the Memory Protection Unit (MPU) + @{ + */ + +/** + \brief Structure type to access the Memory Protection Unit (MPU). + */ +typedef struct +{ + __IM uint32_t TYPE; /*!< Offset: 0x000 (R/ ) MPU Type Register */ + __IOM uint32_t CTRL; /*!< Offset: 0x004 (R/W) MPU Control Register */ + __IOM uint32_t RNR; /*!< Offset: 0x008 (R/W) MPU Region RNRber Register */ + __IOM uint32_t RBAR; /*!< Offset: 0x00C (R/W) MPU Region Base Address Register */ + __IOM uint32_t RASR; /*!< Offset: 0x010 (R/W) MPU Region Attribute and Size Register */ + __IOM uint32_t RBAR_A1; /*!< Offset: 0x014 (R/W) MPU Alias 1 Region Base Address Register */ + __IOM uint32_t RASR_A1; /*!< Offset: 0x018 (R/W) MPU Alias 1 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A2; /*!< Offset: 0x01C (R/W) MPU Alias 2 Region Base Address Register */ + __IOM uint32_t RASR_A2; /*!< Offset: 0x020 (R/W) MPU Alias 2 Region Attribute and Size Register */ + __IOM uint32_t RBAR_A3; /*!< Offset: 0x024 (R/W) MPU Alias 3 Region Base Address Register */ + __IOM uint32_t RASR_A3; /*!< Offset: 0x028 (R/W) MPU Alias 3 Region Attribute and Size Register */ +} MPU_Type; + +/* MPU Type Register Definitions */ +#define MPU_TYPE_IREGION_Pos 16U /*!< MPU TYPE: IREGION Position */ +#define MPU_TYPE_IREGION_Msk (0xFFUL << MPU_TYPE_IREGION_Pos) /*!< MPU TYPE: IREGION Mask */ + +#define MPU_TYPE_DREGION_Pos 8U /*!< MPU TYPE: DREGION Position */ +#define MPU_TYPE_DREGION_Msk (0xFFUL << MPU_TYPE_DREGION_Pos) /*!< MPU TYPE: DREGION Mask */ + +#define MPU_TYPE_SEPARATE_Pos 0U /*!< MPU TYPE: SEPARATE Position */ +#define MPU_TYPE_SEPARATE_Msk (1UL /*<< MPU_TYPE_SEPARATE_Pos*/) /*!< MPU TYPE: SEPARATE Mask */ + +/* MPU Control Register Definitions */ +#define MPU_CTRL_PRIVDEFENA_Pos 2U /*!< MPU CTRL: PRIVDEFENA Position */ +#define MPU_CTRL_PRIVDEFENA_Msk (1UL << MPU_CTRL_PRIVDEFENA_Pos) /*!< MPU CTRL: PRIVDEFENA Mask */ + +#define MPU_CTRL_HFNMIENA_Pos 1U /*!< MPU CTRL: HFNMIENA Position */ +#define MPU_CTRL_HFNMIENA_Msk (1UL << MPU_CTRL_HFNMIENA_Pos) /*!< MPU CTRL: HFNMIENA Mask */ + +#define MPU_CTRL_ENABLE_Pos 0U /*!< MPU CTRL: ENABLE Position */ +#define MPU_CTRL_ENABLE_Msk (1UL /*<< MPU_CTRL_ENABLE_Pos*/) /*!< MPU CTRL: ENABLE Mask */ + +/* MPU Region Number Register Definitions */ +#define MPU_RNR_REGION_Pos 0U /*!< MPU RNR: REGION Position */ +#define MPU_RNR_REGION_Msk (0xFFUL /*<< MPU_RNR_REGION_Pos*/) /*!< MPU RNR: REGION Mask */ + +/* MPU Region Base Address Register Definitions */ +#define MPU_RBAR_ADDR_Pos 5U /*!< MPU RBAR: ADDR Position */ +#define MPU_RBAR_ADDR_Msk (0x7FFFFFFUL << MPU_RBAR_ADDR_Pos) /*!< MPU RBAR: ADDR Mask */ + +#define MPU_RBAR_VALID_Pos 4U /*!< MPU RBAR: VALID Position */ +#define MPU_RBAR_VALID_Msk (1UL << MPU_RBAR_VALID_Pos) /*!< MPU RBAR: VALID Mask */ + +#define MPU_RBAR_REGION_Pos 0U /*!< MPU RBAR: REGION Position */ +#define MPU_RBAR_REGION_Msk (0xFUL /*<< MPU_RBAR_REGION_Pos*/) /*!< MPU RBAR: REGION Mask */ + +/* MPU Region Attribute and Size Register Definitions */ +#define MPU_RASR_ATTRS_Pos 16U /*!< MPU RASR: MPU Region Attribute field Position */ +#define MPU_RASR_ATTRS_Msk (0xFFFFUL << MPU_RASR_ATTRS_Pos) /*!< MPU RASR: MPU Region Attribute field Mask */ + +#define MPU_RASR_XN_Pos 28U /*!< MPU RASR: ATTRS.XN Position */ +#define MPU_RASR_XN_Msk (1UL << MPU_RASR_XN_Pos) /*!< MPU RASR: ATTRS.XN Mask */ + +#define MPU_RASR_AP_Pos 24U /*!< MPU RASR: ATTRS.AP Position */ +#define MPU_RASR_AP_Msk (0x7UL << MPU_RASR_AP_Pos) /*!< MPU RASR: ATTRS.AP Mask */ + +#define MPU_RASR_TEX_Pos 19U /*!< MPU RASR: ATTRS.TEX Position */ +#define MPU_RASR_TEX_Msk (0x7UL << MPU_RASR_TEX_Pos) /*!< MPU RASR: ATTRS.TEX Mask */ + +#define MPU_RASR_S_Pos 18U /*!< MPU RASR: ATTRS.S Position */ +#define MPU_RASR_S_Msk (1UL << MPU_RASR_S_Pos) /*!< MPU RASR: ATTRS.S Mask */ + +#define MPU_RASR_C_Pos 17U /*!< MPU RASR: ATTRS.C Position */ +#define MPU_RASR_C_Msk (1UL << MPU_RASR_C_Pos) /*!< MPU RASR: ATTRS.C Mask */ + +#define MPU_RASR_B_Pos 16U /*!< MPU RASR: ATTRS.B Position */ +#define MPU_RASR_B_Msk (1UL << MPU_RASR_B_Pos) /*!< MPU RASR: ATTRS.B Mask */ + +#define MPU_RASR_SRD_Pos 8U /*!< MPU RASR: Sub-Region Disable Position */ +#define MPU_RASR_SRD_Msk (0xFFUL << MPU_RASR_SRD_Pos) /*!< MPU RASR: Sub-Region Disable Mask */ + +#define MPU_RASR_SIZE_Pos 1U /*!< MPU RASR: Region Size Field Position */ +#define MPU_RASR_SIZE_Msk (0x1FUL << MPU_RASR_SIZE_Pos) /*!< MPU RASR: Region Size Field Mask */ + +#define MPU_RASR_ENABLE_Pos 0U /*!< MPU RASR: Region enable bit Position */ +#define MPU_RASR_ENABLE_Msk (1UL /*<< MPU_RASR_ENABLE_Pos*/) /*!< MPU RASR: Region enable bit Disable Mask */ + +/*@} end of group CMSIS_MPU */ +#endif + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug) + \brief Type definitions for the Core Debug Registers + @{ + */ + +/** + \brief Structure type to access the Core Debug Register (CoreDebug). + */ +typedef struct +{ + __IOM uint32_t DHCSR; /*!< Offset: 0x000 (R/W) Debug Halting Control and Status Register */ + __OM uint32_t DCRSR; /*!< Offset: 0x004 ( /W) Debug Core Register Selector Register */ + __IOM uint32_t DCRDR; /*!< Offset: 0x008 (R/W) Debug Core Register Data Register */ + __IOM uint32_t DEMCR; /*!< Offset: 0x00C (R/W) Debug Exception and Monitor Control Register */ +} CoreDebug_Type; + +/* Debug Halting Control and Status Register Definitions */ +#define CoreDebug_DHCSR_DBGKEY_Pos 16U /*!< CoreDebug DHCSR: DBGKEY Position */ +#define CoreDebug_DHCSR_DBGKEY_Msk (0xFFFFUL << CoreDebug_DHCSR_DBGKEY_Pos) /*!< CoreDebug DHCSR: DBGKEY Mask */ + +#define CoreDebug_DHCSR_S_RESET_ST_Pos 25U /*!< CoreDebug DHCSR: S_RESET_ST Position */ +#define CoreDebug_DHCSR_S_RESET_ST_Msk (1UL << CoreDebug_DHCSR_S_RESET_ST_Pos) /*!< CoreDebug DHCSR: S_RESET_ST Mask */ + +#define CoreDebug_DHCSR_S_RETIRE_ST_Pos 24U /*!< CoreDebug DHCSR: S_RETIRE_ST Position */ +#define CoreDebug_DHCSR_S_RETIRE_ST_Msk (1UL << CoreDebug_DHCSR_S_RETIRE_ST_Pos) /*!< CoreDebug DHCSR: S_RETIRE_ST Mask */ + +#define CoreDebug_DHCSR_S_LOCKUP_Pos 19U /*!< CoreDebug DHCSR: S_LOCKUP Position */ +#define CoreDebug_DHCSR_S_LOCKUP_Msk (1UL << CoreDebug_DHCSR_S_LOCKUP_Pos) /*!< CoreDebug DHCSR: S_LOCKUP Mask */ + +#define CoreDebug_DHCSR_S_SLEEP_Pos 18U /*!< CoreDebug DHCSR: S_SLEEP Position */ +#define CoreDebug_DHCSR_S_SLEEP_Msk (1UL << CoreDebug_DHCSR_S_SLEEP_Pos) /*!< CoreDebug DHCSR: S_SLEEP Mask */ + +#define CoreDebug_DHCSR_S_HALT_Pos 17U /*!< CoreDebug DHCSR: S_HALT Position */ +#define CoreDebug_DHCSR_S_HALT_Msk (1UL << CoreDebug_DHCSR_S_HALT_Pos) /*!< CoreDebug DHCSR: S_HALT Mask */ + +#define CoreDebug_DHCSR_S_REGRDY_Pos 16U /*!< CoreDebug DHCSR: S_REGRDY Position */ +#define CoreDebug_DHCSR_S_REGRDY_Msk (1UL << CoreDebug_DHCSR_S_REGRDY_Pos) /*!< CoreDebug DHCSR: S_REGRDY Mask */ + +#define CoreDebug_DHCSR_C_SNAPSTALL_Pos 5U /*!< CoreDebug DHCSR: C_SNAPSTALL Position */ +#define CoreDebug_DHCSR_C_SNAPSTALL_Msk (1UL << CoreDebug_DHCSR_C_SNAPSTALL_Pos) /*!< CoreDebug DHCSR: C_SNAPSTALL Mask */ + +#define CoreDebug_DHCSR_C_MASKINTS_Pos 3U /*!< CoreDebug DHCSR: C_MASKINTS Position */ +#define CoreDebug_DHCSR_C_MASKINTS_Msk (1UL << CoreDebug_DHCSR_C_MASKINTS_Pos) /*!< CoreDebug DHCSR: C_MASKINTS Mask */ + +#define CoreDebug_DHCSR_C_STEP_Pos 2U /*!< CoreDebug DHCSR: C_STEP Position */ +#define CoreDebug_DHCSR_C_STEP_Msk (1UL << CoreDebug_DHCSR_C_STEP_Pos) /*!< CoreDebug DHCSR: C_STEP Mask */ + +#define CoreDebug_DHCSR_C_HALT_Pos 1U /*!< CoreDebug DHCSR: C_HALT Position */ +#define CoreDebug_DHCSR_C_HALT_Msk (1UL << CoreDebug_DHCSR_C_HALT_Pos) /*!< CoreDebug DHCSR: C_HALT Mask */ + +#define CoreDebug_DHCSR_C_DEBUGEN_Pos 0U /*!< CoreDebug DHCSR: C_DEBUGEN Position */ +#define CoreDebug_DHCSR_C_DEBUGEN_Msk (1UL /*<< CoreDebug_DHCSR_C_DEBUGEN_Pos*/) /*!< CoreDebug DHCSR: C_DEBUGEN Mask */ + +/* Debug Core Register Selector Register Definitions */ +#define CoreDebug_DCRSR_REGWnR_Pos 16U /*!< CoreDebug DCRSR: REGWnR Position */ +#define CoreDebug_DCRSR_REGWnR_Msk (1UL << CoreDebug_DCRSR_REGWnR_Pos) /*!< CoreDebug DCRSR: REGWnR Mask */ + +#define CoreDebug_DCRSR_REGSEL_Pos 0U /*!< CoreDebug DCRSR: REGSEL Position */ +#define CoreDebug_DCRSR_REGSEL_Msk (0x1FUL /*<< CoreDebug_DCRSR_REGSEL_Pos*/) /*!< CoreDebug DCRSR: REGSEL Mask */ + +/* Debug Exception and Monitor Control Register Definitions */ +#define CoreDebug_DEMCR_TRCENA_Pos 24U /*!< CoreDebug DEMCR: TRCENA Position */ +#define CoreDebug_DEMCR_TRCENA_Msk (1UL << CoreDebug_DEMCR_TRCENA_Pos) /*!< CoreDebug DEMCR: TRCENA Mask */ + +#define CoreDebug_DEMCR_MON_REQ_Pos 19U /*!< CoreDebug DEMCR: MON_REQ Position */ +#define CoreDebug_DEMCR_MON_REQ_Msk (1UL << CoreDebug_DEMCR_MON_REQ_Pos) /*!< CoreDebug DEMCR: MON_REQ Mask */ + +#define CoreDebug_DEMCR_MON_STEP_Pos 18U /*!< CoreDebug DEMCR: MON_STEP Position */ +#define CoreDebug_DEMCR_MON_STEP_Msk (1UL << CoreDebug_DEMCR_MON_STEP_Pos) /*!< CoreDebug DEMCR: MON_STEP Mask */ + +#define CoreDebug_DEMCR_MON_PEND_Pos 17U /*!< CoreDebug DEMCR: MON_PEND Position */ +#define CoreDebug_DEMCR_MON_PEND_Msk (1UL << CoreDebug_DEMCR_MON_PEND_Pos) /*!< CoreDebug DEMCR: MON_PEND Mask */ + +#define CoreDebug_DEMCR_MON_EN_Pos 16U /*!< CoreDebug DEMCR: MON_EN Position */ +#define CoreDebug_DEMCR_MON_EN_Msk (1UL << CoreDebug_DEMCR_MON_EN_Pos) /*!< CoreDebug DEMCR: MON_EN Mask */ + +#define CoreDebug_DEMCR_VC_HARDERR_Pos 10U /*!< CoreDebug DEMCR: VC_HARDERR Position */ +#define CoreDebug_DEMCR_VC_HARDERR_Msk (1UL << CoreDebug_DEMCR_VC_HARDERR_Pos) /*!< CoreDebug DEMCR: VC_HARDERR Mask */ + +#define CoreDebug_DEMCR_VC_INTERR_Pos 9U /*!< CoreDebug DEMCR: VC_INTERR Position */ +#define CoreDebug_DEMCR_VC_INTERR_Msk (1UL << CoreDebug_DEMCR_VC_INTERR_Pos) /*!< CoreDebug DEMCR: VC_INTERR Mask */ + +#define CoreDebug_DEMCR_VC_BUSERR_Pos 8U /*!< CoreDebug DEMCR: VC_BUSERR Position */ +#define CoreDebug_DEMCR_VC_BUSERR_Msk (1UL << CoreDebug_DEMCR_VC_BUSERR_Pos) /*!< CoreDebug DEMCR: VC_BUSERR Mask */ + +#define CoreDebug_DEMCR_VC_STATERR_Pos 7U /*!< CoreDebug DEMCR: VC_STATERR Position */ +#define CoreDebug_DEMCR_VC_STATERR_Msk (1UL << CoreDebug_DEMCR_VC_STATERR_Pos) /*!< CoreDebug DEMCR: VC_STATERR Mask */ + +#define CoreDebug_DEMCR_VC_CHKERR_Pos 6U /*!< CoreDebug DEMCR: VC_CHKERR Position */ +#define CoreDebug_DEMCR_VC_CHKERR_Msk (1UL << CoreDebug_DEMCR_VC_CHKERR_Pos) /*!< CoreDebug DEMCR: VC_CHKERR Mask */ + +#define CoreDebug_DEMCR_VC_NOCPERR_Pos 5U /*!< CoreDebug DEMCR: VC_NOCPERR Position */ +#define CoreDebug_DEMCR_VC_NOCPERR_Msk (1UL << CoreDebug_DEMCR_VC_NOCPERR_Pos) /*!< CoreDebug DEMCR: VC_NOCPERR Mask */ + +#define CoreDebug_DEMCR_VC_MMERR_Pos 4U /*!< CoreDebug DEMCR: VC_MMERR Position */ +#define CoreDebug_DEMCR_VC_MMERR_Msk (1UL << CoreDebug_DEMCR_VC_MMERR_Pos) /*!< CoreDebug DEMCR: VC_MMERR Mask */ + +#define CoreDebug_DEMCR_VC_CORERESET_Pos 0U /*!< CoreDebug DEMCR: VC_CORERESET Position */ +#define CoreDebug_DEMCR_VC_CORERESET_Msk (1UL /*<< CoreDebug_DEMCR_VC_CORERESET_Pos*/) /*!< CoreDebug DEMCR: VC_CORERESET Mask */ + +/*@} end of group CMSIS_CoreDebug */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_bitfield Core register bit field macros + \brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk). + @{ + */ + +/** + \brief Mask and shift a bit field value for use in a register bit range. + \param[in] field Name of the register bit field. + \param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk) + +/** + \brief Mask and shift a register value to extract a bit filed value. + \param[in] field Name of the register bit field. + \param[in] value Value of register. This parameter is interpreted as an uint32_t type. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos) + +/*@} end of group CMSIS_core_bitfield */ + + +/** + \ingroup CMSIS_core_register + \defgroup CMSIS_core_base Core Definitions + \brief Definitions for base addresses, unions, and structures. + @{ + */ + +/* Memory mapping of Core Hardware */ +#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */ +#define ITM_BASE (0xE0000000UL) /*!< ITM Base Address */ +#define DWT_BASE (0xE0001000UL) /*!< DWT Base Address */ +#define TPI_BASE (0xE0040000UL) /*!< TPI Base Address */ +#define CoreDebug_BASE (0xE000EDF0UL) /*!< Core Debug Base Address */ +#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */ +#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */ +#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */ + +#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */ +#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */ +#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */ +#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */ +#define ITM ((ITM_Type *) ITM_BASE ) /*!< ITM configuration struct */ +#define DWT ((DWT_Type *) DWT_BASE ) /*!< DWT configuration struct */ +#define TPI ((TPI_Type *) TPI_BASE ) /*!< TPI configuration struct */ +#define CoreDebug ((CoreDebug_Type *) CoreDebug_BASE) /*!< Core Debug configuration struct */ + +#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +/*@} */ + + + +/******************************************************************************* + * Hardware Abstraction Layer + Core Function Interface contains: + - Core NVIC Functions + - Core SysTick Functions + - Core Debug Functions + - Core Register Access Functions + ******************************************************************************/ +/** + \defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference +*/ + + + +/* ########################## NVIC functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_NVICFunctions NVIC Functions + \brief Functions that manage interrupts and exceptions via the NVIC. + @{ + */ + +#ifdef CMSIS_NVIC_VIRTUAL + #ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE + #define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h" + #endif + #include CMSIS_NVIC_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping + #define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping + #define NVIC_EnableIRQ __NVIC_EnableIRQ + #define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ + #define NVIC_DisableIRQ __NVIC_DisableIRQ + #define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ + #define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ + #define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ + #define NVIC_GetActive __NVIC_GetActive + #define NVIC_SetPriority __NVIC_SetPriority + #define NVIC_GetPriority __NVIC_GetPriority + #define NVIC_SystemReset __NVIC_SystemReset +#endif /* CMSIS_NVIC_VIRTUAL */ + +#ifdef CMSIS_VECTAB_VIRTUAL + #ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE + #define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h" + #endif + #include CMSIS_VECTAB_VIRTUAL_HEADER_FILE +#else + #define NVIC_SetVector __NVIC_SetVector + #define NVIC_GetVector __NVIC_GetVector +#endif /* (CMSIS_VECTAB_VIRTUAL) */ + +#define NVIC_USER_IRQ_OFFSET 16 + + +/* The following EXC_RETURN values are saved the LR on exception entry */ +#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */ +#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */ +#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */ + + +/** + \brief Set Priority Grouping + \details Sets the priority grouping field using the required unlock sequence. + The parameter PriorityGroup is assigned to the field SCB->AIRCR [10:8] PRIGROUP field. + Only values from 0..7 are used. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Priority grouping field. + */ +__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + uint32_t reg_value; + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + + reg_value = SCB->AIRCR; /* read old register configuration */ + reg_value &= ~((uint32_t)(SCB_AIRCR_VECTKEY_Msk | SCB_AIRCR_PRIGROUP_Msk)); /* clear bits to change */ + reg_value = (reg_value | + ((uint32_t)0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (PriorityGroupTmp << SCB_AIRCR_PRIGROUP_Pos) ); /* Insert write key and priority group */ + SCB->AIRCR = reg_value; +} + + +/** + \brief Get Priority Grouping + \details Reads the priority grouping field from the NVIC Interrupt Controller. + \return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field). + */ +__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void) +{ + return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos)); +} + + +/** + \brief Enable Interrupt + \details Enables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + __COMPILER_BARRIER(); + NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __COMPILER_BARRIER(); + } +} + + +/** + \brief Get Interrupt Enable status + \details Returns a device specific interrupt enable status from the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt is not enabled. + \return 1 Interrupt is enabled. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Disable Interrupt + \details Disables a device specific interrupt in the NVIC interrupt controller. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + __DSB(); + __ISB(); + } +} + + +/** + \brief Get Pending Interrupt + \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ISPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of a device specific interrupt in the NVIC pending register. + \param [in] IRQn Device specific interrupt number. + \note IRQn must not be negative. + */ +__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->ICPR[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL)); + } +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt. + \param [in] IRQn Device specific interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + \note IRQn must not be negative. + */ +__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn) +{ + if ((int32_t)(IRQn) >= 0) + { + return((uint32_t)(((NVIC->IABR[(((uint32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); + } + else + { + return(0U); + } +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + \note The priority cannot be set for every processor exception. + */ +__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) >= 0) + { + NVIC->IP[((uint32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of a device specific interrupt or a processor exception. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Interrupt Priority. + Value is aligned automatically to the implemented priority bits of the microcontroller. + */ +__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn) +{ + + if ((int32_t)(IRQn) >= 0) + { + return(((uint32_t)NVIC->IP[((uint32_t)IRQn)] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)SCB->SHP[(((uint32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief Encode Priority + \details Encodes the priority for an interrupt with the given priority group, + preemptive priority value, and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set. + \param [in] PriorityGroup Used priority group. + \param [in] PreemptPriority Preemptive priority value (starting from 0). + \param [in] SubPriority Subpriority value (starting from 0). + \return Encoded priority. Value can be used in the function \ref NVIC_SetPriority(). + */ +__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + return ( + ((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) | + ((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL))) + ); +} + + +/** + \brief Decode Priority + \details Decodes an interrupt priority value with a given priority group to + preemptive priority value and subpriority value. + In case of a conflict between priority grouping and available + priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set. + \param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority(). + \param [in] PriorityGroup Used priority group. + \param [out] pPreemptPriority Preemptive priority value (starting from 0). + \param [out] pSubPriority Subpriority value (starting from 0). + */ +__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority) +{ + uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */ + uint32_t PreemptPriorityBits; + uint32_t SubPriorityBits; + + PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp); + SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS)); + + *pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL); + *pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL); +} + + +/** + \brief Set Interrupt Vector + \details Sets an interrupt vector in SRAM based interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + VTOR must been relocated to SRAM before. + \param [in] IRQn Interrupt number + \param [in] vector Address of interrupt handler function + */ +__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector; + /* ARM Application Note 321 states that the M3 does not require the architectural barrier */ +} + + +/** + \brief Get Interrupt Vector + \details Reads an interrupt vector from interrupt vector table. + The interrupt number can be positive to specify a device specific interrupt, + or negative to specify a processor exception. + \param [in] IRQn Interrupt number. + \return Address of interrupt handler function + */ +__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn) +{ + uint32_t *vectors = (uint32_t *)SCB->VTOR; + return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET]; +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void) +{ + __DSB(); /* Ensure all outstanding memory accesses included + buffered write are completed before reset */ + SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) | + (SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) | + SCB_AIRCR_SYSRESETREQ_Msk ); /* Keep priority group unchanged */ + __DSB(); /* Ensure completion of memory access */ + + for(;;) /* wait until reset */ + { + __NOP(); + } +} + +/*@} end of CMSIS_Core_NVICFunctions */ + + +/* ########################## FPU functions #################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_FpuFunctions FPU Functions + \brief Function that provides FPU type. + @{ + */ + +/** + \brief get FPU type + \details returns the FPU type + \returns + - \b 0: No FPU + - \b 1: Single precision FPU + - \b 2: Double + Single precision FPU + */ +__STATIC_INLINE uint32_t SCB_GetFPUType(void) +{ + return 0U; /* No FPU */ +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U) + +/** + \brief System Tick Configuration + \details Initializes the System Timer and its interrupt, and starts the System Tick Timer. + Counter is in free running mode to generate periodic interrupts. + \param [in] ticks Number of ticks between two interrupts. + \return 0 Function succeeded. + \return 1 Function failed. + \note When the variable __Vendor_SysTickConfig is set to 1, then the + function SysTick_Config is not included. In this case, the file device.h + must contain a vendor-specific implementation of this function. + */ +__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks) +{ + if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk) + { + return (1UL); /* Reload value impossible */ + } + + SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */ + NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */ + SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | + SysTick_CTRL_TICKINT_Msk | + SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */ + return (0UL); /* Function successful */ +} + +#endif + +/*@} end of CMSIS_Core_SysTickFunctions */ + + + +/* ##################################### Debug In/Output function ########################################### */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_core_DebugFunctions ITM Functions + \brief Functions that access the ITM debug interface. + @{ + */ + +extern volatile int32_t ITM_RxBuffer; /*!< External variable to receive characters. */ +#define ITM_RXBUFFER_EMPTY ((int32_t)0x5AA55AA5U) /*!< Value identifying \ref ITM_RxBuffer is ready for next character. */ + + +/** + \brief ITM Send Character + \details Transmits a character via the ITM channel 0, and + \li Just returns when no debugger is connected that has booked the output. + \li Is blocking when a debugger is connected, but the previous character sent has not been transmitted. + \param [in] ch Character to transmit. + \returns Character to transmit. + */ +__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch) +{ + if (((ITM->TCR & ITM_TCR_ITMENA_Msk) != 0UL) && /* ITM enabled */ + ((ITM->TER & 1UL ) != 0UL) ) /* ITM Port #0 enabled */ + { + while (ITM->PORT[0U].u32 == 0UL) + { + __NOP(); + } + ITM->PORT[0U].u8 = (uint8_t)ch; + } + return (ch); +} + + +/** + \brief ITM Receive Character + \details Inputs a character via the external variable \ref ITM_RxBuffer. + \return Received character. + \return -1 No character pending. + */ +__STATIC_INLINE int32_t ITM_ReceiveChar (void) +{ + int32_t ch = -1; /* no character available */ + + if (ITM_RxBuffer != ITM_RXBUFFER_EMPTY) + { + ch = ITM_RxBuffer; + ITM_RxBuffer = ITM_RXBUFFER_EMPTY; /* ready for next character */ + } + + return (ch); +} + + +/** + \brief ITM Check Character + \details Checks whether a character is pending for reading in the variable \ref ITM_RxBuffer. + \return 0 No character available. + \return 1 Character available. + */ +__STATIC_INLINE int32_t ITM_CheckChar (void) +{ + + if (ITM_RxBuffer == ITM_RXBUFFER_EMPTY) + { + return (0); /* no character available */ + } + else + { + return (1); /* character available */ + } +} + +/*@} end of CMSIS_core_DebugFunctions */ + + + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_SC300_H_DEPENDANT */ + +#endif /* __CMSIS_GENERIC */ diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/mpu_armv7.h b/bsp/tae32f5300/Libraries/CMSIS/Include/mpu_armv7.h new file mode 100644 index 0000000000..791a8dae65 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/mpu_armv7.h @@ -0,0 +1,275 @@ +/****************************************************************************** + * @file mpu_armv7.h + * @brief CMSIS MPU API for Armv7-M MPU + * @version V5.1.1 + * @date 10. February 2020 + ******************************************************************************/ +/* + * Copyright (c) 2017-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV7_H +#define ARM_MPU_ARMV7_H + +#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U) ///!< MPU Region Size 32 Bytes +#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U) ///!< MPU Region Size 64 Bytes +#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U) ///!< MPU Region Size 128 Bytes +#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U) ///!< MPU Region Size 256 Bytes +#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U) ///!< MPU Region Size 512 Bytes +#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U) ///!< MPU Region Size 1 KByte +#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU) ///!< MPU Region Size 2 KBytes +#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU) ///!< MPU Region Size 4 KBytes +#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU) ///!< MPU Region Size 8 KBytes +#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU) ///!< MPU Region Size 16 KBytes +#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU) ///!< MPU Region Size 32 KBytes +#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU) ///!< MPU Region Size 64 KBytes +#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U) ///!< MPU Region Size 128 KBytes +#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U) ///!< MPU Region Size 256 KBytes +#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U) ///!< MPU Region Size 512 KBytes +#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U) ///!< MPU Region Size 1 MByte +#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U) ///!< MPU Region Size 2 MBytes +#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U) ///!< MPU Region Size 4 MBytes +#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U) ///!< MPU Region Size 8 MBytes +#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U) ///!< MPU Region Size 16 MBytes +#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U) ///!< MPU Region Size 32 MBytes +#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U) ///!< MPU Region Size 64 MBytes +#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU) ///!< MPU Region Size 128 MBytes +#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU) ///!< MPU Region Size 256 MBytes +#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU) ///!< MPU Region Size 512 MBytes +#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU) ///!< MPU Region Size 1 GByte +#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU) ///!< MPU Region Size 2 GBytes +#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU) ///!< MPU Region Size 4 GBytes + +#define ARM_MPU_AP_NONE 0U ///!< MPU Access Permission no access +#define ARM_MPU_AP_PRIV 1U ///!< MPU Access Permission privileged access only +#define ARM_MPU_AP_URO 2U ///!< MPU Access Permission unprivileged access read-only +#define ARM_MPU_AP_FULL 3U ///!< MPU Access Permission full access +#define ARM_MPU_AP_PRO 5U ///!< MPU Access Permission privileged access read-only +#define ARM_MPU_AP_RO 6U ///!< MPU Access Permission read-only access + +/** MPU Region Base Address Register Value +* +* \param Region The region to be configured, number 0 to 15. +* \param BaseAddress The base address for the region. +*/ +#define ARM_MPU_RBAR(Region, BaseAddress) \ + (((BaseAddress) & MPU_RBAR_ADDR_Msk) | \ + ((Region) & MPU_RBAR_REGION_Msk) | \ + (MPU_RBAR_VALID_Msk)) + +/** +* MPU Memory Access Attributes +* +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +*/ +#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \ + ((((TypeExtField) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \ + (((IsShareable) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \ + (((IsCacheable) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \ + (((IsBufferable) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk)) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR_EX(DisableExec, AccessPermission, AccessAttributes, SubRegionDisable, Size) \ + ((((DisableExec) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \ + (((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \ + (((AccessAttributes) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk))) | \ + (((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \ + (((Size) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \ + (((MPU_RASR_ENABLE_Msk)))) + +/** +* MPU Region Attribute and Size Register Value +* +* \param DisableExec Instruction access disable bit, 1= disable instruction fetches. +* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode. +* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral. +* \param IsShareable Region is shareable between multiple bus masters. +* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache. +* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy. +* \param SubRegionDisable Sub-region disable field. +* \param Size Region size of the region to be configured, for example 4K, 8K. +*/ +#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \ + ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size) + +/** +* MPU Memory Access Attribute for strongly ordered memory. +* - TEX: 000b +* - Shareable +* - Non-cacheable +* - Non-bufferable +*/ +#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U) + +/** +* MPU Memory Access Attribute for device memory. +* - TEX: 000b (if shareable) or 010b (if non-shareable) +* - Shareable or non-shareable +* - Non-cacheable +* - Bufferable (if shareable) or non-bufferable (if non-shareable) +* +* \param IsShareable Configures the device memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U)) + +/** +* MPU Memory Access Attribute for normal memory. +* - TEX: 1BBb (reflecting outer cacheability rules) +* - Shareable or non-shareable +* - Cacheable or non-cacheable (reflecting inner cacheability rules) +* - Bufferable or non-bufferable (reflecting inner cacheability rules) +* +* \param OuterCp Configures the outer cache policy. +* \param InnerCp Configures the inner cache policy. +* \param IsShareable Configures the memory as shareable or non-shareable. +*/ +#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) >> 1U), ((InnerCp) & 1U)) + +/** +* MPU Memory Access Attribute non-cacheable policy. +*/ +#define ARM_MPU_CACHEP_NOCACHE 0U + +/** +* MPU Memory Access Attribute write-back, write and read allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_WRA 1U + +/** +* MPU Memory Access Attribute write-through, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WT_NWA 2U + +/** +* MPU Memory Access Attribute write-back, no write allocate policy. +*/ +#define ARM_MPU_CACHEP_WB_NWA 3U + + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; //!< The region base address register value (RBAR) + uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + MPU->RNR = rnr; + MPU->RASR = 0U; +} + +/** Configure an MPU region. +* \param rbar Value for RBAR register. +* \param rsar Value for RSAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr) +{ + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rsar Value for RSAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr) +{ + MPU->RNR = rnr; + MPU->RBAR = rbar; + MPU->RASR = rasr; +} + +/** Memcopy with strictly ordered memory access, e.g. for register targets. +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + while (cnt > MPU_TYPE_RALIASES) { + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize); + table += MPU_TYPE_RALIASES; + cnt -= MPU_TYPE_RALIASES; + } + ARM_MPU_OrderedMemcpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize); +} + +#endif diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/mpu_armv8.h b/bsp/tae32f5300/Libraries/CMSIS/Include/mpu_armv8.h new file mode 100644 index 0000000000..ef44ad01df --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/mpu_armv8.h @@ -0,0 +1,352 @@ +/****************************************************************************** + * @file mpu_armv8.h + * @brief CMSIS MPU API for Armv8-M and Armv8.1-M MPU + * @version V5.1.2 + * @date 10. February 2020 + ******************************************************************************/ +/* + * Copyright (c) 2017-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_MPU_ARMV8_H +#define ARM_MPU_ARMV8_H + +/** \brief Attribute for device memory (outer only) */ +#define ARM_MPU_ATTR_DEVICE ( 0U ) + +/** \brief Attribute for non-cacheable, normal memory */ +#define ARM_MPU_ATTR_NON_CACHEABLE ( 4U ) + +/** \brief Attribute for normal memory (outer and inner) +* \param NT Non-Transient: Set to 1 for non-transient data. +* \param WB Write-Back: Set to 1 to use write-back update policy. +* \param RA Read Allocation: Set to 1 to use cache allocation on read miss. +* \param WA Write Allocation: Set to 1 to use cache allocation on write miss. +*/ +#define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \ + ((((NT) & 1U) << 3U) | (((WB) & 1U) << 2U) | (((RA) & 1U) << 1U) | ((WA) & 1U)) + +/** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRnE (0U) + +/** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGnRE (1U) + +/** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_nGRE (2U) + +/** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */ +#define ARM_MPU_ATTR_DEVICE_GRE (3U) + +/** \brief Memory Attribute +* \param O Outer memory attributes +* \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes +*/ +#define ARM_MPU_ATTR(O, I) ((((O) & 0xFU) << 4U) | ((((O) & 0xFU) != 0U) ? ((I) & 0xFU) : (((I) & 0x3U) << 2U))) + +/** \brief Normal memory non-shareable */ +#define ARM_MPU_SH_NON (0U) + +/** \brief Normal memory outer shareable */ +#define ARM_MPU_SH_OUTER (2U) + +/** \brief Normal memory inner shareable */ +#define ARM_MPU_SH_INNER (3U) + +/** \brief Memory access permissions +* \param RO Read-Only: Set to 1 for read-only memory. +* \param NP Non-Privileged: Set to 1 for non-privileged memory. +*/ +#define ARM_MPU_AP_(RO, NP) ((((RO) & 1U) << 1U) | ((NP) & 1U)) + +/** \brief Region Base Address Register value +* \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned. +* \param SH Defines the Shareability domain for this memory region. +* \param RO Read-Only: Set to 1 for a read-only memory region. +* \param NP Non-Privileged: Set to 1 for a non-privileged memory region. +* \oaram XN eXecute Never: Set to 1 for a non-executable memory region. +*/ +#define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \ + (((BASE) & MPU_RBAR_BASE_Msk) | \ + (((SH) << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \ + ((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \ + (((XN) << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk)) + +/** \brief Region Limit Address Register value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR(LIMIT, IDX) \ + (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \ + (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#if defined(MPU_RLAR_PXN_Pos) + +/** \brief Region Limit Address Register with PXN value +* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended. +* \param PXN Privileged execute never. Defines whether code can be executed from this privileged region. +* \param IDX The attribute index to be associated with this memory region. +*/ +#define ARM_MPU_RLAR_PXN(LIMIT, PXN, IDX) \ + (((LIMIT) & MPU_RLAR_LIMIT_Msk) | \ + (((PXN) << MPU_RLAR_PXN_Pos) & MPU_RLAR_PXN_Msk) | \ + (((IDX) << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \ + (MPU_RLAR_EN_Msk)) + +#endif + +/** +* Struct for a single MPU Region +*/ +typedef struct { + uint32_t RBAR; /*!< Region Base Address Register value */ + uint32_t RLAR; /*!< Region Limit Address Register value */ +} ARM_MPU_Region_t; + +/** Enable the MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control) +{ + __DMB(); + MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} + +#ifdef MPU_NS +/** Enable the Non-secure MPU. +* \param MPU_Control Default access permissions for unconfigured regions. +*/ +__STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control) +{ + __DMB(); + MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk; +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk; +#endif + __DSB(); + __ISB(); +} + +/** Disable the Non-secure MPU. +*/ +__STATIC_INLINE void ARM_MPU_Disable_NS(void) +{ + __DMB(); +#ifdef SCB_SHCSR_MEMFAULTENA_Msk + SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk; +#endif + MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk; + __DSB(); + __ISB(); +} +#endif + +/** Set the memory attribute encoding to the given MPU. +* \param mpu Pointer to the MPU to be configured. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr) +{ + const uint8_t reg = idx / 4U; + const uint32_t pos = ((idx % 4U) * 8U); + const uint32_t mask = 0xFFU << pos; + + if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) { + return; // invalid index + } + + mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask)); +} + +/** Set the memory attribute encoding. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU, idx, attr); +} + +#ifdef MPU_NS +/** Set the memory attribute encoding to the Non-secure MPU. +* \param idx The attribute index to be set [0-7] +* \param attr The attribute value to be set. +*/ +__STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr) +{ + ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr); +} +#endif + +/** Clear and disable the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr) +{ + mpu->RNR = rnr; + mpu->RLAR = 0U; +} + +/** Clear and disable the given MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU, rnr); +} + +#ifdef MPU_NS +/** Clear and disable the given Non-secure MPU region. +* \param rnr Region number to be cleared. +*/ +__STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr) +{ + ARM_MPU_ClrRegionEx(MPU_NS, rnr); +} +#endif + +/** Configure the given MPU region of the given MPU. +* \param mpu Pointer to MPU to be used. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + mpu->RNR = rnr; + mpu->RBAR = rbar; + mpu->RLAR = rlar; +} + +/** Configure the given MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar); +} + +#ifdef MPU_NS +/** Configure the given Non-secure MPU region. +* \param rnr Region number to be configured. +* \param rbar Value for RBAR register. +* \param rlar Value for RLAR register. +*/ +__STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar) +{ + ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar); +} +#endif + +/** Memcopy with strictly ordered memory access, e.g. for register targets. +* \param dst Destination data is copied to. +* \param src Source data is copied from. +* \param len Amount of data words to be copied. +*/ +__STATIC_INLINE void ARM_MPU_OrderedMemcpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len) +{ + uint32_t i; + for (i = 0U; i < len; ++i) + { + dst[i] = src[i]; + } +} + +/** Load the given number of MPU regions from a table to the given MPU. +* \param mpu Pointer to the MPU registers to be used. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U; + if (cnt == 1U) { + mpu->RNR = rnr; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR), &(table->RBAR), rowWordSize); + } else { + uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U); + uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES; + + mpu->RNR = rnrBase; + while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) { + uint32_t c = MPU_TYPE_RALIASES - rnrOffset; + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize); + table += c; + cnt -= c; + rnrOffset = 0U; + rnrBase += MPU_TYPE_RALIASES; + mpu->RNR = rnrBase; + } + + ARM_MPU_OrderedMemcpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize); + } +} + +/** Load the given number of MPU regions from a table. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU, rnr, table, cnt); +} + +#ifdef MPU_NS +/** Load the given number of MPU regions from a table to the Non-secure MPU. +* \param rnr First region number to be configured. +* \param table Pointer to the MPU configuration table. +* \param cnt Amount of regions to be configured. +*/ +__STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt) +{ + ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt); +} +#endif + +#endif + diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/pmu_armv8.h b/bsp/tae32f5300/Libraries/CMSIS/Include/pmu_armv8.h new file mode 100644 index 0000000000..dbd39d20c7 --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/pmu_armv8.h @@ -0,0 +1,337 @@ +/****************************************************************************** + * @file pmu_armv8.h + * @brief CMSIS PMU API for Armv8.1-M PMU + * @version V1.0.0 + * @date 24. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef ARM_PMU_ARMV8_H +#define ARM_PMU_ARMV8_H + +/** + * \brief PMU Events + * \note See the Armv8.1-M Architecture Reference Manual for full details on these PMU events. + * */ + +#define ARM_PMU_SW_INCR 0x0000 /*!< Software update to the PMU_SWINC register, architecturally executed and condition code check pass */ +#define ARM_PMU_L1I_CACHE_REFILL 0x0001 /*!< L1 I-Cache refill */ +#define ARM_PMU_L1D_CACHE_REFILL 0x0003 /*!< L1 D-Cache refill */ +#define ARM_PMU_L1D_CACHE 0x0004 /*!< L1 D-Cache access */ +#define ARM_PMU_LD_RETIRED 0x0006 /*!< Memory-reading instruction architecturally executed and condition code check pass */ +#define ARM_PMU_ST_RETIRED 0x0007 /*!< Memory-writing instruction architecturally executed and condition code check pass */ +#define ARM_PMU_INST_RETIRED 0x0008 /*!< Instruction architecturally executed */ +#define ARM_PMU_EXC_TAKEN 0x0009 /*!< Exception entry */ +#define ARM_PMU_EXC_RETURN 0x000A /*!< Exception return instruction architecturally executed and the condition code check pass */ +#define ARM_PMU_PC_WRITE_RETIRED 0x000C /*!< Software change to the Program Counter (PC). Instruction is architecturally executed and condition code check pass */ +#define ARM_PMU_BR_IMMED_RETIRED 0x000D /*!< Immediate branch architecturally executed */ +#define ARM_PMU_BR_RETURN_RETIRED 0x000E /*!< Function return instruction architecturally executed and the condition code check pass */ +#define ARM_PMU_UNALIGNED_LDST_RETIRED 0x000F /*!< Unaligned memory memory-reading or memory-writing instruction architecturally executed and condition code check pass */ +#define ARM_PMU_BR_MIS_PRED 0x0010 /*!< Mispredicted or not predicted branch speculatively executed */ +#define ARM_PMU_CPU_CYCLES 0x0011 /*!< Cycle */ +#define ARM_PMU_BR_PRED 0x0012 /*!< Predictable branch speculatively executed */ +#define ARM_PMU_MEM_ACCESS 0x0013 /*!< Data memory access */ +#define ARM_PMU_L1I_CACHE 0x0014 /*!< Level 1 instruction cache access */ +#define ARM_PMU_L1D_CACHE_WB 0x0015 /*!< Level 1 data cache write-back */ +#define ARM_PMU_L2D_CACHE 0x0016 /*!< Level 2 data cache access */ +#define ARM_PMU_L2D_CACHE_REFILL 0x0017 /*!< Level 2 data cache refill */ +#define ARM_PMU_L2D_CACHE_WB 0x0018 /*!< Level 2 data cache write-back */ +#define ARM_PMU_BUS_ACCESS 0x0019 /*!< Bus access */ +#define ARM_PMU_MEMORY_ERROR 0x001A /*!< Local memory error */ +#define ARM_PMU_INST_SPEC 0x001B /*!< Instruction speculatively executed */ +#define ARM_PMU_BUS_CYCLES 0x001D /*!< Bus cycles */ +#define ARM_PMU_CHAIN 0x001E /*!< For an odd numbered counter, increment when an overflow occurs on the preceding even-numbered counter on the same PE */ +#define ARM_PMU_L1D_CACHE_ALLOCATE 0x001F /*!< Level 1 data cache allocation without refill */ +#define ARM_PMU_L2D_CACHE_ALLOCATE 0x0020 /*!< Level 2 data cache allocation without refill */ +#define ARM_PMU_BR_RETIRED 0x0021 /*!< Branch instruction architecturally executed */ +#define ARM_PMU_BR_MIS_PRED_RETIRED 0x0022 /*!< Mispredicted branch instruction architecturally executed */ +#define ARM_PMU_STALL_FRONTEND 0x0023 /*!< No operation issued because of the frontend */ +#define ARM_PMU_STALL_BACKEND 0x0024 /*!< No operation issued because of the backend */ +#define ARM_PMU_L2I_CACHE 0x0027 /*!< Level 2 instruction cache access */ +#define ARM_PMU_L2I_CACHE_REFILL 0x0028 /*!< Level 2 instruction cache refill */ +#define ARM_PMU_L3D_CACHE_ALLOCATE 0x0029 /*!< Level 3 data cache allocation without refill */ +#define ARM_PMU_L3D_CACHE_REFILL 0x002A /*!< Level 3 data cache refill */ +#define ARM_PMU_L3D_CACHE 0x002B /*!< Level 3 data cache access */ +#define ARM_PMU_L3D_CACHE_WB 0x002C /*!< Level 3 data cache write-back */ +#define ARM_PMU_LL_CACHE_RD 0x0036 /*!< Last level data cache read */ +#define ARM_PMU_LL_CACHE_MISS_RD 0x0037 /*!< Last level data cache read miss */ +#define ARM_PMU_L1D_CACHE_MISS_RD 0x0039 /*!< Level 1 data cache read miss */ +#define ARM_PMU_OP_COMPLETE 0x003A /*!< Operation retired */ +#define ARM_PMU_OP_SPEC 0x003B /*!< Operation speculatively executed */ +#define ARM_PMU_STALL 0x003C /*!< Stall cycle for instruction or operation not sent for execution */ +#define ARM_PMU_STALL_OP_BACKEND 0x003D /*!< Stall cycle for instruction or operation not sent for execution due to pipeline backend */ +#define ARM_PMU_STALL_OP_FRONTEND 0x003E /*!< Stall cycle for instruction or operation not sent for execution due to pipeline frontend */ +#define ARM_PMU_STALL_OP 0x003F /*!< Instruction or operation slots not occupied each cycle */ +#define ARM_PMU_L1D_CACHE_RD 0x0040 /*!< Level 1 data cache read */ +#define ARM_PMU_LE_RETIRED 0x0100 /*!< Loop end instruction executed */ +#define ARM_PMU_LE_SPEC 0x0101 /*!< Loop end instruction speculatively executed */ +#define ARM_PMU_BF_RETIRED 0x0104 /*!< Branch future instruction architecturally executed and condition code check pass */ +#define ARM_PMU_BF_SPEC 0x0105 /*!< Branch future instruction speculatively executed and condition code check pass */ +#define ARM_PMU_LE_CANCEL 0x0108 /*!< Loop end instruction not taken */ +#define ARM_PMU_BF_CANCEL 0x0109 /*!< Branch future instruction not taken */ +#define ARM_PMU_SE_CALL_S 0x0114 /*!< Call to secure function, resulting in Security state change */ +#define ARM_PMU_SE_CALL_NS 0x0115 /*!< Call to non-secure function, resulting in Security state change */ +#define ARM_PMU_DWT_CMPMATCH0 0x0118 /*!< DWT comparator 0 match */ +#define ARM_PMU_DWT_CMPMATCH1 0x0119 /*!< DWT comparator 1 match */ +#define ARM_PMU_DWT_CMPMATCH2 0x011A /*!< DWT comparator 2 match */ +#define ARM_PMU_DWT_CMPMATCH3 0x011B /*!< DWT comparator 3 match */ +#define ARM_PMU_MVE_INST_RETIRED 0x0200 /*!< MVE instruction architecturally executed */ +#define ARM_PMU_MVE_INST_SPEC 0x0201 /*!< MVE instruction speculatively executed */ +#define ARM_PMU_MVE_FP_RETIRED 0x0204 /*!< MVE floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_SPEC 0x0205 /*!< MVE floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_HP_RETIRED 0x0208 /*!< MVE half-precision floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_HP_SPEC 0x0209 /*!< MVE half-precision floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_SP_RETIRED 0x020C /*!< MVE single-precision floating-point instruction architecturally executed */ +#define ARM_PMU_MVE_FP_SP_SPEC 0x020D /*!< MVE single-precision floating-point instruction speculatively executed */ +#define ARM_PMU_MVE_FP_MAC_RETIRED 0x0214 /*!< MVE floating-point multiply or multiply-accumulate instruction architecturally executed */ +#define ARM_PMU_MVE_FP_MAC_SPEC 0x0215 /*!< MVE floating-point multiply or multiply-accumulate instruction speculatively executed */ +#define ARM_PMU_MVE_INT_RETIRED 0x0224 /*!< MVE integer instruction architecturally executed */ +#define ARM_PMU_MVE_INT_SPEC 0x0225 /*!< MVE integer instruction speculatively executed */ +#define ARM_PMU_MVE_INT_MAC_RETIRED 0x0228 /*!< MVE multiply or multiply-accumulate instruction architecturally executed */ +#define ARM_PMU_MVE_INT_MAC_SPEC 0x0229 /*!< MVE multiply or multiply-accumulate instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_RETIRED 0x0238 /*!< MVE load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_SPEC 0x0239 /*!< MVE load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_RETIRED 0x023C /*!< MVE load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_SPEC 0x023D /*!< MVE load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_RETIRED 0x0240 /*!< MVE store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_SPEC 0x0241 /*!< MVE store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_CONTIG_RETIRED 0x0244 /*!< MVE contiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_CONTIG_SPEC 0x0245 /*!< MVE contiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_CONTIG_RETIRED 0x0248 /*!< MVE contiguous load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_CONTIG_SPEC 0x0249 /*!< MVE contiguous load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_CONTIG_RETIRED 0x024C /*!< MVE contiguous store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_CONTIG_SPEC 0x024D /*!< MVE contiguous store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_NONCONTIG_RETIRED 0x0250 /*!< MVE non-contiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_NONCONTIG_SPEC 0x0251 /*!< MVE non-contiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_NONCONTIG_RETIRED 0x0254 /*!< MVE non-contiguous load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_NONCONTIG_SPEC 0x0255 /*!< MVE non-contiguous load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_NONCONTIG_RETIRED 0x0258 /*!< MVE non-contiguous store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_NONCONTIG_SPEC 0x0259 /*!< MVE non-contiguous store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_MULTI_RETIRED 0x025C /*!< MVE memory instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_LDST_MULTI_SPEC 0x025D /*!< MVE memory instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_LD_MULTI_RETIRED 0x0260 /*!< MVE memory load instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_LD_MULTI_SPEC 0x0261 /*!< MVE memory load instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_ST_MULTI_RETIRED 0x0261 /*!< MVE memory store instruction targeting multiple registers architecturally executed */ +#define ARM_PMU_MVE_ST_MULTI_SPEC 0x0265 /*!< MVE memory store instruction targeting multiple registers speculatively executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_RETIRED 0x028C /*!< MVE unaligned memory load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_SPEC 0x028D /*!< MVE unaligned memory load or store instruction speculatively executed */ +#define ARM_PMU_MVE_LD_UNALIGNED_RETIRED 0x0290 /*!< MVE unaligned load instruction architecturally executed */ +#define ARM_PMU_MVE_LD_UNALIGNED_SPEC 0x0291 /*!< MVE unaligned load instruction speculatively executed */ +#define ARM_PMU_MVE_ST_UNALIGNED_RETIRED 0x0294 /*!< MVE unaligned store instruction architecturally executed */ +#define ARM_PMU_MVE_ST_UNALIGNED_SPEC 0x0295 /*!< MVE unaligned store instruction speculatively executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_NONCONTIG_RETIRED 0x0298 /*!< MVE unaligned noncontiguous load or store instruction architecturally executed */ +#define ARM_PMU_MVE_LDST_UNALIGNED_NONCONTIG_SPEC 0x0299 /*!< MVE unaligned noncontiguous load or store instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_RETIRED 0x02A0 /*!< MVE vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_SPEC 0x02A1 /*!< MVE vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_FP_RETIRED 0x02A4 /*!< MVE floating-point vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_FP_SPEC 0x02A5 /*!< MVE floating-point vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_VREDUCE_INT_RETIRED 0x02A8 /*!< MVE integer vector reduction instruction architecturally executed */ +#define ARM_PMU_MVE_VREDUCE_INT_SPEC 0x02A9 /*!< MVE integer vector reduction instruction speculatively executed */ +#define ARM_PMU_MVE_PRED 0x02B8 /*!< Cycles where one or more predicated beats architecturally executed */ +#define ARM_PMU_MVE_STALL 0x02CC /*!< Stall cycles caused by an MVE instruction */ +#define ARM_PMU_MVE_STALL_RESOURCE 0x02CD /*!< Stall cycles caused by an MVE instruction because of resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_MEM 0x02CE /*!< Stall cycles caused by an MVE instruction because of memory resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_FP 0x02CF /*!< Stall cycles caused by an MVE instruction because of floating-point resource conflicts */ +#define ARM_PMU_MVE_STALL_RESOURCE_INT 0x02D0 /*!< Stall cycles caused by an MVE instruction because of integer resource conflicts */ +#define ARM_PMU_MVE_STALL_BREAK 0x02D3 /*!< Stall cycles caused by an MVE chain break */ +#define ARM_PMU_MVE_STALL_DEPENDENCY 0x02D4 /*!< Stall cycles caused by MVE register dependency */ +#define ARM_PMU_ITCM_ACCESS 0x4007 /*!< Instruction TCM access */ +#define ARM_PMU_DTCM_ACCESS 0x4008 /*!< Data TCM access */ +#define ARM_PMU_TRCEXTOUT0 0x4010 /*!< ETM external output 0 */ +#define ARM_PMU_TRCEXTOUT1 0x4011 /*!< ETM external output 1 */ +#define ARM_PMU_TRCEXTOUT2 0x4012 /*!< ETM external output 2 */ +#define ARM_PMU_TRCEXTOUT3 0x4013 /*!< ETM external output 3 */ +#define ARM_PMU_CTI_TRIGOUT4 0x4018 /*!< Cross-trigger Interface output trigger 4 */ +#define ARM_PMU_CTI_TRIGOUT5 0x4019 /*!< Cross-trigger Interface output trigger 5 */ +#define ARM_PMU_CTI_TRIGOUT6 0x401A /*!< Cross-trigger Interface output trigger 6 */ +#define ARM_PMU_CTI_TRIGOUT7 0x401B /*!< Cross-trigger Interface output trigger 7 */ + +/** \brief PMU Functions */ + +__STATIC_INLINE void ARM_PMU_Enable(void); +__STATIC_INLINE void ARM_PMU_Disable(void); + +__STATIC_INLINE void ARM_PMU_Set_EVTYPER(uint32_t num, uint32_t type); + +__STATIC_INLINE void ARM_PMU_CYCCNT_Reset(void); +__STATIC_INLINE void ARM_PMU_EVCNTR_ALL_Reset(void); + +__STATIC_INLINE void ARM_PMU_CNTR_Enable(uint32_t mask); +__STATIC_INLINE void ARM_PMU_CNTR_Disable(uint32_t mask); + +__STATIC_INLINE uint32_t ARM_PMU_Get_CCNTR(void); +__STATIC_INLINE uint32_t ARM_PMU_Get_EVCNTR(uint32_t num); + +__STATIC_INLINE uint32_t ARM_PMU_Get_CNTR_OVS(void); +__STATIC_INLINE void ARM_PMU_Set_CNTR_OVS(uint32_t mask); + +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Enable(uint32_t mask); +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Disable(uint32_t mask); + +__STATIC_INLINE void ARM_PMU_CNTR_Increment(uint32_t mask); + +/** + \brief Enable the PMU +*/ +__STATIC_INLINE void ARM_PMU_Enable(void) +{ + PMU->CTRL |= PMU_CTRL_ENABLE_Msk; +} + +/** + \brief Disable the PMU +*/ +__STATIC_INLINE void ARM_PMU_Disable(void) +{ + PMU->CTRL &= ~PMU_CTRL_ENABLE_Msk; +} + +/** + \brief Set event to count for PMU eventer counter + \param [in] num Event counter (0-30) to configure + \param [in] type Event to count +*/ +__STATIC_INLINE void ARM_PMU_Set_EVTYPER(uint32_t num, uint32_t type) +{ + PMU->EVTYPER[num] = type; +} + +/** + \brief Reset cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CYCCNT_Reset(void) +{ + PMU->CTRL |= PMU_CTRL_CYCCNT_RESET_Msk; +} + +/** + \brief Reset all event counters +*/ +__STATIC_INLINE void ARM_PMU_EVCNTR_ALL_Reset(void) +{ + PMU->CTRL |= PMU_CTRL_EVENTCNT_RESET_Msk; +} + +/** + \brief Enable counters + \param [in] mask Counters to enable + \note Enables one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Enable(uint32_t mask) +{ + PMU->CNTENSET = mask; +} + +/** + \brief Disable counters + \param [in] mask Counters to enable + \note Disables one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Disable(uint32_t mask) +{ + PMU->CNTENCLR = mask; +} + +/** + \brief Read cycle counter + \return Cycle count +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_CCNTR(void) +{ + return PMU->CCNTR; +} + +/** + \brief Read event counter + \param [in] num Event counter (0-30) to read + \return Event count +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_EVCNTR(uint32_t num) +{ + return PMU->EVCNTR[num]; +} + +/** + \brief Read counter overflow status + \return Counter overflow status bits for the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE uint32_t ARM_PMU_Get_CNTR_OVS(void) +{ + return PMU->OVSSET; +} + +/** + \brief Clear counter overflow status + \param [in] mask Counter overflow status bits to clear + \note Clears overflow status bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_OVS(uint32_t mask) +{ + PMU->OVSCLR = mask; +} + +/** + \brief Enable counter overflow interrupt request + \param [in] mask Counter overflow interrupt request bits to set + \note Sets overflow interrupt request bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Enable(uint32_t mask) +{ + PMU->INTENSET = mask; +} + +/** + \brief Disable counter overflow interrupt request + \param [in] mask Counter overflow interrupt request bits to clear + \note Clears overflow interrupt request bits for one or more of the following: + - event counters (0-30) + - cycle counter +*/ +__STATIC_INLINE void ARM_PMU_Set_CNTR_IRQ_Disable(uint32_t mask) +{ + PMU->INTENCLR = mask; +} + +/** + \brief Software increment event counter + \param [in] mask Counters to increment + \note Software increment bits for one or more event counters (0-30) +*/ +__STATIC_INLINE void ARM_PMU_CNTR_Increment(uint32_t mask) +{ + PMU->SWINC = mask; +} + +#endif diff --git a/bsp/tae32f5300/Libraries/CMSIS/Include/tz_context.h b/bsp/tae32f5300/Libraries/CMSIS/Include/tz_context.h new file mode 100644 index 0000000000..0d09749f3a --- /dev/null +++ b/bsp/tae32f5300/Libraries/CMSIS/Include/tz_context.h @@ -0,0 +1,70 @@ +/****************************************************************************** + * @file tz_context.h + * @brief Context Management for Armv8-M TrustZone + * @version V1.0.1 + * @date 10. January 2018 + ******************************************************************************/ +/* + * Copyright (c) 2017-2018 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined (__clang__) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef TZ_CONTEXT_H +#define TZ_CONTEXT_H + +#include + +#ifndef TZ_MODULEID_T +#define TZ_MODULEID_T +/// \details Data type that identifies secure software modules called by a process. +typedef uint32_t TZ_ModuleId_t; +#endif + +/// \details TZ Memory ID identifies an allocated memory slot. +typedef uint32_t TZ_MemoryId_t; + +/// Initialize secure context memory system +/// \return execution status (1: success, 0: error) +uint32_t TZ_InitContextSystem_S (void); + +/// Allocate context memory for calling secure software modules in TrustZone +/// \param[in] module identifies software modules called from non-secure mode +/// \return value != 0 id TrustZone memory slot identifier +/// \return value 0 no memory available or internal error +TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); + +/// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); + +/// Load secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); + +/// Store secure context (called on RTOS thread context switch) +/// \param[in] id TrustZone memory slot identifier +/// \return execution status (1: success, 0: error) +uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); + +#endif // TZ_CONTEXT_H diff --git a/bsp/tae32f5300/Libraries/SConscript b/bsp/tae32f5300/Libraries/SConscript new file mode 100644 index 0000000000..f316ba52e6 --- /dev/null +++ b/bsp/tae32f5300/Libraries/SConscript @@ -0,0 +1,58 @@ +# RT-Thread building script for bridge + +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/Device/Tai_action/TAE32F53xx/Source/system_tae32f53xx.c +TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll.c +TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_cortex.c +TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_sysctrl.c +TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_fpll.c +TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_gpio.c +TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dma.c +""") + +if GetDepend(['RT_USING_SERIAL']): + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_uart.c'] + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_tmr.c'] + +if GetDepend(['RT_USING_I2C']): + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_i2c.c'] + +if GetDepend(['RT_USING_CAN']): + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_can.c'] + +if GetDepend(['RT_USING_ADC']): + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_adc.c'] + +if GetDepend(['RT_USING_WDT']): + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_wwdg.c'] + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_iwdg.c'] + +if GetDepend(['RT_USING_HWTIMER']) or GetDepend(['RT_USING_PWM'] or GetDepend(['RT_USING_PULSE_ENCODER'])): + src += ['TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_tmr.c'] + +#add for startup script +if rtconfig.CROSS_TOOL == 'gcc': + src = src + ['CMSIS/Device/Tai_action/TAE32F53xx/Source/GCC/startup_ARMCM3.S'] +elif rtconfig.CROSS_TOOL == 'keil': + src = src + ['CMSIS/Device/Tai_action/TAE32F53xx/Source/startup_tae32f53xx.c'] +elif rtconfig.CROSS_TOOL == 'iar': + src = src + ['CMSIS/Device/Tai_action/TAE32F53xx/Source/IAR/startup_ARMCM3.s'] + +#add headfile script +path = [cwd + '/CMSIS/Include', + cwd + '/CMSIS/Device/Tai_action/TAE32F53xx/Include', + cwd + '/TAE32F53xx_StdPeriph_Driver/inc'] + +CPPDEFINES = ['USE_TAE_DRIVER', rtconfig.MCU_TYPE, '__DEBUG'] + +group = DefineGroup('TAE32_StdPeriph', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES) + +Return('group') diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll.h new file mode 100644 index 0000000000..0c289ca40b --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll.h @@ -0,0 +1,166 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll.h + * @author MCD Application Team + * @brief This file contains all the functions prototypes for the LL + * module driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_H_ +#define _TAE32F53XX_LL_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_conf.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup TAE32F53xx_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup TAE32F53xx_LL_Exported_Constants TAE32F53xx LL Exported Constants + * @brief TAE32F53xx LL Exported Constants + * @{ + */ + +/** + * @brief TAE32F53xx LL Driver version number V1.2.0 + */ +#define __TAE32F53xx_LL_VERSION_MAIN (0x01U) /*!< [31:24] main version */ +#define __TAE32F53xx_LL_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */ +#define __TAE32F53xx_LL_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ +#define __TAE32F53xx_LL_VERSION_RC (0x00U) /*!< [7:0] release candidate */ +#define __TAE32F53xx_LL_VERSION ((__TAE32F53xx_LL_VERSION_MAIN << 24) |\ + (__TAE32F53xx_LL_VERSION_SUB1 << 16) |\ + (__TAE32F53xx_LL_VERSION_SUB2 << 8 ) |\ + (__TAE32F53xx_LL_VERSION_RC)) + +/** + * @brief TAE32F53xx SDK Stage String definition + * @note Value range: "Alpha" "Beta" "RC" "Trial" "Release" + */ +#define SDK_STAGE_STR "Release" + +/** + * @} + */ + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup TAE32F53xx_LL_Exported_Types TAE32F53xx LL Exported Types + * @brief TAE32F53xx LL Exported Types + * @{ + */ + +/** + * LL Tick Freq Enum Type Definition + */ +typedef enum { + LL_TICK_FREQ_10HZ = 100U, /*!< Tick Frequency 10Hz */ + LL_TICK_FREQ_100HZ = 10U, /*!< Tick Frequency 100Hz */ + LL_TICK_FREQ_1KHZ = 1U, /*!< Tick Frequency 1KHz */ + LL_TICK_FREQ_DEFAULT = LL_TICK_FREQ_1KHZ, /*!< Tick Frequency default */ +} LL_TickFreqETypeDef; + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup TAE32F53xx_LL_Exported_Functions + * @{ + */ + +/** @addtogroup TAE32F53xx_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_Init(void); +LL_StatusETypeDef LL_DeInit(void); +void LL_MspInit(void); +void LL_MspDeInit(void); + +LL_StatusETypeDef LL_InitTick(uint32_t TickPriority); +/** + * @} + */ + + +/** @addtogroup TAE32F53xx_LL_Exported_Functions_Group2 + * @{ + */ +void LL_IncTick(void); +uint32_t LL_GetTick(void); +uint32_t LL_GetTickPrio(void); +LL_StatusETypeDef LL_SetTickFreq(LL_TickFreqETypeDef Freq); +LL_TickFreqETypeDef LL_GetTickFreq(void); +void LL_SuspendTick(void); +void LL_ResumeTick(void); +void LL_Delay(uint32_t Delay); +uint32_t LL_GetHalVersion(void); +void LL_GetUID(uint32_t *UID[4]); +/** + * @} + */ + + +/** @addtogroup TAE32F53xx_LL_Exported_Functions_Group3 + * @{ + */ +void LL_ShowInfo(void); +void delay_ms(uint32_t ms); +void printf_array(void *ptr, uint32_t len); +/** + * @} + */ + +/** + * @} + */ + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _TAE32F53XX_LL_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_adc.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_adc.h new file mode 100644 index 0000000000..202a6ff6c3 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_adc.h @@ -0,0 +1,3582 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_adc.h + * @author MCD Application Team + * @brief Header file of ADC LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_ADC_H_ +#define _TAE32F53XX_LL_ADC_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup ADC_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup ADC_LL_Exported_Constants ADC LL Exported Constants + * @brief ADC LL Exported Constants + * @{ + */ + +/** + * @brief regular trigger edge + * Internal mask for ADC group regular trigger: + * To select into literal LL_ADC_REG_TRIG_x the relevant bits for: + */ +#define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_LR_EXTEN_0) + +/** + * @brief Mask containing trigger source masks for each of possible + * trigger edge selection duplicated with shifts [0; 4; 8; 12] + * corresponding to {SW start; ext trigger; ext trigger; ext trigger} + */ +#define ADC_REG_TRIG_SOURCE_MASK (((ADC_REG_TRIG_SOFTWARE & ADC_LR_EXTSEL) << (4U * 0UL)) | \ + ((ADC_LR_EXTSEL) << (4U * 1UL)) | \ + ((ADC_LR_EXTSEL) << (4U * 2UL)) | \ + ((ADC_LR_EXTSEL) << (4U * 3UL)) ) + +/** + * @brief Mask containing trigger edge masks for each of possible + * trigger edge selection duplicated with shifts [0; 4; 8; 12] + * corresponding to {SW start; ext trigger; ext trigger; ext trigger} + */ +#define ADC_REG_TRIG_EDGE_MASK (((ADC_REG_TRIG_SOFTWARE & ADC_LR_EXTEN) << (4U * 0UL)) | \ + ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \ + ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \ + ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) ) + +/** + * @brief Definition of ADC group regular trigger bits information + */ +#define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS (ADC_LR_EXTSEL_Pos) + +/** + * @brief Definition of ADC group regular trigger bits information + */ +#define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (ADC_LR_EXTEN_Pos) + +/** + * @brief Internal mask for ADC group injected trigger: + * To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: + */ +#define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_JLR_JEXTEN_0) + +/** + * @brief Mask containing trigger source masks for each of possible + * trigger edge selection duplicated with shifts [0; 4; 8; 12] + * corresponding to {SW start; ext trigger; ext trigger; ext trigger} + */ +#define ADC_INJ_TRIG_SOURCE_MASK (((ADC_INJ_TRIG_SOFTWARE & ADC_JLR_JEXTSEL) << (4U * 0UL)) | \ + ((ADC_JLR_JEXTSEL) << (4U * 1UL)) | \ + ((ADC_JLR_JEXTSEL) << (4U * 2UL)) | \ + ((ADC_JLR_JEXTSEL) << (4U * 3UL)) ) + +/** + * @brief Mask containing trigger edge masks for each of possible + * trigger edge selection duplicated with shifts [0; 4; 8; 12] + * corresponding to {SW start; ext trigger; ext trigger; ext trigger} + */ +#define ADC_INJ_TRIG_EDGE_MASK (((ADC_INJ_TRIG_SOFTWARE & ADC_JLR_JEXTEN) << (4U * 0UL)) | \ + ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 1UL)) | \ + ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 2UL)) | \ + ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) << (4U * 3UL)) ) + +/** + * @brief Definition of ADC group injected trigger bits information + */ +#define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS (ADC_JLR_JEXTSEL_Pos) + +/** + * @brief Definition of ADC group injected trigger bits information + */ +#define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS (ADC_JLR_JEXTEN_Pos) + +/** + * @brief Definition of ADC group injected trigger bits information + */ +#define ADC_SINGLEDIFF_CHANNEL_SHIFT (0x00000001UL) + +/** + * @brief Definition of ADC group injected trigger bits information + */ +#define ADC_JSQX_REGOFFSET (0x00000002UL) + +/** + * @brief Definition of ADC group injected trigger bits information + */ +#define ADC_SMPRX_REGOFFSET (0x00000002UL) + +/** + * @brief Definition of ADC group injected trigger bits information + */ +#define ADC_SMPRX_REGOFFSET_POS (25UL) /* Position of bits ADC_SMPRx_REGOFFSET in ADC_CHANNEL_SMPRX_REGOFFSET_MASK */ + + +/** + * @brief ADC register CR bits: Software can read as well as set this bit. Writing '0' has no effect on the bit value. + */ +#define ADC_CR0_BITS_PROPERTY_RS (ADC_CR0_JADSTP | ADC_CR0_ADSTP | ADC_CR0_JADSTART | ADC_CR0_ADSTART) + + + +/** @defgroup ADC_LL_AWD_CHANNELS ADC LL AWD CHANNELS + * @brief Analog watchdog Monitored channels + * @{ + */ + +/** @brief ADC analog watchdog monitoring disabled */ +#define ADC_AWD_DISABLE (0x00000000UL) +/** @brief ADC analog watchdog monitoring enable */ +#define ADC_AWD_ALL_CHANNELS (0x00000FFFUL) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0 */ +#define ADC_AWD_CHANNEL_0 (ADC_AWD0CR_AWD0CH_0 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1 */ +#define ADC_AWD_CHANNEL_1 (ADC_AWD0CR_AWD0CH_1 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2 */ +#define ADC_AWD_CHANNEL_2 (ADC_AWD0CR_AWD0CH_2 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3 */ +#define ADC_AWD_CHANNEL_3 (ADC_AWD0CR_AWD0CH_3 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4 */ +#define ADC_AWD_CHANNEL_4 (ADC_AWD0CR_AWD0CH_4 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5 */ +#define ADC_AWD_CHANNEL_5 (ADC_AWD0CR_AWD0CH_5 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6 */ +#define ADC_AWD_CHANNEL_6 (ADC_AWD0CR_AWD0CH_6 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7 */ +#define ADC_AWD_CHANNEL_7 (ADC_AWD0CR_AWD0CH_7 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8 */ +#define ADC_AWD_CHANNEL_8 (ADC_AWD0CR_AWD0CH_8 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9 */ +#define ADC_AWD_CHANNEL_9 (ADC_AWD0CR_AWD0CH_9 ) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10 */ +#define ADC_AWD_CHANNEL_10 (ADC_AWD0CR_AWD0CH_10) +/** @brief ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11 */ +#define ADC_AWD_CHANNEL_TEMPSENSOR (ADC_AWD0CR_AWD0CH_11) + +/** + * @} + */ + + +/** @defgroup ADC_LL_IT ADC LL IT + * @brief ADC interruptions for configuration (interruption enable or disable) + * @note IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions + * @{ + */ +#define ADC_IT_ADRDY ADC_IER_ADRDYIE /*!< ADC interruption ADC instance ready */ +#define ADC_IT_EOC ADC_IER_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion */ +#define ADC_IT_EOS ADC_IER_EOSIE /*!< ADC interruption ADC group regular end of sequence conversions */ +#define ADC_IT_OVR ADC_IER_OVRIE /*!< ADC interruption ADC group regular overrun */ +#define ADC_IT_EOSMP ADC_IER_EOSMPIE /*!< ADC interruption ADC group regular end of sampling phase */ +#define ADC_IT_JEOC ADC_IER_JEOCIE /*!< ADC interruption ADC group injected end of unitary conversion */ +#define ADC_IT_JEOS ADC_IER_JEOSIE /*!< ADC interruption ADC group injected end of sequence conversions */ +#define ADC_IT_AWD0 ADC_IER_AWD0IE /*!< ADC interruption ADC analog watchdog 0 */ +#define ADC_IT_AWD1 ADC_IER_AWD1IE /*!< ADC interruption ADC analog watchdog 1 */ +#define ADC_IT_AWD2 ADC_IER_AWD2IE /*!< ADC interruption ADC analog watchdog 2 */ +/** + * @} + */ + + +/** @defgroup ADC_FLAG ADC FLAG + * @brief Flags defines which can be used with LL_ADC_ReadReg function + * @{ + */ +#define ADC_FLAG_ADRDY ADC_ISR_ADRDY /*!< ADC flag ADC instance ready */ +#define ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC flag ADC group regular end of unitary conversion */ +#define ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC flag ADC group regular end of sequence conversions */ +#define ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC flag ADC group regular overrun */ +#define ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC flag ADC group regular end of sampling phase */ +#define ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC flag ADC group injected end of unitary conversion */ +#define ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC flag ADC group injected end of sequence conversions */ +#define ADC_FLAG_AWD0 ADC_ISR_AWD0 /*!< ADC flag ADC analog watchdog 1 */ +#define ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC flag ADC analog watchdog 2 */ +#define ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC flag ADC analog watchdog 3 */ + +#define ADC_AWD_THRESHOLDS_HIGH_POS (16U) /*!< ADC AWD Thresholds high pos */ +/** + * @} + */ + + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup ADC_LL_Exported_Types ADC LL Exported Types + * @brief ADC LL Exported Types + * @{ + */ + +/** + * @brief Oversampling - Data shift + */ +typedef enum { + ADC_OVSS_SHIFT_NONE = 0x0, + /*!< ADC oversampling no shift (sum of the ADC conversions data is not divided to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_1 = ADC_CR1_OVSS_0, + /*!< ADC oversampling shift of 1 (sum of the ADC conversions data is divided by 2 to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_2 = ADC_CR1_OVSS_1, + /*!< ADC oversampling shift of 2 (sum of the ADC conversions data is divided by 4 to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_3 = ADC_CR1_OVSS_1 | ADC_CR1_OVSS_0, + /*!< ADC oversampling shift of 3 (sum of the ADC conversions data is divided by 8 to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_4 = ADC_CR1_OVSS_2, + /*!< ADC oversampling shift of 4 (sum of the ADC conversions data is divided by 16 to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_5 = ADC_CR1_OVSS_2 | ADC_CR1_OVSS_0, + /*!< ADC oversampling shift of 5 (sum of the ADC conversions data is divided by 32 to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_6 = ADC_CR1_OVSS_2 | ADC_CR1_OVSS_1, + /*!< ADC oversampling shift of 6 (sum of the ADC conversions data is divided by 64 to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_7 = ADC_CR1_OVSS_2 | ADC_CR1_OVSS_1 | ADC_CR1_OVSS_0, + /*!< ADC oversampling shift of 7 (sum of the ADC conversions data is divided by 128 to result as the ADC oversampling conversion data) */ + ADC_OVSS_SHIFT_RIGHT_8 = ADC_CR1_OVSS_3, + /*!< ADC oversampling shift of 8 (sum of the ADC conversions data is divided by 256 to result as the ADC oversampling conversion data) */ +} ADC_OverSampShiftETypeDef; + +/** + * @brief Oversampling - Ratio + */ +typedef enum { + ADC_OVSR_RATIO_2 = 0x0, + /*!< ADC oversampling ratio of 2 (before potential shift) */ + ADC_OVSR_RATIO_4 = ADC_CR1_OVSR_0, + /*!< ADC oversampling ratio of 4 (before potential shift) */ + ADC_OVSR_RATIO_8 = ADC_CR1_OVSR_1, + /*!< ADC oversampling ratio of 8 (before potential shift) */ + ADC_OVSR_RATIO_16 = ADC_CR1_OVSR_1 | ADC_CR1_OVSR_0, + /*!< ADC oversampling ratio of 16 (before potential shift) */ + ADC_OVSR_RATIO_32 = ADC_CR1_OVSR_2, + /*!< ADC oversampling ratio of 32 (before potential shift) */ + ADC_OVSR_RATIO_64 = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_0, + /*!< ADC oversampling ratio of 64 (before potential shift) */ + ADC_OVSR_RATIO_128 = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1, + /*!< ADC oversampling ratio of 128 (before potential shift) */ + ADC_OVSR_RATIO_256 = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1 | ADC_CR1_OVSR_0, + /*!< ADC oversampling ratio of 256 (before potential shift) */ +} ADC_OverSampRatioETypeDef; + +/** + * @brief Oversampling scope + */ +typedef enum { + ADC_OVS_DISABLE = 0x0, + /*!< ADC oversampling disabled. */ + ADC_OVS_GRP_REGULAR_CONTINUED = ADC_CR1_ROVSE, + /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular: + when ADC group injected is triggered, the oversampling on ADC group regular is temporary stopped and continued afterwards. */ + ADC_OVS_GRP_REGULAR_RESUMED = ADC_CR1_ROVSM | ADC_CR1_ROVSE, + /*!< ADC oversampling on conversions of ADC group regular. If group injected interrupts group regular: + when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */ + ADC_OVS_GRP_INJECTED = ADC_CR1_JOVSE, + /*!< ADC oversampling on conversions of ADC group injected. */ + ADC_OVS_GRP_INJ_REG_RESUMED = ADC_CR1_JOVSE | ADC_CR1_ROVSE, + /*!< ADC oversampling on conversions of both ADC groups regular and injected. If group injected interrupting group regular: + when ADC group injected is triggered, the oversampling on ADC group regular is resumed from start (oversampler buffer reset). */ +} ADC_OverSampModeETypeDef; + +/** + * @brief Oversampling scope for ADC group regular valid + */ +typedef enum { + ADC_OVS_CONTINUED_MODE = 0x0, + /*!< Oversampling buffer maintained during injection sequence */ + ADC_OVS_RESUMED_MODE = ADC_CR1_ROVSM, + /*!< Oversampling buffer zeroed during injection sequence */ +} ADC_OverSampROVSMETypeDef; + +/** + * @brief Discontinuous mode Trigger over sample + */ +typedef enum { + ADC_OVS_TRIG_CONT = 0x0, + /*!< ADC oversampling discontinuous mode: continuous mode (all conversions of oversampling ratio are done from 1 trigger) */ + ADC_OVS_TRIG_DISCONT = ADC_CR1_TROVS, + /*!< ADC oversampling discontinuous mode: discontinuous mode (each conversion of oversampling ratio needs a trigger) */ +} ADC_OverSampTROVSETypeDef; + +/** + * @brief Synchronization + */ +typedef enum { + ADC_SYNCEN_DIS = 0x0, + /*!< ADC synchronization is disable */ + ADC_SYNCEN_EN = ADC_CR1_SYNCEN, + /*!< ADC synchronization is enabled */ +} ADC_SyncEnETypeDef; + +/** + * @brief ADC TBIMOD SEL + */ +typedef enum { + ADC_TBIMOD_MUX_CLOSE = 0x0, + ADC_TBIMOD_A_SH = ADC_CR1_OVSR_2, + ADC_TBIMOD_A_ADC = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_0, + ADC_TBIMOD_B_SH = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1, + ADC_TBIMOD_B_ADC = ADC_CR1_OVSR_2 | ADC_CR1_OVSR_1 | ADC_CR1_OVSR_0, +} ADC_TestBuffModeETypeDef; + +/** + * @brief ADC ANOLOG CTL + */ +typedef enum { + ADC_ANOLOG_CTL_DEFAULT = ADC_CR2_ISEL_1 | ADC_CR2_CH_EN | ADC_CR2_FADC_EN | ADC_CR2_REF_EN | ADC_CR2_BIAS_EN, + ADC_ANOLOG_CTL_A_SH = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_A_SH, + ADC_ANOLOG_CTL_A_ADC = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_A_ADC, + ADC_ANOLOG_CTL_B_SH = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_B_SH, + ADC_ANOLOG_CTL_B_ADC = ADC_ANOLOG_CTL_DEFAULT | ADC_TBIMOD_B_ADC, +} ADC_AnologCtlETypeDef; + +/** + * @brief Channel Sampling time + */ +typedef enum { + ADC_SAMPLINGTIME_6CYCLES = 0x0, + /*!< Sampling time 6 ADC clock cycles */ + ADC_SAMPLINGTIME_18CYCLES = ADC_SMPR0_SMP0_0, + /*!< Sampling time 18 ADC clock cycles */ + ADC_SAMPLINGTIME_42CYCLES = ADC_SMPR0_SMP0_1, + /*!< Sampling time 42 ADC clock cycles */ + ADC_SAMPLINGTIME_90CYCLES = ADC_SMPR0_SMP0_1 | ADC_SMPR0_SMP0_0, + /*!< Sampling time 90 ADC clock cycles */ + ADC_SAMPLINGTIME_186CYCLES = ADC_SMPR0_SMP0_2, + /*!< Sampling time 186 ADC clock cycles */ + ADC_SAMPLINGTIME_378CYCLES = ADC_SMPR0_SMP0_2 | ADC_SMPR0_SMP0_0, + /*!< Sampling time 378 ADC clock cycles */ + ADC_SAMPLINGTIME_762CYCLES = ADC_SMPR0_SMP0_2 | ADC_SMPR0_SMP0_1, + /*!< Sampling time 762 ADC clock cycles */ + ADC_SAMPLINGTIME_1530CYCLES = ADC_SMPR0_SMP0_2 | ADC_SMPR0_SMP0_1 | ADC_SMPR0_SMP0_0, + /*!< Sampling time 1530 ADC clock cycles */ +} ADC_SampTimeETypeDef; + +/** + * @brief ADC CALCULATE OFFST GROUP SELECT + */ +typedef enum { + ADC_CAL_OFFSET_GROUP0 = 0x0, + /*ADC calibration offset/gain register gruop 0 -- OFR0*/ + ADC_CAL_OFFSET_GROUP1 = ADC_CALR0_CAL0_0, + /*ADC calibration offset/gain register gruop 1 -- OFR1*/ + ADC_CAL_OFFSET_GROUP2 = ADC_CALR0_CAL0_1, + /*ADC calibration offset/gain register gruop 2 -- OFR2*/ + ADC_CAL_OFFSET_GROUP3 = ADC_CALR0_CAL0_1 | ADC_CALR0_CAL0_0, + /*ADC calibration offset/gain register gruop 3 -- OFR3*/ +} ADC_CalrGroupETypeDef; + +/** + * @brief Trigger edge + */ +typedef enum { + LL_ADC_REG_TRIG_SOFT = 0x0, + /*!< ADC group regular conversion software trigger */ + ADC_REG_TRIG_EXT_RISING = ADC_LR_EXTEN_0, + /*!< ADC group regular conversion trigger polarity set to rising edge */ + ADC_REG_TRIG_EXT_FALLING = ADC_LR_EXTEN_1, + /*!< ADC group regular conversion trigger polarity set to falling edge */ + ADC_REG_TRIG_EXT_RISINGFALLING = ADC_LR_EXTEN_1 | ADC_LR_EXTEN_0, + /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */ +} ADC_RegTrigEdgeETypeDef; + +/** + * @brief Continuous mode + */ +typedef enum { + ADC_REG_CONV_SINGLE = 0x0, + /*!< ADC conversions are performed in single mode: one conversion per trigger */ + ADC_REG_CONV_CONTINUOUS = ADC_CR1_CONT, + /*!< ADC conversions are performed in continuous mode: after the first trigger, + following conversions launched successively automatically */ +} ADC_RegConvModeETypeDef; + +/** + * @brief Overrun behavior on conversion data + */ +typedef enum { + ADC_OVR_DATA_PRESERVED = 0x0, + /*!< ADC group regular behavior in case of overrun: data preserved */ + ADC_OVR_DATA_OVERWRITTEN = ADC_CR1_OVRMOD, + /*!< ADC group regular behavior in case of overrun: data overwritten */ +} ADC_OverRunModeETypeDef; + +/** + * @brief Sequencer discontinuous mode + */ +typedef enum { + ADC_REG_SEQ_DISCON_DISABLE = 0x0, + /*!< ADC group regular sequencer discontinuous mode disable */ + ADC_REG_SEQ_DISNUM_1RANK = ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */ + ADC_REG_SEQ_DISNUM_2RANKS = ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 2 ranks */ + ADC_REG_SEQ_DISNUM_3RANKS = ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */ + ADC_REG_SEQ_DISNUM_4RANKS = ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */ + ADC_REG_SEQ_DISNUM_5RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */ + ADC_REG_SEQ_DISNUM_6RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */ + ADC_REG_SEQ_DISNUM_7RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */ + ADC_REG_SEQ_DISNUM_8RANKS = ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN, + /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */ +} ADC_RegDiscontETypeDef; + +/** + * @brief Sequencer length + */ +typedef enum { + ADC_REG_SEQ_LENGTH_1 = 0x0, + /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */ + ADC_REG_SEQ_LENGTH_2 = ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 2 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_3 = ADC_LR_LEN_1, + /*!< ADC group regular sequencer enable with 3 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_4 = ADC_LR_LEN_1 | ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 4 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_5 = ADC_LR_LEN_2, + /*!< ADC group regular sequencer enable with 5 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_6 = ADC_LR_LEN_2 | ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 6 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_7 = ADC_LR_LEN_2 | ADC_LR_LEN_1, + /*!< ADC group regular sequencer enable with 7 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_8 = ADC_LR_LEN_2 | ADC_LR_LEN_1 | ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 8 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_9 = ADC_LR_LEN_3, + /*!< ADC group regular sequencer enable with 9 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_10 = ADC_LR_LEN_3 | ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 10 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_11 = ADC_LR_LEN_3 | ADC_LR_LEN_1, + /*!< ADC group regular sequencer enable with 11 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_12 = ADC_LR_LEN_3 | ADC_LR_LEN_1 | ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 12 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_13 = ADC_LR_LEN_3 | ADC_LR_LEN_2, + /*!< ADC group regular sequencer enable with 13 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_14 = ADC_LR_LEN_3 | ADC_LR_LEN_2 | ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 14 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_15 = ADC_LR_LEN_3 | ADC_LR_LEN_2 | ADC_LR_LEN_1, + /*!< ADC group regular sequencer enable with 15 ranks in the sequence */ + ADC_REG_SEQ_LENGTH_16 = ADC_LR_LEN_3 | ADC_LR_LEN_2 | ADC_LR_LEN_1 | ADC_LR_LEN_0, + /*!< ADC group regular sequencer enable with 16 ranks in the sequence */ +} ADC_RegSeqLengthETypeDef; + +/** + * @brief Sequencer ranks + */ +typedef enum { + ADC_REG_RANK_1 = 0x0UL, + /*!< ADC group regular sequencer rank 1 */ + ADC_REG_RANK_2 = 0x1UL, + /*!< ADC group regular sequencer rank 2 */ + ADC_REG_RANK_3 = 0x2UL, + /*!< ADC group regular sequencer rank 3 */ + ADC_REG_RANK_4 = 0x3UL, + /*!< ADC group regular sequencer rank 4 */ + ADC_REG_RANK_5 = 0x4UL, + /*!< ADC group regular sequencer rank 5 */ + ADC_REG_RANK_6 = 0x5UL, + /*!< ADC group regular sequencer rank 6 */ + ADC_REG_RANK_7 = 0x6UL, + /*!< ADC group regular sequencer rank 7 */ + ADC_REG_RANK_8 = 0x7UL, + /*!< ADC group regular sequencer rank 8 */ + ADC_REG_RANK_9 = 0x8UL, + /*!< ADC group regular sequencer rank 9 */ + ADC_REG_RANK_10 = 0x9UL, + /*!< ADC group regular sequencer rank 10 */ + ADC_REG_RANK_11 = 0xAUL, + /*!< ADC group regular sequencer rank 11 */ + ADC_REG_RANK_12 = 0xBUL, + /*!< ADC group regular sequencer rank 12 */ + ADC_REG_RANK_13 = 0xCUL, + /*!< ADC group regular sequencer rank 13 */ + ADC_REG_RANK_14 = 0xDUL, + /*!< ADC group regular sequencer rank 14 */ + ADC_REG_RANK_15 = 0xEUL, + /*!< ADC group regular sequencer rank 15 */ + ADC_REG_RANK_16 = 0xFUL, + /*!< ADC group regular sequencer rank 16 */ +} ADC_RegSeqRankETypeDef; + +/** + * @brief Trigger source + */ +typedef enum { + ADC_REG_TRIG_SOFTWARE = 0x0, + /*!TCR + */ +typedef enum { + ADC_REG_DMA_TRANSFER_DISABLE = 0x0, + ADC_REG_DMA_TRANSFER_SINGLE = ADC_DMA_TCR_START, + ADC_REG_DMA_TRANSFER_CIRCLE = ADC_DMA_TCR_CIRC | ADC_DMA_TCR_START, +} ADC_DMATransferModeETypeDef; + +/** + * @brief ADC instance Channel number + */ +typedef enum { + ADC_CHANNEL_0 = 0UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 */ + ADC_CHANNEL_1 = 1UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 */ + ADC_CHANNEL_2 = 2UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 */ + ADC_CHANNEL_3 = 3UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 */ + ADC_CHANNEL_4 = 4UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 */ + ADC_CHANNEL_5 = 5UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 */ + ADC_CHANNEL_6 = 6UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 */ + ADC_CHANNEL_7 = 7UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 */ + ADC_CHANNEL_8 = 8UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 */ + ADC_CHANNEL_9 = 9UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 */ + ADC_CHANNEL_10 = 10UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10 */ + ADC_CHANNEL_TEMPSENSOR = 11UL, + /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11 */ +} ADC_ChannelSelETypeDef; + + +/** + * @brief ADC group regular oversampling structure definition + */ +typedef struct __ADC_OversamplingTypeDef { + ADC_OverSampROVSMETypeDef OverSampResetMode; /*!< Set ADC over sample reset mode,only regular group is valid */ + ADC_OverSampTROVSETypeDef TrigOverSamp; /*!< Set ADC trigger over sample */ + ADC_OverSampShiftETypeDef OverSampShiftBit; /*!< Set ADC over sample shift bit */ + ADC_OverSampRatioETypeDef OverSampRatio; /*!< Set ADC over sample ratio */ +} ADC_OversamplingTypeDef; + +/** @defgroup LL_ADC_INIT ADC Exported Init structure + * @brief Structure definition of some features of ADC instance. + * @note These parameters have an impact on ADC scope: ADC instance. + * Affects both group regular and group injected. + * Refer to corresponding unitary functions into + * @note The setting of these parameters by function reference LL_ADC_Init() + * is conditioned to ADC state: + * ADC instance must be disabled. + */ +typedef struct __ADC_InitTypeDef { + uint32_t NormInterrupt; /*!< Set ADC Normal interrupt paramter cconfig. + This parameter can be combination value of reference LL_ADC_IT */ + ADC_SyncEnETypeDef Synchronization; /*!< Set ADC synchronization */ + ADC_AnologCtlETypeDef AnologCfg; /*!< Set ADC anolog paramter cconfig */ + ADC_OverRunModeETypeDef Overrun; /*!< Set ADC group regular behavior in case of overrun: data preserved or overwritten */ + LL_FuncStatusETypeDef RegOversampMode; /*!< Specify whether the regular group oversampling feature is enabled or disabled */ + LL_FuncStatusETypeDef InjOversampMode; /*!< Specify whether the injected group oversampling feature is enabled or disabled */ + ADC_OversamplingTypeDef OverSampling; /*!< Specify the Oversampling parameters.Caution: this setting overwrites the + previous oversampling configuration if oversampling is already enabled. */ +} ADC_InitTypeDef; + +/** + * @brief Structure definition of some features of ADC group regular. + * @note These parameters have an impact on ADC scope: ADC group regular. + * Refer to corresponding unitary functions into + * (functions with prefix "REG"). + */ +typedef struct __ADC_REG_InitTypeDef { + ADC_ChannelSelETypeDef Channel; /*!< Set ADC group regular conversion Channel. */ + LL_FuncStatusETypeDef SampInterrupt; /*!< Configures the ADC conversion Channel Sample interrupt. */ + ADC_RegSeqRankETypeDef SequencerPos; /*!< Set SQR is configured in combination with length for the number of conversions */ + ADC_RegExtTrigSrcETypeDef TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) + or from external peripheral(timer event,hrpwm trigger , up edge). */ + ADC_RegSeqLengthETypeDef SequencerLength; /*!< Set ADC group regular sequencer length. */ + ADC_RegDiscontETypeDef SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided + and scan conversions interrupted every selected number of ranks. */ + ADC_RegConvModeETypeDef ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC + conversions are performedin single mode (one conversion per trigger). or in + continuous mode (after the first trigger,following conversions launched + successively automatically). */ + ADC_DiffSelETypeDef DifferSel; /*!< Set ADC group regular channel is differential or single mode */ + ADC_SampTimeETypeDef SampTimClk; /*!< Set ADC group regular channel sample clk length */ +} ADC_REG_InitTypeDef; + +/** + * @brief Structure definition of some features of ADC group injected. + * @note These parameters have an impact on ADC scope: ADC group injected. + * (functions with prefix "INJ"). + */ +typedef struct __ADC_INJ_InitTypeDef { + ADC_ChannelSelETypeDef Channel; /*!< Set ADC group injected conversion Channel. */ + ADC_InjSeqRankETypeDef SequencerPos; /*!< Set JSQR is configured in combination with length for the number of + conversions the channel is placed on. */ + ADC_InjExtTrigSrcETypeDef TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) + or from external peripheral (timer event, external interrupt line). */ + ADC_InjSeqLengthETypeDef SequencerLength; /*!< Set ADC group injected sequencer length. */ + ADC_InjDiscontEnETypeDef SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence + subdivided and scan conversions interrupted every selected number of ranks. */ + ADC_InjAutoTrigETypeDef TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular. */ + +} ADC_INJ_InitTypeDef; + +/** + * @brief Structure definition of some features of ADC to ECU. + * @note These parameters have an impact on ADC scope: ADC to ECU. + * Electric quantity parameter calculation configuration. + */ +typedef struct __ADC_ECUConfTypeDef { + ADC_EcuGroupETypeDef GroupSel; /*!< Each ADC has four sets of ECU configurations, and the ECU is divided into four events. */ + ADC_ChannelSelETypeDef AddrDataSel; /*!< Set ADC to ECU: The ECU fetches data from the channel address of the ADC . */ + ADC_AnologWDETypeDef PingPongUpZero; /*!< Set Sinusoidal wave above zero detection of the selected watchdog. */ + ADC_AnologWDETypeDef PingPongDownZero; /*!< SetSinusoidal wave down through zero detection of the selected watchdog. */ + ADC_ChannelSelETypeDef AWD2SourceSel; /*!< Set Watchdog 2 monitors channel sources. */ + ADC_ChannelSelETypeDef AWD1SourceSel; /*!< Set Watchdog 1 monitors channel sources. */ + ADC_ChannelSelETypeDef AWD0SourceSel; /*!< Set Watchdog 0 monitors channel sources. */ +} ADC_ECUConfTypeDef; + +/** + * @brief Structure definition of ADC analog watchdog + * @note The setting of these parameters by function HAL_ADC_AnalogWDGConfig() is conditioned to ADC state. + * ADC state can be either: + * - For all parameters except 'HighThreshold', 'LowThreshold': ADC disabled or ADC enabled without conversion on going + * on ADC groups regular and injected. + * - For parameters 'HighThreshold', 'LowThreshold': ADC enabled with conversion on going on regular and injected groups. + */ +typedef struct __ADC_AnalogWDGCfgTypeDef { + + uint32_t Channel; /*!< Select which ADC channel to monitor by analog watchdog. + This parameter can be combination value of reference LL_ADC_AWD_CHANNELS. */ + + int16_t HighThreshold; /*!< Configure the ADC analog watchdog High threshold value. + This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ + + int16_t LowThreshold; /*!< Configures the ADC analog watchdog Low threshold value. + This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ + + ADC_AnologWDETypeDef WatchdogNumber; /*!< Select which ADC analog watchdog is monitoring the selected channel. */ + + ADC_AnologWDFliterETypeDef Filtering; /*!< Specify whether filtering should be use and the number of samples to consider. + Before setting flag or raising interrupt, analog watchdog can wait to have several + consecutive out-of-window samples. This parameter allows to configure this number. */ +} ADC_AnalogWDGCfgTypeDef; + +/** + * @brief Structure definition of ADC DMA Transfer + * @note The setting of these parameters by function LL_ADC_DMATransferConfig() is conditioned to ADC state. + * Each channel corresponds to a set of DMA, and only regular channels can use DMA. + */ +typedef struct __ADC_DMATransferCfgTypeDef { + ADC_ChannelSelETypeDef Channel; /*!< Select which ADC direct memory access the selected channel. */ + LL_FuncStatusETypeDef HalfInterrupt; /*!< Configures the ADC direct memory access Half interrupt. */ + LL_FuncStatusETypeDef FullInterrupt; /*!< Configures the ADC direct memory access Full interrupt. */ + ADC_DMATransferModeETypeDef TransferMode; /*!< Configure the DMA transfer mode to be single or cyclic. */ + uint32_t Address; /*!< Configure the address of the DMA transfer Buffer ,Only SECTION_RAMB, + SECTION_RAMB can be configured . */ + uint32_t Length; /*!< Configure the length of data (byte units) for a single DMA transfer. + This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */ +} ADC_DMATransferCfgTypeDef; + + +/** + * @brief Calibration parameter definitions for ADC groups regular and injected + */ +typedef struct __ADC_CalibrationTypeDef { + ADC_ChannelSelETypeDef Channel; /*!< Select which ADC channel congfigure Calibration parameters. */ + ADC_CalibGroupETypeDef CalibrationGroup; /*!< Set ADC calibration group parameter selection. */ + + int16_t Offset; /*!< Configure ADC calibration offset,default value is 0x0. + This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ + + uint16_t Gain; /*!< Configure ADC calibration gain defaulr value is 0x2000. + This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF */ +} ADC_CalibrationTypeDef; + +/** + * @brief Read ADC self-calibration data + */ +typedef struct { + int16_t SingleOffset; /*!< Read ADC single-ended self-calibration data*/ + + uint16_t SingleGain; /*!< Read ADC single-ended self-calibration data*/ + + int16_t DiffOffset; /*!< Read ADC differential self-calibration data*/ + + uint16_t DiffGain; /*!< Read ADC differential self-calibration data*/ + + int16_t SingleBuffOffset; /*!< Read ADC single-ended plus BUFF self-calibration data*/ + + uint16_t SingleBuffGain; /*!< Read ADC single-ended plus BUFF self-calibration data*/ + +} ADC_CalibrationDataTypeDef; + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup ADC_LL_Exported_Macros ADC LL Exported Macros + * @brief ADC LL Exported Macros + * @{ + */ + +/** + * @brief Driver macro reserved for internal use: set a pointer to + * a register from a register basis from which an offset + * is applied. + * @param __REG__ Register basis from which the offset is applied. + * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers). + * @retval Pointer to register address + */ +#define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \ + ((__IO uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2UL)))) + + +/** @addtogroup ADC_LL_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular + * @{ + */ +/** + * @brief Start ADC group regular conversion. + * @note This function is relevant for both + * internal trigger (SW start) and external trigger: + * - If ADC trigger has been set to software start, ADC conversion + * starts immediately. + * - If ADC trigger has been set to external trigger, ADC conversion + * will start at next trigger event (on the selected trigger edge) + * following the ADC start conversion command. + * @note Setting of this feature is conditioned to + * ADC state: + * ADC must be enabled without conversion on going on group regular, + * without conversion stop command on going on group regular, + * without ADC disable command on going. + * @param Instance ADC instance + * @retval None + */ +#define __LL_ADC_REG_StartConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_ADSTART) + +/** + * @brief Stop ADC group regular conversion. + * @note Setting of this feature is conditioned to ADC state: + * ADC must be enabled with conversion on going on group regular, + * without ADC disable command on going. + * @param Instance ADC instance + * @retval None + */ +#define __LL_ADC_REG_StopConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_ADSTP) + +/** + * @brief Get ADC group regular conversion state. + * @param Instance ADC instance + * @retval 0: no conversion is on going on ADC group regular. + */ +#define __LL_ADC_REG_IsConversionOngoing(__INSTANCE__) \ + ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_ADSTART) == (ADC_CR0_ADSTART)) ? 1UL : 0UL) + +/** + * @brief Get ADC group regular command of conversion stop state + * @param Instance ADC instance + * @retval 0: no command of conversion stop is on going on ADC group regular. + */ +#define __LL_ADC_REG_IsStopConversionOngoing(__INSTANCE__) \ + ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_ADSTP) == (ADC_CR0_ADSTP)) ? 1UL : 0UL) + +/** + * @brief Get ADC group regular conversion data, range fit for + * all ADC configurations. + * @param Instance ADC instance + * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF + */ +#define __LL_ADC_REG_ReadConversionData(__INSTANCE__) (READ_BIT((__INSTANCE__)->DR, ADC_DR_RDATA)) + +/** + * @brief Get ADC group regular every channel conversion data, range fit for + * all ADC configurations. + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF + */ +#define __LL_ADC_REG_ReadChannelConversionData(__INSTANCE__, __CHANNEL__) \ + (READ_BIT((__INSTANCE__)->CDR[__CHANNEL__], ADC_CDR_RDATA)) + +/** + * @} + */ + +/** @addtogroup ADC_LL_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular + * @{ + */ +/** + * @brief Set for the ADC selected offset number 1, 2, 3 or 4: + * Channel to which the offset programmed will be applied + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @param GroupSel value can be one of the following values: + * @arg @ref ADC_OFFSET_1 + * @arg @ref ADC_OFFSET_2 + * @arg @ref ADC_OFFSET_3 + * @arg @ref ADC_OFFSET_4 + */ +#define __LL_ADC_SetCalGroup(__INSTANCE__, __CHANNEL__, __GROUPSEL__) \ + (__CHANNEL__ > 7) ? \ + MODIFY_REG((__INSTANCE__)->CALR1, ADC_CALR1_CAL8 << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET), \ + ((__GROUPSEL__) << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET))) : \ + MODIFY_REG((__INSTANCE__)->CALR0, ADC_CALR0_CAL0 << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET), \ + ((__GROUPSEL__) << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET))) + + +/** + * @brief Set ADC selected offset number 1, 2, 3 or 4. + * @note This function set the 2 items of offset configuration: + * - ADC channel to which the offset programmed will be applied + * (Single mode) + * - Offset level (offset to be subtracted from the raw + * converted data). + * @note Caution: Offset format is dependent to ADC resolution: + * offset has to be left-aligned on bit 11, the LSB (right bits) + * are set to 0. + * @note This function enables the offset, by default. It can be forced + * to disable state using function LL_ADC_SetOffsetState(). + * @param Instance ADC instance + * @param Offsety This parameter can be one of the following values: + * @arg @ref ADC_OFFSET_1 + * @arg @ref ADC_OFFSET_2 + * @arg @ref ADC_OFFSET_3 + * @arg @ref ADC_OFFSET_4 + * @param OffsetValue Value between Min_Data=0x0000 and Max_Data=0xFFFF + * @retval None + */ +#define __LL_ADC_SetOffset(__INSTANCE__, __OFFSETY__, __VALUE__) \ + MODIFY_REG((__INSTANCE__)->OFR[__OFFSETY__], ADC_OFR0_OFFSET, (__VALUE__)) + +/** + * @brief Get for the ADC selected offset number 1, 2, 3 or 4: + * Offset level (offset to be subtracted from the raw + * converted data). Single mode. + * @param Instance ADC instance + * @param Offsety This parameter can be one of the following values: + * @arg @ref ADC_OFFSET_1 + * @arg @ref ADC_OFFSET_2 + * @arg @ref ADC_OFFSET_3 + * @arg @ref ADC_OFFSET_4 + * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF + */ +#define __LL_ADC_GetOffset(__INSTANCE__, __OFFSETY__) READ_BIT((__INSTANCE__)->OFR[__OFFSETY__], ADC_OFR0_OFFSET) + +/** + * @brief Set ADC selected gain compensation number 1, 2, 3 or 4.Single mode. + * @note This function set the gain compensation coefficient + * that is applied to raw converted data using the formula: + * DATA = DATA(raw) * (gain compensation coef) >> 12 + * @param Instance ADC instance + * @param Gainy This parameter can be one of the following values: + * @arg @ref ADC_GAIN_1 + * @arg @ref ADC_GAIN_2 + * @arg @ref ADC_GAIN_3 + * @arg @ref ADC_GAIN_4 + * @param GainCompensation This parameter can be: + * 0 Gain compensation will be disabled and value set to 0 + * 1 -> 8192 Gain compensation will be enabled with specified value(default) + * @retval None + */ +#define __LL_ADC_SetGainCompensation(__INSTANCE__,__GAINY__, __VALUE__) \ + MODIFY_REG((__INSTANCE__)->GCR[(__GAINY__)], ADC_GCR0_GAIN, (__VALUE__)) + +/** + * @brief Get the ADC gain compensation value + * @param Instance ADC instance + * @param Gainy This parameter can be one of the following values: + * @arg @ref ADC_GAIN_1 + * @arg @ref ADC_GAIN_2 + * @arg @ref ADC_GAIN_3 + * @arg @ref ADC_GAIN_4 + * @retval Returned value can be: + * 0 Gain compensation is disabled + * 1 -> 8192 Gain compensation is enabled with returned value + */ +#define __LL_ADC_GetGainCompensation(__INSTANCE__,__GAINY__) READ_BIT((__INSTANCE__)->GCR[(__GAINY__)], ADC_GCR0_GAIN) + +/** + * @brief Set ADC selected offset number 1, 2, 3 or 4. + * @note This function set the 2 items of offset configuration: + * - ADC channel to which the offset programmed will be applied + * (Single mode) + * - Offset level (offset to be subtracted from the raw + * converted data). + * @note Caution: Offset format is dependent to ADC resolution: + * offset has to be left-aligned on bit 11, the LSB (right bits) + * are set to 0. + * @note This function enables the offset, by default. It can be forced + * to disable state using function LL_ADC_SetOffsetState(). + * @param Instance ADC instance + * @param Doffsety This parameter can be one of the following values: + * @arg @ref ADC_OFFSET_1 + * @arg @ref ADC_OFFSET_2 + * @arg @ref ADC_OFFSET_3 + * @arg @ref ADC_OFFSET_4 + * @param OffsetValue Value between Min_Data=0x0000 and Max_Data=0xFFFF + * @retval None + */ +#define __LL_ADC_SetDiffOffset(__INSTANCE__, __DOFFSETY__, __VALUE__) \ + MODIFY_REG((__INSTANCE__)->DOFR[(__DOFFSETY__)], ADC_DOFR0_OFFSET, (__VALUE__)) + +/** + * @brief Get for the ADC selected offset number 1, 2, 3 or 4: + * Offset level (offset to be subtracted from the raw + * converted data). Single mode. + * @param Instance ADC instance + * @param Doffsety This parameter can be one of the following values: + * @arg @ref ADC_OFFSET_1 + * @arg @ref ADC_OFFSET_2 + * @arg @ref ADC_OFFSET_3 + * @arg @ref ADC_OFFSET_4 + * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF + */ +#define __LL_ADC_GetDiffOffset(__INSTANCE__, __DOFFSETY__) READ_BIT((__INSTANCE__)->DOFR[(__DOFFSETY__)], ADC_DOFR0_OFFSET) + +/** + * @brief Set ADC selected gain compensation number 1, 2, 3 or 4.Single mode. + * @note This function set the gain compensation coefficient + * that is applied to raw converted data using the formula: + * DATA = DATA(raw) * (gain compensation coef) >> 12 + * @param Instance ADC instance + * @param Dgainy This parameter can be one of the following values: + * @arg @ref ADC_GAIN_1 + * @arg @ref ADC_GAIN_2 + * @arg @ref ADC_GAIN_3 + * @arg @ref ADC_GAIN_4 + * @param GainCompensation This parameter can be: + * 0 Gain compensation will be disabled and value set to 0 + * 1 -> 8192 Gain compensation will be enabled with specified value(default) + * @retval None + */ +#define __LL_ADC_SetDiffGainCompensation(__INSTANCE__,__DGAINY__, __VALUE__) \ + MODIFY_REG((__INSTANCE__)->DGCR[(__DGAINY__)], ADC_DGCR0_GAIN, (__VALUE__)) + +/** + * @brief Get the ADC gain compensation value ,Differential. + * @param Instance ADC instance + * @param Dgainy This parameter can be one of the following values: + * @arg @ref ADC_GAIN_1 + * @arg @ref ADC_GAIN_2 + * @arg @ref ADC_GAIN_3 + * @arg @ref ADC_GAIN_4 + * @retval Returned value can be: + * 0 Gain compensation is disabled + * 1 -> 8192 Gain compensation is enabled with returned value + */ +#define __LL_ADC_GetDiffGainCompensation(__INSTANCE__,__DGAINY__) READ_BIT((__INSTANCE__)->DGCR[(__DGAINY__)], ADC_DGCR0_GAIN) + +/** + * @brief Set ADC group regular conversion trigger source: + * internal (SW start) or from external peripheral (timer event, + * external interrupt line). + * @note setting trigger source to external trigger + * also set trigger polarity to rising edge. + * ADC must be without conversion on going on group regular. + * @param Instance ADC instance + * @param TriggerSource This parameter can be one of the following values: + * @arg @ref ADC_REG_TRIG_SOFTWARE) + * @arg @ref ADC_REG_TRIG_EXT_TIM0_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM1_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM2_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM3_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM4_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM5_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM6_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM7_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM0_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM1_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM2_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM3_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM4_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM5_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM6_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM7_TRGO + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG0 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG1 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG2 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG3 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG4 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG5 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG6 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG7 + * @arg @ref ADC_REG_TRIG_EXT_PIN + * @retval None + */ +#define __LL_ADC_REG_SetTriggerSource(__INSTANCE__, __TRIGSRC__) \ + MODIFY_REG((__INSTANCE__)->LR, ADC_LR_EXTEN | ADC_LR_EXTSEL, (__TRIGSRC__)) + +/** + * @brief Get ADC group regular conversion trigger source: + * internal (SW start) or from external peripheral (timer event, + * external interrupt line). + * @note To determine whether group regular trigger source is + * internal (SW start) or external, without detail + * of which peripheral is selected as external trigger, + * use function @ref LL_ADC_REG_IsTriggerSourceSWStart. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_REG_TRIG_SOFTWARE) + * @arg @ref ADC_REG_TRIG_EXT_TIM0_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM1_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM2_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM3_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM4_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM5_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM6_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM7_CC + * @arg @ref ADC_REG_TRIG_EXT_TIM0_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM1_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM2_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM3_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM4_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM5_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM6_TRGO + * @arg @ref ADC_REG_TRIG_EXT_TIM7_TRGO + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG0 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG1 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG2 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG3 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG4 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG5 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG6 + * @arg @ref ADC_REG_TRIG_EXT_HRPWM_ADC_TRG7 + * @arg @ref ADC_REG_TRIG_EXT_PIN) + */ +#define __LL_ADC_REG_GetTriggerSource(__INSTANCE__) (READ_BIT((__INSTANCE__)->LR, ADC_LR_EXTSEL) + +/** + * @brief Get ADC group regular conversion trigger source internal (SW start) + * or external. + * @note In case of group regular trigger source set to external trigger, + * to determine which peripheral is selected as external trigger, + * use function @ref LL_ADC_REG_GetTriggerSource(). + * @param Instance ADC instance + * @retval Value "0" if trigger source external trigger + * Value "1" if trigger source SW start. + */ +#define __LL_ADC_REG_IsTriggerSourceSWStart(__INSTANCE__) \ + ((READ_BIT((__INSTANCE__)->LR, ADC_LR_EXTEN) == (ADC_REG_TRIG_SOFTWARE)) ? 1UL : 0UL) + +/** + * @brief Set ADC group regular conversion trigger polarity. + * @note Applicable only for trigger source set to external trigger. + * ADC must be disabled or enabled without conversion on going + * on group regular. + * @param Instance ADC instance + * @param ExternalTriggerEdge This parameter can be one of the following values: + * @arg @ref ADC_REG_TRIG_EXT_RISING + * @arg @ref ADC_REG_TRIG_EXT_FALLING + * @arg @ref ADC_REG_TRIG_EXT_RISINGFALLING + * @retval None + */ +#define __LL_ADC_REG_SetTriggerEdge(__INSTANCE__, __EXIT_EDGE__) MODIFY_REG((__INSTANCE__)->LR, ADC_LR_EXTEN, (__EXIT_EDGE__)) + +/** + * @brief Get ADC group regular conversion trigger polarity. + * @note Applicable only for trigger source set to external trigger. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_REG_TRIG_EXT_RISING + * @arg @ref ADC_REG_TRIG_EXT_FALLING + * @arg @ref ADC_REG_TRIG_EXT_RISINGFALLING + */ +#define __LL_ADC_REG_GetTriggerEdge(__INSTANCE__) READ_BIT((__INSTANCE__)->LR, ADC_LR_EXTEN) + +/** + * @brief Set ADC group regular sequencer length. + * @note Description of ADC group regular sequencer features: + * - For devices with sequencer fully configurable + * sequencer length and each rank affectation to a channel + * are configurable. + * This function performs configuration of: + * - Sequence length: Number of ranks in the scan sequence. + * @note Sequencer length value 0 is equivalent to sequencer of 1 rank: + * ADC conversion on only 1 channel. + * @param Instance ADC instance + * @param SequencerNbRanks This parameter can be one of the following values: + * @arg @ref ADC_REG_SEQ_ENABLE_1 + * @arg @ref ADC_REG_SEQ_ENABLE_2 + * @arg @ref ADC_REG_SEQ_ENABLE_3 + * @arg @ref ADC_REG_SEQ_ENABLE_4 + * @arg @ref ADC_REG_SEQ_ENABLE_5 + * @arg @ref ADC_REG_SEQ_ENABLE_6 + * @arg @ref ADC_REG_SEQ_ENABLE_7 + * @arg @ref ADC_REG_SEQ_ENABLE_8 + * @arg @ref ADC_REG_SEQ_ENABLE_9 + * @arg @ref ADC_REG_SEQ_ENABLE_10 + * @arg @ref ADC_REG_SEQ_ENABLE_11 + * @arg @ref ADC_REG_SEQ_ENABLE_12 + * @arg @ref ADC_REG_SEQ_ENABLE_13 + * @arg @ref ADC_REG_SEQ_ENABLE_14 + * @arg @ref ADC_REG_SEQ_ENABLE_15 + * @arg @ref ADC_REG_SEQ_ENABLE_16 + * @retval None + */ +#define __LL_ADC_REG_SetSequencerLength(__INSTANCE__, __SEQUENCERANKS__) \ + MODIFY_REG((__INSTANCE__)->LR, ADC_LR_LEN, (__SEQUENCERANKS__)) + +/** + * @brief Get ADC group regular sequencer length. + * @note Description of ADC group regular sequencer features: + * - For devices with sequencer fully configurable + * sequencer length and each rank affectation to a channel + * are configurable. + * This function retrieves: + * - Sequence length: Number of ranks in the scan sequence. + * @note Sequencer length value 0 is equivalent to sequencer of 1 rank: + * ADC conversion on only 1 channel. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_REG_SEQ_ENABLE_1 + * @arg @ref ADC_REG_SEQ_ENABLE_2 + * @arg @ref ADC_REG_SEQ_ENABLE_3 + * @arg @ref ADC_REG_SEQ_ENABLE_4 + * @arg @ref ADC_REG_SEQ_ENABLE_5 + * @arg @ref ADC_REG_SEQ_ENABLE_6 + * @arg @ref ADC_REG_SEQ_ENABLE_7 + * @arg @ref ADC_REG_SEQ_ENABLE_8 + * @arg @ref ADC_REG_SEQ_ENABLE_9 + * @arg @ref ADC_REG_SEQ_ENABLE_10 + * @arg @ref ADC_REG_SEQ_ENABLE_11 + * @arg @ref ADC_REG_SEQ_ENABLE_12 + * @arg @ref ADC_REG_SEQ_ENABLE_13 + * @arg @ref ADC_REG_SEQ_ENABLE_14 + * @arg @ref ADC_REG_SEQ_ENABLE_15 + * @arg @ref ADC_REG_SEQ_ENABLE_16 + */ +#define __LL_ADC_REG_GetSequencerLength(__INSTANCE__) READ_BIT((__INSTANCE__)->LR, ADC_LR_LEN) + +/** + * @brief Set ADC group regular sequencer discontinuous mode: + * sequence subdivided and conversions interrupted every selected + * number of ranks. + * @note It is not possible to enable both ADC group regular + * continuous mode and sequencer discontinuous mode. + * @note It is not possible to enable both ADC auto-injected mode + * and ADC group regular sequencer discontinuous mode. + * ADC must be disabled or enabled without conversion on going + * on group regular. + * @param Instance ADC instance + * @param SeqDiscont This parameter can be one of the following values: + * @arg @ref ADC_REG_SEQ_DISCON_DISABLE + * @arg @ref ADC_REG_SEQ_DISNUM_1 + * @arg @ref ADC_REG_SEQ_DISNUM_2 + * @arg @ref ADC_REG_SEQ_DISNUM_3 + * @arg @ref ADC_REG_SEQ_DISNUM_4 + * @arg @ref ADC_REG_SEQ_DISNUM_5 + * @arg @ref ADC_REG_SEQ_DISNUM_6 + * @arg @ref ADC_REG_SEQ_DISNUM_7 + * @arg @ref ADC_REG_SEQ_DISNUM_8 + * @retval None + */ +#define __LL_ADC_REG_SetSequencerDiscont(__INSTANCE__, __SEQDISCONT__) \ + MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, (__SEQDISCONT__)) + +/** + * @brief Get ADC group regular sequencer discontinuous mode: + * sequence subdivided and scan conversions interrupted every selected + * number of ranks. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_REG_SEQ_DISCONT_DISABLE + * @arg @ref ADC_REG_SEQ_DISCONT_1 + * @arg @ref ADC_REG_SEQ_DISCONT_2 + * @arg @ref ADC_REG_SEQ_DISCONT_3 + * @arg @ref ADC_REG_SEQ_DISCONT_4 + * @arg @ref ADC_REG_SEQ_DISCONT_5 + * @arg @ref ADC_REG_SEQ_DISCONT_6 + * @arg @ref ADC_REG_SEQ_DISCONT_7 + * @arg @ref ADC_REG_SEQ_DISCONT_8 + */ +#define __LL_ADC_REG_GetSequencerDiscont(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM) + +/** + * @brief Set ADC group regular sequence: channel on the selected + * scan sequence rank. + * @note This function performs configuration of: + * - Channels ordering into each rank of scan sequence: + * whatever channel can be placed into whatever rank. + * @note ADC group regular sequencer is fully configurable: sequencer length and each rank + * affectation to a channel are configurable. + * Refer to description of function @ref LL_ADC_REG_SetSequencerLength(). + * @param Instance ADC instance + * @param Rank This parameter can be one of the following values: + * @arg @ref ADC_REG_RANK_1 + * @arg @ref ADC_REG_RANK_2 + * @arg @ref ADC_REG_RANK_3 + * @arg @ref ADC_REG_RANK_4 + * @arg @ref ADC_REG_RANK_5 + * @arg @ref ADC_REG_RANK_6 + * @arg @ref ADC_REG_RANK_7 + * @arg @ref ADC_REG_RANK_8 + * @arg @ref ADC_REG_RANK_9 + * @arg @ref ADC_REG_RANK_10 + * @arg @ref ADC_REG_RANK_11 + * @arg @ref ADC_REG_RANK_12 + * @arg @ref ADC_REG_RANK_13 + * @arg @ref ADC_REG_RANK_14 + * @arg @ref ADC_REG_RANK_15 + * @arg @ref ADC_REG_RANK_16 + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @retval None + */ +#define __LL_ADC_REG_SetSequencerRanks(__INSTANCE__, __RANK__, __CHANNEL__) \ + (__RANK__) > 7 ? \ + MODIFY_REG((__INSTANCE__)->SQR1, ADC_SQR1_SQ9 << ((__RANK__ - 8) << ADC_SMPRX_REGOFFSET), \ + ((__CHANNEL__) << ((__RANK__ - 8) << ADC_SMPRX_REGOFFSET))) : \ + MODIFY_REG((__INSTANCE__)->SQR0, ADC_SQR0_SQ1 << ((__RANK__) << ADC_SMPRX_REGOFFSET), \ + ((__CHANNEL__) << ((__RANK__) << ADC_SMPRX_REGOFFSET))) + +/** + * @brief Get ADC group regular sequence: channel on the selected + * scan sequence rank. + * @note ADC group regular sequencer is fully configurable: sequencer length and each rank + * affectation to a channel are configurable. + * Refer to description of function @ref LL_ADC_REG_SetSequencerLength(). + * @param Instance ADC instance + * @param Rank This parameter can be one of the following values: + * @arg @ref ADC_REG_RANK_1 + * @arg @ref ADC_REG_RANK_2 + * @arg @ref ADC_REG_RANK_3 + * @arg @ref ADC_REG_RANK_4 + * @arg @ref ADC_REG_RANK_5 + * @arg @ref ADC_REG_RANK_6 + * @arg @ref ADC_REG_RANK_7 + * @arg @ref ADC_REG_RANK_8 + * @arg @ref ADC_REG_RANK_9 + * @arg @ref ADC_REG_RANK_10 + * @arg @ref ADC_REG_RANK_11 + * @arg @ref ADC_REG_RANK_12 + * @arg @ref ADC_REG_RANK_13 + * @arg @ref ADC_REG_RANK_14 + * @arg @ref ADC_REG_RANK_15 + * @arg @ref ADC_REG_RANK_16 + * @retval Returned value can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + */ +#define __LL_ADC_REG_GetSequencerRanks(__INSTANCE__, __RANK__) \ + (__RANK__) > 7 ? \ + (READ_BIT((__INSTANCE__)->SQR1, ADC_SQR1_SQ9 << ((__RANK__ - 8) << ADC_SMPRX_REGOFFSET))) : \ + (READ_BIT((__INSTANCE__)->SQR0, ADC_SQR0_SQ1 << ((__RANK__) << ADC_SMPRX_REGOFFSET))) + +/** + * @brief Set ADC continuous conversion mode on ADC group regular. + * @note Description of ADC continuous conversion mode: + * - single mode: one conversion per trigger + * - continuous mode: after the first trigger, following + * conversions launched successively automatically. + * @note It is not possible to enable both ADC group regular + * continuous mode and sequencer discontinuous mode. + * @param Instance ADC instance + * @param Continuous This parameter can be one of the following values: + * @arg @ref ADC_REG_CONV_SINGLE + * @arg @ref ADC_REG_CONV_CONTINUOUS + * @retval None + */ +#define __LL_ADC_REG_SetContinuousMode(__INSTANCE__, __COUNT__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_CONT, (__COUNT__)) + +/** + * @brief Get ADC continuous conversion mode on ADC group regular. + * @note Description of ADC continuous conversion mode: + * - single mode: one conversion per trigger + * - continuous mode: after the first trigger, following + * conversions launched successively automatically. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_REG_CONV_SINGLE + * @arg @ref ADC_REG_CONV_CONTINUOUS + */ +#define __LL_ADC_REG_GetContinuousMode(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_CONT) + +/** + * @brief Set ADC group regular conversion data transfer: no transfer or + * transfer by DMA. + * @note If transfer by DMA selected, This ADC mode is intended to be used with DMA mode circular. + * @note If ADC DMA is set to single and DMA is set to mode non-circular: + * when DMA transfers size will be reached, DMA will stop transfers of + * ADC conversions data ADC will raise an overrun error + * (overrun flag and interruption if enabled). + * ADC must be disabled or enabled without conversion on going + * on either groups regular. + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @param DMATransfer This parameter can be one of the following values: + * @arg @ref ADC_REG_DMA_TRANSFER_SINGLE + * @arg @ref ADC_REG_DMA_TRANSFER_CIRCLE + * @retval None + */ +#define __LL_ADC_REG_SetDMATransfer(__INSTANCE__, __CHANNLE__, __DMAMODE__) \ + MODIFY_REG((__INSTANCE__)->DMA_CR[__CHANNLE__].TCR, ADC_DMA_TCR_CIRC | ADC_DMA_TCR_START, (__DMAMODE__)) + +/** + * @brief Get ADC group regular conversion data transfer: no transfer or + * transfer by DMA. + * @note If transfer by DMA selected: + * This ADC mode is intended to be used with DMA mode circular. + * @note If ADC DMA is set to single and DMA is set to mode non-circular: + * when DMA transfers size will be reached, DMA will stop transfers of + * ADC conversions data ADC will raise an overrun error + * (overrun flag and interruption if enabled). + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @retval Returned value can be one of the following values: + * @arg @ref ADC_REG_DMA_TRANSFER_SINGLE + * @arg @ref ADC_REG_DMA_TRANSFER_CIRCLE + */ +#define __LL_ADC_REG_GetDMATransfer(__INSTANCE__, __CHANNLE__) \ + READ_BIT((__INSTANCE__)->DMA_CR[__CHANNLE__].TCR, ADC_DMA_TCR_CIRC | ADC_DMA_TCR_START) + +/** + * @brief Set the DMA transfer address. + * @note If transfer by DMA selected: + * This ADC mode is intended to be used with DMA mode circular. + * @note If ADC DMA is set to single and DMA is set to mode non-circular: + * when DMA transfers size will be reached, DMA will stop transfers of + * ADC conversions data ADC will raise an overrun error + * (overrun flag and interruption if enabled). + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @param Address dma transfer buffer addresss + * @retval None + */ +#define __LL_ADC_REG_SetDMAAddr(__INSTANCE__, __CHANNLE__, __ADDR__) \ + MODIFY_REG((__INSTANCE__)->DMA_CR[__CHANNLE__].TAR, ADC_DMA_TAR_ADDR, (__ADDR__)) + +/** + * @brief Set the DMA transfer length + * @param __INSTANCE__ Special ADC Peripheral + * @param __CHANNLE__ ADC Channel + * @param __LENGTH__ dma transfer length + * @return None + */ +#define __LL_ADC_REG_SetDMALength(__INSTANCE__, __CHANNLE__, __LENGTH__) \ + MODIFY_REG((__INSTANCE__)->DMA_CR[__CHANNLE__].TLR, ADC_DMA_TLR_LENG, (__LENGTH__)) + +/** + * @brief Set ADC group regular behavior in case of overrun: + * data preserved or overwritten. + * @note Compatibility with devices without feature overrun: + * other devices without this feature have a behavior + * equivalent to data overwritten. + * The default setting of overrun is data preserved. + * ADC must be disabled or enabled without conversion on going + * on group regular. + * @param Instance ADC instance + * @param Overrun This parameter can be one of the following values: + * @arg @ref ADC_REG_OVR_DATA_PRESERVED + * @arg @ref ADC_REG_OVR_DATA_OVERWRITTEN + * @retval None + */ +#define __LL_ADC_REG_SetOverrun(__INSTANCE__, __OVRRUN__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_OVRMOD, (__OVRRUN__)) + +/** + * @brief Get ADC group regular behavior in case of overrun: + * data preserved or overwritten. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_REG_OVR_DATA_PRESERVED + * @arg @ref ADC_REG_OVR_DATA_OVERWRITTEN + */ +#define __LL_ADC_REG_GetOverrun(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_OVRMOD) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected + * @{ + */ +/** + * @brief Set ADC group injected conversion trigger source: + * internal (SW start) or from external peripheral (timer event, + * external interrupt line). + * @note setting trigger source to external trigger also set trigger polarity to rising edge + * ADC must not be disabled. Can be enabled with or without conversion + * on going on either groups regular or injected. + * @param Instance ADC instance + * @param TriggerSource This parameter can be one of the following values: + * @arg @ref ADC_INJ_TRIG_SOFTWARE + * @arg @ref ADC_INJ_TRIG_EXT_TIM0_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM1_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM2_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM3_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM4_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM5_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM6_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM7_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM0_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM1_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM2_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM3_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM4_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM5_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM6_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM7_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG0 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG1 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG2 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG3 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG4 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG5 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG6 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG7 + * @arg @ref ADC_INJ_TRIG_EXT_PIN + * @retval None + */ +#define __LL_ADC_INJ_SetTriggerSource(__INSTANCE__, __TRIGSRC__) \ + MODIFY_REG((__INSTANCE__)->JLR, ADC_JLR_JEXTSEL | ADC_JLR_JEXTEN, (__TRIGSRC__)) + +/** + * @brief Get ADC group injected conversion trigger source: + * internal (SW start) or from external peripheral (timer event, + * external interrupt line). + * @note To determine whether group injected trigger source is + * internal (SW start) or external, without detail + * of which peripheral is selected as external trigger, + * @note setting trigger source to external trigger also set trigger polarity to rising edge + * ADC must not be disabled. Can be enabled with or without conversion + * on going on either groups regular or injected. + * @param Instance ADC instance + * @param TriggerSource This parameter can be one of the following values: + * @arg @ref ADC_INJ_TRIG_SOFTWARE + * @arg @ref ADC_INJ_TRIG_EXT_TIM0_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM1_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM2_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM3_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM4_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM5_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM6_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM7_CC + * @arg @ref ADC_INJ_TRIG_EXT_TIM0_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM1_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM2_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM3_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM4_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM5_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM6_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_TIM7_TRGO + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG0 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG1 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG2 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG3 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG4 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG5 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG6 + * @arg @ref ADC_INJ_TRIG_EXT_HRPWM_ADC_TRG7 + * @arg @ref ADC_INJ_TRIG_EXT_PIN + * @retval None + */ +#define __LL_ADC_INJ_GetTriggerSource(__INSTANCE__) READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JEXTSEL) + +/** + * @brief Get ADC group injected conversion trigger source internal (SW start) + or external + * @note In case of group injected trigger source set to external trigger, + * to determine which peripheral is selected as external trigger, + * use function @ref LL_ADC_INJ_GetTriggerSource. + * @param Instance ADC instance + * @retval Value "0" if trigger source external trigger + * Value "1" if trigger source SW start. + */ +#define __LL_ADC_INJ_IsTriggerSourceSWStart(__INSTANCE__) \ + ((READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JEXTEN) == (ADC_INJ_TRIG_SOFTWARE & ADC_JLR_JEXTEN)) ? 1UL : 0UL) + +/** + * @brief Set ADC group injected conversion trigger polarity. + * Applicable only for trigger source set to external trigger. + * ADC must not be disabled. Can be enabled with or without conversion + * on going on either groups regular or injected. + * @param Instance ADC instance + * @param ExternalTriggerEdge This parameter can be one of the following values: + * @arg @ref ADC_INJ_TRIG_EXT_RISING + * @arg @ref ADC_INJ_TRIG_EXT_FALLING + * @arg @ref ADC_INJ_TRIG_EXT_RISINGFALLING + * @retval None + */ +#define __LL_ADC_INJ_SetTriggerEdge(__INSTANCE__, __TRIG_EDGE__) \ + MODIFY_REG((__INSTANCE__)->JLR, ADC_JLR_JEXTEN, (__TRIG_EDGE__)) + +/** + * @brief Get ADC group injected conversion trigger polarity. + * Applicable only for trigger source set to external trigger. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_INJ_TRIG_EXT_RISING + * @arg @ref ADC_INJ_TRIG_EXT_FALLING + * @arg @ref ADC_INJ_TRIG_EXT_RISINGFALLING + */ +#define __LL_ADC_INJ_GetTriggerEdge(__INSTANCE__) READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JEXTEN) + +/** + * @brief Set ADC group injected sequencer length. + * @note This function performs configuration of: + * - Sequence length: Number of ranks in the scan sequence. + * ADC must not be disabled. Can be enabled with or without conversion + * on going on either groups regular or injected. + * @param Instance ADC instance + * @param SequencerNbRanks This parameter can be one of the following values: + * @arg @ref ADC_INJ_SEQ_LENGTH_1 + * @arg @ref ADC_INJ_SEQ_LENGTH_2 + * @arg @ref ADC_INJ_SEQ_LENGTH_3 + * @arg @ref ADC_INJ_SEQ_LENGTH_4 + * @retval None + */ +#define __LL_ADC_INJ_SetSequencerLength(__INSTANCE__, __SEQUENCERANK__) \ + MODIFY_REG((__INSTANCE__)->JLR, ADC_JLR_JLEN, (__SEQUENCERANK__)) + +/** + * @brief Get ADC group injected sequencer length and scan direction. + * @note This function retrieves: + * - Sequence length: Number of ranks in the scan sequence. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_INJ_SEQ_LENGTH_1 + * @arg @ref ADC_INJ_SEQ_LENGTH_2 + * @arg @ref ADC_INJ_SEQ_LENGTH_3 + * @arg @ref ADC_INJ_SEQ_LENGTH_4 + */ +#define __LL_ADC_INJ_GetSequencerLength(__INSTANCE__) READ_BIT((__INSTANCE__)->JLR, ADC_JLR_JLEN) + +/** + * @brief Set ADC group injected sequencer discontinuous mode: + * sequence subdivided and scan conversions interrupted every selected + * number of ranks. + * @note It is not possible to enable both ADC group injected + * auto-injected mode and sequencer discontinuous mode. + * @param Instance ADC instance + * @param SeqDiscont This parameter can be one of the following values: + * @arg @ref ADC_INJ_SEQ_DISCONT_DISABLE + * @arg @ref ADC_INJ_SEQ_DISCONT_ENABLE + * @retval None + */ +#define __LL_ADC_INJ_SetSequencerDiscont(__INSTANCE__, __SEQDISCONT__) \ + MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_JDISCEN, (__SEQDISCONT__)) + +/** + * @brief Get ADC group injected sequencer discontinuous mode: + * sequence subdivided and scan conversions interrupted every selected + * number of ranks. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_INJ_SEQ_DISCONT_DISABLE + * @arg @ref ADC_INJ_SEQ_DISCONT_ENABLE + */ +#define __LL_ADC_INJ_GetSequencerDiscont(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_JDISCEN) + +/** + * @brief Set ADC group injected sequence: channel on the selected + * sequence rank. + * @note Depending on devices and packages, some channels may not be available. + * @note setting of this feature is conditioned to ADC state: + * ADC must not be disabled. Can be enabled with or without conversion + * on going on either groups injected. + * @param Instance ADC instance + * @param Rank Position This parameter can be one of the following values: + * @arg @ref ADC_INJ_RANK_1 + * @arg @ref ADC_INJ_RANK_2 + * @arg @ref ADC_INJ_RANK_3 + * @arg @ref ADC_INJ_RANK_4 + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @retval None + */ +#define __LL_ADC_INJ_SetSequencerRanks(__INSTANCE__, __RANK__, __CHANNEL__) \ + MODIFY_REG((__INSTANCE__)->JSQR, (ADC_JSQR_JSQ1 << (__RANK__)), (__CHANNEL__) << (__RANK__)) + +/** + * @brief Get ADC group injected sequence: channel on the selected + * sequence rank. + * @note Depending on devices and packages, some channels may not be available. + * Refer to device datasheet for channels availability. + * @note setting of this feature is conditioned to ADC state: + * ADC must not be disabled. Can be enabled with or without conversion + * on going on either groups regular or injected. + * @param Instance ADC instance + * @param Rank This parameter can be one of the following values: + * @arg @ref ADC_INJ_RANK_1 + * @arg @ref ADC_INJ_RANK_2 + * @arg @ref ADC_INJ_RANK_3 + * @arg @ref ADC_INJ_RANK_4 + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @retval None + */ +#define __LL_ADC_INJ_GetSequencerRanks(__INSTANCE__, __RANK__) READ_BIT((__INSTANCE__)->JSQR, (ADC_JSQR_JSQ1 << (__RANK__))) + +/** + * @brief Set ADC group injected conversion trigger: + * independent or from ADC group regular. + * @note This mode can be used to extend number of data registers + * updated after one ADC conversion trigger and with data + * permanently kept , up to 5 data registers: + * 1 data register on ADC group regular, 4 data registers + * on ADC group injected. + * @note If ADC group injected injected trigger source is set to an + * external trigger, this feature must be must be set to + * independent trigger. + * ADC group injected automatic trigger is compliant only with + * group injected trigger source set to SW start, without any + * further action on ADC group injected conversion start or stop: + * @note It is not possible to enable both ADC group injected + * auto-injected mode and sequencer discontinuous mode. + * ADC must be disabled or enabled without conversion on going + * on either groups regular or injected. + * @param Instance ADC instance + * @param TrigAuto This parameter can be one of the following values: + * @arg @ref ADC_INJ_TRIG_INDEPENDENT + * @arg @ref ADC_INJ_TRIG_FROM_GRP_REGULAR + * @retval None + */ +#define __LL_ADC_INJ_SetTrigAuto(__INSTANCE__, __TRIGAUTO__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_JAUTO, (__TRIGAUTO__)) + +/** + * @brief Get ADC group injected conversion trigger: + * independent or from ADC group regular. + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_INJ_TRIG_INDEPENDENT + * @arg @ref ADC_INJ_TRIG_FROM_GRP_REGULAR + */ +#define __LL_ADC_INJ_GetTrigAuto(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_JAUTO) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_Configuration_Channels Configuration of ADC hierarchical scope: channels + * @{ + */ +/** + * @brief Set sampling time of the selected ADC channel Unit: ADC clock cycles. + * @note On this device, sampling time is on channel scope: independently + * of channel mapped on ADC group regular or injected. + * @note sampling time constraints must be respected (sampling time can be + * adjusted in function of ADC clock frequency and sampling time + * setting). + * @note Conversion time is the addition of sampling time and processing time. + * ADC processing time is: 12.5 ADC clock cycles at ADC resolution 12 bits + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @param SamplingTime This parameter can be one of the following values: + * @arg @ref ADC_SAMPLINGTIME_6CYCLES + * @arg @ref ADC_SAMPLINGTIME_18CYCLES + * @arg @ref ADC_SAMPLINGTIME_42CYCLES + * @arg @ref ADC_SAMPLINGTIME_90CYCLES + * @arg @ref ADC_SAMPLINGTIME_186CYCLES + * @arg @ref ADC_SAMPLINGTIME_378CYCLES + * @arg @ref ADC_SAMPLINGTIME_762CYCLES + * @arg @ref ADC_SAMPLINGTIME_1530CYCLES + * @retval None + */ + +#define __LL_ADC_SetChannelSamplingTime(__INSTANCE__, __CHANNEL__, __SAMPTIME__) \ + (__CHANNEL__ > 7) ? \ + MODIFY_REG((__INSTANCE__)->SMPR1, ADC_SMPR1_SMP8 << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET), \ + ((__SAMPTIME__) << ((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET))) : \ + MODIFY_REG((__INSTANCE__)->SMPR0, ADC_SMPR0_SMP0 << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET), \ + ((__SAMPTIME__) << ((__CHANNEL__) << ADC_SMPRX_REGOFFSET))) + +/** + * @brief Get sampling time of the selected ADC channel Unit: ADC clock cycles. + * @note sampling time is on channel scope: independently + * of channel mapped on ADC group regular or injected. + * @note Conversion time is the addition of sampling time and processing time. + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @param SamplingTime This parameter can be one of the following values: + * @arg @ref ADC_SAMPLINGTIME_6CYCLES + * @arg @ref ADC_SAMPLINGTIME_18CYCLES + * @arg @ref ADC_SAMPLINGTIME_42CYCLES + * @arg @ref ADC_SAMPLINGTIME_90CYCLES + * @arg @ref ADC_SAMPLINGTIME_186CYCLES + * @arg @ref ADC_SAMPLINGTIME_378CYCLES + * @arg @ref ADC_SAMPLINGTIME_762CYCLES + * @arg @ref ADC_SAMPLINGTIME_1530CYCLES + */ +#define __LL_ADC_GetChannelSamplingTime(__INSTANCE__, __CHANNEL__) (__CHANNEL__ > 7) ? \ + (READ_BIT((__INSTANCE__)->SMPR1, ADC_SMPR1_SMP8 << (((__CHANNEL__ - 8) << ADC_SMPRX_REGOFFSET)))) : \ + (READ_BIT((__INSTANCE__)->SMPR0, ADC_SMPR0_SMP0 << (((__INSTANCE__) << ADC_SMPRX_REGOFFSET)))) + + +/** + * @brief Set mode single-ended or differential input of the selected + * ADC channel. + * In differential mode: Differential measurement is carried out + * between the selected channel 'i' (positive input) and + * channel 'i+1' (negative input). Only channel 'i' has to be + * configured, channel 'i+1' is configured automatically. + * @note For example, internal channels (VrefInt, TempSensor, ...) are + * not available in differential mode. + * @note When configuring a channel 'i' in differential mode, + * the channel 'i+1' is not usable separately.refer to device datasheet + * for more details. + * @note For ADC channels configured in differential mode, both inputs + * should be biased at (Vref+)/2 +/-200mV. + * (Vref+ is the analog voltage reference) + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @param SingleDiff This parameter can be a combination of the following values: + * @arg @ref LL_ADC_SINGLE_ENDED + * @arg @ref LL_ADC_DIFFERENTIAL_ENDED + * @retval None + */ +#define __LL_ADC_SetChannelSingleDiff(__INSTANCE__, __CHANNEL__, __SINGLEDIFF__) \ + MODIFY_REG((__INSTANCE__)->DIFSEL, \ + ADC_SINGLEDIFF_CHANNEL_SHIFT << (__CHANNEL__), \ + (((__SINGLEDIFF__) & ADC_SINGLEDIFF_CHANNEL_SHIFT) << (__CHANNEL__))) + +/** + * @brief Get mode single-ended or differential input of the selected + * ADC channel. + * In differential mode: Differential measurement is carried out + * between the selected channel 'i' (positive input) and + * channel 'i+1' (negative input). Only channel 'i' has to be + * configured, channel 'i+1' is configured automatically. + * @note For example, internal channels (VrefInt, TempSensor, ...) are + * not available in differential mode. + * @note When configuring a channel 'i' in differential mode, + * the channel 'i+1' is not usable separately.refer to device datasheet + * for more details. + * @note For ADC channels configured in differential mode, both inputs + * should be biased at (Vref+)/2 +/-200mV. + * (Vref+ is the analog voltage reference) + * @param Instance ADC instance + * @param Channel This parameter can be one of the following values: + * @arg @ref ADC_CHANNEL_0 + * @arg @ref ADC_CHANNEL_1 + * @arg @ref ADC_CHANNEL_2 + * @arg @ref ADC_CHANNEL_3 + * @arg @ref ADC_CHANNEL_4 + * @arg @ref ADC_CHANNEL_5 + * @arg @ref ADC_CHANNEL_6 + * @arg @ref ADC_CHANNEL_7 + * @arg @ref ADC_CHANNEL_8 + * @arg @ref ADC_CHANNEL_9 + * @arg @ref ADC_CHANNEL_10 + * @arg @ref ADC_CHANNEL_TEMPSENSOR + * @retval SingleDiff This parameter can be a combination of the following values: + * @arg @ref LL_ADC_SINGLE_ENDED + * @arg @ref LL_ADC_DIFFERENTIAL_ENDED + */ +#define __LL_ADC_GetChannelSingleDiff(__INSTANCE__, __CHANNEL__) \ + ((READ_BIT((__INSTANCE__)->DIFSEL, ADC_SINGLEDIFF_CHANNEL_SHIFT << (__CHANNEL__)) == \ + (ADC_SINGLEDIFF_CHANNEL_SHIFT << (__CHANNEL__))) ? 0x1U : 0x0U) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog + * @{ + */ +/** + * @brief Set ADC analog watchdog monitored channels: + * a single channel, multiple channels or all channels, + * @note Once monitored channels are selected, analog watchdog + * is enabled. + * @note In case of need to define a single channel to monitor + * with analog watchdog from sequencer channel definition, + * @note Analog watchdog instance: + * - AWD standard (instance AWD0\1\2): + * - channels monitored: can monitor 1 channel or all channels. + * ADC must be disabled or enabled without conversion on going + * on either groups regular or injected. + * @param Instance ADC instance + * @param AWDy This parameter can be one of the following values: + * @arg @ref ADC_AWD0 + * @arg @ref ADC_AWD1 + * @arg @ref ADC_AWD2 + * @param AWDChannelGroup This parameter can combination of the following values: + * @arg @ref ADC_AWD_DISABLE + * @arg @ref ADC_AWD_ALL_CHANNELS + * @arg @ref ADC_AWD_CHANNEL_0 + * @arg @ref ADC_AWD_CHANNEL_1 + * @arg @ref ADC_AWD_CHANNEL_2 + * @arg @ref ADC_AWD_CHANNEL_3 + * @arg @ref ADC_AWD_CHANNEL_4 + * @arg @ref ADC_AWD_CHANNEL_5 + * @arg @ref ADC_AWD_CHANNEL_6 + * @arg @ref ADC_AWD_CHANNEL_7 + * @arg @ref ADC_AWD_CHANNEL_8 + * @arg @ref ADC_AWD_CHANNEL_9 + * @arg @ref ADC_AWD_CHANNEL_10 + * @arg @ref ADC_AWD_CHANNEL_11 + * @retval None + */ +#define __LL_ADC_SetAnalogWDMonitChannels(__INSTANCE__, __AWDY__, __AWDCHANNEL__) \ + MODIFY_REG((__INSTANCE__)->AWDCR[__AWDY__], ADC_AWD0CR_AWD0CH, __AWDCHANNEL__) + +/** + * @brief Get ADC analog watchdog monitored channel. + * @note Usage of the returned channel number: + * @note Once monitored channels are selected, analog watchdog is enabled. + * @note In case of need to define a single channel to monitor + * with analog watchdog from sequencer channel definition, + * @param Instance ADC instance + * @param AWDy This parameter can be one of the following values: + * @arg @ref ADC_AWD0 + * @arg @ref ADC_AWD1 + * @arg @ref ADC_AWD2 + * @retval Returned value can be one of the following values: + * @arg @ref ADC_AWD_DISABLE + * @arg @ref ADC_AWD_ALL_CHANNELS + * @arg @ref ADC_AWD_CHANNEL_0 + * @arg @ref ADC_AWD_CHANNEL_1 + * @arg @ref ADC_AWD_CHANNEL_2 + * @arg @ref ADC_AWD_CHANNEL_3 + * @arg @ref ADC_AWD_CHANNEL_4 + * @arg @ref ADC_AWD_CHANNEL_5 + * @arg @ref ADC_AWD_CHANNEL_6 + * @arg @ref ADC_AWD_CHANNEL_7 + * @arg @ref ADC_AWD_CHANNEL_8 + * @arg @ref ADC_AWD_CHANNEL_9 + * @arg @ref ADC_AWD_CHANNEL_10 + * @arg @ref ADC_AWD_CHANNEL_11 + */ +#define __LL_ADC_GetAnalogWDMonitChannels(__INSTANCE__, __AWDY__) \ + READ_BIT((Instance->AWDCR[AWDy]), ADC_AWD0CR_AWD0CH & ADC_AWD_ALL_CHANNELS) + +/** + * @brief Set ADC analog watchdog thresholds value of both thresholds + * high and low. + * @note If value of only one threshold high or low must be set, + * use function @ref LL_ADC_SetAnalogWDThresholds(). + * @note In case of ADC resolution different of 16 bits. + * @note Analog watchdog instance: + * - AWD standard (instance AWD0\1\2): + * - channels monitored: can monitor 1 channel or all channels. + * - groups monitored: ADC groups regular and-or injected. + * @note ADC data register bitfield [15:0] (16 most significant bits). + * @param Instance ADC instance + * @param AWDy This parameter can be one of the following values: + * @arg @ref ADC_AWD0 + * @arg @ref ADC_AWD1 + * @arg @ref ADC_AWD2 + * @param AWDThresholdHighValue Value between Min_Data=0x0000 and Max_Data=0xFFFF + * @param AWDThresholdLowValue Value between Min_Data=0x0000 and Max_Data=0xFFFF + * @retval None + */ +#define __LL_ADC_ConfigAnalogWDThresholds(__INSTANCE__, __AWDY__, __HIGHVALUE__, __LOWVALUE__) \ + WRITE_REG((__INSTANCE__)->TR[__AWDY__], ((__HIGHVALUE__) << ADC_AWD_THRESHOLDS_HIGH_POS) | (__LOWVALUE__)) + +/** + * @brief Set ADC analog watchdog threshold value of threshold + * high or low. + * @note If value of only one threshold high or low must be set, + * use function @ref LL_ADC_SetAnalogWDThresholds(). + * @note In case of ADC resolution different of 16 bits. + * @note Analog watchdog instance: + * - AWD standard (instance AWD0\1\2): + * - channels monitored: can monitor 1 channel or all channels. + * - groups monitored: ADC groups regular and-or injected. + * @note ADC data register bitfield [15:0] (16 most significant bits). + * @param Instance ADC instance + * @param AWDy This parameter can be one of the following values: + * @arg @ref ADC_AWD0 + * @arg @ref ADC_AWD1 + * @arg @ref ADC_AWD2 + * @param AWDThresholdsHighLow This parameter can be one of the following values: + * @arg @ref ADC_AWD_THRESHOLD_HIGH + * @arg @ref ADC_AWD_THRESHOLD_LOW + * @param AWDThresholdValue Value between Min_Data=0x0000 and Max_Data=0xFFFF + * @retval None + */ +#define __LL_ADC_SetAnalogWDThresholds(__INSTANCE__, __AWDY__, __SIGN__, __VALUE__) \ + MODIFY_REG((__INSTANCE__)->TR[__AWDY__], (__SIGN__), \ + ((((__VALUE__) << ADC_AWD_THRESHOLDS_HIGH_POS) | (__VALUE__)) & __SIGN__)) + +/** + * @brief Set ADC analog watchdog filtering configuration + * ADC must be disabled or enabled without conversion on going + * on either groups regular or injected. + * @param Instance ADC instance + * @param AWDy This parameter can be one of the following values: + * @arg @ref ADC_AWD0\1\2 + * @param FilteringConfig This parameter can be one of the following values: + * @arg @ref ADC_AWD_FILTERING_NONE + * @arg @ref ADC_AWD_FILTERING_2 + * @arg @ref ADC_AWD_FILTERING_3 + * @arg @ref ADC_AWD_FILTERING_4 + * @arg @ref ADC_AWD_FILTERING_5 + * @arg @ref ADC_AWD_FILTERING_6 + * @arg @ref ADC_AWD_FILTERING_7 + * @arg @ref ADC_AWD_FILTERING_8 + * @arg @ref ADC_AWD_FILTERING_9 + * @arg @ref ADC_AWD_FILTERING_10 + * @arg @ref ADC_AWD_FILTERING_11 + * @arg @ref ADC_AWD_FILTERING_12 + * @arg @ref ADC_AWD_FILTERING_13 + * @arg @ref ADC_AWD_FILTERING_14 + * @arg @ref ADC_AWD_FILTERING_15 + * @arg @ref ADC_AWD_FILTERING_16 + * @retval None + */ +#define __LL_ADC_SetAWDFilteringConfiguration(__INSTANCE__, __AWDY__, __AWDFILTER__) \ + MODIFY_REG((__INSTANCE__)->AWDCR[__AWDY__], ADC_AWD0CR_AWD0FILT, (__AWDFILTER__)) + +/** + * @brief Get ADC analog watchdog filtering configuration + * @note On this TMF5 serie, this feature is only available on first + * analog watchdog (AWD0\1\2) + * @param Instance ADC instance + * @param AWDy This parameter can be one of the following values: + * @arg @ref ADC_AWD0\1\2 + * @param FilteringConfig This parameter can be one of the following values: + * @arg @ref ADC_AWD_FILTERING_NONE + * @arg @ref ADC_AWD_FILTERING_2 + * @arg @ref ADC_AWD_FILTERING_3 + * @arg @ref ADC_AWD_FILTERING_4 + * @arg @ref ADC_AWD_FILTERING_5 + * @arg @ref ADC_AWD_FILTERING_6 + * @arg @ref ADC_AWD_FILTERING_7 + * @arg @ref ADC_AWD_FILTERING_8 + * @arg @ref ADC_AWD_FILTERING_9 + * @arg @ref ADC_AWD_FILTERING_10 + * @arg @ref ADC_AWD_FILTERING_11 + * @arg @ref ADC_AWD_FILTERING_12 + * @arg @ref ADC_AWD_FILTERING_13 + * @arg @ref ADC_AWD_FILTERING_14 + * @arg @ref ADC_AWD_FILTERING_15 + * @arg @ref ADC_AWD_FILTERING_16 + */ +#define __LL_ADC_GetAWDFilteringConfiguration(__INSTANCE__, __AWDY__) \ + READ_BIT((__INSTANCE__)->AWDCR[__AWDY__], ADC_AWD0CR_AWD0FILT) +/** + * @} + */ + + +/** @addtogroup ADC_LL_Configuration_ADC_oversampling Configuration of ADC transversal scope: oversampling + * @{ + */ +/** + * @brief Set ADC oversampling scope: ADC groups regular and-or injected. + * @note If both groups regular and injected are selected, + * specify behavior of ADC group injected interrupting + * group regular: when ADC group injected is triggered, + * the oversampling on ADC group regular is either + * temporary stopped and continued, or resumed from start + * (oversampler buffer reset). + * ADC must be disabled or enabled without conversion on going + * on either groups regular or injected. + * @param Instance ADC instance + * @param This parameter can be one of the following values: + * @arg @ref ADC_OVS_DISABLE + * @arg @ref ADC_OVS_GRP_REGULAR_CONTINUED + * @arg @ref ADC_OVS_GRP_REGULAR_RESUMED + * @arg @ref ADC_OVS_GRP_INJECTED + * @arg @ref ADC_OVS_GRP_INJ_REG_RESUMED + * @retval None + */ +#define __LL_ADC_SetOverSamplingScope(__INSTANCE__, __OVRSCOPE__) \ + MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_ROVSE | ADC_CR1_JOVSE | ADC_CR1_ROVSM, __OVRSCOPE__) + +/** + * @brief Get ADC oversampling scope: ADC groups regular and-or injected. + * @note If both groups regular and injected are selected, + * specify behavior of ADC group injected interrupting + * group regular: when ADC group injected is triggered, + * the oversampling on ADC group regular is either + * temporary stopped and continued, or resumed from start + * (oversampler buffer reset). + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_OVS_DISABLE + * @arg @ref ADC_OVS_GRP_REGULAR_CONTINUED + * @arg @ref ADC_OVS_GRP_REGULAR_RESUMED + * @arg @ref ADC_OVS_GRP_INJECTED + * @arg @ref ADC_OVS_GRP_INJ_REG_RESUMED + */ +#define __LL_ADC_GetOverSamplingScope(__INSTANCE__) \ + READ_BIT((__INSTANCE__)->CR1, ADC_CR1_ROVSE | ADC_CR1_JOVSE | ADC_CR1_ROVSM) + +/** + * @brief Set ADC oversampling discontinuous mode (triggered mode) + * on the selected ADC group. + * @note Number of oversampled conversions are done either in: + * - continuous mode (all conversions of oversampling ratio + * are done from 1 trigger) + * - discontinuous mode (each conversion of oversampling ratio + * needs a trigger) + * @note oversampling discontinuous mode (triggered mode) can be used only + * when oversampling is set on group regular only and in resumed mode. + * @param Instance ADC instance + * @param OverSamplingDiscont This parameter can be one of the following values: + * @arg @ref ADC_OVS_REG_CONT + * @arg @ref ADC_OVS_REG_DISCONT + * @retval None + */ +#define __LL_ADC_SetOverSamplingDiscont(__INSTANCE__, __TROVS__) MODIFY_REG((__INSTANCE__)->CR1, ADC_CR1_TROVS, (__TROVS__)) + +/** + * @brief Get ADC oversampling discontinuous mode (triggered mode) + * on the selected ADC group. + * @note Number of oversampled conversions are done either in: + * - continuous mode (all conversions of oversampling ratio + * are done from 1 trigger) + * - discontinuous mode (each conversion of oversampling ratio + * needs a trigger) + * @param Instance ADC instance + * @retval Returned value can be one of the following values: + * @arg @ref ADC_OVS_REG_CONT + * @arg @ref ADC_OVS_REG_DISCONT + */ +#define __LL_ADC_GetOverSamplingDiscont(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_TROVS) + +/** + * @brief Set ADC oversampling + * (impacting both ADC groups regular and injected) + * @note This function set the 2 items of oversampling configuration: + * - ratio + * - shift + * @param Instance ADC instance + * @param Ratio This parameter can be one of the following values: + * @arg @ref ADC_OVSR_RATIO_2 + * @arg @ref ADC_OVSR_RATIO_4 + * @arg @ref ADC_OVSR_RATIO_8 + * @arg @ref ADC_OVSR_RATIO_16 + * @arg @ref ADC_OVSR_RATIO_32 + * @arg @ref ADC_OVSR_RATIO_64 + * @arg @ref ADC_OVSR_RATIO_128 + * @arg @ref ADC_OVSR_RATIO_256 + * @param Shift This parameter can be one of the following values: + * @arg @ref ADC_OVSS_SHIFT_NONE + * @arg @ref ADC_OVSS_SHIFT_RIGHT_1 + * @arg @ref ADC_OVSS_SHIFT_RIGHT_2 + * @arg @ref ADC_OVSS_SHIFT_RIGHT_3 + * @arg @ref ADC_OVSS_SHIFT_RIGHT_4 + * @arg @ref ADC_OVSS_SHIFT_RIGHT_5 + * @arg @ref ADC_OVSS_SHIFT_RIGHT_6 + * @arg @ref ADC_OVSS_SHIFT_RIGHT_7 + * @arg @ref ADC_OVSS_SHIFT_RIGHT_8 + * @retval None + */ +#define __LL_ADC_ConfigOverSamplingRatioShift(__INSTANCE__, __RATIO__, __SHIFT__) \ + MODIFY_REG((__INSTANCE__)->CR1, (ADC_CR1_OVSS | ADC_CR1_OVSR), (__SHIFT__ | __RATIO__)) + +/** + * @brief Get ADC oversampling ratio + * (impacting both ADC groups regular and injected) + * @param Instance ADC instance + * @retval Ratio This parameter can be one of the following values: + * @arg @ref ADC_OVSR_RATIO_2 + * @arg @ref ADC_OVSR_RATIO_4 + * @arg @ref ADC_OVSR_RATIO_8 + * @arg @ref ADC_OVSR_RATIO_16 + * @arg @ref ADC_OVSR_RATIO_32 + * @arg @ref ADC_OVSR_RATIO_64 + * @arg @ref ADC_OVSR_RATIO_128 + * @arg @ref ADC_OVSR_RATIO_256 + */ +#define __LL_ADC_GetOverSamplingRatio(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_OVSR) + +/** + * @brief Get ADC oversampling shift + * (impacting both ADC groups regular and injected) + * @param Instance ADC instance + * @retval Shift This parameter can be one of the following values: + * @arg @ref ADC_OVS_SHIFT_NONE + * @arg @ref ADC_OVS_SHIFT_RIGHT_1 + * @arg @ref ADC_OVS_SHIFT_RIGHT_2 + * @arg @ref ADC_OVS_SHIFT_RIGHT_3 + * @arg @ref ADC_OVS_SHIFT_RIGHT_4 + * @arg @ref ADC_OVS_SHIFT_RIGHT_5 + * @arg @ref ADC_OVS_SHIFT_RIGHT_6 + * @arg @ref ADC_OVS_SHIFT_RIGHT_7 + * @arg @ref ADC_OVS_SHIFT_RIGHT_8 + */ +#define __LL_ADC_GetOverSamplingShift(__INSTANCE__) READ_BIT((__INSTANCE__)->CR1, ADC_CR1_OVSS) +/** + * @} + */ + + +/** @addtogroup ADC_LL_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected + * @{ + */ +/** + * @brief Start ADC group injected conversion. + * @note This function is relevant for both internal trigger (SW start) and external trigger: + * - If ADC trigger has been set to software start, ADC conversion + * starts immediately. + * - If ADC trigger has been set to external trigger, ADC conversion + * will start at next trigger event (on the selected trigger edge) + * following the ADC start conversion command. + * @note Setting of this feature is conditioned to ADC state: + * ADC must be enabled without conversion on going on group injected, + * without conversion stop command on going on group injected. + * @param Instance ADC instance + * @retval None + */ +#define __LL_ADC_INJ_StartConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_JADSTART) + +/** + * @brief Stop ADC group injected conversion. + * @note Setting of this feature is conditioned to ADC state: + * ADC must be enabled with conversion on going on group injected, + * without ADC disable command on going. + * @param Instance ADC instance + * @retval None + */ +#define __LL_ADC_INJ_StopConversion(__INSTANCE__) MODIFY_REG((__INSTANCE__)->CR0, ADC_CR0_BITS_PROPERTY_RS, ADC_CR0_JADSTP) + +/** + * @brief Get ADC group injected conversion state. + * @param Instance ADC instance + * @retval 0: no conversion is on going on ADC group injected. + */ +#define __LL_ADC_INJ_IsConversionOngoing(__INSTANCE__) \ + ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_JADSTART) == (ADC_CR0_JADSTART)) ? 1UL : 0UL) + +/** + * @brief Get ADC group injected command of conversion stop state + * @param Instance ADC instance + * @retval 0: no command of conversion stop is on going on ADC group injected. + */ +#define __LL_ADC_INJ_IsStopConversionOngoing(__INSTANCE__) \ + ((READ_BIT((__INSTANCE__)->CR0, ADC_CR0_JADSTP) == (ADC_CR0_JADSTP)) ? 1UL : 0UL) + +/** + * @brief Get ADC group injected conversion data, range fit for + * all ADC configurations. + * @param Instance ADC instance + * @param Rank This parameter can be one of the following values: + * @arg @ref ADC_INJ_RANK_1 + * @arg @ref ADC_INJ_RANK_2 + * @arg @ref ADC_INJ_RANK_3 + * @arg @ref ADC_INJ_RANK_4 + * @retval Value between Min_Data=0x0000 and Max_Data=0xFFFF + */ +#define __LL_ADC_INJ_ReadConversionData(__INSTANCE__, __RANK__) \ + READ_BIT((__INSTANCE__)->JDR[(__RANK__) >> ADC_JSQX_REGOFFSET], ADC_JDR0_JDATA) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_ECU related register interface functions are configured in the ADC + * @{ + */ +/** + * @brief Sets the source channel for the data Address flag bit. + * @note The linkage with the ECU must work in DMA cycle mode. + * @param Instance ADC instance + * @param GroupSel ADC_ECR_GROUP_SEL + * @param Channel ADC_CHANNEL + * @retval None + */ +#define __LL_ADC_ECU_SetAddrDataFlag(__INSTANCE__, __GROUP__, __CHANNLE__) \ + MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_ADSRC, ((__CHANNLE__) << ADC_ECR0_ADSRC_Pos)) + +/** + * @brief Set PINGPONG to rise and fall over zero and choose which watchdog to monitor. + * @note Try to use different watchdogs for ascending and + * descending zero - crossing monitoring. + * @param Instance ADC instance + * @param GroupSel ADC_ECR_GROUP_SEL + * @param UpZeroAWD the range of value AWD0\1\2 + * @param DownZeroAWD the range of value AWD0\1\2 + * @retval None + */ +#define __LL_ADC_ECU_SetUpDownPPFlag(__INSTANCE__, __GROUP__, __UPAWD__, __DOWNAWD__) \ + MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], \ + ADC_ECR0_PSRCU | ADC_ECR0_PSRCD, \ + (((__UPAWD__) << ADC_ECR0_PSRCU_Pos) | ((__DOWNAWD__) << ADC_ECR0_PSRCD_Pos))) + +/** + * @brief Set up a watch-dog 2 monitoring channel. + * @note The selected channel for ascending and descending zero crossing + * monitoring watchdog must be configured to be the same. + * @param Instance ADC instance + * @param GroupSel ADC_ECR_GROUP_SEL + * @param Channel ADC_CHANNEL + * @retval None + */ +#define __LL_ADC_ECU_SetAWD2Channel(__INSTANCE__, __GROUP__, __CHANNLE__) \ + MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_AWD2SEL, ((__CHANNLE__) << ADC_ECR0_AWD2SEL_Pos)) + +/** + * @brief Set up a watch-dog 1 monitoring channel. + * @note The selected channel for ascending and descending zero crossing + * monitoring watchdog must be configured to be the same. + * @param Instance ADC instance + * @param GroupSel ADC_ECR_GROUP_SEL + * @param Channel ADC_CHANNEL + * @retval None + */ +#define __LL_ADC_ECU_SetAWD1Channel(__INSTANCE__, __GROUP__, __CHANNLE__) \ + MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_AWD1SEL, ((__CHANNLE__) << ADC_ECR0_AWD1SEL_Pos)) + +/** + * @brief Set up a watch-dog 0 monitoring channel. + * @note The selected channel for ascending and descending zero crossing + * monitoring watchdog must be configured to be the same. + * @param Instance ADC instance + * @param GroupSel ADC_ECR_GROUP_SEL + * @param Channel ADC_CHANNEL + * @retval None + */ +#define __LL_ADC_ECU_SetAWD0Channel(__INSTANCE__, __GROUP__, __CHANNLE__) \ + MODIFY_REG((__INSTANCE__)->ECR[__GROUP__], ADC_ECR0_AWD0SEL, ((__CHANNLE__) << ADC_ECR0_AWD0SEL_Pos)) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_FLAG_Management ADC normal flag management + * @{ + */ +/** + * @brief Get flag ADC ready. + * @note Flag ADC_FLAG_ADRDY is raised when the ADC + * is enabled and when conversion clock is active. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_ADRDY(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_ADRDY) == (ADC_FLAG_ADRDY)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC group regular end of unitary conversion. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_EOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_EOC) == (ADC_FLAG_EOC)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC group regular end of sequence conversions. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_EOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_EOS) == (ADC_FLAG_EOS)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC group regular overrun. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_OVR(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_OVR) == (ADC_FLAG_OVR)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC group regular end of sampling phase. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_EOSMP(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_EOSMP) == (ADC_FLAG_EOSMP)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC group injected end of unitary conversion. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_JEOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_JEOC) == (ADC_FLAG_JEOC)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC group injected end of sequence conversions. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_JEOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_JEOS) == (ADC_FLAG_JEOS)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC analog watchdog 0 flag + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_AWD0(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_AWD0) == (ADC_FLAG_AWD0)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC analog watchdog 1. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_AWD1(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_AWD1) == (ADC_FLAG_AWD1)) ? 1UL : 0UL) + +/** + * @brief Get flag ADC analog watchdog 2. + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_AWD2(__INSTANCE__) ((READ_BIT((__INSTANCE__)->ISR, ADC_FLAG_AWD2) == (ADC_FLAG_AWD2)) ? 1UL : 0UL) + +/** + * @brief Clear flag ADC ready. + * @note Flag ADC_FLAG_ADRDY is raised when the ADC + * is enabled and when conversion clock is active. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_ADRDY(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_ADRDY) + +/** + * @brief Clear flag ADC group regular end of unitary conversion. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_EOC(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_EOC) + +/** + * @brief Clear flag ADC group regular end of sequence conversions. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_EOS(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_EOS) + +/** + * @brief Clear flag ADC group regular overrun. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_OVR(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_OVR) + +/** + * @brief Clear flag ADC group regular end of sampling phase. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_EOSMP(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_EOSMP) + +/** + * @brief Clear flag ADC group injected end of unitary conversion. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_JEOC(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_JEOC) + +/** + * @brief Clear flag ADC group injected end of sequence conversions. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_JEOS(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_JEOS) + +/** + * @brief Clear flag ADC analog watchdog 0. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_AWD0(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_AWD0) + +/** + * @brief Clear flag ADC analog watchdog 1. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_AWD1(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_AWD1) + +/** + * @brief Clear flag ADC analog watchdog 2. + * @param __INSTANCE__ ADC instance + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_AWD2(__INSTANCE__) WRITE_REG((__INSTANCE__)->ISR, ADC_FLAG_AWD2) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_IT_Management ADC IT management + * @{ + */ +/** + * @brief Enable the specified ADC interrupt. + * @param __INSTANCE__ ADC instance + * @param __INTERRUPT__ specifies the ADC flags to clear. + * This parameter can be any combination of @ref ADC_Flag_definition: + * @arg ADC_IT_ADRDY ADC flag ADC instance ready + * @arg ADC_IT_EOC ADC flag ADC group regular end of unitary conversion + * @arg ADC_IT_EOS ADC flag ADC group regular end of sequence conversions + * @arg ADC_IT_OVR ADC flag ADC group regular overrun + * @arg ADC_IT_EOSMP ADC flag ADC group regular end of sampling phase + * @arg ADC_IT_JEOC ADC flag ADC group injected end of unitary conversion + * @arg ADC_IT_JEOS ADC flag ADC group injected end of sequence conversions + * @arg ADC_IT_AWD0 ADC flag ADC analog watchdog 1 + * @arg ADC_IT_AWD1 ADC flag ADC analog watchdog 2 + * @arg ADC_IT_AWD2 ADC flag ADC analog watchdog 3 + * @retval None + */ +#define __LL_ADC_ENABLE_IT(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->IER, __INTERRUPT__) + +/** + * @brief Disable the specified ADC interrupt. + * @param __INSTANCE__ ADC instance + * @param __INTERRUPT__ specifies the TMR flags to clear. + * This parameter can be any combination of @ref TMR_Flag_definition: + * @arg ADC_IT_ADRDY ADC flag ADC instance ready + * @arg ADC_IT_EOC ADC flag ADC group regular end of unitary conversion + * @arg ADC_IT_EOS ADC flag ADC group regular end of sequence conversions + * @arg ADC_IT_OVR ADC flag ADC group regular overrun + * @arg ADC_IT_EOSMP ADC flag ADC group regular end of sampling phase + * @arg ADC_IT_JEOC ADC flag ADC group injected end of unitary conversion + * @arg ADC_IT_JEOS ADC flag ADC group injected end of sequence conversions + * @arg ADC_IT_AWD0 ADC flag ADC analog watchdog 1 + * @arg ADC_IT_AWD1 ADC flag ADC analog watchdog 2 + * @arg ADC_IT_AWD2 ADC flag ADC analog watchdog 3 + * @retval None + */ +#define __LL_ADC_DISABLE_IT(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->IER, __INTERRUPT__) + +/** + * @brief Get state of interruption ADC ready + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ + +#define __LL_ADC_GET_IT_ADRDY(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_ADRDY) == (ADC_IT_ADRDY)) ? 1UL : 0UL) +/** + * @brief Get state of interruption ADC group regular end of unitary conversion + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_EOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_EOC) == (ADC_IT_EOC)) ? 1UL : 0UL) + +/** + * @brief Get state of interruption ADC group regular end of sequence conversions + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_EOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_EOS) == (ADC_IT_EOS)) ? 1UL : 0UL) + +/** + * @brief Get state of interruption ADC group regular overrun + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_OVR(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_OVR) == (ADC_IT_OVR)) ? 1UL : 0UL) + +/** + * @brief Get state of interruption ADC group regular end of sampling + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_EOSMP(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_EOSMP) == (ADC_IT_EOSMP)) ? 1UL : 0UL) + +/** + * @brief Get state of interruption ADC group injected end of unitary conversion + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_JEOC(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_JEOC) == (ADC_IT_JEOC)) ? 1UL : 0UL) + +/** + * @brief Get state of interruption ADC group injected end of sequence conversions + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_JEOS(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_JEOS) == (ADC_IT_JEOS)) ? 1UL : 0UL) +/** + * @brief Get state of interruption Get ADC analog watchdog 0 + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_AWD0(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_AWD0) == (ADC_IT_AWD0)) ? 1UL : 0UL) + +/** + * @brief Get state of interruption ADC analog watchdog 1 + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_AWD1(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_AWD1) == (ADC_IT_AWD1)) ? 1UL : 0UL) + +/** + * @brief Get state of interruption Get ADC analog watchdog 2 + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_AWD2(__INSTANCE__) ((READ_BIT((__INSTANCE__)->IER, ADC_IT_AWD2) == (ADC_IT_AWD2)) ? 1UL : 0UL) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_SAMP_INT_FLAG ADC Sample interrupt management + * @{ + */ +/** + * @brief Enable interruption ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_ENABLE_IT_DONE(__INSTANCE__, __CHANNEL__) \ + SET_BIT((__INSTANCE__)->SIER, (ADC_SIER_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Disable interruption ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_DISABLE_IT_DONE(__INSTANCE__, __CHANNEL__) \ + CLEAR_BIT((__INSTANCE__)->SIER, (ADC_SIER_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Get state of interruption Get ADC every channel Sample done. + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_DONE(__INSTANCE__, __CHANNEL__) \ + ((READ_BIT((__INSTANCE__)->SIER, (ADC_SIER_CHANNEL_0 << (__CHANNEL__))) == \ + ((ADC_SIER_CHANNEL_0 << (__CHANNEL__)))) ? 1UL : 0UL) + +/** + * @brief Clear flag ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_DONE(__INSTANCE__, __CHANNEL__) \ + WRITE_REG((__INSTANCE__)->SISR, (ADC_SISR_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Get flagADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_DONE(__INSTANCE__, __CHANNEL__) \ + ((READ_BIT((__INSTANCE__)->SISR, (ADC_SISR_CHANNEL_0 << (__CHANNEL__))) == \ + (ADC_SISR_CHANNEL_0 << (__CHANNEL__))) ? 1UL : 0UL) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_HALF_INT_FLAG ADC Half interrupt management + * @{ + */ +/** + * @brief Enable interruption ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_ENABLE_IT_HALF(__INSTANCE__, __CHANNEL__) \ + SET_BIT((__INSTANCE__)->HIER, (ADC_HIER_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Disable interruption ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_DISABLE_IT_HALF(__INSTANCE__, __CHANNEL__) \ + CLEAR_BIT((__INSTANCE__)->HIER, (ADC_HIER_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Get state of interruption Get ADC every channel Sample done. + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_HALF(__INSTANCE__, __CHANNEL__) \ + ((READ_BIT((__INSTANCE__)->HIER, (ADC_HIER_CHANNEL_0 << (__CHANNEL__))) == \ + ((ADC_HIER_CHANNEL_0 << (__CHANNEL__)))) ? 1UL : 0UL) + +/** + * @brief Clear flag ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_HALF(__INSTANCE__, __CHANNEL__) \ + WRITE_REG((__INSTANCE__)->HISR, (ADC_HISR_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Get flagADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_HALF(__INSTANCE__, __CHANNEL__) \ + ((READ_BIT((__INSTANCE__)->HISR, (ADC_HISR_CHANNEL_0 << (__CHANNEL__))) == \ + (ADC_HISR_CHANNEL_0 << (__CHANNEL__))) ? 1UL : 0UL) + +/** + * @} + */ + + +/** @addtogroup ADC_LL_FULL_INT_FLAG ADC Full interrupt management + * @{ + */ +/** + * @brief Enable interruption ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_ENABLE_IT_FULL(__INSTANCE__, __CHANNEL__) \ + SET_BIT((__INSTANCE__)->FIER, (ADC_FIER_CHANNEL_0 << (__CHANNEL__))) +/** + * @brief Disable interruption ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_DISABLE_IT_FULL(__INSTANCE__, __CHANNEL__) \ + CLEAR_BIT((__INSTANCE__)->FIER, (ADC_FIER_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Get state of interruption Get ADC every channel Sample done. + * (0: interrupt disabled, 1: interrupt enabled). + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_IT_FULL(__INSTANCE__, __CHANNEL__) \ + ((READ_BIT((__INSTANCE__)->FIER, (ADC_FIER_CHANNEL_0 << (__CHANNEL__))) == \ + ((ADC_FIER_CHANNEL_0 << (__CHANNEL__)))) ? 1UL : 0UL) + +/** + * @brief Clear flag ADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval None + */ +#define __LL_ADC_CLEAR_FLAG_FULL(__INSTANCE__, __CHANNEL__) \ + WRITE_REG((__INSTANCE__)->FISR, (ADC_FISR_CHANNEL_0 << (__CHANNEL__))) + +/** + * @brief Get flagADC every channel Sample done. + * @param __INSTANCE__ ADC instance + * @param Channel 0~11 + * @retval State of bit (1 or 0). + */ +#define __LL_ADC_GET_FLAG_FULL(__INSTANCE__, __CHANNEL__) \ + ((READ_BIT((__INSTANCE__)->FISR, (ADC_FISR_CHANNEL_0 << (__CHANNEL__))) == \ + (ADC_FISR_CHANNEL_0 << (__CHANNEL__))) ? 1UL : 0UL) + +/** + * @} + */ + + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup ADC_LL_Exported_Functions + * @{ + */ + +/** @addtogroup ADC_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_ADC_Init(ADC_TypeDef *Instance, ADC_InitTypeDef *ADC_InitStruct); +LL_StatusETypeDef LL_ADC_DeInit(ADC_TypeDef *Instance); +LL_StatusETypeDef LL_ADC_REG_Init(ADC_TypeDef *Instance, ADC_REG_InitTypeDef *ADC_REG_InitStruct); +LL_StatusETypeDef LL_ADC_INJ_Init(ADC_TypeDef *Instance, ADC_INJ_InitTypeDef *ADC_INJ_InitStruct); +void LL_ADC_MspInit(ADC_TypeDef *Instance); +void LL_ADC_MspDeInit(ADC_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup ADC_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_ADC_ECU_Config(ADC_TypeDef *Instance, ADC_ECUConfTypeDef *ADC_ECU_Config); +LL_StatusETypeDef LL_ADC_AnalogWDGConfig(ADC_TypeDef *Instance, ADC_AnalogWDGCfgTypeDef *AnalogWDGConfig); +LL_StatusETypeDef LL_ADC_DMATransferConfig(ADC_TypeDef *Instance, ADC_DMATransferCfgTypeDef *DMATransferConfig); +LL_StatusETypeDef LL_ADC_CalibrationConfig(ADC_TypeDef *Instance, ADC_CalibrationTypeDef *CalibrationConfig); +float LL_ADC_TemperatureCovert(uint16_t voltage_data); +/** + * @} + */ + + +/** @addtogroup ADC_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_ADC_AdRdyCallback(ADC_TypeDef *Instance); +void LL_ADC_EosmpCallback(ADC_TypeDef *Instance); +void LL_ADC_AnologWD2Callback(ADC_TypeDef *Instance); +void LL_ADC_AnologWD1Callback(ADC_TypeDef *Instance); +void LL_ADC_AnologWD0Callback(ADC_TypeDef *Instance); +void LL_ADC_OverRunCallback(ADC_TypeDef *Instance); +void LL_ADC_JeosCallback(ADC_TypeDef *Instance); +void LL_ADC_EosCallback(ADC_TypeDef *Instance); +void LL_ADC_JeocCallback(ADC_TypeDef *Instance); +void LL_ADC_EocCallback(ADC_TypeDef *Instance); +void LL_ADC_SampCallback(ADC_TypeDef *Instance, uint8_t Channel); +void LL_ADC_HalfCallback(ADC_TypeDef *Instance, uint8_t Channel); +void LL_ADC_FullCallback(ADC_TypeDef *Instance, uint8_t Channel); + +void LL_ADC_NORM_IRQHandler(ADC_TypeDef *Instance); +void LL_ADC_SAMP_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel); +void LL_ADC_HALF_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel); +void LL_ADC_FULL_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel); +/** + * @} + */ + +/** + * @} + */ + + +/* Private constants ---------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup ADC_LL_Private_Macros ADC LL Private Macros + * @brief ADC LL Private Macros + * @{ + */ + +/** + * @brief Judge is ADC synchronization or not + * @param __SYNCHRONZATION__ synchronization to judge + * @retval 0 isn't ADC synchronization + * @retval 1 is ADC synchronization + */ +#define IS_ADC_SYNCHRONIZATION(__SYNCHRONZATION__) \ + ( ((__SYNCHRONZATION__) == ADC_SYNCEN_DIS) \ + || ((__SYNCHRONZATION__) == ADC_SYNCEN_EN) \ + ) + +/** + * @brief Judge is ADC over samp mode set or not + * @param __OVER_SAMP_MODE__ over samp mode to judge + * @retval 0 isn't ADC over samp mode set + * @retval 1 is ADC over samp mode set + */ +#define IS_ADC_OVERSAMPMODE_SET(__OVER_SAMP_MODE__) \ + ( ((__OVER_SAMP_MODE__) == ADC_OVS_CONTINUED_MODE) \ + || ((__OVER_SAMP_MODE__) == ADC_OVS_RESUMED_MODE) \ + ) + +/** + * @brief Judge is ADC trig over samp or not + * @param __TRIG_OVER_SAMP__ trig over samp to judge + * @retval 0 isn't ADC trig over samp + * @retval 1 is ADC trig over samp + */ +#define IS_ADC_TRIGOVERSAMP(__TRIG_OVER_SAMP__) \ + ( ((__TRIG_OVER_SAMP__) == ADC_OVS_TRIG_CONT) \ + || ((__TRIG_OVER_SAMP__) == ADC_OVS_TRIG_DISCONT) \ + ) + +/** + * @brief Judge is ADC over samp shift or not + * @param __OVER_SAMP_SHIFT__ over samp shift to judge + * @retval 0 isn't ADC over samp shift + * @retval 1 is ADC over samp shift + */ +#define IS_ADC_OVERSAMPSHIFT(__OVER_SAMP_SHIFT__) \ + ( ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_NONE) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_1) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_2) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_3) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_4) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_5) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_6) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_7) \ + || ((__OVER_SAMP_SHIFT__) == ADC_OVSS_SHIFT_RIGHT_8) \ + ) + +/** + * @brief Judge is ADC over samp ratio or not + * @param __OVER_SAMP_RATIO__ over samp ratio to judge + * @retval 0 isn't ADC over samp ratio + * @retval 1 is ADC over samp ratio + */ +#define IS_ADC_OVERSAMPRATIO(__OVER_SAMP_RATIO__) \ + ( ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_2) \ + || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_4) \ + || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_8) \ + || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_16) \ + || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_32) \ + || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_64) \ + || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_128) \ + || ((__OVER_SAMP_RATIO__) == ADC_OVSR_RATIO_256) \ + ) + +/** + * @brief Judge is ADC anolog set or not + * @param __ANOLOG_SET__ anolog set to judge + * @retval 0 isn't ADC anolog set + * @retval 1 is ADC anolog set + */ +#define IS_ADC_ANOLOGSET(__ANOLOG_SET__) \ + ( ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_DEFAULT) \ + || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_A_SH) \ + || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_A_ADC) \ + || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_B_SH) \ + || ((__ANOLOG_SET__) == ADC_ANOLOG_CTL_B_ADC) \ + ) + +/** + * @brief Judge is ADC channel or not + * @param __ADC_CHANNEL__ ADC channel to judge + * @retval 0 isn't ADC channel + * @retval 1 is ADC channel + */ +#define IS_ADC_CHANNEL(__ADC_CHANNEL__) \ + ( ((__ADC_CHANNEL__) == ADC_CHANNEL_0) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_1) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_2) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_3) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_4) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_5) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_6) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_7) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_8) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_9) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_10) \ + || ((__ADC_CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) \ + ) + + +/** + * @brief Judge is ADC reg trig source or not + * @param __REG_TRIG_SOURCE__ reg trig source to judge + * @retval 0 isn't ADC reg trig source + * @retval 1 is ADC reg trig source + */ +#define IS_ADC_REG_TRIG_SOURCE( __REG_TRIG_SOURCE__) \ + ( ((__REG_TRIG_SOURCE__) == ADC_REG_TRIG_SOFTWARE) \ + || (((__REG_TRIG_SOURCE__) & (ADC_LR_EXTSEL_Msk | ADC_LR_EXTEN_Msk)) != 0x00U) \ + ) + +/** + * @brief Judge is ADC reg continuous mode or not + * @param __REG_CONTINUOUS_MODE__ reg continuous mode to judge + * @retval 0 isn't ADC reg continuous mode + * @retval 1 is ADC reg continuous mode + */ +#define IS_ADC_REG_CONTINUOUS_MODE(__REG_CONTINUOUS_MODE__) \ + ( ((__REG_CONTINUOUS_MODE__) == ADC_REG_CONV_SINGLE) \ + || ((__REG_CONTINUOUS_MODE__) == ADC_REG_CONV_CONTINUOUS) \ + ) + +/** + * @brief Judge is ADC reg seq discont or not + * @param __REG_DISCONT_MODE__ reg seq discont to judge + * @retval 0 isn't ADC reg seq discont + * @retval 1 is ADC reg seq discont + */ +#define IS_ADC_REG_SEQ_DISCONT(__REG_DISCONT_MODE__) \ + ( ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISCON_DISABLE) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_1RANK) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_2RANKS) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_3RANKS) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_4RANKS) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_5RANKS) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_6RANKS) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_7RANKS) \ + || ((__REG_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_8RANKS) \ + ) + +/** + * @brief Judge is ADC reg differ sel or not + * @param __DIFSEL_MODE__ differ sel mode to judge + * @retval 0 isn't ADC reg differ sel + * @retval 1 is ADC reg differ sel + */ +#define IS_ADC_REG_DIFFERSEL(__DIFSEL_MODE__) \ + ( ((__DIFSEL_MODE__) == ADC_DIFSEL_DIFFER) \ + || ((__DIFSEL_MODE__) == ADC_DIFSEL_SINGLE) \ + ) + +/** + * @brief Judge is ADC reg samp time clock or not + * @param __REG_SAMPTIMCLK__ reg samp time clock to judge + * @retval 0 isn't ADC reg samp time clock + * @retval 1 is ADC reg samp time clock + */ +#define IS_ADC_REG_SAMPTIMCLK(__REG_SAMPTIMCLK__) \ + ( ((__REG_SAMPTIMCLK__) == ADC_SAMPLINGTIME_6CYCLES) \ + || (((__REG_SAMPTIMCLK__) & ADC_SMPR0_SMP0_Msk) != 0x00U) \ + ) + +/** + * @brief Judge is ADC LL cal coef sel or not + * @param __CALCOEFSEL__ cal coef sel to judge + * @retval 0 isn't ADC LL cal coef sel + * @retval 1 is ADC LL cal coef sel + */ +#define IS_LL_ADC_CALCOEFSEL(__CALCOEFSEL__) \ + ( ((__CALCOEFSEL__) == ADC_CALIB_GROUP0) \ + || ((__CALCOEFSEL__) == ADC_CALIB_GROUP1) \ + || ((__CALCOEFSEL__) == ADC_CALIB_GROUP2) \ + || ((__CALCOEFSEL__) == ADC_CALIB_GROUP3) \ + ) + +/** + * @brief Judge is ADC over data behavior or not + * @param __REG_OVR_DATA_BEHAVIOR__ over data behavior to judge + * @retval 0 isn't ADC over data behavior + * @retval 1 is ADC over data behavior + */ +#define IS_ADC_OVR_DATA_BEHAVIOR(__REG_OVR_DATA_BEHAVIOR__) \ + ( ((__REG_OVR_DATA_BEHAVIOR__) == ADC_OVR_DATA_PRESERVED) \ + || ((__REG_OVR_DATA_BEHAVIOR__) == ADC_OVR_DATA_OVERWRITTEN) \ + ) + +/** + * @brief Judge is ADC reg dma transfer or not + * @param __REG_DMA_TRANSFER__ reg dma transfer to judge + * @retval 0 isn't ADC reg dma transfer + * @retval 1 is ADC reg dma transfer + */ +#define IS_ADC_REG_DMA_TRANSFER(__REG_DMA_TRANSFER__) \ + ( ((__REG_DMA_TRANSFER__) == ADC_REG_DMA_TRANSFER_SINGLE) \ + || ((__REG_DMA_TRANSFER__) == ADC_REG_DMA_TRANSFER_CIRCLE) \ + || ((__REG_DMA_TRANSFER__) == ADC_REG_DMA_TRANSFER_DISABLE) \ + ) + +/** + * @brief Judge is ADC reg awd filter or not + * @param __REG_AWD_FILTER__ reg awd filter to judge + * @retval 0 isn't ADC reg awd filter + * @retval 1 is ADC reg awd filter + */ +#define IS_ADC_REG_AWD_FILTER(__REG_AWD_FILTER__) \ + ( (((__REG_AWD_FILTER__) & ADC_AWD0CR_AWD0FILT_Msk) != 0x00U) \ + || ((__REG_AWD_FILTER__) == ADC_AWD_FILTERING_NONE) \ + ) + +/** + * @brief Judge is ADC reg awd sel or not + * @param __REG_AWD_SEL__ reg awd sel to judge + * @retval 0 isn't ADC reg awd sel + * @retval 1 is ADC reg awd sel + */ +#define IS_ADC_REG_AWD_SEL(__REG_AWD_SEL__) \ + ( ((__REG_AWD_SEL__) == ADC_AWD2) \ + || ((__REG_AWD_SEL__) == ADC_AWD0) \ + || ((__REG_AWD_SEL__) == ADC_AWD1) \ + ) + +/** + * @brief Judge is ADC awd channel or not + * @param __AWD_CHANNEL__ awd channel to judge + * @retval 0 isn't ADC awd channel + * @retval 1 is ADC awd channel + */ +#define IS_ADC_AWD_CHANNEL(__AWD_CHANNEL__) \ + ( (((__AWD_CHANNEL__) & ADC_AWD0CR_AWD0CH_Msk) != 0x00U) \ + || (((__AWD_CHANNEL__) & (ADC_AWD0CR_AWD0CH_Msk)) == 0x00U) \ + ) + +/** + * @brief Judge is ADC reg seq length or not + * @param __REG_SEQ_LENGTH__ reg seq length to judge + * @retval 0 isn't ADC reg seq length + * @retval 1 is ADC reg seq length + */ +#define IS_ADC_REG_SEQ_LENGTH(__REG_SEQ_LENGTH__) \ + ( ((__REG_SEQ_LENGTH__) == ADC_REG_SEQ_LENGTH_1) \ + || (((__REG_SEQ_LENGTH__) & ADC_LR_LEN_Msk) != 0x00U) \ + ) + +/** + * @brief Judge is ADC reg seq pos or not + * @param __REG_SEQ_POS_ reg seq pos to judge + * @retval 0 isn't ADC reg seq pos + * @retval 1 is ADC reg seq pos + */ +#define IS_ADC_REG_SEQ_POS(__REG_SEQ_POS_) \ + ( ((__REG_SEQ_POS_) == ADC_REG_RANK_1) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_2) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_3) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_4) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_5) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_6) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_7) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_8) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_9) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_10) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_11) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_12) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_13) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_14) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_15) \ + || ((__REG_SEQ_POS_) == ADC_REG_RANK_16) \ + ) + +/** + * @brief Judge is ADC reg seq discont mode or not + * @param __REG_SEQ_DISCONT_MODE__ reg seq discont mode to judge + * @retval 0 isn't ADC reg seq discont mode + * @retval 1 is ADC reg seq discont mode + */ +#define IS_ADC_REG_SEQ_DISCONT_MODE(__REG_SEQ_DISCONT_MODE__) \ + ( ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISCON_DISABLE) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_1RANK) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_2RANKS) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_3RANKS) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_4RANKS) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_5RANKS) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_6RANKS) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_7RANKS) \ + || ((__REG_SEQ_DISCONT_MODE__) == ADC_REG_SEQ_DISNUM_8RANKS) \ + ) + + +/** + * @brief Judge is ADC inj trig source or not + * @param __INJ_TRIG_SOURCE__ inj trig source to judge + * @retval 0 isn't ADC inj trig source + * @retval 1 is ADC inj trig source + */ +#define IS_ADC_INJ_TRIG_SOURCE( __INJ_TRIG_SOURCE__) \ + ( ((__INJ_TRIG_SOURCE__) == ADC_INJ_TRIG_SOFTWARE) \ + || (((__INJ_TRIG_SOURCE__) & (ADC_JLR_JEXTSEL_Msk | ADC_JLR_JEXTEN_Msk)) != 0x00U) \ + ) + +/** + * @brief Judge is ADC inj trig ext edge or not + * @param __INJ_TRIG_EXT_EDGE__ inj trig ext edge to judge + * @retval 0 isn't ADC inj trig ext edge + * @retval 1 is ADC inj trig ext edge + */ +#define IS_ADC_INJ_TRIG_EXT_EDGE(__INJ_TRIG_EXT_EDGE__) \ + ( ((__INJ_TRIG_EXT_EDGE__) == ADC_INJ_TRIG_EXT_RISING) \ + || ((__INJ_TRIG_EXT_EDGE__) == ADC_INJ_TRIG_EXT_FALLING) \ + || ((__INJ_TRIG_EXT_EDGE__) == ADC_INJ_TRIG_EXT_RISINGFALLING) \ + ) + +/** + * @brief Judge is ADC inj trig auto or not + * @param __INJ_TRIG_AUTO__ inj trig auto to judge + * @retval 0 isn't ADC inj trig auto + * @retval 1 is ADC inj trig auto + */ +#define IS_ADC_INJ_TRIG_AUTO(__INJ_TRIG_AUTO__) \ + ( ((__INJ_TRIG_AUTO__) == ADC_INJ_TRIG_INDEPENDENT) \ + || ((__INJ_TRIG_AUTO__) == ADC_INJ_TRIG_FROM_GRP_REGULAR) \ + ) + +/** + * @brief Judge is ADC inj seq scan length or not + * @param __INJ_SEQ_LENGTH__ inj seq scan length to judge + * @retval 0 isn't ADC inj seq scan length + * @retval 1 is ADC inj seq scan length + */ +#define IS_ADC_INJ_SEQ_SCAN_LENGTH(__INJ_SEQ_LENGTH__) \ + ( ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_1) \ + || ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_2) \ + || ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_3) \ + || ((__INJ_SEQ_LENGTH__) == ADC_INJ_SEQ_LENGTH_4) \ + ) + +/** + * @brief Judge is ADC inj jseq pos or not + * @param __INJ_SEQ_LENGTH__ inj jseq pos to judge + * @retval 0 isn't ADC inj jseq pos + * @retval 1 is ADC inj jseq pos + */ +#define IS_ADC_INJ_JSEQ_POS(__INJ_SEQ_LENGTH__) \ + ( ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_1) \ + || ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_2) \ + || ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_3) \ + || ((__INJ_SEQ_LENGTH__) == ADC_INJ_RANK_4) \ + ) + +/** + * @brief Judge is ADC inj seq scan discont mode or not + * @param __INJ_SEQ_DISCONT_MODE__ inj seq scan discont mode to judge + * @retval 0 isn't ADC inj seq scan discont mode + * @retval 1 is ADC inj seq scan discont mode + */ +#define IS_ADC_INJ_SEQ_SCAN_DISCONT_MODE(__INJ_SEQ_DISCONT_MODE__) \ + ( ((__INJ_SEQ_DISCONT_MODE__) == ADC_INJ_SEQ_DISCONT_DISABLE) \ + || ((__INJ_SEQ_DISCONT_MODE__) == ADC_INJ_SEQ_DISCONT_ENABLE) \ + ) + + +/** + * @brief Judge is ADC ECU group sel or not + * @param __ECU_GROUP_SEL__ ECU group sel to judge + * @retval 0 isn't ADC ECU group sel + * @retval 1 is ADC ECU group sel + */ +#define IS_ADC_ECU_GROUPSEL(__ECU_GROUP_SEL__) \ + ( ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP0) \ + || ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP1) \ + || ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP2) \ + || ((__ECU_GROUP_SEL__) == ADC_CALIB_GROUP3) \ + ) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_ADC_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_can.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_can.h new file mode 100644 index 0000000000..e739b4f9dc --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_can.h @@ -0,0 +1,1030 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_can.h + * @author MCD Application Team + * @brief Header file for CAN LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_CAN_H_ +#define _TAE32F53XX_LL_CAN_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup CAN_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/** @defgroup CAN_LL_Exported_Types CAN LL Exported Types + * @brief CAN LL Exported Types + * @{ + */ + +/** + *@brief CAN RX buffer status enum type define + */ +typedef enum { + CAN_RX_BUF_STA_EMPTY = 0, /*!< CAN RX buffer empty */ + CAN_RX_BUF_STA_FEW, /*!< CAN RX buffer few */ + CAN_RX_BUF_STA_ALMOST_FULL, /*!< CAN RX buffer almost full */ + CAN_RX_BUF_STA_FULL, /*!< CAN RX buffer full */ +} CAN_RxBufStaETypeDef; + +/** + * @brief CAN acceptance filter slot definition. + */ +typedef enum { + CAN_ACCEPT_FILT_SLOT_0 = 0, /*!< CAN acceptance filter slot 0 */ + CAN_ACCEPT_FILT_SLOT_1, /*!< CAN acceptance filter slot 1 */ + CAN_ACCEPT_FILT_SLOT_2, /*!< CAN acceptance filter slot 2 */ + CAN_ACCEPT_FILT_SLOT_3, /*!< CAN acceptance filter slot 3 */ + CAN_ACCEPT_FILT_SLOT_4, /*!< CAN acceptance filter slot 4 */ + CAN_ACCEPT_FILT_SLOT_5, /*!< CAN acceptance filter slot 5 */ + CAN_ACCEPT_FILT_SLOT_6, /*!< CAN acceptance filter slot 6 */ + CAN_ACCEPT_FILT_SLOT_7, /*!< CAN acceptance filter slot 7 */ + CAN_ACCEPT_FILT_SLOT_8, /*!< CAN acceptance filter slot 8 */ + CAN_ACCEPT_FILT_SLOT_9, /*!< CAN acceptance filter slot 9 */ + CAN_ACCEPT_FILT_SLOT_10, /*!< CAN acceptance filter slot 10 */ + CAN_ACCEPT_FILT_SLOT_11, /*!< CAN acceptance filter slot 11 */ + CAN_ACCEPT_FILT_SLOT_12, /*!< CAN acceptance filter slot 12 */ + CAN_ACCEPT_FILT_SLOT_13, /*!< CAN acceptance filter slot 13 */ + CAN_ACCEPT_FILT_SLOT_14, /*!< CAN acceptance filter slot 14 */ + CAN_ACCEPT_FILT_SLOT_15, /*!< CAN acceptance filter slot 15 */ +} CAN_AcceptFilSlotETypeDef; + +/** + * @brief CAN RX buffer almost full warnning limit definition + */ +typedef enum { + CAN_RX_ALMOST_FULL_LIMIT_0 = 0, /*!< CAN RX buffer almost full warnning limit: 0 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_1, /*!< CAN RX buffer almost full warnning limit: 1 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_2, /*!< CAN RX buffer almost full warnning limit: 2 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_3, /*!< CAN RX buffer almost full warnning limit: 3 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_4, /*!< CAN RX buffer almost full warnning limit: 4 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_5, /*!< CAN RX buffer almost full warnning limit: 5 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_6, /*!< CAN RX buffer almost full warnning limit: 6 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_7, /*!< CAN RX buffer almost full warnning limit: 7 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_8, /*!< CAN RX buffer almost full warnning limit: 8 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_9, /*!< CAN RX buffer almost full warnning limit: 9 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_10, /*!< CAN RX buffer almost full warnning limit: 10 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_11, /*!< CAN RX buffer almost full warnning limit: 11 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_12, /*!< CAN RX buffer almost full warnning limit: 12 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_13, /*!< CAN RX buffer almost full warnning limit: 13 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_14, /*!< CAN RX buffer almost full warnning limit: 14 Byte */ + CAN_RX_ALMOST_FULL_LIMIT_15, /*!< CAN RX buffer almost full warnning limit: 15 Byte */ +} CAN_RxAlmostFullLimitETypeDef; + +/** + * @brief CAN programmable error warning limit definition + */ +typedef enum { + CAN_ERR_WARN_LIMIT_8 = 0, /*!< CAN programmable error warning limit: 8 bytes */ + CAN_ERR_WARN_LIMIT_16, /*!< CAN programmable error warning limit: 16 bytes */ + CAN_ERR_WARN_LIMIT_24, /*!< CAN programmable error warning limit: 24 bytes */ + CAN_ERR_WARN_LIMIT_32, /*!< CAN programmable error warning limit: 32 bytes */ + CAN_ERR_WARN_LIMIT_40, /*!< CAN programmable error warning limit: 40 bytes */ + CAN_ERR_WARN_LIMIT_48, /*!< CAN programmable error warning limit: 48 bytes */ + CAN_ERR_WARN_LIMIT_56, /*!< CAN programmable error warning limit: 56 bytes */ + CAN_ERR_WARN_LIMIT_64, /*!< CAN programmable error warning limit: 64 bytes */ + CAN_ERR_WARN_LIMIT_72, /*!< CAN programmable error warning limit: 72 bytes */ + CAN_ERR_WARN_LIMIT_80, /*!< CAN programmable error warning limit: 80 bytes */ + CAN_ERR_WARN_LIMIT_88, /*!< CAN programmable error warning limit: 88 bytes */ + CAN_ERR_WARN_LIMIT_96, /*!< CAN programmable error warning limit: 96 bytes */ + CAN_ERR_WARN_LIMIT_104, /*!< CAN programmable error warning limit: 104 bytes */ + CAN_ERR_WARN_LIMIT_112, /*!< CAN programmable error warning limit: 112 bytes */ + CAN_ERR_WARN_LIMIT_120, /*!< CAN programmable error warning limit: 120 bytes */ + CAN_ERR_WARN_LIMIT_128, /*!< CAN programmable error warning limit: 128 bytes */ +} CAN_ErrWarnLimitETypeDef; + + +/** + * @brief CAN RX buffer format type definition + */ +typedef struct __CAN_RxBufFormatTypeDef { + /*! Standard/Extended iDentifier value + */ + uint32_t id : 29, + + /*! Reserved bit. + */ + reserved1 : 2, + + /*! Error State Indicator. This is a read-only status bit for RBUF and is not available + * in TBUF. The protocol machine automatically embeds the correct value of ESI into + * transmitted frames. ESI is only included in CAN FD frames and does not exist in CAN + * 2.0 frames. + */ + err_state_indicator : 1; + + /*! The Data Length Code (DLC) in RBUF and TBUF defines the length of the payload(the + * number of payload bytes in a frame). + */ + uint32_t data_len_code : 4, + + /*! Bit Rate Switch + * 0: nominal / slow bit rate for the complete frame. + * 1: switch to data / fast bit rate for the data payload and the CRC + * Only CAN FD frames can switch the bitrate. Therefore BRS is forced to 0 if EDL=0 + */ + bit_rate_switch : 1, + + /*! Extended Data Length + * 0: CAN 2.0 frame (up to 8 bytes payload) + * 1: CAN FD frame (up to 64 bytes payload) + */ + extended_data_len : 1, + + /*! Remote Transmission Request + * 0: data frame + * 1: remote frame + * Only CAN 2.0 frames can be remote frames. There is no remote frame for CAN FD. + * Therefore RTR is forced to 0 if EDL=1 in the TBUF. + */ + remote_tx_req : 1, + + /*! IDentifier Extension + * 0: Standard Format: ID(10:0) + * 1: Extended Format: ID(28:0) + */ + id_extension : 1, + + /*! Reserved bit. + */ + reserved2 : 24; +} CAN_RxBufFormatTypeDef; + +/** + * @brief CAN TX buffer format type definition + */ +typedef struct __CAN_TxBufFormatTypeDef { + /*! Standard/Extended iDentifier value + */ + uint32_t id : 29, + + /*! Reserved bit. + */ + reserved1 : 3; + + /*! The Data Length Code (DLC) in RBUF and TBUF defines the length of the payload(the + * number of payload bytes in a frame). + */ + uint32_t data_len_code : 4, + + /*! Bit Rate Switch + * 0: nominal / slow bit rate for the complete frame. + * 1: switch to data / fast bit rate for the data payload and the CRC + * Only CAN FD frames can switch the bitrate. Therefore BRS is forced to 0 if EDL=0 + */ + bit_rate_switch : 1, + + /*! Extended Data Length + * 0: CAN 2.0 frame (up to 8 bytes payload) + * 1: CAN FD frame (up to 64 bytes payload) + */ + extended_data_len : 1, + + /*! Remote Transmission Request + * 0: data frame + * 1: remote frame + * Only CAN 2.0 frames can be remote frames. There is no remote frame for CAN FD. + * Therefore RTR is forced to 0 if EDL=1 in the TBUF. + */ + remote_tx_req : 1, + + /*! IDentifier Extension + * 0: Standard Format: ID(10:0) + * 1: Extended Format: ID(28:0) + */ + id_extension : 1, + + /*! Reserved bit. + */ + reserved2 : 24; +} CAN_TxBufFormatTypeDef; + +/** + * @brief CAN acceptance filter config type definition + */ +typedef struct __CAN_AcceptFilCfgTypeDef { + CAN_AcceptFilSlotETypeDef slot; /*!< acceptance filter slot number */ + uint32_t code_val; /*!< acceptance filter code value */ + uint32_t mask_val; /*!< acceptance filter mask value */ +} CAN_AcceptFilCfgTypeDef; + +/** + * @brief CAN user config type definition + */ +typedef struct __CAN_UserCfgTypeDef { + uint32_t baudrate; /*!< baudrate */ + uint8_t bit_timing_seg1; /*!< bit timing segment1 */ + uint8_t bit_timing_seg2; /*!< bit timing degment2 */ + uint8_t bit_timing_sjw; /*!< bit timing synchronization jump width */ + CAN_RxAlmostFullLimitETypeDef rx_almost_full_limit; /*!< rx buffer almost full warning limit */ + CAN_ErrWarnLimitETypeDef err_limit; /*!< error warning limit */ + CAN_AcceptFilCfgTypeDef *accept_fil_cfg_ptr; /*!< acceptance filter config pointer */ + uint8_t accept_fil_cfg_num; /*!< acceptance filter config number */ +} CAN_UserCfgTypeDef; + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup CAN_LL_Exported_Macros CAN LL Exported Macros + * @brief CAN LL Exported Macros + * @{ + */ + +/** + * @brief CAN reset set + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_Reset_Set(__CAN__) SET_BIT((__CAN__)->CFG_STAT, CAN_RESET_Msk) + +/** + * @brief CAN reset clear + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_Reset_Clr(__CAN__) CLEAR_BIT((__CAN__)->CFG_STAT, CAN_RESET_Msk) + +/** + * @brief CAN reset status get + * @param __CAN__ Specifies CAN peripheral + * @retval 0 CAN reset has set + * @retval 1 CAN reset has clear + */ +#define __LL_CAN_ResetSta_Get(__CAN__) (READ_BIT((__CAN__)->CFG_STAT, CAN_RESET_Msk) >> CAN_RESET_Pos) + +/** + * @brief CAN loop back mode external enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_LoopBackModeExt_En(__CAN__) SET_BIT((__CAN__)->CFG_STAT, CAN_LOOP_BACK_EXTERNAL_Msk) + +/** + * @brief CAN loop back mode external disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_LoopBackModeExt_Dis(__CAN__) CLEAR_BIT((__CAN__)->CFG_STAT, CAN_LOOP_BACK_EXTERNAL_Msk) + +/** + * @brief CAN loop back mode internal enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_LoopBackModeInternal_En(__CAN__) SET_BIT((__CAN__)->CFG_STAT, CAN_LOOP_BACK_INTERNAL_Msk) + +/** + * @brief CAN loop back mode internal disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_LoopBackModeInternal_Dis(__CAN__) CLEAR_BIT((__CAN__)->CFG_STAT, CAN_LOOP_BACK_INTERNAL_Msk) + +/** + * @brief CAN TX primary single shot enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxPriSingleShot_En(__CAN__) SET_BIT((__CAN__)->CFG_STAT, CAN_TX_PRI_SINGLE_SHOT_Msk) + +/** + * @brief CAN TX primary single shot disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxPriSingleShot_Dis(__CAN__) CLEAR_BIT((__CAN__)->CFG_STAT, CAN_TX_PRI_SINGLE_SHOT_Msk) + +/** + * @brief CAN TX secondary single shot enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSecSingleShot_En(__CAN__) SET_BIT((__CAN__)->CFG_STAT, CAN_TX_SEC_SINGLE_SHOT_Msk) + +/** + * @brief CAN TX secondary single shot disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSecSingleShot_Dis(__CAN__) CLEAR_BIT((__CAN__)->CFG_STAT, CAN_TX_SEC_SINGLE_SHOT_Msk) + +/** + * @brief Judge is RX active or not + * @param __CAN__ Specifies CAN peripheral + * @retval 0 Isn't RX active + * @retval 1 Is RX active + */ +#define __LL_CAN_IsRxActive(__CAN__) (READ_BIT((__CAN__)->CFG_STAT, CAN_RX_ACT_Msk) >> CAN_RX_ACT_Pos) + +/** + * @brief Judge is TX active or not + * @param __CAN__ Specifies CAN peripheral + * @retval 0 Isn't TX active + * @retval 1 Is TX active + */ +#define __LL_CAN_IsTxActive(__CAN__) (READ_BIT((__CAN__)->CFG_STAT, CAN_TX_ACT_Msk) >> CAN_TX_ACT_Pos) + +/** + * @brief Judge is bus off or not + * @param __CAN__ Specifies CAN peripheral + * @retval 0 Is bus on + * @retval 1 Is bus off + */ +#define __LL_CAN_IsBusOff(__CAN__) (READ_BIT((__CAN__)->CFG_STAT, CAN_BUS_OFF_Msk) >> CAN_BUS_OFF_Pos) + + +/** + * @brief TX buffer select PTB + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxBufSel_PTB(__CAN__) CLEAR_BIT((__CAN__)->TCMD, CAN_TX_BUF_SEL_Msk) + +/** + * @brief TX buffer select STB + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxBufSel_STB(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_TX_BUF_SEL_Msk) + +/** + * @brief Listen only mode enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_ListenOnlyMode_En(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_LISTEN_ONLY_Msk) + +/** + * @brief Listen only mode disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_ListenOnlyMode_Dis(__CAN__) CLEAR_BIT((__CAN__)->TCMD, CAN_LISTEN_ONLY_Msk) + +/** + * @brief TX standby mode enalbe + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxStandbyMode_En(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_TX_STANDBY_Msk) + +/** + * @brief TX standby mode disalbe + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxStandbyMode_Dis(__CAN__) CLEAR_BIT((__CAN__)->TCMD, CAN_TX_STANDBY_Msk) + +/** + * @brief TX primary enable set + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxPriEn_Set(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_TX_PRI_EN_Msk) + +/** + * @brief TX primary enable get + * @param __CAN__ Specifies CAN peripheral + * @return TX primary enable status + */ +#define __LL_CAN_TxPriEn_Get(__CAN__) (READ_BIT((__CAN__)->TCMD, CAN_TX_PRI_EN_Msk) >> CAN_TX_PRI_EN_Pos) + +/** + * @brief TX primary abort set + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxPriAbort_Set(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_TX_PRI_ABORT_Msk) + +/** + * @brief TX secondary one set + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSecOne_Set(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_TX_SEC_ONE_Msk) + +/** + * @brief TX secondary one get + * @param __CAN__ Specifies CAN peripheral + * @return TX secondary one status + */ +#define __LL_CAN_TxSecOne_Get(__CAN__) (READ_BIT((__CAN__)->TCMD, CAN_TX_SEC_ONE_Msk) >> CAN_TX_SEC_ONE_Pos) + +/** + * @brief TX secondary all set + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSecAll_Set(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_TX_SEC_ALL_Msk) + +/** + * @brief TX secondary all get + * @param __CAN__ Specifies CAN peripheral + * @return TX secondary send all status + */ +#define __LL_CAN_TxSecAll_Get(__CAN__) (READ_BIT((__CAN__)->TCMD, CAN_TX_SEC_ALL_Msk) >> CAN_TX_SEC_ALL_Pos) + +/** + * @brief TX secondary abort set + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSecAbort_Set(__CAN__) SET_BIT((__CAN__)->TCMD, CAN_TX_SEC_ABORT_Msk) + + +/** + * @brief FD ISO enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_FD_ISO_En(__CAN__) SET_BIT((__CAN__)->TCTRL, CAN_FD_ISO_Msk) + +/** + * @brief FD ISO disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_FD_ISO_Dis(__CAN__) CLEAR_BIT((__CAN__)->TCTRL, CAN_FD_ISO_Msk) + +/** + * @brief TX secondary buffer next set + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSecNext_Set(__CAN__) SET_BIT((__CAN__)->TCTRL, CAN_TX_SEC_NEXT_Msk) + +/** + * @brief TX secondary status get + * @param __CAN__ Specifies CAN peripheral + * @return Number of filled message secondary buffers + */ +#define __LL_CAN_TxSecSta_Get(__CAN__) (READ_BIT((__CAN__)->TCTRL, CAN_TX_SEC_STA_Msk) >> CAN_TX_SEC_STA_Pos) + + +/** + * @brief Judge is RX buffer overflow or not + * @param __CAN__ Specifies CAN peripheral + * @retval 0 Isn't RX buffer overflow + * @retval 1 Is RX buffer overflow + */ +#define __LL_CAN_IsRxBufOver(__CAN__) (READ_BIT((__CAN__)->RCTRL, CAN_RX_BUF_OVER_Msk) >> CAN_RX_BUF_OVER_Pos) + +/** + * @brief RX buffer release + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_RxBufRelease(__CAN__) SET_BIT((__CAN__)->RCTRL, CAN_RX_BUF_REL_Msk) + +/** + * @brief RX buffer status get + * @param __CAN__ Specifies CAN peripheral + * @retval 0 RX buffer empty + * @retval 1 empty < RX buffer < almost full + * @retval 2 RX buffer >= almost full + * @retval 3 RX buffer full + */ +#define __LL_CAN_RxBufSta_Get(__CAN__) (READ_BIT((__CAN__)->RCTRL, CAN_RX_BUF_STA_Msk) >> CAN_RX_BUF_STA_Pos) + + +/** + * @brief RX interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_Rx_INT_EN(__CAN__) SET_BIT((__CAN__)->RTIE, CAN_RX_INT_EN_Msk) + +/** + * @brief RX interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_Rx_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->RTIE, CAN_RX_INT_EN_Msk) + +/** + * @brief RX buffer overrun interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_RxBufOver_INT_EN(__CAN__) SET_BIT((__CAN__)->RTIE, CAN_RX_BUF_OVER_INT_EN_Msk) + +/** + * @brief RX buffer overrun interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_RxBufOver_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->RTIE, CAN_RX_BUF_OVER_INT_EN_Msk) + +/** + * @brief RX buffer full interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_RxBufFull_INT_EN(__CAN__) SET_BIT((__CAN__)->RTIE, CAN_RX_BUF_FULL_INT_EN_Msk) + +/** + * @brief RX buffer full interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_RxBufFull_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->RTIE, CAN_RX_BUF_FULL_INT_EN_Msk) + +/** + * @brief RX buffer almost full interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_RxBufAlmostFull_INT_EN(__CAN__) SET_BIT((__CAN__)->RTIE, CAN_RX_BUF_ALMOST_FULL_INT_EN_Msk) + +/** + * @brief RX buffer almost full interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_RxBufAlmostFull_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->RTIE, CAN_RX_BUF_ALMOST_FULL_INT_EN_Msk) + +/** + * @brief TX primary interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxPri_INT_En(__CAN__) SET_BIT((__CAN__)->RTIE, CAN_TX_PRI_INT_EN_Msk) + +/** + * @brief TX primary interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxPri_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->RTIE, CAN_TX_PRI_INT_EN_Msk) + +/** + * @brief TX secondary interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSec_INT_En(__CAN__) SET_BIT((__CAN__)->RTIE, CAN_TX_SEC_INT_EN_Msk) + +/** + * @brief TX secondary interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxSec_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->RTIE, CAN_TX_SEC_INT_EN_Msk) + +/** + * @brief Error interrupt enalbe + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_Err_INT_En(__CAN__) SET_BIT((__CAN__)->RTIE, CAN_ERR_INT_EN_Msk) + +/** + * @brief Error interrupt disalbe + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_Err_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->RTIE, CAN_ERR_INT_EN_Msk) + +/** + * @brief Judge is TX secondary buffer full or not + * @param __CAN__ Specifies CAN peripheral + * @retval 0 Isn't TX secondary buffer full + * @retval 1 Is TX secondary buffer full + */ +#define __LL_CAN_IsTxSecBufFull(__CAN__) (READ_BIT((__CAN__)->RTIE, CAN_TX_SEC_BUF_FULL_Msk) >> CAN_TX_SEC_BUF_FULL_Pos) + + +/** + * @brief Interrupt status get + * @param __CAN__ Specifies CAN peripheral + * @return Interrupt status + */ +#define __LL_CAN_IntSta_Get(__CAN__) READ_REG((__CAN__)->RTIF) + + +/** + * @brief Judge is error warning limit reached or not + * @param __CAN__ Specifies CAN peripheral + * @retval 0 Isn't error warning limit reached + * @retval 1 Is error warning limit reached + */ +#define __LL_CAN_IsErrWarnLimitReached(__CAN__) \ + (READ_BIT((__CAN__)ERRINT, CAN_ERR_WARN_LIMIT_REACHED_Msk) >> CAN_ERR_WARN_LIMIT_REACHED_Pos) + +/** + * @brief Judge is error passive mode active or not + * @param __CAN__ Specifies CAN peripheral + * @retval 0 Error passive mode isn't active + * @retval 1 Error passive mode is active + */ +#define __LL_CAN_IsErrPassiveModeActive(__CAN__) (READ_BIT((__CAN__)->ERRINT, CAN_ERR_PASS_ACT_Msk) >> CAN_ERR_PASS_ACT_Pos) + +/** + * @brief Error passive interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_ErrPassive_INT_En(__CAN__) SET_BIT((__CAN__)->ERRINT, CAN_ERR_PASS_INT_EN_Msk) + +/** + * @brief Error passive interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_ErrPassive_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->ERRINT, CAN_ERR_PASS_INT_EN_Msk) + +/** + * @brief Arbitration lost interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_ArbLost_INT_En(__CAN__) SET_BIT((__CAN__)->ERRINT, CAN_ARB_LOST_INT_EN_Msk) + +/** + * @brief Arbitration lost interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_ArbLost_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->ERRINT, CAN_ARB_LOST_INT_EN_Msk) + +/** + * @brief Bus error interrupt enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_BusErr_INT_En(__CAN__) SET_BIT((__CAN__)->ERRINT, CAN_BUS_ERR_INT_EN_Msk) + +/** + * @brief Bus error interrupt disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_BusErr_INT_Dis(__CAN__) CLEAR_BIT((__CAN__)->ERRINT, CAN_BUS_ERR_INT_EN_Msk) + +/** + * @brief Error interrupt status get + * @param __CAN__ Specifies CAN peripheral + * @return Error interrupt status + */ +#define __LL_CAN_ErrIntSta_Get(__CAN__) \ + (READ_BIT((__CAN__)->ERRINT, (CAN_ERR_PASS_INT_STA_Msk | CAN_ARB_LOST_INT_STA_Msk | CAN_BUS_ERR_INT_STA_Msk))) + + +/** + * @brief RX buffer almost full warning limit set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_RxBufAlmostFullLimit_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->LIMIT, CAN_RX_BUF_ALMOST_FULL_LIMIT_Msk, ((val & 0xfUL) << CAN_RX_BUF_ALMOST_FULL_LIMIT_Pos)) + +/** + * @brief Error warning limit set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_ErrWarnLimit_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->LIMIT, CAN_ERR_WARN_LIMIT_Msk, ((val & 0xfUL) << CAN_ERR_WARN_LIMIT_Pos)) + + +/** + * @brief Fast speed synchronization jump width set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_FS_SyncJumpWidth_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->BITTIME0, CAN_FS_SYNC_JUMP_WIDTH_Msk, ((val & 0x3UL) << CAN_FS_SYNC_JUMP_WIDTH_Pos)) + +/** + * @brief Slow speed bit timing segment1 set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_SS_BitTimingSeg1_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->BITTIME0, CAN_SS_SEG1_Msk, ((val & 0x3fUL) << CAN_SS_SEG1_Pos)) + + +/** + * @brief Fast speed bit timing segment2 set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_FS_BitTimingSeg2_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->BITTIME1, CAN_FS_SEG2_Msk, ((val & 0x7UL) << CAN_FS_SEG2_Pos)) + +/** + * @brief Slow speed bit timing segment2 set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_SS_BitTimingSeg2_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->BITTIME1, CAN_SS_SEG2_Msk, ((val & 0x1fUL) << CAN_SS_SEG2_Pos)) + + +/** + * @brief Fast speed bit timing segment1 set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_FS_BitTimingSeg1_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->BITTIME2, CAN_FS_SEG1_Msk, ((val & 0xfUL) << CAN_FS_SEG1_Pos)) + +/** + * @brief Slow speed synchronization jump width set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_SS_SyncJumpWidth_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->BITTIME2, CAN_SS_SYNC_JUMP_WIDTH_Msk, ((val & 0xfUL) << CAN_SS_SYNC_JUMP_WIDTH_Pos)) + + +/** + * @brief Slow speed prescaler set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_SS_Prescaler_Set(__CAN__,val) WRITE_REG((__CAN__)->S_PRESC, ((val) & CAN_SS_PRESCALER_Msk)) + + +/** + * @brief Fast speed prescaler set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_FS_Prescaler_Set(__CAN__,val) WRITE_REG((__CAN__)->F_PRESC, ((val) & CAN_FS_PRESCALER_Msk)) + + +/** + * @brief TX delay compensation enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxDelayComp_En(__CAN__) SET_BIT((__CAN__)->TDC, CAN_TX_DELAY_COMP_EN_Msk) + +/** + * @brief TX delay compensation disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_TxDelayComp_Dis(__CAN__) CLEAR_BIT((__CAN__)->TDC, CAN_TX_DELAY_COMP_EN_Msk) + +/** + * @brief Secondary sample point offset set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_SecSamplePointOffset_Set(__CAN__,val) \ + MODIFY_REG((__CAN__)->TDC, CAN_SEC_SAMPLE_POINT_OFFSET_Msk, ((val & 0x1f) << CAN_SEC_SAMPLE_POINT_OFFSET_Pos)) + + +/** + * @brief Error code get + * @param __CAN__ Specifies CAN peripheral + * @retval 0 no error + * @retval 1 bit error + * @retval 2 form error + * @retval 3 stuff error + * @retval 4 acknowledgement error + * @retval 5 CRC error + * @retval 6 other error + * @retval 7 not used + */ +#define __LL_CAN_ErrCode_Get(__CAN__) (READ_BIT((__CAN__)->EALCAP, CAN_ERR_CODE_Msk) >> CAN_ERR_CODE_Pos) + +/** + * @brief Arbitration lost capture get + * @param __CAN__ Specifies CAN peripheral + * @return bit position in the frame where the arbitration has been lost + */ +#define __LL_CAN_ArbLostCapture_Get(__CAN__) (READ_BIT((__CAN__)->EALCAP, CAN_ARB_LOST_CAPTURE_Msk) >> CAN_ARB_LOST_CAPTURE_Pos) + + +/** + * @brief RX error count get + * @param __CAN__ Specifies CAN peripheral + * @return RX error count + */ +#define __LL_CAN_RxErrCnt_Get(__CAN__) READ_REG((__CAN__)->RECNT) + + +/** + * @brief TX error count get + * @param __CAN__ Specifies CAN peripheral + * @return TX error count + */ +#define __LL_CAN_TxErrCnt_Get(__CAN__) READ_REG((__CAN__)->TECNT) + + +/** + * @brief Acceptance filter content select mask + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_AcceptFilContentSel_Mask(__CAN__) SET_BIT((__CAN__)->ACFCTRL, CAN_ACPT_FIL_CONTENT_SEL_Msk) + +/** + * @brief Acceptance filter content select code + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_AcceptFilContentSel_Code(__CAN__) CLEAR_BIT((__CAN__)->ACFCTRL, CAN_ACPT_FIL_CONTENT_SEL_Msk) + +/** + * @brief Acceptance filter address set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_AcceptFilAddr_Set(__CAN__, val) \ + MODIFY_REG((__CAN__)->ACFCTRL, CAN_ACPT_FIL_ADDR_Msk, ((val & 0xfUL) << CAN_ACPT_FIL_ADDR_Pos)) + + +/** + * @brief Acceptance filter enable + * @param __CAN__ Specifies CAN peripheral + * @param fil_num Acceptance filter slot number + * @note fil_num value range [0, 15] + * @return None + */ +#define __LL_CAN_AcceptFil_En(__CAN__, fil_num) \ + do { \ + if(fil_num < 8) { \ + MODIFY_REG((__CAN__)->ACF_EN_0, (0x1UL<ACF_EN_1, (0x1UL<<(fil_num-8)), (0x1UL<<(fil_num-8))); \ + } \ + } while(0) + + +/** + * @brief Acceptance mask IDE bit check enable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_AcceptFilMaskIDE_En(__CAN__) SET_BIT((__CAN__)->ACF, CAN_ACPT_MASK_IDE_CHK_EN_Msk) + +/** + * @brief Acceptance mask IDE bit check disable + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_AcceptFilMaskIDE_Dis(__CAN__) CLEAR_BIT((__CAN__)->ACF, CAN_ACPT_MASK_IDE_CHK_EN_Msk) + +/** + * @brief Acceptance filter accepts only extended frames + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_AcceptFilMaskIDESel_Ext(__CAN__) SET_BIT((__CAN__)->ACF, CAN_ACPT_MASK_IDE_BIT_VAL_Msk) + +/** + * @brief Acceptance filter accepts only standard frames + * @param __CAN__ Specifies CAN peripheral + * @return None + */ +#define __LL_CAN_AcceptFilMaskIDESel_Std(__CAN__) CLEAR_BIT((__CAN__)->ACF, CAN_ACPT_MASK_IDE_BIT_VAL_Msk) + +/** + * @brief Acceptance filter code or mask set + * @param __CAN__ Specifies CAN peripheral + * @param val set value + * @return None + */ +#define __LL_CAN_AcceptFilCodeOrMaskVal_Set(__CAN__, val) \ + MODIFY_REG((__CAN__)->ACF, CAN_ACPT_CODE_OR_MASK_Msk, ((val & 0x1fffffffUL) << CAN_ACPT_CODE_OR_MASK_Pos)) + + + +/** + * @brief CAN frame ID format to 11 bits + */ +#define __LL_CAN_FrameIDFormat_11Bits(n) ((n) & 0x7FFUL) + +/** + * @brief CAN frame ID format to 29 bits + */ +#define __LL_CAN_FrameIDFormat_29Bits(n) ((n) & 0x1FFFFFFFUL) + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup CAN_LL_Exported_Functions + * @{ + */ + +/** @addtogroup CAN_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_CAN_Init(CAN_TypeDef *Instance, CAN_UserCfgTypeDef *user_cfg); +LL_StatusETypeDef LL_CAN_DeInit(CAN_TypeDef *Instance); +void LL_CAN_MspInit(CAN_TypeDef *Instance); +void LL_CAN_MspDeInit(CAN_TypeDef *Instance); +/** + * @} + */ + +/** @addtogroup CAN_LL_Exported_Functions_Group2 + * @{ + */ +uint32_t LL_CAN_SendStandard_PTB(CAN_TypeDef *Instance, CAN_TxBufFormatTypeDef *buf_fmt, uint32_t *buf); +uint32_t LL_CAN_SendStandard_STB(CAN_TypeDef *Instance, CAN_TxBufFormatTypeDef *buf_fmt, uint32_t *buf); +uint32_t LL_CAN_SendStandard_STB_Multi(CAN_TypeDef *Instance, CAN_TxBufFormatTypeDef *buf_fmt, + uint32_t *buf, uint32_t send_cnt); +/** + * @} + */ + +/** @addtogroup CAN_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_CAN_IRQHandler(CAN_TypeDef *Instance); + +void LL_CAN_RxCallback(CAN_TypeDef *Instance); +void LL_CAN_RxOverCallback(CAN_TypeDef *Instance); +void LL_CAN_RxFullCallback(CAN_TypeDef *Instance); +void LL_CAN_RxAlmostFullCallback(CAN_TypeDef *Instance); +void LL_CAN_TxPriCallback(CAN_TypeDef *Instance); +void LL_CAN_TxSecCallback(CAN_TypeDef *Instance); +void LL_CAN_ErrCallback(CAN_TypeDef *Instance); +void LL_CAN_AbortCallback(CAN_TypeDef *Instance); + +void LL_CAN_ErrPassiveCallback(CAN_TypeDef *Instance); +void LL_CAN_ArbLostCallback(CAN_TypeDef *Instance); +void LL_CAN_BusErrCallback(CAN_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + +/* Private constants ---------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_CAN_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_cmp.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_cmp.h new file mode 100644 index 0000000000..d5ccc24284 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_cmp.h @@ -0,0 +1,570 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_cmp.h + * @author MCD Application Team + * @brief Header file for CMP Module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_CMP_H_ +#define _TAE32F53XX_LL_CMP_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup CMP_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup CMP_LL_Exported_Constants CMP LL Exported Constants + * @brief CMP LL Exported Constants + * @{ + */ + +/** @defgroup CMP_Channel_selection CMP Channel selection + * @{ + */ +#define CMP_CHANNEL_0 (0x00000001U) +#define CMP_CHANNEL_1 (0x00000002U) +#define CMP_CHANNEL_2 (0x00000004U) +#define CMP_CHANNEL_3 (0x00000008U) +#define CMP_CHANNEL_ALL (CMP_CHANNEL_0 | CMP_CHANNEL_1 | CMP_CHANNEL_2 | CMP_CHANNEL_3 ) +/** + * @} + */ + +/** @defgroup CMP_Interrupt_definition CMP Interrupt definition + * @{ + */ +#define CMP_IT_FALIE CMP_CR_FALIE /*!< CMP_CHx failing edge interrupt */ +#define CMP_IT_RISIE CMP_CR_RISIE /*!< CMP_CHx rising edge interrupt */ +/** + * @} + */ + +/** @defgroup CMP_Flag_definition CMP Flag Definition + * @{ + */ +#define CMP_FLAG_FAL3IF CMP_SR_FALIF_3 +#define CMP_FLAG_FAL2IF CMP_SR_FALIF_2 +#define CMP_FLAG_FAL1IF CMP_SR_FALIF_1 +#define CMP_FLAG_FAL0IF CMP_SR_FALIF_0 +#define CMP_FLAG_RIS3IF CMP_SR_RISIF_3 +#define CMP_FLAG_RIS2IF CMP_SR_RISIF_2 +#define CMP_FLAG_RIS1IF CMP_SR_RISIF_1 +#define CMP_FLAG_RIS0IF CMP_SR_RISIF_0 +#define CMP_FLAG_ALLIF (CMP_SR_FALIF_3 | CMP_SR_FALIF_2 | \ + CMP_SR_FALIF_1 | CMP_SR_FALIF_0 | \ + CMP_SR_RISIF_3 | CMP_SR_RISIF_2 | \ + CMP_SR_RISIF_1 | CMP_SR_RISIF_0) +/** + * @} + */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup CMP_LL_Exported_Macros CMP LL Exported Macros + * @brief CMP LL Exported Macros + * @{ + */ + +/** + * @brief Enable CMP Channel + * @param __INSTANCE__ CMP peripheral + * @param __CHN_NB__ Specifies CMP Channel + * This parameter can be a value of 0 to (CMP_CHN_NB - 1) + * @return None + */ +#define __LL_CMP_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], CMP_CR_PEN) + +/** + * @brief Disable CMP Channel + * @param __INSTANCE__ CMP peripheral + * @param __CHN_NB__ Specifies CMP Channel + * This parameter can be a value of 0 to (CMP_CHN_NB - 1) + * @return None + */ +#define __LL_CMP_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], CMP_CR_PEN) + +/** + * @brief Enable the specified CMP Channel Interrupts + * @param __INSTANCE__ CMP peripheral + * @param __CHN_NB__ Specifies CMP Channel + * This parameter can be a value of 0 to (CMP_CHN_NB - 1) + * @param __INTERRUPT__ specifies the CMP Channel interrupt source to enable. + * This parameter can be any combination of @ref CMP_Interrupt_definition: + * @arg CMP_IT_FALIE : CMP_CHx failing edge interrupt + * @arg CMP_IT_RISIE : CMP_CHx rising edge interrupt + * @return None + */ +#define __LL_CMP_IT_ENABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__)) + +/** + * @brief Disable the specified CMP Channel Interrupts + * @param __INSTANCE__ CMP peripheral + * @param __CHN_NB__ Specifies CMP Channel + * This parameter can be a value of 0 to (CMP_CHN_NB - 1) + * @param __INTERRUPT__ specifies the CMP Channel interrupt source to disable. + * This parameter can be any combination of @ref CMP_Interrupt_definition: + * @arg CMP_IT_FALIE : CMP_CHx failing edge interrupt + * @arg CMP_IT_RISIE : CMP_CHx rising edge interrupt + * @return None + */ +#define __LL_CMP_IT_DISABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__)) + + +/** + * @brief Check whether the specified CMP Channel interrupt source is set or not. + * @param __INSTANCE__ CMP peripheral + * @param __CHN_NB__ Specifies CMP Channel + * This parameter can be a value of 0 to (CMP_CHN_NB - 1) + * @param __INTERRUPT__ specifies the CMP Channel interrupt source to check. + * This parameter can be ONE of @ref CMP_Interrupt_definition: + * @arg CMP_IT_FALIE : CMP_CHx failing edge interrupt + * @arg CMP_IT_RISIE : CMP_CHx rising edge interrupt + * @return None + */ +#define __LL_CMP_IT_CHECK_SOURCE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) \ + ((READ_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** + * @brief Check whether the specified pending flag is SET or not. + * @param __INSTANCE__ CMP peripheral. + * @param __FLAG__ specifies the CMP pending flag to check. + * This parameter can be ONE of the following values where x can be a value of + * 0, 1 ... (CMP_CHN_NB - 1): + * @arg CMP_FLAG_FALxIF : CMP_CHx failing edge interrupt pending flag + * @arg CMP_FLAG_RISxIF : CMP_CHx rising interrupt pending flag + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_CMP_PENDING_FLAG_GET(__INSTANCE__, __FLAG__) ((READ_BIT((__INSTANCE__)->SR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Clear the specified pending flags + * @param __INSTANCE__ CMP peripheral. + * @param __FLAG__ specifies the CMP pending flag to clear. + * This parameter can be any combination of the following values where x can be a value of + * 0, 1 ... (CMP_CHN_NB - 1): + * @arg CMP_FLAG_FALxIF : CMP_CHx failing edge interrupt pending flag + * @arg CMP_FLAG_RISxIF : CMP_CHx rising interrupt pending flag + * @arg CMP_FLAG_ALLIF : CMP All interrupt pending flags + * @return None + */ +#define __LL_CMP_PENDING_FLAG_CLEAR(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->SR, (__FLAG__)) + + +/** + * @brief Set the specified CMP Channel output debounce value + * @param __INSTANCE__ CMP peripheral. + * @param __CHN_NB__ Specifies CMP Channel + * This parameter can be a value of 0 to (CMP_CHN_NB - 1) + * @param __VAL__ Specifies debounce value + * This value can be a range from 0 - 0xFFF (in System Clocks) + * @return None + */ +#define __LL_CMP_DEBOUNCE_VALUE_SET(__INSTANCE__, __CHN_NB__, __VAL__) WRITE_REG((__INSTANCE__)->DEBR[__CHN_NB__], (__VAL__)) + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup CMP_LL_Exported_Types CMP LL Exported Types + * @brief CMP LL Exported Types + * @{ + */ + +/** + * @brief CMP input minus (INM) + */ +typedef enum { + CMP_INPUT_MINUS_GND = 0x0U, + /*!< Comparator input minus connected to GND */ + CMP_INPUT_MINUS_IO1 = CMP_CR_INM_0, + /*!< Comparator input minus connected to IO1, Note: For CMPx instance availability, please refer to SPEC Document */ + CMP_INPUT_MINUS_IO2 = CMP_CR_INM_1, + /*!< Comparator input minus connected to IO2, Note: For CMPx instance availability, please refer to SPEC Document */ + CMP_INPUT_MINUS_DAC = CMP_CR_INM_1 | CMP_CR_INM_0, + /*!< Comparator input minus connected to DAC Channel x for CMP Channel x. + Note: For CMPx & DACx instances availability, please refer to SPEC Document */ +} CMP_InputMinusETypeDef; + +/** + * @brief CMP Hysteresis + */ +typedef enum { + CMP_HYSTERESIS_NONE = 0x0U, /*!< No hysteresis */ + CMP_HYSTERESIS_10MV = CMP_CR_HYST_0, /*!< Hysteresis level 10mV */ + CMP_HYSTERESIS_20MV = CMP_CR_HYST_1, /*!< Hysteresis level 20mV */ + CMP_HYSTERESIS_30MV = CMP_CR_HYST_1 | CMP_CR_HYST_0, /*!< Hysteresis level 30mV */ +} CMP_HysteresisETypeDef; + +/** + * @brief CMP Blanking Source + * @note For CMPx & TMRx instances availability, please refer to SPEC Document + */ +typedef enum { + CMP_BLANKINGSRC_NONE = 0x00000000U, + + CMP_BLANKINGSRC_TMR0_PWM_CMP0 = CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR0_PWM (specific to CMP Channel0). */ + CMP_BLANKINGSRC_TMR1_PWM_CMP1 = CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel1). */ + CMP_BLANKINGSRC_TMR0_PWM_CMP2 = CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR0_PWM (specific to CMP Channel2). */ + CMP_BLANKINGSRC_TMR1_PWM_CMP3 = CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel3). */ + + CMP_BLANKINGSRC_TMR1_PWM_CMP0 = CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel0). */ + CMP_BLANKINGSRC_TMR2_PWM_CMP1 = CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel1). */ + CMP_BLANKINGSRC_TMR1_PWM_CMP2 = CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR1_PWM (specific to CMP Channel2). */ + CMP_BLANKINGSRC_TMR2_PWM_CMP3 = CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel3). */ + + CMP_BLANKINGSRC_TMR2_PWM_CMP0 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel0). */ + CMP_BLANKINGSRC_TMR3_PWM_CMP1 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel1). */ + CMP_BLANKINGSRC_TMR2_PWM_CMP2 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR2_PWM (specific to CMP Channel2). */ + CMP_BLANKINGSRC_TMR3_PWM_CMP3 = CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel3). */ + + CMP_BLANKINGSRC_TMR3_PWM_CMP0 = CMP_CR_BLANKING_2, + /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel0). */ + CMP_BLANKINGSRC_TMR4_PWM_CMP1 = CMP_CR_BLANKING_2, + /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel1). */ + CMP_BLANKINGSRC_TMR3_PWM_CMP2 = CMP_CR_BLANKING_2, + /*!< CMP output blanking source TMR3_PWM (specific to CMP Channel2). */ + CMP_BLANKINGSRC_TMR4_PWM_CMP3 = CMP_CR_BLANKING_2, + /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel3). */ + + CMP_BLANKINGSRC_TMR4_PWM_CMP0 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel0). */ + CMP_BLANKINGSRC_TMR5_PWM_CMP1 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel1). */ + CMP_BLANKINGSRC_TMR4_PWM_CMP2 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR4_PWM (specific to CMP Channel2). */ + CMP_BLANKINGSRC_TMR5_PWM_CMP3 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel3). */ + + CMP_BLANKINGSRC_TMR5_PWM_CMP0 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel0). */ + CMP_BLANKINGSRC_TMR6_PWM_CMP1 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel1). */ + CMP_BLANKINGSRC_TMR5_PWM_CMP2 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR5_PWM (specific to CMP Channel2). */ + CMP_BLANKINGSRC_TMR6_PWM_CMP3 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1, + /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel3). */ + + CMP_BLANKINGSRC_TMR6_PWM_CMP0 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel0). */ + CMP_BLANKINGSRC_TMR7_PWM_CMP1 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR7_PWM (specific to CMP Channel1). */ + CMP_BLANKINGSRC_TMR6_PWM_CMP2 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR6_PWM (specific to CMP Channel2). */ + CMP_BLANKINGSRC_TMR7_PWM_CMP3 = CMP_CR_BLANKING_2 | CMP_CR_BLANKING_1 | CMP_CR_BLANKING_0, + /*!< CMP output blanking source TMR7_PWM (specific to CMP Channel3). */ +} CMP_BlankingSrcETypeDef; + +/** + * @brief CMP Output Debounce + */ +typedef enum { + CMP_OUTPUT_DEBOUNCE_DISABLE = 0x0U, /*!< Disable CMP output debounce */ + CMP_OUTPUT_DEBOUNCE_ENABLE = CMP_CR_ODEB, /*!< Enable CMP output debounce */ +} CMP_OutputDebounceETypeDef; + +/** + * @brief CMP output polarity + */ +typedef enum { + CMP_OUPUT_POLARITY_NON_INVERTED = 0x0U, + /*!< CMP output level is not inverted. CMP output HIGH when the input plus(INP) is at a higher voltage than the input minus(INM) */ + CMP_OUPUT_POLARITY_INVERTED = CMP_CR_OPOL, + /*!< CMP output level is inverted. CMP output LOW when the input plus(INP) is at a higher voltage than the input minus(INM) */ +} CMP_OutputPolarityETypeDef; + +/** + * @brief CMP trigger interrupt + */ +typedef enum { + CMP_TRIGGER_IT_DISABLE = 0x00000000U, + /*!< CMP output triggering event without interrupt */ + CMP_TRIGGER_IT_FALLING = CMP_CR_FALIE, + /*!< CMP output triggering event with interrupt on falling edge */ + CMP_TRIGGER_IT_RISING = CMP_CR_RISIE, + /*!< CMP output triggering event with interrupt on rising edge */ + CMP_TRIGGER_IT_RISING_FALLING = CMP_CR_RISIE | CMP_CR_FALIE, + /*!< CMP output triggering event with interrupt on both rising and falling edges */ +} CMP_TriggerITETypeDef; + + +/** + * @brief CMP Channel Configuration structure definition + */ +typedef struct __CMP_ChannelConfTypeDef { + CMP_InputMinusETypeDef InputMinus; /*!< Set comparator input minus (INM). */ + CMP_HysteresisETypeDef Hysteresis; /*!< Set comparator hysteresis mode of the input minus(INM). */ + CMP_BlankingSrcETypeDef BlankingSource; /*!< Set comparator blanking source. */ + CMP_OutputDebounceETypeDef OutputDebounce; /*!< Set comparator output debounce. */ + CMP_OutputPolarityETypeDef OutputPolarity; /*!< Set comparator output polarity. */ + CMP_TriggerITETypeDef TriggerInterrupt; /*!< Set the comparator output triggering with or without interrupt. */ + + uint32_t OutputDebounceValue; /*!< Set comparator output debounce vaule. This Should be configured when + Output Debounce is enabled. + this value can be a range from 0 - 0xFFF (in System Clocks) */ +} CMP_ChannelConfTypeDef; + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup CMP_LL_Exported_Functions + * @{ + */ + +/** @addtogroup CMP_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_CMP_Init(CMP_TypeDef *Instance); +LL_StatusETypeDef LL_CMP_DeInit(CMP_TypeDef *Instance); +void LL_CMP_MspInit(CMP_TypeDef *Instance); +void LL_CMP_MspDeInit(CMP_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup CMP_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_CMP_ChannelConfig(CMP_TypeDef *Instance, uint32_t Channel, CMP_ChannelConfTypeDef *sConfig); +/** + * @} + */ + + +/** @addtogroup CMP_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_CMP_Start(CMP_TypeDef *Instance, uint32_t Channel); +LL_StatusETypeDef LL_CMP_Stop(CMP_TypeDef *Instance, uint32_t Channel); +/** + * @} + */ + + +/** @addtogroup CMP_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_CMP_IRQHandler(CMP_TypeDef *Instance); +void LL_CMP_FailingEdgeTrigCallback(CMP_TypeDef *Instance, uint32_t Channel); +void LL_CMP_RisingEdgeTrigCallback(CMP_TypeDef *Instance, uint32_t Channel); +/** + * @} + */ + +/** + * @} + */ + + +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup CMP_LL_Private_Macros CMP LL Private Macros + * @brief CMP LL Private Macros + * @{ + */ + +/** + * @brief Judge is CMP channel number or not + * @param CHN_NB channel number to judge + * @retval 0 isn't CMP channel number + * @retval 1 is CMP channel number + */ +#define IS_CMP_NUMBER(CHN_NB) ((CHN_NB) < CMP_CHN_NB) + +/** + * @brief Judge is CMP Channel or not + * @param CHN Channel to judge + * @retval 0 isn't CMP Channel + * @retval 1 is CMP Channel + */ +#define IS_CMP_CHANNEL(CHN) (((CHN) == CMP_CHANNEL_0) || \ + ((CHN) == CMP_CHANNEL_1) || \ + ((CHN) == CMP_CHANNEL_2) || \ + ((CHN) == CMP_CHANNEL_3)) + +/** + * @brief Judge is CMP input minus or not + * @param INM input minus to judge + * @retval 0 isn't CMP input minus + * @retval 1 is CMP input minus + */ +#define IS_CMP_INPUT_MINUS(INM) (((INM) == CMP_INPUT_MINUS_GND) || \ + ((INM) == CMP_INPUT_MINUS_IO1) || \ + ((INM) == CMP_INPUT_MINUS_IO2) || \ + ((INM) == CMP_INPUT_MINUS_DAC)) + +/** + * @brief Judge is CMP hysteresis or not + * @param HYST hysteresis to judge + * @retval 0 isn't CMP hysteresis + * @retval 1 is CMP hysteresis + */ +#define IS_CMP_HYSTERESIS(HYST) (((HYST) == CMP_HYSTERESIS_NONE) || \ + ((HYST) == CMP_HYSTERESIS_10MV) || \ + ((HYST) == CMP_HYSTERESIS_20MV) || \ + ((HYST) == CMP_HYSTERESIS_30MV)) + +/** + * @brief Judge is CMP blanking source or not + * @param CHN CMP channel to judge + * @param BLANKING blanking to judge + * @retval 0 isn't CMP blanking source + * @retval 1 is CMP blanking source + */ +#define IS_CMP_BLANKING_SOURCE(CHN, BLANKING) ( \ + (((CHN) == CMP_CHANNEL_0) && \ + (((BLANKING) == CMP_BLANKINGSRC_NONE) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR0_PWM_CMP0) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP0) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP0) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP0) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP0) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP0) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP0))) \ + || \ + (((CHN) == CMP_CHANNEL_1) && \ + (((BLANKING) == CMP_BLANKINGSRC_NONE) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP1) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP1) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP1) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP1) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP1) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP1) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR7_PWM_CMP1))) \ + || \ + (((CHN) == CMP_CHANNEL_2) && \ + (((BLANKING) == CMP_BLANKINGSRC_NONE) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR0_PWM_CMP2) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP2) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP2) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP2) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP2) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP2) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP2))) \ + || \ + (((CHN) == CMP_CHANNEL_3) && \ + (((BLANKING) == CMP_BLANKINGSRC_NONE) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR1_PWM_CMP3) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR2_PWM_CMP3) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR3_PWM_CMP3) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR4_PWM_CMP3) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR5_PWM_CMP3) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR6_PWM_CMP3) || \ + ((BLANKING) == CMP_BLANKINGSRC_TMR7_PWM_CMP3))) \ + ) + +/** + * @brief Judge is CMP output debounce or not + * @param DEB debounce to judge + * @retval 0 isn't CMP output debounce + * @retval 1 is CMP output debounce + */ +#define IS_CMP_OUTPUT_DEBOUNCE(DEB) (((DEB) == CMP_OUTPUT_DEBOUNCE_DISABLE) || \ + ((DEB) == CMP_OUTPUT_DEBOUNCE_ENABLE)) + +/** + * @brief Jugdge is CMP output debounce value or not + * @param VAL value to judge + * @retval 0 isn't CMP output debounce value + * @retval 1 is CMP output debounce value + */ +#define IS_CMP_OUTPUT_DEBOUNCE_VAL(VAL) ((VAL) <= 0xFFFUL) + + +/** + * @brief Jugdge is CMP output debounce polarity or not + * @param POL polarity to judge + * @retval 0 isn't CMP output debounce polarity + * @retval 1 is CMP output debounce polarity + */ +#define IS_CMP_OUTPUT_POLARITY(POL) (((POL) == CMP_OUPUT_POLARITY_NON_INVERTED) || \ + ((POL) == CMP_OUPUT_POLARITY_INVERTED)) + +/** + * @brief Judge is CMP trigger interrupt or not + * @param INTERRUPT trigger interrupt to judge + * @retval 0 isn't CMP trigger interrupt + * @retval 1 is CMP trigger interrupt + */ +#define IS_CMP_TRIGGER_IT(INTERRUPT) (((INTERRUPT) == CMP_TRIGGER_IT_DISABLE) || \ + ((INTERRUPT) == CMP_TRIGGER_IT_FALLING) || \ + ((INTERRUPT) == CMP_TRIGGER_IT_RISING) || \ + ((INTERRUPT) == CMP_TRIGGER_IT_RISING_FALLING)) + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_CMP_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_cortex.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_cortex.h new file mode 100644 index 0000000000..5e4c0a8bc5 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_cortex.h @@ -0,0 +1,208 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_cortex.h + * @author MCD Application Team + * @brief Head file for CORTEX LL module driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_CORTEX_H_ +#define _TAE32F53XX_LL_CORTEX_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup CORTEX_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/** @defgroup CORTEX_LL_Exported_Constants CORTEX LL Exported Constants + * @brief CORTEX LL Exported Constants + * @{ + */ + +/** @defgroup CORTEX_Preemption_Priority_Group CORTEX Preemption Priority Group + * @{ + */ +#define NVIC_PRIORITYGROUP_0 0x00000007U /*!< 0 bit for pre-emption priority, 3 bits for subpriority */ +#define NVIC_PRIORITYGROUP_1 0x00000006U /*!< 1 bit for pre-emption priority, 2 bits for subpriority */ +#define NVIC_PRIORITYGROUP_2 0x00000005U /*!< 2 bits for pre-emption priority, 1 bit for subpriority */ +#define NVIC_PRIORITYGROUP_3 0x00000004U /*!< 3 bits for pre-emption priority, 0 bit for subpriority */ +/** + * @} + */ + +/** @defgroup CORTEX_SysTick_Clock_Source CORTEX SysTick Clock Source + * @brief CORTEX SysTick Clock Source + * @{ + */ +#define SYSTICK_CLKSOURCE_HCLK_DIV8 0x00000000U /*!< SYSTICK Clock Source HCLK Div8 */ +#define SYSTICK_CLKSOURCE_HCLK 0x00000004U /*!< SYSTICK Clock Source HCLK */ +/** + * @} + */ + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup CORTEX_LL_Exported_Functions + * @{ + */ + +/** @addtogroup CORTEX_LL_Exported_Functions_Group1 + * @{ + */ +void LL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup); +uint32_t LL_NVIC_GetPriorityGrouping(void); +void LL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority); +void LL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority); +/** + * @} + */ + + +/** @addtogroup CORTEX_LL_Exported_Functions_Group2 + * @{ + */ +void LL_NVIC_EnableIRQ(IRQn_Type IRQn); +void LL_NVIC_DisableIRQ(IRQn_Type IRQn); +void LL_NVIC_SetPendingIRQ(IRQn_Type IRQn); +uint32_t LL_NVIC_GetPendingIRQ(IRQn_Type IRQn); +void LL_NVIC_ClearPendingIRQ(IRQn_Type IRQn); +uint32_t LL_NVIC_GetActive(IRQn_Type IRQn); +void LL_NVIC_SystemReset(void); +/** + * @} + */ + + +/** @addtogroup CORTEX_LL_Exported_Functions_Group3 + * @{ + */ +void LL_SYSTICK_CLKSourceConfig(uint32_t CLKSource); +uint32_t LL_SYSTICK_Config(uint32_t TicksNumb); +/** + * @} + */ + + +/** @addtogroup CORTEX_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_SYSTICK_IRQHandler(void); +void LL_SYSTICK_Callback(void); +/** + * @} + */ + + +/** + * @} + */ + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup CORTEX_LL_Private_Macros CORTEX LL Private Macros + * @brief CORTEX LL Private Macros + * @{ + */ + +/** + * @brief Judge is NVIC priority group or not + * @param GROUP priority group to judge + * @retval 0 isn't NVIC priority group + * @retval 1 is NVIC priority group + */ +#define IS_NVIC_PRIORITY_GROUP(GROUP) (((GROUP) == NVIC_PRIORITYGROUP_0) || \ + ((GROUP) == NVIC_PRIORITYGROUP_1) || \ + ((GROUP) == NVIC_PRIORITYGROUP_2) || \ + ((GROUP) == NVIC_PRIORITYGROUP_3)) + +/** + * @brief Judge is NVIC preemption priority or not + * @param PRIORITY preemption priority to judge + * @retval 0 isn't NVIC preemption priority + * @retval 1 is NVIC preemption priority + */ +#define IS_NVIC_PREEMPTION_PRIORITY(PRIORITY) ((PRIORITY) < 0x10U) + +/** + * @brief Judge is NVIC SubPriority or not + * @param PRIORITY SubPriority to judge + * @retval 0 isn't NVIC SubPriority + * @retval 1 is NVIC SubPriority + */ +#define IS_NVIC_SUB_PRIORITY(PRIORITY) ((PRIORITY) < 0x10U) + +/** + * @brief Judge is NVIC device IRQ or not + * @param IRQ IRQ to judge + * @retval 0 isn't NVIC device IRQ + * @retval 1 is NVIC device IRQ + */ +#define IS_NVIC_DEVICE_IRQ(IRQ) ((IRQ) >= (IRQn_Type)0x00U) + +/** + * @brief Judge is SYSTICK clock source or not + * @param SOURCE clock source to judge + * @retval 0 isn't SYSTICK clock source + * @retval 1 is SYSTICK clock source + */ +#define IS_SYSTICK_CLK_SOURCE(SOURCE) (((SOURCE) == SYSTICK_CLKSOURCE_HCLK) || ((SOURCE) == SYSTICK_CLKSOURCE_HCLK_DIV8)) +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_CORTEX_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dac.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dac.h new file mode 100644 index 0000000000..bb589b0394 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dac.h @@ -0,0 +1,606 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dac.h + * @author MCD Application Team + * @brief Header file for DAC Module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_DAC_H_ +#define _TAE32F53XX_LL_DAC_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup DAC_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup DAC_LL_Exported_Constants DAC LL Exported Constants + * @brief DAC LL Exported Constants + * @{ + */ + +/** @defgroup DAC_Channel_selection DAC Channel selection + * @brief DAC Channel selection + * @{ + */ +#define DAC_CHANNEL_0 (0x00000001U) /*!< DAC Channel 0 */ +#define DAC_CHANNEL_1 (0x00000002U) /*!< DAC Channel 1 */ +#define DAC_CHANNEL_2 (0x00000004U) /*!< DAC Channel 2 */ +#define DAC_CHANNEL_3 (0x00000008U) /*!< DAC Channel 3 */ +#define DAC_CHANNEL_ALL (DAC_CHANNEL_0 | DAC_CHANNEL_1 | DAC_CHANNEL_2 | DAC_CHANNEL_3 ) +/** + * @} + */ + +/** @defgroup DAC_Interrupt_definition DAC Interrupt definition + * @brief DAC Interrupt definition + * @{ + */ +#define DAC_IT_DIE DAC_CR_DIE /*!< DAC_CHx DONE interrupt */ +#define DAC_IT_DBIE DAC_CR_DBIE /*!< DAC_CHx DONEB interrupt */ +/** + * @} + */ + +/** @defgroup DAC_Flag_definition DAC Flag Definition + * @{ + */ +#define DAC_FLAG_D0IF DAC_ISR_D0IF /*!< DAC Channel0 DONE pending flag */ +#define DAC_FLAG_D1IF DAC_ISR_D1IF /*!< DAC Channel1 DONE pending flag */ +#define DAC_FLAG_D2IF DAC_ISR_D2IF /*!< DAC Channel2 DONE pending flag */ +#define DAC_FLAG_D3IF DAC_ISR_D3IF /*!< DAC Channel0 DONE pending flag */ +#define DAC_FLAG_DB0IF DAC_ISR_DB0IF /*!< DAC Channel0 DONEB pending flag */ +#define DAC_FLAG_DB1IF DAC_ISR_DB1IF /*!< DAC Channel1 DONEB pending flag */ +#define DAC_FLAG_DB2IF DAC_ISR_DB2IF /*!< DAC Channel2 DONEB pending flag */ +#define DAC_FLAG_DB3IF DAC_ISR_DB3IF /*!< DAC Channel3 DONEB pending flag */ +#define DAC_FLAG_ALLIF (DAC_FLAG_D0IF | DAC_FLAG_D1IF | \ + DAC_FLAG_D2IF | DAC_FLAG_D3IF | \ + DAC_FLAG_DB0IF | DAC_FLAG_DB1IF | \ + DAC_FLAG_DB2IF | DAC_FLAG_DB3IF ) +/** + * @} + */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup DAC_LL_Exported_Macros DAC LL Exported Macros + * @brief DAC LL Exported Macros + * @{ + */ + +/** + * @brief Enable DAC Channel + * @param __INSTANCE__ DAC peripheral + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @return None + */ +#define __LL_DAC_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_PEN) + +/** + * @brief Disable DAC Channel + * @param __INSTANCE__ DAC peripheral + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @return None + */ +#define __LL_DAC_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_PEN) + + +/** + * @brief Enable DAC Channel Output to IO feature + * @param __INSTANCE__ DAC peripheral + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @return None + */ +#define __LL_DAC_OUTPUT_ENABLE(__INSTANCE__, __CHN_NB__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_OEN) + +/** + * @brief Disable DAC Channel Output to IO feature + * @param __INSTANCE__ DAC peripheral + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @return None + */ +#define __LL_DAC_OUTPUT_DISABLE(__INSTANCE__, __CHN_NB__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], DAC_CR_OEN) + +/** + * @brief Enable the specified DAC Channel Interrupts + * @param __INSTANCE__ DAC peripheral + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @param __INTERRUPT__ specifies the DAC Channel interrupt source to enable. + * This parameter can be any combination of @ref DAC_Interrupt_definition: + * @arg DAC_IT_DIE : DAC_CHx DONE interrupt + * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt + * @return None + */ +#define __LL_DAC_IT_ENABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR[__CHN_NB__], __INTERRUPT__) + +/** + * @brief Disable the specified DAC Channel Interrupts + * @param __INSTANCE__ DAC peripheral + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @param __INTERRUPT__ specifies the DAC Channel interrupt source to disable. + * This parameter can be any combination of @ref DAC_Interrupt_definition: + * @arg DAC_IT_DIE : DAC_CHx DONE interrupt + * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt + * @return None + */ +#define __LL_DAC_IT_DISABLE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR[__CHN_NB__], __INTERRUPT__) + +/** + * @brief Check whether the specified DAC Channel interrupt source is set or not. + * @param __INSTANCE__ DAC peripheral + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @param __INTERRUPT__ specifies the DAC Channel interrupt source to check. + * This parameter can be ONE of @ref DAC_Interrupt_definition: + * @arg DAC_IT_DIE : DAC_CHx DONE interrupt + * @arg DAC_IT_DBIE : DAC_CHx DONEB interrupt + * @return None + */ +#define __LL_DAC_IT_CHECK_SOURCE(__INSTANCE__, __CHN_NB__, __INTERRUPT__) \ + ((READ_BIT((__INSTANCE__)->CR[__CHN_NB__], (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** + * @brief Check whether the specified pending flag is SET or not. + * @param __INSTANCE__ DAC peripheral. + * @param __FLAG__ specifies the DAC pending flag to check. + * This parameter can be ONE of the following values where x can be a value of + * 0, 1 ... (DAC_CHN_NB - 1): + * @arg DAC_FLAG_DxIF : DAC_CHx DONE interrupt pending flag + * @arg DAC_FLAG_DBxIF : DAC_CHx DONEB interrupt pending flag + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_DAC_PENDING_FLAG_GET(__INSTANCE__, __FLAG__) \ + ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Clear the specified pending flags + * @param __INSTANCE__ DAC peripheral. + * @param __FLAG__ specifies the DAC pending flag to clear. + * This parameter can be any combination of the following values where x can be a value of + * 0, 1 ... (DAC_CHN_NB - 1): + * @arg DAC_FLAG_DxIF : DAC_CHx DONE interrupt pending flag + * @arg DAC_FLAG_DBxIF : DAC_CHx DONEB interrupt pending flag + * @arg DAC_FLAG_ALLIF : DAC All interrupt pending flags + * @return None + */ +#define __LL_DAC_PENDING_FLAG_CLEAR(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__)) + + +/** + * @brief Set the data for DAC channel conversion on runtime + * @param __INSTANCE__ DAC peripheral. + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @param __DATA__ Data to be loaded + * @return None + */ +#define __LL_DAC_SET_VALUE(__INSTANCE__, __CHN_NB__, __DATA__) WRITE_REG((__INSTANCE__)->WDR[__CHN_NB__], __DATA__) + + +/** + * @brief Get the DAC channel conversion value on runtime + * @param __INSTANCE__ DAC peripheral. + * @param __CHN_NB__ Specifies DAC Channel + * This parameter can be a value of 0 to (DAC_CHN_NB - 1) + * @return Conversion value + */ +#define __LL_DAC_GET_VALUE(__INSTANCE__, __CHN_NB__) READ_REG((__INSTANCE__)->RDR[__CHN_NB__]) + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup DAC_LL_Exported_Types DAC LL Exported Types + * @brief DAC LL Exported Types + * @{ + */ + +/** + * @brief DAC Channel Output + */ +typedef enum { + DAC_CHANNEL_OUTPUT_DISABLE = 0x00000000U, /*!< DAC Channel Disable */ + DAC_CHANNEL_OUTPUT_ENABLE = DAC_CR_OEN, /*!< DAC Channel Enable */ +} DAC_OutputEnETypedef; + +/** + * @brief DAC Channel Interrupt Done + */ +typedef enum { + DAC_CHANNEL_DONE_IT_DISABLE = 0x00000000U, /*!< DAC Channel Done Interrupt Disable */ + DAC_CHANNEL_DONE_IT_ENABLE = DAC_CR_DIE, /*!< DAC Channel Done Interrupt Enable */ +} DAC_DoneITEnETypedef; + +/** + * @brief DAC Channel Interrupt DoneB + */ +typedef enum { + DAC_CHANNEL_DONEB_IT_DISABLE = 0x00000000U, /*!< DAC Channel DoneB Interrupt Disable */ + DAC_CHANNEL_DONEB_IT_ENABLE = DAC_CR_DBIE, /*!< DAC Channel DoneB Interrupt Enable */ +} DAC_DoneBITEnETypedef; + +/** + * @brief DAC Sawtooth Polarity + */ +typedef enum { + DAC_SAWTOOTH_POLARITY_DEC = 0x00000000U, /*!< Sawtooth wave generation, polarity is decrement */ + DAC_SAWTOOTH_POLARITY_INC = DAC_CR_STDIR, /*!< Sawtooth wave generation, polarity is increment */ +} DAC_SawthoothPolETypedef; + +/** + * @brief DAC Triangle Initial Direction + */ +typedef enum { + DAC_TRIANGLE_INITIALDIRECTION_DEC = 0x00000000U, /*!< Triangle wave generation, initial direction is decrement */ + DAC_TRIANGLE_INITIALDIRECTION_INC = DAC_CR_TGDIR, /*!< Triangle wave generation, initial direction is increment */ +} DAC_TriangleInitDirETypedef; + +/** + * @brief DAC Triangle Amplitude + */ +typedef enum { + DAC_TRIANGLE_AMPLITUDE_1 = 0x00000000U, /*!< Amplitude of 1 */ + DAC_TRIANGLE_AMPLITUDE_3 = DAC_CR_TGAMP_0, /*!< Amplitude of 3 */ + DAC_TRIANGLE_AMPLITUDE_7 = DAC_CR_TGAMP_1, /*!< Amplitude of 7 */ + DAC_TRIANGLE_AMPLITUDE_15 = DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 15 */ + DAC_TRIANGLE_AMPLITUDE_31 = DAC_CR_TGAMP_2, /*!< Amplitude of 31 */ + DAC_TRIANGLE_AMPLITUDE_63 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_0, /*!< Amplitude of 63 */ + DAC_TRIANGLE_AMPLITUDE_127 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_1, /*!< Amplitude of 127 */ + DAC_TRIANGLE_AMPLITUDE_255 = DAC_CR_TGAMP_2 | DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 255 */ + DAC_TRIANGLE_AMPLITUDE_511 = DAC_CR_TGAMP_3, /*!< Amplitude of 511 */ + DAC_TRIANGLE_AMPLITUDE_1023 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_0, /*!< Amplitude of 1023 */ + DAC_TRIANGLE_AMPLITUDE_2047 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_1, /*!< Amplitude of 2047 */ + DAC_TRIANGLE_AMPLITUDE_4095 = DAC_CR_TGAMP_3 | DAC_CR_TGAMP_1 | DAC_CR_TGAMP_0, /*!< Amplitude of 4095 */ +} DAC_TrangleAmplETypedef; + +/** + * @brief DAC Trigger Selection + */ +typedef enum { + DAC_TRIGGER_SOFTWARE = 0x0U, /*!< Software trigger by setting bit[s] in DAC_SWTR register */ + DAC_TRIGGER_TMR0_TRGO = 0x1U, /*!< TRGO signal exported from TMR0 (source from Update Event) */ + DAC_TRIGGER_TMR1_TRGO = 0x2U, /*!< TRGO signal exported from TMR1 (source from Update Event) */ + DAC_TRIGGER_TMR2_TRGO = 0x3U, /*!< TRGO signal exported from TMR2 (source from Update Event) */ + DAC_TRIGGER_TMR3_TRGO = 0x3U, /*!< TRGO signal exported from TMR3 (source from Update Event) */ + DAC_TRIGGER_TMR4_TRGO = 0x4U, /*!< TRGO signal exported from TMR4 (source from Update Event) */ + DAC_TRIGGER_TMR5_TRGO = 0x5U, /*!< TRGO signal exported from TMR5 (source from Update Event) */ + DAC_TRIGGER_TMR6_TRGO = 0x6U, /*!< TRGO signal exported from TMR6 (source from Update Event) */ + DAC_TRIGGER_TMR7_TRGO = 0x7U, /*!< TRGO signal exported from TMR7 (source from Update Event) */ + DAC_TRIGGER_HRPWM_DAC_RESET_TRG0 = 0x8U, /*!< DAC Reset Trigger event from HRPWM Slave timer0 */ + DAC_TRIGGER_HRPWM_DAC_RESET_TRG1 = 0x9U, /*!< DAC Reset Trigger event from HRPWM Slave timer1 */ + DAC_TRIGGER_HRPWM_DAC_RESET_TRG2 = 0xAU, /*!< DAC Reset Trigger event from HRPWM Slave timer2 */ + DAC_TRIGGER_HRPWM_DAC_RESET_TRG3 = 0xBU, /*!< DAC Reset Trigger event from HRPWM Slave timer3 */ + DAC_TRIGGER_HRPWM_DAC_RESET_TRG4 = 0xCU, /*!< DAC Reset Trigger event from HRPWM Slave timer4 */ + DAC_TRIGGER_HRPWM_DAC_RESET_TRG5 = 0xDU, /*!< DAC Reset Trigger event from HRPWM Slave timer5 */ + DAC_TRIGGER_HRPWM_DAC_STEP_TRG0 = 0x8U, /*!< DAC Step Trigger event from HRPWM Slave timer0 */ + DAC_TRIGGER_HRPWM_DAC_STEP_TRG1 = 0x9U, /*!< DAC Step Trigger event from HRPWM Slave timer1 */ + DAC_TRIGGER_HRPWM_DAC_STEP_TRG2 = 0xAU, /*!< DAC Step Trigger event from HRPWM Slave timer2 */ + DAC_TRIGGER_HRPWM_DAC_STEP_TRG3 = 0xBU, /*!< DAC Step Trigger event from HRPWM Slave timer3 */ + DAC_TRIGGER_HRPWM_DAC_STEP_TRG4 = 0xCU, /*!< DAC Step Trigger event from HRPWM Slave timer4 */ + DAC_TRIGGER_HRPWM_DAC_STEP_TRG5 = 0xDU, /*!< DAC Step Trigger event from HRPWM Slave timer5 */ + DAC_TRIGGER_HRPWM_ADC_TRG0 = 0xEU, /*!< DAC0 Step Trigger event from HRPWM Common ADDA Trigger 0 */ + DAC_TRIGGER_HRPWM_ADC_TRG1 = 0xEU, /*!< DAC1 Step Trigger event from HRPWM Common ADDA Trigger 1 */ + DAC_TRIGGER_HRPWM_ADC_TRG2 = 0xEU, /*!< DAC2 Step Trigger event from HRPWM Common ADDA Trigger 2 */ + DAC_TRIGGER_HRPWM_ADC_TRG3 = 0xEU, /*!< DAC3 Step Trigger event from HRPWM Common ADDA Trigger 3 */ + DAC_TRIGGER_HRPWM_ADC_TRG4 = 0xEU, /*!< DAC0 Reset Trigger event from HRPWM Common ADDA Trigger 4 */ + DAC_TRIGGER_HRPWM_ADC_TRG5 = 0xEU, /*!< DAC1 Reset Trigger event from HRPWM Common ADDA Trigger 5 */ + DAC_TRIGGER_HRPWM_ADC_TRG6 = 0xEU, /*!< DAC2 Reset Trigger event from HRPWM Common ADDA Trigger 6 */ + DAC_TRIGGER_HRPWM_ADC_TRG7 = 0xEU, /*!< DAC3 Reset Trigger event from HRPWM Common ADDA Trigger 7 */ + DAC_TRIGGER_EXTERNAL_INPUT_IO1 = 0xFU, /*!< DAC External Trigger from IO1, please see SPEC from more details */ + DAC_TRIGGER_EXTERNAL_INPUT_IO2 = 0xFU, /*!< DAC External Trigger from IO2, please see SPEC from more details */ +} DAC_TriggerSrcETypedef; + + +/** + * @brief DAC Channel Configuration structure definition + */ +typedef struct __DAC_ChannelConfTypeDef { + DAC_OutputEnETypedef Output; /*!< Specifies the DAC conversion output to IO or not. */ + + uint32_t DoneIntPending; /*!< Specifies the interrupt for DONE pending flag enable or disable + This parameter can be a value of @ref DAC_Channel_Interrupt_Done + Note: Sawtooth Reset or Tranigle Step convert done will trigger the DONE flag */ + + uint32_t DoneBIntPending; /*!< Specifies the interrupt for DONEB pending flag enable or disable + This parameter can be a value of @ref DAC_Channel_Interrupt_DoneB + Note: Sawtooth Step convert done will trigger the DONEB flag */ +} DAC_ChannelConfTypeDef; + +/** + * @brief DAC Sawtooth Wave Configuration structure definition + */ +typedef struct __DAC_SawtoothConfTypeDef { + uint16_t ResetData; /*!< Specifies the Sawtooth wave Reset value. + This parameter can be a number in range from 0 to DAC full range 4095(0xFFF) */ + + uint16_t StepData; /*!< Specifies the Sawtooth wave step value. + 12.4 bit format, unsigned: 12 bits exponent / 4 bits mantissa + Step value step is 1/16 = 0.0625 + Step value range is 0.0000 to 4095.9375 (0xFFF.F) */ + + DAC_TriggerSrcETypedef ResetTrigger; /*!< Specifies the external trigger source for the Sawtooth wave reset trigger + Please see the SPEC Document for more details about the trigger selections */ + DAC_TriggerSrcETypedef StepTrigger; /*!< Specifies the external trigger source for the Sawtooth wave step trigger + Please see the SPEC Document for more details about the trigger selections */ + DAC_SawthoothPolETypedef Polarity; /*!< Specifies the Sawtooth wave step polarity.*/ +} DAC_SawtoothConfTypeDef; + +/** + * @brief DAC Triangle Wave Configuration structure definition + */ +typedef struct __DAC_TriangleConfTypeDef { + DAC_TriangleInitDirETypedef InitialDirection; /*!< Specifies the Triangle wave initial step direction. */ + DAC_TrangleAmplETypedef Amplitude; /*!< Specifies max triangle amplitude. */ + DAC_TriggerSrcETypedef StepTrigger; /*!< Specifies the external trigger source for the Triangle wave step trigger + Please see the SPEC Document for more details about the trigger selections */ +} DAC_TriangleConfTypeDef; + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup DAC_LL_Exported_Functions + * @{ + */ + +/** @addtogroup DAC_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_DAC_Init(DAC_TypeDef *Instance); +LL_StatusETypeDef LL_DAC_DeInit(DAC_TypeDef *Instance); +void LL_DAC_MspInit(DAC_TypeDef *Instance); +void LL_DAC_MspDeInit(DAC_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup DAC_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_DAC_ChannelConfig(DAC_TypeDef *Instance, uint32_t Channel, DAC_ChannelConfTypeDef *sConfig); +LL_StatusETypeDef LL_DAC_SawtoothWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_SawtoothConfTypeDef *sConfig); +LL_StatusETypeDef LL_DAC_TriangleWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_TriangleConfTypeDef *sConfig); +/** + * @} + */ + + +/** @addtogroup DAC_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_DAC_Start(DAC_TypeDef *Instance, uint32_t Channel); +LL_StatusETypeDef LL_DAC_Stop(DAC_TypeDef *Instance, uint32_t Channel); +LL_StatusETypeDef LL_DAC_SetValue(DAC_TypeDef *Instance, uint32_t Channel, uint16_t Data); +uint16_t LL_DAC_GetValue(DAC_TypeDef *Instance, uint32_t Channel); +LL_StatusETypeDef LL_DAC_SawtoothWaveDataStep(DAC_TypeDef *Instance, uint32_t Channel); +LL_StatusETypeDef LL_DAC_SawtoothWaveDataReset(DAC_TypeDef *Instance, uint32_t Channel); +LL_StatusETypeDef LL_DAC_TriangleWaveStep(DAC_TypeDef *Instance, uint32_t Channel); +/** + * @} + */ + + +/** @addtogroup DAC_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_DAC_IRQHandler(DAC_TypeDef *Instance); +void LL_DAC_ConvDoneCallback(DAC_TypeDef *Instance, uint32_t Channel); +void LL_DAC_ConvDoneBCallback(DAC_TypeDef *Instance, uint32_t Channel); +/** + * @} + */ + +/** + * @} + */ + + +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup DAC_LL_Private_Macros DAC LL Private Macros + * @brief DAC LL Private Macros + * @{ + */ + +/** + * @brief Judge is DAC channel number or not + * @param CHN_NB channel number to judge + * @retval 0 isn't DAC channel number + * @retval 1 is DAC channel number + */ +#define IS_DAC_NUMBER(CHN_NB) ((CHN_NB) < DAC_CHN_NB) + +/** + * @brief Judge is DAC channel or not + * @param CHN channel to judge + * @retval 0 isn't DAC channel + * @retval 1 is DAC channel + */ +#define IS_DAC_CHANNEL(CHN) (((CHN) == DAC_CHANNEL_0) || \ + ((CHN) == DAC_CHANNEL_1) || \ + ((CHN) == DAC_CHANNEL_2) || \ + ((CHN) == DAC_CHANNEL_3)) + +/** + * @brief Judge is DAC channels mask or not + * @param CHN channels mask to judge + * @retval 0 isn't DAC channels mask + * @retval 1 is DAC channels mask + */ +#define IS_DAC_CHANNELS_MASK(CHN) ((((CHN) & DAC_CHANNEL_ALL) != 0x00UL) && \ + (((CHN) & ~(DAC_CHANNEL_ALL)) == 0x00UL)) + +/** + * @brief Judge is DAC channel output select or not + * @param OUTPUT output select + * @retval 0 isn't DAC channel output select + * @retval 1 is DAC channel output select + */ +#define IS_DAC_CHANNEL_OUTPUT_SEL(OUTPUT) (((OUTPUT) == DAC_CHANNEL_OUTPUT_DISABLE) || \ + ((OUTPUT) == DAC_CHANNEL_OUTPUT_ENABLE)) + +/** + * @brief Judge is DAC channel done interrupt pending config or not + * @param PENDING pending config to judge + * @retval 0 isn't DAC channel done interrupt pending config + * @retval 1 is DAC channel done interrupt pending config + */ +#define IS_DAC_CHANNEL_DONE_IT_PENDING_CFG(PENDING) (((PENDING) == DAC_CHANNEL_DONE_IT_DISABLE) || \ + ((PENDING) == DAC_CHANNEL_DONE_IT_ENABLE)) + +/** + * @brief Judge is DAC channel doneB interrupt pending config or not + * @param PENDING pending config to judge + * @retval 0 isn't DAC channel doneB interrupt pending config + * @retval 1 is DAC channel doneB interrupt pending config + */ +#define IS_DAC_CHANNEL_DONEB_IT_PENDING_CFG(PENDING) (((PENDING) == DAC_CHANNEL_DONEB_IT_DISABLE) || \ + ((PENDING) == DAC_CHANNEL_DONEB_IT_ENABLE)) + +/** + * @brief Judge is DAC sawtooth reset data or not + * @param DATA data to judge + * @retval 0 isn't DAC sawtooth reset data + * @retval 1 is DAC sawtooth reset data + */ +#define IS_DAC_SAWTOOTH_RESET_DATA(DATA) ((DATA) <= 0xFFFUL) + +/** + * @brief Judge is DAC sawtooth step data or not + * @param DATA data to judge + * @retval 0 isn't DAC sawtooth step data + * @retval 1 is DAC sawtooth step data + */ +#define IS_DAC_SAWTOOTH_STEP_DATA(DATA) ((DATA) <= 0xFFFFUL) + +/** + * @brief Judge is DAC sawtooth reset trigger or not + * @param TRIGGER trigger to judge + * @retval 0 isn't DAC sawtooth reset trigger + * @retval 1 is DAC sawtooth reset trigger + */ +#define IS_DAC_SAWTOOTH_RESET_TRIGGER(TRIGGER) ((TRIGGER) < 16U) + +/** + * @brief Judge is DAC sawtooth step trigger or not + * @param TRIGGER trigger to judge + * @retval 0 isn't DAC sawtooth step trigger + * @retval 1 is DAC sawtooth step trigger + */ +#define IS_DAC_SAWTOOTH_STEP_TRIGGER(TRIGGER) ((TRIGGER) < 16U) + +/** + * @brief Judge is DAC sawtooth polarity or not + * @param POLARITY polarity to judge + * @retval 0 isn't DAC sawtooth polarity + * @retval 1 is DAC sawtooth polarity + */ +#define IS_DAC_SAWTOOTH_POLARITY(POLARITY) (((POLARITY) == DAC_SAWTOOTH_POLARITY_DEC) || \ + ((POLARITY) == DAC_SAWTOOTH_POLARITY_INC)) + +/** + * @brief Judge is DAC triangle initial direction or not + * @param DIR direction to judge + * @retval 0 isn't DAC triangle initial direction + * @retval 1 is DAC triangle initial direction + */ +#define IS_DAC_TRIANGLE_INITIALDIRECTION(DIR) (((DIR) == DAC_TRIANGLE_INITIALDIRECTION_DEC) || \ + ((DIR) == DAC_TRIANGLE_INITIALDIRECTION_INC)) + +/** + * @brief Judge is DAC triangle amplitude or not + * @param AMP amplitude to judge + * @retval 0 isn't DAC triangle amplitude + * @retval 1 is DAC triangle amplitude + */ +#define IS_DAC_TRIANGLE_AMPLITUDE(AMP) (((AMP) == DAC_TRIANGLE_AMPLITUDE_1) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_3) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_7) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_15) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_31) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_63) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_127) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_255) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_511) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_1023) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_2047) || \ + ((AMP) == DAC_TRIANGLE_AMPLITUDE_4095)) + +/** + * @brief Judge is DAC triangle step trigger or not + * @param TRIGGER trigger to judge + * @retval 0 isn't DAC triangle step trigger + * @retval 1 is DAC triangle step trigger + */ +#define IS_DAC_TRIANGLE_STEP_TRIGGER(TRIGGER) ((TRIGGER) < 16U) + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_DAC_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dali.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dali.h new file mode 100644 index 0000000000..0c043f9558 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dali.h @@ -0,0 +1,499 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dali.h + * @author MCD Application Team + * @brief Header file for DALI module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_DALI_H_ +#define _TAE32F53XX_LL_DALI_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup DALI_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/** @defgroup DALI_LL_Exported_Types DALI LL Exported Types + * @brief DALI LL Exported Types + * @{ + */ + +/** @defgroup DALI_Mode_Selection DALI mode selection + * @brief DALI mode selection + * @{ + */ +typedef enum { + DALI_MODE_SLAVE = 0, /*!< Slave mode */ + DALI_MODE_MASTER = DALI_CR_MODE, /*!< Master mode */ +} DALI_ModeETypeDef; +/** + * @} + */ + +/** @defgroup DALI_Forward_Message_Length DALI forward frame message length + * @brief DALI forward frame message length + * @{ + */ +typedef enum { + DALI_MESSAGELENGTH_16Bit = 0, /*!< DALI Forward frame message length sets to 16 bits */ + DALI_MESSAGELENGTH_17Bit = DALI_CR_ML_0, /*!< DALI Forward frame message length sets to 17 bits */ + DALI_MESSAGELENGTH_18Bit = DALI_CR_ML_1, /*!< DALI Forward frame message length sets to 18 bits */ + DALI_MESSAGELENGTH_24Bit = (DALI_CR_ML_0 | DALI_CR_ML_1), /*!< DALI Forward frame message length sets to 24 bits */ +} DALI_MsgLenETypeDef; +/** + * @} + */ + +/** @defgroup DALI_Polarity_Selection DALI polarity selection + * @brief DALI polarity selection + * @{ + */ +typedef enum { + DALI_POLARITY_ACTIVE_HIGH = 0, /*!< Active High */ + DALI_POLARITY_ACTIVE_LOW = DALI_CR_POL, /*!< Active Low */ +} DALI_PolETypeDef; +/** + * @} + */ + +/** @defgroup DALI_Filter_Selection DALI filter selection + * @brief DALI filter selection + * @{ + */ +typedef enum { + DALI_FILTER_DISABLE = 0, /*!< Disable filter feature */ + DALI_FILTER_ENABLE = DALI_FCR_FE, /*!< Enable filter feature */ +} DALI_FilterETypeDef; +/** + * @} + */ + +/** @defgroup DALI_Interrupt_definition DALI Interrupt Definition + * @brief DALI Interrupt Definition + * @{ + */ +typedef enum { + DALI_IT_BEIE = DALI_CR_BEIE, /*!< DALI Backward Error Interrupt Enable */ + DALI_IT_FEIE = DALI_CR_FEIE, /*!< DALI Forward Error Interrupt Enable */ + DALI_IT_BDIE = DALI_CR_BDIE, /*!< DALI Backward Done Interrupt Enable */ + DALI_IT_FDIE = DALI_CR_FDIE, /*!< DALI Forward Done Interrupt Enable */ +} DALI_IntETypeDef; +/** + * @} + */ + +/** @defgroup DALI_Pending_Flag_definition DALI Pending Flag Definition + * @brief DALI Pending Flag Definition + * @{ + */ +typedef enum { + DALI_FLAG_BEIF = DALI_ISR_BEIF, /*!< DALI Backward Error Pending Flag */ + DALI_FLAG_FEIF = DALI_ISR_FEIF, /*!< DALI Forward Error Pending Flag */ + DALI_FLAG_BDIF = DALI_ISR_BDIF, /*!< DALI Backward Done Pending Flag */ + DALI_FLAG_FDIF = DALI_ISR_FDIF, /*!< DALI Forward Done Pending Flag */ +} DALI_FlagTypeDef; +/** + * @} + */ + +/** @defgroup DALI_Status_Flag_definition DALI Status Flag Definition + * @brief DALI Status Flag Definition + * @{ + */ +typedef enum { + DALI_FLAG_BSY = DALI_ISR_BSY, /*!< DALI BUSY Status Flag */ +} DALI_StatusTypeDef; +/** + * @} + */ + +/** @defgroup DALI_Baudrate_definition DALI Baudrate Definition + * @brief DALI Baudrate Definition + * @{ + */ +typedef enum { + DALI_BAUDRATE_1K2 = 1200U, /*!< DALI Baudrate 1.2K */ + DALI_BAUDRATE_2K4 = 2400U, /*!< DALI Baudrate 2.4K */ + DALI_BAUDRATE_4K8 = 4800U, /*!< DALI Baudrate 4.8K */ +} DALI_BaudETypeDef; +/** + * @} + */ + + +/** + * @brief DALI Initialization Structure definition + */ +typedef struct __DALI_InitTypeDef { + DALI_ModeETypeDef Mode; /*!< Specifies the DALI working mode. + This parameter can be a value in @ref DALI_ModeETypeDef */ + + DALI_BaudETypeDef Baudrate; /*!< Specifies the DALI division value + This parameter can be a value in @ref DALI_BaudETypeDef */ + + DALI_MsgLenETypeDef MessageLen; /*!< Specifies the DALI Forward frame message length. + This parameter can be a value in @ref DALI_MsgLenETypeDef */ + + DALI_PolETypeDef Polarity; /*!< Specifies the DALI polarity + This parameter can be a value in @ref DALI_PolETypeDef */ + + DALI_FilterETypeDef Filter; /*!< Specifies the DALI enable filter or not. + This parameter can be a value in @ref DALI_FilterETypeDef */ + + uint16_t FilterCounter; /*!< Specifies the DALI filter counter value (in APB1 Clock) + This parameter can be a number in range from 0 to 0xFFFF */ + + uint16_t ForwardDelay; /*!< Specifies the DALI forward frame delay timing. + This parameter can be a number in range from 0 to 511 + DelayTime(ms) = (22 + ForwardDelay) * T */ + + uint16_t BackwardDelay; /*!< Specifies the DALI backward frame delay timing. + This parameter can be a number in range from 0 to 127 + DelayTime(ms) = (7 + BackwardDelay) * T */ +} DALI_InitTypeDef; + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup DALI_LL_Exported_Macros DALI LL Exported Macros + * @brief DALI LL Exported Macros + * @{ + */ + +/** + * @brief Enable the DALI peripheral + * @param __INSTANCE__ DALI peripheral + * @return None + */ +#define __LL_DALI_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR, DALI_CR_PEN) + +/** + * @brief Disable the DALI peripheral + * @param __INSTANCE__ DALI peripheral + * @return None + */ +#define __LL_DALI_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR, DALI_CR_PEN) + + +/** + * @brief Enable the specified DALI Interrupts + * @param __INSTANCE__ DALI peripheral + * @param __IT__ specifies the DALI interrupt source to enable. + * This parameter can be any combination of @enum DALI_IntETypeDef in + * @ref DALI_Interrupt_definition + * @return None + */ +#define __LL_DALI_IT_ENABLE(__INSTANCE__, __IT__) SET_BIT((__INSTANCE__)->CR, (__IT__)) + +/** + * @brief Disable the specified DALI Interrupts + * @param __INSTANCE__ DALI peripheral + * @param __IT__ specifies the DALI interrupt source to disable. + * This parameter can be any combination of @enum DALI_IntETypeDef in + * @ref DALI_Interrupt_definition + * @return None + */ +#define __LL_DALI_IT_DISABLE(__INSTANCE__, __IT__) CLEAR_BIT((__INSTANCE__)->CR, (__IT__)) + +/** + * @brief Check whether the specified DALI Channel interrupt source is set or not. + * @param __INSTANCE__ DALI peripheral + * @param __IT__ specifies the DALI Channel interrupt source to check. + * This parameter can be ONE of @enum DALI_IntETypeDef in @ref DALI_Interrupt_definition + @return The state of __IT__ (SET or RESET). + */ +#define __LL_DALI_IT_SOURCE_CHECK(__INSTANCE__, __IT__) ((READ_BIT((__INSTANCE__)->CR, (__IT__)) == (__IT__)) ? SET : RESET) + +/** + * @brief Clear the specified pending flags + * @param __INSTANCE__ DALI peripheral. + * @param __FLAG__ Specifies the DALI pending flag to clear. + * This parameter can be any combination of @enum DALI_FlagTypeDef in + * @ref DALI_Pending_Flag_definition + * @return None + */ +#define __LL_DALI_PENDING_FLAG_CLEAR(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__)) + +/** + * @brief Check whether the specified pending flag is SET or not. + * @param __INSTANCE__ DALI peripheral. + * @param __FLAG__ Specifies the DALI pending flag to get. + * This parameter can be ONE of @enum DALI_FlagTypeDef in @ref DALI_Pending_Flag_definition + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_DALI_PENDING_FLAG_GET(__INSTANCE__, __FLAG__) ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + + +/** + * @brief Check whether the specified status flag is SET or not. + * @param __INSTANCE__ DALI peripheral. + * @param __FLAG__ Specifies the DALI pending flag to get. + * This parameter can be ONE of @enum DALI_StatusTypeDef in @ref DALI_Status_Flag_definition + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_DALI_STATUS_FLAG_GET(__INSTANCE__, __STA__) ((READ_BIT((__INSTANCE__)->ISR, (__STA__)) == (__STA__)) ? SET : RESET) + +/** + * @brief DALI master writes forward data to DALI_FDR register on runtime + * @param __INSTANCE__ DALI peripheral. + * @param __DATA__ Forward frame data + * @return None + */ +#define __LL_DALI_MSTR_WRITE_FORWARD_DATA(__INSTANCE__, __DATA__) WRITE_REG((__INSTANCE__)->FDR, (__DATA__) & 0xFFFFFFUL) + +/** + * @brief DALI master reads backward data from DALI_BDR register on runtime + * @param __INSTANCE__ DALI peripheral. + * @return Backward data + */ +#define __LL_DALI_MSTR_READ_BACKWARD_DATA(__INSTANCE__) (READ_REG((__INSTANCE__)->BDR) & 0xFFUL) + +/** + * @brief DALI slave writes backward data to DALI_BDR register on runtime + * @param __INSTANCE__ DALI peripheral. + * @param __DATA__ Backward frame data + * @return None + */ +#define __LL_DALI_SLV_WRITE_BACKWARD_DATA(__INSTANCE__, __DATA__) WRITE_REG((__INSTANCE__)->BDR, (__DATA__) & 0xFFUL) + +/** + * @brief DALI slave reads forward data from DALI_FDR register on runtime + * @param __INSTANCE__ DALI peripheral. + * @return Forward data + */ +#define __LL_DALI_SLV_READ_FORWARD_DATA(__INSTANCE__) (READ_REG((__INSTANCE__)->FDR) & 0xFFFFFFUL) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup DALI_LL_Exported_Functions + * @{ + */ + +/** @addtogroup DALI_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_DALI_Init(DALI_TypeDef *Instance, DALI_InitTypeDef *Init); +LL_StatusETypeDef LL_DALI_DeInit(DALI_TypeDef *Instance); +void LL_DALI_MspInit(DALI_TypeDef *Instance); +void LL_DALI_MspDeInit(DALI_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup DALI_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_DALI_WaitForLastOperation(DALI_TypeDef *Instance, uint32_t Timeout); +/** + * @} + */ + + +/** @addtogroup DALI_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_DALI_Master_Transmit(DALI_TypeDef *Instance, uint32_t ForwardData); +LL_StatusETypeDef LL_DALI_Master_Transmit_IT(DALI_TypeDef *Instance, uint32_t ForwardData); +LL_StatusETypeDef LL_DALI_Master_Receive(DALI_TypeDef *Instance, uint8_t *BackwardData); +LL_StatusETypeDef LL_DALI_Master_Receive_IT(DALI_TypeDef *Instance); + +LL_StatusETypeDef LL_DALI_Slave_Transmit(DALI_TypeDef *Instance, uint8_t BackwardData); +LL_StatusETypeDef LL_DALI_Slave_Transmit_IT(DALI_TypeDef *Instance, uint8_t BackwardData); +LL_StatusETypeDef LL_DALI_Slave_Receive(DALI_TypeDef *Instance, uint32_t *ForwardData); +LL_StatusETypeDef LL_DALI_Slave_Receive_IT(DALI_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup DALI_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_DALI_IRQHandler(DALI_TypeDef *Instance); + +void LL_DALI_MstrRecviveDoneCallback(DALI_TypeDef *Instance); +void LL_DALI_MstrRecviveErrorCallback(DALI_TypeDef *Instance); +void LL_DALI_MstrTransmitDoneCallback(DALI_TypeDef *Instance); +void LL_DALI_MstrTransmitErrorCallback(DALI_TypeDef *Instance); + +void LL_DALI_SlvReceiveDoneCallback(DALI_TypeDef *Instance); +void LL_DALI_SlvReceiveErrorCallback(DALI_TypeDef *Instance); +void LL_DALI_SlvTransmitDoneCallback(DALI_TypeDef *Instance); +void LL_DALI_SlvTransmitErrorCallback(DALI_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private constants ---------------------------------------------------------*/ +/** @defgroup DALI_LL_Private_Constants DALI LL private constants + * @brief DALI LL private constants + * @{ + */ + +/** + * @brief Max timeout for DALI operations, Default 1000 ticks + */ +#define DALI_TIMEOUT_MAX_VALUE 1000UL + +/** + * @} + */ + + +/* Private macros ------------------------------------------------------------*/ +/** @defgroup DALI_LL_Private_Macros DALI LL private macros + * @brief DALI LL private macros + * @{ + */ + +/** + * @brief Judge is DALI mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't DALI mode + * @retval 1 is DALI mode + */ +#define IS_DALI_MODE(__MODE__) (((__MODE__) == DALI_MODE_MASTER) || \ + ((__MODE__) == DALI_MODE_SLAVE)) + +/** + * @brief Judge is DALI message length or not + * @param __LEN__ length to judge + * @retval 0 isn't DALI message length + * @retval 1 is DALI message length + */ +#define IS_DALI_MESSAGE_LEN(__LEN__) (((__LEN__) == DALI_MESSAGELENGTH_16Bit) || \ + ((__LEN__) == DALI_MESSAGELENGTH_17Bit) || \ + ((__LEN__) == DALI_MESSAGELENGTH_18Bit) || \ + ((__LEN__) == DALI_MESSAGELENGTH_24Bit)) + +/** + * @brief Judge is DALI polarity or not + * @param __POL__ polarity to judge + * @retval 0 isn't DALI polarity + * @retval 1 is DALI polarity + */ +#define IS_DALI_POLARITY(__POL__) (((__POL__) == DALI_POLARITY_ACTIVE_HIGH) || \ + ((__POL__) == DALI_POLARITY_ACTIVE_LOW)) + +/** + * @brief Judge is DALI filter enable or not + * @param __EN__ enable to judge + * @retval 0 isn't DALI filter enable + * @retval 1 is DALI filter enable + */ +#define IS_DALI_FILTER_ENABLE(__EN__) (((__EN__) == DALI_FILTER_DISABLE) || \ + ((__EN__) == DALI_FILTER_ENABLE)) + +/** + * @brief Judge is DALI filter counter or not + * @param __CNT__ counter to judge + * @retval 0 isn't DALI filter counter + * @retval 1 is DALI filter counter + */ +#define IS_DALI_FILTER_COUNTER(__CNT__) ((__CNT__) <= 0xFFFFUL) + +/** + * @brief Judge is DALI forward delay or not + * @param __DLY__ delay to judge + * @retval 0 isn't DALI forward delay + * @retval 1 is DALI forward delay + */ +#define IS_DALI_FORWARD_DELAY(__DLY__) ((__DLY__) <= 0x1FFUL) + +/** + * @brief Judge is DALI backward delay or not + * @param __DLY__ delay to judge + * @retval 0 isn't DALI backward delay + * @retval 1 is DALI backward delay + */ +#define IS_DALI_BACKWARD_DELAY(__DLY__) ((__DLY__) <= 0x7FUL) + +/** + * @brief Judge is DALI prescale or not + * @param __PSC__ prescale to judge + * @retval 0 isn't DALI prescale + * @retval 1 is DALI prescale + */ +#define IS_DALI_PRESCALE(__PSC__) ((__PSC__) <= 0xFFFUL) + +/** + * @brief Judge is DALI supported baudrate or not + * @param __BRT__ Baudrate to judge + * @retval 0 isn't DALI supported baudrate + * @retval 1 is DALI supported baudrate + */ +#define IS_DALI_BAUDRATE(__BRT__) (((__BRT__) == DALI_BAUDRATE_1K2) || \ + ((__BRT__) == DALI_BAUDRATE_2K4) || \ + ((__BRT__) == DALI_BAUDRATE_4K8)) + + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_DALI_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_def.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_def.h new file mode 100644 index 0000000000..edae4890ee --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_def.h @@ -0,0 +1,306 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_def.h + * @author MCD Application Team + * @brief This file contains LL common defines, enumeration, macros and + * structures definitions. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_DEF_H_ +#define _TAE32F53XX_LL_DEF_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include +#include "tae32f53xx.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup DEFINE_LL DEFINE LL + * @brief DEFINE LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup DEFINE_LL_Exported_Constants DEFINE LL Exported Constants + * @brief DEFINE LL Exported Constants + * @{ + */ + +/** + * @brief LL wait forever time definition + */ +#define LL_WAIT_FOREVER 0xFFFFFFFFUL + +/** + * @brief LL wait max delay time definition + */ +#define LL_MAX_DELAY (LL_WAIT_FOREVER - 1U) + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup DEFINE_LL_Exported_Types DEFINE LL Exported Types + * @brief DEFINE LL Exported Types + * @{ + */ + +/** + * @brief LL Status type definition + */ +typedef enum { + LL_OK = 0x00U, /*! LL status OK */ + LL_ERROR = 0x01U, /*! LL status ERROR */ + LL_BUSY = 0x02U, /*! LL status BUSY */ + LL_TIMEOUT = 0x03U, /*! LL status TIMEOUT */ + LL_FAILED = 0x04U, /*! LL status FAILED */ +} LL_StatusETypeDef; + +/** + * @brief LL Flag status type definition + */ +typedef enum { + RESET = 0, /*!< LL flag status RESET */ + SET = !RESET, /*!< LL flag status SET */ +} LL_FlagStatusETypeDef; + +/** + * @brief LL Functional status type definition + */ +typedef enum { + DISABLE = 0, /*!< LL functional status DISABLE */ + ENABLE = !DISABLE, /*!< LL functional status ENABLE */ +} LL_FuncStatusETypeDef; + +/** + * @brief LL Error status type definiton + */ +typedef enum { + SUCCESS = 0U, /*!< LL error status SUCCESS */ + ERROR = !SUCCESS, /*!< LL error status ERROR */ +} LL_ErrStatusETypeDef; + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup DEFINE_LL_Exported_Macros DEFINE LL Exported Macros + * @brief DEFINE LL Exported Macros + * @{ + */ + +/* Compiler ALIAS and WEAK attribute definition */ +#if defined (__CC_ARM) /*!< AC5 Compiler */ +#define __ALIAS_FUNC(FUNC) __attribute__ ((weak, alias(#FUNC))) +#define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void) __attribute__ ((weak, alias(#FUNC_ALIAS))); +#elif defined (__ICCARM__) /*!< IAR Compiler */ +#define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void);_Pragma(_STRINGIFY(_WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS))) +#define _WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) weak WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*!< AC6 Compiler */ +#define __ALIAS_FUNC(FUNC) __attribute__ ((weak, alias(#FUNC))) +#define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void) __attribute__ ((weak, alias(#FUNC_ALIAS))); +#elif defined (__GNUC__) /*!< GCC Compiler */ +#define __ALIAS_FUNC(FUNC) __attribute__ ((weak, alias(#FUNC))) +#define __WEAK_ALIAS_FUNC(FUNC, FUNC_ALIAS) void FUNC(void) __attribute__ ((weak, alias(#FUNC_ALIAS))); +#else +#error Not supported compiler type +#endif + + +/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */ +/* Compiler aligned on 4-bytes attribute definition */ +#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */ +#ifndef __ALIGN_END +#define __ALIGN_END __attribute__ ((aligned (4))) +#endif + +#ifndef __ALIGN_BEGIN +#define __ALIGN_BEGIN +#endif + +#else + +#ifndef __ALIGN_END +#define __ALIGN_END +#endif + +#ifndef __ALIGN_BEGIN +#if defined (__CC_ARM) /* ARM Compiler */ +#define __ALIGN_BEGIN __align(4) +#elif defined (__ICCARM__) /* IAR Compiler */ +#define __ALIGN_BEGIN +#endif +#endif +#endif + + +/* Compiler __NOINLINE attribute definition */ +#if defined (__CC_ARM) || defined (__GNUC__) /* ARM & GNUCompiler */ +#define __NOINLINE __attribute__ ( (noinline) ) +#elif defined (__ICCARM__) /* ICCARM Compiler */ +#define __NOINLINE _Pragma("optimize = no_inline") +#endif + + +/* Compiler misc attribute definition */ +#if defined (__CC_ARM) /*!< AC5 Compiler */ +#define __NO_INIT __attribute__((zero_init)) +#define __AT(n) __attribute__((at(n))) +#define __SECTION(SECT) __attribute__((section(#SECT))) +#elif defined (__ICCARM__) /*!< IAR Compiler */ +#define __NO_INIT __no_init +#define __AT(n) @(n) +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) /*!< AC6 Compiler */ +#define __NO_INIT +#define __AT(n) __attribute__ ((section(".ARM.__at_"#n))) +#define __SECTION(SECT) __attribute__((section(#SECT))) +#elif defined (__GNUC__) /*!< GCC Compiler */ +#define __NO_INIT __attribute__((zero_init)) +#define __AT(n) +#define __SECTION(SECT) __attribute__((section(#SECT))) +#endif + + +/** + * @brief Bit left shift definition + * @param pos left shift position + * @return Bit left shift value + */ +#define BIT(pos) (1U << (pos)) + +/** + * @brief Set bit definition + * @param REG register + * @param BIT Bit to set + * @return None + */ +#define SET_BIT(REG, BIT) ((REG) |= (BIT)) + +/** + * @brief Clear bit definition + * @param REG register + * @param BIT Bit to clear + * @return None + */ +#define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT)) + +/** + * @brief Read bit definition + * @param REG register + * @param BIT Bit to read + * @return None + */ +#define READ_BIT(REG, BIT) ((REG) & (BIT)) + +/** + * @brief Clear register definiton + * @param REG register + * @return None + */ +#define CLEAR_REG(REG) ((REG) = (0x0)) + +/** + * @brief Write register definiton + * @param REG register + * @param VAL write value + * @return None + */ +#define WRITE_REG(REG, VAL) ((REG) = (VAL)) + +/** + * @brief Read register definition + * @param REG register + * @return None + */ +#define READ_REG(REG) ((REG)) + +/** + * @brief Modify register definition + * @param REG register + * @param CLEARMASK clear mask + * @param SETMASK set mask + * @return None + */ +#define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) + +/** + * @brief Position value definition + * @param VAL value + * @return None + */ +#define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL))) + + + +/** + * @brief To avoid gcc/g++ warnings + * @param X avoid warning param + * @return None + */ +#define LL_UNUSED(X) (void)X + +/** + * @brief Macro for counting the element number of an array + * @param a Array to be Counted + * @return size of Array + */ +#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_DEF_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dflash.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dflash.h new file mode 100644 index 0000000000..3ddd325b7d --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dflash.h @@ -0,0 +1,271 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dflash.h + * @author MCD Application Team + * @brief Header file for DataFlash module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_DFLASH_H_ +#define _TAE32F53XX_LL_DFLASH_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup DFLASH_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup DFLASH_LL_Exported_Constants DFLASH LL Exported Constants + * @brief DFLASH LL Exported Constants + * @{ + */ + +/** @defgroup DFLASH_Keys DFLASH Keys + * @brief DFLASH Keys + * @{ + */ +#define DFLASH_KEY1 0x32107654U /*!< DFLASH key1 */ +#define DFLASH_KEY2 0xFEDCBA98U /*!< DFLASH key2: used with DFLASH_KEY1 to unlock the DFLASH Program/Read/Erase features*/ +/** + * @} + */ + +/** @defgroup DFLASH_Flag_definition DFLASH Flag Definition + * @brief DFLASH Flag Definition + * @{ + */ +#define DFLASH_FLAG_BSY DFLASH_SR_BSY /*!< DFLASH flag BSY */ +#define DFLASH_FLAG_DIF DFLASH_ISR_DIF /*!< DFLASH flag DIF */ +#define DFLASH_FLAG_EIF DFLASH_ISR_EIF /*!< DFLASH flag EIF */ +/** + * @} + */ + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup DFLASH_LL_Exported_Macros DFLASH LL Exported Macros + * @brief DFLASH LL Exported Macros + * @{ + */ + +/** + * @brief Set the DFLASH_DR Register value. + * @param __DATA__ specifies the Data value. + * @return None + */ +#define __LL_DFLASH_DATA_SET(__DATA__) WRITE_REG(DFLASH->DR, (__DATA__)) + +/** + * @brief Get the TMR Counter Register value on runtime. + * @return Value in the DFLASH_DR Register + */ +#define __LL_DFLASH_DATA_GET() READ_REG(DFLASH->DR) + +/** + * @brief Check whether the specified status flag in DFLASH_SR Register is SET or not. + * @param __FLAG__ specifies the DFLASH status flag to check. + * This parameter can be ONE of the following values: + * @arg DFLASH_FLAG_BSY : DFLASH BUSY Status + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_DFLASH_STATUS_FLAG_GET(__FLAG__) ((READ_BIT(DFLASH->SR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Check whether the specified interrupt pending flag in DFLASH_ISR Register is SET or not. + * @param __FLAG__ specifies the DFLASH interrupt pending flag to check. + * This parameter can be ONE of the following values: + * @arg DFLASH_FLAG_DIF : Done + * @arg DFLASH_FLAG_EIF : Operation Error + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_DFLASH_PENDING_FLAG_GET(__FLAG__) ((READ_BIT(DFLASH->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Clear the DFLASH's Pending Register flag. + * @param __FLAG__ specifies the DFLASH pending flags to clear. + * This parameter can be any combination of the following values: + * @arg DFLASH_FLAG_DIF : Done + * @arg DFLASH_FLAG_EIF : Operation Error + * @return None + */ +#define __LL_DFLASH_PENDING_FLAG_CLEAR(__FLAG__) WRITE_REG(DFLASH->ISR, (__FLAG__)) + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup DFLASH_LL_Exported_Functions + * @{ + */ + +/** @addtogroup DFLASH_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_DFLASH_WaitForLastOperation(uint32_t Timeout); +/** + * @} + */ + + +/** @addtogroup DFLASH_LL_Exported_Functions_Group2 + * @{ + */ + +/** + * @brief Unlock the DFLASH Program/Read/Erase access. + * @param None + * @return LL Status + */ +__STATIC_INLINE LL_StatusETypeDef LL_DFLASH_Unlock(void) +{ + if (READ_BIT(DFLASH->CR, DFLASH_CR_LOCK) != RESET) { + /* Authorize the DFLASH Program/Read/Erase access */ + WRITE_REG(DFLASH->KEYR, DFLASH_KEY1); + WRITE_REG(DFLASH->KEYR, DFLASH_KEY2); + + /* Verify DFLASH is unlocked */ + if (READ_BIT(DFLASH->CR, DFLASH_CR_LOCK_Msk) != RESET) { + return LL_ERROR; + } + } + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Lock the DFLASH Program/Read/Erase access. + * @param None + * @return LL Status + */ +__STATIC_INLINE LL_StatusETypeDef LL_DFLASH_Lock(void) +{ + /* Set the LOCK Bit to lock the DFLASH Program/Read/Erase access */ + SET_BIT(DFLASH->CR, DFLASH_CR_LOCK); + + /* Verify DFLASH is locked */ + if (READ_BIT(DFLASH->CR, DFLASH_CR_LOCK_Msk) == RESET) { + return LL_ERROR; + } + + /* Return function status */ + return LL_OK; +} + +LL_StatusETypeDef LL_DFLASH_Program_Byte(uint32_t Address, uint8_t Data); +LL_StatusETypeDef LL_DFLASH_Program_Word(uint32_t Address, uint32_t Data); + +LL_StatusETypeDef LL_DFLASH_Read_Byte(uint32_t Address, uint8_t *Data); +LL_StatusETypeDef LL_DFLASH_Read_Word(uint32_t Address, uint32_t *Data); + +LL_StatusETypeDef LL_DFLASH_MassErase(void); +LL_StatusETypeDef LL_DFLASH_SectorErase(uint16_t Sector); +LL_StatusETypeDef LL_DFLASH_MultiSectorsErase(uint16_t Sector, uint16_t Num, uint16_t *SectorError); +/** + * @} + */ + +/** + * @} + */ + +/* Private constants ---------------------------------------------------------*/ +/** @defgroup DFLASH_LL_Private_Constants DFLASH LL Private Constants + * @brief DFLASH LL Private Constants + * @{ + */ + +#define DFLASH_PROGRAM_ADDRESS_MASK 0x0000FFFFU /*!< Program address mask */ +#define DFLASH_TIMEOUT_MAX_VALUE 300U /*!< Max timeout for data flash operations. Default 300 ticks */ + +/** + * @} + */ + +/* Private macros ------------------------------------------------------------*/ +/** @defgroup DFLASH_LL_Private_Macros DFLASH LL Private Macros + * @brief DFLASH LL Private Macros + * @{ + */ + +/** + * @brief Judge is DFLASH address mask or not + * @param ADDRESS address to judge + * @retval 0 isn't DFLASH address mask + * @retval 1 is DFLASH address mask + */ +#define IS_DFLASH_ADDRESS_MASK(ADDRESS) ((ADDRESS) < (0x4800U)) + +/** + * @brief Judge is DFLASH address check align or not + * @param ADDRESS address to judge + * @retval 0 isn't DFLASH address check align + * @retval 1 is DFLASH address check align + */ +#define IS_DFLASH_ADDRESS_CHECK_ALIGN(ADDRESS) (((ADDRESS) & 0x3) == 0x00U) + +/** + * @brief Judge is DFLASH sector or not + * @param SECTOR sector to judge + * @retval 0 isn't DFLASH sector + * @retval 1 is DFLASH sector + */ +#define IS_DFLASH_NB_SECTORS(SECTOR) ((SECTOR) < 36U) + +/** + * @} + */ + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_DFLASH_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dma.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dma.h new file mode 100644 index 0000000000..c99743058d --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_dma.h @@ -0,0 +1,1193 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dma.h + * @author MCD Application Team + * @brief Header file for DMA LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_DMA_H_ +#define _TAE32F53XX_LL_DMA_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup DMA_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup DMA_LL_Exported_Constants DMA LL Exported Constants + * @brief DMA LL Exported Constants + * @{ + */ + +/** + * @brief DMA block size max + */ +#define LL_DMA_BLOCK_SIZE_MAX (0xfffU) + +/** + * @brief SRAMBC address start + */ +#define LL_DMA_SRMBC_ADDR_START (0x20004000UL) + +/** + * @brief SRAMBC address end + */ +#define LL_DMA_SRMBC_ADDR_END (0x20006000UL - 1) + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup DMA_LL_Exported_Types DMA LL Exported Types + * @brief DMA LL Exported Types + * @{ + */ + +/** + * @brief DMA Source Peripheral bus type definition + */ +typedef enum { + DMA_SRC_PERIPH_BUS_AHB_MST1 = DMA_CH_CR0_SMS_AHB_MST1, /*!< Source Peripheral bus AHB Master1 */ + DMA_SRC_PERIPH_BUS_AHB_MST2 = DMA_CH_CR0_SMS_AHB_MST2, /*!< Source Peripheral bus AHB Master2 */ +} DMA_SrcPeriphBusETypeDef; + +/** + * @brief DMA Destination Peripheral bus type definition + */ +typedef enum { + DMA_DST_PERIPH_BUS_AHB_MST1 = DMA_CH_CR0_DMS_AHB_MST1, /*!< Destination Peripheral bus AHB Master1 */ + DMA_DST_PERIPH_BUS_AHB_MST2 = DMA_CH_CR0_DMS_AHB_MST2, /*!< Destination Peripheral bus AHB Master2 */ +} DMA_DstPeriphBusETypeDef; + +/** + * brief DMA transfer type type definition + */ +typedef enum { + DMA_TRANS_TYPE_M2M = DMA_CH_CR0_TTC_M2M, /*!< Transfer type M2M */ + DMA_TRANS_TYPE_M2P = DMA_CH_CR0_TTC_M2P, /*!< Transfer type M2P */ + DMA_TRANS_TYPE_P2M = DMA_CH_CR0_TTC_P2M, /*!< Transfer type P2M */ + DMA_TRANS_TYPE_P2P = DMA_CH_CR0_TTC_P2P, /*!< Transfer type P2P */ +} DMA_TransTypeETypeDef; + +/** + * @brief DMA Source burst length type definition + */ +typedef enum { + DMA_SRC_BURST_LEN_1 = DMA_CH_CR0_SBTL_1, /*!< Source burst length 1 */ + DMA_SRC_BURST_LEN_4 = DMA_CH_CR0_SBTL_4, /*!< Source burst length 4 */ + DMA_SRC_BURST_LEN_8 = DMA_CH_CR0_SBTL_8, /*!< Source burst length 8 */ +} DMA_SrcBurstLenETypeDef; + +/** + * @brief DMA Destination burst length type definition + */ +typedef enum { + DMA_DST_BURST_LEN_1 = DMA_CH_CR0_DBTL_1, /*!< Destination burst length 1 */ + DMA_DST_BURST_LEN_4 = DMA_CH_CR0_DBTL_4, /*!< Destination burst length 4 */ + DMA_DST_BURST_LEN_8 = DMA_CH_CR0_DBTL_8, /*!< Destination burst length 8 */ +} DMA_DstBurstLenETypeDef; + +/** + * @brief DMA Source address mode type definition + */ +typedef enum { + DMA_SRC_ADDR_MODE_INC = DMA_CH_CR0_SINC_INC, /*!< Source address mode Increase */ + DMA_SRC_ADDR_MODE_DEC = DMA_CH_CR0_SINC_DEC, /*!< Source address mode Decrease */ + DMA_SRC_ADDR_MODE_FIX = DMA_CH_CR0_SINC_FIX, /*!< Source address mode Fixed */ +} DMA_SrcAddrModeETypeDef; + +/** + * @brief DMA Destination address mode type definition + */ +typedef enum { + DMA_DST_ADDR_MODE_INC = DMA_CH_CR0_DINC_INC, /*!< Destination address mode Increase */ + DMA_DST_ADDR_MODE_DEC = DMA_CH_CR0_DINC_DEC, /*!< Destination address mode Decrease */ + DMA_DST_ADDR_MODE_FIX = DMA_CH_CR0_DINC_FIX, /*!< Destination address mode Fixed */ +} DMA_DstAddrModeETypeDef; + +/** + * @brief DMA Source transfer width type definition + */ +typedef enum { + DMA_SRC_TRANS_WIDTH_8b = DMA_CH_CR0_STW_8b, /*!< Source transfer width 8bit */ + DMA_SRC_TRANS_WIDTH_16b = DMA_CH_CR0_STW_16b, /*!< Source transfer width 16bit */ + DMA_SRC_TRANS_WIDTH_32b = DMA_CH_CR0_STW_32b, /*!< Source transfer width 32bit */ +} DMA_SrcTransWidthETypeDef; + +/** + * @brief DMA Destination transfer width type definition + */ +typedef enum { + DMA_DST_TRANS_WIDTH_8b = DMA_CH_CR0_DTW_8b, /*!< Destination transfer width 8bit */ + DMA_DST_TRANS_WIDTH_16b = DMA_CH_CR0_DTW_16b, /*!< Destination transfer width 16bit */ + DMA_DST_TRANS_WIDTH_32b = DMA_CH_CR0_DTW_32b, /*!< Destination transfer width 32bit */ +} DMA_DstTransWidthETypeDef; + +/** + * @brief DMA Source handshaking interface type definition + */ +typedef enum { + DMA_SRC_HANDSHAKE_IFC_MEMORY = 0, /*!< Source handshaking interface MEMORY */ + DMA_SRC_HANDSHAKE_IFC_I2C0_TX = DMA_CH_CR3_SHSIF_I2C0_TX, /*!< Source handshaking interface I2C0_TX */ + DMA_SRC_HANDSHAKE_IFC_I2C0_RX = DMA_CH_CR3_SHSIF_I2C0_RX, /*!< Source handshaking interface I2C0_RX */ + DMA_SRC_HANDSHAKE_IFC_I2C1_TX = DMA_CH_CR3_SHSIF_I2C1_TX, /*!< Source handshaking interface I2C1_TX */ + DMA_SRC_HANDSHAKE_IFC_I2C1_RX = DMA_CH_CR3_SHSIF_I2C1_RX, /*!< Source handshaking interface I2C1_RX */ + DMA_SRC_HANDSHAKE_IFC_UART0_TX = DMA_CH_CR3_SHSIF_UART0_TX, /*!< Source handshaking interface UART0_TX */ + DMA_SRC_HANDSHAKE_IFC_UART0_RX = DMA_CH_CR3_SHSIF_UART0_RX, /*!< Source handshaking interface UART0_RX */ + DMA_SRC_HANDSHAKE_IFC_UART1_TX = DMA_CH_CR3_SHSIF_UART1_TX, /*!< Source handshaking interface UART1_TX */ + DMA_SRC_HANDSHAKE_IFC_UART1_RX = DMA_CH_CR3_SHSIF_UART1_RX, /*!< Source handshaking interface UART1_RX */ +} DMA_SrcHandshakeIfcETypeDef; + +/** + * @brief DMA Destination handshaking interface type definition + */ +typedef enum { + DMA_DST_HANDSHAKE_IFC_MEMORY = 0, /*!< Destination handshaking interface MEMORY */ + DMA_DST_HANDSHAKE_IFC_I2C0_TX = DMA_CH_CR3_DHSIF_I2C0_TX, /*!< Destination handshaking interface I2C0_TX */ + DMA_DST_HANDSHAKE_IFC_I2C0_RX = DMA_CH_CR3_DHSIF_I2C0_RX, /*!< Destination handshaking interface I2C0_RX */ + DMA_DST_HANDSHAKE_IFC_I2C1_TX = DMA_CH_CR3_DHSIF_I2C1_TX, /*!< Destination handshaking interface I2C1_TX */ + DMA_DST_HANDSHAKE_IFC_I2C1_RX = DMA_CH_CR3_DHSIF_I2C1_RX, /*!< Destination handshaking interface I2C1_RX */ + DMA_DST_HANDSHAKE_IFC_UART0_TX = DMA_CH_CR3_DHSIF_UART0_TX, /*!< Destination handshaking interface UART0_TX */ + DMA_DST_HANDSHAKE_IFC_UART0_RX = DMA_CH_CR3_DHSIF_UART0_RX, /*!< Destination handshaking interface UART0_RX */ + DMA_DST_HANDSHAKE_IFC_UART1_TX = DMA_CH_CR3_DHSIF_UART1_TX, /*!< Destination handshaking interface UART1_TX */ + DMA_DST_HANDSHAKE_IFC_UART1_RX = DMA_CH_CR3_DHSIF_UART1_RX, /*!< Destination handshaking interface UART1_RX */ +} DMA_DstHandshakeIfcETypeDef; + +/** + * @brief DMA channel type definition + */ +typedef enum { + DMA_CHANNEL_0 = 0U, /*!< DMA Channel 0 */ + DMA_CHANNEL_1 = 1U, /*!< DMA Channel 1 */ + DMA_CHANNEL_NUM = 2U, /*!< DMA Channel Number */ + DMA_CHANNEL_INVALID = 0xFFU, /*!< DMA Channel Invalid */ +} DMA_ChannelETypeDef; + +/** + * @brief DMA State type definition + */ +typedef enum { + DMA_STATE_RESET = 0, /*!< DMA State Reset: not yet initialized or disabled */ + DMA_STATE_READY, /*!< DMA State Ready: initialized and ready for use */ + DMA_STATE_BUSY, /*!< DMA State Busy: process is ongoing */ +} DMA_StateETypeDef; + + +/** + * @brief DMA IRQ callback function type definition + */ +typedef void (*DMA_IRQCallback)(void *arg); + + +/** + * @brief DMA user config type definition + */ +typedef struct __DMA_UserCfgTypeDef { + DMA_TransTypeETypeDef trans_type; /*!< transfer type */ + DMA_SrcAddrModeETypeDef src_addr_mode; /*!< source address mode */ + DMA_DstAddrModeETypeDef dst_addr_mode; /*!< destination address mode */ + DMA_SrcTransWidthETypeDef src_data_width; /*!< source data width */ + DMA_DstTransWidthETypeDef dst_data_width; /*!< destination data width */ + DMA_SrcHandshakeIfcETypeDef src_hs_ifc; /*!< source handshake interface */ + DMA_DstHandshakeIfcETypeDef dst_hs_ifc; /*!< destination handshake interface */ + + void *end_arg; /*!< argument of transfer complete callback fucntion */ + DMA_IRQCallback end_callback; /*!< transfer complete callback fucntion */ + void *err_arg; /*!< argument of transfer error callback fucntion */ + DMA_IRQCallback err_callback; /*!< transfer error callback fucntion */ +} DMA_UserCfgTypeDef; + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup DMA_LL_Exported_Macros DMA LL Exported Macros + * @brief DMA LL Exported Macros + * @{ + */ + +/** + * @brief Source address set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param addr Source address + * @return None + */ +#define __LL_DMA_SrcAddr_Set(__DMA__, ch, addr) WRITE_REG((__DMA__)->CH[(ch)].SAR, addr) + + +/** + * @brief Destination address set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param addr Destination address + * @return None + */ +#define __LL_DMA_DstAddr_Set(__DMA__, ch, addr) WRITE_REG((__DMA__)->CH[(ch)].DAR, addr) + + +/** + * @brief Source peripheral bus set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param bus Source peripheral bus + * @return None + */ +#define __LL_DMA_SrcPeriphBus_Set(__DMA__, ch, bus) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_SMS_Msk, bus) + +/** + * @brief Destination peripheral bus set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param bus Destination peripheral bus + * @return None + */ +#define __LL_DMA_DstPeriphBus_Set(__DMA__, ch, bus) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_DMS_Msk, bus) + +/** + * @brief Transfer type set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param type Transfer type + * @return None + */ +#define __LL_DMA_TransType_Set(__DMA__, ch, type) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_TTC_Msk, type) + +/** + * @brief Source burst length set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param len Source burst length + * @return None + */ +#define __LL_DMA_SrcBurstLen_Set(__DMA__, ch, len) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_SBTL_Msk, len) + +/** + * @brief Destination burst length set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param len Destination burst length + * @return None + */ +#define __LL_DMA_DstBurstLen_Set(__DMA__, ch, len) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_DBTL_Msk, len) + +/** + * @brief Source address mode set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param mode Source address mode + * @return None + */ +#define __LL_DMA_SrcAddrMode_Set(__DMA__, ch, mode) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_SINC_Msk, mode) + +/** + * @brief Destination address mode set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param mode Destination address mode + * @return None + */ +#define __LL_DMA_DstAddrMode_Set(__DMA__, ch, mode) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_DINC_Msk, mode) + +/** + * @brief Source transfer width set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param width Source transfer width + * @return None + */ +#define __LL_DMA_SrcTransWidth_Set(__DMA__, ch, width) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_STW_Msk, width) + +/** + * @brief Source transfer width get + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @retval 0 8 bits + * @retval 1 16 bits + * @retval 2 32 bits + */ +#define __LL_DMA_SrcTransWidth_Get(__DMA__, ch) (READ_BIT((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_STW_Msk) >> DMA_CH_CR0_STW_Pos) + +/** + * @brief Destination transfer width set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param width Destination transfer width + * @return None + */ +#define __LL_DMA_DstTransWidth_Set(__DMA__, ch, width) MODIFY_REG((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_DTW_Msk, width) + +/** + * @brief Channel interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_Channel_Int_En(__DMA__, ch) SET_BIT((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_CHIE_Msk) + +/** + * @brief Channel interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_Channel_Int_Dis(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR0, DMA_CH_CR0_CHIE_Msk) + +/** + * @brief Channel register CR0 write + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param val write value + * @return None + */ +#define __LL_DMA_ChannelRegCR0_Write(__DMA__, ch, val) WRITE_REG((__DMA__)->CH[(ch)].CR0, val) + + +/** + * @brief Judge is block transfer done or not + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @retval 0 isn't block transfer done + * @retval 1 is block transfer done + */ +#define __LL_DMA_IsBlockTransDone(__DMA__, ch) (READ_BIT((__DMA__)->CH[(ch)].CR1, DMA_CH_CR1_DONE_Msk) >> DMA_CH_CR1_DONE_Pos) + +/** + * @brief Block transfer done clear + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_BlockTransDone_Clr(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR1, DMA_CH_CR1_DONE_Msk) + +/** + * @brief Block transfer count set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param cnt Block transfer count + * @return None + */ +#define __LL_DMA_BlockTransCnt_Set(__DMA__, ch, cnt) \ + MODIFY_REG((__DMA__)->CH[(ch)].CR1, DMA_CH_CR1_BTCNT_Msk, (((cnt) & 0xfffUL) << DMA_CH_CR1_BTCNT_Pos)) + +/** + * @brief Channel register CR1 write + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param val write value + * @return None + */ +#define __LL_DAM_ChannelRegCR1_Write(__DMA__, ch, val) WRITE_REG((__DMA__)->CH[(ch)].CR1, val) + + +/** + * @brief Burst length max set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param max Burst length max + * @return None + */ +#define __LL_DMA_BurstLenMax_Set(__DMA__, ch, max) \ + MODIFY_REG((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_MBL_Msk, (((max) & 0x3ffUL) << DMA_CH_CR2_MBL_Pos)) + +/** + * @brief Source handshake mode set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_SrcHandshakeMode_Set(__DMA__, ch) SET_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_SHSM_Msk) + +/** + * @brief Source handshake mode clear + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_SrcHandshakeMode_Clr(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_SHSM_Msk) + +/** + * @brief Destination handshake mode set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_DstHandshakeMode_Set(__DMA__, ch) SET_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_DHSM_Msk) + +/** + * @brief Destination handshake mode clear + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_DstHandshakeMode_Clr(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_DHSM_Msk) + +/** + * @brief Judge is channel FIFO empty or not + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @retval 0 isn't channel FIFO empty + * @retval 1 is channel FIFO empty + */ +#define __LL_DMA_IsChannelFIFOEmpty(__DMA__, ch) \ + (READ_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_FIFO_EF_Msk) >> DMA_CH_CR2_FIFO_EF_Pos) + +/** + * @brief Channel suspend set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_ChannelSuspend_Set(__DMA__, ch) SET_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_SUSP_Msk) + +/** + * @brief Channel suspend clear + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_ChannelSuspend_Clr(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_SUSP_Msk) + +/** + * @brief Channel priority set high + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_ChannelPriHigh_Set(__DMA__, ch) SET_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_PRI_Msk) + +/** + * @brief Channel priority set low + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_ChannelPriLow_Set(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR2, DMA_CH_CR2_PRI_Msk) + +/** + * @brief Channel register CR2 write + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param val write value + * @return None + */ +#define __LL_DAM_ChannelRegCR2_Write(__DMA__, ch, val) WRITE_REG((__DMA__)->CH[(ch)].CR2, val) + + +/** + * @brief Destination handshake interface set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param ifc Destination handshake interface + * @return None + */ +#define __LL_DMA_DstHandshakeIfc_Set(__DMA__, ch, ifc) MODIFY_REG((__DMA__)->CH[(ch)].CR3, DMA_CH_CR3_DHSIF_Msk, ifc) + +/** + * @brief Source handshake interface set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param ifc Source handshake interface + * @return None + */ +#define __LL_DMA_SrcHandshakeIfc_Set(__DMA__, ch, ifc) MODIFY_REG((__DMA__)->CH[(ch)].CR3, DMA_CH_CR3_SHSIF_Msk, ifc) + +/** + * @brief FIFO mode half set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_FIFOModeHalf_Set(__DMA__, ch) SET_BIT((__DMA__)->CH[(ch)].CR3, DMA_CH_CR3_FMD_Msk) + +/** + * @brief FIFO mode once set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_FIFOModeOnce_Set(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR3, DMA_CH_CR3_FMD_Msk) + +/** + * @brief Channel folw control mode source request set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_ChFlowModeSrcReq_Set(__DMA__, ch) CLEAR_BIT((__DMA__)->CH[(ch)].CR3, DMA_CH_CR3_FCMD_Msk) + +/** + * @brief Channel folw control mode destination request set + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @return None + */ +#define __LL_DMA_ChFlowModeDstReq_Set(__DMA__, ch) SET_BIT((__DMA__)->CH[(ch)].CR3, DMA_CH_CR3_FCMD_Msk) + +/** + * @brief Channel register CR3 write + * @param __DMA__ Specifies DMA peripheral + * @param ch DMA channel + * @param val write value + * @return None + */ +#define __LL_DAM_ChannelRegCR3_Write(__DMA__, ch, val) WRITE_REG((__DMA__)->CH[(ch)].CR3, val) + + +/** + * @brief Channel 1 transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 1 transfer hasn't completed + * @retval 1 Channel 1 transfer has completed + */ +#define __LL_DMA_Ch1TransComSta_Get(__DMA__) (READ_BIT((__DMA__)->TSR, DMA_TSR_TS_CH1_Msk) >> DMA_TSR_TS_CH1_Pos) + +/** + * @brief Channel 0 transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 0 transfer hasn't completed + * @retval 1 Channel 0 transfer has completed + */ +#define __LL_DMA_Ch0TransComSta_Get(__DMA__) (READ_BIT((__DMA__)->TSR, DMA_TSR_TS_CH0_Msk) >> DMA_TSR_TS_CH0_Pos) + + +/** + * @brief Channel 1 block transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 1 block transfer hasn't completed + * @retval 1 Channel 1 block transfer has completed + */ +#define __LL_DMA_Ch1BlockTransComSta_Get(__DMA__) (READ_BIT((__DMA__)->BTSR, DMA_BTSR_BTS_CH1_Msk) >> DMA_BTSR_BTS_CH1_Pos) + +/** + * @brief Channel 0 block transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 0 block transfer hasn't completed + * @retval 1 Channel 0 block transfer has completed + */ +#define __LL_DMA_Ch0BlockTransComSta_Get(__DMA__) (READ_BIT((__DMA__)->BTSR, DMA_BTSR_BTS_CH0_Msk) >> DMA_BTSR_BTS_CH0_Pos) + + +/** + * @brief Channel 1 source transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 1 source transfer hasn't completed + * @retval 1 Channel 1 source transfer has completed + */ +#define __LL_DMA_Ch1SrcTransComSta_Get(__DMA__) (READ_BIT((__DMA__)->STSR, DMA_STSR_STS_CH1_Msk) >> DMA_STSR_STS_CH1_Pos) + +/** + * @brief Channel 0 source transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 0 source transfer hasn't completed + * @retval 1 Channel 0 source transfer has completed + */ +#define __LL_DMA_Ch0SrcTransComSta_Get(__DMA__) (READ_BIT((__DMA__)->STSR, DMA_STSR_STS_CH0_Msk) >> DMA_STSR_STS_CH0_Pos) + + +/** + * @brief Channel 1 destination transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 1 destination transfer hasn't completed + * @retval 1 Channel 1 destination transfer has completed + */ +#define __LL_DMA_Ch1DstTransComSta_Get(__DMA__) (READ_BIT((__DMA__)->DTSR, DMA_DTSR_DTS_CH1_Msk) >> DMA_DTSR_DTS_CH1_Pos) + +/** + * @brief Channel 0 destination transfer complete status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 0 destination transfer hasn't completed + * @retval 1 Channel 0 destination transfer has completed + */ +#define __LL_DMA_Ch0DstTransComSta_Get(__DMA__) (READ_BIT((__DMA__)->DTSR, DMA_DTSR_DTS_CH0_Msk) >> DMA_DTSR_DTS_CH0_Pos) + + +/** + * @brief Channel 1 transfer error status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 1 transfer normal + * @retval 1 Channel 1 transfer error + */ +#define __LL_DMA_Ch1TransErrSta_Get(__DMA__) (READ_BIT((__DMA__)->TESR, DMA_TESR_TES_CH1_Msk) >> DMA_TESR_TES_CH1_Pos) + +/** + * @brief Channel 0 transfer error status get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 Channel 0 transfer normal + * @retval 1 Channel 0 transfer error + */ +#define __LL_DMA_Ch0TransErrSta_Get(__DMA__) (READ_BIT((__DMA__)->TESR, DMA_TESR_TES_CH0_Msk) >> DMA_TESR_TES_CH0_Pos) + + +/** + * @brief Channel 1 transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch1TransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->TIPR, DMA_TIPR_TIP_CH1_Msk) >> DMA_TIPR_TIP_CH1_Pos) + +/** + * @brief Channel 0 transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch0TransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->TIPR, DMA_TIPR_TIP_CH0_Msk) >> DMA_TIPR_TIP_CH0_Pos) + + +/** + * @brief Channel 1 block transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch1BlockTransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->BTIPR, DMA_BTIPR_BTIF_CH1_Msk) >> DMA_BTIPR_BTIF_CH1_Pos) + +/** + * @brief Channel 0 block transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch0BlockTransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->BTIPR, DMA_BTIPR_BTIF_CH0_Msk) >> DMA_BTIPR_BTIF_CH0_Pos) + + +/** + * @brief Channel 1 source transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch1SrcTransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->STIPR, DMA_STIPR_STIF_CH1_Msk) >> DMA_STIPR_STIF_CH1_Pos) + +/** + * @brief Channel 0 source transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch0SrcTransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->STIPR, DMA_STIPR_STIF_CH0_Msk) >> DMA_STIPR_STIF_CH0_Pos) + + +/** + * @brief Channel 1 destination transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch1DstTransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->DTIPR, DMA_DTIPR_DTIF_CH1_Msk) >> DMA_DTIPR_DTIF_CH1_Pos) + +/** + * @brief Channel 0 destination transfer complete interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch0DstTransComIntSta_Get(__DMA__) (READ_BIT((__DMA__)->DTIPR, DMA_DTIPR_DTIF_CH0_Msk) >> DMA_DTIPR_DTIF_CH0_Pos) + + +/** + * @brief Channel 1 transfer error interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch1TransErrIntSta_Get(__DMA__) (READ_BIT((__DMA__)->TEIPR, DMA_TEIPR_TEIF_CH1_Msk) >> DMA_TEIPR_TEIF_CH1_Pos) + +/** + * @brief Channel 0 transfer error interrupt pending get + * @param __DMA__ Specifies DMA peripheral + * @retval 0 no pending + * @retval 1 pending + */ +#define __LL_DMA_Ch0TransErrIntSta_Get(__DMA__) (READ_BIT((__DMA__)->TEIPR, DMA_TEIPR_TEIF_CH0_Msk) >> DMA_TEIPR_TEIF_CH0_Pos) + + +/** + * @brief Channel 1 transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1TransCom_Int_En(__DMA__) SET_BIT((__DMA__)->TIMR, DMA_TIMR_TIWE_CH1_Msk | DMA_TIMR_TIE_CH1_Msk) + +/** + * @brief Channel 1 transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1TransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->TIMR, DMA_TIMR_TIWE_CH1_Msk | DMA_TIMR_TIE_CH1_Msk, DMA_TIMR_TIWE_CH1_Msk | (0x0 << DMA_TIMR_TIE_CH1_Pos)) + +/** + * @brief Channel 0 transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0TransCom_Int_En(__DMA__) SET_BIT((__DMA__)->TIMR, DMA_TIMR_TIWE_CH0_Msk | DMA_TIMR_TIE_CH0_Msk) + +/** + * @brief Channel 0 transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0TransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->TIMR, DMA_TIMR_TIWE_CH0_Msk | DMA_TIMR_TIE_CH0_Msk, DMA_TIMR_TIWE_CH0_Msk | (0x0 << DMA_TIMR_TIE_CH0_Pos)) + +/** + * @brief Reg TIMR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegTIMR_Write(__DMA__, val) WRITE_REG((__DMA__)->TIMR, val) + + +/** + * @brief Channel 1 block transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1BlockTransCom_Int_En(__DMA__) SET_BIT((__DMA__)->BTIMR, DMA_BTIMR_BTIWE_CH1_Msk | DMA_BTIMR_BTIE_CH1_Msk) + +/** + * @brief Channel 1 block transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1BlockTransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->BTIMR, DMA_BTIMR_BTIWE_CH1_Msk | DMA_BTIMR_BTIE_CH1_Msk, DMA_BTIMR_BTIWE_CH1_Msk | (0x0 << DMA_BTIMR_BTIE_CH1_Pos)) + +/** + * @brief Channel 0 block transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0BlockTransCom_Int_En(__DMA__) SET_BIT((__DMA__)->BTIMR, DMA_BTIMR_BTIWE_CH0_Msk | DMA_BTIMR_BTIE_CH0_Msk) + +/** + * @brief Channel 0 block transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0BlockTransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->BTIMR, DMA_BTIMR_BTIWE_CH0_Msk | DMA_BTIMR_BTIE_CH0_Msk, DMA_BTIMR_BTIWE_CH0_Msk | (0x0 << DMA_BTIMR_BTIE_CH0_Pos)) + +/** + * @brief Reg BTIMR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegBTIMR_Write(__DMA__, val) WRITE_REG((__DMA__)->BTIMR, val) + + +/** + * @brief Channel 1 source transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1SrcTransCom_Int_En(__DMA__) SET_BIT((__DMA__)->STIMR, DMA_STIMR_STIWE_CH1_Msk | DMA_STIMR_STIE_CH1_Msk) + +/** + * @brief Channel 1 source transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1SrcTransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->STIMR, DMA_STIMR_STIWE_CH1_Msk | DMA_STIMR_STIE_CH1_Msk, DMA_STIMR_STIWE_CH1_Msk | (0x0 << DMA_STIMR_STIE_CH1_Pos)) + +/** + * @brief Channel 0 source transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0SrcTransCom_Int_En(__DMA__) SET_BIT((__DMA__)->STIMR, DMA_STIMR_STIWE_CH0_Msk | DMA_STIMR_STIE_CH0_Msk) + +/** + * @brief Channel 0 source transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0SrcTransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->STIMR, DMA_STIMR_STIWE_CH0_Msk | DMA_STIMR_STIE_CH0_Msk, DMA_STIMR_STIWE_CH0_Msk | (0x0 << DMA_STIMR_STIE_CH0_Pos)) + +/** + * @brief Reg STIMR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegSTIMR_Write(__DMA__, val) WRITE_REG((__DMA__)->STIMR, val) + + +/** + * @brief Channel 1 destination transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1DstTransCom_Int_En(__DMA__) SET_BIT((__DMA__)->DTIMR, DMA_DTIMR_DTIWE_CH1_Msk | DMA_DTIMR_DTIE_CH1_Msk) + +/** + * @brief Channel 1 destination transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1DstTransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->DTIMR, DMA_DTIMR_DTIWE_CH1_Msk | DMA_DTIMR_DTIE_CH1_Msk, DMA_DTIMR_DTIWE_CH1_Msk | (0x0 << DMA_DTIMR_DTIE_CH1_Pos)) + +/** + * @brief Channel 0 destination transfer complete interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0DstTransCom_Int_En(__DMA__) SET_BIT((__DMA__)->DTIMR, DMA_DTIMR_DTIWE_CH0_Msk | DMA_DTIMR_DTIE_CH0_Msk) + +/** + * @brief Channel 0 destination transfer complete interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0DstTransCom_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->DTIMR, DMA_DTIMR_DTIWE_CH0_Msk | DMA_DTIMR_DTIE_CH0_Msk, DMA_DTIMR_DTIWE_CH0_Msk | (0x0 << DMA_DTIMR_DTIE_CH0_Pos)) + +/** + * @brief Reg DTIMR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegDTIMR_Write(__DMA__, val) WRITE_REG((__DMA__)->DTIMR, val) + + +/** + * @brief Channel 1 transfer error interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1TransErr_Int_En(__DMA__) SET_BIT((__DMA__)->TEIMR, DMA_TEIMR_TEIWE_CH1_Msk | DMA_TEIMR_TEIE_CH1_Msk) + +/** + * @brief Channel 1 transfer error interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1TransErr_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->TEIMR, DMA_TEIMR_TEIWE_CH1_Msk | DMA_TEIMR_TEIE_CH1_Msk, DMA_TEIMR_TEIWE_CH1_Msk | (0x0 << DMA_TEIMR_TEIE_CH1_Pos)) + +/** + * @brief Channel 0 transfer error interrupt enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0TransErr_Int_En(__DMA__) SET_BIT((__DMA__)->TEIMR, DMA_TEIMR_TEIWE_CH0_Msk | DMA_TEIMR_TEIE_CH0_Msk) + +/** + * @brief Channel 0 transfer error interrupt disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0TransErr_Int_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->TEIMR, DMA_TEIMR_TEIWE_CH0_Msk | DMA_TEIMR_TEIE_CH0_Msk, DMA_TEIMR_TEIWE_CH0_Msk | (0x0 << DMA_TEIMR_TEIE_CH0_Pos)) + +/** + * @brief Reg TEIMR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegTEIMR_Write(__DMA__, val) WRITE_REG((__DMA__)->TEIMR, val) + + +/** + * @brief Channel 1 transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1TransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->TCR, DMA_TCR_TC_CH1_Msk) + +/** + * @brief Channel 0 transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0TransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->TCR, DMA_TCR_TC_CH0_Msk) + +/** + * @brief Reg TCR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegTCR_Write(__DMA__, val) WRITE_REG((__DMA__)->TCR, val) + + +/** + * @brief Channel 1 block transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1BlockTransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->BTCR, DMA_BTCR_BTC_CH1_Msk) + +/** + * @brief Channel 0 block transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0BlockTransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->BTCR, DMA_BTCR_BTC_CH0_Msk) + +/** + * @brief Reg BTCR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegBTCR_Write(__DMA__, val) WRITE_REG((__DMA__)->BTCR, val) + + +/** + * @brief Channel 1 source transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1SrcTransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->STCR, DMA_STCR_STC_CH1_Msk) + +/** + * @brief Channel 0 source transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0SrcTransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->STCR, DMA_STCR_STC_CH0_Msk) + +/** + * @brief Reg STCR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegSTCR_Write(__DMA__, val) WRITE_REG((__DMA__)->STCR, val) + + +/** + * @brief Channel 1 destination transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1DstTransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->DTCR, DMA_DTCR_DTC_CH1_Msk) + +/** + * @brief Channel 0 destination transfer complete status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0DstTransComSta_Clr(__DMA__) WRITE_REG((__DMA__)->DTCR, DMA_DTCR_DTC_CH0_Msk) + +/** + * @brief Reg DTCR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegDTCR_Write(__DMA__, val) WRITE_REG((__DMA__)->DTCR, val) + + +/** + * @brief Channel 1 transfer error status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1TransErrSta_Clr(__DMA__) WRITE_REG((__DMA__)->TECR, DMA_TECR_TEC_CH1_Msk) + +/** + * @brief Channel 0 transfer error status clear + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0TransErrSta_Clr(__DMA__) WRITE_REG((__DMA__)->TECR, DMA_TECR_TEC_CH0_Msk) + +/** + * @brief Reg TECR Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegTECR_Write(__DMA__, val) WRITE_REG((__DMA__)->TECR, val) + + +/** + * @brief Peripheral enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Periph_En(__DMA__) SET_BIT((__DMA__)->CR0, DMA_CR0_PEN_Msk) + +/** + * @brief Peripheral disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Periph_Dis(__DMA__) CLEAR_BIT((__DMA__)->CR0, DMA_CR0_PEN_Msk) + +/** + * @brief Reg CR0 Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegCR0_Write(__DMA__, val) WRITE_REG((__DMA__)->CR0, val) + + +/** + * @brief Channel 1 enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1_En(__DMA__) SET_BIT((__DMA__)->CR1, DMA_CR1_CHWE_CH1_Msk | DMA_CR1_CHEN_CH1_Msk) + +/** + * @brief Channel 1 disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch1_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->CR1, DMA_CR1_CHWE_CH1_Msk | DMA_CR1_CHEN_CH1_Msk, DMA_CR1_CHWE_CH1_Msk | (0x0 << DMA_CR1_CHEN_CH1_Pos)) + +/** + * @brief Channel 0 enable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0_En(__DMA__) SET_BIT((__DMA__)->CR1, DMA_CR1_CHWE_CH0_Msk | DMA_CR1_CHEN_CH0_Msk) + +/** + * @brief Channel 0 disable + * @param __DMA__ Specifies DMA peripheral + * @return None + */ +#define __LL_DMA_Ch0_Dis(__DMA__) \ + MODIFY_REG((__DMA__)->CR1, DMA_CR1_CHWE_CH0_Msk | DMA_CR1_CHEN_CH0_Msk, DMA_CR1_CHWE_CH0_Msk | (0x0 << DMA_CR1_CHEN_CH0_Pos)) + +/** + * @brief Reg CR1 Write + * @param __DMA__ Specifies DMA peripheral + * @param val write value + * @return None + */ +#define __LL_DMA_RegCR1_Write(__DMA__, val) WRITE_REG((__DMA__)->CR1, val) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup DMA_LL_Exported_Functions + * @{ + */ + +/** @addtogroup DMA_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_DMA_Init(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, DMA_UserCfgTypeDef *user_cfg); +LL_StatusETypeDef LL_DMA_DeInit(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch); +/** + * @} + */ + + +/** @addtogroup DMA_LL_Exported_Functions_Group2 + * @{ + */ +DMA_ChannelETypeDef LL_DMA_ChannelRequest(void); +DMA_ChannelETypeDef LL_DMA_ChReqSpecific(DMA_ChannelETypeDef ch); +void LL_DMA_ChannelRelease(DMA_ChannelETypeDef ch); +/** + * @} + */ + + +/** @addtogroup DMA_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_DMA_Start_CPU(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, + uint32_t src_addr, uint32_t dst_addr, uint32_t data_len); +LL_StatusETypeDef LL_DMA_Start_IT(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, + uint32_t src_addr, uint32_t dst_addr, uint32_t data_len); +LL_StatusETypeDef LL_DMA_Stop_CPU(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch); +LL_StatusETypeDef LL_DMA_Stop_IT(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch); +LL_StatusETypeDef LL_DMA_WaitComplete_CPU(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, uint32_t timeout); +/** + * @} + */ + + +/** @addtogroup DMA_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_DMA_IRQHandler(DMA_TypeDef *Instance); +/** + * @} + */ + + +/** + * @} + */ + + +/* Private constants ---------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_DMA_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_ecu.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_ecu.h new file mode 100644 index 0000000000..71279e206a --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_ecu.h @@ -0,0 +1,726 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_ecu.h + * @author MCD Application Team + * @brief Header file of ECU LL module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_ECU_H_ +#define _TAE32F53XX_LL_ECU_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup ECU_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup ECU_LL_Exported_Constants ECU LL Exported Constants + * @brief ECU LL Exported Constants + * @{ + */ + +/** @defgroup LL_ECU_ENABLE ECU enable define + * @brief ECU Enable Bit Set and Bit Reset + * @{ + */ +#define ECU_DISABLE (0x00000000U) /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC0_DTFLAG0 = 0x0, + /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC0_DTFLAG1 = ECU_PRC_DATSEL_0, + /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC0_DTFLAG2 = ECU_PRC_DATSEL_1, + /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC0_DTFLAG3 = ECU_PRC_DATSEL_1 | ECU_PRC_DATSEL_0, + /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC1_DTFLAG0 = ECU_PRC_DATSEL_2, + /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC1_DTFLAG1 = ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_0, + /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC1_DTFLAG2 = ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_1, + /*!ADDR_DATA_FLAG */ + ECU_PSR_DATSEL_ADC1_DTFLAG3 = ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_1 | ECU_PRC_DATSEL_0, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC0_ADFLAG0 = 0x0, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC0_ADFLAG1 = ECU_PRC_ADRSEL_0, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC0_ADFLAG2 = ECU_PRC_ADRSEL_1, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC0_ADFLAG3 = ECU_PRC_ADRSEL_1 | ECU_PRC_ADRSEL_0, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC1_ADFLAG0 = ECU_PRC_ADRSEL_2, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC1_ADFLAG1 = ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_0, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC1_ADFLAG2 = ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_1, + /*!ADDR_DATA_FLAG*/ + ECU_PSR_ADRSEL_ADC1_ADFLAG3 = ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_1 | ECU_PRC_ADRSEL_0, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC0_PPFLAG0 = 0x0, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC0_PPFLAG1 = ECU_PRC_CRSSEL_0, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC0_PPFLAG2 = ECU_PRC_CRSSEL_1, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC0_PPFLAG3 = ECU_PRC_CRSSEL_1 | ECU_PRC_CRSSEL_0, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC1_PPFLAG0 = ECU_PRC_CRSSEL_2, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC1_PPFLAG1 = ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_0, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC1_PPFLAG2 = ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_1, + /*!PSRCU/PSRCD */ + ECU_PSR_CRSSEL_ADC1_PPFLAG3 = ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_1 | ECU_PRC_CRSSEL_0, + /*!CON, ECU_CON_ENABLE) + +/** + * @brief Disable the ECU module. + * @param __INSTANCE__ Specifies ECU peripheral + * @return None + */ +#define __LL_ECU_MODULE_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CON, ECU_CON_ENABLE) + +/** + * @brief Get the ECU module states. + * @param __INSTANCE__ Specifies ECU peripheral + * @return ENABLE : the module is enable + * DISABLE : the module is disable + */ +#define __LL_ECU_GET_STA(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_ENABLE)) == 0x1UL) ? ENABLE : DISABLE) + +/** + * @brief Enable the specified ECU Calculate complete interrupt. + * @param __INSTANCE__ Specifies ECU peripheral + * @return None + */ +#define __LL_ECU_DONE_IT_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CON, ECU_CON_INTEN) + +/** + * @brief Disable the specified ECU Calculate complete interrupt. + * @param __INSTANCE__ Specifies ECU peripheral + * @return None + */ +#define __LL_ECU_DONE_IT_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CON, ECU_CON_INTEN) + +/** + * @brief Check the ECU Calculate complete interrupts are enabled or disable. + * @param __INSTANCE__ Specifies ECU peripheral + * @return SET : the interrupt is enable + * RESET : the interrupt is disable + */ +#define __LL_ECU_DONE_GET_IT(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_INTEN)) == 0x02UL) ? SET : RESET) + +/** + * @brief Check whether the specified ECU Calculate complete pending flag is set or not. + * @param __INSTANCE__ Specifies ECU peripheral + * @return SET : the interrupt flag is set + * RESET : the interrupt flag is reset + */ +#define __LL_ECU_DONE_GET_FLAG(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_INT)) == 0x8000UL) ? SET : RESET) + +/** + * @brief Clear the specified ECU Calculate complete pending flags. + * @param __INSTANCE__ Specifies ECU peripheral + * @return None + */ +#define __LL_ECU_DONE_CLEAR_FLAG(__INSTANCE__) SET_BIT((__INSTANCE__)->CON, ECU_CON_INT) + +/** + * @brief Input data square enable, after the completion of the calculation automatically reset + * @param __INSTANCE__ Specifies ECU peripheral + * @return None + */ +#define __LL_ECU_SQRT_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CON, ECU_CON_SQRT) + +/** + * @brief Gets the square root completion flag + * @param __INSTANCE__ Specifies ECU peripheral + * @return RESET That means the square root is complete + * SET That means the square root is not complete + */ +#define __LL_ECU_SQRT_DONE_FLAG(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_SQRT)) == 0x4000UL) ? SET : RESET) + +/** + * @brief Sets the zero crossing event that needs to be selected + * @param __INSTANCE__ Specifies ECU peripheral + * @param __EVENT__ cross zero event as follow: + * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAF0 + * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAG1 + * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAG2 + * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAG3 + * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG0 + * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG1 + * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG2 + * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG3 + * @arg @ref ECU_PSR_CRSSEL_TIM0_OC + * @arg @ref ECU_PSR_CRSSEL_TIM1_OC + * @arg @ref ECU_PSR_CRSSEL_TIM2_OC + * @arg @ref ECU_PSR_CRSSEL_TIM3_OC + * @arg @ref ECU_PSR_CRSSEL_TIM4_OC + * @arg @ref ECU_PSR_CRSSEL_TIM5_OC + * @arg @ref ECU_PSR_CRSSEL_TIM6_OC + * @arg @ref ECU_PSR_CRSSEL_TIM7_OC + * @return None + */ +#define __LL_ECU_CROSS_ZERO_EVENT(__INSTANCE__, __EVENT__) MODIFY_REG((__INSTANCE__)->PRC, ECU_PRC_CRSSEL, __EVENT__) + +/** + * @brief Sets the data event that needs to be selected + * @param __INSTANCE__ Specifies ECU peripheral + * @param __EVENT__ cross zero event as follow: + * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAF0 + * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAG1 + * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAG2 + * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAG3 + * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG0 + * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG1 + * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG2 + * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG3 + * @arg @ref ECU_PSR_DATSEL_TIM0_OC + * @arg @ref ECU_PSR_DATSEL_TIM1_OC + * @arg @ref ECU_PSR_DATSEL_TIM2_OC + * @arg @ref ECU_PSR_DATSEL_TIM3_OC + * @arg @ref ECU_PSR_DATSEL_TIM4_OC + * @arg @ref ECU_PSR_DATSEL_TIM5_OC + * @arg @ref ECU_PSR_DATSEL_TIM6_OC + * @arg @ref ECU_PSR_DATSEL_TIM7_OC + * @return None + */ +#define __LL_ECU_DATA_FLAG_EVENT(__INSTANCE__, __EVENT__) MODIFY_REG((__INSTANCE__)->PRC, ECU_PRC_DATSEL, __EVENT__) + + +/** + * @brief Sets the addr_data flag event that needs to be selected + * @param __INSTANCE__ Specifies ECU peripheral + * @param __EVENT__ cross zero event as follow: + * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAF0 + * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAG1 + * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAG2 + * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAG3 + * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG0 + * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG1 + * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG2 + * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG3 + * @arg @ref ECU_PSR_ADRSEL_TIM0_OC + * @arg @ref ECU_PSR_ADRSEL_TIM1_OC + * @arg @ref ECU_PSR_ADRSEL_TIM2_OC + * @arg @ref ECU_PSR_ADRSEL_TIM3_OC + * @arg @ref ECU_PSR_ADRSEL_TIM4_OC + * @arg @ref ECU_PSR_ADRSEL_TIM5_OC + * @arg @ref ECU_PSR_ADRSEL_TIM6_OC + * @arg @ref ECU_PSR_ADRSEL_TIM7_OC + * @return None + */ +#define __LL_ECU_ADDR_FLAG_EVENT(__INSTANCE__, __EVENT__) MODIFY_REG((__INSTANCE__)->PRC, ECU_PRC_ADRSEL, __EVENT__) + +/** + * @brief Get the average effective value of the voltage + * @param __INSTANCE__ Specifies ECU peripheral + * @return The result of the voltage + */ +#define __LL_ECU_GET_VRMS(__INSTANCE__) READ_BIT((__INSTANCE__)->V, ECU_V_VRMS) + +/** + * @brief Get the average effective value of the current + * @param __INSTANCE__ Specifies ECU peripheral + * @return The result of the current + */ +#define __LL_ECU_GET_IRMS(__INSTANCE__) READ_BIT((__INSTANCE__)->I, ECU_I_IRMS) + +/** + * @brief Get the average active power + * @param __INSTANCE__ Specifies ECU peripheral + * @return The result of average active power + */ +#define __LL_ECU_P_PAVG(__INSTANCE__) READ_REG((__INSTANCE__)->P) + +/** + * @brief Get the average reactive power + * @param __INSTANCE__ Specifies ECU peripheral + * @return The result of average reactive power + */ +#define __LL_ECU_Q_QAVG(__INSTANCE__) READ_REG((__INSTANCE__)->Q) + +/** + * @brief Get the apparent power value + * @param __INSTANCE__ Specifies ECU peripheral + * @return The result of apparent power + */ +#define __LL_ECU_S_SCAL(__INSTANCE__) READ_REG((__INSTANCE__)->S) + +/** + * @brief Get the power factor value + * @param __INSTANCE__ Specifies ECU peripheral + * @return The result of power factor + */ +#define __LL_ECU_PF_PFCAL(__INSTANCE__) READ_REG((__INSTANCE__)->PF) + +/** + * @brief Get the fundamental frequency value + * @param __INSTANCE__ Specifies ECU peripheral + * @return The result of fundamental frequency + */ +#define __LL_ECU_F_FCNT(__INSTANCE__) READ_BIT((__INSTANCE__)->F, ECU_F_FCNT) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup ECU_LL_Exported_Functions + * @{ + */ + +/** @addtogroup ECU_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_ECU_Init(ECU_TypeDef *Instance, ECU_InitTypeDef *ECU_Init); +LL_StatusETypeDef LL_ECU_DeInit(ECU_TypeDef *Instance); +void LL_ECU_MspInit(ECU_TypeDef *Instance); +void LL_ECU_MspDeInit(ECU_TypeDef *Instance); +/** + * @} + */ + +/** @addtogroup ECU_LL_Exported_Functions_Group2 + * @{ + */ +void LL_ECU_WriteSqrtInData(ECU_TypeDef *Instance, uint32_t SqrtValue); +uint32_t LL_ECU_ReadSqrtOutData(ECU_TypeDef *Instance); +/** + * @} + */ + +/** @addtogroup ECU_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_ECU_IRQHandler(ECU_TypeDef *Instance); +void LL_ECU_CalDoneCallback(ECU_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup ECU_LL_Private_Macros ECU LL Private Macros + * @brief ECU LL Private Macros + * @{ + */ + +/** + * @brief Judge is ECU enable/disable mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't ECU enable/disable mode + * @retval 1 is ECU enable/disable mode + */ +#define IS_ECU_MODULE(__MODE__) \ + ( ((__MODE__) == ECU_DISABLE) \ + || ((__MODE__) == ECU_ENABLE) \ + ) + +/** + * @brief Judge is ECU average or not + * @param __AVERAGE__ average to judge + * @retval 0 isn't ECU average + * @retval 1 is ECU average + */ +#define IS_ECU_AVERAGE(__AVERAGE__) \ + ( ((__AVERAGE__) == ECU_AVERAGE_DISABLE) \ + || ((__AVERAGE__) == ECU_AVERAGE_2PERIOD) \ + || ((__AVERAGE__) == ECU_AVERAGE_4PERIOD) \ + || ((__AVERAGE__) == ECU_AVERAGE_8PERIOD) \ + ) + +/** + * @brief Judge is ECU acsft or not + * @param __ACSFT__ acsft to judge + * @retval 0 isn't ECU acsft + * @retval 1 is ECU acsft + */ +#define IS_ECU_ACSFT(__ACSFT__) \ + ( ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_DISABLE) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_1) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_2) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_3) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_4) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_5) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_6) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_7) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_8) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_9) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_10) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_11) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_12) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_13) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_14) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_15) \ + || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_16) \ + ) + +/** + * @brief Judge is ECU apsft or not + * @param __APSFT__ apsft to judge + * @retval 0 isn't ECU apsft + * @retval 1 is ECU apsft + */ +#define IS_ECU_APSFT(__APSFT__) \ + ( ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_DISABLE) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_1) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_2) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_3) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_4) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_5) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_6) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_7) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_8) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_9) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_10) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_11) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_12) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_13) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_14) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_15) \ + || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_16) \ + ) + +/** + * @brief Judge is ECU datsel or not + * @param __DATSEL__ datsel to judge + * @retval 0 isn't ECU datsel + * @retval 1 is ECU datsel + */ +#define IS_ECU_DATSEL(__DATSEL__) \ + ( ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG0) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG1) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG2) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG3) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG0) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG1) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG2) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG3) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM0_OC) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM1_OC) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM2_OC) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM3_OC) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM4_OC) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM5_OC) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM6_OC) \ + || ((__DATSEL__) == ECU_PSR_DATSEL_TIM7_OC) \ + ) + +/** + * @brief Judge is ECU crssel or not + * @param __CRSSEL__ crssel to judge + * @retval 0 isn't ECU crssel + * @retval 1 is ECU crssel + */ +#define IS_ECU_CRSSEL(__CRSSEL__) \ + ( ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG0) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG1) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG2) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG3) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG0) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG1) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG2) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG3) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM0_OC) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM1_OC) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM2_OC) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM3_OC) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM4_OC) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM5_OC) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM6_OC) \ + || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM7_OC) \ + ) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_ECU_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_flash.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_flash.h new file mode 100644 index 0000000000..df8c01002d --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_flash.h @@ -0,0 +1,451 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_flash.h + * @author MCD Application Team + * @brief Head file for FLASH module LL driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_FLASH_H_ +#define _TAE32F53XX_LL_FLASH_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup FLASH_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup FLASH_LL_Exported_Types FLASH LL Exported Types + * @brief Set the read protection level + * @{ + */ + +/** + @brief Set the read protection level +*/ +typedef enum { + FLASH_RDP_LEVEL_0 = 0xAAU, /*!< FLASH Read Protection Level 0 */ + FLASH_RDP_LEVEL_1 = 0xFFU, /*!< FLASH Read Protection Level 1 */ + FLASH_RDP_LEVEL_2 = 0xCCU, /*!< FLASH Read Protection Level 2, Warning: When enabling read protection + level 2,it's no more possible to go back to level 1 or 0 */ +} FLASH_RDPLVETypeDef; + + +/** + @brief Write Protection State + */ +typedef enum { + FLASH_WRPSTATE_DISABLE = 0x00U, /*!< Disable the write protection of the desired sections */ + FLASH_WRPSTATE_ENABLE = 0x01U, /*!< Enable the write protection of the desired sections */ +} FLASH_WRPSTETypeDef; + +/** + * @brief Write Permission Area Control. Each AREA control 8 sections (refer to one area) in Main Memory Array + */ +typedef enum { + FLASH_WRP_AREA_1 = 0x00000001, /*!< FLASH Write Protection Area 1 */ + FLASH_WRP_AREA_2 = 0x00000002, /*!< FLASH Write Protection Area 2 */ + FLASH_WRP_AREA_3 = 0x00000004, /*!< FLASH Write Protection Area 3 */ + FLASH_WRP_AREA_4 = 0x00000008, /*!< FLASH Write Protection Area 4 */ + FLASH_WRP_AREA_5 = 0x00000010, /*!< FLASH Write Protection Area 5 */ + FLASH_WRP_AREA_6 = 0x00000020, /*!< FLASH Write Protection Area 6 */ + FLASH_WRP_AREA_7 = 0x00000040, /*!< FLASH Write Protection Area 7 */ + FLASH_WRP_AREA_8 = 0x00000080, /*!< FLASH Write Protection Area 8 */ + FLASH_WRP_AREA_9 = 0x00000100, /*!< FLASH Write Protection Area 9 */ + FLASH_WRP_AREA_10 = 0x00000200, /*!< FLASH Write Protection Area 10 */ + FLASH_WRP_AREA_11 = 0x00000400, /*!< FLASH Write Protection Area 11 */ + FLASH_WRP_AREA_12 = 0x00000800, /*!< FLASH Write Protection Area 12 */ + FLASH_WRP_AREA_13 = 0x00001000, /*!< FLASH Write Protection Area 13 */ + FLASH_WRP_AREA_14 = 0x00002000, /*!< FLASH Write Protection Area 14 */ + FLASH_WRP_AREA_15 = 0x00004000, /*!< FLASH Write Protection Area 15 */ + FLASH_WRP_AREA_16 = 0x00008000, /*!< FLASH Write Protection Area 16 */ + FLASH_WRP_AREA_17 = 0x00010000, /*!< FLASH Write Protection Area 17 */ + FLASH_WRP_AREA_18 = 0x00020000, /*!< FLASH Write Protection Area 18 */ + FLASH_WRP_AREA_19 = 0x00040000, /*!< FLASH Write Protection Area 19 */ + FLASH_WRP_AREA_20 = 0x00080000, /*!< FLASH Write Protection Area 20 */ + FLASH_WRP_AREA_ALL = 0x000FFFFF, /*!< FLASH Write Protection Area ALL */ + FLASH_WRP_AREA_Msk = FLASH_WRP_AREA_ALL, /*!< FLASH Write Protection Area Mask */ +} FLASH_WRPAREAETypeDef; + +/** + * @} + */ + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup FLASH_LL_Exported_Constants FLASH LL Exported Constants + * @brief FLASH LL Exported Constants + * @{ + */ + +/** @defgroup FLASH_Error_Codes FLASH Error Codes + * @{ + */ +#define FLASH_ERROR_NONE 0x00U /*!< No error */ +#define FLASH_ERROR_OPT 0x01U /*!< Operation error */ +#define FLASH_ERROR_WRP 0x02U /*!< Write protection error */ +#define FLASH_ERROR_RDP 0x04U /*!< Read protection error */ +#define FLASH_ERROR_ECC 0x08U /*!< ECC validity error */ +/** + * @} + */ + + +/** @defgroup FLASH_Program_Width FLASH Program Width + * @{ + */ +#define FLASH_PROG_DATA_WIDTH 16U /*!< Data width in a single programming operation.Number in bytes */ +/** + * @} + */ + + +/** @defgroup FLASH_Keys FLASH Keys + * @{ + */ +#define FLASH_KEY1 0x32107654U /*!< FLASH key1 */ +#define FLASH_KEY2 0xFEDCBA98U /*!< FLASH key2: used with FLASH_KEY1 + to unlock the FLASH Program/Erase features */ + +#define FLASH_OP_KEY 0x50035003U /*!< FLASH Operation Protection Key : + Unlock the operation of FLASH Read/Write Protection Register */ + +#define FLASH_PWR_KEY 0x50030000U /*!< FLASH pwr key: unlock the FLASH Standby/Wakeup features */ +/** + * @} + */ + +/** @defgroup FLASH_Flag_definition FLASH Flag Definition + * @{ + */ +#define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Flag BSY */ +#define FLASH_FLAG_DIF FLASH_ISR_DIF /*!< FLASH Flag DIF */ +#define FLASH_FLAG_ECCEIF FLASH_ISR_ECCEIF /*!< FLASH Flag ECCEIF */ +#define FLASH_FLAG_RPEIF FLASH_ISR_RPEIF /*!< FLASH Flag RPEIF */ +#define FLASH_FLAG_WPEIF FLASH_ISR_WPEIF /*!< FLASH Flag WPEIF */ +#define FLASH_FLAG_OPTEIF FLASH_ISR_OPTEIF /*!< FLASH Flag OPEIF */ +/** + * @} + */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup FLASH_LL_Exported_Macros FLASH LL Exported Macros + * @brief FLASH LL Exported Macros + * @{ + */ + +/** + * @brief Enable FLASH I BUS Prefetch feature. + * @note Prefetch feature should not be enabled when CPU frequency is lower than 40MHz. + * @param None + * @return None + */ +#define __LL_FLASH_I_BUS_PREFETCH_ENABLE() SET_BIT(FLASH->CR, FLASH_CR_IBPE) + +/** + * @brief Disable FLASH I BUS Prefetch feature. + * @param None + * @return None + */ +#define __LL_FLASH_I_BUS_PREFETCH_DISABLE() CLEAR_BIT(FLASH->CR, FLASH_CR_IBPE) + +/** + * @brief Enable FLASH D BUS Prefetch feature. + * @note Prefetch feature should not be enabled when CPU frequency is lower than 40MHz. + * @param None + * @return None + */ +#define __LL_FLASH_D_BUS_PREFETCH_ENABLE() SET_BIT(FLASH->CR, FLASH_CR_DBPE) + +/** + * @brief Disable FLASH D BUS Prefetch feature. + * @param None + * @return None + */ +#define __LL_FLASH_D_BUS_PREFETCH_DISABLE() CLEAR_BIT(FLASH->CR, FLASH_CR_DBPE) + +/** + * @brief FLASH Standby. + * Flash will enter standby mode aim for low power mode. + * @param None + * @return None + */ +#define __LL_FLASH_STANDBY_ENABLE() do{ WRITE_REG(FLASH->LPR, FLASH_PWR_KEY); \ + SET_BIT(FLASH->LPR, FLASH_LPR_STDBY); \ + } while (0); + +/** + * @brief FLASH Wakeup. + * Flash will exit from standby mode. + * @param None + * @return None + */ +#define __LL_FLASH_WAKEUP_ENABLE() do{ WRITE_REG(FLASH->LPR, FLASH_PWR_KEY); \ + SET_BIT(FLASH->LPR, FLASH_LPR_WKUP); \ + } while (0); + +/** + * @brief Check whether the specified status flag in FLASH_SR Register is SET or not. + * @param __FLAG__ specifies the FLASH status flag to check. + * This parameter can be ONE of the following values: + * @arg FLASH_FLAG_BSY : FLASH BUSY Status + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_FLASH_GET_STATUS_FLAG(__FLAG__) ((READ_BIT(FLASH->SR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Check whether the specified interrupt pending flag in FLASH_ISR Register is SET or not. + * @param __FLAG__ specifies the FLASH interrupt pending flag to check. + * This parameter can be ONE of the following values: + * @arg FLASH_FLAG_DIF : Done + * @arg FLASH_FLAG_ECCEIF : ECC Error + * @arg FLASH_FLAG_RPEIF : Read Protection Error + * @arg FLASH_FLAG_WPEIF : Write Protection Error + * @arg FLASH_FLAG_OPTEIF : Operation Error + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_FLASH_GET_PENDING_FLAG(__FLAG__) ((READ_BIT(FLASH->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Clear the FLASH's Pending Register flag. + * @param __FLAG__ specifies the FLASH pending flags to clear. + * This parameter can be any combination of the following values: + * @arg FLASH_FLAG_DIF : Done + * @arg FLASH_FLAG_ECCEIF : ECC Error + * @arg FLASH_FLAG_RPEIF : Read Protection Error + * @arg FLASH_FLAG_WPEIF : Write Protection Error + * @arg FLASH_FLAG_OPTEIF : Operation Error + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_FLASH_CLEAR_PENDING_FLAG(__FLAG__) WRITE_REG(FLASH->ISR, (__FLAG__)) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup FLASH_LL_Exported_Functions + * @{ + */ + +/** @addtogroup FLASH_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_FLASH_ReadProtectLevelConfig(FLASH_RDPLVETypeDef RDPLevel); +LL_StatusETypeDef LL_FLASH_WriteProtectConfig(FLASH_WRPAREAETypeDef WRPAreas, FLASH_WRPSTETypeDef WRPState); +/** + * @} + */ + + +/** @addtogroup FLASH_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_FLASH_WaitForLastOperation(uint32_t Timeout); +uint32_t LL_FLASH_GetError(void); +/** + * @} + */ + + +/** @addtogroup FLASH_LL_Exported_Functions_Group3 + * @{ + */ + +/** + * @brief Unlock the FLASH Program/Erase access. + * @param None + * @return LL Status + */ +__STATIC_INLINE LL_StatusETypeDef LL_FLASH_Unlock(void) +{ + if (READ_BIT(FLASH->CR, FLASH_CR_LOCK) != RESET) { + /* Authorize the FLASH Program/Erase access */ + WRITE_REG(FLASH->KEYR, FLASH_KEY1); + WRITE_REG(FLASH->KEYR, FLASH_KEY2); + + /* Verify FLASH is unlocked */ + if (READ_BIT(FLASH->CR, FLASH_CR_LOCK_Msk) != RESET) { + return LL_ERROR; + } + } + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Lock the FLASH Program/Erase access. + * @param None + * @return LL Status + */ +__STATIC_INLINE LL_StatusETypeDef LL_FLASH_Lock(void) +{ + /* Set the LOCK Bit to lock the FLASH Program/Erase access */ + SET_BIT(FLASH->CR, FLASH_CR_LOCK); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Unlock the FLASH write/read Protection Feature access. + * @param None + * @return LL Status + */ +__STATIC_INLINE LL_StatusETypeDef LL_FLASH_PF_Unlock(void) +{ + /* Unlock the FLASH Read/Write Operation Protection access */ + WRITE_REG(FLASH->KEYR, FLASH_OP_KEY); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Lock the FLASH write/read Protection Feature access. + * @param None + * @return LL Status + */ +__STATIC_INLINE LL_StatusETypeDef LL_FLASH_PF_Lock(void) +{ + /* Lock the Read/Write Operation Protection access */ + WRITE_REG(FLASH->KEYR, 0x00000000UL); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Launch the write/read Protection Feature reloading. + * @param None + * @retval None + */ +__STATIC_INLINE LL_StatusETypeDef LL_FLASH_PF_Launch(void) +{ + /* Set the LAU bit in FLASH_CR register to reload */ + SET_BIT(FLASH->CR, FLASH_CR_LAU); + + /* Return function status */ + return LL_OK; +} + + +LL_StatusETypeDef LL_FLASH_Program(uint32_t Address, uint8_t Data[FLASH_PROG_DATA_WIDTH]); + +LL_StatusETypeDef LL_FLASH_MultiSectorsErase(uint16_t Sector, uint16_t Num, uint16_t *SectorError); +LL_StatusETypeDef LL_FLASH_SectorErase(uint16_t Sector); + +LL_StatusETypeDef LL_FLASH_ChipErase(void); + +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/** @defgroup FLASH_LL_Private_Constants FLASH LL Private Constants + * @brief FLASH LL Private Constants + * @{ + */ + +#define FLASH_PROGRAM_ADDRESS_MASK 0x00FFFFFFU /*!< Program address mask */ +#define FLASH_TIMEOUT_MAX_VALUE 300U /*!< Max timeout for flash operations. Default 300 ticks */ + +/** + * @} + */ + + +/* Private macros ------------------------------------------------------------*/ +/** @defgroup FLASH_LL_Private_Macros FLASH LL Private Macros + * @brief FLASH LL Private Macros + * @{ + */ + +/** + * @brief Judge is write protect state or not + * @param STATE state to judge + * @retval 0 isn't write protect state + * @retval 1 is write protect state + */ +#define IS_WRITE_PROTECT_STATE(STATE) (((STATE) == FLASH_WRPSTATE_DISABLE) || \ + +/** + * @brief Judge is flash program address align 128bit or not + * @param ADDRESS address to judge + * @retval 0 isn't flash program address align 128bit + * @retval 1 is flash program address align 128bit + */ +#define IS_FLASH_PROGRAM_ADDRESS_ALIGN_128BIT(ADDRESS) (((ADDRESS) & 0xF) == 0x00U) + +/** + * @brief Judge is flash sector or not + * @param SECTOR sector to judge + * @retval 0 isn't flash sector + * @retval 1 is flash sector + */ +#define IS_FLASH_NB_SECTORS(SECTOR) ((SECTOR) < 160U) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_FLASH_H_ */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_fpll.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_fpll.h new file mode 100644 index 0000000000..f0abf10366 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_fpll.h @@ -0,0 +1,148 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_fpll.h + * @author MCD Application Team + * @brief Header file for FPLL LL Module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_FPLL_H_ +#define _TAE32F53XX_LL_FPLL_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup FPLL_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup FPLL_LL_Exported_Macros FPLL LL Exported Macros + * @brief FPLL LL Exported Macros + * @{ + */ + +/** + * @brief FPLL Enable + * @param __FPLL__ Specifies FPLL peripheral + * @return None + */ +#define __LL_FPLL_En(__FPLL__) SET_BIT((__FPLL__)->FCR, FPLL_EN_Msk) + +/** + * @brief FPLL Disable + * @param __FPLL__ Specifies FPLL peripheral + * @return None + */ +#define __LL_FPLL_Dis(__FPLL__) CLEAR_BIT((__FPLL__)->FCR, FPLL_EN_Msk) + +/** + * @brief FPLL Start + * @param __FPLL__ Specifies FPLL peripheral + * @return None + */ +#define __LL_FPLL_Start(__FPLL__) SET_BIT((__FPLL__)->FCR, FPLL_START_Msk) + + +/** + * @brief FPLL Div Integer Set + * @param __FPLL__ Specifies FPLL peripheral + * @param integer FPLL Div Integer + * @return None + */ +#define __LL_FPLL_DivInt_Set(__FPLL__, integer) \ + MODIFY_REG((__FPLL__)->FDR, FPLL_DIV_INT_Msk, ((integer & 0x3fffUL) << FPLL_DIV_INT_Pos)) + +/** + * @brief FPLL Div Fraction Set + * @param __FPLL__ Specifies FPLL peripheral + * @param frac FPLL Div Fraction + * @return None + */ +#define __LL_FPLL_DivFrac_Set(__FPLL__, frac) \ + MODIFY_REG((__FPLL__)->FDR, FPLL_DIV_FRAC_Msk, ((frac & 0xffffUL) << FPLL_DIV_FRAC_Pos)) +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup FPLL_LL_Exported_Functions + * @{ + */ + +/** @addtogroup FPLL_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_FPLL_Init(FPLL_TypeDef *Instance); +LL_StatusETypeDef LL_FPLL_DeInit(FPLL_TypeDef *Instance); +void LL_FPLL_MspInit(FPLL_TypeDef *Instance); +void LL_FPLL_MspDeInit(FPLL_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup FPLL_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_FPLL_DivStart(FPLL_TypeDef *Instance, uint16_t integer, uint16_t frac); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_FPLL_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_gpio.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_gpio.h new file mode 100644 index 0000000000..2739175777 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_gpio.h @@ -0,0 +1,518 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_gpio.h + * @author MCD Application Team + * @brief Header file of GPIO LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_GPIO_H_ +#define _TAE32F53XX_LL_GPIO_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup GPIO_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup GPIO_LL_Exported_Types GPIO LL Exported Types + * @brief GPIO LL Exported Types + * @{ + */ + +/** + * @brief GPIO Configuration Mode + * Elements values convention: 0xX0Y0000Z + * - X : GPIO mode or Interrupt Mode + * - Y : External IT detection + * - Z : IO Direction mode (Input, Output or Alternate) + * @note External Interrupt only vailed in input mode + */ +typedef enum { + GPIO_MODE_INPUT = 0x00000000u, /*!< GPIO Input Mode */ + GPIO_MODE_OUTPUT = 0x00000001u, /*!< GPIO Output Mode */ + GPIO_MODE_AF = 0x00000002u, /*!< GPIO Alternate Mode */ + GPIO_MODE_ANALOG = 0x00000003u, /*!< Analog Mode */ + GPIO_MODE_IT_RISING = 0x10100000u, /*!< External Interrupt Mode with Rising edge trigger detection */ + GPIO_MODE_IT_FALLING = 0x10200000u, /*!< External Interrupt Mode with Falling edge trigger detection */ + GPIO_MODE_IT_RISING_FALLING = 0x10300000u, /*!< External Interrupt Mode with Rising/Falling edge trigger detection */ +} GPIO_ModeETypeDef; + +/** + * @brief GPIO AF Mode enumeration + */ + +typedef enum { + GPIO_AF0_INPUT = ((uint8_t)0x0), /*!< GPIO alternate function 0 INPUT */ + + GPIO_AF1_OUTPUT = ((uint8_t)0x1), /*!< GPIO alternate function 1 OUTPUT */ + + GPIO_AF2_MCO = ((uint8_t)0x2), /*!< GPIO alternate function 2 MCO */ + GPIO_AF2_SWDAT = ((uint8_t)0x2), /*!< GPIO alternate function 2 SWDAT */ + GPIO_AF2_SWCLK = ((uint8_t)0x2), /*!< GPIO alternate function 2 SWCLK */ + GPIO_AF2_SWO = ((uint8_t)0x2), /*!< GPIO alternate function 2 SWO */ + GPIO_AF2_SYSDBOUT = ((uint8_t)0x2), /*!< GPIO alternate function 2 SYSDBOUT */ + + GPIO_AF3_TMR0 = ((uint8_t)0x3), /*!< GPIO alternate function 3 TMR0 */ + GPIO_AF3_TMR1 = ((uint8_t)0x3), /*!< GPIO alternate function 3 TMR1 */ + GPIO_AF3_TMR2 = ((uint8_t)0x3), /*!< GPIO alternate function 3 TMR2 */ + GPIO_AF3_TMR3 = ((uint8_t)0x3), /*!< GPIO alternate function 3 TMR3 */ + + GPIO_AF4_TMR0 = ((uint8_t)0x4), /*!< GPIO alternate function 4 TMR0 */ + GPIO_AF4_TMR1 = ((uint8_t)0x4), /*!< GPIO alternate function 4 TMR1 */ + GPIO_AF4_TMR2 = ((uint8_t)0x4), /*!< GPIO alternate function 4 TMR2 */ + GPIO_AF4_TMR3 = ((uint8_t)0x4), /*!< GPIO alternate function 4 TMR3 */ + + GPIO_AF5_TMR4 = ((uint8_t)0x5), /*!< GPIO alternate function 5 TMR4 */ + GPIO_AF5_TMR5 = ((uint8_t)0x5), /*!< GPIO alternate function 5 TMR5 */ + GPIO_AF5_TMR6 = ((uint8_t)0x5), /*!< GPIO alternate function 5 TMR6 */ + GPIO_AF5_TMR7 = ((uint8_t)0x5), /*!< GPIO alternate function 5 TMR7 */ + + GPIO_AF6_TMR4 = ((uint8_t)0x6), /*!< GPIO alternate function 6 TMR4 */ + GPIO_AF6_TMR5 = ((uint8_t)0x6), /*!< GPIO alternate function 6 TMR5 */ + GPIO_AF6_TMR6 = ((uint8_t)0x6), /*!< GPIO alternate function 6 TMR6 */ + GPIO_AF6_TMR7 = ((uint8_t)0x6), /*!< GPIO alternate function 6 TMR7 */ + + GPIO_AF7_CAN = ((uint8_t)0x7), /*!< GPIO alternate function 7 CAN */ + GPIO_AF7_I2C0 = ((uint8_t)0x7), /*!< GPIO alternate function 7 I2C0 */ + + GPIO_AF8_I2C0 = ((uint8_t)0x8), /*!< GPIO alternate function 8 I2C0 */ + GPIO_AF8_DALI = ((uint8_t)0x8), /*!< GPIO alternate function 8 DALI */ + + GPIO_AF9_I2C1 = ((uint8_t)0x9), /*!< GPIO alternate function 9 I2C1 */ + GPIO_AF9_UART1 = ((uint8_t)0x9), /*!< GPIO alternate function 9 UART1 */ + + GPIO_AF10_UART0 = ((uint8_t)0xA), /*!< GPIO alternate function 10 UART0 */ + GPIO_AF10_UART1 = ((uint8_t)0xA), /*!< GPIO alternate function 10 UART1 */ + + GPIO_AF11_HRPWM = ((uint8_t)0xB), /*!< GPIO alternate function 11 HRPWM */ + GPIO_AF11_USB = ((uint8_t)0xB), /*!< GPIO alternate function 1 USB */ + + GPIO_AF12_HRPWM = ((uint8_t)0xC), /*!< GPIO alternate function 12 HRPWM */ + + GPIO_AF13_HRPWM = ((uint8_t)0xD), /*!< GPIO alternate function 13 HRPWM */ + + GPIO_AF14_CMP0 = ((uint8_t)0xE), /*!< GPIO alternate function 14 CMP0 */ + GPIO_AF14_CMP1 = ((uint8_t)0xE), /*!< GPIO alternate function 14 CMP1 */ + GPIO_AF14_CMP2 = ((uint8_t)0xE), /*!< GPIO alternate function 14 CMP2 */ + GPIO_AF14_CMP3 = ((uint8_t)0xE), /*!< GPIO alternate function 14 CMP3 */ + + GPIO_AF15_ANALOG = ((uint8_t)0xF), /*!< GPIO alternate function 15 ANALOG */ + GPIO_AF15_ADC0 = ((uint8_t)0xF), /*!< GPIO alternate function 15 ADC0 */ + GPIO_AF15_ADC1 = ((uint8_t)0xF), /*!< GPIO alternate function 15 ADC1 */ + GPIO_AF15_DAC0 = ((uint8_t)0xF), /*!< GPIO alternate function 15 DAC0 */ + GPIO_AF15_DAC1 = ((uint8_t)0xF), /*!< GPIO alternate function 15 DAC1 */ + GPIO_AF15_DAC2 = ((uint8_t)0xF), /*!< GPIO alternate function 15 DAC2 */ + GPIO_AF15_DAC3 = ((uint8_t)0xF), /*!< GPIO alternate function 15 DAC3 */ + GPIO_AF15_CMP0 = ((uint8_t)0xF), /*!< GPIO alternate function 15 CMP0 */ + GPIO_AF15_CMP1 = ((uint8_t)0xF), /*!< GPIO alternate function 15 CMP1 */ + GPIO_AF15_CMP2 = ((uint8_t)0xF), /*!< GPIO alternate function 15 CMP2 */ + GPIO_AF15_CMP3 = ((uint8_t)0xF), /*!< GPIO alternate function 15 CMP3 */ + GPIO_AF15_USB = ((uint8_t)0xF), /*!< GPIO alternate function 15 USB */ +} GPIO_AFETypeDef; + +/** + * @brief GPIO Pull-Up or Pull-Down Activation + */ +typedef enum { + GPIO_NOPULL = 0x00000000U, /*!< No Pull-up or Pull-down activation */ + GPIO_PULLUP = 0x00000001U, /*!< Pull-up activation */ + GPIO_PULLDOWN = 0x00000002U, /*!< Pull-down activation */ +} GPIO_PullETypeDef; + +/** + * @brief GPIO output type: Push-Pull or Open-Drain + */ +typedef enum { + GPIO_OTYPE_PP = 0x00000000U, /*!< Output Push Pull Type */ + GPIO_OTYPE_OD = 0x00000001U, /*!< Output Open Drain Type */ +} GPIO_OutputETypeDef; + +/** + * @brief GPIO Output Maximum frequency + */ +typedef enum { + GPIO_SPEED_FREQ_LOW = 0x00000000U, /*!< Low speed */ + GPIO_SPEED_FREQ_HIGH = 0x00000001U, /*!< High speed */ +} GPIO_SpeedETypeDef; + +/** + * @brief GPIO Bit SET and Bit RESET enumeration + */ +typedef enum { + GPIO_PIN_RESET = 0, /*!< GPIO pin state RESET */ + GPIO_PIN_SET, /*!< GPIO pin state SET */ +} GPIO_PinStateETypeDef; + + +/** + * @brief GPIO Init structure definition + */ +typedef struct __GPIO_InitTypeDef { + uint32_t Pin; /*!< Specifies the GPIO pins to be configured. + This parameter can be any value of @ref GPIO_pins_define */ + + GPIO_ModeETypeDef Mode; /*!< Specifies the operating mode for the selected pins. */ + + GPIO_OutputETypeDef OType; /*!< Specifies the output type for the selected pins(output or AF output mode only). */ + + GPIO_PullETypeDef Pull; /*!< Specifies the Pull-up or Pull-Down activation for the selected pins. */ + + GPIO_SpeedETypeDef Speed; /*!< Specifies the speed for the selected pins. */ + + GPIO_AFETypeDef Alternate; /*!< Peripheral to be connected to the selected pins. */ +} GPIO_InitTypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup GPIO_LL_Exported_Constants GPIO LL Exported Constants + * @brief GPIO LL Exported Constants + * @{ + */ + +/** @addtogroup GPIO_pins_define GPIO pins define + * @{ + */ +#define GPIO_NUMBER 16U + +#define GPIO_PIN_0 ((uint16_t)0x0001) /* Pin 0 selected */ +#define GPIO_PIN_1 ((uint16_t)0x0002) /* Pin 1 selected */ +#define GPIO_PIN_2 ((uint16_t)0x0004) /* Pin 2 selected */ +#define GPIO_PIN_3 ((uint16_t)0x0008) /* Pin 3 selected */ +#define GPIO_PIN_4 ((uint16_t)0x0010) /* Pin 4 selected */ +#define GPIO_PIN_5 ((uint16_t)0x0020) /* Pin 5 selected */ +#define GPIO_PIN_6 ((uint16_t)0x0040) /* Pin 6 selected */ +#define GPIO_PIN_7 ((uint16_t)0x0080) /* Pin 7 selected */ +#define GPIO_PIN_8 ((uint16_t)0x0100) /* Pin 8 selected */ +#define GPIO_PIN_9 ((uint16_t)0x0200) /* Pin 9 selected */ +#define GPIO_PIN_10 ((uint16_t)0x0400) /* Pin 10 selected */ +#define GPIO_PIN_11 ((uint16_t)0x0800) /* Pin 11 selected */ +#define GPIO_PIN_12 ((uint16_t)0x1000) /* Pin 12 selected */ +#define GPIO_PIN_13 ((uint16_t)0x2000) /* Pin 13 selected */ +#define GPIO_PIN_14 ((uint16_t)0x4000) /* Pin 14 selected */ +#define GPIO_PIN_15 ((uint16_t)0x8000) /* Pin 15 selected */ +#define GPIO_PIN_All ((uint16_t)0xFFFF) /* All pins selected */ + +#define GPIO_PIN_MASK 0x0000FFFFu /* PIN mask for assert test */ + +/** + * @} + */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup GPIO_LL_Exported_Macros GPIO LL Exported Macros + * @brief GPIO LL Exported Macros + * @{ + */ + +/** + * @brief Enable the specified GPIO_Port interrupt. + * @param __GPIO__ specifies GPIO Port to enable. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @return None + */ +#define __LL_GPIO_PORT_IT_ENABLE(__GPIO__) WRITE_REG((__GPIO__)->IER, 0x01U) + +/** + * @brief Disable the specified GPIO_Port interrupt. + * @param __GPIO__ specifies GPIO Port to disable. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @return None + */ +#define __LL_GPIO_PORT_IT_DISABLE(__GPIO__) WRITE_REG((__GPIO__)->IER, 0x00U) + +/** + * @brief Enable the specified GPIO_Pin interrupt. + * @note GPIO_Port interrupt must also be enabled. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_IT_ENABLE(__GPIO__, __PIN__) SET_BIT((__GPIO__)->ITER, (__PIN__)) + +/** + * @brief Disable the specified GPIO_Pin interrupt. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_IT_DISABLE(__GPIO__, __PIN__) CLEAR_BIT((__GPIO__)->ITER, (__PIN__)) + +/** + * @brief Check whether the specified GPIO_Pin Interrupt is enabled or not. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return The interrupt settings for specified GPIO_Pin(ENABLE or DISABLE) + */ +#define __LL_GPIO_IT_CHECK_SOURCE(__GPIO__, __PIN__) ((((__GPIO__)->ITER & GPIO_ITER_ITE) == (__PIN__)) ? SET : RESET) + +/** + * @brief Check whether the specified GPIO_Pin pending flag is set or not. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return The pending state of __PIN__ + * @retval SET At least one of __PIN__ is Pending + * @retval RESET None of __PIN__ is Pending + */ +#define __LL_GPIO_GET_FLAG(__GPIO__, __PIN__) ((((__GPIO__)->PR & (__PIN__)) != 0x00UL) ? SET : RESET) + +/** + * @brief Clear the specified GPIO_Pin pending flags + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_CLEAR_FLAG(__GPIO__, __PIN__) ((__GPIO__)->PR = (__PIN__)) + +/** + * @brief Check whether the specified GPIO_Pin interrupt pending flag is asserted or not. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return The interrupt pending state of __PIN__ + * @retval SET At least one of __PIN__ is pending interrupt + * @retval RESET None of __PIN__ is pending interrupt + */ +#define __LL_GPIO_GET_IT(__GPIO__, __PIN__) ((((__GPIO__)->PR & (__PIN__)) != 0x00UL) ? SET : RESET) + +/** + * @brief Clear the specified GPIO_Pin interrupt pending flags + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_CLEAR_IT(__GPIO__, __PIN__) ((__GPIO__)->PR = (__PIN__)) + +/** + * @brief Enable the specified GPIO_Pin input debounce feature. + * The external signal will debounce 4 HCLK time before enter GPIO module + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_INPUT_DEB_ENABLE(__GPIO__, __PIN__) SET_BIT((__GPIO__)->SDER, (__PIN__)) + +/** + * @brief Disable the specified GPIO_Pin input debounce feature. + * The external signal will enter GPIO module without any debounce + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_INPUT_DEB_DISABLE(__GPIO__, __PIN__) CLEAR_BIT((__GPIO__)->SDER, (__PIN__)) + +/** + * @brief Enable the specified GPIO_Pin input synchronize feature. + * The external signal will be aligned with HCLK before enter GPIO module + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_INPUT_SYNC_ENABLE(__GPIO__, __PIN__) SET_BIT((__GPIO__)->SDER, ((__PIN__) << 16U)) + +/** + * @brief Disable the specified GPIO_Pin input synchronize feature. + * The external signal will enter GPIO module without synchronization + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_INPUT_SYNC_DISABLE(__GPIO__, __PIN__) CLEAR_BIT((__GPIO__)->SDER, ((__PIN__) << 16U)) + +/** + * @brief Enable the specified GPIO_Pin input Hysteresis feature. + * When enable hysteresis, the rising edge?threshold?voltage is larger than the falling edge?threshold?voltage + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_INPUT_HY_ENABLE(__GPIO__, __PIN__) SET_BIT((__GPIO__)->IHYR, (__PIN__)) + +/** + * @brief Disable the specified GPIO_Pin input Hysteresis feature. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_INPUT_HY_DISABLE(__GPIO__, __PIN__) CLEAR_BIT((__GPIO__)->IHYR, (__PIN__)) + +/** + * @brief Set low output driver strenght (8mA) for specified GPIO_Pin. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_OUTPUT_DRV_STRENGHT_LOW(__GPIO__, __PIN__) CLEAR_BIT((__GPIO__)->DSR, (__PIN__)) + +/** + * @brief Set high output driver strenght (24mA) for specified GPIO_Pin. + * @param __GPIO__ specifies GPIO Port. + * This parameter can be one of GPIOx where x can be (A, B, ...) + * @param __PIN__ specifies GPIO Pin. + * This parameter can be any combination of @ref GPIO_pins_define + * @return None + */ +#define __LL_GPIO_OUTPUT_DRV_STRENGHT_HIGH(__GPIO__, __PIN__) SET_BIT((__GPIO__)->DSR, (__PIN__)) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup GPIO_LL_Exported_Functions + * @{ + */ + +/** @addtogroup GPIO_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init); +LL_StatusETypeDef LL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin); +/** + * @} + */ + + +/** @addtogroup GPIO_LL_Exported_Functions_Group2 + * @{ + */ +void LL_GPIO_AF_Config(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_AFETypeDef Alternate); +/** + * @} + */ + + +/** @addtogroup GPIO_LL_Exported_Functions_Group3 + * @{ + */ +GPIO_PinStateETypeDef LL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) ; +void LL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinStateETypeDef PinState); +void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin); +uint16_t LL_GPIO_ReadData(GPIO_TypeDef *GPIOx); +void LL_GPIO_WriteData(GPIO_TypeDef *GPIOx, uint16_t Data); +/** + * @} + */ + + +/** @addtogroup GPIO_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_GPIO_IRQHandler(GPIO_TypeDef *GPIOx); +void LL_GPIO_ExtTrigCallback(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup GPIO_LL_Private_Macros GPIO LL Private Macros + * @brief GPIO LL Private Macros + * @{ + */ + +/** + * @brief Judge is GPIO pin or not + * @param __PIN__ pin to judge + * @retval 0 isn't GPIO pin + * @retval 1 is GPIO pin + */ +#define IS_GPIO_PIN(__PIN__) ((((__PIN__) & GPIO_PIN_MASK) != 0x00U) && \ + (((__PIN__) & ~GPIO_PIN_MASK) == 0x00U)) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_GPIO_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_hrpwm.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_hrpwm.h new file mode 100644 index 0000000000..22e14f3ac7 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_hrpwm.h @@ -0,0 +1,3550 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_hrpwm.h + * @author MCD Application Team + * @brief Header file of HRPWM LL module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_HRPWM_H_ +#define _TAE32F53XX_LL_HRPWM_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup HRPWM_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup HRPWM_LL_Exported_Constants HRPWM LL Exported Constants + * @brief HRPWM LL Exported Constants + * @{ + */ + +/** @defgroup HRPWM_Max_Timer HRPWM Max Timer + * @{ + */ +#define MAX_HRPWM_TIMER 6U +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Index HRPWM Index + * @brief Constants defining the hrpwm indexes + * @{ + */ +#define HRPWM_INDEX_SLAVE_0 0x0U /*!< Index used to access slave pwm 0 registers */ +#define HRPWM_INDEX_SLAVE_1 0x1U /*!< Index used to access slave pwm 1 registers */ +#define HRPWM_INDEX_SLAVE_2 0x2U /*!< Index used to access slave pwm 2 registers */ +#define HRPWM_INDEX_SLAVE_3 0x3U /*!< Index used to access slave pwm 3 registers */ +#define HRPWM_INDEX_SLAVE_4 0x4U /*!< Index used to access slave pwm 4 registers */ +#define HRPWM_INDEX_SLAVE_5 0x5U /*!< Index used to access slave pwm 5 registers */ +#define HRPWM_INDEX_MASTER 0x6U /*!< Index used to access master registers */ +#define HRPWM_INDEX_COMMON 0xFFU /*!< Index used to access HRPWM common registers */ +/** + * @} + */ + +/** @defgroup HRPWM_Compare_Unit HRPWM Compare Unit + * @brief Constants defining compare unit identifiers + * @{ + */ +#define HRPWM_COMPAREUNIT_A 0x00000001U /*!< Compare unit A identifier */ +#define HRPWM_COMPAREUNIT_B 0x00000002U /*!< Compare unit B identifier */ +#define HRPWM_COMPAREUNIT_C 0x00000004U /*!< Compare unit C identifier */ +#define HRPWM_COMPAREUNIT_D 0x00000008U /*!< Compare unit D identifier */ +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Output_Start HRPWM Timer Output + * @brief Constants defining timer output identifiers -- output enable,not enable cannot output wave + * @{ + */ +#define HRPWM_OUTPUT_OEN0A 0x00000001U /*!< Timer 0 - Output A identifier */ +#define HRPWM_OUTPUT_OEN0B 0x00000002U /*!< Timer 0 - Output B identifier */ +#define HRPWM_OUTPUT_OEN1A 0x00000004U /*!< Timer 1 - Output A identifier */ +#define HRPWM_OUTPUT_OEN1B 0x00000008U /*!< Timer 1 - Output B identifier */ +#define HRPWM_OUTPUT_OEN2A 0x00000010U /*!< Timer 2 - Output A identifier */ +#define HRPWM_OUTPUT_OEN2B 0x00000020U /*!< Timer 2 - Output B identifier */ +#define HRPWM_OUTPUT_OEN3A 0x00000040U /*!< Timer 3 - Output A identifier */ +#define HRPWM_OUTPUT_OEN3B 0x00000080U /*!< Timer 3 - Output B identifier */ +#define HRPWM_OUTPUT_OEN4A 0x00000100U /*!< Timer 4 - Output A identifier */ +#define HRPWM_OUTPUT_OEN4B 0x00000200U /*!< Timer 4 - Output B identifier */ +#define HRPWM_OUTPUT_OEN5A 0x00000400U /*!< Timer 5 - Output A identifier */ +#define HRPWM_OUTPUT_OEN5B 0x00000800U /*!< Timer 5 - Output B identifier */ +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Output_Stop HRPWM Timer Output Disable + * @brief Constants defining timer disable output identifiers + * @{ + */ +#define HRPWM_OUTPUT_ODIS0A 0x00000001U /*!< Timer 0 - Disable Output A identifier */ +#define HRPWM_OUTPUT_ODIS0B 0x00000002U /*!< Timer 0 - Disable Output B identifier */ +#define HRPWM_OUTPUT_ODIS1A 0x00000004U /*!< Timer 1 - Disable Output A identifier */ +#define HRPWM_OUTPUT_ODIS1B 0x00000008U /*!< Timer 1 - Disable Output B identifier */ +#define HRPWM_OUTPUT_ODIS2A 0x00000010U /*!< Timer 2 - Disable Output A identifier */ +#define HRPWM_OUTPUT_ODIS2B 0x00000020U /*!< Timer 2 - Disable Output B identifier */ +#define HRPWM_OUTPUT_ODIS3A 0x00000040U /*!< Timer 3 - Disable Output A identifier */ +#define HRPWM_OUTPUT_ODIS3B 0x00000080U /*!< Timer 3 - Disable Output B identifier */ +#define HRPWM_OUTPUT_ODIS4A 0x00000100U /*!< Timer 4 - Disable Output A identifier */ +#define HRPWM_OUTPUT_ODIS4B 0x00000200U /*!< Timer 4 - Disable Output B identifier */ +#define HRPWM_OUTPUT_ODIS5A 0x00000400U /*!< Timer 5 - Disable Output A identifier */ +#define HRPWM_OUTPUT_ODIS5B 0x00000800U /*!< Timer 5 - Disable Output B identifier */ +/** + * @} + */ + +/** @defgroup HRPWM_Synchronization_Options HRPWM Synchronization Options + * @brief Constants defining the options for synchronizing multiple HRPWM + * instances, as a master unit (generating a synchronization signal) + * or as a slave (waiting for a trigger to be synchronized) + * @{ + */ +#define HRPWM_SYNCOPTION_NONE 0x0 /*!< HRPWM instance doesn't handle external sync signals (SYNCIN, SYNCOUT) */ +#define HRPWM_SYNCOPTION_MASTER 0x1U/*!< HRPWM instance acts as a MASTER, i.e. generates external sync output (SYNCOUT) */ +#define HRPWM_SYNCOPTION_SLAVE 0x2U/*!< HRPWM instance acts as a SLAVE, i.e. it is sync by external sources (SYNCIN) */ +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Update_Trigger HRPWM Timer Update Trigger + * @brief Constants defining whether the registers update is done synchronously with any other timer or master update + * @{ + */ +#define HRPWM_UPDATETRIGGER_NONE 0x00000000U /*!< Register update is disabled */ +#define HRPWM_UPDATETRIGGER_MASTER (HRPWM_CR0_MUPD) /*!< Register update is triggered by the master timer update */ +#define HRPWM_UPDATETRIGGER_TIMER_0 (HRPWM_CR0_UPD0) /*!< Register update is triggered by the timer 0 update */ +#define HRPWM_UPDATETRIGGER_TIMER_1 (HRPWM_CR0_UPD1) /*!< Register update is triggered by the timer 1 update */ +#define HRPWM_UPDATETRIGGER_TIMER_2 (HRPWM_CR0_UPD2) /*!< Register update is triggered by the timer 2 update */ +#define HRPWM_UPDATETRIGGER_TIMER_3 (HRPWM_CR0_UPD3) /*!< Register update is triggered by the timer 3 update */ +#define HRPWM_UPDATETRIGGER_TIMER_4 (HRPWM_CR0_UPD4) /*!< Register update is triggered by the timer 4 update */ +#define HRPWM_UPDATETRIGGER_TIMER_5 (HRPWM_CR0_UPD5) /*!< Register update is triggered by the timer 5 update */ +#define HRPWM_UPDATETRIGGER_REP (HRPWM_CR0_UPDREP) /*!< Register update is triggered by the Repetition update */ +#define HRPWM_UPDATETRIGGER_RST (HRPWM_CR0_UPDRST) /*!< Register update is triggered by the reset update */ +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Set_Trigger HRPWM Output Set A\B Source + * @brief Constants defining the events that can be selected to configure the set crossbar of a timer output + * @{ + */ +#define HRPWM_OUTPUT_SET_NONE (0x00000000U) /*!< HRPWM output set none */ +#define HRPWM_OUTPUT_SET_SST (1UL << 18) /*!< Timer reset event coming solely from software forces the output + to its active state */ +#define HRPWM_OUTPUT_SET_RESYNC (1UL << 17) /*!< SYNC input forces the output to its active state */ +#define HRPWM_OUTPUT_SET_EXTEVNT5 (1UL << 16) /*!< External event 5 forces the output to its active state */ +#define HRPWM_OUTPUT_SET_EXTEVNT4 (1UL << 15) /*!< External event 4 forces the output to its active state */ +#define HRPWM_OUTPUT_SET_EXTEVNT3 (1UL << 14) /*!< External event 3 forces the output to its active state */ +#define HRPWM_OUTPUT_SET_EXTEVNT2 (1UL << 13) /*!< External event 2 forces the output to its active state */ +#define HRPWM_OUTPUT_SET_EXTEVNT1 (1UL << 12) /*!< External event 1 forces the output to its active state */ +#define HRPWM_OUTPUT_SET_EXTEVNT0 (1UL << 11) /*!< External event 0 forces the output to its active state */ +#define HRPWM_OUTPUT_SET_MSTPRD (1UL << 10) /*!< The master timer period event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_MSTCMPD (1UL << 9) /*!< Master Timer compare D event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_MSTCMPC (1UL << 8) /*!< Master Timer compare C event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_MSTCMPB (1UL << 7) /*!< Master Timer compare B event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_MSTCMPA (1UL << 6) /*!< Master Timer compare A event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_PRD (1UL << 5) /*!< Timer period event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_CMPD (1UL << 4) /*!< Timer compare D event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_CMPC (1UL << 3) /*!< Timer compare C event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_CMPB (1UL << 2) /*!< Timer compare B event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_CMPA (1UL << 1) /*!< Timer compare A event forces the output to its active state */ +#define HRPWM_OUTPUT_SET_UPDATE (1UL << 0) /*!< Timer register update event forces the output to its active state */ +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Clear_Trigger HRPWM Output Clear A\B Source + * @brief Constants defining the events that can be selected to configure the clear crossbar of a timer output + * @{ + */ +#define HRPWM_OUTPUT_CLEAR_NONE (0x00000000U) /*!< HRPWM output clear None */ +#define HRPWM_OUTPUT_CLEAR_SST (1UL << 18) /*!< Timer reset event coming solely from software forces the output + to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_RESYNC (1UL << 17) /*!< SYNC input forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_EXTEVNT5 (1UL << 16) /*!< External event 5 forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_EXTEVNT4 (1UL << 15) /*!< External event 4 forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_EXTEVNT3 (1UL << 14) /*!< External event 3 forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_EXTEVNT2 (1UL << 13) /*!< External event 2 forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_EXTEVNT1 (1UL << 12) /*!< External event 1 forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_EXTEVNT0 (1UL << 11) /*!< External event 0 forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_MSTPRD (1UL << 10) /*!< The master timer period event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_MSTCMPD (1UL << 9) /*!< Master Timer compare D event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_MSTCMPC (1UL << 8) /*!< Master Timer compare C event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_MSTCMPB (1UL << 7) /*!< Master Timer compare B event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_MSTCMPA (1UL << 6) /*!< Master Timer compare A event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_PRD (1UL << 5) /*!< Timer period event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_CMPD (1UL << 4) /*!< Timer compare D event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_CMPC (1UL << 3) /*!< Timer compare C event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_CMPB (1UL << 2) /*!< Timer compare B event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_CMPA (1UL << 1) /*!< Timer compare A event forces the output to its inactive state */ +#define HRPWM_OUTPUT_CLEAR_UPDATE (1UL << 0) /*!< Timer register update event forces the output to its inactive state */ +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Reset_Trigger HRPWM Timer Reset Trigger + * @brief Constants defining the events that can be selected to trigger the reset of the timer counter + * @{ + */ +#define HRPWM_RESET_TRIGGER_NONE 0x00000000U /*!< No counter reset trigger */ +#define HRPWM_RESET_TRIGGER_EXTEVT5 (HRPWM_RSTR_EXTEVT5) /*!< The timer counter is reset upon external event 5 */ +#define HRPWM_RESET_TRIGGER_EXTEVT4 (HRPWM_RSTR_EXTEVT4) /*!< The timer counter is reset upon external event 4 */ +#define HRPWM_RESET_TRIGGER_EXTEVT3 (HRPWM_RSTR_EXTEVT3) /*!< The timer counter is reset upon external event 3 */ +#define HRPWM_RESET_TRIGGER_UPD_CMPA5 (HRPWM_RSTR_UPD_CMPA5) /*!< The timer counter is reset upon other timer 5 update and Compare A event */ +#define HRPWM_RESET_TRIGGER_CMPD4 (HRPWM_RSTR_CMPD4 ) /*!< The timer counter is reset upon other timer 4 Compare D event */ +#define HRPWM_RESET_TRIGGER_CMPB4 (HRPWM_RSTR_CMPB4 ) /*!< The timer counter is reset upon other timer 4 Compare B event */ +#define HRPWM_RESET_TRIGGER_UPD_CMPA4 (HRPWM_RSTR_UPD_CMPA4) /*!< The timer counter is reset upon other timer 4 update and Compare A event */ +#define HRPWM_RESET_TRIGGER_CMPD3 (HRPWM_RSTR_CMPD3 ) /*!< The timer counter is reset upon other timer 3 Compare D event */ +#define HRPWM_RESET_TRIGGER_CMPB3 (HRPWM_RSTR_CMPB3 ) /*!< The timer counter is reset upon other timer 3 Compare B event */ +#define HRPWM_RESET_TRIGGER_UPD_CMPA3 (HRPWM_RSTR_UPD_CMPA3) /*!< The timer counter is reset upon other timer 3 update and Compare A event */ +#define HRPWM_RESET_TRIGGER_CMPD2 (HRPWM_RSTR_CMPD2 ) /*!< The timer counter is reset upon other timer 2 Compare D event */ +#define HRPWM_RESET_TRIGGER_CMPB2 (HRPWM_RSTR_CMPB2 ) /*!< The timer counter is reset upon other timer 2 Compare B event */ +#define HRPWM_RESET_TRIGGER_UPD_CMPA2 (HRPWM_RSTR_UPD_CMPA2) /*!< The timer counter is reset upon other timer 2 update and Compare A event */ +#define HRPWM_RESET_TRIGGER_CMPD1 (HRPWM_RSTR_CMPD1 ) /*!< The timer counter is reset upon other timer 1 Compare D event */ +#define HRPWM_RESET_TRIGGER_CMPB1 (HRPWM_RSTR_CMPB1 ) /*!< The timer counter is reset upon other timer 1 Compare B event */ +#define HRPWM_RESET_TRIGGER_UPD_CMPA1 (HRPWM_RSTR_UPD_CMPA1) /*!< The timer counter is reset upon other timer 1 update and Compare A event */ +#define HRPWM_RESET_TRIGGER_CMPD0 (HRPWM_RSTR_CMPD0 ) /*!< The timer counter is reset upon other timer 0 Compare D event */ +#define HRPWM_RESET_TRIGGER_CMPB0 (HRPWM_RSTR_CMPB0 ) /*!< The timer counter is reset upon other timer 0 Compare B event */ +#define HRPWM_RESET_TRIGGER_UPD_CMPA0 (HRPWM_RSTR_UPD_CMPA0) /*!< The timer counter is reset upon other timer 0 update and Compare A event */ +#define HRPWM_RESET_TRIGGER_CMPD5 (HRPWM_RSTR_CMPD5 ) /*!< The timer counter is reset upon other timer 5 Compare D event */ +#define HRPWM_RESET_TRIGGER_CMPB5 (HRPWM_RSTR_CMPB5 ) /*!< The timer counter is reset upon other timer 5 Compare B event */ +#define HRPWM_RESET_TRIGGER_EXTEVT2 (HRPWM_RSTR_EXTEVT2 ) /*!< The timer counter is reset upon external event 2 */ +#define HRPWM_RESET_TRIGGER_EXTEVT1 (HRPWM_RSTR_EXTEVT1 ) /*!< The timer counter is reset upon external event 1 */ +#define HRPWM_RESET_TRIGGER_EXTEVT0 (HRPWM_RSTR_EXTEVT0 ) /*!< The timer counter is reset upon external event 0 */ +#define HRPWM_RESET_TRIGGER_MSTPER (HRPWM_RSTR_MSTPER ) /*!< The timer counter is reset upon master timer period event */ +#define HRPWM_RESET_TRIGGER_MSTCMPD (HRPWM_RSTR_MSTCMPD ) /*!< The timer counter is reset upon master timer Compare 1 event */ +#define HRPWM_RESET_TRIGGER_MSTCMPC (HRPWM_RSTR_MSTCMPC ) /*!< The timer counter is reset upon master timer Compare 2 event */ +#define HRPWM_RESET_TRIGGER_MSTCMPB (HRPWM_RSTR_MSTCMPB ) /*!< The timer counter is reset upon master timer Compare 3 event */ +#define HRPWM_RESET_TRIGGER_MSTCMPA (HRPWM_RSTR_MSTCMPA ) /*!< The timer counter is reset upon master timer Compare 4 event */ +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Fault_Enabling HRPWM Timer Fault Enabling + * @brief Constants defining whether a fault channel is enabled for a timer + * @{ + */ +#define HRPWM_FAULTEN_NONE 0x00000000U /*!< No fault enabled */ +#define HRPWM_FAULTEN_FAULT0 (HRPWM_FLTR_FLT0EN) /*!< Fault 0 enabled */ +#define HRPWM_FAULTEN_FAULT1 (HRPWM_FLTR_FLT1EN) /*!< Fault 1 enabled */ +#define HRPWM_FAULTEN_FAULT2 (HRPWM_FLTR_FLT2EN) /*!< Fault 2 enabled */ +#define HRPWM_FAULTEN_FAULT3 (HRPWM_FLTR_FLT3EN) /*!< Fault 3 enabled */ +#define HRPWM_FAULTEN_FAULT4 (HRPWM_FLTR_FLT4EN) /*!< Fault 4 enabled */ +#define HRPWM_FAULTEN_FAULT5 (HRPWM_FLTR_FLT5EN) /*!< Fault 5 enabled */ +/** + * @} + */ + +/** @defgroup HRPWM_ADC_Trigger_Event HRPWM ADC Trigger Event + * @brief constants defining the events triggering ADC conversion. + * HRPWM_ADCTRIGEVENT0246*: ADC Triggers 0 and 2 and 4 and 6 + * HRPWM_ADCTRIGEVENT1357_*: ADC Triggers 1 and 3 and 5 and 7 + * @{ + */ +#define HRPWM_ADCTRIGEVENT0_CMPD5 (HRPWM_ADT0R_CMPD5) /*!< ADC Trigger on Slave Timer 5 compare D */ +#define HRPWM_ADCTRIGEVENT0_CMPC5 (HRPWM_ADT0R_CMPC5) /*!< ADC Trigger on Slave Timer 5 compare C */ +#define HRPWM_ADCTRIGEVENT0_PER4 (HRPWM_ADT0R_PER4) /*!< ADC Trigger on Slave Timer 4 period */ +#define HRPWM_ADCTRIGEVENT0_CMPD4 (HRPWM_ADT0R_CMPD4) /*!< ADC Trigger on Slave Timer 4 compare D */ +#define HRPWM_ADCTRIGEVENT0_CMPC4 (HRPWM_ADT0R_CMPC4) /*!< ADC Trigger on Slave Timer 4 compare C */ +#define HRPWM_ADCTRIGEVENT0_CMPB4 (HRPWM_ADT0R_CMPB4) /*!< ADC Trigger on Slave Timer 4 compare B */ +#define HRPWM_ADCTRIGEVENT0_RST3 (HRPWM_ADT0R_RST3) /*!< ADC Trigger on Slave Timer 3 reset */ +#define HRPWM_ADCTRIGEVENT0_CMPD3 (HRPWM_ADT0R_CMPD3) /*!< ADC Trigger on Slave Timer 3 compare D */ +#define HRPWM_ADCTRIGEVENT0_CMPC3 (HRPWM_ADT0R_CMPC3) /*!< ADC Trigger on Slave Timer 3 compare C */ +#define HRPWM_ADCTRIGEVENT0_CMPB3 (HRPWM_ADT0R_CMPB3) /*!< ADC Trigger on Slave Timer 3 compare B */ +#define HRPWM_ADCTRIGEVENT0_PER2 (HRPWM_ADT0R_PER2) /*!< ADC Trigger on Slave Timer 2 period */ +#define HRPWM_ADCTRIGEVENT0_CMPD2 (HRPWM_ADT0R_CMPD2) /*!< ADC Trigger on Slave Timer 2 compare D */ +#define HRPWM_ADCTRIGEVENT0_CMPC2 (HRPWM_ADT0R_CMPC2) /*!< ADC Trigger on Slave Timer 2 compare C */ +#define HRPWM_ADCTRIGEVENT0_CMPB2 (HRPWM_ADT0R_CMPB2) /*!< ADC Trigger on Slave Timer 2 compare B */ +#define HRPWM_ADCTRIGEVENT0_RST1 (HRPWM_ADT0R_RST1) /*!< ADC Trigger on Slave Timer 1 reset */ +#define HRPWM_ADCTRIGEVENT0_CMPD1 (HRPWM_ADT0R_CMPD1) /*!< ADC Trigger on Slave Timer 1 compare D */ +#define HRPWM_ADCTRIGEVENT0_CMPC1 (HRPWM_ADT0R_CMPC1) /*!< ADC Trigger on Slave Timer 1 compare C */ +#define HRPWM_ADCTRIGEVENT0_CMPB1 (HRPWM_ADT0R_CMPB1) /*!< ADC Trigger on Slave Timer 1 compare B */ +#define HRPWM_ADCTRIGEVENT0_PER0 (HRPWM_ADT0R_PER0) /*!< ADC Trigger on Slave Timer 0 period */ +#define HRPWM_ADCTRIGEVENT0_CMPD0 (HRPWM_ADT0R_CMPD0) /*!< ADC Trigger on Slave Timer 0 compare D */ +#define HRPWM_ADCTRIGEVENT0_CMPC0 (HRPWM_ADT0R_CMPC0) /*!< ADC Trigger on Slave Timer 0 compare C */ +#define HRPWM_ADCTRIGEVENT0_CMPB0 (HRPWM_ADT0R_CMPB0) /*!< ADC Trigger on Slave Timer 0 compare B */ +#define HRPWM_ADCTRIGEVENT0_RST5 (HRPWM_ADT0R_RST5) /*!< ADC Trigger on Slave Timer 5 reset */ +#define HRPWM_ADCTRIGEVENT0_CMPB5 (HRPWM_ADT0R_CMPB5) /*!< ADC Trigger on Slave Timer 5 compare B */ +#define HRPWM_ADCTRIGEVENT0_EEV2 (HRPWM_ADT0R_EEV2) /*!< ADC Trigger on external event 2 */ +#define HRPWM_ADCTRIGEVENT0_EEV1 (HRPWM_ADT0R_EEV1) /*!< ADC Trigger on external event 1 */ +#define HRPWM_ADCTRIGEVENT0_EEV0 (HRPWM_ADT0R_EEV0) /*!< ADC Trigger on external event 0 */ +#define HRPWM_ADCTRIGEVENT0_MPER (HRPWM_ADT0R_MPER) /*!< ADC Trigger on Master Timer period */ +#define HRPWM_ADCTRIGEVENT0_MCMPD (HRPWM_ADT0R_MCMPD) /*!< ADC Trigger on Master Timer compare D */ +#define HRPWM_ADCTRIGEVENT0_MCMPC (HRPWM_ADT0R_MCMPC) /*!< ADC Trigger on Master Timer compare C */ +#define HRPWM_ADCTRIGEVENT0_MCMPB (HRPWM_ADT0R_MCMPB) /*!< ADC Trigger on Master Timer compare B */ +#define HRPWM_ADCTRIGEVENT0_MCMPA (HRPWM_ADT0R_MCMPA) /*!< ADC Trigger on Master Timer compare A */ + +#define HRPWM_ADCTRIGEVENT1_CMPD5 (HRPWM_ADT1R_CMPD5) /*!< ADC Trigger on Slave Timer 5 compare D */ +#define HRPWM_ADCTRIGEVENT1_CMPC5 (HRPWM_ADT1R_CMPC5) /*!< ADC Trigger on Slave Timer 5 compare C */ +#define HRPWM_ADCTRIGEVENT1_RST4 (HRPWM_ADT1R_RST4) /*!< ADC Trigger on Slave Timer 4 reset */ +#define HRPWM_ADCTRIGEVENT1_CMPD4 (HRPWM_ADT1R_CMPD4) /*!< ADC Trigger on Slave Timer 4 compare D */ +#define HRPWM_ADCTRIGEVENT1_CMPC4 (HRPWM_ADT1R_CMPC4) /*!< ADC Trigger on Slave Timer 4 compare C */ +#define HRPWM_ADCTRIGEVENT1_CMPB4 (HRPWM_ADT1R_CMPB4) /*!< ADC Trigger on Slave Timer 4 compare B */ +#define HRPWM_ADCTRIGEVENT1_PER3 (HRPWM_ADT1R_PER3) /*!< ADC Trigger on Slave Timer 3 period */ +#define HRPWM_ADCTRIGEVENT1_CMPD3 (HRPWM_ADT1R_CMPD3) /*!< ADC Trigger on Slave Timer 3 compare D */ +#define HRPWM_ADCTRIGEVENT1_CMPC3 (HRPWM_ADT1R_CMPC3) /*!< ADC Trigger on Slave Timer 3 compare C */ +#define HRPWM_ADCTRIGEVENT1_CMPB3 (HRPWM_ADT1R_CMPB3) /*!< ADC Trigger on Slave Timer 3 compare B */ +#define HRPWM_ADCTRIGEVENT1_RST2 (HRPWM_ADT1R_RST2) /*!< ADC Trigger on Slave Timer 2 reset */ +#define HRPWM_ADCTRIGEVENT1_CMPD2 (HRPWM_ADT1R_CMPD2) /*!< ADC Trigger on Slave Timer 2 compare D */ +#define HRPWM_ADCTRIGEVENT1_CMPC2 (HRPWM_ADT1R_CMPC2) /*!< ADC Trigger on Slave Timer 2 compare C */ +#define HRPWM_ADCTRIGEVENT1_CMPB2 (HRPWM_ADT1R_CMPB2) /*!< ADC Trigger on Slave Timer 2 compare B */ +#define HRPWM_ADCTRIGEVENT1_PER1 (HRPWM_ADT1R_PER1) /*!< ADC Trigger on Slave Timer 1 period */ +#define HRPWM_ADCTRIGEVENT1_CMPD1 (HRPWM_ADT1R_CMPD1) /*!< ADC Trigger on Slave Timer 1 compare D */ +#define HRPWM_ADCTRIGEVENT1_CMPC1 (HRPWM_ADT1R_CMPC1) /*!< ADC Trigger on Slave Timer 1 compare C */ +#define HRPWM_ADCTRIGEVENT1_CMPB1 (HRPWM_ADT1R_CMPB1) /*!< ADC Trigger on Slave Timer 1 compare B */ +#define HRPWM_ADCTRIGEVENT1_RST0 (HRPWM_ADT1R_RST0) /*!< ADC Trigger on Slave Timer 0 reset */ +#define HRPWM_ADCTRIGEVENT1_CMPD0 (HRPWM_ADT1R_CMPD0) /*!< ADC Trigger on Slave Timer 0 compare D */ +#define HRPWM_ADCTRIGEVENT1_CMPC0 (HRPWM_ADT1R_CMPC0) /*!< ADC Trigger on Slave Timer 0 compare C */ +#define HRPWM_ADCTRIGEVENT1_CMPB0 (HRPWM_ADT1R_CMPB0) /*!< ADC Trigger on Slave Timer 0 compare B */ +#define HRPWM_ADCTRIGEVENT1_PER5 (HRPWM_ADT1R_PER5) /*!< ADC Trigger on Slave Timer 5 period */ +#define HRPWM_ADCTRIGEVENT1_CMPB5 (HRPWM_ADT1R_CMPB5) /*!< ADC Trigger on Slave Timer 5 compare B */ +#define HRPWM_ADCTRIGEVENT1_EEV2 (HRPWM_ADT1R_EEV5) /*!< ADC Trigger on external event 2 */ +#define HRPWM_ADCTRIGEVENT1_EEV1 (HRPWM_ADT1R_EEV4) /*!< ADC Trigger on external event 1 */ +#define HRPWM_ADCTRIGEVENT1_EEV0 (HRPWM_ADT1R_EEV3) /*!< ADC Trigger on external event 0 */ +#define HRPWM_ADCTRIGEVENT1_MPER (HRPWM_ADT1R_MPER) /*!< ADC Trigger on Master Timer period */ +#define HRPWM_ADCTRIGEVENT1_MCMPD (HRPWM_ADT1R_MCMPD) /*!< ADC Trigger on Master Timer compare D */ +#define HRPWM_ADCTRIGEVENT1_MCMPC (HRPWM_ADT1R_MCMPC) /*!< ADC Trigger on Master Timer compare C */ +#define HRPWM_ADCTRIGEVENT1_MCMPB (HRPWM_ADT1R_MCMPB) /*!< ADC Trigger on Master Timer compare B */ +#define HRPWM_ADCTRIGEVENT1_MCMPA (HRPWM_ADT1R_MCMPA) /*!< ADC Trigger on Master Timer compare A */ +/** + * @} + */ + +/** @defgroup HRPWM_Software_Timer_Update HRPWM Software Timer Update + * @brief Constants used to force timer registers update + * @{ + */ +#define HRPWM_UPDATE_MASTER (HRPWM_CR1_MSWU)/*!< Force an immediate transfer from the preload to the active register in the master timer */ +#define HRPWM_UPDATE_SLAVE_0 (HRPWM_CR1_SWU0)/*!< Force an immediate transfer from the preload to the active register in the slave timer 0 */ +#define HRPWM_UPDATE_SLAVE_1 (HRPWM_CR1_SWU1)/*!< Force an immediate transfer from the preload to the active register in the slave timer 1 */ +#define HRPWM_UPDATE_SLAVE_2 (HRPWM_CR1_SWU2)/*!< Force an immediate transfer from the preload to the active register in the slave timer 2 */ +#define HRPWM_UPDATE_SLAVE_3 (HRPWM_CR1_SWU3)/*!< Force an immediate transfer from the preload to the active register in the slave timer 3 */ +#define HRPWM_UPDATE_SLAVE_4 (HRPWM_CR1_SWU4)/*!< Force an immediate transfer from the preload to the active register in the slave timer 4 */ +#define HRPWM_UPDATE_SLAVE_5 (HRPWM_CR1_SWU5)/*!< Force an immediate transfer from the preload to the active register in the slave timer 5 */ +/** + * @} + */ + +/** @defgroup HRPWM_Software_Timer_SwapOutput HRPWM Software Timer swap Output + * @brief Constants used to swap the output of the timer registers + * @{ + */ +#define HRPWM_SWAP_SLAVE_0 (HRPWM_CR1_SWP0) /*!< Swap the output of the slave Timer 0 */ +#define HRPWM_SWAP_SLAVE_1 (HRPWM_CR1_SWP1) /*!< Swap the output of the slave Timer 1 */ +#define HRPWM_SWAP_SLAVE_2 (HRPWM_CR1_SWP2) /*!< Swap the output of the slave Timer 2 */ +#define HRPWM_SWAP_SLAVE_3 (HRPWM_CR1_SWP3) /*!< Swap the output of the slave Timer 3 */ +#define HRPWM_SWAP_SLAVE_4 (HRPWM_CR1_SWP4) /*!< Swap the output of the slave Timer 4 */ +#define HRPWM_SWAP_SLAVE_5 (HRPWM_CR1_SWP5) /*!< Swap the output of the slave Timer 5 */ +/** + * @} + */ + +/** @defgroup HRPWM_Software_Timer_Reset HRPWM Software Timer Reset + * @brief Constants used to force timer counter reset + * @{ + */ +#define HRPWM_RESET_MASTER (HRPWM_CR1_MRST) /*!< Reset the master timer counter */ +#define HRPWM_RESET_SLAVE_0 (HRPWM_CR1_RST0) /*!< Reset the slave timer 0 counter */ +#define HRPWM_RESET_SLAVE_1 (HRPWM_CR1_RST1) /*!< Reset the slave timer 1 counter */ +#define HRPWM_RESET_SLAVE_2 (HRPWM_CR1_RST2) /*!< Reset the slave timer 2 counter */ +#define HRPWM_RESET_SLAVE_3 (HRPWM_CR1_RST3) /*!< Reset the slave timer 3 counter */ +#define HRPWM_RESET_SLAVE_4 (HRPWM_CR1_RST4) /*!< Reset the slave timer 4 counter */ +#define HRPWM_RESET_SLAVE_5 (HRPWM_CR1_RST5) /*!< Reset the slave timer 5 counter */ +/** + * @} + */ + +/** @defgroup HRPWM_Software_Timer_Update_Disable HRPWM Software Timer Update Disable + * @brief Constants used to force timer counter Update Disable + * @{ + */ +#define HRPWM_UPDISABLE_MASTER (HRPWM_CR0_MUDIS) /*!< Update Disable the master timer counter */ +#define HRPWM_UPDISABLE_SLAVE_0 (HRPWM_CR0_UDIS0) /*!< Update Disable the slave timer 0 counter */ +#define HRPWM_UPDISABLE_SLAVE_1 (HRPWM_CR0_UDIS1) /*!< Update Disable the slave timer 1 counter */ +#define HRPWM_UPDISABLE_SLAVE_2 (HRPWM_CR0_UDIS2) /*!< Update Disable the slave timer 2 counter */ +#define HRPWM_UPDISABLE_SLAVE_3 (HRPWM_CR0_UDIS3) /*!< Update Disable the slave timer 3 counter */ +#define HRPWM_UPDISABLE_SLAVE_4 (HRPWM_CR0_UDIS4) /*!< Update Disable the slave timer 4 counter */ +#define HRPWM_UPDISABLE_SLAVE_5 (HRPWM_CR0_UDIS5) /*!< Update Disable the slave timer 5 counter */ +/** + * @} + */ + +/** @defgroup HRPWM_Software_forced_update HRPWM Software forced update + * @brief Constants used to force timer counter Software forced update + * @{ + */ +#define HRPWM_SOFT_UPDATE_MASTER (HRPWM_CR1_MSWU) /*!< Update Disable the master timer counter */ +#define HRPWM_SOFT_UPDATE_SLAVE_0 (HRPWM_CR1_SWU0) /*!< Update Disable the slave timer 0 counter */ +#define HRPWM_SOFT_UPDATE_SLAVE_1 (HRPWM_CR1_SWU1) /*!< Update Disable the slave timer 1 counter */ +#define HRPWM_SOFT_UPDATE_SLAVE_2 (HRPWM_CR1_SWU2) /*!< Update Disable the slave timer 2 counter */ +#define HRPWM_SOFT_UPDATE_SLAVE_3 (HRPWM_CR1_SWU3) /*!< Update Disable the slave timer 3 counter */ +#define HRPWM_SOFT_UPDATE_SLAVE_4 (HRPWM_CR1_SWU4) /*!< Update Disable the slave timer 4 counter */ +#define HRPWM_SOFT_UPDATE_SLAVE_5 (HRPWM_CR1_SWU5) /*!< Update Disable the slave timer 5 counter */ +/** + * @} + */ + +/** @defgroup HRPWM_Output_State HRPWM Output State + * @brief Constants defining the state of a timer output + * @{ + */ +#define HRPWM_OUTPUTSTATE_IDLE (0x00000001U) /*!< Main operating mode, where the output can take the active or + inactive level as programmed in the crossbar unit */ +#define HRPWM_OUTPUTSTATE_RUN (0x00000002U) /*!< Default operating state (e.g. after an HRPWM reset, when the + outputs are disabled by software or during a burst mode operation */ +#define HRPWM_OUTPUTSTATE_FAULT (0x00000003U) /*!< Safety state, entered in case of a shut-down request on + FAULTx inputs */ +/** + * @} + */ + +/** @defgroup HRPWM_Common_Interrupt_Enable HRPWM Common Interrupt Enable + * @{ + */ +#define HRPWM_IT_SRC (0x0000003FU) +#define HRPWM_IT_NONE (0x00000000U) /*!< No interrupt enabled */ +#define HRPWM_IT_FLT0 HRPWM_IER_FLT0IE /*!< Fault 0 interrupt enable */ +#define HRPWM_IT_FLT1 HRPWM_IER_FLT1IE /*!< Fault 1 interrupt enable */ +#define HRPWM_IT_FLT2 HRPWM_IER_FLT2IE /*!< Fault 2 interrupt enable */ +#define HRPWM_IT_FLT3 HRPWM_IER_FLT3IE /*!< Fault 3 interrupt enable */ +#define HRPWM_IT_FLT4 HRPWM_IER_FLT4IE /*!< Fault 4 interrupt enable */ +#define HRPWM_IT_FLT5 HRPWM_IER_FLT5IE /*!< Fault 5 interrupt enable */ +#define HRPWM_IT_SYSFLT HRPWM_IER_SYSFLTIE /*!< System Fault interrupt enable */ +/** + * @} + */ + +/** @defgroup HRPWM_Common_Interrupt_Flag HRPWM Common Interrupt Flag + * @{ + */ +#define HRPWM_FLAG_FLT0 HRPWM_ISR_FLT0 /*!< Fault 0 interrupt flag */ +#define HRPWM_FLAG_FLT1 HRPWM_ISR_FLT1 /*!< Fault 1 interrupt flag */ +#define HRPWM_FLAG_FLT2 HRPWM_ISR_FLT2 /*!< Fault 2 interrupt flag */ +#define HRPWM_FLAG_FLT3 HRPWM_ISR_FLT3 /*!< Fault 3 interrupt flag */ +#define HRPWM_FLAG_FLT4 HRPWM_ISR_FLT4 /*!< Fault 4 interrupt flag */ +#define HRPWM_FLAG_FLT5 HRPWM_ISR_FLT5 /*!< Fault 5 interrupt flag */ +#define HRPWM_FLAG_SYSFLT HRPWM_ISR_SYSFLT /*!< System Fault interrupt flag */ +/** + * @} + */ + +/** @defgroup HRPWM_Master_Interrupt_Enable HRPWM Master Interrupt Enable + * @{ + */ +#define HRPWM_MASTER_IT_SRC 0x000000FFU /*!< ALL interrupt enabled */ +#define HRPWM_MASTER_IT_NONE 0x00000000U /*!< No interrupt enabled */ +#define HRPWM_MASTER_IT_MCMPA HRPWM_MIER_MCMPAIE /*!< Master compare A interrupt enable */ +#define HRPWM_MASTER_IT_MCMPB HRPWM_MIER_MCMPBIE /*!< Master compare B interrupt enable */ +#define HRPWM_MASTER_IT_MCMPC HRPWM_MIER_MCMPCIE /*!< Master compare C interrupt enable */ +#define HRPWM_MASTER_IT_MCMPD HRPWM_MIER_MCMPDIE /*!< Master compare D interrupt enable */ +#define HRPWM_MASTER_IT_MPER HRPWM_MIER_MPERIE /*!< Master Period interrupt enable */ +#define HRPWM_MASTER_IT_SYNC HRPWM_MIER_SYNCIE /*!< Synchronization input interrupt enable */ +#define HRPWM_MASTER_IT_MUPD HRPWM_MIER_MUPDIE /*!< Master update interrupt enable */ +#define HRPWM_MASTER_IT_MREP HRPWM_MIER_MREPIE /*!< Master Repetition interrupt enable */ +/** + * @} + */ + +/** @defgroup HRPWM_Master_Interrupt_Flag HRPWM Master Interrupt flag + * @{ + */ +#define HRPWM_MASTER_FLAG_NONE 0x00000000U /*!< No interrupt flag */ +#define HRPWM_MASTER_FLAG_MCMPA HRPWM_MISR_MCMPA /*!< Master compare A interrupt flag */ +#define HRPWM_MASTER_FLAG_MCMPB HRPWM_MISR_MCMPB /*!< Master compare B interrupt flag */ +#define HRPWM_MASTER_FLAG_MCMPC HRPWM_MISR_MCMPC /*!< Master compare C interrupt flag */ +#define HRPWM_MASTER_FLAG_MCMPD HRPWM_MISR_MCMPD /*!< Master compare D interrupt flag */ +#define HRPWM_MASTER_FLAG_MPER HRPWM_MISR_MPER /*!< Master Period interrupt flag */ +#define HRPWM_MASTER_FLAG_SYNC HRPWM_MISR_SYNC /*!< Synchronization input interrupt flag */ +#define HRPWM_MASTER_FLAG_MUPD HRPWM_MISR_MUPD /*!< Master update interrupt flag */ +#define HRPWM_MASTER_FLAG_MREP HRPWM_MISR_MREP /*!< Master Repetition interrupt flag */ +/** + * @} + */ + +/** @defgroup HRPWM_Slave_Timer_Unit_Interrupt_Enable HRPWM Timing Unit Interrupt Enable + * @{ + */ +#define HRPWM_IT_TIMER_SRC 0x00000FFFU /*!< ALL interrupt enabled */ +#define HRPWM_IT_TIMER_NONE 0x00000000U /*!< No interrupt enabled */ +#define HRPWM_IT_CMPA HRPWM_IER_CMPAIE /*!< Timer compare A interrupt enable */ +#define HRPWM_IT_CMPB HRPWM_IER_CMPBIE /*!< Timer compare B interrupt enable */ +#define HRPWM_IT_CMPC HRPWM_IER_CMPCIE /*!< Timer compare C interrupt enable */ +#define HRPWM_IT_CMPD HRPWM_IER_CMPDIE /*!< Timer compare D interrupt enable */ +#define HRPWM_IT_PER HRPWM_IER_PERIE /*!< Timer period interrupt enable */ +#define HRPWM_IT_UPD HRPWM_IER_UPDIE /*!< Timer update interrupt enable */ +#define HRPWM_IT_SETA HRPWM_IER_SETAIE /*!< Timer output 1 set interrupt enable */ +#define HRPWM_IT_CLRA HRPWM_IER_CLRAIE /*!< Timer output 1 reset interrupt enable */ +#define HRPWM_IT_SETB HRPWM_IER_SETBIE /*!< Timer output 2 set interrupt enable */ +#define HRPWM_IT_CLRB HRPWM_IER_CLRBIE /*!< Timer output 2 reset interrupt enable */ +#define HRPWM_IT_RST HRPWM_IER_RSTIE /*!< Timer reset interrupt enable */ +#define HRPWM_IT_REP HRPWM_IER_REPIE /*!< Timer repetition interrupt enable */ +/** + * @} + */ + +/** @defgroup HRPWM_Slave_Timer_Unit_Interrupt_Flag HRPWM Timing Unit Interrupt Flag + * @{ + */ +#define HRPWM_FLAG_CMPA HRPWM_ISR_CMPA /*!< Timer compare A interrupt flag */ +#define HRPWM_FLAG_CMPB HRPWM_ISR_CMPB /*!< Timer compare B interrupt flag */ +#define HRPWM_FLAG_CMPC HRPWM_ISR_CMPC /*!< Timer compare C interrupt flag */ +#define HRPWM_FLAG_CMPD HRPWM_ISR_CMPD /*!< Timer compare D interrupt flag */ +#define HRPWM_FLAG_PER HRPWM_ISR_PER /*!< Timer period interrupt flag */ +#define HRPWM_FLAG_UPD HRPWM_ISR_UPD /*!< Timer update interrupt flag */ +#define HRPWM_FLAG_SETA HRPWM_ISR_SETA /*!< Timer output 1 set interrupt flag */ +#define HRPWM_FLAG_CLRA HRPWM_ISR_CLRA /*!< Timer output 1 reset interrupt flag */ +#define HRPWM_FLAG_SETB HRPWM_ISR_SETB /*!< Timer output 2 set interrupt flag */ +#define HRPWM_FLAG_CLRB HRPWM_ISR_CLRB /*!< Timer output 2 reset interrupt flag */ +#define HRPWM_FLAG_RST HRPWM_ISR_RST /*!< Timer reset interrupt flag */ +#define HRPWM_FLAG_REP HRPWM_ISR_REP /*!< Timer repetition interrupt flag */ +/** + * @} + */ + +/** + * @} + */ + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup HRPWM_LL_Exported_Types HRPWM LL Exported Types + * @brief HRPWM LL Exported Types + * @{ + */ + +/** @defgroup HRPWM_DLL_CURRENT HRPWM DLL CURRENT + * @brief Constants defining dll current identifiers + * @{ + */ +typedef enum { + HRPWM_DLLCR_DLLGCP_4 = 0x0, /*!< DLL current selector bit: 4uA */ + HRPWM_DLLCR_DLLGCP_6 = HRPWM_DLLCR_DLLGCP_0, /*!< DLL current selector bit: 6uA */ + HRPWM_DLLCR_DLLGCP_8 = HRPWM_DLLCR_DLLGCP_1 | HRPWM_DLLCR_DLLGCP_0, /*!< DLL current selector bit: 8uA */ +} HRPWM_DllCurrentETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_ADC_Trigger HRPWM ADC Trigger + * @brief Constants defining ADC triggers identifiers + * @{ + */ +typedef enum { + HRPWM_ADCTRIGGER_0 = 0x0U, /*!< ADC trigger 0 identifier */ + HRPWM_ADCTRIGGER_1 = 0x1U, /*!< ADC trigger 1 identifier */ + HRPWM_ADCTRIGGER_2 = 0x2U, /*!< ADC trigger 2 identifier */ + HRPWM_ADCTRIGGER_3 = 0x3U, /*!< ADC trigger 3 identifier */ + HRPWM_ADCTRIGGER_4 = 0x4U, /*!< ADC trigger 4 identifier */ + HRPWM_ADCTRIGGER_5 = 0x5U, /*!< ADC trigger 5 identifier */ + HRPWM_ADCTRIGGER_6 = 0x6U, /*!< ADC trigger 6 identifier */ + HRPWM_ADCTRIGGER_7 = 0x7U, /*!< ADC trigger 7 identifier */ +} HRPWM_AdcTrigGroupETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Channels HRPWM External Event Channels + * @brief Constants defining external event channel identifiers + * @{ + */ +typedef enum { + HRPWM_EVENT_NONE = 0x6U, /*!< None Event */ + HRPWM_EVENT_0 = 0x0U, /*!< External event channel 0 identifier */ + HRPWM_EVENT_1 = 0x1U, /*!< External event channel 1 identifier */ + HRPWM_EVENT_2 = 0x2U, /*!< External event channel 2 identifier */ + HRPWM_EVENT_3 = 0x3U, /*!< External event channel 3 identifier */ + HRPWM_EVENT_4 = 0x4U, /*!< External event channel 4 identifier */ + HRPWM_EVENT_5 = 0x5U, /*!< External event channel 5 identifier */ +} HRPWM_EventSelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Channel HRPWM Fault Channel + * @brief Constants defining fault channel identifiers + * @{ + */ +typedef enum { + HRPWM_FAULT_0 = 0x00U, /*!< Fault channel 0 identifier */ + HRPWM_FAULT_1 = 0x01U, /*!< Fault channel 1 identifier */ + HRPWM_FAULT_2 = 0x02U, /*!< Fault channel 2 identifier */ + HRPWM_FAULT_3 = 0x03U, /*!< Fault channel 3 identifier */ + HRPWM_FAULT_4 = 0x04U, /*!< Fault channel 4 identifier */ + HRPWM_FAULT_5 = 0x05U, /*!< Fault channel 5 identifier */ + HRPWM_SYSFAULT = 0x06U, /*!< Fault channel 5 identifier */ +} HRPWM_FaultSelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Prescaler_Ratio HRPWM Prescaler Ratio + * @brief Constants defining timer high-resolution clock prescaler ratio. + * @{ + */ +typedef enum { + HRPWM_PRESCALERRATIO_MUL32 = 0x0U, /*!< fHRCK: fHRPWM x 32U = 5.12 GHz - Resolution: 195 ps */ + HRPWM_PRESCALERRATIO_MUL16 = 0x1U, /*!< fHRCK: fHRPWM x 16U = 2.56 GHz - Resolution: 390 ps */ + HRPWM_PRESCALERRATIO_MUL8 = 0x2U, /*!< fHRCK: fHRPWM x 8U = 1.28 GHz - Resolution: 781 ps */ + HRPWM_PRESCALERRATIO_MUL4 = 0x3U, /*!< fHRCK: fHRPWM x 4U = 640 MHz - Resolution: 1.56 ns */ + HRPWM_PRESCALERRATIO_MUL2 = 0x4U, /*!< fHRCK: fHRPWM x 2U = 320 MHz - Resolution: 3.125 ns */ + HRPWM_PRESCALERRATIO_DIV1 = 0x5U, /*!< fHRCK: fHRPWM = 160 MHz - Resolution: 6.25 ns */ + HRPWM_PRESCALERRATIO_DIV2 = 0x6U, /*!< fHRCK: fHRPWM / 2U = 80 MHz - Resolution: 12.5 ns */ + HRPWM_PRESCALERRATIO_DIV4 = 0x7U, /*!< fHRCK: fHRPWM / 4U = 40 MHz - Resolution: 25 ns */ +} HRPWM_PrescalerRatioETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Counter_Operating_Mode HRPWM Counter Operating Mode + * @brief Constants defining timer counter operating mode. + * @{ + */ +typedef enum { + HRPWM_MODE_CONTINUOUS = HRPWM_CR0_CONT, /*!< The timer operates in continuous (free-running) mode */ + HRPWM_MODE_SINGLESHOT = 0x0, /*!< The timer operates in non retriggerable single-shot mode */ + HRPWM_MODE_SINGLESHOT_RETRIGGERABLE = HRPWM_CR0_RETRIG, /*!< The timer operates in retriggerable single-shot mode */ +} HRPWM_ModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Half_Mode_Enable HRPWM Half Mode Enable + * @brief Constants defining half mode enabling status. + * @{ + */ +typedef enum { + HRPWM_HALFMODE_DISABLE = 0x0, /*!< Half mode is disabled */ + HRPWM_HALFMODE_ENABLE = HRPWM_CR0_HALF, /*!< Half mode is enabled */ +} HRPWM_HalfModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Interleaved_Mode HRPWM Interleaved Mode + * @brief Constants defining interleaved mode enabling status. + * @{ + */ +typedef enum { + HRPWM_INTERLEAVED_MODE_DISABLE = 0x0, /*!< HRPWM interleaved Mode is disabled */ + HRPWM_INTERLEAVED_MODE_TRIPLE = HRPWM_CR0_INTLVD_0, /*!< HRPWM interleaved Mode is Triple */ + HRPWM_INTERLEAVED_MODE_QUAD = HRPWM_CR0_INTLVD_1, /*!< HRPWM interleaved Mode is Quad */ +} HRPWM_InterleavedModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Push_Pull_Mode HRPWM Timer Push Pull Mode + * @brief Constants defining whether or not the push-pull mode is enabled for a timer. + * @{ + */ +typedef enum { + HRPWM_PUSHPULLMODE_DISABLE = 0x0, /*!< Push-Pull mode disabled */ + HRPWM_PUSHPULLMODE_ENABLE = HRPWM_CR0_PSHPLL, /*!< Push-Pull mode enabled */ +} HRPWM_PushpullModeETypeDef; + +typedef enum { + HRPWM_MODE_NONE = 0, /*!< HRPWM mode none */ + HRPWM_MODE_HALF = HRPWM_CR0_HALF, /*!< HRPWM mode half */ + HRPWM_MODE_PUSHPULL = HRPWM_CR0_PSHPLL, /*!< HRPWM mode push pull */ + HRPWM_MODE_INTERLEAVED_TRIPLE = HRPWM_CR0_INTLVD_0, /*!< HRPWM mode interleaved triple */ + HRPWM_MODE_INTERLEAVED_QUAD = HRPWM_CR0_INTLVD_1, /*!< HRPWM mode interleaved quad */ + HRPWM_MODE_HALF_PUSHPULL = HRPWM_CR0_HALF | HRPWM_CR0_PSHPLL, /*!< HRPWM mode half push pull */ + HRPWM_MODE_HALF_INTERLEAVED_TRIPLE = HRPWM_CR0_HALF | HRPWM_CR0_INTLVD_0, /*!< HRPWM mode half interleaved triple */ + HRPWM_MODE_HALF_INTERLEAVED_QUAD = HRPWM_CR0_HALF | HRPWM_CR0_INTLVD_1, /*!< HRPWM mode half interleaved quad */ + HRPWM_MODE_PUSHPULL_INTERLEAVED_TRIPLE = HRPWM_CR0_PSHPLL | HRPWM_CR0_INTLVD_0, /*!< HRPWM mode push pull interleaved triple*/ + HRPWM_MODE_PUSHPULL_INTERLEAVED_QUAD = HRPWM_CR0_PSHPLL | HRPWM_CR0_INTLVD_1, /*!< HRPWM mode push pull interleaved quad */ +} HRPWM_OutputModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Start_On_Sync_Input_Event HRPWM Start On Sync Input Event + * @brief Constants defining the timer behavior following the synchronization event + * @{ + */ +typedef enum { + HRPWM_SYNCSTART_DISABLE = 0x0, /*!< Synchronization input event has effect on the timer */ + HRPWM_SYNCSTART_ENABLE = HRPWM_CR0_SYNCSTRT, /*!< Synchronization input event starts the timer */ +} HRPWM_SyncStartETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Reset_On_Sync_Input_Event HRPWM Reset On Sync Input Event + * @brief Constants defining the timer behavior following the synchronization event + * @{ + */ +typedef enum { + HRPWM_SYNCRESET_DISABLE = 0x0, /*!< Synchronization input event has effect on the timer */ + HRPWM_SYNCRESET_ENABLE = HRPWM_CR0_SYNCRST, /*!< Synchronization input event resets the timer */ +} HRPWM_SyncResetETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Resync_Update_Enable HRPWM Re-Synchronized Update + * @brief Constants defining whether the update source coming outside from the timing unit must be synchronized + * @{ + */ +typedef enum { + HRPWM_RSYNCUPDATE_DISABLE = 0x0, /*!< The update is taken into account immediately */ + HRPWM_RSYNCUPDATE_ENABLE = HRPWM_CR0_RSYNCU, /*!< The update is taken into account on the following Reset/Roll-over event*/ +} HRPWM_RsyncUpdateETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Register_Preload_Enable HRPWM Register Preload Enable + * @brief Constants defining whether a write access into a preloadable + * register is done into the active or the preload register. + * @{ + */ +typedef enum { + HRPWM_PRELOAD_DISABLE = 0x0, /*!< Preload disabled: the write access is directly done into the active register */ + HRPWM_PRELOAD_ENABLE = HRPWM_MCR_PREEN,/*!< Preload enabled: the write access is done into the preload register */ +} HRPWM_PreloadEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Synchronization_Input_Source HRPWM Synchronization Input Source + * @brief Constants defining the synchronization input source + * @{ + */ +typedef enum { + HRPWM_SYNCINPUTSOURCE_NONE = 0x0, /*!< HRPWM Synchronization Input Source None */ + HRPWM_SYNCINPUTSOURCE_TIM0_TRGO_EVENT = HRPWM_MCR_SYNCIN_EN, /*!< The HRPWM is synchronized with TIM0_TRGO */ + HRPWM_SYNCINPUTSOURCE_EVENT = HRPWM_MCR_SYNCIN_SRC | HRPWM_MCR_SYNCIN_EN, + /*!< A positive pulse on SYNCIN input triggers the HRPWM */ +} HRPWM_SyncInputSrcETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Synchronization_Output_Source HRPWM Synchronization Output Source + * @brief Constants defining the source and event to be sent on the synchronization outputs + * @{ + */ +#define HRPWM_SYNCOUTPUTSOURCE_SRC ( HRPWM_MCR_SYNCOUT_SRC_1 | HRPWM_MCR_SYNCOUT_SRC_0) +typedef enum { + HRPWM_SYNCOUTPUTSOURCE_MASTER_START = 0x0, + /*!< A pulse is sent on the SYNCOUT output upon master timer start event */ + HRPWM_SYNCOUTPUTSOURCE_MASTER_CMPA = HRPWM_MCR_SYNCOUT_SRC_0, + /*!< A pulse is sent on the SYNCOUT output upon master timer compare 1 event */ + HRPWM_SYNCOUTPUTSOURCE_SLAVE0_STARTRST = HRPWM_MCR_SYNCOUT_SRC_1, + /*!< A pulse is sent on the SYNCOUT output upon timer A start or reset events */ + HRPWM_SYNCOUTPUTSOURCE_SLAVE0_CMPA = HRPWM_MCR_SYNCOUT_SRC_1 | HRPWM_MCR_SYNCOUT_SRC_0, + /*!< A pulse is sent on the SYNCOUT output upon timer A compare 1 event */ +} HRPWM_SyncOutputSrcETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Synchronization_Output_Polarity HRPWM Synchronization Output Polarity + * @brief Constants defining the routing and conditioning of the synchronization output event + * @{ + */ +typedef enum { + HRPWM_SYNCOUTPUTPOLARITY_NEGATIVE = HRPWM_MCR_SYNCOUT_POL, + /*!< SCOUT pin has a low idle level and issues a positive pulse of 16 fHRPWM clock cycles length for the synchronization */ + HRPWM_SYNCOUTPUTPOLARITY_POSITIVE = 0x0, + /*!< SCOUT pin has a high idle level and issues a negative pulse of 16 fHRPWM clock cycles length for the synchronization */ +} HRPWM_SyncOutputPolETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Synchronization_Output_Enable HRPWM Synchronization Output Polarity + * @brief Constants defining the routing and conditioning of the synchronization output event + * @{ + */ +typedef enum { + HRPWM_SYNCOUTPUT_ENABLE = HRPWM_MCR_SYNCOUT_EN, + /*!< SCOUT pin has a low idle level and issues a positive pulse of 16 fHRPWM clock cycles length for the synchronization */ + HRPWM_SYNCOUTPUT_DISABLE = 0x0, + /*!< SCOUT pin has a high idle level and issues a negative pulse of 16 fHRPWM clock cycles length for the synchronization */ +} HRPWM_SyncOutputEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Fault_RollOver_Mode HRPWM Timer RollOver Mode + * @brief Constants defining when the roll-over is generated upon Timerx + * event generated when the counter is equal to 0 or to HRPWM_PERxR value or BOTH + * This setting only applies when the UDM bit is set. It is not significant otherwise. + * @{ + */ +typedef enum { + HRPWM_FLTROM_BOTH = 0x0, /*!< The roll-over event is generated when the count is Period / 0 */ + HRPWM_FLTROM_ZERO = HRPWM_CR1_FLTROM_0, /*!< The roll-over event is generated when the count is 0 */ + HRPWM_FLTROM_PERIOD = HRPWM_CR1_FLTROM_1, /*!< The roll-over event is generated when the count is Period */ +} HRPWM_FltRollOverETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Event_RollOver_Mode HRPWM Timer RollOver Mode + * @brief HRPWM Timer RollOver Mode + * @{ + */ +typedef enum { + HRPWM_EEVROM_BOTH = 0x0, /*!< The roll-over event is generated when the count is Period / 0 */ + HRPWM_EEVROM_ZERO = HRPWM_CR1_EEVROM_0, /*!< The roll-over event is generated when the count is 0 */ + HRPWM_EEVROM_PERIOD = HRPWM_CR1_EEVROM_1, /*!< The roll-over event is generated when the count is Period */ +} HRPWM_EventRollOverETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_ADTrig_RollOver_Mode HRPWM Timer RollOver Mode + * @brief HRPWM Timer RollOver Mode + * @{ + */ +typedef enum { + HRPWM_ADROM_BOTH = 0x0, /*!< The roll-over event is generated when the count is Period / 0 */ + HRPWM_ADROM_ZERO = HRPWM_CR1_ADROM_0, /*!< The roll-over event is generated when the count is 0 */ + HRPWM_ADROM_PERIOD = HRPWM_CR1_ADROM_1, /*!< The roll-over event is generated when the count is Period */ +} HRPWM_AdcRollOverETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_Output_RollOver_Mode HRPWM Timer RollOver Mode + * @brief HRPWM Timer RollOver Mode + * @{ + */ +typedef enum { + HRPWM_OUTROM_BOTH = 0x0, /*!< The roll-over event is generated when the count is Period / 0 */ + HRPWM_OUTROM_ZERO = HRPWM_CR1_OUTROM_0, /*!< The roll-over event is generated when the count is 0 */ + HRPWM_OUTROM_PERIOD = HRPWM_CR1_OUTROM_1, /*!< The roll-over event is generated when the count is Period */ +} HRPWM_OutputRollOverETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_RollOver_Mode HRPWM Timer RollOver Mode + * @breif HRPWM Timer RollOver Mode + * @{ + */ +typedef enum { + HRPWM_ROM_BOTH = 0x0, /*!< The roll-over event is generated when the count is Period / 0 */ + HRPWM_ROM_ZERO = HRPWM_CR1_ROM_0, /*!< The roll-over event is generated when the count is 0 */ + HRPWM_ROM_PERIOD = HRPWM_CR1_ROM_1, /*!< The roll-over event is generated when the count is Period */ +} HRPWM_RollOverETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_UpDown_Mode HRPWM Timer UpDown Mode + * @brief Constants defining how the timer counter operates + * @{ + */ +typedef enum { + HRPWM_COUNT_UP = 0x0, /*!< Timer counter is operating in up-counting mode */ + HRPWM_COUNT_UPDOWN = HRPWM_CR1_UDM, /*!< Timer counter is operating in up-down counting mode */ +} HRPWM_CounterModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_DualChannelDac_Reset HRPWM Dual Channel Dac Reset Trigger + * @brief Constants defining when the HRPWM_dac_reset_trgx trigger is generated + * @{ + */ +typedef enum { + HRPWM_DAC_DCDR_SETA = 0x0, /*!< the trigger is generated on output A set event */ + HRPWM_DAC_DCDR_RESET = HRPWM_CR1_DCDR, /*!< the trigger is generated on counter reset or roll-over event */ +} HRPWM_DacResetSelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_DualChannelDac_Step HRPWM Dual Channel Dac Step Trigger + * @brief Constants defining when the HRPWM_dac_step_trgx trigger is generated + * @{ + */ +typedef enum { + HRPWM_DAC_DCDS_CLEARA = 0x0, /*!< the trigger is generated on output 1 reset event */ + HRPWM_DAC_DCDS_CMPD = HRPWM_CR1_DCDS, /*!< the trigger is generated on compare D event */ +} HRPWM_DacStepSelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_DualChannelDac_Enable HRPWM Dual Channel DAC Trigger Enable + * @brief Constants enabling the dual channel DAC triggering mechanism + * @{ + */ +typedef enum { + HRPWM_DAC_DCDE_DISABLE = 0x0, /*!< the Dual channel DAC trigger is disabled */ + HRPWM_DAC_DCDE_ENABLE = HRPWM_CR1_DCDE, /*!< the Dual channel DAC trigger is enabled */ +} HRPWM_DacTrigEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Deadtime_Rising_Sign HRPWM Dead-time Rising Sign + * @brief Constants defining whether the dead-time is positive or negative (overlapping signal) on rising edge + * @{ + */ +typedef enum { + HRPWM_DEADTIME_RSIGN_NEGATIVE = 0x0, /*!< Negative dead-time on rising edge */ + HRPWM_DEADTIME_RSIGN_POSITIVE = HRPWM_DTR_SDTR, /*!< Positive dead-time on rising edge */ +} HRPWM_DeadTimeRiseSignETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Deadtime_Falling_Sign HRPWM Dead-time Falling Sign + * @brief Constants defining whether the dead-time is positive or negative (overlapping signal) on falling edge + * @{ + */ +typedef enum { + HRPWM_DEADTIME_FSIGN_NEGATIVE = 0x0, /*!< Negative dead-time on falling edge */ + HRPWM_DEADTIME_FSIGN_POSITIVE = HRPWM_DTR_SDTF, /*!< Positive dead-time on falling edge */ +} HRPWM_DeadTimeFallSignETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_External_Event_Filter HRPWM Timer External Event Filter + * @brief Constants defining the event filtering applied to external events + * by a timer0 (5bit), the position of eventx need to left x*5bit; + * @{ + */ +typedef enum { + HRPWM_EEVFLT_NONE = 0x0, + /*!< HRPWM EEFVLT NONE */ + HRPWM_EEVFLT_BLANKING_CMPA = HRPWM_EEFR0_EE0FLTR_0, + /*!< Blanking from counter reset/roll-over to Compare A */ + HRPWM_EEVFLT_BLANKING_CMPB = HRPWM_EEFR0_EE0FLTR_1, + /*!< Blanking from counter reset/roll-over to Compare B */ + HRPWM_EEVFLT_BLANKING_CMPC = HRPWM_EEFR0_EE0FLTR_1 | HRPWM_EEFR0_EE0FLTR_0, + /*!< Blanking from counter reset/roll-over to Compare C */ + HRPWM_EEVFLT_BLANKING_CMPD = HRPWM_EEFR0_EE0FLTR_2, + /*!< Blanking from counter reset/roll-over to Compare D */ + HRPWM_EEVFLT_BLANKING_UPCMPA_UPCMPB = HRPWM_EEFR0_EE0FLTR_2 | HRPWM_EEFR0_EE0FLTR_0, + /*!< Blanking from counter up compare A to compare B only up_down mode valid */ + HRPWM_EEVFLT_BLANKING_UPCMPC_UPCMPD = HRPWM_EEFR0_EE0FLTR_2 | HRPWM_EEFR0_EE0FLTR_1, + /*!< Blanking from counter up compare C to compare D only up_down mode valid */ + HRPWM_EEVFLT_BLANKING_DOWNCMPA_DOWNCMPB = HRPWM_EEFR0_EE0FLTR_2 | HRPWM_EEFR0_EE0FLTR_1 | HRPWM_EEFR0_EE0FLTR_0, + /*!< Blanking from counter down compare A to compare B only up_down mode valid */ + HRPWM_EEVFLT_BLANKING_DOWNCMPC_DOWNCMPD = HRPWM_EEFR0_EE0FLTR_3, + /*!< Blanking from counter down compare C to compare D only up_down mode valid */ + HRPWM_EEVFLT_WINDOWS_BLANKING_CMPA = HRPWM_EEFR0_EE0FLTR_3 | HRPWM_EEFR0_EE0FLTR_0, + /*!< Windows from counter reset/roll-over to Compare A */ + HRPWM_EEVFLT_WINDOWS_BLANKING_CMPB = HRPWM_EEFR0_EE0FLTR_3 | HRPWM_EEFR0_EE0FLTR_1, + /*!< Windows from counter reset/roll-over to Compare B */ + HRPWM_EEVFLT_WINDOWS_BLANKING_CMPC = HRPWM_EEFR0_EE0FLTR_3 | HRPWM_EEFR0_EE0FLTR_1 | HRPWM_EEFR0_EE0FLTR_0, + /*!< Windows from counter reset/roll-over to Compare C */ + HRPWM_EEVFLT_WINDOWS_BLANKING_CMPD = HRPWM_EEFR0_EE0FLTR_3 | HRPWM_EEFR0_EE0FLTR_2, + /*!< Windows from counter reset/roll-over to Compare D */ + HRPWM_EEVFLT_WINDOWS_UPCMPB_UPCMPC = HRPWM_EEFR0_EE0FLTR_3 | HRPWM_EEFR0_EE0FLTR_2 | HRPWM_EEFR0_EE0FLTR_0, + /*!< Windows from counter up compare B to compare C only up_down mode valid */ + HRPWM_EEVFLT_WINDOWS_DOWNCMPB_DOWNCMPC = HRPWM_EEFR0_EE0FLTR_3 | HRPWM_EEFR0_EE0FLTR_2 | HRPWM_EEFR0_EE0FLTR_1, + /*!< Windows from counter down compare B to compare C only up_down mode valid */ + HRPWM_EEVFLT_WINDOWS_UPCMPB_DOWNCMPC = HRPWM_EEFR0_EE0FLTR_3 | HRPWM_EEFR0_EE0FLTR_2 | HRPWM_EEFR0_EE0FLTR_1 | HRPWM_EEFR0_EE0FLTR_0, + /*!< Windows from counter up compare B to down compare C only up_down mode valid */ +} HRPWM_EventAFilterWindowETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_External_Event_Latch HRPWM Timer External Event Latch + * @brief Constants defining whether or not the external event is + * memorized (latched) and generated as soon as the blanking period + * is completed or the window ends, the position of eventx need to left x*5bit; + * @{ + */ +typedef enum { + HRPWM_EVENTLATCH_DISABLE = 0x0, + /*!< Event is ignored if it happens during a blank, or passed through during a window */ + HRPWM_EVENTLATCH_ENABLE = HRPWM_EEFR0_EE0LTCH, + /*!< Event is latched and delayed till the end of the blanking or windowing period */ +} HRPWM_EventALatchETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Source_Select HRPWM Timer External Event Counter A source selection + * @brief Constants defining the External Event Counter A source selection + * @{ + */ +typedef enum { + HRPWM_EEVASEL_SOURCE_EEVENT0 = 0x00U, /*!< External Event A selected event 0 as the source */ + HRPWM_EEVASEL_SOURCE_EEVENT1 = 0x10U, /*!< External Event A selected event 1 as the source */ + HRPWM_EEVASEL_SOURCE_EEVENT2 = 0x20U, /*!< External Event A selected event 2 as the source */ + HRPWM_EEVASEL_SOURCE_EEVENT3 = 0x30U, /*!< External Event A selected event 3 as the source */ + HRPWM_EEVASEL_SOURCE_EEVENT4 = 0x40U, /*!< External Event A selected event 4 as the source */ + HRPWM_EEVASEL_SOURCE_EEVENT5 = 0x50U, /*!< External Event A selected event 5 as the source */ +} HRPWM_EventASourceSelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_External_Event_Counter HRPWM Timer External Event Counter + * @brief Constants enabling the External Event A Counter + * @{ + */ +typedef enum { + HRPWM_EEVACOUNTER_DISABLE = 0x0, /*!< External Event Counter disabled */ + HRPWM_EEVACOUNTER_ENABLE = HRPWM_EEFR1_EEVACE, /*!< External Event Counter enabled */ +} HRPWM_EventACouterEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Timer_External_Event_ResetMode HRPWM Timer External Counter Reset Mode + * @brief Constants enabling the External Event Counter A Reset Mode + * @{ + */ +typedef enum { + HRPWM_EEVARSTM_UNCONDITIONAL = 0x0, + /*!< External Event Counter is reset on each reset / roll-over event */ + HRPWM_EEVARSTM_CONDITIONAL = HRPWM_EEFR1_EEVARSTM, + /*!< External Event Counter is reset on each reset / roll-over event only if no event occurs during last counting period */ +} HRPWM_EventARstModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Chopper_Frequency HRPWM Chopper Frequency + * @brief Constants defining the frequency of the generated high frequency carrier + * @{ + */ +typedef enum { + HRPWM_CHOPPER_CARFRQ_DIV16 = 0x0, + /*!< fCHPFRQ = fHRPWM / 16 */ + HRPWM_CHOPPER_CARFRQ_DIV32 = HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 32 */ + HRPWM_CHOPPER_CARFRQ_DIV48 = HRPWM_CHPR_CARFRQ_1, + /*!< fCHPFRQ = fHRPWM / 48 */ + HRPWM_CHOPPER_CARFRQ_DIV64 = HRPWM_CHPR_CARFRQ_1 | HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 64 */ + HRPWM_CHOPPER_CARFRQ_DIV80 = HRPWM_CHPR_CARFRQ_2, + /*!< fCHPFRQ = fHRPWM / 80 */ + HRPWM_CHOPPER_CARFRQ_DIV96 = HRPWM_CHPR_CARFRQ_2 | HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 96 */ + HRPWM_CHOPPER_CARFRQ_DIV112 = HRPWM_CHPR_CARFRQ_2 | HRPWM_CHPR_CARFRQ_1, + /*!< fCHPFRQ = fHRPWM / 112 */ + HRPWM_CHOPPER_CARFRQ_DIV128 = HRPWM_CHPR_CARFRQ_2 | HRPWM_CHPR_CARFRQ_1 | HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 128 */ + HRPWM_CHOPPER_CARFRQ_DIV144 = HRPWM_CHPR_CARFRQ_3, + /*!< fCHPFRQ = fHRPWM / 144 */ + HRPWM_CHOPPER_CARFRQ_DIV160 = HRPWM_CHPR_CARFRQ_3 | HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 160 */ + HRPWM_CHOPPER_CARFRQ_DIV176 = HRPWM_CHPR_CARFRQ_3 | HRPWM_CHPR_CARFRQ_1, + /*!< fCHPFRQ = fHRPWM / 176 */ + HRPWM_CHOPPER_CARFRQ_DIV192 = HRPWM_CHPR_CARFRQ_3 | HRPWM_CHPR_CARFRQ_1 | HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 192 */ + HRPWM_CHOPPER_CARFRQ_DIV208 = HRPWM_CHPR_CARFRQ_3 | HRPWM_CHPR_CARFRQ_2, + /*!< fCHPFRQ = fHRPWM / 208 */ + HRPWM_CHOPPER_CARFRQ_DIV224 = HRPWM_CHPR_CARFRQ_3 | HRPWM_CHPR_CARFRQ_2 | HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 224 */ + HRPWM_CHOPPER_CARFRQ_DIV240 = HRPWM_CHPR_CARFRQ_3 | HRPWM_CHPR_CARFRQ_2 | HRPWM_CHPR_CARFRQ_1, + /*!< fCHPFRQ = fHRPWM / 240 */ + HRPWM_CHOPPER_CARFRQ_DIV256 = HRPWM_CHPR_CARFRQ_3 | HRPWM_CHPR_CARFRQ_2 | HRPWM_CHPR_CARFRQ_1 | HRPWM_CHPR_CARFRQ_0, + /*!< fCHPFRQ = fHRPWM / 256 */ +} HRPWM_ChopperCarfreqETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Chopper_Duty_Cycle HRPWM Chopper Duty Cycle + * @brief Constants defining the duty cycle of the generated high frequency carrier + * Duty cycle can be adjusted by 1/8 step (from 0/8 up to 7/8) + * @{ + */ +typedef enum { + HRPWM_CHOPPER_DUTYCYCLE_0 = 0x0, + /*!< Only 1st pulse is present */ + HRPWM_CHOPPER_DUTYCYCLE_1 = HRPWM_CHPR_CARDTY_0, + /*!< Duty cycle of the carrier signal is 12.5U % */ + HRPWM_CHOPPER_DUTYCYCLE_2 = HRPWM_CHPR_CARDTY_1, + /*!< Duty cycle of the carrier signal is 25U % */ + HRPWM_CHOPPER_DUTYCYCLE_3 = HRPWM_CHPR_CARDTY_1 | HRPWM_CHPR_CARDTY_0, + /*!< Duty cycle of the carrier signal is 37.5U % */ + HRPWM_CHOPPER_DUTYCYCLE_4 = HRPWM_CHPR_CARDTY_2, + /*!< Duty cycle of the carrier signal is 50U % */ + HRPWM_CHOPPER_DUTYCYCLE_5 = HRPWM_CHPR_CARDTY_2 | HRPWM_CHPR_CARDTY_0, + /*!< Duty cycle of the carrier signal is 62.5U % */ + HRPWM_CHOPPER_DUTYCYCLE_6 = HRPWM_CHPR_CARDTY_2 | HRPWM_CHPR_CARDTY_1, + /*!< Duty cycle of the carrier signal is 75U % */ + HRPWM_CHOPPER_DUTYCYCLE_7 = HRPWM_CHPR_CARDTY_2 | HRPWM_CHPR_CARDTY_1 | HRPWM_CHPR_CARDTY_0, + /*!< Duty cycle of the carrier signal is 87.5U % */ +} HRPWM_ChopperDutyETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Chopper_Start_Pulse_Width HRPWM Chopper Start Pulse Width + * @brief Constants defining the pulse width of the first pulse of the generated high frequency carrier + * @{ + */ +typedef enum { + HRPWM_CHOPPER_PULSEWIDTH_16 = 0x0, + /*!< tSTPW = tHRPWM x 16 */ + HRPWM_CHOPPER_PULSEWIDTH_32 = HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 32 */ + HRPWM_CHOPPER_PULSEWIDTH_48 = HRPWM_CHPR_STRPW_1, + /*!< tSTPW = tHRPWM x 48 */ + HRPWM_CHOPPER_PULSEWIDTH_64 = HRPWM_CHPR_STRPW_1 | HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 64 */ + HRPWM_CHOPPER_PULSEWIDTH_80 = HRPWM_CHPR_STRPW_2, + /*!< tSTPW = tHRPWM x 80 */ + HRPWM_CHOPPER_PULSEWIDTH_96 = HRPWM_CHPR_STRPW_2 | HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 96 */ + HRPWM_CHOPPER_PULSEWIDTH_112 = HRPWM_CHPR_STRPW_2 | HRPWM_CHPR_STRPW_1, + /*!< tSTPW = tHRPWM x 112 */ + HRPWM_CHOPPER_PULSEWIDTH_128 = HRPWM_CHPR_STRPW_2 | HRPWM_CHPR_STRPW_1 | HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 128 */ + HRPWM_CHOPPER_PULSEWIDTH_144 = HRPWM_CHPR_STRPW_3, + /*!< tSTPW = tHRPWM x 144 */ + HRPWM_CHOPPER_PULSEWIDTH_160 = HRPWM_CHPR_STRPW_3 | HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 160 */ + HRPWM_CHOPPER_PULSEWIDTH_176 = HRPWM_CHPR_STRPW_3 | HRPWM_CHPR_STRPW_1, + /*!< tSTPW = tHRPWM x 176 */ + HRPWM_CHOPPER_PULSEWIDTH_192 = HRPWM_CHPR_STRPW_3 | HRPWM_CHPR_STRPW_1 | HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 192 */ + HRPWM_CHOPPER_PULSEWIDTH_208 = HRPWM_CHPR_STRPW_3 | HRPWM_CHPR_STRPW_2, + /*!< tSTPW = tHRPWM x 208 */ + HRPWM_CHOPPER_PULSEWIDTH_224 = HRPWM_CHPR_STRPW_3 | HRPWM_CHPR_STRPW_2 | HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 224 */ + HRPWM_CHOPPER_PULSEWIDTH_240 = HRPWM_CHPR_STRPW_3 | HRPWM_CHPR_STRPW_2 | HRPWM_CHPR_STRPW_1, + /*!< tSTPW = tHRPWM x 240 */ + HRPWM_CHOPPER_PULSEWIDTH_256 = HRPWM_CHPR_STRPW_3 | HRPWM_CHPR_STRPW_2 | HRPWM_CHPR_STRPW_1 | HRPWM_CHPR_STRPW_0, + /*!< tSTPW = tHRPWM x 256 */ +} HRPWM_ChopperPulseWidthETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Output_ChopperA_Mode_Enable HRPWM Output Chopper Mode Enable + * @brief Constants defining whether or not chopper mode is enabled for a timer + output + * @{ + */ +typedef enum { + HRPWM_OUTPUTCHOPPERA_DISABLE = 0x0, /*!< Output signal is not altered */ + HRPWM_OUTPUTCHOPPERA_ENABLE = HRPWM_OUTR_CHPA, /*!< Output signal is chopped by a carrier signal */ +} HRPWM_ChopperAEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_OutputA_IDLE_Level HRPWM Output IDLE Level + * @brief Constants defining the output level when output is in IDLE state + * @{ + */ +typedef enum { + HRPWM_OUTPUTIDLEA_INACTIVE = 0x0, /*!< Output at inactive level when in IDLE state */ + HRPWM_OUTPUTIDLEA_ACTIVE = HRPWM_OUTR_IDLESA, /*!< Output at active level when in IDLE state */ +} HRPWM_IdelALevelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_OutputA_FAULT_Level HRPWM Output FAULT Level + * @brief Constants defining the output level when output is in FAULT state + * @{ + */ +typedef enum { + HRPWM_OUTPUTFAULTA_NONE = 0x0, /*!< The output is not affected by the fault input */ + HRPWM_OUTPUTFAULTA_ACTIVE = HRPWM_OUTR_FAULTA_0, /*!< Output at active level when in FAULT state */ + HRPWM_OUTPUTFAULTA_INACTIVE = HRPWM_OUTR_FAULTA_1, /*!< Output at inactive level when in FAULT state */ + HRPWM_OUTPUTFAULTA_HIGHZ = HRPWM_OUTR_FAULTA_1 | HRPWM_OUTR_FAULTA_0,/*!< Output is tri-stated when in FAULT state */ +} HRPWM_FaultALevelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_OutputA_Active_Polarity HRPWM Output Active_Polarity + * @brief Constants whether the effective polarity is low level valid or high level valid + * @{ + */ +typedef enum { + HRPWM_OUTPUT_POLA_POSITIVE = 0x0, /*!< Positive polarity, high output efficiency */ + HRPWM_OUTPUT_POLA_NEGATIVE = HRPWM_OUTR_POLA, /*!< Negative polarity, low output efficiency */ +} HRPWM_OutputAPolETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Output_ChopperB_Mode_Enable HRPWM Output Chopper Mode Enable + * @brief Constants defining whether or not chopper mode is enabled for a timer output + * @{ + */ +typedef enum { + HRPWM_OUTPUTCHOPPERB_DISABLE = 0x0, /*!< Output signal is not altered */ + HRPWM_OUTPUTCHOPPERB_ENABLE = HRPWM_OUTR_CHPB, /*!< Output signal is chopped by a carrier signal */ +} HRPWM_ChopperBEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_OutputB_IDLE_Level HRPWM Output IDLE Level + * @brief Constants defining the output level when output is in IDLE state + * @{ + */ +typedef enum { + HRPWM_OUTPUTIDLEB_INACTIVE = 0x0, /*!< Output at inactive level when in IDLE state */ + HRPWM_OUTPUTIDLEB_ACTIVE = HRPWM_OUTR_IDLESB, /*!< Output at active level when in IDLE state */ +} HRPWM_IdelBLevelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_OutputB_FAULT_Level HRPWM Output FAULT Level + * @brief Constants defining the output level when output is in FAULT state + * @{ + */ +typedef enum { + HRPWM_OUTPUTFAULTB_NONE = 0x0, /*!< The output is not affected by the fault input */ + HRPWM_OUTPUTFAULTB_ACTIVE = HRPWM_OUTR_FAULTB_0, /*!< Output at active level when in FAULT state */ + HRPWM_OUTPUTFAULTB_INACTIVE = HRPWM_OUTR_FAULTB_1, /*!< Output at inactive level when in FAULT state */ + HRPWM_OUTPUTFAULTB_HIGHZ = HRPWM_OUTR_FAULTB_1 | HRPWM_OUTR_FAULTB_0,/*!< Output is tri-stated when in FAULT state */ +} HRPWM_FaultBLevelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_OutputB_Active_Polarity HRPWM Output Active_Polarity + * @brief Constants whether the effective polarity is low level valid or high level valid + * @{ + */ +typedef enum { + HRPWM_OUTPUT_POLB_POSITIVE = 0x0, /*!< Positive polarity, high output efficiency */ + HRPWM_OUTPUT_POLB_NEGATIVE = HRPWM_OUTR_POLB, /*!< Negative polarity, low output efficiency */ +} HRPWM_OutputBPolETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_ADC_Trigger_PostScaler HRPWM ADC Trigger PostScaler + * @brief constants defining the adc trigger PostScaler 0~0xf; + * @{ + */ +typedef enum { + HRPWM_ADCTRIG_PSC_1 = 0x0, + /*!< The PostScaler number of 1 */ + HRPWM_ADCTRIG_PSC_2 = HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 2 */ + HRPWM_ADCTRIG_PSC_3 = HRPWM_ADPSR_ADPSC0_1, + /*!< The PostScaler number of 3 */ + HRPWM_ADCTRIG_PSC_4 = HRPWM_ADPSR_ADPSC0_1 | HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 4 */ + HRPWM_ADCTRIG_PSC_5 = HRPWM_ADPSR_ADPSC0_2, + /*!< The PostScaler number of 5 */ + HRPWM_ADCTRIG_PSC_6 = HRPWM_ADPSR_ADPSC0_2 | HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 6 */ + HRPWM_ADCTRIG_PSC_7 = HRPWM_ADPSR_ADPSC0_2 | HRPWM_ADPSR_ADPSC0_1, + /*!< The PostScaler number of 7 */ + HRPWM_ADCTRIG_PSC_8 = HRPWM_ADPSR_ADPSC0_2 | HRPWM_ADPSR_ADPSC0_1 | HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 8 */ + HRPWM_ADCTRIG_PSC_9 = HRPWM_ADPSR_ADPSC0_3, + /*!< The PostScaler number of 9 */ + HRPWM_ADCTRIG_PSC_10 = HRPWM_ADPSR_ADPSC0_3 | HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 10 */ + HRPWM_ADCTRIG_PSC_11 = HRPWM_ADPSR_ADPSC0_3 | HRPWM_ADPSR_ADPSC0_1, + /*!< The PostScaler number of 11 */ + HRPWM_ADCTRIG_PSC_12 = HRPWM_ADPSR_ADPSC0_3 | HRPWM_ADPSR_ADPSC0_1 | HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 12 */ + HRPWM_ADCTRIG_PSC_13 = HRPWM_ADPSR_ADPSC0_3 | HRPWM_ADPSR_ADPSC0_2, + /*!< The PostScaler number of 13 */ + HRPWM_ADCTRIG_PSC_14 = HRPWM_ADPSR_ADPSC0_3 | HRPWM_ADPSR_ADPSC0_2 | HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 14 */ + HRPWM_ADCTRIG_PSC_15 = HRPWM_ADPSR_ADPSC0_3 | HRPWM_ADPSR_ADPSC0_2 | HRPWM_ADPSR_ADPSC0_1, + /*!< The PostScaler number of 15 */ + HRPWM_ADCTRIG_PSC_16 = HRPWM_ADPSR_ADPSC0_3 | HRPWM_ADPSR_ADPSC0_2 | HRPWM_ADPSR_ADPSC0_1 | HRPWM_ADPSR_ADPSC0_0, + /*!< The PostScaler number of 16 */ +} HRPWM_AdcTrigPSCETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_ADC_Trigger_Update_Source HRPWM ADC Trigger Update Source + * @brief constants defining the source triggering the update of the + HRPWM_ADCxR register (transfer from preload to active register). 3bit + * @{ + */ +typedef enum { + HRPWM_ADCTRIGUPDATE_MASTER = 0x0, /*!< Master timer */ + HRPWM_ADCTRIGUPDATE_TIMER_0 = HRPWM_CR0_ADUSRC0_0, /*!< Slave Timer 0 */ + HRPWM_ADCTRIGUPDATE_TIMER_1 = HRPWM_CR0_ADUSRC0_1, /*!< Slave Timer 1 */ + HRPWM_ADCTRIGUPDATE_TIMER_2 = HRPWM_CR0_ADUSRC0_1 | HRPWM_CR0_ADUSRC0_0, /*!< Slave Timer 2 */ + HRPWM_ADCTRIGUPDATE_TIMER_3 = HRPWM_CR0_ADUSRC0_2, /*!< Slave Timer 3 */ + HRPWM_ADCTRIGUPDATE_TIMER_4 = HRPWM_CR0_ADUSRC0_2 | HRPWM_CR0_ADUSRC0_0, /*!< Slave Timer 4 */ + HRPWM_ADCTRIGUPDATE_TIMER_5 = HRPWM_CR0_ADUSRC0_2 | HRPWM_CR0_ADUSRC0_1, /*!< Slave Timer 5 */ +} HRPWM_AdcTrigUpdateSrcETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_ADC_Trigger_Length HRPWM ADC Trigger Length + * @brief constants defining the events triggering length. (left x * 4bit) + * @{ + */ +typedef enum { + HRPWM_ADCTRIG_LENGTH_1 = 0x0, + /*!< The length of ADC trigger time is 1 clock */ + HRPWM_ADCTRIG_LENGTH_2 = HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 2 clock */ + HRPWM_ADCTRIG_LENGTH_3 = HRPWM_CR2_TLEN0_1, + /*!< The length of ADC trigger time is 3 clock */ + HRPWM_ADCTRIG_LENGTH_4 = HRPWM_CR2_TLEN0_1 | HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 4 clock */ + HRPWM_ADCTRIG_LENGTH_5 = HRPWM_CR2_TLEN0_2, + /*!< The length of ADC trigger time is 5 clock */ + HRPWM_ADCTRIG_LENGTH_6 = HRPWM_CR2_TLEN0_2 | HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 6 clock */ + HRPWM_ADCTRIG_LENGTH_7 = HRPWM_CR2_TLEN0_2 | HRPWM_CR2_TLEN0_1, + /*!< The length of ADC trigger time is 7 clock */ + HRPWM_ADCTRIG_LENGTH_8 = HRPWM_CR2_TLEN0_2 | HRPWM_CR2_TLEN0_1 | HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 8 clock */ + HRPWM_ADCTRIG_LENGTH_9 = HRPWM_CR2_TLEN0_3, + /*!< The length of ADC trigger time is 9 clock */ + HRPWM_ADCTRIG_LENGTH_10 = HRPWM_CR2_TLEN0_3 | HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 10 clock */ + HRPWM_ADCTRIG_LENGTH_11 = HRPWM_CR2_TLEN0_3 | HRPWM_CR2_TLEN0_1, + /*!< The length of ADC trigger time is 11 clock */ + HRPWM_ADCTRIG_LENGTH_12 = HRPWM_CR2_TLEN0_3 | HRPWM_CR2_TLEN0_1 | HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 12 clock */ + HRPWM_ADCTRIG_LENGTH_13 = HRPWM_CR2_TLEN0_3 | HRPWM_CR2_TLEN0_2, + /*!< The length of ADC trigger time is 13 clock */ + HRPWM_ADCTRIG_LENGTH_14 = HRPWM_CR2_TLEN0_3 | HRPWM_CR2_TLEN0_2 | HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 14 clock */ + HRPWM_ADCTRIG_LENGTH_15 = HRPWM_CR2_TLEN0_3 | HRPWM_CR2_TLEN0_2 | HRPWM_CR2_TLEN0_1, + /*!< The length of ADC trigger time is 15 clock */ + HRPWM_ADCTRIG_LENGTH_16 = HRPWM_CR2_TLEN0_3 | HRPWM_CR2_TLEN0_2 | HRPWM_CR2_TLEN0_1 | HRPWM_CR2_TLEN0_0, + /*!< The length of ADC trigger time is 16 clock */ +} HRPWM_AdcTrigLengthETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Prescaler HRPWM External Event Prescaler + * @brief Constants defining division ratio between the timer clock frequency + * fHRPWM) and the external event signal sampling clock (fEEVS) + * used by the digital filters + * @{ + */ +typedef enum { + HRPWM_EEVSD_DIV1 = 0x0, /*!< fEEVS=fHRPWM */ + HRPWM_EEVSD_DIV2 = HRPWM_EECR2_EEVSD_0, /*!< fEEVS=fHRPWM / 2U */ + HRPWM_EEVSD_DIV4 = (int32_t)HRPWM_EECR2_EEVSD_1, /*!< fEEVS=fHRPWM / 4U */ + HRPWM_EEVSD_DIV8 = (int32_t)(HRPWM_EECR2_EEVSD_1 | HRPWM_EECR2_EEVSD_0), /*!< fEEVS=fHRPWM / 8U */ +} HRPWM_EventPrescalerETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Filter HRPWM External Event Filter + * @brief Constants defining the frequency used to sample an external event 6 + * input and the length (N) of the digital filter applied + * @{ + */ +typedef enum { + HRPWM_EVENTFILTER_NONE = 0x0, + /*!< Filter disabled */ + HRPWM_EVENTFILTER_1 = HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fHRPWM, N=2U */ + HRPWM_EVENTFILTER_2 = HRPWM_EECR2_EE0F_1, + /*!< fSAMPLING= fHRPWM, N=4U */ + HRPWM_EVENTFILTER_3 = HRPWM_EECR2_EE0F_1 | HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fHRPWM, N=8U */ + HRPWM_EVENTFILTER_4 = HRPWM_EECR2_EE0F_2, + /*!< fSAMPLING= fEEVS/2U, N=6U */ + HRPWM_EVENTFILTER_5 = HRPWM_EECR2_EE0F_2 | HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fEEVS/2U, N=8U */ + HRPWM_EVENTFILTER_6 = HRPWM_EECR2_EE0F_2 | HRPWM_EECR2_EE0F_1, + /*!< fSAMPLING= fEEVS/4U, N=6U */ + HRPWM_EVENTFILTER_7 = HRPWM_EECR2_EE0F_2 | HRPWM_EECR2_EE0F_1 | HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fEEVS/4U, N=8U */ + HRPWM_EVENTFILTER_8 = HRPWM_EECR2_EE0F_3, + /*!< fSAMPLING= fEEVS/8U, N=6U */ + HRPWM_EVENTFILTER_9 = HRPWM_EECR2_EE0F_3 | HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fEEVS/8U, N=8U */ + HRPWM_EVENTFILTER_10 = HRPWM_EECR2_EE0F_3 | HRPWM_EECR2_EE0F_1, + /*!< fSAMPLING= fEEVS/16U, N=5U */ + HRPWM_EVENTFILTER_11 = HRPWM_EECR2_EE0F_3 | HRPWM_EECR2_EE0F_1 | HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fEEVS/16U, N=6U */ + HRPWM_EVENTFILTER_12 = HRPWM_EECR2_EE0F_3 | HRPWM_EECR2_EE0F_2, + /*!< fSAMPLING= fEEVS/16U, N=8U */ + HRPWM_EVENTFILTER_13 = HRPWM_EECR2_EE0F_3 | HRPWM_EECR2_EE0F_2 | HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fEEVS/32U, N=5U */ + HRPWM_EVENTFILTER_14 = HRPWM_EECR2_EE0F_3 | HRPWM_EECR2_EE0F_2 | HRPWM_EECR2_EE0F_1, + /*!< fSAMPLING= fEEVS/32U, N=6U */ + HRPWM_EVENTFILTER_15 = HRPWM_EECR2_EE0F_3 | HRPWM_EECR2_EE0F_2 | HRPWM_EECR2_EE0F_1 | HRPWM_EECR2_EE0F_0, + /*!< fSAMPLING= fEEVS/32U, N=8U */ +} HRPWM_EventFilterETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Fast_Mode HRPWM External Event Fast Mode + * @brief Constants defining whether or not an external event is programmed in fast mode + * @{ + */ +typedef enum { + HRPWM_EVENTFASTMODE_DISABLE = 0x0, + /*!< External Event is re-synchronized by the HRPWM logic before acting on outputs */ + HRPWM_EVENTFASTMODE_ENABLE = HRPWM_EECR0_EE0FAST, + /*!< External Event is acting asynchronously on outputs (low latency mode) */ +} HRPWM_EventFastModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Sensitivity HRPWM External Event Sensitivity + * @brief Constants defining the sensitivity (level-sensitive or edge-sensitive) + * of an external event + * @{ + */ +typedef enum { + HRPWM_EVENTSENS_LEVEL = 0x0, + /*!< External event is active on level */ + HRPWM_EVENTSENS_RISINGEDGE = HRPWM_EECR0_EE0SNS_0, + /*!< External event is active on Rising edge */ + HRPWM_EVENTSENS_FALLINGEDGE = HRPWM_EECR0_EE0SNS_1, + /*!< External event is active on Falling edge */ + HRPWM_EVENTSENS_BOTHEDGES = HRPWM_EECR0_EE0SNS_1 | HRPWM_EECR0_EE0SNS_0, + /*!< External event is active on Rising and Falling edges */ +} HRPWM_EventSensETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Polarity HRPWM External Event Polarity + * @brief Constants defining the polarity of an external event + * @{ + */ +typedef enum { + HRPWM_EVENTPOL_HIGH = 0x0, /*!< External event is active high */ + HRPWM_EVENTPOL_LOW = HRPWM_EECR0_EE0POL, /*!< External event is active low */ +} HRPWM_EventPolETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Event_Sources HRPWM External Event Sources + * @brief Constants defining available sources associated to external events + * @{ + */ +typedef enum { + HRPWM_EEVSRC_GPIO = 0x0, /*!< External event source 1U for External Event */ + HRPWM_EEVSRC_COMP_OUT = HRPWM_EECR0_EE0SRC_0, /*!< External event source 2U for External Event */ + HRPWM_EEVSRC_TIM_TRGO = HRPWM_EECR0_EE0SRC_1, /*!< External event source 3U for External Event */ + HRPWM_EEVSRC_ADC_AWD = HRPWM_EECR0_EE0SRC_1 | HRPWM_EECR0_EE0SRC_0, /*!< External event source 4U for External Event */ +} HRPWM_EventSrcSelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Enable HRPWM Fault Enable + * @brief Constants defining the Enable of a fault event + * @{ + */ +typedef enum { + HRPWM_FAULT_DISABLE = 0x0, /*!< Fault input is disable */ + HRPWM_FAULT_ENABLE = HRPWM_FLTINR0_FLT0E, /*!< Fault input is enable */ +} HRPWM_FaultEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Sources HRPWM Fault Sources + * @brief Constants defining whether a fault is triggered by any external or internal fault source + * @{ + */ +typedef enum { + HRPWM_FLTSRC_GPIO = 0x0, /*!< The fault source 1U for External pin 0 */ + HRPWM_FLTSRC_COMP_OUT = HRPWM_FLTINR0_FLT0SRC_0, /*!< The fault source 2U for External Event 0 */ + HRPWM_FLTSRC_EVENT = HRPWM_FLTINR0_FLT0SRC_1, /*!< The fault source 3U for internal Event 0 */ +} HRPWM_FaultSrcSelETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Polarity HRPWM Fault Polarity + * @brief Constants defining the polarity of a fault event + * @{ + */ +typedef enum { + HRPWM_FAULTPOL_HIGH = 0x0, /*!< Fault input is active low */ + HRPWM_FAULTPOL_LOW = HRPWM_FLTINR0_FLT0P, /*!< Fault input is active high */ +} HRPWM_FaultPolETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Blanking HRPWM Fault Blanking Source + * @brief Constants defining the blanking source of a fault event + * @{ + */ +typedef enum { + HRPWM_FAULTBLKS_RSTALIGNED = 0x0, /*!< Fault blanking source is Reset-aligned window */ + HRPWM_FAULTBLKS_MOVING = HRPWM_FLTINR2_FLT0BLKS, /*!< Fault blanking source is Moving window */ +} HRPWM_FaultBlkWindowETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_ResetMode HRPWM Fault Reset Mode + * @brief Constants defining the Counter reset mode of a fault event + * @{ + */ +typedef enum { + HRPWM_FAULTRSTM_UNCONDITIONAL = 0x0, + /*!< Fault counter is reset on each reset / roll-over event */ + HRPWM_FAULTRSTM_CONDITIONAL = HRPWM_FLTINR2_FLT0RSTM, + /*!< Fault counter is reset on each reset / roll-over event only if no fault occurred during last countingperiod. */ +} HRPWM_FaultRstModeETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Blanking_Control HRPWM Fault Blanking Control + * @brief Constants used to enable or disable the blanking mode of a fault channel + * @{ + */ +typedef enum { + HRPWM_FAULTBLKEN_DISABLE = 0x0, /*!< No blanking on Fault */ + HRPWM_FAULTBLKEN_ENABLE = HRPWM_FLTINR2_FLT0BLKE, /*!< Fault blanking mode */ +} HRPWM_FaultBlkEnETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_External_Fault_Prescaler HRPWM External Fault Prescaler + * @brief Constants defining the division ratio between the timer clock + * frequency (fHRPWM) and the fault signal sampling clock (fFLTS) used + * by the digital filters. + * @{ + */ +typedef enum { + HRPWM_FLTSD_DIV1 = 0x0, /*!< fFLTS=fHRPWM */ + HRPWM_FLTSD_DIV2 = HRPWM_FLTINR1_FLTSD_0, /*!< fFLTS=fHRPWM / 2U */ + HRPWM_FLTSD_DIV4 = (int32_t)HRPWM_FLTINR1_FLTSD_1, /*!< fFLTS=fHRPWM / 4U */ + HRPWM_FLTSD_DIV8 = (int32_t)(HRPWM_FLTINR1_FLTSD_1 | HRPWM_FLTINR1_FLTSD_0), /*!< fFLTS=fHRPWM / 8U */ +} HRPWM_FaultPrescalerETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Filter HRPWM Fault Filter + * @brief Constants defining the frequency used to sample the fault input and + * the length (N) of the digital filter applied + * @{ + */ +typedef enum { + HRPWM_FAULTFILTER_NONE = 0x0, + /*!< Filter disabled */ + HRPWM_FAULTFILTER_1 = HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fHRPWM, N=2U */ + HRPWM_FAULTFILTER_2 = HRPWM_FLTINR1_FLT0F_1, + /*!< fSAMPLING= fHRPWM, N=4U */ + HRPWM_FAULTFILTER_3 = HRPWM_FLTINR1_FLT0F_1 | HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fHRPWM, N=8U */ + HRPWM_FAULTFILTER_4 = HRPWM_FLTINR1_FLT0F_2, + /*!< fSAMPLING= fFLTS/2U, N=6U */ + HRPWM_FAULTFILTER_5 = HRPWM_FLTINR1_FLT0F_2 | HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fFLTS/2U, N=8U */ + HRPWM_FAULTFILTER_6 = HRPWM_FLTINR1_FLT0F_2 | HRPWM_FLTINR1_FLT0F_1, + /*!< fSAMPLING= fFLTS/4U, N=6U */ + HRPWM_FAULTFILTER_7 = HRPWM_FLTINR1_FLT0F_2 | HRPWM_FLTINR1_FLT0F_1 | HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fFLTS/4U, N=8U */ + HRPWM_FAULTFILTER_8 = HRPWM_FLTINR1_FLT0F_3, + /*!< fSAMPLING= fFLTS/8U, N=6U */ + HRPWM_FAULTFILTER_9 = HRPWM_FLTINR1_FLT0F_3 | HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fFLTS/8U, N=8U */ + HRPWM_FAULTFILTER_10 = HRPWM_FLTINR1_FLT0F_3 | HRPWM_FLTINR1_FLT0F_1, + /*!< fSAMPLING= fFLTS/16U, N=5U */ + HRPWM_FAULTFILTER_11 = HRPWM_FLTINR1_FLT0F_3 | HRPWM_FLTINR1_FLT0F_1 | HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fFLTS/16U, N=6U */ + HRPWM_FAULTFILTER_12 = HRPWM_FLTINR1_FLT0F_3 | HRPWM_FLTINR1_FLT0F_2, + /*!< fSAMPLING= fFLTS/16U, N=8U */ + HRPWM_FAULTFILTER_13 = HRPWM_FLTINR1_FLT0F_3 | HRPWM_FLTINR1_FLT0F_2 | HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fFLTS/32U, N=5U */ + HRPWM_FAULTFILTER_14 = HRPWM_FLTINR1_FLT0F_3 | HRPWM_FLTINR1_FLT0F_2 | HRPWM_FLTINR1_FLT0F_1, + /*!< fSAMPLING= fFLTS/32U, N=6U */ + HRPWM_FAULTFILTER_15 = HRPWM_FLTINR1_FLT0F_3 | HRPWM_FLTINR1_FLT0F_2 | HRPWM_FLTINR1_FLT0F_1 | HRPWM_FLTINR1_FLT0F_0, + /*!< fSAMPLING= fFLTS/32U, N=8U */ +} HRPWM_FaultFilterETypeDef; +/** + * @} + */ + +/** @defgroup HRPWM_Fault_Counter HRPWM Fault counter threshold value + * @brief Constants defining the FAULT Counter threshold (FLTCNT + 1) + * @{ + */ +typedef enum { + HRPWM_FAULTCOUNTER_NONE = 0x0, + /*!< Counter threshold = 0U */ + HRPWM_FAULTCOUNTER_1 = HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 1U */ + HRPWM_FAULTCOUNTER_2 = HRPWM_FLTINR3_FLT0CNT_1, + /*!< Counter threshold = 2U */ + HRPWM_FAULTCOUNTER_3 = HRPWM_FLTINR3_FLT0CNT_1 | HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 3U */ + HRPWM_FAULTCOUNTER_4 = HRPWM_FLTINR3_FLT0CNT_2, + /*!< Counter threshold = 4U */ + HRPWM_FAULTCOUNTER_5 = HRPWM_FLTINR3_FLT0CNT_2 | HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 5U */ + HRPWM_FAULTCOUNTER_6 = HRPWM_FLTINR3_FLT0CNT_2 | HRPWM_FLTINR3_FLT0CNT_1, + /*!< Counter threshold = 6U */ + HRPWM_FAULTCOUNTER_7 = HRPWM_FLTINR3_FLT0CNT_2 | HRPWM_FLTINR3_FLT0CNT_1 | HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 7U */ + HRPWM_FAULTCOUNTER_8 = HRPWM_FLTINR3_FLT0CNT_3, + /*!< Counter threshold = 8U */ + HRPWM_FAULTCOUNTER_9 = HRPWM_FLTINR3_FLT0CNT_3 | HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 9U */ + HRPWM_FAULTCOUNTER_10 = HRPWM_FLTINR3_FLT0CNT_3 | HRPWM_FLTINR3_FLT0CNT_1, + /*!< Counter threshold = 10U */ + HRPWM_FAULTCOUNTER_11 = HRPWM_FLTINR3_FLT0CNT_3 | HRPWM_FLTINR3_FLT0CNT_1 | HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 11U */ + HRPWM_FAULTCOUNTER_12 = HRPWM_FLTINR3_FLT0CNT_3 | HRPWM_FLTINR3_FLT0CNT_2, + /*!< Counter threshold = 12U */ + HRPWM_FAULTCOUNTER_13 = HRPWM_FLTINR3_FLT0CNT_3 | HRPWM_FLTINR3_FLT0CNT_2 | HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 13U */ + HRPWM_FAULTCOUNTER_14 = HRPWM_FLTINR3_FLT0CNT_3 | HRPWM_FLTINR3_FLT0CNT_2 | HRPWM_FLTINR3_FLT0CNT_1, + /*!< Counter threshold = 14U */ + HRPWM_FAULTCOUNTER_15 = HRPWM_FLTINR3_FLT0CNT_3 | HRPWM_FLTINR3_FLT0CNT_2 | HRPWM_FLTINR3_FLT0CNT_1 | HRPWM_FLTINR3_FLT0CNT_0, + /*!< Counter threshold = 15U */ +} HRPWM_FaultCounterETypeDef; +/** + * @} + */ + + +/** + * @brief HRPWM Master Timer Configuration Structure definition - Time base related parameters + */ +typedef struct __HRPWM_MasterSyncTypeDef { + uint32_t SyncOptions; /*!< Specifies how the HRPWM instance handles the external synchronization signals. + The HRPWM instance can be configured to act as a slave (waiting for a trigger + to be synchronized) or a master (generating a synchronization signal) or both. + This parameter can be a combination of @ref HRPWM_Synchronization_Options. */ + HRPWM_SyncInputSrcETypeDef SyncInputSource; /*!< Specifies the external synchronization input source (significant only when + the HRPWM instance is configured as a slave). */ + HRPWM_SyncOutputSrcETypeDef SyncOutputSource; /*!< Specifies the source and event to be sent on the external synchronization outputs + (significant only when the HRPWM instance is configured as a master). */ + HRPWM_SyncOutputEnETypeDef SyncOutputEnable; /*!< Specifies the source and event to be sent on the external synchronization outputs + (significant only when the HRPWM is configured as a master).*/ + HRPWM_SyncOutputPolETypeDef SyncOutputPolarity; /*!< Specifies the conditioning of the event to be sent on the external synchronization + outputs (significant only when the HRPWM instance is configured as a master). */ +} HRPWM_MasterSyncTypeDef; + +/** + * @brief Timer configuration definition -- Timerx (x=0...5) & Master timer + */ +typedef struct __HRPWM_TimerBaseCfgTypeDef { + uint32_t InterruptRequests; /*!< Relevant for all HRPWM timers, including the master. + Specifies which interrupts requests must enabled for the timer. + This parameter can be any combination of @ref HRPWM_Master_Interrupt_Enable + or @ref HRPWM_Timing_Unit_Interrupt_Enable */ + uint32_t Period; /*!< Specifies the timer period. + The period value must be above 3 periods of the fHRPWM clock. + Maximum value is = 0xFFFDU */ + uint32_t RepetitionCounter; /*!< Specifies the timer repetition period. + This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ + uint32_t ResetTrigger; /*!< Relevant for Timer0 to Timer5. no master timer. + Specifies source(s) triggering the timer counter reset. + This parameter can be a combination of @ref HRPWM_Timer_Reset_Trigger */ + HRPWM_PrescalerRatioETypeDef PrescalerRatio;/*!< Specifies the timer clock prescaler ratio. */ + HRPWM_ModeETypeDef Mode; /*!< Specifies the counter operating mode. continues or single */ + HRPWM_SyncStartETypeDef StartOnSync; /*!< Relevant for all HRPWM timers, including the master.Specifies whether or + not timer is reset by a rising edge on the synchronization input (when enabled). */ + HRPWM_SyncResetETypeDef ResetOnSync; /*!< Relevant for all HRPWM timers, including the master.Specifies whether or + not timer is reset by a rising edge on the synchronization input (when enabled). */ + HRPWM_RsyncUpdateETypeDef ReSyncUpdate; /*!< Relevant for Timer0 to Timer5.Specifies whether update source is coming + from the timing unit @ref HRPWM_Timer_Resync_Update_Enable */ + +} HRPWM_TimerBaseCfgTypeDef; + +/** + * @brief Simple output compare mode configuration definition -- Timerx (x=0...5) & Master timer + */ +typedef struct __HRPWM_TimerCompareCfgTypeDef { + HRPWM_PreloadEnETypeDef PreloadEnable; /*!< Relevant for all HRPWM timers, including the master. + Specifies whether or not register preload is enabled. */ + uint32_t UpdateTrigger; /*!< Relevant for Timer0 to Timer5. no Master timer update source ; + Specifies source(s) triggering the timer registers update. + This parameter can be a combination of @ref HRPWM_Timer_Update_Trigger */ + uint32_t CompareValueA; /*!< Specifies the compare A value of the timer compare unit. + The minimum value must be greater than or equal to 3 periods of the fHRPWM clock. + The maximum value must be less than or equal to 0xFFFFU - 1 periods of the fHRPWM clock */ + uint32_t CompareValueB; /*!< Specifies the compare B value of the timer compare unit. + The minimum value must be greater than or equal to 3 periods of the fHRPWM clock. + The maximum value must be less than or equal to 0xFFFFU - 1 periods of the fHRPWM clock */ + uint32_t CompareValueC; /*!< Specifies the compare C value of the timer compare unit. + The minimum value must be greater than or equal to 3 periods of the fHRPWM clock. + The maximum value must be less than or equal to 0xFFFFU - 1 periods of the fHRPWM clock */ + uint32_t CompareValueD; /*!< Specifies the compare D value of the timer compare unit. + The minimum value must be greater than or equal to 3 periods of the fHRPWM clock. + The maximum value must be less than or equal to 0xFFFFU - 1 periods of the fHRPWM clock */ +} HRPWM_TimerCompareCfgTypeDef; + +/** + * @brief Timer RollOver definition -- Timerx (x=0...5) + */ +typedef struct __HRPWM_TimerRollOverCfgTypeDef { + HRPWM_CounterModeETypeDef UpDownMode; /*!< Relevant for Timer0 to Timer5. + Specifies whether or not counter is operating in up or up-down counting mode. */ + HRPWM_RollOverETypeDef RollOverMode; /*!< Relevant for Timer0 to Timer5. + Roll over mode selection Settings are only valid in up-down counting mode. */ + HRPWM_OutputRollOverETypeDef OutputRollOverMode;/*!< Relevant for Timer0 to Timer5. + Output roll over mode selection Settings, valid only in up-down counting mode. */ + HRPWM_FltRollOverETypeDef FaultRollOverMode; /*!< Relevant for Timer0 to Timer5. + The fault roll over mode selection setting is only valid in up-down counting mode. */ + HRPWM_EventRollOverETypeDef EeventRollOverMode;/*!< Relevant for Timer0 to Timer5. + The event roll over mode selection setting is only valid in up-down counting mode. */ + HRPWM_AdcRollOverETypeDef AdcRollOverMode; /*!< Relevant for Timer0 to Timer5. + The ADDA trigger roll over mode selection setting is only valid in up-down counting mode. */ +} HRPWM_TimerRollOverCfgTypeDef; + +/** + * @brief Timer Daul Channel Dac definition -- Timerx (x=0...5) + */ +typedef struct __HRPWM_TimerDaulDacCfgTypeDef { + HRPWM_DacResetSelETypeDef DualChannelDacReset; /*!< Relevant for Timer0 to Timer5. + Specifies how the HRPWM_dac_reset_trgx trigger is generated. */ + HRPWM_DacStepSelETypeDef DualChannelDacStep; /*!< Relevant for Timer0 to Timer5. + Specifies how the HRPWM_dac_step_trgx trigger is generated. */ + HRPWM_DacTrigEnETypeDef DualChannelDacEnable; /*!< Relevant for Timer0 to Timer5. + Enables or not the dual channel DAC triggering mechanism. */ +} HRPWM_TimerDaulDacCfgTypeDef; + +/** + * @brief Output configuration definition -- Timerx (x=0...5) + */ +typedef struct __HRPWM_OutputCfgTypeDef { + HRPWM_OutputAPolETypeDef OutputAPolarity; /*!< Specifies the output polarity. */ + HRPWM_IdelALevelETypeDef IdleALevel; /*!< Specifies whether the output level is active or inactive when in IDLE state. */ + HRPWM_FaultALevelETypeDef FaultALevel; /*!< Specifies whether the output level is active or inactive when in FAULT state. */ + HRPWM_ChopperAEnETypeDef ChopperAModeEnable; /*!< Indicates whether or not the chopper mode is enabled*/ + HRPWM_OutputBPolETypeDef OutputBPolarity; /*!< Specifies the output polarity.*/ + HRPWM_IdelBLevelETypeDef IdleBLevel; /*!< Specifies whether the output level is active or inactive when in IDLE state. */ + HRPWM_FaultBLevelETypeDef FaultBLevel; /*!< Specifies whether the output level is active or inactive when in FAULT state. */ + HRPWM_ChopperBEnETypeDef ChopperBModeEnable; /*!< Indicates whether or not the chopper mode is enabled */ + uint32_t OutputASetSource; /*!< A channel output action set source event selection + This parameter can be combination value of @ref HRPWM_Timer_Set_Trigger */ + uint32_t OutputAClearSource; /*!< A channel output action clear source event selection + This parameter can be combination value of @ref HRPWM_Timer_Clear_Trigger */ + uint32_t OutputBSetSource; /*!< B channel output action set source event selection + This parameter can be combination value of @ref HRPWM_Timer_Set_Trigger */ + uint32_t OutputBClearSource; /*!< B channel output action clear source event selection + This parameter can be combination value of @ref HRPWM_Timer_Clear_Trigger */ +} HRPWM_OutputCfgTypeDef; + +/** + * @brief Dead time feature configuration definition -- Timerx (x=0...5) + */ +typedef struct __HRPWM_DeadTimeCfgTypeDef { + LL_FuncStatusETypeDef DeadTimeEn; /*!< Specifies the dead-time output enable */ + + uint32_t RisingValue; /*!< Specifies the dead-time following a rising edge. + This parameter can be a number between 0x0 and 0xFFFU */ + HRPWM_DeadTimeRiseSignETypeDef RisingSign; /*!< Specifies whether the dead-time is positive or negative on rising edge. */ + uint32_t FallingValue; /*!< Specifies the dead-time following a falling edge. + This parameter can be a number between 0x0 and 0xFFFU */ + HRPWM_DeadTimeFallSignETypeDef FallingSign; /*!< Specifies whether the dead-time is positive or negative on falling edge. */ +} HRPWM_DeadTimeCfgTypeDef; + +/** + * @brief Chopper mode configuration definition -- Timerx (x=0...5) + */ +typedef struct __HRPWM_ChopperModeCfgTypeDef { + HRPWM_ChopperAEnETypeDef ChopperAModeEnable; /*!< Indicates whether or not the chopper mode is enabled */ + HRPWM_ChopperBEnETypeDef ChopperBModeEnable; /*!< Indicates whether or not the chopper mode is enabled */ + HRPWM_ChopperCarfreqETypeDef CarrierFreq; /*!< Specifies the Timer carrier frequency value. */ + HRPWM_ChopperDutyETypeDef DutyCycle; /*!< Specifies the Timer chopper duty cycle value. */ + HRPWM_ChopperPulseWidthETypeDef StartPulse; /*!< Specifies the Timer pulse width value. */ +} HRPWM_ChopperModeCfgTypeDef; + +/** + * @brief External event filtering in timing units configuration definition -- Timerx (x=0...5) + */ +typedef struct __HRPWM_TimerEventFilteringCfgTypeDef { + HRPWM_EventAFilterWindowETypeDef Filter; /*!< Specifies the type of event filtering within the timing unit. */ + HRPWM_EventALatchETypeDef Latch; /*!< Specifies whether or not the signal is latched. */ +} HRPWM_TimerEventFilteringCfgTypeDef; + +/** + * @brief External Event Counter A configuration definition -- Timerx (x=0...5) + */ +typedef struct __HRPWM_ExternalEventACfgTypeDef { + HRPWM_EventACouterEnETypeDef CounterEnable; /*!< Specifies the External Event A Counter enable. */ + HRPWM_EventARstModeETypeDef ResetMode; /*!< Specifies the External Event A Counte Reset Mode. */ + HRPWM_EventASourceSelETypeDef Source; /*!< Specifies the External Event A Counter source selection. */ + uint32_t Counter; /*!< Specifies the External Event A Counter Threshold. + This parameter can be a number between 0x0 and 0x3F */ +} HRPWM_ExternalEventACfgTypeDef; + +/** + * @brief External event channel configuration definition -- common timer + */ +typedef struct __HRPWM_EventCfgTypeDef { + HRPWM_EventSrcSelETypeDef Source; /*!< Identifies the source of the external event. */ + HRPWM_EventPolETypeDef Polarity; /*!< Specifies the polarity of the external event (in case of level sensitivity). */ + HRPWM_EventSensETypeDef Sensitivity; /*!< Specifies the sensitivity of the external event. */ + HRPWM_EventPrescalerETypeDef SampClockDiv; /*!< External event sampling time frequency division ratio. */ + HRPWM_EventFilterETypeDef Filter; /*!< Defines the frequency used to sample the External Event and the length of the digital filter. */ + HRPWM_EventFastModeETypeDef FastMode; /*!< Indicates whether or not low latency mode is enabled for the external event. */ +} HRPWM_EventCfgTypeDef; + +/** + * @brief Fault channel configuration definition -- common timer + */ +typedef struct __HRPWM_FaultCfgTypeDef { + uint32_t InterruptEn; /*!< Relevant for comon timer. + Specifies which interrupts requests must enabled for comon timer. + This parameter can be any combination of @ref HRPWM_Common_Interrupt_Enable */ + HRPWM_FaultSrcSelETypeDef Source; /*!< Identifies the source of the fault. */ + HRPWM_FaultPolETypeDef Polarity; /*!< Specifies the polarity of the fault event. */ + HRPWM_FaultPrescalerETypeDef SampClockDiv; /*!< Fault signal sampling time frequency division ratio. */ + HRPWM_FaultFilterETypeDef Filter; /*!< Defines the frequency used to sample the Fault input and the length of the digital filter. */ + HRPWM_FaultEnETypeDef Enable; /*!< Corresponding fault sampling enablement. */ +} HRPWM_FaultCfgTypeDef; + +/** + * @brief Fault channel configuration blanking definition -- common timer + */ +typedef struct __HRPWM_FaultBlankingCfgTypeDef { + HRPWM_FaultCounterETypeDef Threshold; /*!< Specifies the Fault counter Threshold. */ + HRPWM_FaultBlkEnETypeDef BlankingEnable; /*!< Specifies the Fault blanking enablement. */ + HRPWM_FaultRstModeETypeDef ResetMode; /*!< Specifies the reset mode of a fault event counter. */ + HRPWM_FaultBlkWindowETypeDef BlankingSource;/*!< Specifies the blanking source of a fault event. */ +} HRPWM_FaultBlankingCfgTypeDef; + +/** + * @brief ADC trigger configuration definition -- common timer + */ +typedef struct __HRPWM_ADCTriggerCfgTypeDef { + uint32_t Trigger; /*!< Specifies the event(s) triggering the ADC conversion. + This parameter can be a combination of @ref HRPWM_ADC_Trigger_Event */ + HRPWM_AdcTrigGroupETypeDef TriggerGroup; /*!< Specifies the ADC trigger group 0~7. */ + HRPWM_AdcTrigUpdateSrcETypeDef UpdateSource;/*!< Specifies the ADC trigger update source. */ + HRPWM_AdcTrigLengthETypeDef TriggerLength; /*!< Specifies the event(s) triggering the ADC\DAC conversion.In practical use, + the length configuration should be greater than 3 clocks. For example, + under a 160M clock, the minimum configuration value is 0x3; */ + HRPWM_AdcTrigPSCETypeDef TriggerPostScaler; /*!< Specifies the event(s) triggering the ADC\DAC conversion. */ +} HRPWM_ADCTriggerCfgTypeDef; + +/** + * @brief HRPWM DLL start configuration definition -- common timer + */ +typedef struct __HRPWM_DLLCfgTypedef { + HRPWM_DllCurrentETypeDef CurrentSel;/*!< Configure DLL current selection. */ + uint32_t ClockDelayThres0; /*!< DLL Clock Delay Threshold. CLKPHASE = PULPHASE - DLLTHRES0. range : 0~0x1F */ + uint32_t ClockDelayThres1; /*!< DLL Clock Delay Threshold. CLKPHASE <= DLLTHRES1 : + Sample hrpwm_clk Pulse CLKPHASE > DLLTHRES1 : Sample hrpwm_dly_clk Pulse. range : 0~0x1F */ +} HRPWM_DLLCfgTypedef; +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup HRPWM_LL_Exported_Macros HRPWM LL Exported Macros + * @brief HRPWM LL Exported Macros + * @{ + */ + +/** + * @brief swap the output of the timer + * HRPWM_SETA1R and HRPWM_RSTAR are coding for the output B, + * HRPWM_SETA2R and HRPWM_RSTAR are coding for the output B + * @note Push pull mode setting is invalid + * @param __TIMER__ : Timer index + * This parameter can be a combination of the following values: + * @arg HRPWM_SWAP_SLAVE_0 + * @arg HRPWM_SWAP_SLAVE_1 + * @arg HRPWM_SWAP_SLAVE_2 + * @arg HRPWM_SWAP_SLAVE_3 + * @arg HRPWM_SWAP_SLAVE_4 + * @arg HRPWM_SWAP_SLAVE_5 + * @retval none + */ +#define __LL_HRPWM_OUTPUT_SWAP(__TIMER__) \ + MODIFY_REG(HRPWM->Common.CR1, HRPWM_CR1_SWP5 | HRPWM_CR1_SWP5 | HRPWM_CR1_SWP5 | HRPWM_CR1_SWP5 | HRPWM_CR1_SWP5, __TIMER__) + +/** + * @brief swap the output of the timer + * HRPWM_SETAR and HRPWM_RSTAR are coding for the output B, + * HRPWM_SETAR and HRPWM_RSTAR are coding for the output B + * @note Push pull mode setting is invalid + * @param __TIMER__ : Timer index + * This parameter Only one of the values can be selected, not a combination: + * @arg HRPWM_SWAP_SLAVE_0 + * @arg HRPWM_SWAP_SLAVE_1 + * @arg HRPWM_SWAP_SLAVE_2 + * @arg HRPWM_SWAP_SLAVE_3 + * @arg HRPWM_SWAP_SLAVE_4 + * @arg HRPWM_SWAP_SLAVE_5 + * @retval none + */ +#define __LL_HRPWM_TIMER_OUTPUT_SWAP(__TIMER__) SET_BIT(HRPWM->Common.CR1, __TIMER__) + +/** + * @brief Un-swap the output of the timer + * HRPWM_SETAR and HRPWM_RSTAR are coding for the output A, + * HRPWM_SETAR and HRPWM_RSTAR are coding for the output A + * @note Push pull mode setting is invalid + * @param __TIMER__ : Timer index + * This parameter Only one of the values can be selected, not a combination: + * @arg HRPWM_SWAP_SLAVE_0 + * @arg HRPWM_SWAP_SLAVE_1 + * @arg HRPWM_SWAP_SLAVE_2 + * @arg HRPWM_SWAP_SLAVE_3 + * @arg HRPWM_SWAP_SLAVE_4 + * @arg HRPWM_SWAP_SLAVE_5 + * @retval none + */ +#define __LL_HRPWM_TIMER_OUTPUT_NOSWAP(__TIMER__) CLEAR_BIT(HRPWM->Common.CR1, __TIMER__) + +/** @brief Enables or disables the specified HRPWM common interrupts. + * @param __INTERRUPT__ specifies the interrupt source to enable or disable. + * This parameter can be one of the following values: + * @arg HRPWM_IT_FLT0: Fault 0 interrupt enable + * @arg HRPWM_IT_FLT1: Fault 1 interrupt enable + * @arg HRPWM_IT_FLT2: Fault 2 interrupt enable + * @arg HRPWM_IT_FLT3: Fault 3 interrupt enable + * @arg HRPWM_IT_FLT4: Fault 4 interrupt enable + * @arg HRPWM_IT_FLT5: Fault 5 interrupt enable + * @arg HRPWM_IT_SYSFLT: System Fault interrupt enable + * @retval None + */ +#define __LL_HRPWM_ENABLE_IT(__INTERRUPT__) (HRPWM->Common.IER |= (__INTERRUPT__)) +#define __LL_HRPWM_DISABLE_IT(__INTERRUPT__) (HRPWM->Common.IER &= ~(__INTERRUPT__)) + +/** @brief Enables or disables the specified HRPWM Master timer interrupts. + * @param __INTERRUPT__ specifies the interrupt source to enable or disable. + * This parameter can be one of the following values: + * @arg HRPWM_MASTER_IT_MPER: Master Period interrupt enable + * @arg HRPWM_MASTER_IT_MCMPA: Master compare A interrupt enable + * @arg HRPWM_MASTER_IT_MCMPB: Master compare B interrupt enable + * @arg HRPWM_MASTER_IT_MCMPC: Master compare C interrupt enable + * @arg HRPWM_MASTER_IT_MCMPD: Master compare D interrupt enable + * @arg HRPWM_MASTER_IT_MREP: Master Repetition interrupt enable + * @arg HRPWM_MASTER_IT_SYNC: Synchronization input interrupt enable + * @arg HRPWM_MASTER_IT_MUPD: Master update interrupt enable + * @retval None + */ +#define __LL_HRPWM_MASTER_ENABLE_IT(__INTERRUPT__) (HRPWM->Master.MIER |= (__INTERRUPT__)) +#define __LL_HRPWM_MASTER_DISABLE_IT(__INTERRUPT__) (HRPWM->Master.MIER &= ~(__INTERRUPT__)) + +/** @brief Enables or disables the specified HRPWM Timerx interrupts. + * @param __TIMER__ specified the timing unit (Timer 0 to 5) + * @param __INTERRUPT__ specifies the interrupt source to enable or disable. + * This parameter can be one of the following values: + * @arg HRPWM_IT_PER: Timer Period interrupt enable + * @arg HRPWM_IT_CMPA: Timer compare 1 interrupt enable + * @arg HRPWM_IT_CMP2: Timer compare 2 interrupt enable + * @arg HRPWM_IT_CMP3: Timer compare 3 interrupt enable + * @arg HRPWM_IT_CMP4: Timer compare 4 interrupt enable + * @arg HRPWM_IT_SETA: Timer output 1 set interrupt enable + * @arg HRPWM_IT_RSTA: Timer output 1 reset interrupt enable + * @arg HRPWM_IT_SETB: Timer output 2 set interrupt enable + * @arg HRPWM_IT_RSTB: Timer output 2 reset interrupt enable + * @arg HRPWM_IT_RST: Timer reset interrupt enable + * @arg HRPWM_IT_REP: Timer repetition interrupt enable + * @arg HRPWM_IT_UPD: Timer update interrupt enable + * @arg HRPWM_IT_DLYPRT: Timer delay protection interrupt enable + * @retval None + */ +#define __LL_HRPWM_TIMER_ENABLE_IT(__TIMER__, __INTERRUPT__) (HRPWM->PWM[(__TIMER__)].IER |= (__INTERRUPT__)) +#define __LL_HRPWM_TIMER_DISABLE_IT(__TIMER__, __INTERRUPT__) (HRPWM->PWM[(__TIMER__)].IER &= ~(__INTERRUPT__)) + +/** @brief Checks if the specified HRPWM common interrupt source is enabled or disabled. + * @param __INTERRUPT__ specifies the interrupt source to check. + * @param __INTERRUPT__ specifies the interrupt source to enable or disable. + * This parameter can be one of the following values: + * @arg HRPWM_IT_FLT0: Fault 0 interrupt enable + * @arg HRPWM_IT_FLT1: Fault 1 interrupt enable + * @arg HRPWM_IT_FLT2: Fault 2 interrupt enable + * @arg HRPWM_IT_FLT3: Fault 3 interrupt enable + * @arg HRPWM_IT_FLT4: Fault 4 interrupt enable + * @arg HRPWM_IT_FLT5: Fault 5 interrupt enable + * @arg HRPWM_IT_SYSFLT: System Fault interrupt enable + * @retval The new state of __INTERRUPT__ (TRUE or FALSE). + */ +#define __LL_HRPWM_GET_IT(__INTERRUPT__) (((HRPWM->Common.IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** @brief Checks if the specified HRPWM Master interrupt source is enabled or disabled. + * @param __INTERRUPT__ specifies the interrupt source to check. + * This parameter can be one of the following values: + * @arg HRPWM_MASTER_IT_MPER: Master Period interrupt enable + * @arg HRPWM_MASTER_IT_MCMPA: Master compare A interrupt enable + * @arg HRPWM_MASTER_IT_MCMPB: Master compare B interrupt enable + * @arg HRPWM_MASTER_IT_MCMPC: Master compare C interrupt enable + * @arg HRPWM_MASTER_IT_MCMPD: Master compare D interrupt enable + * @arg HRPWM_MASTER_IT_MREP: Master Repetition interrupt enable + * @arg HRPWM_MASTER_IT_SYNC: Synchronization input interrupt enable + * @arg HRPWM_MASTER_IT_MUPD: Master update interrupt enable + * @retval The new state of __INTERRUPT__ (TRUE or FALSE). + */ +#define __LL_HRPWM_MASTER_GET_IT(__INTERRUPT__) (((HRPWM->Master.MIER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** @brief Checks if the specified HRPWM Timerx interrupt source is enabled or disabled. + * @param __TIMER__ specified the timing unit (Timer 0 to 5) + * @param __INTERRUPT__ specifies the interrupt source to enable or disable. + * This parameter can be one of the following values: + * @arg HRPWM_IT_PER: Timer Period interrupt enable + * @arg HRPWM_IT_CMPA: Timer compare A interrupt enable + * @arg HRPWM_IT_CMPB: Timer compare B interrupt enable + * @arg HRPWM_IT_CMPC: Timer compare C interrupt enable + * @arg HRPWM_IT_CMPD: Timer compare D interrupt enable + * @arg HRPWM_IT_SETA: Timer output A set interrupt enable + * @arg HRPWM_IT_RSTA: Timer output A reset interrupt enable + * @arg HRPWM_IT_SETB: Timer output B set interrupt enable + * @arg HRPWM_IT_RSTB: Timer output B reset interrupt enable + * @arg HRPWM_IT_RST: Timer reset interrupt enable + * @arg HRPWM_IT_REP: Timer repetition interrupt enable + * @arg HRPWM_IT_UPD: Timer update interrupt enable + * @arg HRPWM_IT_DLYPRT: Timer delay protection interrupt enable + * @retval The new state of __INTERRUPT__ (TRUE or FALSE). + */ +#define __LL_HRPWM_TIMER_GET_IT(__TIMER__, __INTERRUPT__) \ + (((HRPWM->PWM[(__TIMER__)].IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** @brief Get the specified HRPWM common pending flag. + * @param __INTERRUPT__ specifies the interrupt pending bit to clear. + * This parameter can be one of the following values: + * @arg HRPWM_FLAG_FLT0: Fault 0 flag + * @arg HRPWM_FLAG_FLT1: Fault 1 flag + * @arg HRPWM_FLAG_FLT2: Fault 2 flag + * @arg HRPWM_FLAG_FLT3: Fault 3 flag + * @arg HRPWM_FLAG_FLT4: Fault 4 flag + * @arg HRPWM_FLAG_FLT5: Fault 5 flag + * @arg HRPWM_FLAG_SYSFLT: System Fault interrupt flag + * @retval The new state of __INTERRUPT__ (TRUE or FALSE). + */ +#define __LL_HRPWM_GET_ITFLAG(__INTERRUPT__) (((HRPWM->Common.ISR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** @brief Get the specified HRPWM Master pending flag. + * @param __INTERRUPT__ specifies the interrupt pending bit. + * This parameter can be one of the following values: + * @arg HRPWM_MASTER_FLAG_MPER: Master Period interrupt flag + * @arg HRPWM_MASTER_FLAG_MCMPA: Master compare A interrupt flag + * @arg HRPWM_MASTER_FLAG_MCMPB: Master compare B interrupt flag + * @arg HRPWM_MASTER_FLAG_MCMPC: Master compare C interrupt flag + * @arg HRPWM_MASTER_FLAG_MCMPD: Master compare D interrupt flag + * @arg HRPWM_MASTER_FLAG_MREP: Master Repetition interrupt flag + * @arg HRPWM_MASTER_FLAG_SYNC: Synchronization input interrupt flag + * @arg HRPWM_MASTER_FLAG_MUPD: Master update interrupt flag + * @retval The new state of __INTERRUPT__ (TRUE or FALSE). + */ +#define __LL_HRPWM_MASTER_GET_ITFLAG(__INTERRUPT__) \ + (((HRPWM->Master.MISR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** @brief Get the specified HRPWM Timerx pending flag. + * @param __TIMER__ specified the timing unit (Timer 0 to 5) + * @param __INTERRUPT__ specifies the interrupt pending bit. + * This parameter can be one of the following values: + * @arg HRPWM_FLAG_PER: Timer Period interrupt flag + * @arg HRPWM_FLAG_CMPA: Timer compare A interrupt flag + * @arg HRPWM_FLAG_CMPB: Timer compare B interrupt flag + * @arg HRPWM_FLAG_CMPC: Timer compare C interrupt flag + * @arg HRPWM_FLAG_CMPD: Timer compare D interrupt flag + * @arg HRPWM_FLAG_SETA: Timer output A set interrupt flag + * @arg HRPWM_FLAG_RSTA: Timer output A reset interrupt flag + * @arg HRPWM_FLAG_SETB: Timer output B set interrupt flag + * @arg HRPWM_FLAG_RSTB: Timer output B reset interrupt flag + * @arg HRPWM_FLAG_RST: Timer reset interrupt flag + * @arg HRPWM_FLAG_REP: Timer repetition interrupt flag + * @arg HRPWM_FLAG_UPD: Timer update interrupt flag + * @retval The new state of __INTERRUPT__ (TRUE or FALSE). + */ +#define __LL_HRPWM_TIMER_GET_ITFLAG(__TIMER__, __INTERRUPT__) \ + (((HRPWM->PWM[(__TIMER__)].ISR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + + +/** @brief Clears the specified HRPWM common pending flag. + * @param __INTERRUPT__ specifies the interrupt pending bit to clear. + * This parameter can be one of the following values: + * @arg HRPWM_FLAG_FLT0: Fault 0 clear flag + * @arg HRPWM_FLAG_FLT1: Fault 1 clear flag + * @arg HRPWM_FLAG_FLT2: Fault 2 clear flag + * @arg HRPWM_FLAG_FLT3: Fault 3 clear flag + * @arg HRPWM_FLAG_FLT4: Fault 4 clear flag + * @arg HRPWM_FLAG_FLT5: Fault 5 clear flag + * @arg HRPWM_FLAG_SYSFLT: System Fault interrupt clear flag + * @retval None + */ +#define __LL_HRPWM_CLEAR_ITFLAG(__INTERRUPT__) (HRPWM->Common.ISR = (__INTERRUPT__)) + +/** @brief Clears the specified HRPWM Master pending flag. + * @param __INTERRUPT__ specifies the interrupt pending bit to clear. + * This parameter can be one of the following values: + * @arg HRPWM_MASTER_FLAG_MPER: Master Period interrupt clear flag + * @arg HRPWM_MASTER_FLAG_MCMPA: Master compare A interrupt clear flag + * @arg HRPWM_MASTER_FLAG_MCMPB: Master compare B interrupt clear flag + * @arg HRPWM_MASTER_FLAG_MCMPC: Master compare C interrupt clear flag + * @arg HRPWM_MASTER_FLAG_MCMPD: Master compare D interrupt clear flag + * @arg HRPWM_MASTER_FLAG_MREP: Master Repetition interrupt clear flag + * @arg HRPWM_MASTER_FLAG_SYNC: Synchronization input interrupt clear flag + * @arg HRPWM_MASTER_FLAG_MUPD: Master update interrupt clear flag + * @retval None + */ +#define __LL_HRPWM_MASTER_CLEAR_ITFLAG(__INTERRUPT__) (HRPWM->Master.MISR = (__INTERRUPT__)) + +/** @brief Clears the specified HRPWM Timerx pending flag. + * @param __TIMER__ specified the timing unit (Timer A to F) + * @param __INTERRUPT__ specifies the interrupt pending bit to clear. + * This parameter can be one of the following values: + * @arg HRPWM_FLAG_PER: Timer Period interrupt clear flag + * @arg HRPWM_FLAG_CMPA: Timer compare A interrupt clear flag + * @arg HRPWM_FLAG_CMPB: Timer compare B interrupt clear flag + * @arg HRPWM_FLAG_CMPC: Timer compare C interrupt clear flag + * @arg HRPWM_FLAG_CMPD: Timer compare D interrupt clear flag + * @arg HRPWM_FLAG_SETA: Timer output A set interrupt clear flag + * @arg HRPWM_FLAG_RSTA: Timer output A reset interrupt clear flag + * @arg HRPWM_FLAG_SETB: Timer output B set interrupt clear flag + * @arg HRPWM_FLAG_RSTB: Timer output B reset interrupt clear flag + * @arg HRPWM_FLAG_RST: Timer reset interrupt clear flag + * @arg HRPWM_FLAG_REP: Timer repetition interrupt clear flag + * @arg HRPWM_FLAG_UPD: Timer update interrupt clear flag + * @retval None + */ +#define __LL_HRPWM_TIMER_CLEAR_ITFLAG(__TIMER__, __INTERRUPT__) (HRPWM->PWM[(__TIMER__)].ISR = (__INTERRUPT__)) + +/** @brief Sets the HRPWM timer Period value on runtime + * @param __TIMER__ HRPWM timer + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __PERIOD__ specifies the Period Register new value. + * @retval None + */ +#define __LL_HRPWM_SETPERIOD(__TIMER__, __PERIOD__) \ + (((__TIMER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MPER = (__PERIOD__)) :\ + (HRPWM->PWM[(__TIMER__)].PERR = (__PERIOD__))) + +/** @brief Gets the HRPWM timer Period Register value on runtime + * @param __TIMER__ HRPWM timer + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @retval timer Period Register + */ +#define __LL_HRPWM_GETPERIOD(__TIMER__) \ + (((__TIMER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MPER) : (HRPWM->PWM[(__TIMER__)].PERR)) + + +/** @brief Sets the HRPWM timer clock prescaler value on runtime + * @param __TIMER__ HRPWM timer + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __PRESCALER__ specifies the clock prescaler new value. + * This parameter can be one of the following values: + * @arg HRPWM_PRESCALERRATIO_MUL32: fHRCK: fHRPWM x 32U = 5.12 GHz - Resolution: 195 ps (fHRPWM=144MHz) + * @arg HRPWM_PRESCALERRATIO_MUL16: fHRCK: fHRPWM x 16U = 2.56 GHz - Resolution: 390 ps (fHRPWM=144MHz) + * @arg HRPWM_PRESCALERRATIO_MUL8: fHRCK: fHRPWM x 8U = 1.28 GHz - Resolution: 781 ps (fHRPWM=144MHz) + * @arg HRPWM_PRESCALERRATIO_MUL4: fHRCK: fHRPWM x 4U = 640 MHz - Resolution: 1.56 ns (fHRPWM=144MHz) + * @arg HRPWM_PRESCALERRATIO_MUL2: fHRCK: fHRPWM x 2U = 320 MHz - Resolution: 3.125 ns (fHRPWM=144MHz) + * @arg HRPWM_PRESCALERRATIO_DIV1: fHRCK: fHRPWM = 160 MHz - Resolution: 6.25 ns (fHRPWM=144MHz) + * @arg HRPWM_PRESCALERRATIO_DIV2: fHRCK: fHRPWM / 2U = 80 MHz - Resolution: 12.5 ns (fHRPWM=144MHz) + * @arg HRPWM_PRESCALERRATIO_DIV4: fHRCK: fHRPWM / 4U = 40 MHz - Resolution: 25 ns (fHRPWM=144MHz) + * @retval None + */ +#define __LL_HRPWM_SETCLOCKPRESCALER(__TIMER__, __PRESCALER__) \ + (((__TIMER__) == HRPWM_INDEX_MASTER) ? (MODIFY_REG(HRPWM->Master.MCR, HRPWM_MCR_CKPSC, (__PRESCALER__))) :\ + (MODIFY_REG(HRPWM->PWM[(__TIMER__)].CR0, HRPWM_CR0_CKPSC, (__PRESCALER__)))) + +/** @brief Gets the HRPWM timer clock prescaler value on runtime + * @param __TIMER__ HRPWM timer + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @retval timer clock prescaler value + */ +#define __LL_HRPWM_GETCLOCKPRESCALER(__TIMER__) \ + (((__TIMER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCR & HRPWM_MCR_CKPSC) : \ + (HRPWM->PWM[(__TIMER__)].CR0 & HRPWM_CR0_CKPSC)) + +/** @brief Sets the HRPWM timer Compare Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __COMPAREUNIT__ timer compare unit + * This parameter can be one of the following values: + * @arg HRPWM_COMPAREUNIT_A: Compare A + * @arg HRPWM_COMPAREUNIT_B: Compare B + * @arg HRPWM_COMPAREUNIT_C: Compare C + * @arg HRPWM_COMPAREUNIT_D: Compare D + * @param __COMPARE__ specifies the Compare new value. + * @retval None + */ +#define __LL_HRPWM_SETCOMPARE(__TIMER__, __COMPAREUNIT__, __COMPARE__) \ + (((__TIMER__) == HRPWM_INDEX_MASTER) ? \ + (((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_A) ? (HRPWM->Master.MCMPAR = (__COMPARE__)) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_B) ? (HRPWM->Master.MCMPBR = (__COMPARE__)) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_C) ? (HRPWM->Master.MCMPCR = (__COMPARE__)) : \ + (HRPWM->Master.MCMPDR = (__COMPARE__))) \ + : \ + (((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_A) ? (HRPWM->PWM[(__TIMER__)].CMPAR = (__COMPARE__)) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_B) ? (HRPWM->PWM[(__TIMER__)].CMPBR = (__COMPARE__)) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_C) ? (HRPWM->PWM[(__TIMER__)].CMPCR = (__COMPARE__)) : \ + (HRPWM->PWM[(__TIMER__)].CMPDR = (__COMPARE__)))) + +/** @brief Gets the HRPWM timer Compare Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __COMPAREUNIT__ timer compare unit + * This parameter can be one of the following values: + * @arg HRPWM_COMPAREUNIT_A: Compare A + * @arg HRPWM_COMPAREUNIT_B: Compare B + * @arg HRPWM_COMPAREUNIT_C: Compare C + * @arg HRPWM_COMPAREUNIT_D: Compare D + * @retval Compare value + */ +#define __LL_HRPWM_GETCOMPARE(__TIMER__, __COMPAREUNIT__) \ + (((__TIMER__) == HRPWM_INDEX_MASTER) ? \ + (((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_A) ? (HRPWM->Master.MCMPAR) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_B) ? (HRPWM->Master.MCMPBR) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_C) ? (HRPWM->Master.MCMPCR) : \ + (HRPWM->Master.MCMPDR)) \ + : \ + (((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_A) ? (HRPWM->PWM[(__TIMER__)].CMPAR) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_B) ? (HRPWM->PWM[(__TIMER__)].CMPBR) : \ + ((__COMPAREUNIT__) == HRPWM_COMPAREUNIT_C) ? (HRPWM->PWM[(__TIMER__)].CMPCR) : \ + (HRPWM->PWM[(__TIMER__)].CMPDR))) + +/** @brief Sets the HRPWM timer Compare A Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __VALUE__ specifies the Compare new value. + * @retval None + */ +#define __LL_HRPWM_SETCOMPARE_A(__TINER__, __VALUE__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPAR = (__VALUE__)) : \ + (HRPWM->PWM[(__TINER__)].CMPAR = (__VALUE__))) + +/** @brief Sets the HRPWM timer Compare B Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __VALUE__ specifies the Compare new value. + * @retval None + */ +#define __LL_HRPWM_SETCOMPARE_B(__TINER__, __VALUE__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPBR = (__VALUE__)) : \ + (HRPWM->PWM[(__TINER__)].CMPBR = (__VALUE__))) + +/** @brief Sets the HRPWM timer Compare C Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __VALUE__ specifies the Compare new value. + * @retval None + */ +#define __LL_HRPWM_SETCOMPARE_C(__TINER__, __VALUE__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPCR = (__VALUE__)) : \ + (HRPWM->PWM[(__TINER__)].CMPCR = (__VALUE__))) + +/** @brief Sets the HRPWM timer Compare A Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @param __VALUE__ specifies the Compare new value. + * @retval None + */ +#define __LL_HRPWM_SETCOMPARE_D(__TINER__, __VALUE__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPDR = (__VALUE__)) : \ + (HRPWM->PWM[(__TINER__)].CMPDR = (__VALUE__))) + + +/** @brief Gets the HRPWM timer Compare A Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @retval Compare value + */ + +#define __LL_HRPWM_GETCOMPARE_A(__TINER__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPAR) :(HRPWM->PWM[(__TINER__)].CMPAR)) + +/** @brief Gets the HRPWM timer Compare B Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @retval Compare value + */ + +#define __LL_HRPWM_GETCOMPARE_B(__TINER__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPBR) : (HRPWM->PWM[(__TINER__)].CMPBR)) + +/** @brief Gets the HRPWM timer Compare C Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @retval Compare value + */ + +#define __LL_HRPWM_GETCOMPARE_C(__TINER__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPCR) : (HRPWM->PWM[(__TINER__)].CMPCR)) + +/** @brief Gets the HRPWM timer Compare D Register value on runtime + * @param __TIMER__ HRPWM timer (not is commmon timer) + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @retval Compare value + */ + +#define __LL_HRPWM_GETCOMPARE_D(__TINER__) \ + (((__TINER__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCMPDR) : (HRPWM->PWM[(__TINER__)].CMPDR)) + + +/** @brief Enables or disables the timer counter(s) + * @param __TIMERS__ timers to enable/disable + * This parameter can be any combinations of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Slave pwm 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Slave pwm 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Slave pwm 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Slave pwm 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Slave pwm 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Slave pwm 5 identifier + * @retval None + */ +#define __LL_HRPWM_TIMER_ENABLE(__TIMERS__) \ + (((__TIMERS__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCR |= HRPWM_MCR_MCEN) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_0) ? (HRPWM->Master.MCR |= HRPWM_MCR_CEN0) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_1) ? (HRPWM->Master.MCR |= HRPWM_MCR_CEN1) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_2) ? (HRPWM->Master.MCR |= HRPWM_MCR_CEN2) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_3) ? (HRPWM->Master.MCR |= HRPWM_MCR_CEN3) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_4) ? (HRPWM->Master.MCR |= HRPWM_MCR_CEN4) : \ + ((HRPWM->Master.MCR |= HRPWM_MCR_CEN5))) + + +#define __LL_HRPWM_TIMER_DISABLE(__TIMERS__) \ + (((__TIMERS__) == HRPWM_INDEX_MASTER) ? (HRPWM->Master.MCR &= ~(HRPWM_MCR_MCEN)) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_0) ? (HRPWM->Master.MCR &= ~(HRPWM_MCR_CEN0)) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_1) ? (HRPWM->Master.MCR &= ~(HRPWM_MCR_CEN1)) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_2) ? (HRPWM->Master.MCR &= ~(HRPWM_MCR_CEN2)) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_3) ? (HRPWM->Master.MCR &= ~(HRPWM_MCR_CEN3)) : \ + ((__TIMERS__) == HRPWM_INDEX_SLAVE_4) ? (HRPWM->Master.MCR &= ~(HRPWM_MCR_CEN4)) : \ + ((HRPWM->Master.MCR &= ~(HRPWM_MCR_CEN5)))) + +/** @brief Enables ALL the timer counter(s) + * @param __INSTANCE__ HRPWM HANDLE + * @retval None + */ +#define __LL_HRPWM_ALL_TIMER_ENABLE(__INSTANCE__) \ + (SET_BIT((__INSTANCE__)->Master.MCR, \ + HRPWM_MCR_MCEN | HRPWM_MCR_CEN0 | HRPWM_MCR_CEN1 | HRPWM_MCR_CEN2 | HRPWM_MCR_CEN3 | HRPWM_MCR_CEN4 | HRPWM_MCR_CEN5)) + +/** @brief Disables the timer counter(s) + * @param __INSTANCE__ HRPWM HANDLE + * @retval None + */ +#define __LL_HRPWM_ALL_TIMER_DISABLE(__INSTANCE__) \ + (CLEAR_BIT((__INSTANCE__)->Master.MCR, \ + HRPWM_MCR_MCEN | HRPWM_MCR_CEN0 | HRPWM_MCR_CEN1 | HRPWM_MCR_CEN2 | HRPWM_MCR_CEN3 | HRPWM_MCR_CEN4 | HRPWM_MCR_CEN5)) + + +/** @brief Modify the length of the dead zone + * @param __TIMERS__ timers to enable/disable + * This parameter can be any combinations of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Timer 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Timer 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Timer 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Timer 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Timer 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Timer 5 identifier + * @param __VALUES__ timer dead timer value the range of value is 0 ~ 0xfff + * @retval None + */ +#define __LL_HRPWM_DEADTIME_RISE_VALUE(__TIMERS__, __VALUES__) \ + MODIFY_REG(HRPWM->PWM[__TIMERS__].DTR, HRPWM_DTR_DTR, (__VALUES__)) + +#define __LL_HRPWM_DEADTIME_FALL_VALUE(__TIMERS__, __VALUES__) \ + MODIFY_REG(HRPWM->PWM[__TIMERS__].DTR, HRPWM_DTR_DTF, ((__VALUES__) << 16U)) + +/** @brief Modify the length of the dead zone + * @param __TIMERS__ timers to enable/disable + * This parameter can be any combinations of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Timer 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Timer 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Timer 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Timer 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Timer 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Timer 5 identifier + * @param __SIGN__ timer dead timer sign + * HRPWM_Deadtime_Rising_Sign: HRPWM_DEADTIME_RSIGN_NEGATIVE \ HRPWM_DEADTIME_RSIGN_POSITIVE + * HRPWM_Deadtime_Falling_Sign: HRPWM_DEADTIME_FSIGN_NEGATIVE \ HRPWM_DEADTIME_FSIGN_POSITIVE + * @retval None + */ +#define __LL_HRPWM_DEADTIME_RISE_SIGN(__TIMERS__, __SIGN__) MODIFY_REG(HRPWM->PWM[__TIMERS__].DTR, HRPWM_DTR_SDTR, (__SIGN__)) + +#define __LL_HRPWM_DEADTIME_FALL_SIGN(__TIMERS__, __SIGN__) MODIFY_REG(HRPWM->PWM[__TIMERS__].DTR, HRPWM_DTR_SDTF, (__SIGN__)) + + +/** @brief Start output wave + * @param __OUTPUT__ timers start output wave @ HRPWM_Timer_Output_Start + * This parameter can be any combinations of the following values: + * @arg HRPWM_OUTPUT_OEN0A + * @arg HRPWM_OUTPUT_OEN0B + * @arg HRPWM_OUTPUT_OEN1A + * @arg HRPWM_OUTPUT_OEN1B + * @arg HRPWM_OUTPUT_OEN2A + * @arg HRPWM_OUTPUT_OEN2B + * @arg HRPWM_OUTPUT_OEN3A + * @arg HRPWM_OUTPUT_OEN3B + * @arg HRPWM_OUTPUT_OEN4A + * @arg HRPWM_OUTPUT_OEN4B + * @arg HRPWM_OUTPUT_OEN5A + * @arg HRPWM_OUTPUT_OEN5B + * @retval None + */ +#define __LL_HRPWM_OUTPUT_START(__OUTPUT__) SET_BIT(HRPWM->Common.OENR, (__OUTPUT__)) + +/** @brief Stop output wave + * @param __OUTPUT__ timers start output wave @ HRPWM_Timer_Output_Stop + * This parameter can be any combinations of the following values: + * @arg HRPWM_OUTPUT_ODIS0A + * @arg HRPWM_OUTPUT_ODIS0B + * @arg HRPWM_OUTPUT_ODIS1A + * @arg HRPWM_OUTPUT_ODIS1B + * @arg HRPWM_OUTPUT_ODIS2A + * @arg HRPWM_OUTPUT_ODIS2B + * @arg HRPWM_OUTPUT_ODIS3A + * @arg HRPWM_OUTPUT_ODIS3B + * @arg HRPWM_OUTPUT_ODIS4A + * @arg HRPWM_OUTPUT_ODIS4B + * @arg HRPWM_OUTPUT_ODIS5A + * @arg HRPWM_OUTPUT_ODIS5B + * @retval None + */ +#define __LL_HRPWM_OUTPUT_STOP(__OUTPUT__) SET_BIT(HRPWM->Common.ODISR, (__OUTPUT__)) + +/** @brief Multiple mode combination configuration + * @param __TIMERS__ timers to enable/disable + * This parameter can be any combinations of the following values: + * @arg HRPWM_INDEX_MASTER: Master timer identifier + * @arg HRPWM_INDEX_SLAVE_0: Timer 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Timer 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Timer 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Timer 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Timer 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Timer 5 identifier + + * @param __MODE__ set output mode(half \ interleaved \ pushpull) + * This parameter can be any combinations of the following values: + * @arg HRPWM_HALFMODE_DISABLE + * @arg HRPWM_HALFMODE_ENABLE + * @arg HRPWM_INTERLEAVED_MODE_DISABLE + * @arg HRPWM_INTERLEAVED_MODE_TRIPLE + * @arg HRPWM_INTERLEAVED_MODE_QUAD + * @arg HRPWM_PUSHPULLMODE_DISABLE + * @arg HRPWM_PUSHPULLMODE_ENABLE + * @retval None + */ +#define __LL_HRPWM_OUTPUTMODE_SET(__TIMERS__, __MODE__) \ + (((__TIMERS__) == HRPWM_INDEX_MASTER) ? \ + (MODIFY_REG(HRPWM->Master.MCR , HRPWM_MCR_HALF | HRPWM_MCR_INTLVD, __MODE__)) : \ + (MODIFY_REG(HRPWM->PWM[__TIMERS__].CR0 , HRPWM_CR0_HALF | HRPWM_CR0_INTLVD | HRPWM_CR0_PSHPLL, __MODE__))) + +/** @brief Select which faults are effectively configured in each slave timer + * @param __TIMERS__ timers to enable/disable + * This parameter can be any combinations of the following values: + * @arg HRPWM_INDEX_SLAVE_0: Timer 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Timer 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Timer 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Timer 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Timer 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Timer 5 identifier + * @param __FAULT__ timers start output wave @ HRPWM_Timer_Fault_Enabling + * This parameter can be any combinations of the following values: + * @arg HRPWM_FAULTEN_NONE + * @arg HRPWM_FAULTEN_FAULT0 + * @arg HRPWM_FAULTEN_FAULT1 + * @arg HRPWM_FAULTEN_FAULT2 + * @arg HRPWM_FAULTEN_FAULT3 + * @arg HRPWM_FAULTEN_FAULT4 + * @arg HRPWM_FAULTEN_FAULT5 + * @retval None + */ +#define __LL_HRPWM_SLAVE_FAULT_VALID_SEL(__TIMERS__, __FAULT__) MODIFY_REG(HRPWM->PWM[__TIMERS__].FLTR, 0x3F, __FAULT__) + +/** @brief The software forces the corresponding output high or low + * @param __TIMERS__ timers to + * After configuring this bit, you must reconfigure the output event in order to reoutput + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0: Timer 0 identifier + * @arg HRPWM_INDEX_SLAVE_1: Timer 1 identifier + * @arg HRPWM_INDEX_SLAVE_2: Timer 2 identifier + * @arg HRPWM_INDEX_SLAVE_3: Timer 3 identifier + * @arg HRPWM_INDEX_SLAVE_4: Timer 4 identifier + * @arg HRPWM_INDEX_SLAVE_5: Timer 5 identifier + * @retval None + */ + +#define __LL_HRPWM_OUTPUT_A_SET(__TIMERS__) \ + do { \ + CLEAR_REG(HRPWM->PWM[__TIMERS__].CLRAR); \ + WRITE_REG(HRPWM->PWM[__TIMERS__].SETAR, HRPWM_SETAR_SST); \ + } while(0) + +#define __LL_HRPWM_OUTPUT_A_CLEAR(__TIMERS__) \ + do { \ + CLEAR_REG(HRPWM->PWM[__TIMERS__].SETAR); \ + WRITE_REG(HRPWM->PWM[__TIMERS__].CLRAR, HRPWM_CLRAR_SST); \ + } while(0) + +#define __LL_HRPWM_OUTPUT_B_SET(__TIMERS__) \ + do { \ + CLEAR_REG(HRPWM->PWM[__TIMERS__].CLRBR); \ + WRITE_REG(HRPWM->PWM[__TIMERS__].SETBR, HRPWM_SETBR_SST); \ + } while(0) + +#define __LL_HRPWM_OUTPUT_B_CLEAR(__TIMERS__) \ + do { \ + CLEAR_REG(HRPWM->PWM[__TIMERS__].SETBR); \ + WRITE_REG(HRPWM->PWM[__TIMERS__].CLRBR, HRPWM_CLRBR_SST); \ + } while(0) +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup HRPWM_LL_Exported_Functions +* @{ +*/ + +/** @addtogroup HRPWM_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_HRPWM_Init(HRPWM_TypeDef *Instance, HRPWM_MasterSyncTypeDef *pMasterSync); +LL_StatusETypeDef LL_HRPWM_DeInit(HRPWM_TypeDef *Instance); +void LL_HRPWM_MspInit(HRPWM_TypeDef *Instance); +void LL_HRPWM_MspDeInit(HRPWM_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup HRPWM_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_HRPWM_DLLStartConfig(HRPWM_TypeDef *Instance, HRPWM_DLLCfgTypedef *DLLConfig); +LL_StatusETypeDef LL_HRPWM_DLLStart(HRPWM_TypeDef *Instance); +LL_StatusETypeDef LL_HRPWM_TimerBaseConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_TimerBaseCfgTypeDef *pTimeBaseCfg); +LL_StatusETypeDef LL_HRPWM_TimerCompareConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerCompareCfgTypeDef *pTimerCompCfg); +/** + * @} + */ + + +/** @addtogroup HRPWM_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_HRPWM_StopCounter(uint32_t TimerIdx); +LL_StatusETypeDef LL_HRPWM_StartCounter(uint32_t TimerIdx); +/** + * @} + */ + + +/** @addtogroup HRPWM_LL_Exported_Functions_Group4 + * @{ + */ +LL_StatusETypeDef LL_HRPWM_TimerUintRollOverContrl(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerRollOverCfgTypeDef *pTimerRollOverCfg); +LL_StatusETypeDef LL_HRPWM_TimerDualChannelDacConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerDaulDacCfgTypeDef *pTimerDacCfg); +LL_StatusETypeDef LL_HRPWM_TimerRollOverMode(HRPWM_TypeDef *Instance, uint32_t TimerIdx, uint32_t pRollOverMode); +/** + * @} + */ + + +/** @addtogroup HRPWM_LL_Exported_Functions_Group5 + * @{ + */ +LL_StatusETypeDef LL_HRPWM_FaultConfig(HRPWM_TypeDef *Instance, uint32_t Fault, HRPWM_FaultCfgTypeDef *pFaultCfg, + HRPWM_FaultBlankingCfgTypeDef *pFaultBlkCfg); +LL_StatusETypeDef LL_HRPWM_FaultBlankingConfig(HRPWM_TypeDef *Instance, uint32_t Fault, + HRPWM_FaultBlankingCfgTypeDef *pFaultBlkCfg); +LL_StatusETypeDef LL_HRPWM_FaultCounterConfig(HRPWM_TypeDef *Instance, uint32_t Fault, + HRPWM_FaultBlankingCfgTypeDef *pFaultBlkCfg); +LL_StatusETypeDef LL_HRPWM_FaultCounterReset(uint32_t Fault); +LL_StatusETypeDef LL_HRPWM_ADDATriggerConfig(HRPWM_TypeDef *Instance, HRPWM_ADCTriggerCfgTypeDef *pADCTriggerCfg); +LL_StatusETypeDef LL_HRPWM_OutputConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_OutputCfgTypeDef *pOutputCfg); +LL_StatusETypeDef LL_HRPWM_DeadTimeConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_DeadTimeCfgTypeDef *pDeaTimedCfg); +LL_StatusETypeDef LL_HRPWM_ChopperConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_ChopperModeCfgTypeDef *pChopperCfg); +LL_StatusETypeDef LL_HRPWM_EventConfig(HRPWM_TypeDef *Instance, uint32_t Event, HRPWM_EventCfgTypeDef *pEventCfg); +LL_StatusETypeDef LL_HRPWM_TimerEventAConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_ExternalEventACfgTypeDef *pEventCfg, HRPWM_TimerEventFilteringCfgTypeDef *pEventFilter); +LL_StatusETypeDef LL_HRPWM_TimerEventAFilter(HRPWM_TypeDef *Instance, uint32_t TimerIdx, uint32_t Event, + HRPWM_TimerEventFilteringCfgTypeDef *pEventFilter); +/** + * @} + */ + + +/** @addtogroup HRPWM_LL_Exported_Functions_Group6 + * @{ + */ +LL_StatusETypeDef LL_HRPWM_ForceRegistersUpdate(uint32_t TimerIdx); +LL_StatusETypeDef LL_HRPWM_DisRegisterUpdate(uint32_t TimerIdx); +LL_StatusETypeDef LL_HRPWM_EnRegUpdate(uint32_t TimerIdx); +LL_StatusETypeDef LL_HRPWM_StartOutput(uint32_t TimerIdx); +LL_StatusETypeDef LL_HRPWM_StopOutput(uint32_t TimerIdx); +LL_StatusETypeDef LL_HRPWM_SwapOutput(uint32_t TimerIdx, uint32_t swap); +LL_StatusETypeDef LL_HRPWM_ResetCounter(uint32_t TimerIdx); +/** + * @} + */ + + +/** @addtogroup HRPWM_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_HRPWM_IRQHandler(uint32_t TimerIdx); + +void LL_HRPWM_FLT_IRQHandler(void); +void LL_HRPWM_SLAVE_IRQHandler(uint32_t TimerIdx); +void LL_HRPWM_MSTR_IRQHandler(void); + +void LL_HRPWM_Fault0Callback(void); +void LL_HRPWM_Fault1Callback(void); +void LL_HRPWM_Fault2Callback(void); +void LL_HRPWM_Fault3Callback(void); +void LL_HRPWM_Fault4Callback(void); +void LL_HRPWM_Fault5Callback(void); +void LL_HRPWM_SystemFaultCallback(void); +void LL_HRPWM_SynchronizationEventCallback(void); +void LL_HRPWM_RegistersUpdateCallback(uint32_t TimerIdx); +void LL_HRPWM_RepetitionEventCallback(uint32_t TimerIdx); +void LL_HRPWM_CompareAEventCallback(uint32_t TimerIdx); +void LL_HRPWM_CompareBEventCallback(uint32_t TimerIdx); +void LL_HRPWM_CompareCEventCallback(uint32_t TimerIdx); +void LL_HRPWM_CompareDEventCallback(uint32_t TimerIdx); +void LL_HRPWM_PeriodEventCallback(uint32_t TimerIdx); +void LL_HRPWM_CounterResetCallback(uint32_t TimerIdx); +void LL_HRPWM_OutputASetCallback(uint32_t TimerIdx); +void LL_HRPWM_OutputBSetCallback(uint32_t TimerIdx); +void LL_HRPWM_OutputAResetCallback(uint32_t TimerIdx); +void LL_HRPWM_OutputBResetCallback(uint32_t TimerIdx); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup HRPWM_LL_Private_Macros HRPWM LL Private Macros + * @brief HRPWM LL Private Macros + * @{ + */ + +/** + * @brief Judge is HRPWM index all or not + * @param __INDEX__ index to judge + * @retval 0 isn't HRPWM index all + * @retval 1 is HRPWM index all + */ +#define IS_HRPWM_INDEX_ALL(__INDEX__) \ + (((__INDEX__) == HRPWM_INDEX_SLAVE_0) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_1) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_2) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_3) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_4) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_5) || \ + ((__INDEX__) == HRPWM_INDEX_MASTER) || \ + ((__INDEX__) == HRPWM_INDEX_COMMON)) + +/** + * @brief Judge is HRPWM index or not + * @param __INDEX__ index to judge + * @retval 0 isn't HRPWM index + * @retval 1 is HRPWM index + */ +#define IS_HRPWM_INDEX(__INDEX__) \ + (((__INDEX__) == HRPWM_INDEX_SLAVE_0) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_1) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_2) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_3) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_4) || \ + ((__INDEX__) == HRPWM_INDEX_SLAVE_5) || \ + ((__INDEX__) == HRPWM_INDEX_MASTER)) + +/** + * @brief Judge is HRPWM fault interrupt or not + * @param __INTERRUPT__ interrupt to judge + * @retval 0 isn't HRPWM fault interrupt + * @retval 1 is HRPWM fault interrupt + */ +#define IS_HRPWM_FAULT_IT(__INTERRUPT__) \ + (((__INTERRUPT__) == HRPWM_IT_NONE) || \ + (((__INTERRUPT__) & HRPWM_IT_SRC) != HRPWM_IT_NONE)) + +/** + * @brief Judge is HRPWM master interrupt or not + * @param __INTERRUPT__ interrupt to judge + * @retval 0 isn't HRPWM master interrupt + * @retval 1 is HRPWM master interrupt + */ +#define IS_HRPWM_MASTER_IT(__INTERRUPT__) \ + (((__INTERRUPT__) == HRPWM_MASTER_IT_NONE) || \ + (((__INTERRUPT__) & HRPWM_MASTER_IT_SRC) != HRPWM_MASTER_IT_NONE)) + +/** + * @brief Judge is HRPWM timer interrupt or not + * @param __INTERRUPT__ interrupt to judge + * @retval 0 isn't HRPWM timer interrupt + * @retval 1 is HRPWM timer interrupt + */ +#define IS_HRPWM_TIMER_IT(__INTERRUPT__) \ + (((__INTERRUPT__) == HRPWM_IT_TIMER_NONE) || \ + (((__INTERRUPT__) & HRPWM_IT_TIMER_SRC) != HRPWM_IT_TIMER_NONE)) + +/** + * @brief Judge is HRPWM sync output source or not + * @param __OUTPUT__ output source to judge + * @retval 0 isn't HRPWM sync output source + * @retval 1 is HRPWM sync output source + */ +#define IS_HRPWM_SYNCOUTPUTSOURCE(__OUTPUT__) \ + (((__OUTPUT__) == HRPWM_SYNCOUTPUTSOURCE_MASTER_START) || \ + ((__OUTPUT__) == HRPWM_SYNCOUTPUTSOURCE_MASTER_CMPA) || \ + ((__OUTPUT__) == HRPWM_SYNCOUTPUTSOURCE_SLAVE0_STARTRST) || \ + ((__OUTPUT__) == HRPWM_SYNCOUTPUTSOURCE_SLAVE0_CMPA)) + +/** + * @brief Judge is HRPWM sync output polarity or not + * @param __POLARITY__ output polarity to judge + * @retval 0 isn't HRPWM sync polarity source + * @retval 1 is HRPWM sync polarity source + */ +#define IS_HRPWM_SYNCOUTPUTPOLARITY(__POLARITY__) \ + (((__POLARITY__) == HRPWM_SYNCOUTPUTPOLARITY_POSITIVE) || \ + ((__POLARITY__) == HRPWM_SYNCOUTPUTPOLARITY_NEGATIVE)) + +/** + * @brief Judge is HRPWM sync input source or not + * @param __SOURCE__ input source to judge + * @retval 0 isn't HRPWM sync input source + * @retval 1 is HRPWM sync input source + */ +#define IS_HRPWM_SYNINPUTSOURCE(__SOURCE__) \ + (((__SOURCE__) == HRPWM_SYNCINPUTSOURCE_NONE) || \ + ((__SOURCE__) == HRPWM_SYNCINPUTSOURCE_TIM0_TRGO_EVENT) || \ + ((__SOURCE__) == HRPWM_SYNCINPUTSOURCE_EVENT)) + +/** + * @brief Judge is HRPWM DLLGCP or not + * @param __CURRENT__ current to judge + * @retval 0 isn't HRPWM DLLGCP + * @retval 1 is HRPWM DLLGCP + */ +#define IS_HRPWM_DLLGCP(__CURRENT__) \ + (((__CURRENT__) == HRPWM_DLLCR_DLLGCP_4) || \ + ((__CURRENT__) == HRPWM_DLLCR_DLLGCP_6) || \ + ((__CURRENT__) == HRPWM_DLLCR_DLLGCP_8)) + +/** + * @brief Judge is HRPWM prescale ratio or not + * @param __CLKPSC__ ratio to judge + * @retval 0 isn't HRPWM prescale ratio + * @retval 1 is HRPWM prescale ratio + */ +#define IS_HRPWM_PRESCALERRATIO(__CLKPSC__) \ + (((__CLKPSC__) == HRPWM_PRESCALERRATIO_MUL32) || \ + ((__CLKPSC__) == HRPWM_PRESCALERRATIO_MUL16) || \ + ((__CLKPSC__) == HRPWM_PRESCALERRATIO_MUL8) || \ + ((__CLKPSC__) == HRPWM_PRESCALERRATIO_MUL4) || \ + ((__CLKPSC__) == HRPWM_PRESCALERRATIO_MUL2) || \ + ((__CLKPSC__) == HRPWM_PRESCALERRATIO_DIV1) || \ + ((__CLKPSC__) == HRPWM_PRESCALERRATIO_DIV2) || \ + ((__CLKPSC__) == HRPWM_PRESCALERRATIO_DIV4)) + +/** + * @brief Judge is HRPWM preload or not + * @param __PREEN__ preload to judge + * @retval 0 isn't HRPWM preload + * @retval 1 is HRPWM preload + */ +#define IS_HRPWM_PRELOAD(__PREEN__) \ + (((__PREEN__) == HRPWM_PRELOAD_DISABLE) || \ + ((__PREEN__) == HRPWM_PRELOAD_ENABLE)) + + +/** + * @brief Judge is HRPWM half mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM half mode + * @retval 1 is HRPWM half mode + */ +#define IS_HRPWM_HALFMODE(__MODE__) \ + (((__MODE__) == HRPWM_HALFMODE_DISABLE) || \ + ((__MODE__) == HRPWM_HALFMODE_ENABLE)) + +/** + * @brief Judge is HRPWM push pull mode or not + * @param __SYNC__ mode to judge + * @retval 0 isn't HRPWM push pull mode + * @retval 1 is HRPWM push pull mode + */ +#define IS_HRPWM_PUSHPULLMODE(__SYNC__) \ + (((__SYNC__) == HRPWM_PUSHPULLMODE_DISABLE) || \ + ((__SYNC__) == HRPWM_PUSHPULLMODE_ENABLE)) + +/** + * @brief Judge is HRPWM sync start or not + * @param __SYNC__ sync start to judge + * @retval 0 isn't HRPWM sync start + * @retval 1 is HRPWM sync start + */ +#define IS_HRPWM_SYNCSTART(__SYNC__) \ + (((__SYNC__) == HRPWM_SYNCSTART_DISABLE) || \ + ((__SYNC__) == HRPWM_SYNCSTART_ENABLE)) + +/** + * @brief Judge is HRPWM sync reset or not + * @param __SYNC__ sync reset to judge + * @retval 0 isn't HRPWM sync reset + * @retval 1 is HRPWM sync reset + */ +#define IS_HRPWM_SYNCRESET(__SYNC__) \ + (((__SYNC__) == HRPWM_SYNCRESET_DISABLE) || \ + ((__SYNC__) == HRPWM_SYNCRESET_ENABLE)) + +/** + * @brief Judge is HRPWM Interleaved Mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM Interleaved Mode + * @retval 1 is HRPWM Interleaved Mode + */ +#define IS_HRPWM_INTERLEAVEDMODE(__MODE__) \ + (((__MODE__) == HRPWM_INTERLEAVED_MODE_DISABLE) || \ + ((__MODE__) == HRPWM_INTERLEAVED_MODE_TRIPLE) || \ + ((__MODE__) == HRPWM_INTERLEAVED_MODE_QUAD)) + +/** + * @brief Judge is HRPWM fault enable or not + * @param __FAULT__ fault to judge + * @retval 0 isn't HRPWM fault enable + * @retval 1 is HRPWM fault enable + */ +#define IS_HRPWM_FAULTENABLE(__FAULT__) \ + (((__FAULT__) == HRPWM_FAULTEN_NONE) || \ + (((__FAULT__) & 0x3f) != HRPWM_FAULTEN_NONE)) + +/** + * @brief Judge is HRPWM resync update or not + * @param __RESYNC__ resync to judge + * @retval 0 isn't HRPWM resync update + * @retval 1 is HRPWM resync update + */ +#define IS_HRPWM_RESYNCUPDATE(__RESYNC__) \ + (((__RESYNC__) == HRPWM_RSYNCUPDATE_DISABLE) || \ + ((__RESYNC__) == HRPWM_RSYNCUPDATE_ENABLE)) + +/** + * @brief Judge is HRPWM update trigger or not + * @param __UPDATE__ update trigger to judge + * @retval 0 isn't HRPWM update trigger + * @retval 1 is HRPWM update trigger + */ +#define IS_HRPWM_UPDATETRIGGER(__UPDATE__) \ + (((__UPDATE__) == HRPWM_UPDATETRIGGER_NONE) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_MASTER) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_REP) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_RST) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_TIMER_0) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_TIMER_1) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_TIMER_2) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_TIMER_3) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_TIMER_4) || \ + ((__UPDATE__) == HRPWM_UPDATETRIGGER_TIMER_5)) + +/** + * @brief Judge is HRPWM mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM mode + * @retval 1 is HRPWM mode + */ +#define IS_HRPWM_MODE(__MODE__) \ + (((__MODE__) == HRPWM_MODE_CONTINUOUS) || \ + ((__MODE__) == HRPWM_MODE_SINGLESHOT) || \ + ((__MODE__) == HRPWM_MODE_SINGLESHOT_RETRIGGERABLE)) + +/** + * @brief Judge is HRPWM dual DAC reset or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM dual DAC reset + * @retval 1 is HRPWM dual DAC reset + */ +#define IS_HRPWM_DUALDAC_RESET(__MODE__) \ + (((__MODE__) == HRPWM_DAC_DCDR_RESET) || \ + ((__MODE__) == HRPWM_DAC_DCDR_SETA)) + +/** + * @brief Judge is HRPWM dual DAC step or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM dual DAC step + * @retval 1 is HRPWM dual DAC step + */ +#define IS_HRPWM_DUALDAC_STEP(__MODE__) \ + (((__MODE__) == HRPWM_DAC_DCDS_CMPD) || \ + ((__MODE__) == HRPWM_DAC_DCDS_CLEARA)) + +/** + * @brief Judge is HRPWM dual DAC enable or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM dual DAC enable + * @retval 1 is HRPWM dual DAC enable + */ +#define IS_HRPWM_DUALDAC_ENABLE(__MODE__) \ + (((__MODE__) == HRPWM_DAC_DCDE_DISABLE) || \ + ((__MODE__) == HRPWM_DAC_DCDE_ENABLE)) + +/** + * @brief Judge is HRPWM fault or not + * @param __FAULT__ fault to judge + * @retval 0 isn't HRPWM fault + * @retval 1 is HRPWM fault + */ +#define IS_HRPWM_FAULT(__FAULT__) \ + (((__FAULT__) == HRPWM_FAULT_0) || \ + ((__FAULT__) == HRPWM_FAULT_1) || \ + ((__FAULT__) == HRPWM_FAULT_2) || \ + ((__FAULT__) == HRPWM_FAULT_3) || \ + ((__FAULT__) == HRPWM_FAULT_4) || \ + ((__FAULT__) == HRPWM_FAULT_5)) + +/** + * @brief Judge is HRPWM fault source or not + * @param __SOURCE__ source to judge + * @retval 0 isn't HRPWM fault source + * @retval 1 is HRPWM fault source + */ +#define IS_HRPWM_FAULTSOURCE(__SOURCE__) \ + (((__SOURCE__) == HRPWM_FLTSRC_GPIO) || \ + ((__SOURCE__) == HRPWM_FLTSRC_COMP_OUT) || \ + ((__SOURCE__) == HRPWM_FLTSRC_EVENT)) + +/** + * @brief Judge is HRPWM fault polarity or not + * @param __POLARITY__ polarity to judge + * @retval 0 isn't HRPWM fault polarity + * @retval 1 is HRPWM fault polarity + */ +#define IS_HRPWM_FAULTPOLARITY(__POLARITY__) \ + (((__POLARITY__) == HRPWM_FAULTPOL_LOW) || \ + ((__POLARITY__) == HRPWM_FAULTPOL_HIGH)) + +/** + * @brief Judge is HRPWM fault filter or not + * @param __FILTER__ filter to judge + * @retval 0 isn't HRPWM fault filter + * @retval 1 is HRPWM fault filter + */ +#define IS_HRPWM_FAULTFILTER(__FILTER__) \ + (((__FILTER__) == HRPWM_FAULTFILTER_NONE) || \ + (((__FILTER__) & HRPWM_FLTINR1_FLT0F) != HRPWM_FAULTFILTER_NONE)) + +/** + * @brief Judge is HRPWM fault sample clock div or not + * @param __CLKDIV__ clock div to judge + * @retval 0 isn't HRPWM fault sample clock div + * @retval 1 is HRPWM fault sample clock div + */ +#define IS_HRPWM_FAULTSAMPCLK(__CLKDIV__) \ + (((__CLKDIV__) == HRPWM_FLTSD_DIV1) || \ + ((__CLKDIV__) == HRPWM_FLTSD_DIV2) || \ + ((__CLKDIV__) == HRPWM_FLTSD_DIV4) || \ + ((__CLKDIV__) == HRPWM_FLTSD_DIV8)) + +/** + * @brief Judge is HRPWM fault blanking enable or not + * @param __BLKEN__ blanking enable to judge + * @retval 0 isn't HRPWM fault blanking enable + * @retval 1 is HRPWM fault blanking enable + */ +#define IS_HRPWM_FAULTBLKEN(__BLKEN__) \ + (((__BLKEN__) == HRPWM_FAULTBLKEN_DISABLE) || \ + ((__BLKEN__) == HRPWM_FAULTBLKEN_ENABLE)) + +/** + * @brief Judge is HRPWM fault blanking source or not + * @param __BLKSRC__ blanking source to judge + * @retval 0 isn't HRPWM fault blanking source + * @retval 1 is HRPWM fault blanking source + */ +#define IS_HRPWM_FAULTBLKSRC(__BLKSRC__) \ + (((__BLKSRC__) == HRPWM_FAULTBLKS_RSTALIGNED) || \ + ((__BLKSRC__) == HRPWM_FAULTBLKS_MOVING)) + +/** + * @brief Judge is HRPWM fault reset mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM fault reset mode + * @retval 1 is HRPWM fault reset mode + */ +#define IS_HRPWM_FAULTRSTMODE(__MODE__) \ + (((__MODE__) == HRPWM_FAULTRSTM_UNCONDITIONAL) || \ + ((__MODE__) == HRPWM_FAULTRSTM_CONDITIONAL)) + +/** + * @brief Judge is HRPWM ADC trigger or not + * @param __ADCTRIGGER__ trigger to judge + * @retval 0 isn't HRPWM ADC trigger + * @retval 1 is HRPWM ADC trigger + */ +#define IS_HRPWM_ADCTRIGGER(__ADCTRIGGER__) \ + (((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_0) || \ + ((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_1) || \ + ((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_2) || \ + ((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_3) || \ + ((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_4) || \ + ((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_5) || \ + ((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_6) || \ + ((__ADCTRIGGER__) == HRPWM_ADCTRIGGER_7)) + +/** + * @brief Judge is HRPWM ADC trigger post scaler or not + * @param __PSC__ post scaler to judge + * @retval 0 isn't HRPWM ADC trigger post scaler + * @retval 1 is HRPWM ADC trigger post scaler + */ +#define IS_HRPWM_ADCTRIGGER_POSTSCALER(__PSC__) \ + (((__PSC__) == HRPWM_ADCTRIG_PSC_1) || \ + (((__PSC__) & HRPWM_ADPSR_ADPSC0) != HRPWM_ADCTRIG_PSC_1)) + +/** + * @brief Judge is HRPWM ADC trigger length or not + * @param __LENGTH__ length to judge + * @retval 0 isn't HRPWM ADC trigger length + * @retval 1 is HRPWM ADC trigger length + */ +#define IS_HRPWM_ADCTRIGGER_LENGTH(__LENGTH__) \ + (((__LENGTH__) == HRPWM_ADCTRIG_LENGTH_1) || \ + (((__LENGTH__) & HRPWM_CR2_TLEN0) != HRPWM_ADCTRIG_LENGTH_1)) + +/** + * @brief Judge is HRPWM ADC trigger update source or not + * @param __UPDSRC__ update source to judge + * @retval 0 isn't HRPWM ADC trigger update source + * @retval 1 is HRPWM ADC trigger update source + */ +#define IS_HRPWM_ADCTRIGGER_UPDATESRC(__UPDSRC__) \ + (((__UPDSRC__) == HRPWM_ADCTRIGUPDATE_MASTER) || \ + ((__UPDSRC__) == HRPWM_ADCTRIGUPDATE_TIMER_0) || \ + ((__UPDSRC__) == HRPWM_ADCTRIGUPDATE_TIMER_1) || \ + ((__UPDSRC__) == HRPWM_ADCTRIGUPDATE_TIMER_2) || \ + ((__UPDSRC__) == HRPWM_ADCTRIGUPDATE_TIMER_3) || \ + ((__UPDSRC__) == HRPWM_ADCTRIGUPDATE_TIMER_4) || \ + ((__UPDSRC__) == HRPWM_ADCTRIGUPDATE_TIMER_5)) + +/** + * @brief Judge is HRPWM output A active polarity or not + * @param __POLARITY__ polarity to judge + * @retval 0 isn't HRPWM output A active polarity + * @retval 1 is HRPWM output A active polarity + */ +#define IS_HRPWM_OUTPUTA_POLARITY(__POLARITY__) \ + (((__POLARITY__) == HRPWM_OUTPUT_POLA_POSITIVE) || \ + ((__POLARITY__) == HRPWM_OUTPUT_POLA_NEGATIVE)) + +/** + * @brief Judge is HRPWM output A idel level or not + * @param __IDEL__ idel level to judge + * @retval 0 isn't HRPWM output A idel level + * @retval 1 is HRPWM output A idel level + */ +#define IS_HRPWM_OUTPUTA_IDLELEVEL(__IDEL__) \ + (((__IDEL__) == HRPWM_OUTPUTIDLEA_INACTIVE) || \ + ((__IDEL__) == HRPWM_OUTPUTIDLEA_ACTIVE)) + +/** + * @brief Judge is HRPWM output A fault level or not + * @param __LEVEL__ fault level to judge + * @retval 0 isn't HRPWM output A fault level + * @retval 1 is HRPWM output A fault level + */ +#define IS_HRPWM_OUTPUTA_FLTLEVEL(__LEVEL__) \ + (((__LEVEL__) == HRPWM_OUTPUTFAULTA_NONE) || \ + ((__LEVEL__) == HRPWM_OUTPUTFAULTA_ACTIVE) || \ + ((__LEVEL__) == HRPWM_OUTPUTFAULTA_INACTIVE) || \ + ((__LEVEL__) == HRPWM_OUTPUTFAULTA_HIGHZ)) + +/** + * @brief Judge is HRPWM output A Chopper Mode enable or not + * @param __CHOPPER__ Chopper Mode enable to judge + * @retval 0 isn't HRPWM output A Chopper Mode enable + * @retval 1 is HRPWM output A Chopper Mode enable + */ +#define IS_HRPWM_OUTPUTA_CHOPPEREN(__CHOPPER__) \ + (((__CHOPPER__) == HRPWM_OUTPUTCHOPPERA_ENABLE) || \ + ((__CHOPPER__) == HRPWM_OUTPUTCHOPPERA_DISABLE)) + +/** + * @brief Judge is HRPWM output B active polarity or not + * @param __POLARITY__ polarity to judge + * @retval 0 isn't HRPWM output B active polarity + * @retval 1 is HRPWM output B active polarity + */ +#define IS_HRPWM_OUTPUTB_POLARITY(__POLARITY__) \ + (((__POLARITY__) == HRPWM_OUTPUT_POLB_POSITIVE) || \ + ((__POLARITY__) == HRPWM_OUTPUT_POLB_NEGATIVE)) + +/** + * @brief Judge is HRPWM output B idel level or not + * @param __IDEL__ idel level to judge + * @retval 0 isn't HRPWM output B idel level + * @retval 1 is HRPWM output B idel level + */ +#define IS_HRPWM_OUTPUTB_IDLELEVEL(__IDEL__) \ + (((__IDEL__) == HRPWM_OUTPUTIDLEB_INACTIVE) || \ + ((__IDEL__) == HRPWM_OUTPUTIDLEB_ACTIVE)) + +/** + * @brief Judge is HRPWM output B fault level or not + * @param __LEVEL__ fault level to judge + * @retval 0 isn't HRPWM output B fault level + * @retval 1 is HRPWM output B fault level + */ +#define IS_HRPWM_OUTPUTB_FLTLEVEL(__LEVEL__) \ + (((__LEVEL__) == HRPWM_OUTPUTFAULTB_NONE) || \ + ((__LEVEL__) == HRPWM_OUTPUTFAULTB_ACTIVE) || \ + ((__LEVEL__) == HRPWM_OUTPUTFAULTB_INACTIVE) || \ + ((__LEVEL__) == HRPWM_OUTPUTFAULTB_HIGHZ)) + +/** + * @brief Judge is HRPWM output B Chopper Mode enable or not + * @param __CHOPPER__ Chopper Mode enable to judge + * @retval 0 isn't HRPWM output B Chopper Mode enable + * @retval 1 is HRPWM output B Chopper Mode enable + */ +#define IS_HRPWM_OUTPUTB_CHOPPEREN(__CHOPPER__) \ + (((__CHOPPER__) == HRPWM_OUTPUTCHOPPERB_ENABLE) || \ + ((__CHOPPER__) == HRPWM_OUTPUTCHOPPERB_DISABLE)) + +/** + * @brief Judge is HRPWM output event or not + * @param __INTERRUPT__ interrupt to judge + * @retval 0 isn't HRPWM output event + * @retval 1 is HRPWM output event + */ +#define IS_HRPWM_OUTPUT_SET_EVENT(__INTERRUPT__) \ + (((__INTERRUPT__) == HRPWM_OUTPUT_SET_NONE) || \ + (((__INTERRUPT__) & 0x7FFFFU) != HRPWM_OUTPUT_SET_NONE)) +/** + * @brief Judge is HRPWM output event or not + * @param __INTERRUPT__ interrupt to judge + * @retval 0 isn't HRPWM output event + * @retval 1 is HRPWM output event + */ +#define IS_HRPWM_OUTPUT_CLEAR_EVENT(__INTERRUPT__) \ + (((__INTERRUPT__) == HRPWM_OUTPUT_CLEAR_NONE) || \ + (((__INTERRUPT__) & 0x7FFFFU) != HRPWM_OUTPUT_CLEAR_NONE)) + +/** + * @brief Judge is HRPWM dead time rising sign or not + * @param __SIGN__ sign to judge + * @retval 0 isn't HRPWM dead time rising sign + * @retval 1 is HRPWM dead time rising sign + */ +#define IS_HRPWM_DEADTIME_SDTR(__SIGN__) \ + (((__SIGN__) == HRPWM_DEADTIME_RSIGN_NEGATIVE) || \ + ((__SIGN__) == HRPWM_DEADTIME_RSIGN_POSITIVE)) + +/** + * @brief Judge is HRPWM dead time falling sign or not + * @param __SIGN__ sign to judge + * @retval 0 isn't HRPWM dead time falling sign + * @retval 1 is HRPWM dead time falling sign + */ +#define IS_HRPWM_DEADTIME_SDTF(__SIGN__) \ + (((__SIGN__) == HRPWM_DEADTIME_FSIGN_NEGATIVE) || \ + ((__SIGN__) == HRPWM_DEADTIME_FSIGN_POSITIVE)) + +/** + * @brief Judge is HRPWM chopper duty cycle or not + * @param __CARDTY__ chopper duty cycle to judge + * @retval 0 isn't HRPWM chopper duty cycle + * @retval 1 is HRPWM chopper duty cycle + */ +#define IS_HRPWM_CHOPPER_CARDTY(__CARDTY__) \ + (((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_0) || \ + ((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_1) || \ + ((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_2) || \ + ((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_3) || \ + ((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_4) || \ + ((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_5) || \ + ((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_6) || \ + ((__CARDTY__) == HRPWM_CHOPPER_DUTYCYCLE_7)) + +/** + * @brief Judge is HRPWM chopper start pulse width or not + * @param __STRPW__ start pulse width to judge + * @retval 0 isn't HRPWM chopper start pulse width + * @retval 1 is HRPWM chopper start pulse width + */ +#define IS_HRPWM_CHOPPER_STRPW(__STRPW__) \ + (((__STRPW__) == HRPWM_CHOPPER_PULSEWIDTH_16) || \ + (((__STRPW__) & HRPWM_CHPR_STRPW) != HRPWM_CHOPPER_PULSEWIDTH_16)) + +/** + * @brief Judge is HRPWM chopper frequency or not + * @param __CARFRQ__ chopper frequency to judge + * @retval 0 isn't HRPWM chopper frequency + * @retval 1 is HRPWM chopper frequency + */ +#define IS_HRPWM_CHOPPER_CARFRQ(__CARFRQ__) \ + (((__CARFRQ__) == HRPWM_CHOPPER_CARFRQ_DIV16) || \ + (((__CARFRQ__) & HRPWM_CHPR_CARFRQ) != HRPWM_CHOPPER_CARFRQ_DIV16)) + +/** + * @brief Judge is HRPWM event or not + * @param __EVENT__ event to judge + * @retval 0 isn't HRPWM event + * @retval 1 is HRPWM event + */ +#define IS_HRPWM_EVENT(__EVENT__) \ + (((__EVENT__) == HRPWM_EVENT_NONE) || \ + ((__EVENT__) == HRPWM_EVENT_0) || \ + ((__EVENT__) == HRPWM_EVENT_1) || \ + ((__EVENT__) == HRPWM_EVENT_2) || \ + ((__EVENT__) == HRPWM_EVENT_3) || \ + ((__EVENT__) == HRPWM_EVENT_4) || \ + ((__EVENT__) == HRPWM_EVENT_5)) + +/** + * @brief Judge is HRPWM event source or not + * @param __SOURCE__ source to judge + * @retval 0 isn't HRPWM event source + * @retval 1 is HRPWM event source + */ +#define IS_HRPWM_EVENTSOURCE(__SOURCE__) \ + (((__SOURCE__) == HRPWM_EEVSRC_GPIO) || \ + ((__SOURCE__) == HRPWM_EEVSRC_COMP_OUT) || \ + ((__SOURCE__) == HRPWM_EEVSRC_TIM_TRGO) || \ + ((__SOURCE__) == HRPWM_EEVSRC_ADC_AWD)) + +/** + * @brief Judge is HRPWM event polarity or not + * @param __POLARITY__ polarity to judge + * @retval 0 isn't HRPWM event polarity + * @retval 1 is HRPWM event polarity + */ +#define IS_HRPWM_EVENTPOLARITY(__POLARITY__) \ + (((__POLARITY__) == HRPWM_EVENTPOL_HIGH) || \ + ((__POLARITY__) == HRPWM_EVENTPOL_LOW)) + +/** + * @brief Judge is HRPWM event filter or not + * @param __FILTER__ filter to judge + * @retval 0 isn't HRPWM event filter + * @retval 1 is HRPWM event filter + */ +#define IS_HRPWM_EVENTFILTER(__FILTER__) \ + (((__FILTER__) == HRPWM_EVENTFILTER_NONE) || \ + (((__FILTER__) & HRPWM_EECR2_EE0F) != HRPWM_EVENTFILTER_NONE)) + +/** + * @brief Judge is HRPWM event prescaler div or not + * @param __CLKDIV__ prescaler div to judge + * @retval 0 isn't HRPWM event prescaler div + * @retval 1 is HRPWM event prescaler div + */ +#define IS_HRPWM_EVENTSAMPCLK(__CLKDIV__) \ + (((__CLKDIV__) == HRPWM_EEVSD_DIV1) || \ + ((__CLKDIV__) == HRPWM_EEVSD_DIV2) || \ + ((__CLKDIV__) == HRPWM_EEVSD_DIV4) || \ + ((__CLKDIV__) == HRPWM_EEVSD_DIV8)) + +/** + * @brief Judge is HRPWM event fast mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM event fast mode + * @retval 1 is HRPWM event fast mode + */ +#define IS_HRPWM_EVENTFASTMODE(__MODE__) \ + (((__MODE__) == HRPWM_EVENTFASTMODE_DISABLE) || \ + ((__MODE__) == HRPWM_EVENTFASTMODE_ENABLE)) + +/** + * @brief Judge is HRPWM event Sensitivity or not + * @param __SNS__ Sensitivity to judge + * @retval 0 isn't HRPWM event Sensitivity + * @retval 1 is HRPWM event Sensitivity + */ +#define IS_HRPWM_EVENTSNS(__SNS__) \ + (((__SNS__) == HRPWM_EVENTSENS_LEVEL) || \ + ((__SNS__) == HRPWM_EVENTSENS_RISINGEDGE) || \ + ((__SNS__) == HRPWM_EVENTSENS_FALLINGEDGE) || \ + ((__SNS__) == HRPWM_EVENTSENS_BOTHEDGES)) + +/** + * @brief Judge is HRPWM event A filter or not + * @param __FILTER__ filter to judge + * @retval 0 isn't HRPWM event filter A + * @retval 1 is HRPWM event filter A + */ +#define IS_HRPWM_EVENTA_FILTER(__FILTER__) \ + (((__FILTER__) == HRPWM_EEVFLT_NONE) || \ + (((__FILTER__) & HRPWM_EEFR0_EE0FLTR) != HRPWM_EEVFLT_NONE)) + +/** + * @brief Judge is HRPWM event A latch or not + * @param __LATCH__ latch to judge + * @retval 0 isn't HRPWM event A latch + * @retval 1 is HRPWM event A latch + */ +#define IS_HRPWM_EVENTA_LATCH(__LATCH__) \ + (((__LATCH__) == HRPWM_EVENTLATCH_DISABLE) || \ + ((__LATCH__) == HRPWM_EVENTLATCH_ENABLE)) + +/** + * @brief Judge is HRPWM event A source or not + * @param __SOURCE__ source to judge + * @retval 0 isn't HRPWM event A source + * @retval 1 is HRPWM event A source + */ +#define IS_HRPWM_EVENTA_SOURCE(__SOURCE__) \ + (((__SOURCE__) == HRPWM_EEVASEL_SOURCE_EEVENT0) || \ + ((__SOURCE__) == HRPWM_EEVASEL_SOURCE_EEVENT1) || \ + ((__SOURCE__) == HRPWM_EEVASEL_SOURCE_EEVENT2) || \ + ((__SOURCE__) == HRPWM_EEVASEL_SOURCE_EEVENT3) || \ + ((__SOURCE__) == HRPWM_EEVASEL_SOURCE_EEVENT4) || \ + ((__SOURCE__) == HRPWM_EEVASEL_SOURCE_EEVENT5)) + +/** + * @brief Judge is HRPWM event A reset mode or not + * @param __MODE__ mode to judge + * @retval 0 isn't HRPWM event A reset mode + * @retval 1 is HRPWM event A reset mode + */ +#define IS_HRPWM_EVENTA_RSTMODE(__MODE__) \ + (((__MODE__) == HRPWM_EEVARSTM_CONDITIONAL) || \ + ((__MODE__) == HRPWM_EEVARSTM_UNCONDITIONAL)) + +/** + * @brief Judge is HRPWM event A counter enable or not + * @param __COUNTEREN__ counter enable to judge + * @retval 0 isn't HRPWM event A counter enable + * @retval 1 is HRPWM event A counter enable + */ +#define IS_HRPWM_EVENTA_COUNTEREN(__COUNTEREN__) \ + (((__COUNTEREN__) == HRPWM_EEVACOUNTER_DISABLE) || \ + ((__COUNTEREN__) == HRPWM_EEVACOUNTER_ENABLE)) + +/** + * @brief Judge is HRPWM reset event or not + * @param __RESET__ reset event to judge + * @retval 0 isn't HRPWM reset event + * @retval 1 is HRPWM reset event + */ +#define IS_HRPWM_RST_EVENT(__RESET__) \ + (((__RESET__) == HRPWM_RESET_TRIGGER_NONE) || \ + (((__RESET__) & (0x1FFFFFFF)) != 0x0U)) + +/** + * @brief Judge is HRPWM roll over mode or not + * @param __ROLLOVER__ mode to judge + * @retval 0 isn't HRPWM roll over mode + * @retval 1 is HRPWM roll over mode + */ +#define IS_HRPWM_ROLLOVERMODE(__ROLLOVER__) \ + (((__ROLLOVER__) == HRPWM_ROM_BOTH) || \ + ((__ROLLOVER__) == HRPWM_ROM_ZERO) || \ + ((__ROLLOVER__) == HRPWM_ROM_PERIOD)) + +/** + * @brief Judge is HRPWM roll over mode or not + * @param __ROLLOVER__ mode to judge + * @retval 0 isn't HRPWM roll over mode + * @retval 1 is HRPWM roll over mode + */ +#define IS_HRPWM_OUTPUTROLLOVERMODE(__ROLLOVER__) \ + (((__ROLLOVER__) == HRPWM_OUTROM_BOTH) || \ + ((__ROLLOVER__) == HRPWM_OUTROM_ZERO) || \ + ((__ROLLOVER__) == HRPWM_OUTROM_PERIOD)) + +/** + * @brief Judge is HRPWM roll over mode or not + * @param __ROLLOVER__ mode to judge + * @retval 0 isn't HRPWM roll over mode + * @retval 1 is HRPWM roll over mode + */ +#define IS_HRPWM_ADCROLLOVERMODE(__ROLLOVER__) \ + (((__ROLLOVER__) == HRPWM_ADROM_BOTH) || \ + ((__ROLLOVER__) == HRPWM_ADROM_ZERO) || \ + ((__ROLLOVER__) == HRPWM_ADROM_PERIOD)) + +/** + * @brief Judge is HRPWM roll over mode or not + * @param __ROLLOVER__ mode to judge + * @retval 0 isn't HRPWM roll over mode + * @retval 1 is HRPWM roll over mode + */ +#define IS_HRPWM_FLTROLLOVERMODE(__ROLLOVER__) \ + (((__ROLLOVER__) == HRPWM_FLTROM_BOTH) || \ + ((__ROLLOVER__) == HRPWM_FLTROM_ZERO) || \ + ((__ROLLOVER__) == HRPWM_FLTROM_PERIOD)) + +/** + * @brief Judge is HRPWM roll over mode or not + * @param __ROLLOVER__ mode to judge + * @retval 0 isn't HRPWM roll over mode + * @retval 1 is HRPWM roll over mode + */ +#define IS_HRPWM_EVTROLLOVERMODE(__ROLLOVER__) \ + (((__ROLLOVER__) == HRPWM_EEVROM_BOTH) || \ + ((__ROLLOVER__) == HRPWM_EEVROM_ZERO) || \ + ((__ROLLOVER__) == HRPWM_EEVROM_PERIOD)) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_HRPWM_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_i2c.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_i2c.h new file mode 100644 index 0000000000..6df60ace78 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_i2c.h @@ -0,0 +1,2511 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_i2c.h + * @author MCD Application Team + * @brief Header file for I2C LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TMF5XXX_LL_I2C_H_ +#define _TMF5XXX_LL_I2C_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" +#ifdef LL_DMA_MODULE_ENABLED +#include "tae32f53xx_ll_dma.h" +#endif + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup I2C_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup I2C_LL_Exported_Constants I2C LL Exported Constants + * @brief I2C LL Exported Constants + * @{ + */ + +/** + * @brief I2C SS SPEED Max Macro Define + */ +#define I2C_SS_SPEED_MAX (100000UL) + +/** + * @brief I2C FS SPEED Max Macro Define + */ +#define I2C_FS_SPEED_MAX (400000UL) + +/** + * @brief I2C FS PLUS SPEED Max Macro Define + */ +#define I2C_FS_PLUS_SPEED_MAX (1000000UL) + +/** + * @brief I2C HS SPEED Max Macro Define + */ +#define I2C_HS_SPEED_MAX (3400000UL) + + +/** + * @brief I2C FIFO Depth Define + */ +#define I2C_FIFO_DEPTH (16) + +/** + * @} + */ + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup I2C_LL_Exported_Macros I2C LL Exported Macros + * @brief I2C LL Exported Macros + * @{ + */ + +/** + * @brief I2C SMBUS Persistant Slave Address Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvPersistant_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_SMBUS_PST_SLV_ADDR_EN_Msk) + +/** + * @brief I2C SMBUS Persistant Slave Address Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvPersistant_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SMBUS_PST_SLV_ADDR_EN_Msk) + +/** + * @brief I2C SMBUS ARP Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARP_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_SMBUS_ARP_EN_Msk) + +/** + * @brief I2C SMBUS ARP Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARP_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SMBUS_ARP_EN_Msk) + +/** + * @brief I2C SMBUS Slave Quick Cmd Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvQuickCmd_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_SMBUS_SLV_QUICK_CMD_EN_Msk) + +/** + * @brief I2C SMBUS Slave Quick Cmd Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvQuickCmd_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SMBUS_SLV_QUICK_CMD_EN_Msk) + +/** + * @brief I2C Optional SAR Control Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_OptionalSarCtrl_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_OPTIONAL_SAR_CTRL_Msk) + +/** + * @brief I2C Master Bus Clear Feature Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_BusClrFeature_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_BUS_CLEAR_FEATURE_CTRL_Msk) + +/** + * @brief I2C Master Bus Clear Feature Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_BusClrFeature_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_BUS_CLEAR_FEATURE_CTRL_Msk) + +/** + * @brief I2C Stop Detect If Master Active Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_StopDetIfActive_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_STOP_DET_IF_MASTER_ACT_Msk) + +/** + * @brief I2C Stop Detect If Master Active Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_StopDetIfActive_Clr(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_STOP_DET_IF_MASTER_ACT_Msk) + +/** + * @brief I2C RX FIFO Full Hold Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxFIFOFullHold_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_RX_FIFO_FULL_HLD_CTRL_Msk) + +/** + * @brief I2C RX FIFO Full Hold Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxFIFOFullHold_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_RX_FIFO_FULL_HLD_CTRL_Msk) + +/** + * @brief I2C TX Empty Control Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxEmptyCtrl_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_TX_EMPTY_CTRL_Msk) + +/** + * @brief I2C TX Empty Control Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxEmptyCtrl_Clr(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_TX_EMPTY_CTRL_Msk) + +/** + * @brief I2C Slave Stop Detect If Addressed Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_StopDetIfAddressed_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_STOP_DET_IFADDRESSED_Msk) + +/** + * @brief I2C Slave Stop Detect If Addressed Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_StopDetIfAddressed_Clr(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_STOP_DET_IFADDRESSED_Msk) + +/** + * @brief I2C Slave Mode Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLAVE_Mode_En(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_SLAVE_DISABLE_Msk) + +/** + * @brief I2C Slave Mode Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLAVE_Mode_Dis(__I2C__) SET_BIT((__I2C__)->CON, I2C_SLAVE_DISABLE_Msk) + +/** + * @brief I2C Master Restart Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_Restart_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_RESTART_EN_Msk) + +/** + * @brief I2C Master Restart Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_Restart_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_RESTART_EN_Msk) + +/** + * @brief I2C Master 7bit Address Mode Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_7bAddr_Set(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_10BITADDR_MASTER_Msk) + +/** + * @brief I2C Master 10bit Address Mode Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_10bAddr_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_10BITADDR_MASTER_Msk) + +/** + * @brief I2C Slave 7bit Address Mode Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_7bAddr_Set(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_10BITADDR_SLAVE_Msk) + +/** + * @brief I2C Slave 10bit Address Mode Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_10bAddr_Set(__I2C__) SET_BIT((__I2C__)->CON, I2C_10BITADDR_SLAVE_Msk) + +/** + * @brief I2C Speed Set + * @param __I2C__ Specifies I2C peripheral + * @param speed I2C Speed + * @return None + */ +#define __LL_I2C_Speed_Set(__I2C__, speed) MODIFY_REG((__I2C__)->CON, I2C_SPEED_Msk, speed) + +/** + * @brief I2C Master Mode Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MASTER_Mode_En(__I2C__) SET_BIT((__I2C__)->CON, I2C_MASTER_MODE_Msk) + +/** + * @brief I2C Master Mode Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MASTER_Mode_Dis(__I2C__) CLEAR_BIT((__I2C__)->CON, I2C_MASTER_MODE_Msk) + +/** + * @brief I2C Master Mode is Enable or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 I2C isn't Master Mode + * @retval 1 I2C is Master Mode + */ +#define __LL_I2C_IsMasterMode(__I2C__) READ_BIT((__I2C__)->CON, I2C_MASTER_MODE_Msk) + +/** + * @brief I2C TAR SMBUD Quick Cmd Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_SmbusQuickCmd_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_SMBUS_QUICK_CMD_Msk) + +/** + * @brief I2C TAR SMBUD Quick Cmd Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_SmbusQuickCmd_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_SMBUS_QUICK_CMD_Msk) + +/** + * @brief I2C TAR Device ID Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_DevID_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_TAR_DEV_ID_Msk) + +/** + * @brief I2C TAR Device ID Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_DevID_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_TAR_DEV_ID_Msk) + +/** + * @brief I2C TAR Master 7bit Address Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_MST_7bAddr_Set(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_TAR_10BITADDR_MASTER_Msk) + +/** + * @brief I2C TAR Master 10bit Address Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_MST_10bAddr_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_TAR_10BITADDR_MASTER_Msk) + +/** + * @brief I2C TAR Special Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_Special_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_SPECIAL_Msk) + +/** + * @brief I2C TAR Special Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_Special_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_SPECIAL_Msk) + +/** + * @brief I2C TAR GC OR Start Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_GcOrStart_Set(__I2C__) SET_BIT((__I2C__)->TAR, I2C_GC_OR_START_Msk) + +/** + * @brief I2C TAR GC OR Start Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TAR_GcOrStart_Clr(__I2C__) CLEAR_BIT((__I2C__)->TAR, I2C_GC_OR_START_Msk) + +/** + * @brief I2C Master TAR Set + * @param __I2C__ Specifies I2C peripheral + * @param tar I2C Master TAR + * @return None + */ +#define __LL_I2C_TAR_Set(__I2C__, tar) MODIFY_REG((__I2C__)->TAR, I2C_TAR_Msk, ((tar & 0x3ffUL) << I2C_TAR_Pos)) + + +/** + * @brief I2C Slave SAR Set + * @param __I2C__ Specifies I2C peripheral + * @param tar I2C Slave SAR + * @return None + */ +#define __LL_I2C_SAR_Set(__I2C__, sar) MODIFY_REG((__I2C__)->SAR, I2C_SAR_Msk, ((sar & 0x3ffUL) << I2C_SAR_Pos)) + + +/** + * @brief Judge Is First Data Byte or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't first data byte + * @retval 1 Is first data byte + */ +#define __LL_I2C_IsFirstDataByte(__I2C__) (READ_BIT((__I2C__)->DCMD, I2C_FIRST_DATA_BYTE_Msk) >> I2C_FIRST_DATA_BYTE_Pos) + +/** + * @brief I2C Restart Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Restart_Set(__I2C__) SET_BIT((__I2C__)->DCMD, I2C_RESTART_Msk) + +/** + * @brief I2C Restart Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Restart_Clr(__I2C__) CLEAR_BIT((__I2C__)->DCMD, I2C_RESTART_Msk) + +/** + * @brief I2C Stop Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Stop_Set(__I2C__) SET_BIT((__I2C__)->DCMD, I2C_STOP_Msk) + +/** + * @brief I2C Stop Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Stop_Clr(__I2C__) CLEAR_BIT((__I2C__)->DCMD, I2C_STOP_Msk) + +/** + * @brief I2C Master Cmd Read Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_CmdRead_Set(__I2C__) SET_BIT((__I2C__)->DCMD, I2C_CMD_Msk) + +/** + * @brief I2C Master Cmd Write Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_CmdWrite_Set(__I2C__) CLEAR_BIT((__I2C__)->DCMD, I2C_CMD_Msk) + +/** + * @brief I2C Data Write + * @param __I2C__ Specifies I2C peripheral + * @param dat data to write + * @return None + */ +#define __LL_I2C_DAT_Write(__I2C__, dat) MODIFY_REG((__I2C__)->DCMD, I2C_DAT_Msk, (((dat) & 0xffUL) << I2C_DAT_Pos)) + +/** + * @brief I2C Data Read + * @param __I2C__ Specifies I2C peripheral + * @return read data + */ +#define __LL_I2C_DAT_Read(__I2C__) (READ_BIT((__I2C__)->DCMD, I2C_DAT_Msk) >> I2C_DAT_Pos) + +/** + * @brief I2C timing start and send 8b address + * @param __I2C__ Specifies I2C peripheral + * @param addr_8b 8b address + * @return None + */ +#define __LL_I2C_Timing_RestartAddr8b(__I2C__, addr_8b) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | ((addr_8b & 0xffUL) << I2C_DAT_Pos)); \ + } while(0) + +/** + * @brief I2C timing restart and send 16b address + * @param __I2C__ Specifies I2C peripheral + * @param addr_16b 16b address + * @return None + */ +#define __LL_I2C_Timing_RestartAddr16b(__I2C__, addr_16b) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | (((addr_16b >> 8) & 0xffUL) << I2C_DAT_Pos)); \ + WRITE_REG((__I2C__)->DCMD, ((addr_16b & 0xffUL) << I2C_DAT_Pos)); \ + } while(0) + +/** + * @brief I2C timing restart and send 32b address + * @param __I2C__ Specifies I2C peripheral + * @param addr_32b 32b address + * @return None + */ +#define __LL_I2C_Timing_RestartAddr32b(__I2C__, addr_32b) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | (((addr_32b >> 24) & 0xffUL) << I2C_DAT_Pos)); \ + WRITE_REG((__I2C__)->DCMD, (((addr_32b >> 16) & 0xffUL) << I2C_DAT_Pos)); \ + WRITE_REG((__I2C__)->DCMD, (((addr_32b >> 8) & 0xffUL) << I2C_DAT_Pos)); \ + WRITE_REG((__I2C__)->DCMD, ((addr_32b & 0xffUL) << I2C_DAT_Pos)); \ + } while(0) + +/** + * @brief I2C timing restart read stop + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Timing_RestartReadStop(__I2C__) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | I2C_CMD_READ | I2C_STOP_Msk); \ + } while(0) + +/** + * @brief I2C timing restart read + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Timing_RestartRead(__I2C__) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | I2C_CMD_READ); \ + } while(0) + +/** + * @brief I2C timing read + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Timing_Read(__I2C__) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_CMD_READ); \ + } while(0) + +/** + * @brief I2C timing read stop + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Timing_ReadStop(__I2C__) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_CMD_READ | I2C_STOP_Msk); \ + } while(0) + +/** + * @brief I2C timing write + * @param __I2C__ Specifies I2C peripheral + * @param dat write data + * @return None + */ +#define __LL_I2C_Timing_Write(__I2C__, dat) \ + do { \ + WRITE_REG((__I2C__)->DCMD, (((dat) & 0xffUL) << I2C_DAT_Pos)); \ + } while(0) + +/** + * @brief I2C timing restart write + * @param __I2C__ Specifies I2C peripheral + * @param dat write data + * @return None + */ +#define __LL_I2C_Timing_RestartWrite(__I2C__, dat) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | (((dat) & 0xffUL) << I2C_DAT_Pos)); \ + } while(0) + + +/** + * @brief I2C timing write stop + * @param __I2C__ Specifies I2C peripheral + * @param dat write data + * @return None + */ +#define __LL_I2C_Timing_WriteStop(__I2C__, dat) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_STOP_Msk | (((dat) & 0xffUL) << I2C_DAT_Pos)); \ + } while(0) + +/** + * @brief I2C timing restart write stop + * @param __I2C__ Specifies I2C peripheral + * @param dat write data + * @return None + */ +#define __LL_I2C_Timing_RestartWriteStop(__I2C__, dat) \ + do { \ + WRITE_REG((__I2C__)->DCMD, I2C_RESTART_Msk | I2C_STOP_Msk | (((dat) & 0xffUL) << I2C_DAT_Pos)); \ + } while(0) + + +/** + * @brief I2C SS SCL High Count Set + * @param __I2C__ Specifies I2C peripheral + * @param cnt I2C SS SCL High Count + * @return None + */ +#define __LL_I2C_SS_SCLHcnt_Set(__I2C__, cnt) \ + MODIFY_REG((__I2C__)->SSHCNT, I2C_SS_SCL_HCNT_Msk, ((cnt & 0xffffUL) << I2C_SS_SCL_HCNT_Pos)) + + +/** + * @brief I2C SS SCL Low Count Set + * @param __I2C__ Specifies I2C peripheral + * @param cnt I2C SS SCL Low Count + * @return None + */ +#define __LL_I2C_SS_SCLLcnt_Set(__I2C__, cnt) \ + MODIFY_REG((__I2C__)->SSLCNT, I2C_SS_SCL_LCNT_Msk, ((cnt & 0xffffUL) << I2C_SS_SCL_LCNT_Pos)) + + +/** + * @brief I2C FS SCL High Count Set + * @param __I2C__ Specifies I2C peripheral + * @param cnt I2C FS SCL High Count + * @return None + */ +#define __LL_I2C_FS_SCLHcnt_Set(__I2C__, cnt) \ + MODIFY_REG((__I2C__)->FSHCNT, I2C_FS_SCL_HCNT_Msk, ((cnt & 0xffffUL) << I2C_FS_SCL_HCNT_Pos)) + + +/** + * @brief I2C FS SCL Low Count Set + * @param __I2C__ Specifies I2C peripheral + * @param cnt I2C FS SCL Low Count + * @return None + */ +#define __LL_I2C_FS_SCLLcnt_Set(__I2C__, cnt) \ + MODIFY_REG((__I2C__)->FSLCNT, I2C_FS_SCL_LCNT_Msk, ((cnt & 0xffffUL) << I2C_FS_SCL_LCNT_Pos)) + + +/** + * @brief Judge SCL Stuck at Low or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SCL isn't Stuck at Low + * @retval 1 SCL is Stuck at Low + */ +#define __LL_I2C_IsSCLStuckAtLow(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_SCL_STK_AT_LOW_INT_STA_Msk) >> I2C_SCL_STK_AT_LOW_INT_STA_Pos) + +/** + * @brief Judge Master On Hold or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Master isn't On Hold + * @retval 1 Master is On Hold + */ +#define __LL_I2C_MST_IsOnHold(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_MST_ON_HOLD_INT_STA_Msk) >> I2C_MST_ON_HOLD_INT_STA_Pos) + +/** + * @brief Judge Slave is Restart Detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave isn't Restart Detect + * @retval 1 Slave is Restart Detect + */ +#define __LL_I2C_SLV_IsRestartDet(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_RESTART_DET_INT_STA_Msk) >> I2C_RESTART_DET_INT_STA_Pos) + +/** + * @brief Judge Slave Genaral Call or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't Genaral Call + * @retval 1 Is Genaral Call + */ +#define __LL_I2C_SLV_IsGenCall(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_GEN_CALL_INT_STA_Msk) >> I2C_GEN_CALL_INT_STA_Pos) + +/** + * @brief Judge Start Detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't start detect + * @retval 1 Is start detect + */ +#define __LL_I2C_IsStartDet(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_START_DET_INT_STA_Msk) >> I2C_START_DET_INT_STA_Pos) + +/** + * @brief Judge Stop Detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't stop detect + * @retval 1 Is stop detect + */ +#define __LL_I2C_IsStopDet(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_STOP_DET_INT_STA_Msk) >> I2C_STOP_DET_INT_STA_Pos) + +/** + * @brief Judge I2C Activity or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 I2C isn't activity + * @retval 1 I2C is activity + */ +#define __LL_I2C_IsActivityInt(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_ACTIVITY_INT_STA_Msk) >> I2C_ACTIVITY_INT_STA_Pos) + +/** + * @brief Judge Slave RX Done or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave isn't RX Done + * @retval 1 Slave is RX Done + */ +#define __LL_I2C_SLV_IsRxDone(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_RX_DONE_INT_STA_Msk) >> I2C_RX_DONE_INT_STA_Pos) + +/** + * @brief Judge TX Abort or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't TX Abort + * @retval 1 Is TX Abort + */ +#define __LL_I2C_IsTxAbort(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_TX_ABRT_INT_STA_Msk) >> I2C_TX_ABRT_INT_STA_Pos) + +/** + * @brief Judge Slave Read Request or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave isn't Read Request + * @retval 1 Slave is Read Request + */ +#define __LL_I2C_SLV_IsReadReq(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_RD_REQ_INT_STA_Msk) >> I2C_RD_REQ_INT_STA_Pos) + +/** + * @brief Judge TX Empty or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't TX Empty + * @retval 1 Is TX Empty + */ +#define __LL_I2C_IsTxEmpty(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_TX_EMPTY_INT_STA_Msk) >> I2C_TX_EMPTY_INT_STA_Pos) + +/** + * @brief Judge TX Over or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't TX Over + * @retval 1 Is TX Over + */ +#define __LL_I2C_IsTxOver(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_TX_OVER_INT_STA_Msk) >> I2C_TX_OVER_INT_STA_Pos) + +/** + * @brief Judge RX Full or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't RX Full + * @retval 1 Is RX Full + */ +#define __LL_I2C_IsRxFull(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_RX_FULL_INT_STA_Msk) >> I2C_RX_FULL_INT_STA_Pos) + +/** + * @brief Judge RX Over or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't RX Over + * @retval 1 Is RX Over + */ +#define __LL_I2C_IsRxOver(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_RX_OVER_INT_STA_Msk) >> I2C_RX_OVER_INT_STA_Pos) + +/** + * @brief Judge RX Under or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't RX Under + * @retval 1 Is RX Under + */ +#define __LL_I2C_IsRxUnder(__I2C__) \ + (READ_BIT((__I2C__)->INTRST, I2C_RX_UNDER_INT_STA_Msk) >> I2C_RX_UNDER_INT_STA_Pos) + +/** + * @brief I2C interrupt status get + * @param __I2C__ Specifies I2C peripheral + * @return I2C interrupt status + */ +#define __LL_I2C_IntSta_Get(__I2C__) (READ_REG((__I2C__)->INTRST)) + +/** + * @brief I2C SCL Stuck at low Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SCLStuckAtLow_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_SCL_STK_AT_LOW_INT_EN_Msk) + +/** + * @brief I2C SCL Stuck at low Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SCLStuckAtLow_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_SCL_STK_AT_LOW_INT_EN_Msk) + +/** + * @brief I2C Master on hold Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_OnHold_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_MST_ON_HOLD_INT_EN_Msk) + +/** + * @brief I2C Master on hold Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_OnHold_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_MST_ON_HOLD_INT_EN_Msk) + +/** + * @brief I2C Slave Restart Detect Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_RestartDet_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RESTART_DET_INT_EN_Msk) + +/** + * @brief I2C Slave Restart Detect Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_RestartDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RESTART_DET_INT_EN_Msk) + +/** + * @brief I2C Slave Genaral Call Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_GenCall_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_GEN_CALL_INT_EN_Msk) + +/** + * @brief I2C Slave Genaral Call Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_GenCall_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_GEN_CALL_INT_EN_Msk) + +/** + * @brief I2C Start Detect Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_StartDet_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_START_DET_INT_EN_Msk) + +/** + * @brief I2C Start Detect Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_StartDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_START_DET_INT_EN_Msk) + +/** + * @brief I2C Stop Detect Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_StopDet_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_STOP_DET_INT_EN_Msk) + +/** + * @brief I2C Stop Detect Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_StopDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_STOP_DET_INT_EN_Msk) + +/** + * @brief I2C Activity Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Activity_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_ACTIVITY_INT_EN_Msk) + +/** + * @brief I2C Activity Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Activity_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_ACTIVITY_INT_EN_Msk) + +/** + * @brief I2C Slave RX Done Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_RxDone_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_DONE_INT_EN_Msk) + +/** + * @brief I2C Slave RX Done Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_RxDone_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_DONE_INT_EN_Msk) + +/** + * @brief I2C TX Abort Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxAbort_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_TX_ABRT_INT_EN_Msk) + +/** + * @brief I2C TX Abort Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxAbort_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_TX_ABRT_INT_EN_Msk) + +/** + * @brief I2C Slave Read Request Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_ReadReq_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RD_REQ_INT_EN_Msk) + +/** + * @brief I2C Slave Read Request Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_ReadReq_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RD_REQ_INT_EN_Msk) + +/** + * @brief I2C TX Empty Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxEmpty_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_TX_EMPTY_INT_EN_Msk) + +/** + * @brief I2C TX Empty Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxEmpty_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_TX_EMPTY_INT_EN_Msk) + +/** + * @brief I2C TX Over Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxOver_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_TX_OVER_INT_EN_Msk) + +/** + * @brief I2C TX Over Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxOver_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_TX_OVER_INT_EN_Msk) + +/** + * @brief I2C RX Full Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxFull_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_FULL_INT_EN_Msk) + +/** + * @brief I2C RX Full Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxFull_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_FULL_INT_EN_Msk) + +/** + * @brief I2C RX Over Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxOver_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_OVER_INT_EN_Msk) + +/** + * @brief I2C RX Over Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxOver_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_OVER_INT_EN_Msk) + +/** + * @brief I2C RX Under Interrupt Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxUnder_INT_En(__I2C__) SET_BIT((__I2C__)->INTRMS, I2C_RX_UNDER_INT_EN_Msk) + +/** + * @brief I2C RX Under Interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxUnder_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->INTRMS, I2C_RX_UNDER_INT_EN_Msk) + + +/** + * @brief Judge SCL Stuck at Low Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SCL isn't Stuck at Low + * @retval 1 SCL is Stuck at Low + */ +#define __LL_I2C_IsSCLStuckAtLow_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_SCL_STK_AT_LOW_RAW_INT_STA_Msk) >> I2C_SCL_STK_AT_LOW_RAW_INT_STA_Pos) + +/** + * @brief Judge Master On Hold Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Master isn't On Hold + * @retval 1 Master is On Hold + */ +#define __LL_I2C_MST_IsOnHold_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_MST_ON_HOLD_RAW_INT_STA_Msk) >> I2C_MST_ON_HOLD_RAW_INT_STA_Pos) + +/** + * @brief Judge Slave is Restart Detect Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave isn't Restart Detect + * @retval 1 Slave is Restart Detect + */ +#define __LL_I2C_SLV_IsRestartDet_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_RESTART_DET_RAW_INT_STA_Msk) >> I2C_RESTART_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge Slave Genaral Call Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't Genaral Call + * @retval 1 Is Genaral Call + */ +#define __LL_I2C_SLV_IsGenCall_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_GEN_CALL_RAW_INT_STA_Msk) >> I2C_GEN_CALL_RAW_INT_STA_Pos) + +/** + * @brief Judge Start Detect Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't start detect + * @retval 1 Is start detect + */ +#define __LL_I2C_IsStartDet_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_START_DET_RAW_INT_STA_Msk) >> I2C_START_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge Stop Detect Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't stop detect + * @retval 1 Is stop detect + */ +#define __LL_I2C_IsStopDet_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_STOP_DET_RAW_INT_STA_Msk) >> I2C_STOP_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge I2C Activity Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 I2C isn't activity + * @retval 1 I2C is activity + */ +#define __LL_I2C_IsActivity_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_ACTIVITY_RAW_INT_STA_Msk) >> I2C_ACTIVITY_RAW_INT_STA_Pos) + +/** + * @brief Judge Slave RX Done Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave isn't RX Done + * @retval 1 Slave is RX Done + */ +#define __LL_I2C_SLV_IsRxDone_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_RX_DONE_RAW_INT_STA_Msk) >> I2C_RX_DONE_RAW_INT_STA_Pos) + +/** + * @brief Judge TX Abort Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't TX Abort + * @retval 1 Is TX Abort + */ +#define __LL_I2C_IsTxAbort_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_TX_ABRT_RAW_INT_STA_Msk) >> I2C_TX_ABRT_RAW_INT_STA_Pos) + +/** + * @brief Judge Slave Read Request Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave isn't Read Request + * @retval 1 Slave is Read Request + */ +#define __LL_I2C_SLV_IsReadReq_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_RD_REQ_RAW_INT_STA_Msk) >> I2C_RD_REQ_RAW_INT_STA_Pos) + +/** + * @brief Judge TX Empty Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't TX Empty + * @retval 1 Is TX Empty + */ +#define __LL_I2C_IsTxEmpty_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_TX_EMPTY_RAW_INT_STA_Msk) >> I2C_TX_EMPTY_RAW_INT_STA_Pos) + +/** + * @brief Judge TX Over Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't TX Over + * @retval 1 Is TX Over + */ +#define __LL_I2C_IsTxOver_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_TX_OVER_RAW_INT_STA_Msk) >> I2C_TX_OVER_RAW_INT_STA_Pos) + +/** + * @brief Judge RX Full Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't RX Full + * @retval 1 Is RX Full + */ +#define __LL_I2C_IsRxFull_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_RX_FULL_RAW_INT_STA_Msk) >> I2C_RX_FULL_RAW_INT_STA_Pos) + +/** + * @brief Judge RX Over Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't RX Over + * @retval 1 Is RX Over + */ +#define __LL_I2C_IsRxOver_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_RX_OVER_RAW_INT_STA_Msk) >> I2C_RX_OVER_RAW_INT_STA_Pos) + +/** + * @brief Judge RX Under Raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't RX Under + * @retval 1 Is RX Under + */ +#define __LL_I2C_IsRxUnder_Raw(__I2C__) \ + (READ_BIT((__I2C__)->RINTRST, I2C_RX_UNDER_RAW_INT_STA_Msk) >> I2C_RX_UNDER_RAW_INT_STA_Pos) + + +/** + * @brief I2C RX Trigger Level Set + * @param __I2C__ Specifies I2C peripheral + * @param tl RX Trigger Level + * @return None + */ +#define __LL_I2C_RxTL_Set(__I2C__, tl) MODIFY_REG((__I2C__)->RXTL, I2C_RX_TL_Msk, (((tl-1) & 0xffUL) << I2C_RX_TL_Pos)) + +/** + * @brief I2C TX Trigger Level Set + * @param __I2C__ Specifies I2C peripheral + * @param tl TX Trigger Level + * @return None + */ +#define __LL_I2C_TxTL_Set(__I2C__, tl) MODIFY_REG((__I2C__)->TXTL, I2C_TX_TL_Msk, (((tl-1) & 0xffUL) << I2C_TX_TL_Pos)) + + +/** + * @brief I2C Soft Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_SoftIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->INTRCR, I2C_CLR_INT_Msk) >> I2C_CLR_INT_Pos) + + +/** + * @brief I2C RX Under Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_RxUnderRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RXUNCR, I2C_CLR_RX_UNDER_Msk) >> I2C_CLR_RX_UNDER_Pos) + + +/** + * @brief I2C RX Over Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_RxOverRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RXOVCR, I2C_CLR_RX_OVER_Msk) >> I2C_CLR_RX_OVER_Pos) + + +/** + * @brief I2C TX Over Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_TxOverRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->TXOVCR, I2C_CLR_TX_OVER_Msk) >> I2C_CLR_TX_OVER_Pos) + + +/** + * @brief I2C Slave Read Request Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_SLV_ReadReqRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RDREQCR, I2C_CLR_RD_REQ_Msk) >> I2C_CLR_RD_REQ_Pos) + + +/** + * @brief I2C TX Abort Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_TxAbortRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->TXABCR, I2C_CLR_TX_ABRT_Msk) >> I2C_CLR_TX_ABRT_Pos) + + +/** + * @brief I2C Slave RX Done Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_SLV_RxDoneRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->RXDOCR, I2C_CLR_RX_DONE_Msk) >> I2C_CLR_RX_DONE_Pos) + + +/** + * @brief I2C Activity Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_ActivityRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->ACTICR, I2C_CLR_ACTIVITY_Msk) >> I2C_CLR_ACTIVITY_Pos) + + +/** + * @brief I2C Stop Detect Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_StopDetRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->SPDETCR, I2C_CLR_STOP_DET_Msk) >> I2C_CLR_STOP_DET_Pos) + + +/** + * @brief I2C Start Detect Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_StartDetRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->STDETCR, I2C_CLR_START_DET_Msk) >> I2C_CLR_START_DET_Pos) + + +/** + * @brief I2C Slave Genaral Call Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_SLV_GenCallRawIntSta_Clr(__I2C__) (READ_BIT((__I2C__)->GCCR, I2C_CLR_GEN_CALL_Msk) >> I2C_CLR_GEN_CALL_Pos) + + +/** + * @brief I2C SMBUS Alert Enable Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_AlertEn_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SMBUS_ALERT_EN_Msk) + +/** + * @brief I2C SMBUS Alert Enable Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_AlertEn_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_SMBUS_ALERT_EN_Msk) + +/** + * @brief I2C SMBUS Suspend Enable Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SuspendEn_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SMBUS_SUSPEND_EN_Msk) + +/** + * @brief I2C SMBUS Suspend Enable Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SuspendEn_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_SMBUS_SUSPEND_EN_Msk) + +/** + * @brief I2C SMBUS CLK Reset Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ClkReset_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SMBUS_CLK_RESET_Msk) + +/** + * @brief I2C SMBUS CLK Reset Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ClkReset_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_SMBUS_CLK_RESET_Msk) + +/** + * @brief I2C SDA Stuck Recovery Enable Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SDAStuckRecoveryEn_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_SDA_STK_RECOVERY_EN_Msk) + +/** + * @brief I2C Master TX Cmd Block Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_TxCmdBlock_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_TX_CMD_BLOCK_Msk) + +/** + * @brief I2C Master TX Cmd Block Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_TxCmdBlock_Clr(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_TX_CMD_BLOCK_Msk) + +/** + * @brief I2C Master Abort Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_MST_Abort_Set(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_ABORT_Msk) + +/** + * @brief I2C Module Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Enable(__I2C__) SET_BIT((__I2C__)->ENABLE, I2C_ENABLE_Msk) + +/** + * @brief I2C Module Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_Disable(__I2C__) CLEAR_BIT((__I2C__)->ENABLE, I2C_ENABLE_Msk) + + +/** + * @brief Judge SMBUS Alert Status or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't alert status + * @retval 1 Is alert status + */ +#define __LL_I2C_SMBUS_IsAlertSta(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_ALERT_STATUS_Msk) >> I2C_SMBUS_ALERT_STATUS_Pos) + +/** + * @brief Judge SMBUS Suspend Status or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't Suspend status + * @retval 1 Is Suspend status + */ +#define __LL_I2C_SMBUS_IsSuspendSta(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_SUSPEND_STATUS_Msk) >> I2C_SMBUS_SUSPEND_STATUS_Pos) + +/** + * @brief Judge SMBUS Slave Address Resolved or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS Slave Address Isn't Resolved + * @retval 1 SMBUS Slave Address Is Resolved + */ +#define __LL_I2C_SMBUS_IsSlvAddrResolved(__I2C__) \ + (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_SLV_ADDR_RESOLVED_Msk) >> I2C_SMBUS_SLV_ADDR_RESOLVED_Pos) + +/** + * @brief Judge SMBUS Slave Address Valid or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS Slave Address Isn't Valid + * @retval 1 SMBUS Slave Address Is Valid + */ +#define __LL_I2C_SMBUS_IsSlvAddrValid(__I2C__) \ + (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_SLV_ADDR_VALID_Msk) >> I2C_SMBUS_SLV_ADDR_VALID_Pos) + +/** + * @brief I2C SMBUS Quick Cmd Bit + * @param __I2C__ Specifies I2C peripheral + * @return SMBUS Quick Cmd Bit(R/W) + */ +#define __LL_I2C_SMBUS_QuickCmdBit(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SMBUS_QUICK_CMD_BIT_Msk) >> I2C_SMBUS_QUICK_CMD_BIT_Pos) + +/** + * @brief Judge SDA Stuck No Recovered or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SDA Stuck has Recovered + * @retval 1 SDA Stuck hasn't Recovered + */ +#define __LL_I2C_IsSDAStuckNoRecovered(__I2C__) \ + (READ_BIT((__I2C__)->STATUS, I2C_SDA_STUCK_NOT_RECOVERED_Msk) >> I2C_SDA_STUCK_NOT_RECOVERED_Pos) + +/** + * @brief Judge Slave Hold RX FIFO Full or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave Isn't Holding RX FIFO Full + * @retval 1 Slave Is Holding RX FIFO Full + */ +#define __LL_I2C_SLV_IsHoldRxFIFOFull(__I2C__) \ + (READ_BIT((__I2C__)->STATUS, I2C_SLV_HOLD_RX_FIFO_FULL_Msk) >> I2C_SLV_HOLD_RX_FIFO_FULL_Pos) + +/** + * @brief Judge Slave Hold Tx FIFO Empty or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave Isn't Holding Tx FIFO Empty + * @retval 1 Slave Is Holding Tx FIFO Empty + */ +#define __LL_I2C_SLV_IsHoldTxFIFOEmpty(__I2C__) \ + (READ_BIT((__I2C__)->STATUS, I2C_SLV_HOLD_TX_FIFO_EMPTY_Msk) >> I2C_SLV_HOLD_TX_FIFO_EMPTY_Pos) + +/** + * @brief Judge Master Hold RX FIFO Full or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Master Isn't Holding RX FIFO Full + * @retval 1 Master Is Holding RX FIFO Full + */ +#define __LL_I2C_MST_IsHoldRxFIFOFull(__I2C__) \ + (READ_BIT((__I2C__)->STATUS, I2C_MST_HOLD_RX_FIFO_FULL_Msk) >> I2C_MST_HOLD_RX_FIFO_FULL_Pos) + +/** + * @brief Judge Master Hold Tx FIFO Empty or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Master Isn't Holding Tx FIFO Empty + * @retval 1 Master Is Holding Tx FIFO Empty + */ +#define __LL_I2C_MST_IsHoldTxFIFOEmpty(__I2C__) \ + (READ_BIT((__I2C__)->STATUS, I2C_MST_HOLD_TX_FIFO_EMPTY_Msk) >> I2C_MST_HOLD_TX_FIFO_EMPTY_Pos) + +/** + * @brief Judge Slave Activity or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave Isn't Activity + * @retval 1 Slave Is Activity + */ +#define __LL_I2C_SLV_IsActivity(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_SLV_ACTIVITY_Msk) >> I2C_SLV_ACTIVITY_Pos) + +/** + * @brief Judge Master Activity or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Master Isn't Activity + * @retval 1 Master Is Activity + */ +#define __LL_I2C_MST_IsActivity(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_MST_ACTIVITY_Msk) >> I2C_MST_ACTIVITY_Pos) + +/** + * @brief Judge RXFIFO Full Entirely or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 RXFIFO isn't full Entirely + * @retval 1 RXFIFO is full Entirely + */ +#define __LL_I2C_IsRxFIFOFull(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_RFF_Msk) >> I2C_RFF_Pos) + +/** + * @brief Judge RXFIFO Not Empty or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 RXFIO is empty + * @retval 1 RXFIO isn't empty + */ +#define __LL_I2C_IsRxFIFONotEmpty(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_RFNE_Msk) >> I2C_RFNE_Pos) + +/** + * @brief Judge TXFIFO Empty or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 TXFIFO isn't empty + * @retval 1 TXFIFO is empty + */ +#define __LL_I2C_IsTxFIFOEmpty(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_TFE_Msk) >> I2C_TFE_Pos) + +/** + * @brief Judge TXFIFO Not Full or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 TXFIFO is Full + * @retval 1 TXFIFO isn't Full + */ +#define __LL_I2C_IsTxFIFONotFull(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_TFNF_Msk) >> I2C_TFNF_Pos) + +/** + * @brief Judge I2C Activity or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 I2C isn't activity + * @retval 1 I2C is activity + */ +#define __LL_I2C_IsActivitySta(__I2C__) (READ_BIT((__I2C__)->STATUS, I2C_ACTIVITY_Msk) >> I2C_ACTIVITY_Pos) + + +/** + * @brief I2C TXFIFO Level Get + * @param __I2C__ Specifies I2C peripheral + * @return TXFIFO Level + */ +#define __LL_I2C_TxFIFOLevel_Get(__I2C__) (READ_BIT((__I2C__)->TXFLR, I2C_TXFLR_Msk) >> I2C_TXFLR_Pos) + + +/** + * @brief I2C RXFIFO Level Get + * @param __I2C__ Specifies I2C peripheral + * @return RXFIFO Level + */ +#define __LL_I2C_RxFIFOLevel_Get(__I2C__) (READ_BIT((__I2C__)->RXFLR, I2C_RXFLR_Msk) >> I2C_RXFLR_Pos) + + +/** + * @brief I2C SDA RX Hold Set + * @param __I2C__ Specifies I2C peripheral + * @param hld SDA RX Hold + * @return None + */ +#define __LL_I2C_SDARxHold_Set(__I2C__, hld) \ + MODIFY_REG((__I2C__)->SDA_HOLD, I2C_SDA_RX_HOLD_Msk, ((hld & 0xffUL) << I2C_SDA_RX_HOLD_Pos)) + +/** + * @brief I2C SDA TX Hold Set + * @param __I2C__ Specifies I2C peripheral + * @param hld SDA TX Hold + * @return None + */ +#define __LL_I2C_SDATxHold_Set(__I2C__, hld) \ + MODIFY_REG((__I2C__)->SDA_HOLD, I2C_SDA_TX_HOLD_Msk, ((hld & 0xffffUL) << I2C_SDA_TX_HOLD_Pos)) + + +/** + * @brief I2C TX Flush Count Get + * @param __I2C__ Specifies I2C peripheral + * @return TX Flush Count + */ +#define __LL_I2C_TxFlushCnt_Get(__I2C__) (READ_BIT((__I2C__)->TXABSR, I2C_TX_FLUSH_CNT_Msk) >> I2C_TX_FLUSH_CNT_Pos) + +/** + * @brief Judge Master Abort Source Device Write or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Device Write + * @retval 1 Abort Source Is Device Write + */ +#define __LL_I2C_MST_AbortSrc_IsDevWrite(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_DEV_WRITE_Msk) >> I2C_ABRT_DEV_WRITE_Pos) + +/** + * @brief Judge Master Abort Source Device Slave Address No ACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Device Slave Address No ACK + * @retval 1 Abort Source Is Device Slave Address No ACK + */ +#define __LL_I2C_MST_AbortSrc_IsDevSlvAddrNoAck(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_DEV_SLV_ADDR_NOACK_Msk) >> I2C_ABRT_DEV_SLV_ADDR_NOACK_Pos) + +/** + * @brief Judge Master Abort Source Device No ACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Device No ACK + * @retval 1 Abort Source Is Device No ACK + */ +#define __LL_I2C_MST_AbortSrc_IsDevNoAck(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_DEV_NOACK_Msk) >> I2C_ABRT_DEV_NOACK_Pos) + +/** + * @brief Judge Master Abort Source SDA Stuck at Low or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't SDA Stuck at Low + * @retval 1 Abort Source Is SDA Stuck at Low + */ +#define __LL_I2C_MST_AbortSrc_IsSDAStuckAtLow(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SDA_STUCK_AT_LOW_Msk) >> I2C_ABRT_SDA_STUCK_AT_LOW_Pos) + +/** + * @brief Judge Master Abort Source User Abort or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't User Abort + * @retval 1 Abort Source Is User Abort + */ +#define __LL_I2C_MST_AbortSrc_IsUserAbort(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_USER_ABRT_Msk) >> I2C_ABRT_USER_ABRT_Pos) + +/** + * @brief Judge Slave Abort Source Slave Read In TX or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Slave Read In TX + * @retval 1 Abort Source Is Slave Read In TX + */ +#define __LL_I2C_SLV_AbortSrc_IsSlvReadInTx(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SLVRD_INTX_Msk) >> I2C_ABRT_SLVRD_INTX_Pos) + +/** + * @brief Judge Slave Abort Source Slave Lost Bus or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Slave Lost Bus + * @retval 1 Abort Source Is Slave Lost Bus + */ +#define __LL_I2C_SLV_AbortSrc_IsSlvLostBus(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SLV_ARBLOST_Msk) >> I2C_ABRT_SLV_ARBLOST_Pos) + +/** + * @brief Judge Slave Abort Source Slave Flush TXFIFO or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Slave Flush TXFIFO + * @retval 1 Abort Source Is Slave Flush TXFIFO + */ +#define __LL_I2C_SLV_AbortSrc_IsSlvFlushTxFIFO(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SLVFLUSH_TXFIFO_Msk) >> I2C_ABRT_SLVFLUSH_TXFIFO_Pos) + +/** + * @brief Judge Abort Source ARB Lost or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't ARB Lost + * @retval 1 Abort Source Is ARB Lost + */ +#define __LL_I2C_AbortSrc_IsArbLost(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ARB_LOST_Msk) >> I2C_ARB_LOST_Pos) + +/** + * @brief Judge Abort Source Master Disable or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Master Disable + * @retval 1 Abort Source Is Master Disable + */ +#define __LL_I2C_AbortSrc_IsMasterDis(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_MASTER_DIS_Msk) >> I2C_ABRT_MASTER_DIS_Pos) + +/** + * @brief Judge Master Abort Source 10bit Read No Restart or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't 10bit Read No Restart + * @retval 1 Abort Source Is 10bit Read No Restart + */ +#define __LL_I2C_MST_AbortSrc_Is10bReadNoRestart(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_10B_RD_NORSTRT_Msk) >> I2C_ABRT_10B_RD_NORSTRT_Pos) + +/** + * @brief Judge Master Abort Source Send Start No Restart or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Send Start No Restart + * @retval 1 Abort Source Is Send Start No Restart + */ +#define __LL_I2C_MST_AbortSrc_IsSendStartNoRestart(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SBYTE_NORSTRT_Msk) >> I2C_ABRT_SBYTE_NORSTRT_Pos) + +/** + * @brief Judge Master Abort Source HS No Restart or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't HS No Restart + * @retval 1 Abort Source Is HS No Restart + */ +#define __LL_I2C_MST_AbortSrc_IsHsNoRestart(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_HS_NORSTRT_Msk) >> I2C_ABRT_HS_NORSTRT_Pos) + +/** + * @brief Judge Master Abort Source Send Start ACK Detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Send Start ACK Detect + * @retval 1 Abort Source Is Send Start ACK Detect + */ +#define __LL_I2C_MST_AbortSrc_IsSendStartAckDet(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_SBYTE_ACKDET_Msk) >> I2C_ABRT_SBYTE_ACKDET_Pos) + +/** + * @brief Judge Master Abort Source HS ACK Detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't HS ACK Detect + * @retval 1 Abort Source Is HS ACK Detect + */ +#define __LL_I2C_MST_AbortSrc_IsHsAckDet(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_HS_ACKDET_Msk) >> I2C_ABRT_HS_ACKDET_Pos) + +/** + * @brief Judge Master Abort Source Genaral Call Read or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Genaral Call Read + * @retval 1 Abort Source Is Genaral Call Read + */ +#define __LL_I2C_MST_AbortSrc_IsGenCallRead(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_GCALL_READ_Msk) >> I2C_ABRT_GCALL_READ_Pos) + +/** + * @brief Judge Master Abort Source Genaral Call No ACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't Genaral Call No ACK + * @retval 1 Abort Source Is Genaral Call No ACK + */ +#define __LL_I2C_MST_AbortSrc_IsGenCallNoAck(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_GCALL_NOACK_Msk) >> I2C_ABRT_GCALL_NOACK_Pos) + +/** + * @brief Judge Master Abort Source TX Data No ACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't TX Data No ACK + * @retval 1 Abort Source Is TX Data No ACK + */ +#define __LL_I2C_MST_AbortSrc_IsTxDataNoAck(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_TXDATA_NOACK_Msk) >> I2C_ABRT_TXDATA_NOACK_Pos) + +/** + * @brief Judge Master Abort Source 10b Address 2 No ACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't 10b Address 2 No ACK + * @retval 1 Abort Source Is 10b Address 2 No ACK + */ +#define __LL_I2C_MST_AbortSrc_Is10bAddr2NoAck(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_10ADDR2_NOACK_Msk) >> I2C_ABRT_10ADDR2_NOACK_Pos) + +/** + * @brief Judge Master Abort Source 10b Address 1 No ACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't 10b Address 1 No ACK + * @retval 1 Abort Source Is 10b Address 1 No ACK + */ +#define __LL_I2C_MST_AbortSrc_Is10bAddr1NoAck(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_10ADDR1_NOACK_Msk) >> I2C_ABRT_10ADDR1_NOACK_Pos) + +/** + * @brief Judge Master Abort Source 7b Address No ACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Abort Source Isn't 7b Address No ACK + * @retval 1 Abort Source Is 7b Address No ACK + */ +#define __LL_I2C_MST_AbortSrc_Is7bAddrNoAck(__I2C__) \ + (READ_BIT((__I2C__)->TXABSR, I2C_ABRT_7B_ADDR_NOACK_Msk) >> I2C_ABRT_7B_ADDR_NOACK_Pos) + + +/** + * @brief I2C Slave Force Data No ACK Set + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_ForceDataNoAck_Set(__I2C__) SET_BIT((__I2C__)->NACKEN, I2C_SLV_DATA_NACK_Msk) + +/** + * @brief I2C Slave Force Data No ACK Clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SLV_ForceDataNoAck_Clr(__I2C__) CLEAR_BIT((__I2C__)->NACKEN, I2C_SLV_DATA_NACK_Msk) + + +/** + * @brief I2C TX DMA Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxDMA_En(__I2C__) SET_BIT((__I2C__)->DMACT, I2C_DMA_TDMAE_Msk) + +/** + * @brief I2C TX DMA Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_TxDMA_Dis(__I2C__) CLEAR_BIT((__I2C__)->DMACT, I2C_DMA_TDMAE_Msk) + +/** + * @brief I2C RX DMA Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxDMA_En(__I2C__) SET_BIT((__I2C__)->DMACT, I2C_DMA_RDMAE_Msk) + +/** + * @brief I2C RX DMA Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_RxDMA_Dis(__I2C__) CLEAR_BIT((__I2C__)->DMACT, I2C_DMA_RDMAE_Msk) + + +/** + * @brief I2C TX DMA Trigger Level Set + * @param __I2C__ Specifies I2C peripheral + * @param tl TX DMA Trigger Level + * @return None + */ +#define __LL_I2C_TxDMATriggerLevel_Set(__I2C__, tl) \ + MODIFY_REG((__I2C__)->DMATDLR, I2C_DMA_DMATDL_Msk, ((tl & 0xfUL) << I2C_DMA_DMATDL_Pos)) + + +/** + * @brief I2C RX DMA Trigger Level Set + * @param __I2C__ Specifies I2C peripheral + * @param tl RX DMA Trigger Level + * @return None + */ +#define __LL_I2C_RxDMATriggerLevel_Set(__I2C__, tl) \ + MODIFY_REG((__I2C__)->DMARDLR, I2C_DMA_DMARDL_Msk, (((tl-1) & 0xfUL) << I2C_DMA_DMARDL_Pos)) + + +#define __LL_I2C_SDA_Setup_Set(__I2C__, val) \ + MODIFY_REG((__I2C__)->SDA_SETUP, I2C_SDA_SETUP_Msk, ((val & 0xffUL) << I2C_SDA_SETUP_Pos)) + + +/** + * @brief I2C ACK Genaral Call Enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_AckGenCall_En(__I2C__) SET_BIT((__I2C__)->GCACK, I2C_ACK_GEN_CALL_Msk) + +/** + * @brief I2C ACK Genaral Call Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_AckGenCall_Dis(__I2C__) CLEAR_BIT((__I2C__)->GCACK, I2C_ACK_GEN_CALL_Msk) + + +/** + * @brief Judge Slave RX Data Lost or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Slave Isn't RX Data Lost + * @retval 1 Slave Is RX Data Lost + */ +#define __LL_I2C_SLV_IsRxDataLost(__I2C__) \ + (READ_BIT((__I2C__)->ENST, I2C_SLV_RX_DATA_LOST_Msk) >> I2C_SLV_RX_DATA_LOST_Pos) + +/** + * @brief Judge Slave Disable While Busy or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 Isn't Slave Disable While Busy + * @retval 1 Is Slave Disable While Busy + */ +#define __LL_I2C_SLV_IsSlvDisWhileBusy(__I2C__) \ + (READ_BIT((__I2C__)->ENST, I2C_SLVDIS_WHILEBUSY_Msk) >> I2C_SLVDIS_WHILEBUSY_Pos) + +/** + * @brief Judge I2C Enable or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 I2C Isn't Enable + * @retval 1 I2C Is Enable + */ +#define __LL_I2C_IsEnable(__I2C__) (READ_BIT((__I2C__)->ENST, I2C_EN_Msk) >> I2C_EN_Pos) + + +/** + * @brief I2C FS Spike Lengh Set + * @param __I2C__ Specifies I2C peripheral + * @param len FS Spike Lengh + * @return None + */ +#define __LL_I2C_FsSpkLen_Set(__I2C__, len) \ + MODIFY_REG((__I2C__)->FS_SPKLEN, I2C_FS_SPKLEN_Msk, ((len & 0xffUL) << I2C_FS_SPKLEN_Pos)) + + +/** + * @brief I2C Restart Detect RAW Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_RestartDetRawIntSta_Clr(__I2C__) \ + (READ_BIT((__I2C__)->RSDETCR, I2C_CLR_RESTART_DET_Msk) >> I2C_CLR_RESTART_DET_Pos) + + +/** + * @brief I2C SCL Stuck at Low Timeout Set + * @param __I2C__ Specifies I2C peripheral + * @param val Timeout Value + * @return None + */ +#define __LL_I2C_SCLStuckAtLowTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->SCLLTO,\ + I2C_SCL_STK_LOW_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SCL_STK_LOW_TIMEOUT_Pos)) + + +/** + * @brief I2C SDA Stuck at Low Timeout Set + * @param __I2C__ Specifies I2C peripheral + * @param val Timeout Value + * @return None + */ +#define __LL_I2C_SDAStuckAtLowTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->SDALTO,\ + I2C_SDA_STK_LOW_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SDA_STK_LOW_TIMEOUT_Pos)) + + +/** + * @brief I2C SCL Stuck Detect RAW Interrupt Status Clear + * @param __I2C__ Specifies I2C peripheral + * @return Read Value, not use + */ +#define __LL_I2C_SCLStuckDetRawIntSta_Clr(__I2C__) \ + (READ_BIT((__I2C__)->SSTDETCR, I2C_CLR_SCL_STK_Msk) >> I2C_CLR_SCL_STK_Pos) + + +/** + * @brief I2C Device ID Set + * @param __I2C__ Specifies I2C peripheral + * @param id Device ID + * @return None + */ +#define __LL_I2C_DeviceID_Set(__I2C__, id) MODIFY_REG((__I2C__)->DEVICE_ID, I2C_DEV_ID_Msk, ((id & 0xffffffUL) << I2C_DEV_ID_Pos)) + + +/** + * @brief I2C SMBUS Clock Low Sext Timeout Set + * @param __I2C__ Specifies I2C peripheral + * @param val Timeout Value + * @return None + */ +#define __LL_I2C_SMBUS_ClkLowSextTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->TSEXT,\ + I2C_SMBUS_CLK_LOW_SEXT_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SMBUS_CLK_LOW_SEXT_TIMEOUT_Pos)) + + +/** + * @brief I2C SMBUS Clock Low Mext Timeout Set + * @param __I2C__ Specifies I2C peripheral + * @param val Timeout Value + * @return None + */ +#define __LL_I2C_SMBUS_ClkLowMextTimeout_Set(__I2C__, val) MODIFY_REG((__I2C__)->TMEXT,\ + I2C_SMBUS_CLK_LOW_MEXT_TIMEOUT_Msk, ((val & 0xffffffffUL) << I2C_SMBUS_CLK_LOW_MEXT_TIMEOUT_Pos)) + + +/** + * @brief I2C SMBUS Thigh Max Bus Idle Count Set + * @param __I2C__ Specifies I2C peripheral + * @param cnt Count + * @return None + */ +#define __LL_I2C_SMBUS_ThighMaxBusIdleCnt_Set(__I2C__, cnt) MODIFY_REG((__I2C__)->IDCNT,\ + I2C_SMBUS_THIGH_MAX_BUS_IDLE_CNT_Msk, ((cnt & 0xffffUL) << I2C_SMBUS_THIGH_MAX_BUS_IDLE_CNT_Pos)) + + +/** + * @brief Judge SMBUS is alert detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't alert detect + * @retval 1 SMBUS is alert detect + */ +#define __LL_I2C_SMBUS_IsAlertDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_SMBUS_ALERT_DET_INT_STA_Msk) << I2C_SMBUS_ALERT_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is suspend detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't suspend detect + * @retval 1 SMBUS is suspend detect + */ +#define __LL_I2C_SMBUS_IsSuspendDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_SMBUS_SUSPEND_DET_INT_STA_Msk) << I2C_SMBUS_SUSPEND_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is slave RX PEC NACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't slave RX PEC NACK + * @retval 1 SMBUS is slave RX PEC NACK + */ +#define __LL_I2C_SMBUS_IsSlvRxPecNack(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_SLV_RX_PEC_NACK_INT_STA_Msk) << I2C_SLV_RX_PEC_NACK_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP assgn address cmd detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP assgn address cmd detect + * @retval 1 SMBUS is ARP assgn address cmd detect + */ +#define __LL_I2C_SMBUS_IsARPAssgnAddrCmdDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_ASSGN_ADDR_CMD_DET_INT_STA_Msk) << I2C_ARP_ASSGN_ADDR_CMD_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP get UDID cmd detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP get UDID cmd detect + * @retval 1 SMBUS is ARP get UDID cmd detect + */ +#define __LL_I2C_SMBUS_IsARPGetUdidCmdDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_GET_UDID_CMD_DET_INT_STA_Msk) << I2C_ARP_GET_UDID_CMD_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP reset cmd detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP reset cmd detect + * @retval 1 SMBUS is ARP reset cmd detect + */ +#define __LL_I2C_SMBUS_IsARPRstCmdDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_RST_CMD_DET_INT_STA_Msk) << I2C_ARP_RST_CMD_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP prepare cmd detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP prepare cmd detect + * @retval 1 SMBUS is ARP prepare cmd detect + */ +#define __LL_I2C_SMBUS_IsARPPrepareCmdDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_ARP_PREPARE_CMD_DET_INT_STA_Msk) << I2C_ARP_PREPARE_CMD_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is host nofity mst detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't host nofity mst detect + * @retval 1 SMBUS is host nofity mst detect + */ +#define __LL_I2C_SMBUS_IsHostNotifyMstDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_HOST_NOTIFY_MST_DET_INT_STA_Msk) << I2C_HOST_NOTIFY_MST_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is quick cmd detect or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't quick cmd detect + * @retval 1 SMBUS is quick cmd detect + */ +#define __LL_I2C_SMBUS_IsQuickCmdDet(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_QUICK_CMD_DET_INT_STA_Msk) << I2C_QUICK_CMD_DET_INT_STA_Pos) + +/** + * @brief Judge SMBUS is mst clock extend timeout or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't mst clock extend timeout + * @retval 1 SMBUS is mst clock extend timeout + */ +#define __LL_I2C_SMBUS_IsMstClkExtendTimeout(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_MST_CLK_EXTND_TIMEOUT_INT_STA_Msk) << I2C_MST_CLK_EXTND_TIMEOUT_INT_STA_Pos) + +/** + * @brief Judge SMBUS is slave clock extend timeout or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't slave clock extend timeout + * @retval 1 SMBUS is slave clock extend timeout + */ +#define __LL_I2C_SMBUS_IsSlvClkExtendTimeout(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRST, I2C_SLV_CLK_EXTND_TIMEOUT_INT_STA_Msk) << I2C_SLV_CLK_EXTND_TIMEOUT_INT_STA_Pos) + + +/** + * @brief SMBUS alert detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_AlertDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_ALERT_DET_INT_EN_Msk) + +/** + * @brief SMBUS alert detect interrupt Disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_AlertDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_ALERT_DET_INT_EN_Msk) + +/** + * @brief SMBUS Suspend detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SuspendDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_SUSPEND_DET_INT_EN_Msk) + +/** + * @brief SMBUS Suspend detect interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SuspendDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SMBUS_SUSPEND_DET_INT_EN_Msk) + +/** + * @brief SMBUS slave RX PEC NACK interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvRxPecNack_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SLV_RX_PEC_NACK_INT_EN_Msk) + +/** + * @brief SMBUS slave RX PEC NACK interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvRxPecNack_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SLV_RX_PEC_NACK_INT_EN_Msk) + +/** + * @brief SBMUS ARP assgn addr cmd detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPAssgnAddrCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_ASSGN_ADDR_CMD_DET_INT_EN_Msk) + +/** + * @brief SBMUS ARP assgn addr cmd detect interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPAssgnAddrCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_ASSGN_ADDR_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS ARP get UDID cmd detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPGetUdidCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_GET_UDID_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS ARP get UDID cmd detect interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPGetUdidCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_GET_UDID_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS ARP reset cmd detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPRstCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_RST_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS ARP reset cmd detect interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPRstCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_RST_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS ARP prepare cmd detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPPrepareCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_ARP_PREPARE_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS ARP prepare cmd detect interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPPrepareCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_ARP_PREPARE_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS host notify master detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_HostNotifyMstDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_HOST_NOTIFY_MST_DET_INT_EN_Msk) + +/** + * @brief SMBUS host notify master detect interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_HostNotifyMstDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_HOST_NOTIFY_MST_DET_INT_EN_Msk) + +/** + * @brief SMBUS quick cmd detect interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_QuickCmdDet_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_QUICK_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS quick cmd detect interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_QuickCmdDet_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_QUICK_CMD_DET_INT_EN_Msk) + +/** + * @brief SMBUS master clock extend timeout interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_MstClkExtendTimeout_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_MST_CLK_EXTND_TIMEOUT_INT_EN_Msk) + +/** + * @brief SMBUS master clock extend timeout interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_MstClkExtendTimeout_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_MST_CLK_EXTND_TIMEOUT_INT_EN_Msk) + +/** + * @brief SMBUS slave clock extend timeout interrupt enable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvClkExtendTimeout_INT_En(__I2C__) SET_BIT((__I2C__)->SMINTRMS, I2C_SLV_CLK_EXTND_TIMEOUT_INT_EN_Msk) + +/** + * @brief SMBUS slave clock extend timeout interrupt disable + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvClkExtendTimeout_INT_Dis(__I2C__) CLEAR_BIT((__I2C__)->SMINTRMS, I2C_SLV_CLK_EXTND_TIMEOUT_INT_EN_Msk) + + +/** + * @brief Judge SMBUS is alert detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't alert detect raw + * @retval 1 SMBUS is alert detect raw + */ +#define __LL_I2C_SMBUS_IsAlertDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_SMBUS_ALERT_DET_RAW_INT_STA_Msk) << I2C_SMBUS_ALERT_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is suspend detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't suspend detect raw + * @retval 1 SMBUS is suspend detect raw + */ +#define __LL_I2C_SMBUS_IsSuspendDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_SMBUS_SUSPEND_DET_RAW_INT_STA_Msk) << I2C_SMBUS_SUSPEND_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is slave RX PEC NACK or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't slave RX PEC NACK + * @retval 1 SMBUS is slave RX PEC NACK + */ +#define __LL_I2C_SMBUS_IsSlvRxPecNackRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_SLV_RX_PEC_NACK_RAW_INT_STA_Msk) << I2C_SLV_RX_PEC_NACK_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP assgn address cmd detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP assgn address cmd detect raw + * @retval 1 SMBUS is ARP assgn address cmd detect raw + */ +#define __LL_I2C_SMBUS_IsARPAssgnAddrCmdDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_ASSGN_ADDR_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_ASSGN_ADDR_CMD_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP get UDID cmd detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP get UDID cmd detect raw + * @retval 1 SMBUS is ARP get UDID cmd detect raw + */ +#define __LL_I2C_SMBUS_IsARPGetUdidCmdDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_GET_UDID_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_GET_UDID_CMD_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP reset cmd detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP reset cmd detect raw + * @retval 1 SMBUS is ARP reset cmd detect raw + */ +#define __LL_I2C_SMBUS_IsARPRstCmdDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_RST_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_RST_CMD_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is ARP prepare cmd detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't ARP prepare cmd detect raw + * @retval 1 SMBUS is ARP prepare cmd detect raw + */ +#define __LL_I2C_SMBUS_IsARPPrepareCmdDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_ARP_PREPARE_CMD_DET_RAW_INT_STA_Msk) << I2C_ARP_PREPARE_CMD_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is host nofity mst detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't host nofity mst detect raw + * @retval 1 SMBUS is host nofity mst detect raw + */ +#define __LL_I2C_SMBUS_IsHostNotifyMstDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_HOST_NOTIFY_MST_DET_RAW_INT_STA_Msk) << I2C_HOST_NOTIFY_MST_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is quick cmd detect raw or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't quick cmd detect raw + * @retval 1 SMBUS is quick cmd detect raw + */ +#define __LL_I2C_SMBUS_IsQuickCmdDetRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_QUICK_CMD_DET_RAW_INT_STA_Msk) << I2C_QUICK_CMD_DET_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is mst clock extend timeout or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't mst clock extend timeout + * @retval 1 SMBUS is mst clock extend timeout + */ +#define __LL_I2C_SMBUS_IsMstClkExtendTimeoutRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_MST_CLK_EXTND_TIMEOUT_RAW_INT_STA_Msk) << I2C_MST_CLK_EXTND_TIMEOUT_RAW_INT_STA_Pos) + +/** + * @brief Judge SMBUS is slave clock extend timeout or not + * @param __I2C__ Specifies I2C peripheral + * @retval 0 SMBUS isn't slave clock extend timeout + * @retval 1 SMBUS is slave clock extend timeout + */ +#define __LL_I2C_SMBUS_IsSlvClkExtendTimeoutRaw(__I2C__) \ + (READ_BIT((__I2C__)->SMINTRRST, I2C_SLV_CLK_EXTND_TIMEOUT_RAW_INT_STA_Msk) << I2C_SLV_CLK_EXTND_TIMEOUT_RAW_INT_STA_Pos) + + +/** + * @brief SMBUS alert detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_AlertDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SMBUS_ALERT_DET_Msk) + +/** + * @brief SMBUS suspend detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SuspendDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SMBUS_SUSPEND_DET_Msk) + +/** + * @brief SMBUS slave RX PEC NACK raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvRxPecNackRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SLV_RX_PEC_NACK_Msk) + +/** + * @brief SMBUS ARP assgn addredd cmd detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPAssgnAddrCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_ASSGN_ADDR_CMD_DET_Msk) + +/** + * @brief SMBUS ARP get UDID cmd detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPUdidCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_GET_UDID_CMD_DET_Msk) + +/** + * @brief SMBUS ARP reset cmd detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPRstCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_RST_CMD_DET_Msk) + +/** + * @brief SMBUS ARP prepare cmd detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_ARPPrepareCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_ARP_PREPARE_CMD_DET_Msk) + +/** + * @brief SMBUS host notify master detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_HostNotifyMstDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_HOST_NOTIFY_MST_DET_Msk) + +/** + * @brief SMBUS quick cmd detect raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_QuickCmdDetRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_QUICK_CMD_DET_Msk) + +/** + * @brief SMBUS master clock extend timeout raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_MstClkExtendTimeoutRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_MST_CLOCK_EXTND_TIMEOUT_Msk) + +/** + * @brief SMBUS Slave clock extend timeout raw interrupt status clear + * @param __I2C__ Specifies I2C peripheral + * @return None + */ +#define __LL_I2C_SMBUS_SlvClkExtendTimeoutRawIntSta_Clr(__I2C__) SET_BIT((__I2C__)->SMINTRCR, I2C_CLR_SLV_CLOCK_EXTND_TIMEOUT_Msk) + + +/** + * @brief SMBUS optional SAR set + * @param __I2C__ Specifies I2C peripheral + * @param sar optional SAR + * @return None + */ +#define __LL_I2C_SMBUS_OptionalSAR_Set(__I2C__, sar) \ + MODIFY_REG((__I2C__)->SAROP, I2C_OPTIONAL_SAR_Msk, ((sar & 0x7fUL) << I2C_OPTIONAL_SAR_Pos)) + + +/** + * @brief SMBUS ARP UDID LSB set + * @param __I2C__ Specifies I2C peripheral + * @param lsb SMBUS ARP UDID LSB + * @return None + */ +#define __LL_I2C_SMBUS_ARPUdidLsb_Set(__I2C__, lsb) \ + MODIFY_REG((__I2C__)->UDIDLSB, I2C_SMBUS_ARP_UDID_LSB_Msk, ((lsb & 0xffffffffUL) << I2C_SMBUS_ARP_UDID_LSB_Pos)) + +/** + * @} + */ + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup I2C_LL_Exported_Types I2C LL Exported Types + * @brief I2C LL Exported Types + * @{ + */ + +/** + * @brief I2C role definition + */ +typedef enum { + I2C_ROLE_MASTER, /*!< I2C role master */ + I2C_ROLE_SLAVE, /*!< I2C role slave */ +} I2C_RoleETypeDef; + +/** + * @brief I2C address bit definition + */ +typedef enum { + I2C_ADDR_7BIT, /*!< I2C address mode 7b */ + I2C_ADDR_10BIT, /*!< I2C address mode 10b */ +} I2C_AddrModeETypeDef; + +/** + * @brief I2C memmory address size definition + */ +typedef enum { + I2C_MEMADDR_SIZE_INVALID = 0, /*!< memmory address size invalid */ + I2C_MEMADDR_SIZE_8BIT = 1, /*!< memmory address size 8bit */ + I2C_MEMADDR_SIZE_16BIT = 2, /*!< memmory address size 16bit */ + I2C_MEMADDR_SIZE_32BIT = 4, /*!< memmory address size 32bit */ +} I2C_MemAddrSizeETypeDef; + + +/** + * @brief I2C user config + */ +typedef struct __I2C_UserCfgTypeDef { + I2C_RoleETypeDef role; /*!< role */ + I2C_AddrModeETypeDef addr_mode; /*!< address mode */ + uint32_t baudrate; /*!< baudrate */ + uint16_t slave_addr; /*!< slave address */ + LL_FuncStatusETypeDef smbus_enable; /*!< smbus enable */ + uint32_t smbus_master_extend_clk; /*!< smbus master extend clk */ + uint32_t smbus_slaver_extend_clk; /*!< smbus slaver extend clk */ +} I2C_UserCfgTypeDef; + +/** + * @brief I2C DMA Status + */ +typedef enum { + IIC_DMA_STATE_RESET = 0, /*!< DMA State Reset: not yet initialized or disabled */ + IIC_DMA_STATE_READY, /*!< DMA State Ready: initialized and ready for use */ + IIC_DMA_STATE_BUSY, /*!< DMA State Busy: process is ongoing */ + IIC_DMA_STATE_ERROR, /*!< DMA State Error: process is Error */ + IIC_DMA_STATE_FINISH, /*!< DMA State Finish: process has been finished */ +} I2C_DMAStatusTypeDef; + +/** + * @brief I2C frame definition + */ +typedef struct __I2C_FrameTypeDef { + I2C_TypeDef *Instance; /*!< I2C Reg base address */ + uint16_t target_addr; /*!< target address */ + uint32_t mem_addr; /*!< memory address */ + I2C_MemAddrSizeETypeDef mem_addr_size; /*!< memory address size */ + uint8_t *buf; /*!< buffer pointer */ + uint32_t buf_len; /*!< buffer length */ + uint32_t command; /*!< smbus_command */ + uint16_t XferCount; /*!< I2C transfer counter */ + uint32_t clk_cnt; /*!< I2C sent clk to read */ +#ifdef LL_DMA_MODULE_ENABLED + DMA_ChannelETypeDef dma_tx_ch; /*!< I2C Tx DMA Channel */ + DMA_ChannelETypeDef dma_rx_ch; /*!< I2C Rx DMA Channel */ + I2C_DMAStatusTypeDef TXdma_status; /*!< I2C DMA status */ + I2C_DMAStatusTypeDef RXdma_status; /*!< I2C DMA status */ +#endif +} I2C_FrameTypeDef; + + +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup I2C_LL_Exported_Functions + * @{ + */ + +/** @addtogroup I2C_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_I2C_Init(I2C_TypeDef *Instance, I2C_UserCfgTypeDef *user_cfg); +LL_StatusETypeDef LL_I2C_DeInit(I2C_TypeDef *Instance); +void LL_I2C_MspInit(I2C_TypeDef *Instance); +void LL_I2C_MspDeInit(I2C_TypeDef *Instance); +/** + * @} + */ + +/** @addtogroup I2C_LL_Exported_Functions_Group2 + * @{ + */ + +uint32_t LL_I2C_MasterWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +uint32_t LL_I2C_MasterRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_I2C_SlaveWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_I2C_SlaveRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout); +uint32_t LL_SMBUS_MasterWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +uint32_t LL_SMBUS_MasterRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_SMBUS_SlaveRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_SMBUS_SlaveWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_I2C_MasterWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_I2C_SlaveWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_I2C_MasterRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_I2C_SlaveRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_SMBUS_MasterWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_SMBUS_MasterRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_SMBUS_SlaveRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); +LL_StatusETypeDef LL_SMBUS_SlaveWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame); + +#ifdef LL_DMA_MODULE_ENABLED +LL_StatusETypeDef LL_I2C_MasterWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_I2C_MasterRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_I2C_SlaveRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_I2C_SlaveWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_SMBUS_MasterWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_SMBUS_MasterRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_SMBUS_SlaveWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +LL_StatusETypeDef LL_SMBUS_SlaveRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout); +#endif + +/** + * @} + */ + +/** @addtogroup I2C_LL_Exported_Functions_Group3 + * @{ + */ +void LL_I2C_IRQHandler(I2C_TypeDef *Instance, I2C_FrameTypeDef *hi2c); +void LL_I2C_SCLStuckAtLowCallback(I2C_TypeDef *Instance); +void LL_I2C_MstOnHoldCallback(I2C_TypeDef *Instance); +void LL_I2C_SlvRestartDetCallback(I2C_TypeDef *Instance); +void LL_I2C_SlvGenCallCallback(I2C_TypeDef *Instance); +void LL_I2C_StartDetCallback(I2C_TypeDef *Instance); +void LL_I2C_StopDetCallback(I2C_TypeDef *Instance); +void LL_I2C_ActivityCallback(I2C_TypeDef *Instance); +void LL_I2C_SlvRxDoneCallback(I2C_TypeDef *Instance); +void LL_I2C_TxAbortCallback(I2C_TypeDef *Instance); +void LL_I2C_SlvReadReqCallback(I2C_TypeDef *Instance); +void LL_I2C_TxEmptyCallback(I2C_TypeDef *Instance); +void LL_I2C_TxOverCallback(I2C_TypeDef *Instance); +void LL_I2C_RxFullCallback(I2C_TypeDef *Instance); +void LL_I2C_RxOverCallback(I2C_TypeDef *Instance); +void LL_I2C_RxUnderCallback(I2C_TypeDef *Instance); +void LL_SMBUS_SlvClkExtTimeoutCallback(I2C_TypeDef *Instance); +void LL_SMBUS_MstClkExtTimeoutCallback(I2C_TypeDef *Instance); + + +/** + * @} + */ + +/** + * @} + */ + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* _TMF5XXX_LL_I2C_H_ */ + + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_iir.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_iir.h new file mode 100644 index 0000000000..0c48070ce6 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_iir.h @@ -0,0 +1,354 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_iir.h + * @author MCD Application Team + * @brief Header file of IIR LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_IIR_H_ +#define _TAE32F53XX_LL_IIR_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup IIR_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup IIR_LL_Exported_Types IIR LL Exported Types + * @brief IIR LL Exported Types + * @{ + */ + +/** + * @brief IIR Order type definition + */ +typedef enum { + IIR_ORDER_1 = 0x00000000UL, /*!< Source Peripheral bus AHB Master1 */ + IIR_ORDER_2 = IIR_CR0_ORD_0, /*!< IIR order 2 */ + IIR_ORDER_3 = IIR_CR0_ORD_1, /*!< IIR order 3 */ + IIR_ORDER_4 = (IIR_CR0_ORD_0 | IIR_CR0_ORD_1), /*!< IIR order 4 */ +} IIR_OrderETypeDef; + +/* + * @brief IIR internal data buffer reset or not + */ +typedef enum { + IIR_BUFFER_NO_RESET = 0x00000000UL, /*!< Do nothing to IIR Internal Data Buffer */ + IIR_BUFFER_RESET = IIR_CR0_IBRST, /*!< IIR Internal Data Buffer should reset */ +} IIR_BufferETypeDef; + + +/** + * @brief IIR Auto-Reload mode enable or disable + */ +typedef enum { + IIR_AUTORELOAD_DISABLE = 0x00000000UL, /*!< IIR Auto-Reload mode disable */ + IIR_AUTORELOAD_ENABLE = IIR_CR1_AREN, /*!< IIR Auto-Reload mode enable */ +} IIR_ATReloadETypeDef; + +/** + * @brief IIR initialization structure definition + */ +typedef struct __IIR_InitTypeDef { + IIR_OrderETypeDef Order; /*!< Specifies the IIR order */ + IIR_BufferETypeDef BufferReset; /*!< Indicate to reset the internal data buffer or not */ +} IIR_InitTypeDef; + +/** + * @brief IIR configuration structure definition + */ +typedef struct __IIR_ConfigTypeDef { + uint32_t InDataAddress; /*!< Specifies the input data address in memory area. + The address must be aligned to 16-bit boundary in specifies memory areas(For + more information, please see the documents of system architecture designs) */ + + uint32_t InDataScale; /*!< Specifies magnify scale for the input data. + This parameter can be a value between 0 to 16 which stand for the input data + magnified 2^0 to 2^16 times */ + + uint32_t FeedBackScale; /*!< Specifies the feekback narrow scale. + This parameter can be a value between 0 to 31 which stand for feedback + narrowed 2^0 to 2^31 times */ + + uint32_t OutDataScale; /*!< Specifies narrow scale for the output data. + This parameter can be a value between 0 to 31 which stand for the output data + narrowed 2^0 to 2^31 times */ + + int16_t AxCOEF[4]; /*!< Specifies the coefficient A. + This parameter can be a value between -32768 to +32767 */ + + int16_t BxCOEF[5]; /*!< Specifies the coefficient B. + This parameter can be a value between -32768 to +32767 */ +} IIR_ConfigTypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup IIR_LL_Exported_Constants IIR LL Exported Constants + * @brief IIR LL Exported Constants + * @{ + */ + +/** @defgroup IIR_Flag_definition IIR Flag Definition + * @{ + */ +#define IIR_FLAG_FDIF IIR_ISR_FDIF /*!< IIR Filter Done Interrupt Flag */ +/** + * @} + */ + +/** @defgroup IIR_Interrupt_definition IIR Interrupt Definition + * @{ + */ +#define IIR_IT_FDIE IIR_IER_IE /*!< IIR Filter Done Interrupt Enable */ +/** + * @} + */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup IIR_LL_Exported_Macros IIR LL Exported Macros + * @brief IIR LL Exported Macros + * @{ + */ + +/** + * @brief Enable the specified IIR interrupt. + * @param __INSTANCE__ IIR peripheral + * @param __INTERRUPT__ specifies the IIR interrupt source to enable. + * This parameter can be one of the following values: + * @arg IIR_IT_FDIE: Filiter Done Interrupt Enable + * @return None + */ +#define __LL_IIR_ENABLE_IT(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->IER, __INTERRUPT__) + + +/** + * @brief Disable the specified IIR interrupt. + * @param __INSTANCE__ IIR peripheral + * @param __INTERRUPT__ specifies the IIR interrupt source to disable. + * This parameter can be one of the following values: + * @arg IIR_IT_FDIE: Filiter Done Interrupt Enable + * @return None + */ +#define __LL_IIR_DISABLE_IT(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->IER, __INTERRUPT__) + + +/** + * @brief Check whether the specified IIR interrupt source is enabled or not. + * @param __INSTANCE__ IIR peripheral + * @param __INTERRUPT__ specifies the IIR interrupt source to check. + * This parameter can be one of the following values: + * @arg IIR_IT_FDIE: Filiter Done Interrupt Enable + * @return The state of __INTERRUPT__ (SET or RESET). + */ +#define __LL_IIR_IT_CHECK_SOURCE(__INSTANCE__, __INTERRUPT__) \ + ((READ_BIT((__INSTANCE__)->IER, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** @brief Check whether the specified IIR status or interrupt flag is set or not. + * @param __INSTANCE__ IIR peripheral + * @param __FLAG__ specifies the IIR flag to check. + * This parameter can be one of the following values: + * @arg IIR_FLAG_FDIF: Filiter Done Interrupt Flag + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_IIR_GET_FLAG(__INSTANCE__, __FLAG__) \ + ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Clear the specified IIR status or interrupt flag. + * @param __INSTANCE__ IIR peripheral + * @param __FLAG__ specifies the IIR flag to clear. + * This parameter can be one of the following values: + * @arg IIR_FLAG_FDIF: Filiter Done Interrupt Flag + * @return None + */ +#define __LL_IIR_CLEAR_FLAG(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__)) + +/** + * @brief Enable the IIR AutoReload feature. + * @param __INSTANCE__ IIR peripheral + * @return None + */ +#define __LL_IIR_AUTORELOAD_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR1, IIR_CR1_AREN) + +/** + * @brief Enable the IIR peripheral. + * @param __INSTANCE__ IIR peripheral + * @return None + */ +#define __LL_IIR_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR0, IIR_CR0_IIREN) + +/** + * @brief Disable the IIR peripheral. + * @param __INSTANCE__ IIR peripheral + * @return None + */ +#define __LL_IIR_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR0, IIR_CR0_IIREN) + +/** + * @brief Start IIR filter + * @param __INSTANCE__ IIR peripheral + * @return None + */ +#define __LL_IIR_FILTER_START(__INSTANCE__) SET_BIT((__INSTANCE__)->CR1, IIR_CR1_START) + + +/** + * @brief Reset the IIR internal data buffer. + * @param __INSTANCE__ IIR peripheral + * @return None + */ +#define __LL_IIR_FILTER_BUFFER_RESET(__INSTANCE__) SET_BIT((__INSTANCE__)->CR0, IIR_CR0_IBRST) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup IIR_LL_Exported_functions + * @{ + */ + +/** @addtogroup IIR_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_IIR_Init(IIR_TypeDef *Instance, IIR_InitTypeDef *Init); +LL_StatusETypeDef LL_IIR_DeInit(IIR_TypeDef *Instance); +void LL_IIR_MspInit(IIR_TypeDef *Instance); +void LL_IIR_MspDeInit(IIR_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup IIR_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_IIR_FilterConfig(IIR_TypeDef *Instance, IIR_ConfigTypeDef *Config); +LL_StatusETypeDef LL_IIR_FilterConfig_Preload(IIR_TypeDef *Instance, IIR_ConfigTypeDef *Config); +/** + * @} + */ + + +/** @addtogroup IIR_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_IIR_FilterStart(IIR_TypeDef *Instance, IIR_ATReloadETypeDef AutoReload); +LL_StatusETypeDef LL_IIR_FilterStart_IT(IIR_TypeDef *Instance, IIR_ATReloadETypeDef AutoReload); +LL_StatusETypeDef LL_IIR_FilterBufferReset(IIR_TypeDef *Instance); +int16_t LL_IIR_FilterDataGet(IIR_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup IIR_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_IIR_IRQHandler(IIR_TypeDef *IIRx); +void LL_IIR_FilterDoneCallBack(IIR_TypeDef *IIRx); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @addtogroup IIR_LL_Private_Macros IIR LL Private Macros + * @brief IIR LL Private Macros + * @{ + */ + +/** + * @brief Judge is IIR output data scale or not + * @param __SCALE__ scale to judge + * @retval 0 isn't IIR output data scale + * @retval 1 is IIR output data scale + */ +#define IS_IIR_OUTPUT_DATA_SCALE(__SCALE__) ((__SCALE__) <= 0x1FU) + +/** + * @brief Judge is IIR input data scale or not + * @param __SCALE__ scale to judge + * @retval 0 isn't IIR input data scale + * @retval 1 is IIR input data scale + */ +#define IS_IIR_INPUT_DATA_SCALE(__SCALE__) ((__SCALE__) <= 0x10U) + +/** + * @brief Judge is IIR feedback data scale or not + * @param __SCALE__ scale to judge + * @retval 0 isn't IIR feedback data scale + * @retval 1 is IIR feedback data scale + */ +#define IS_IIR_FEEDBACK_SCALE(__SCALE__) ((__SCALE__) <= 0x1FU) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_IIR_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_iwdg.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_iwdg.h new file mode 100644 index 0000000000..8b2c2d2385 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_iwdg.h @@ -0,0 +1,321 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_iwdg.h + * @author MCD Application Team + * @brief Header file of IWDG LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_IWDG_H_ +#define _TAE32F53XX_LL_IWDG_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup IWDG_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup IWDG_LL_Exported_Types IWDG LL Exported Types + * @brief IWDG LL Exported Types + * @{ + */ + +/** + * @brief IWDG Prescaler enumeration + */ +typedef enum { + IWDG_PRESCALER_4 = IWDG_PSCR_PSC_0, /*!< IWDG prescaler set to 4 */ + IWDG_PRESCALER_8 = IWDG_PSCR_PSC_1, /*!< IWDG prescaler set to 8 */ + IWDG_PRESCALER_16 = IWDG_PSCR_PSC_2, /*!< IWDG prescaler set to 16 */ + IWDG_PRESCALER_32 = IWDG_PSCR_PSC_3, /*!< IWDG prescaler set to 32 */ + IWDG_PRESCALER_64 = IWDG_PSCR_PSC_4, /*!< IWDG prescaler set to 64 */ + IWDG_PRESCALER_128 = IWDG_PSCR_PSC_5, /*!< IWDG prescaler set to 128 */ + IWDG_PRESCALER_256 = IWDG_PSCR_PSC_6, /*!< IWDG prescaler set to 256 */ + IWDG_PRESCALER_512 = IWDG_PSCR_PSC_7, /*!< IWDG prescaler set to 512 */ +} IWDG_PreScalerETypeDef; + + +/** + @brief IWDG Mode enumeration + */ +typedef enum { + IWDG_MODE_RESET = IWDG_CR_MODE_RESET, /*!< IWDG Reset after timeout */ + IWDG_MODE_INTERRUPT = IWDG_CR_MODE_INTERRUPT, /*!< IWDG Trigger a interrupt after timeout */ +} IWDG_ModeETypeDef; + + +/** + * @brief IWDG Init structure definition + */ +typedef struct __IWDG_InitTypeDef { + IWDG_PreScalerETypeDef Prescaler; /*!< Select the prescaler of the IWDG. */ + uint32_t Reload_val; /*!< Specifies the IWDG down-counter reload value. + This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ + IWDG_ModeETypeDef Mode; /*!< Specifies the IWDG bahavior after timeout.*/ +} IWDG_InitTypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup IWDG_LL_Exported_Constants IWDG LL Exported Constants + * @brief IWDG LL Exported Constants + * @{ + */ + +/** @defgroup IWDG_Interrupt_definition IWDG interrupt Definition + * @{ + */ +#define IWDG_IT_TOIE IWDG_CR_TOIE /*!< IWDG Timeout Interrupte Enable */ +/** + * @} + */ + +/** @defgroup IWDG_Flag_definition IWDG Flag Definition + * @{ + */ +#define IWDG_FLAG_PSCUPD IWDG_SR_PSCUPD /*!< IWDG Prescaler Update flag */ +#define IWDG_FLAG_RLVUPD IWDG_SR_RLVUPD /*!< IWDG Reload Value Update flag */ +#define IWDG_FLAG_TOIF IWDG_SR_TOIF /*!< IWDG Timeout Interrupt flag */ +/** + * @} + */ + +/** @defgroup IWDG_Key_definition IWDG Key Definition + * @{ + */ +#define IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */ +#define IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */ +#define IWDG_KEY_DISABLE 0x0000DDDDU /*!< IWDG Peripheral Disable */ +#define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005003U /*!< IWDG Write Access Enable */ +#define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000U /*!< IWDG Write Access Disable */ +/** + * @} + */ + + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup IWDG_LL_Exported_Macros IWDG LL Exported Macros + * @brief IWDG LL Exported Constants + * @{ + */ + +/** + * @brief Enable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers. + * @param __INSTANCE__ IWDG peripheral + * @return None + */ +#define __LL_IWDG_ENABLE_WRITE_ACCESS(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_WRITE_ACCESS_ENABLE) + +/** + * @brief Disable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers. + * @param __INSTANCE__ IWDG peripheral + * @return None + */ +#define __LL_IWDG_DISABLE_WRITE_ACCESS(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_WRITE_ACCESS_DISABLE) + + +/** + * @brief Enable the IWDG peripheral. + * @param __INSTANCE__ IWDG peripheral + * @return None + */ +#define __LL_IWDG_START(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_ENABLE) + +/** + * @brief Disable the IWDG peripheral. + * @param __INSTANCE__ IWDG peripheral + * @return None + */ +#define __LL_IWDG_STOP(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_DISABLE) + +/** @brief Enable the specified IWDG interrupt. + * @note __LL_IWDG_ENABLE_WRITE_ACCESS() must be called to enable write access before enable + * the IWDG interrupt. + * @param __INSTANCE__ IWDG peripheral + * @param __INTERRUPT__ specifies the IWDG interrupt source to enable. + * This parameter can be one of the following values: + * @arg IWDG_IT_TOIE: Timeout interrupt flag + * @retrun None + */ +#define __LL_IWDG_ENABLE_IT(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) + +/** @brief Disable the specified TIM interrupt. + * @note __LL_IWDG_ENABLE_WRITE_ACCESS() must be called to enable write access before disable + * the IWDG interrupt. + * @param __INSTANCE__ IWDG peripheral + * @param __INTERRUPT__ specifies the IWDG interrupt source to enable. + * This parameter can be one of the following values: + * @arg IWDG_IT_TOIE: Timeout interrupt flag + * @retval None + */ +#define __LL_IWDG_DISABLE_IT(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) + + +/** @brief Check whether the specified IWDG status or interrupt flag is set or not. + * @param __INSTANCE__ IWDG peripheral + * @param __FLAG__ specifies the IWDG flag to check. + * This parameter can be one of the following values: + * @arg IWDG_FLAG_PSCUPD: Prescaler value update flag + * @arg IWDG_FLAG_RLVUPD: Reload value update flag + * @arg IWDG_FLAG_TOIF: Timeout interrupt flag + * @return The new state of __FLAG__ (SET or RESET). + */ +#define __LL_IWDG_GET_FLAG(__INSTANCE__, __FLAG__) \ + ((READ_BIT((__INSTANCE__)->SR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Clear the specified IWDG status or interrupt flag. + * @param __INSTANCE__ IWDG peripheral + * @param __FLAG__ specifies the IWDG flag to clear. + * This parameter can be one of the following values: + * @arg IWDG_FLAG_TOIF: Timeout interrupt flag + * @return None + */ +#define __LL_IWDG_CLEAR_FLAG(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->SR, (__FLAG__)) + +/** + * @brief Check whether the specified IWDG interrupt source is enabled or not. + * @param __INSTANCE__ IWDG peripheral + * @param __INTERRUPT__ specifies the IWDG interrupt source to check. + * This parameter can be one of the following values: + * @arg IWDG_IT_TOIE: Timeout interrupt + * @return The state of __INTERRUPT__ (SET or RESET). + */ +#define __LL_IWDG_IT_CHECK_SOURCE(__INSTANCE__, __INTERRUPT__) \ + ((READ_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** + * @brief Reload IWDG counter with value defined in the reload register + * (write access to IWDG_PR & IWDG_RLR registers disabled). + * @note Flag RLVUPD and PSCUPD must be 0 before refreshing IWDG counter. + * @param __INSTANCE__ IWDG peripheral + * @return None + */ +#define __LL_IWDG_RELOAD_COUNTER(__INSTANCE__) WRITE_REG((__INSTANCE__)->KEYR, IWDG_KEY_RELOAD) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup IWDG_LL_Exported_Functions + * @{ + */ + +/** @addtogroup IWDG_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_IWDG_Init(IWDG_TypeDef *Instance, IWDG_InitTypeDef *Init); +LL_StatusETypeDef LL_IWDG_DeInit(IWDG_TypeDef *Instance); +void LL_IWDG_MspInit(IWDG_TypeDef *Instance); +void LL_IWDG_MspDeInit(IWDG_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup IWDG_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_IWDG_Refresh(IWDG_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup IWDG_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_IWDG_IRQHandler(IWDG_TypeDef *Instance); +void LL_IWDG_TimeOutCallBack(IWDG_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup IWDG_LL_Private_Macros IWDG LL Private Macros + * @brief IWDG LL Private Macros + * @{ + */ + +/** + * @brief Check IWDG prescaler value. + * @param __PRESCALER__ IWDG prescaler value + * @return None + */ + +/** + * @brief Check IWDG reload value. + * @param __RELOAD__ IWDG reload value + * @return None + */ +#define IS_IWDG_RELOAD_Val(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RLV) + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_IWDG_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_lvdctrl.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_lvdctrl.h new file mode 100644 index 0000000000..03c2f45a64 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_lvdctrl.h @@ -0,0 +1,464 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_lvdctrl.h + * @author MCD Application Team + * @brief Head file for LVDCTRL LL Module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_LVDCTRL_H_ +#define _TAE32F53XX_LL_LVDCTRL_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup LVDCTRL_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup LVDCTRL_LL_Exported_Macros LVDCTRL LL Exported Macros + * @brief LVDCTRL LL Exported Macros + * @{ + */ + +/** + * @brief Judge VDD Over Current or not + * @param __LVD__ Specifies LVD peripheral + * @retval 0 VDD isn't Over Current + * @retval 1 VDD is Over Current + */ +#define __LL_LVDCTRL_IsVDDOverCur(__LVD__) (READ_BIT((__LVD__)->LACR, LVDCTRL_VDDOC_ST_Msk) >> LVDCTRL_VDDOC_ST_Pos) + +/** + * @brief Judge VDD Low Voltage or not + * @param __LVD__ Specifies LVD peripheral + * @retval 0 VDD isn't Low Voltage + * @retval 1 VDD is Low Voltage + */ +#define __LL_LVDCTRL_IsVDDLowVol(__LVD__) (READ_BIT((__LVD__)->LACR, LVDCTRL_VDDLV_ST_Msk) >> LVDCTRL_VDDLV_ST_Pos) + +/** + * @brief Judge VCC Low Voltage or not + * @param __LVD__ Specifies LVD peripheral + * @retval 0 VCC isn't Low Voltage + * @retval 1 VCC is Low Voltage + */ +#define __LL_LVDCTRL_IsVCCLowVol(__LVD__) (READ_BIT((__LVD__)->LACR, LVDCTRL_VCCLV_ST_Msk) >> LVDCTRL_VCCLV_ST_Pos) + +/** + * @brief Judge AVCC Low Voltage or not + * @param __LVD__ Specifies LVD peripheral + * @retval 0 AVCC isn't Low Voltage + * @retval 1 AVCC is Low Voltage + */ +#define __LL_LVDCTRL_IsAVCCLowVol(__LVD__) (READ_BIT((__LVD__)->LACR, LVDCTRL_AVCCLV_ST_Msk) >> LVDCTRL_AVCCLV_ST_Pos) + +/** + * @brief VDD Over Current Bypass Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurByp_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_VDDOC_BYP_EN_Msk) + +/** + * @brief VDD Over Current Bypass Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurByp_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_VDDOC_BYP_EN_Msk) + +/** + * @brief VDD Low Voltage Bypass Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolByp_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_VDDLV_BYP_EN_Msk) + +/** + * @brief VDD Low Voltage Bypass Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolByp_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_VDDLV_BYP_EN_Msk) + +/** + * @brief VCC Low Voltage Bypass Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolByp_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_VCCLV_BYP_EN_Msk) + +/** + * @brief VCC Low Voltage Bypass Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolByp_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_VCCLV_BYP_EN_Msk) + +/** + * @brief AVCC Low Voltage Bypass Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolByp_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_AVCCLV_BYP_EN_Msk) + +/** + * @brief AVCC Low Voltage Bypass Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolByp_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_AVCCLV_BYP_EN_Msk) + +/** + * @brief Analog Input Signal Debounce Limit Set + * @param __LVD__ Specifies LVD peripheral + * @param limit Analog Input Signal Debounce Limit + * @return None + */ +#define __LL_LVDCTRL_AnalogInDbcLimit_Set(__LVD__, limit) \ + MODIFY_REG((__LVD__)->LACR, LVDCTRL_ANAIN_DBC_LIMIT_Msk, ((limit & 0xffUL) << LVDCTRL_ANAIN_DBC_LIMIT_Pos)) + +/** + * @brief VCC Low Voltage Threshold Set + * @param __LVD__ Specifies LVD peripheral + * @param thres VCC Low Voltage Threshold + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolThres_Set(__LVD__, thres) MODIFY_REG((__LVD__)->LACR, LVDCTRL_VCCLV_SET_Msk, thres) + +/** + * @brief AVCC Low Voltage Threshold Set + * @param __LVD__ Specifies LVD peripheral + * @param thres AVCC Low Voltage Threshold + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolThres_Set(__LVD__, thres) MODIFY_REG((__LVD__)->LACR, LVDCTRL_AVCCLV_SET_Msk, thres) + +/** + * @brief VDD Over Current Threshold Set + * @param __LVD__ Specifies LVD peripheral + * @param thres VDD Over Current Threshold + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurThres_Set(__LVD__, thres) MODIFY_REG((__LVD__)->LACR, LVDCTRL_VDDOC_SET_Msk, thres) + +/** + * @brief VDD Low Voltage Threshold Set + * @param __LVD__ Specifies LVD peripheral + * @param thres VDD Low Voltage Threshold + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolThres_Set(__LVD__, thres) MODIFY_REG((__LVD__)->LACR, LVDCTRL_VDDLV_SET_Msk, thres) + +/** + * @brief VCC Low Voltage Detect Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolDet_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_VCCLV_EN_Msk) + +/** + * @brief VCC Low Voltage Detect Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolDet_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_VCCLV_EN_Msk) + +/** + * @brief AVCC Low Voltage Detect Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolDet_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_AVCCLV_EN_Msk) + +/** + * @brief AVCC Low Voltage Detect Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolDet_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_AVCCLV_EN_Msk) + +/** + * @brief VDD Over Current Detect Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurDet_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_VDDOC_EN_Msk) + +/** + * @brief VDD Over Current Detect Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurDet_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_VDDOC_EN_Msk) + +/** + * @brief VDD Low Voltage Detect Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolDet_En(__LVD__) SET_BIT((__LVD__)->LACR, LVDCTRL_VDDLV_EN_Msk) + +/** + * @brief VDD Low Voltage Detect Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolDet_Dis(__LVD__) CLEAR_BIT((__LVD__)->LACR, LVDCTRL_VDDLV_EN_Msk) + + +/** + * @brief VDD Over Current Braking Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurBrk_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VDDOC_BRK_EN_Msk) + +/** + * @brief VDD Over Current Braking Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurBrk_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VDDOC_BRK_EN_Msk) + +/** + * @brief VDD Low Voltage Braking Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolBrk_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VDDLV_BRK_EN_Msk) + +/** + * @brief VDD Low Voltage Braking Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolBrk_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VDDLV_BRK_EN_Msk) + +/** + * @brief VCC Low Voltage Braking Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolBrk_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VCCLV_BRK_EN_Msk) + +/** + * @brief VCC Low Voltage Braking Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolBrk_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VCCLV_BRK_EN_Msk) + +/** + * @brief AVCC Low Voltage Braking Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolBrk_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_AVCCLV_BRK_EN_Msk) + +/** + * @brief AVCC Low Voltage Braking Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolBrk_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_AVCCLV_BRK_EN_Msk) + +/** + * @brief VDD Over Current Interrupt Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurInt_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VDDOC_INT_EN_Msk) + +/** + * @brief VDD Over Current Interrupt Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurInt_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VDDOC_INT_EN_Msk) + +/** + * @brief VDD Low Voltage Interrupt Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolInt_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VDDLV_INT_EN_Msk) + +/** + * @brief VDD Low Voltage Interrupt Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolInt_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VDDLV_INT_EN_Msk) + +/** + * @brief VCC Low Voltage Interrupt Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolInt_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VCCLV_INT_EN_Msk) + +/** + * @brief VCC Low Voltage Interrupt Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolInt_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VCCLV_INT_EN_Msk) + +/** + * @brief AVCC Low Voltage Interrupt Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolInt_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_AVCCLV_INT_EN_Msk) + +/** + * @brief AVCC Low Voltage Interrupt Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolInt_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_AVCCLV_INT_EN_Msk) + +/** + * @brief VDD Over Current Reset Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurRst_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VDDOC_RST_EN_Msk) + +/** + * @brief VDD Over Current Reset Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_OverCurRst_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VDDOC_RST_EN_Msk) + +/** + * @brief VDD Low Voltage Reset Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolRst_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VDDLV_RST_EN_Msk) + +/** + * @brief VDD Low Voltage Reset Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VDD_LowVolRst_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VDDLV_RST_EN_Msk) + +/** + * @brief VCC Low Voltage Reset Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolRst_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_VCCLV_RST_EN_Msk) + +/** + * @brief VCC Low Voltage Reset Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_VCC_LowVolRst_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_VCCLV_RST_EN_Msk) + +/** + * @brief AVCC Low Voltage Reset Enable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolRst_En(__LVD__) SET_BIT((__LVD__)->LCR, LVDCTRL_AVCCLV_RST_EN_Msk) + +/** + * @brief AVCC Low Voltage Reset Disable + * @param __LVD__ Specifies LVD peripheral + * @return None + */ +#define __LL_LVDCTRL_AVCC_LowVolRst_Dis(__LVD__) CLEAR_BIT((__LVD__)->LCR, LVDCTRL_AVCCLV_RST_EN_Msk) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup LVDCTRL_LL_Exported_Functions + * @{ + */ + +/** @addtogroup LVDCTRL_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_LVD_Init(LVD_TypeDef *Instance); +LL_StatusETypeDef LL_LVD_DeInit(LVD_TypeDef *Instance); +void LL_LVD_MspInit(LVD_TypeDef *Instance); +void LL_LVD_MspDeInit(LVD_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup LVDCTRL_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_LVD_CtrlIRQHandler(LVD_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_LVDCTRL_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_sysctrl.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_sysctrl.h new file mode 100644 index 0000000000..adb916973e --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_sysctrl.h @@ -0,0 +1,3025 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_sysctrl.h + * @author MCD Application Team + * @brief Header file for SYSCTRL LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_SYSCTRL_H_ +#define _TAE32F53XX_LL_SYSCTRL_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup SYSCTRL_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup SYSCTRL_LL_Exported_Macros SYSCTRL LL Exported Macros + * @brief SYSCTRL LL Exported Macros + * @{ + */ + +/** + * @brief PLL0 Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL0_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_EN_Msk) + +/** + * @brief PLL0 Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL0_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_EN_Msk) + +/** + * @brief Judge PLL0 has Locked or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 PLL0 hasn't Locked + * @retval 1 PLL0 has Locked + */ +#define __LL_SYSCTRL_PLL0_IsLocked(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_LOCKED_Msk) >> SYSCTRL_PLL0_LOCKED_Pos) + +/** + * @brief PLL0 LPF Select 8M + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL0_LPF_8M(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_LPF_Msk) + +/** + * @brief PLL0 LPF Select 26M + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL0_LPF_26M(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_LPF_Msk) + +/** + * @brief PLL0 Band Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param band PLL0 Band + * @return None + */ +#define __LL_SYSCTRL_PLL0_Band_Set(__SYSCTRL__, band) \ + MODIFY_REG((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_BAND_Msk, band) + +/** + * @brief PLL0 GVCO Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param vco PLL0 GVCO + * @return None + */ +#define __LL_SYSCTRL_PLL0_GVCO_Set(__SYSCTRL__, vco) \ + MODIFY_REG((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_GVCO_Msk, vco) + +/** + * @brief PLL0 DIV Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div PLL0 Div + * @return None + */ +#define __LL_SYSCTRL_PLL0_DIV_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_DIV_Msk, (((div-1) & 0xfUL) << SYSCTRL_PLL0_DIV_Pos)) + +/** + * @brief PLL0 Pre Div Set to 2 + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL0_PreDiv_2(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_PREDIV_Msk) + +/** + * @brief PLL0 Pre Div Set to 1 + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL0_PreDiv_1(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_PREDIV_Msk) + +/** + * @brief PLL0 Ref CLK Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param ref_clk PLL0 Ref CLK + * @return None + */ +#define __LL_SYSCTRL_PLL0_RefClk_Set(__SYSCTRL__, ref_clk) \ + MODIFY_REG((__SYSCTRL__)->PLL0CR, SYSCTRL_PLL0_REFCLK_Msk, ref_clk) + + +/** + * @brief PLL1 Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL1_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_EN_Msk) + +/** + * @brief PLL1 Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL1_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_EN_Msk) + +/** + * @brief Judge PLL1 has Locked or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 PLL1 hasn't Locked + * @retval 1 PLL1 has Locked + */ +#define __LL_SYSCTRL_PLL1_IsLocked(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_LOCKED_Msk) >> SYSCTRL_PLL1_LOCKED_Pos) + +/** + * @brief PLL1 LPF Select 8M + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL1_LPF_8M(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_LPF_Msk) + +/** + * @brief PLL1 LPF Select 26M + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL1_LPF_26M(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_LPF_Msk) + +/** + * @brief PLL1 Band Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param band PLL1 Band + * @return None + */ +#define __LL_SYSCTRL_PLL1_Band_Set(__SYSCTRL__, band) \ + MODIFY_REG((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_BAND_Msk, band) + +/** + * @brief PLL1 GVCO Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param vco PLL1 GVCO + * @return None + */ +#define __LL_SYSCTRL_PLL1_GVCO_Set(__SYSCTRL__, vco) \ + MODIFY_REG((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_GVCO_Msk, vco) + +/** + * @brief PLL1 DIV Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div PLL1 Div + * @return None + */ +#define __LL_SYSCTRL_PLL1_DIV_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_DIV_Msk, (((div-1) & 0xfUL) << SYSCTRL_PLL1_DIV_Pos)) + +/** + * @brief PLL1 Pre Div Set to 2 + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL1_PreDiv_2(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_PREDIV_Msk) + +/** + * @brief PLL1 Pre Div Set to None + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL1_PreDiv_1(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_PREDIV_Msk) + +/** + * @brief PLL1 Ref CLK Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param ref_clk PLL1 Ref CLK + * @return None + */ +#define __LL_SYSCTRL_PLL1_RefClk_Set(__SYSCTRL__, ref_clk) \ + MODIFY_REG((__SYSCTRL__)->PLL1CR, SYSCTRL_PLL1_REFCLK_Msk, ref_clk) + + +/** + * @brief PLL2 Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL2_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_EN_Msk) + +/** + * @brief PLL2 Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL2_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_EN_Msk) + +/** + * @brief Judge PLL2 has Locked or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 PLL2 hasn't Locked + * @retval 1 PLL2 has Locked + */ +#define __LL_SYSCTRL_PLL2_IsLocked(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_LOCKED_Msk) >> SYSCTRL_PLL2_LOCKED_Pos) + +/** + * @brief PLL2 LPF Select 8M + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL2_LPF_8M(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_LPF_Msk) + +/** + * @brief PLL2 LPF Select 26M + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL2_LPF_26M(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_LPF_Msk) + +/** + * @brief PLL2 Band Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param band PLL2 Band + * @return None + */ +#define __LL_SYSCTRL_PLL2_Band_Set(__SYSCTRL__, band) \ + MODIFY_REG((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_BAND_Msk, band) + +/** + * @brief PLL2 GVCO Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param vco PLL2 GVCO + * @return None + */ +#define __LL_SYSCTRL_PLL2_GVCO_Set(__SYSCTRL__, vco) \ + MODIFY_REG((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_GVCO_Msk, vco) + +/** + * @brief PLL2 DIV Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div PLL2 Div + * @return None + */ +#define __LL_SYSCTRL_PLL2_DIV_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_DIV_Msk, (((div-1) & 0xfUL) << SYSCTRL_PLL2_DIV_Pos)) + +/** + * @brief PLL2 Pre Div Set to 2 + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL2_PreDiv_2(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_PREDIV_Msk) + +/** + * @brief PLL2 Pre Div Set to None + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PLL2_PreDiv_1(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_PREDIV_Msk) + +/** + * @brief PLL2 Ref CLK Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param ref_clk PLL2 Ref CLK + * @return None + */ +#define __LL_SYSCTRL_PLL2_RefClk_Set(__SYSCTRL__, ref_clk) \ + MODIFY_REG((__SYSCTRL__)->PLL2CR, SYSCTRL_PLL2_REFCLK_Msk, ref_clk) + + +/** + * @brief SYSCLK Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div SYSCLK Div + * @return None + */ +#define __LL_SYSCTRL_SysClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->SCLKCR, SYSCTRL_SYSCLK_DIV_Msk, (((div-1) & 0xffUL) << SYSCTRL_SYSCLK_DIV_Pos)) + +/** + * @brief SYSCLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src SYSCLK Source + * @return None + */ +#define __LL_SYSCTRL_SysClkSrc_Set(__SYSCTRL__, src) \ + MODIFY_REG((__SYSCTRL__)->SCLKCR, SYSCTRL_SYSCLK_SRC_Msk, src) + + +/** + * @brief APB1 CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB1Clk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_APB1CLK_EN_Msk) + +/** + * @brief APB1 CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB1Clk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_APB1CLK_EN_Msk) + +/** + * @brief APB0 CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB0Clk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_APB0CLK_EN_Msk) + +/** + * @brief APB0 CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB0Clk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_APB0CLK_EN_Msk) + +/** + * @brief AHB CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AHBClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_AHBCLK_EN_Msk) + +/** + * @brief AHB CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AHBClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_AHBCLK_EN_Msk) + +/** + * @brief APB1 CLK Div SET + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div APB1 Div + * @return None + */ +#define __LL_SYSCTRL_APB1ClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->BCLKCR, SYSCTRL_APB1CLK_DIV_Msk, (((div-1) & 0xffUL) << SYSCTRL_APB1CLK_DIV_Pos)) + +/** + * @brief APB1 CLK Div GET + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return APB1 Div + */ +#define __LL_SYSCTRL_APB1ClkDiv_Get(__SYSCTRL__) \ + ((READ_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_APB1CLK_DIV_Msk) >> SYSCTRL_APB1CLK_DIV_Pos) + 1) + +/** + * @brief APB0 CLK Div SET + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div APB0 Div + * @return None + */ +#define __LL_SYSCTRL_APB0ClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->BCLKCR, SYSCTRL_APB0CLK_DIV_Msk, (((div-1) & 0xffUL) << SYSCTRL_APB0CLK_DIV_Pos)) + +/** + * @brief APB0 CLK Div GET + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return APB0 Div + */ +#define __LL_SYSCTRL_APB0ClkDiv_Get(__SYSCTRL__) \ + ((READ_BIT((__SYSCTRL__)->BCLKCR, SYSCTRL_APB0CLK_DIV_Msk) >> SYSCTRL_APB0CLK_DIV_Pos) + 1) + + +/** + * @brief GPIOD Debounce CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src GPIOD Debounce CLK Source + * @return None + */ +#define __LL_SYSCTRL_GPIODDbcSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_GPIOD_DBCCLK_SRC_Msk, src) + +/** + * @brief GPIOC Debounce CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src GPIOC Debounce CLK Source + * @return None + */ +#define __LL_SYSCTRL_GPIOCDbcSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_GPIOC_DBCCLK_SRC_Msk, src) + +/** + * @brief GPIOB Debounce CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src GPIOB Debounce CLK Source + * @return None + */ +#define __LL_SYSCTRL_GPIOBDbcSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_GPIOB_DBCCLK_SRC_Msk, src) + +/** + * @brief GPIOA Debounce CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src GPIOA Debounce CLK Source + * @return None + */ +#define __LL_SYSCTRL_GPIOADbcSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_GPIOA_DBCCLK_SRC_Msk, src) + +/** + * @brief DFLASH Memory CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src DFLASH Memory CLK Source + * @return None + */ +#define __LL_SYSCTRL_DFLASHMemClkSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_DFLASH_MEMCLK_SRC_Msk, src) + +/** + * @brief EFLASH Memory CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src EFLASH Memory CLK Source + * @return None + */ +#define __LL_SYSCTRL_EFLASHMemClkSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_EFLASH_MEMCLK_SRC_Msk, src) + +/** + * @brief ADC Function CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src ADC Function CLK Source + * @return None + */ +#define __LL_SYSCTRL_ADCFunClkSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_ADC_FUNCLK_SRC_Msk, src) + +/** + * @brief HRPWM Function CLK Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src HRPWM Function CLK Source + * @return None + */ +#define __LL_SYSCTRL_HRPWMFunClkSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->FSRCCR, SYSCTRL_HRPWM_FUNCLK_SRC_Msk, src) + + +/** + * @brief DFLASH Memory Clk Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div DFLASH Memory Clk Div + * @return None + */ +#define __LL_SYSCTRL_DFLASHMemClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD0CR, SYSCTRL_DFLASH_MEMCLK_DIV_Msk, (((div-1) & 0xfUL) << SYSCTRL_DFLASH_MEMCLK_DIV_Pos)) + +/** + * @brief EFLASH Memory Clk Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div EFLASH Memory Clk Div + * @return None + */ +#define __LL_SYSCTRL_EFLASHMemClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD0CR, SYSCTRL_EFLASH_MEMCLK_DIV_Msk, (((div-1) & 0xfUL) << SYSCTRL_EFLASH_MEMCLK_DIV_Pos)) + +/** + * @brief ADC Function Clk Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div ADC Function Clk Div + * @return None + */ +#define __LL_SYSCTRL_ADCFunClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD0CR, SYSCTRL_ADC_FUNCLK_DIV_Msk, (((div-1) & 0x3UL) << SYSCTRL_ADC_FUNCLK_DIV_Pos)) + +/** + * @brief HRPWM Function Clk Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div HRPWM Function Clk Div + * @return None + */ +#define __LL_SYSCTRL_HRPWMFunClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD0CR, SYSCTRL_HRPWM_FUNCLK_DIV_Msk, (((div-1) & 0x3UL) << SYSCTRL_HRPWM_FUNCLK_DIV_Pos)) + + +/** + * @brief GPIOD Debounce CLK Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div GPIOD Debounce CLK Div + * @return None + */ +#define __LL_SYSCTRL_GPIODDbcClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD1CR, SYSCTRL_GPIOD_DBCCLK_DIV_Msk, (((div-1) & 0xffUL) << SYSCTRL_GPIOD_DBCCLK_DIV_Pos)) +/** + * @brief GPIOC Debounce CLK Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div GPIOC Debounce CLK Div + * @return None + */ +#define __LL_SYSCTRL_GPIOCDbcClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD1CR, SYSCTRL_GPIOC_DBCCLK_DIV_Msk, (((div-1) & 0xffUL) << SYSCTRL_GPIOC_DBCCLK_DIV_Pos)) + +/** + * @brief GPIOB Debounce CLK Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div GPIOB Debounce CLK Div + * @return None + */ +#define __LL_SYSCTRL_GPIOBDbcClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD1CR, SYSCTRL_GPIOB_DBCCLK_DIV_Msk, (((div-1) & 0xffUL) << SYSCTRL_GPIOB_DBCCLK_DIV_Pos)) + +/** + * @brief GPIOA Debounce CLK Div Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param div GPIOA Debounce CLK Div + * @return None + */ +#define __LL_SYSCTRL_GPIOADbcClkDiv_Set(__SYSCTRL__, div) \ + MODIFY_REG((__SYSCTRL__)->FCD1CR, SYSCTRL_GPIOA_DBCCLK_DIV_Msk, (((div-1) & 0xffUL) << SYSCTRL_GPIOA_DBCCLK_DIV_Pos)) + + +/** + * @brief LSTIMER Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_LSTIMERBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_LSTIMER_BUSCLK_EN_Msk) + +/** + * @brief LSTIMER Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_LSTIMERBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_LSTIMER_BUSCLK_EN_Msk) + +/** + * @brief UART1 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART1BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_UART1_BUSCLK_EN_Msk) + +/** + * @brief UART1 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART1BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_UART1_BUSCLK_EN_Msk) + +/** + * @brief UART0 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART0BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_UART0_BUSCLK_EN_Msk) + +/** + * @brief UART0 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART0BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_UART0_BUSCLK_EN_Msk) + +/** + * @brief I2C1 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C1BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_I2C1_BUSCLK_EN_Msk) + +/** + * @brief I2C1 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C1BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_I2C1_BUSCLK_EN_Msk) + +/** + * @brief I2C0 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C0BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_I2C0_BUSCLK_EN_Msk) + +/** + * @brief I2C0 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C0BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0CCR, SYSCTRL_I2C0_BUSCLK_EN_Msk) + + +/** + * @brief ECU Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ECUBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_ECU_BUSCLK_EN_Msk) + +/** + * @brief ECU Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ECUBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_ECU_BUSCLK_EN_Msk) + +/** + * @brief IIR4 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR4BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR4_BUSCLK_EN_Msk) + +/** + * @brief IIR4 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR4BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR4_BUSCLK_EN_Msk) + +/** + * @brief IIR3 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR3BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR3_BUSCLK_EN_Msk) + +/** + * @brief IIR3 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR3BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR3_BUSCLK_EN_Msk) + +/** + * @brief IIR2 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR2BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR2_BUSCLK_EN_Msk) + +/** + * @brief IIR2 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR2BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR2_BUSCLK_EN_Msk) + +/** + * @brief IIR1 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR1BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR1_BUSCLK_EN_Msk) + +/** + * @brief IIR1 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR1BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR1_BUSCLK_EN_Msk) + +/** + * @brief IIR0 Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR0BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR0_BUSCLK_EN_Msk) + +/** + * @brief IIR0 Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR0BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_IIR0_BUSCLK_EN_Msk) + +/** + * @brief DALI Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DALIBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_DALI_BUSCLK_EN_Msk) + +/** + * @brief DALI Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DALIBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1CCR, SYSCTRL_DALI_BUSCLK_EN_Msk) + + + +/** + * @brief RAM2 Bus Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RAM2BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_RAM2_BUSCLK_EN_Msk) + +/** + * @brief RAM2 Bus Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RAM2BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_RAM2_BUSCLK_EN_Msk) + +/** + * @brief RAM1 Bus Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RAM1BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_RAM1_BUSCLK_EN_Msk) + +/** + * @brief RAM1 Bus Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RAM1BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_RAM1_BUSCLK_EN_Msk) + +/** + * @brief RAM0 Bus Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RAM0BusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_RAM0_BUSCLK_EN_Msk) + +/** + * @brief RAM0 Bus Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RAM0BusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_RAM0_BUSCLK_EN_Msk) + +/** + * @brief USB Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_USBBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_USB_BUSCLK_EN_Msk) + +/** + * @brief USB Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_USBBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_USB_BUSCLK_EN_Msk) + +/** + * @brief DFLASH Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DFLASHBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_DFLASH_BUSCLK_EN_Msk) + +/** + * @brief DFLASH Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DFLASHBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_DFLASH_BUSCLK_EN_Msk) + +/** + * @brief EFLASH Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_EFLASHBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_EFLASH_BUSCLK_EN_Msk) + +/** + * @brief EFLASH Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_EFLASHBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_EFLASH_BUSCLK_EN_Msk) + +/** + * @brief HRPWM Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HRPWMBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_HRPWM_BUSCLK_EN_Msk) + +/** + * @brief HRPWM Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HRPWMBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_HRPWM_BUSCLK_EN_Msk) + +/** + * @brief ADC Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_ADC_BUSCLK_EN_Msk) + +/** + * @brief ADC Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_ADC_BUSCLK_EN_Msk) + +/** + * @brief DAC Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DACBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_DAC_BUSCLK_EN_Msk) + +/** + * @brief DAC Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DACBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_DAC_BUSCLK_EN_Msk) + +/** + * @brief CMP Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CMPBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_CMP_BUSCLK_EN_Msk) + +/** + * @brief CMP Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CMPBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_CMP_BUSCLK_EN_Msk) + +/** + * @brief GPIOD Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIODBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOD_BUSCLK_EN_Msk) + +/** + * @brief GPIOD Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIODBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOD_BUSCLK_EN_Msk) + +/** + * @brief GPIOC Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOCBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOC_BUSCLK_EN_Msk) + +/** + * @brief GPIOC Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOCBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOC_BUSCLK_EN_Msk) + +/** + * @brief GPIOB Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOBBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOB_BUSCLK_EN_Msk) + +/** + * @brief GPIOB Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOBBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOB_BUSCLK_EN_Msk) + +/** + * @brief GPIOA Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOABusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOA_BUSCLK_EN_Msk) + +/** + * @brief GPIOA Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOABusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_GPIOA_BUSCLK_EN_Msk) + +/** + * @brief HSTIMER Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HSTIMERBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_HSTIMER_BUSCLK_EN_Msk) + +/** + * @brief HSTIMER Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HSTIMERBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_HSTIMER_BUSCLK_EN_Msk) + +/** + * @brief CAN Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CANBusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_CAN_BUSCLK_EN_Msk) + +/** + * @brief CAN Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CANBusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_CAN_BUSCLK_EN_Msk) + +/** + * @brief DMA Bus CLK Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DMABusClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_DMA_BUSCLK_EN_Msk) + +/** + * @brief DMA Bus CLK Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DMABusClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBCCR, SYSCTRL_DMA_BUSCLK_EN_Msk) + + +/** + * @brief HRPWM Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HRPWMFunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_HRPWM_FUNCLK_EN_Msk) + +/** + * @brief HRPWM Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HRPWMFunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_HRPWM_FUNCLK_EN_Msk) + +/** + * @brief ADC Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCFunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_ADC_FUNCLK_EN_Msk) + +/** + * @brief ADC Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCFunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_ADC_FUNCLK_EN_Msk) + +/** + * @brief CAN Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CANFunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_CAN_FUNCLK_EN_Msk) + +/** + * @brief CAN Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CANFunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_CAN_FUNCLK_EN_Msk) + +/** + * @brief ECU Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ECUFunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_ECU_FUNCLK_EN_Msk) + +/** + * @brief ECU Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ECUFunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_ECU_FUNCLK_EN_Msk) + +/** + * @brief IIR4 Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR4FunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR4_FUNCLK_EN_Msk) + +/** + * @brief IIR4 Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR4FunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR4_FUNCLK_EN_Msk) + +/** + * @brief IIR3 Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR3FunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR3_FUNCLK_EN_Msk) + +/** + * @brief IIR3 Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR3FunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR3_FUNCLK_EN_Msk) + +/** + * @brief IIR2 Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR2FunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR2_FUNCLK_EN_Msk) + +/** + * @brief IIR2 Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR2FunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR2_FUNCLK_EN_Msk) + +/** + * @brief IIR1 Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR1FunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR1_FUNCLK_EN_Msk) + +/** + * @brief IIR1 Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR1FunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR1_FUNCLK_EN_Msk) + +/** + * @brief IIR0 Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR0FunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR0_FUNCLK_EN_Msk) + +/** + * @brief IIR0 Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR0FunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_IIR0_FUNCLK_EN_Msk) + +/** + * @brief USB Function Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_USBFunClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_USB_FUNCLK_EN_Msk) + +/** + * @brief USB Function Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_USBFunClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_USB_FUNCLK_EN_Msk) + +/** + * @brief DFLASH Memory Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DFLASHMemClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_DFLASH_MEMCLK_EN_Msk) + +/** + * @brief DFLASH Memory Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DFLASHMemClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_DFLASH_MEMCLK_EN_Msk) + +/** + * @brief EFLASH Memory Clk Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_EFLASHMemClk_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_EFLASH_MEMCLK_EN_Msk) + +/** + * @brief EFLASH Memory Clk Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_EFLASHMemClk_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->FUNCCR, SYSCTRL_EFLASH_MEMCLK_EN_Msk) + + +/** + * @brief GPIOD Debounce Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIODDbcSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOD_DBC_SOFTRST_Msk) + +/** + * @brief GPIOD Debounce Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIODDbcSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOD_DBC_SOFTRST_Msk) + +/** + * @brief GPIOC Debounce Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOCDbcSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOC_DBC_SOFTRST_Msk) + +/** + * @brief GPIOC Debounce Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOCDbcSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOC_DBC_SOFTRST_Msk) + +/** + * @brief GPIOB Debounce Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOBDbcSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOB_DBC_SOFTRST_Msk) + +/** + * @brief GPIOB Debounce Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOBDbcSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOB_DBC_SOFTRST_Msk) + +/** + * @brief GPIOA Debounce Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOADbcSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOA_DBC_SOFTRST_Msk) + +/** + * @brief GPIOA Debounce Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOADbcSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_GPIOA_DBC_SOFTRST_Msk) + +/** + * @brief APB1 Bus Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB1BusSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_APB1BUS_SOFTRST_Msk) + +/** + * @brief APB1 Bus Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB1BusSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_APB1BUS_SOFTRST_Msk) + +/** + * @brief APB0 Bus Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB0BusSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_APB0BUS_SOFTRST_Msk) + +/** + * @brief APB0 Bus Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB0BusSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_APB0BUS_SOFTRST_Msk) + +/** + * @brief AHB Bus Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AHBBusSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_AHBBUS_SOFTRST_Msk) + +/** + * @brief AHB Bus Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AHBBusSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSRCR, SYSCTRL_AHBBUS_SOFTRST_Msk) + +/** + * @brief System Soft Reset all Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_SysSoftRstAll_Assert(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->SYSRCR, 0x0) + +/** + * @brief System Soft Reset all Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_SysSoftRstAll_Release(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->SYSRCR, 0xffffffffUL) + + +/** + * @brief LSTIMER Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_LSTIMERSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_LSTIMER_SOFTRST_Msk) + +/** + * @brief LSTIMER Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_LSTIMERSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_LSTIMER_SOFTRST_Msk) + +/** + * @brief UART1 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART1SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_UART1_SOFTRST_Msk) + +/** + * @brief UART1 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART1SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_UART1_SOFTRST_Msk) + +/** + * @brief UART0 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART0SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_UART0_SOFTRST_Msk) + +/** + * @brief UART0 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_UART0SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_UART0_SOFTRST_Msk) + +/** + * @brief I2C1 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C1SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_I2C1_SOFTRST_Msk) + +/** + * @brief I2C1 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C1SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_I2C1_SOFTRST_Msk) + +/** + * @brief I2C0 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C0SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_I2C0_SOFTRST_Msk) + +/** + * @brief I2C0 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C0SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB0RCR, SYSCTRL_I2C0_SOFTRST_Msk) + +/** + * @brief APB0 Soft Reset all Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB0SoftRstAll_Assert(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->APB0RCR, 0x0) + +/** + * @brief APB0 Soft Reset all Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB0SoftRstAll_Release(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->APB0RCR, 0xffffffffUL) + + +/** + * @brief ECU Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ECUSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_ECU_SOFTRST_Msk) + +/** + * @brief ECU Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ECUSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_ECU_SOFTRST_Msk) + +/** + * @brief IIR4 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR4SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR4_SOFTRST_Msk) + +/** + * @brief IIR4 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR4SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR4_SOFTRST_Msk) + +/** + * @brief IIR3 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR3SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR3_SOFTRST_Msk) + +/** + * @brief IIR3 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR3SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR3_SOFTRST_Msk) + +/** + * @brief IIR2 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR2SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR2_SOFTRST_Msk) + +/** + * @brief IIR2 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR2SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR2_SOFTRST_Msk) + +/** + * @brief IIR1 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR1SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR1_SOFTRST_Msk) + +/** + * @brief IIR1 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR1SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR1_SOFTRST_Msk) + +/** + * @brief IIR0 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR0SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR0_SOFTRST_Msk) + +/** + * @brief IIR0 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IIR0SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_IIR0_SOFTRST_Msk) + +/** + * @brief FPLL2 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_FPLL2SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_FPLL2_SOFTRST_Msk) + +/** + * @brief FPLL2 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_FPLL2SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_FPLL2_SOFTRST_Msk) + +/** + * @brief FPLL1 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_FPLL1SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_FPLL1_SOFTRST_Msk) + +/** + * @brief FPLL1 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_FPLL1SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_FPLL1_SOFTRST_Msk) + +/** + * @brief FPLL0 Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_FPLL0SoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_FPLL0_SOFTRST_Msk) + +/** + * @brief FPLL0 Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_FPLL0SoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_FPLL0_SOFTRST_Msk) + +/** + * @brief DALI Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DALISoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_DALI_SOFTRST_Msk) + +/** + * @brief DALI Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DALISoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->APB1RCR, SYSCTRL_DALI_SOFTRST_Msk) + +/** + * @brief APB1 Soft Reset all Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB1SoftRstAll_Assert(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->APB1RCR, 0x0) + +/** + * @brief APB1 Soft Reset all Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_APB1SoftRstAll_Release(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->APB1RCR, 0xffffffffUL) + + +/** + * @brief DFLASH Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DFLASHSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_DFLASH_SOFTRST_Msk) + +/** + * @brief DFLASH Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DFLASHSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_DFLASH_SOFTRST_Msk) + +/** + * @brief HSTIMER Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HSTIMERSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_HSTIMER_SOFTRST_Msk) + +/** + * @brief HSTIMER Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HSTIMERSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_HSTIMER_SOFTRST_Msk) + +/** + * @brief GPIOD Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIODSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOD_SOFTRST_Msk) + +/** + * @brief GPIOD Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIODSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOD_SOFTRST_Msk) + +/** + * @brief GPIOC Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOCSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOC_SOFTRST_Msk) + +/** + * @brief GPIOC Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOCSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOC_SOFTRST_Msk) + +/** + * @brief GPIOB Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOBSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOB_SOFTRST_Msk) + +/** + * @brief GPIOB Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOBSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOB_SOFTRST_Msk) + +/** + * @brief GPIOA Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOASoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOA_SOFTRST_Msk) + +/** + * @brief GPIOA Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIOASoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_GPIOA_SOFTRST_Msk) + +/** + * @brief USB Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_USBSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_USB_SOFTRST_Msk) + +/** + * @brief USB Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_USBSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_USB_SOFTRST_Msk) + +/** + * @brief HRPWM Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HRPWMSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_HRPWM_SOFTRST_Msk) + +/** + * @brief HRPWM Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HRPWMSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_HRPWM_SOFTRST_Msk) + +/** + * @brief DAC Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DACSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_DAC_SOFTRST_Msk) + +/** + * @brief DAC Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DACSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_DAC_SOFTRST_Msk) + +/** + * @brief ADC Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_ADC_SOFTRST_Msk) + +/** + * @brief ADC Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_ADC_SOFTRST_Msk) + +/** + * @brief CMP Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CMPSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_CMP_SOFTRST_Msk) + +/** + * @brief CMP Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CMPSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_CMP_SOFTRST_Msk) + +/** + * @brief EFLASH Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_EFLASHSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_EFLASH_SOFTRST_Msk) + +/** + * @brief EFLASH Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_EFLASHSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_EFLASH_SOFTRST_Msk) + +/** + * @brief CAN Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CANSoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_CAN_SOFTRST_Msk) + +/** + * @brief CAN Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CANSoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_CAN_SOFTRST_Msk) + +/** + * @brief DMA Soft Reset Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DMASoftRst_Assert(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_DMA_SOFTRST_Msk) + +/** + * @brief DMA Soft Reset Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_DMASoftRst_Release(__SYSCTRL__) SET_BIT((__SYSCTRL__)->AHBRCR, SYSCTRL_DMA_SOFTRST_Msk) + +/** + * @brief AHB Soft Reset all Assert + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AHBSoftRstAll_Assert(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->AHBRCR, 0x0) + +/** + * @brief AHB Soft Reset all Release + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AHBSoftRstAll_Release(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->AHBRCR, 0xffffffffUL) + + +/** + * @brief RC8M Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RC8M_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_RC8M_EN_Msk) + +/** + * @brief RC8M Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_RC8M_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_RC8M_EN_Msk) + +/** + * @brief XOSC Loss IRQ Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSCLossIRQ_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSCLOSS_IRQEN_Msk) + +/** + * @brief XOSC Loss IRQ Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSCLossIRQ_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSCLOSS_IRQEN_Msk) + +/** + * @brief XOSC HY Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_HY_EN(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_HYEN_Msk) + +/** + * @brief XOSC HY Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_HY_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_HYEN_Msk) + +/** + * @brief XOSC DR Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param cur Current + * @return None + */ +#define __LL_SYSCTRL_XOSC_DR_Set(__SYSCTRL__, cur) MODIFY_REG((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_DR_Msk, cur) + +/** + * @brief XOSC CTO Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param cap capacitance Register Value + * @return None + */ +#define __LL_SYSCTRL_XOSC_CTO_Set(__SYSCTRL__, cap) \ + MODIFY_REG((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_CTO_Msk, ((cap & 0xfUL) << SYSCTRL_XOSC_CTO_Pos)) + +/** + * @brief XOSC CTI Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param cap capacitance Register Value + * @return None + */ +#define __LL_SYSCTRL_XOSC_CTI_Set(__SYSCTRL__, cap) \ + MODIFY_REG((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_CTI_Msk, ((cap & 0xfUL) << SYSCTRL_XOSC_CTI_Pos)) + +/** + * @brief XOSC CS Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param cap capacitance + * @return None + */ +#define __LL_SYSCTRL_XOSC_CS_Set(__SYSCTRL__, cap) MODIFY_REG((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_CS_Msk, cap) + +/** + * @brief XOSC Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_EN_Msk) + +/** + * @brief XOSC Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->XOSCCR, SYSCTRL_XOSC_EN_Msk) + + +/** + * @brief Judge XOSC Loss or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 XOSC hasn't loss + * @retval 1 XOSC has loss + */ +#define __LL_SYSCTRL_IsXOSCLossPending(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_LOSS_PENDING_Msk) >> SYSCTRL_XOSC_LOSS_PENDING_Pos) + +/** + * @brief Clear XOSC Loss Pending + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSCLossPending_Clr(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_LOSS_PENDING_Msk) + +/** + * @brief Enable SYSCLK Auto Switch to RC8M When XOSC Fault + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_SysclkSw_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_SYSCLK_SWEN_Msk) + +/** + * @brief Disable SYSCLK Auto Switch to RC8M When XOSC Fault + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_SysclkSw_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_SYSCLK_SWEN_Msk) + +/** + * @brief Enable PLL Ref Clk Auto Switch to RC8M When XOSC Fault + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_PLLRefClkSw_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_REFCLK_SWEN_Msk) + +/** + * @brief Disable PLL Ref Clk Auto Switch to RC8M When XOSC Fault + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_PLLRefClkSw_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_REFCLK_SWEN_Msk) + +/** + * @brief XOSC MNT Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_MNT_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_MNTEN_Msk) + +/** + * @brief XOSC MNT Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_XOSC_MNT_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_MNTEN_Msk) + +/** + * @brief XOSC AutoSwitch Window Width Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param width Auto Switch Window Width Register Value + * @return None + */ +#define __LL_SYSCTRL_XOSC_Width_Set(__SYSCTRL__, width) \ + MODIFY_REG((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_WIDTH_Msk, ((width & 0xfUL) << SYSCTRL_XOSC_WIDTH_Pos)) + +/** + * @brief XOSC AutoSwitch Function High Limit Value Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param limit High Limit Register Value + * @return None + */ +#define __LL_SYSCTRL_XOSC_HighLimit_Set(__SYSCTRL__, limit) \ + MODIFY_REG((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_HIGH_LIMIT_Msk, ((limit & 0x3ffUL) << SYSCTRL_XOSC_HIGH_LIMIT_Pos)) + +/** + * @brief XOSC AutoSwitch Function Low Limit Value Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param limit Low Limit Register Value + * @return None + */ +#define __LL_SYSCTRL_XOSC_LowLimit_Set(__SYSCTRL__, limit) \ + MODIFY_REG((__SYSCTRL__)->XASWCR, SYSCTRL_XOSC_LOW_LIMIT_Msk, ((limit & 0x3ffUL) << SYSCTRL_XOSC_LOW_LIMIT_Pos)) + + +/** + * @brief ADC Buffer Source Select + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src ADC Buffer Source + * @return None + */ +#define __LL_SYSCTRL_ADCBufSrc_Sel(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->BUFCR, SYSCTRL_ADCBUF_SRCSEL_Msk, src) + +/** + * @brief ADC Buffer Bypass Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCBufBypass_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->BUFCR, SYSCTRL_ADCBUF_BYPASS_Msk) + +/** + * @brief ADC Buffer Bypass Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCBufBypass_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->BUFCR, SYSCTRL_ADCBUF_BYPASS_Msk) + +/** + * @brief ADC Buffer Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCBuf_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->BUFCR, SYSCTRL_ADCBUF_EN_Msk) + +/** + * @brief ADC Buffer Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCBuf_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->BUFCR, SYSCTRL_ADCBUF_EN_Msk) + +/** + * @brief TOUT Source Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src TOUT Source + * @return None + */ +#define __LL_SYSCTRL_TOUTSrc_Set(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->BUFCR, SYSCTRL_TOUT_SRC_Msk, src) + + +/** + * @brief ADC Fan Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADC_Fan_Dis(__SYSCTRL__) \ + MODIFY_REG((__SYSCTRL__)->SYSCCR, SYSCTRL_ADCCTRL_FANOUT_EN_Msk, (0x0 << SYSCTRL_ADCCTRL_FANOUT_EN_Pos)) + +/** + * @brief ADC Fan Out Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADC_FanOut_En(__SYSCTRL__) \ + MODIFY_REG((__SYSCTRL__)->SYSCCR, SYSCTRL_ADCCTRL_FANOUT_EN_Msk, (0x1 << SYSCTRL_ADCCTRL_FANOUT_EN_Pos)) + +/** + * @brief ADC Fan In Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADC_FanIn_En(__SYSCTRL__) \ + MODIFY_REG((__SYSCTRL__)->SYSCCR, SYSCTRL_ADCCTRL_FANOUT_EN_Msk, (0x2 << SYSCTRL_ADCCTRL_FANOUT_EN_Pos)) + +/** + * @brief ADC Data Fan Out Source Select ADC0 + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCDataFanOutSrc_ADC0(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_ADCDATA_FANOUT_SRC_Msk) + +/** + * @brief ADC Data Fan Out Source Select ADC1 + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCDataFanOutSrc_ADC1(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_ADCDATA_FANOUT_SRC_Msk) + +/** + * @brief ADC Data Fan Out Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCDataFanOut_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_ADCDATA_FANOUT_EN_Msk) + +/** + * @brief ADC Data Fan Out Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_ADCDataFanOut_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_ADCDATA_FANOUT_EN_Msk) + +/** + * @brief I2C1 SMBUS Output Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C1_SMBUSOutput_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_I2C1_SMBUS_OE_Msk) + +/** + * @brief I2C1 SMBUS Output Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C1_SMBUSOutput_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_I2C1_SMBUS_OE_Msk) + +/** + * @brief I2C0 SMBUS Output Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C0_SMBUSOutput_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_I2C0_SMBUS_OE_Msk) + +/** + * @brief I2C0 SMBUS Output Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_I2C0_SMBUSOutput_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_I2C0_SMBUS_OE_Msk) + +/** + * @brief JTAG Bug Fix Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_JTAG_BugFix_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_JTAG_BUGFIX_EN_Msk) + +/** + * @brief JTAG Bug Fix Diaable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_JTAG_BugFix_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_JTAG_BUGFIX_EN_Msk) + +/** + * @brief CAN FD Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CAN_FD_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_CANFD_EN_Msk) + +/** + * @brief CAN FD Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CAN_FD_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_CANFD_EN_Msk) + +/** + * @brief CPU Lockup Reset Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CPU_LockupRst_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_CPU_LOCKUPRST_EN_Msk) + +/** + * @brief CPU Lockup Reset Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CPU_LockupRst_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_CPU_LOCKUPRST_EN_Msk) + +/** + * @brief WWDG Debug Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_WWDG_Debug_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_WWDG_DEBUG_EN_Msk) + +/** + * @brief WWDG Debug Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_WWDG_Debug_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_WWDG_DEBUG_EN_Msk) + +/** + * @brief WWDG Timeout Reset Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_WWDG_TimeoutRst_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_WWDG_TIMEOUTRST_EN_Msk) + +/** + * @brief WWDG Timeout Reset Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_WWDG_TimeoutRst_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_WWDG_TIMEOUTRST_EN_Msk) + +/** + * @brief IWDG Debug Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IWDG_Debug_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_IWDG_DEBUG_EN_Msk) + +/** + * @brief IWDG Debug Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IWDG_Debug_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_IWDG_DEBUG_EN_Msk) + +/** + * @brief IWDG Timeout Reset Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IWDG_TimeoutRst_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_IWDG_TIMEOUTRST_EN_Msk) + +/** + * @brief IWDG Timeout Reset Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IWDG_TimeoutRst_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_IWDG_TIMEOUTRST_EN_Msk) + +/** + * @brief HSTMR Debug Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HSTMR_Debug_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_HSTMR_DEBUG_EN_Msk) + +/** + * @brief HSTMR Debug Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_HSTMR_Debug_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_HSTMR_DEBUG_EN_Msk) + +/** + * @brief LSTMR Debug Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_LSTMR_Debug_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_LSTMR_DEBUG_EN_Msk) + +/** + * @brief LSTMR Debug Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_LSTMR_Debug_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_LSTMR_DEBUG_EN_Msk) + +/** + * @brief GPIO Input NMI Interrupt Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIO_InputNMI_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_GPIO_NMIEN_Msk) + +/** + * @brief GPIO Input NMI Interrupt Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_GPIO_InputNMI_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_GPIO_NMIEN_Msk) + +/** + * @brief CLK Test Source Select + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param src CLK Test Source + * @return None + */ +#define __LL_SYSCTRL_CLK_TestSrc_Sel(__SYSCTRL__, src) MODIFY_REG((__SYSCTRL__)->SYSCCR, SYSCTRL_CLK_TEST_SRC_Msk, src) + +/** + * @brief CLK Fan Out Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CLK_FanOut_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_CLK_FANOUT_EN_Msk) + +/** + * @brief CLK Fan Out Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CLK_FanOut_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_CLK_FANOUT_EN_Msk) + +/** + * @brief PMU Debug1 Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PMU_Debug1_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_PMU_DEBUG1_EN_Msk) + +/** + * @brief PMU Debug1 Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PMU_Debug1_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_PMU_DEBUG1_EN_Msk) + +/** + * @brief PMU Debug0 Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PMU_Debug0_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_PMU_DEBUG0_EN_Msk) + +/** + * @brief PMU Debug0 Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_PMU_Debug0_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_PMU_DEBUG0_EN_Msk) + +/** + * @brief TEST CLK In Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_TESTClkIn_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_TEST_CLKIN_EN_Msk) + +/** + * @brief TEST CLK In Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_TESTClkIn_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->SYSCCR, SYSCTRL_TEST_CLKIN_EN_Msk) + + +/** + * @brief Judge SysReq Reset or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 Isn't SysReq Reset + * @retval 1 Is SysReq Reset + */ +#define __LL_SYSCTRL_IsSysReqRst(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_SYSREQ_RST_ST_Msk) >> SYSCTRL_SYSREQ_RST_ST_Pos) + +/** + * @brief Clear SysReq Reset Pending + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_SysReqRst_Clr(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_SYSREQ_RST_ST_Msk) + +/** + * @brief Judge MCLR Reset or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 Isn't MCLR Reset + * @retval 1 Is MCLR Reset + */ +#define __LL_SYSCTRL_IsMCLRRst(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_MCLR_RST_ST_Msk) >> SYSCTRL_MCLR_RST_ST_Pos) + +/** + * @brief Clear MCLR Reset Pending + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_MCLRRst_Clr(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_MCLR_RST_ST_Msk) + +/** + * @brief Judge LVD Reset or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 Isn't LVD Reset + * @retval 1 Is LVD Reset + */ +#define __LL_SYSCTRL_IsLVDRst(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_LVD_RST_ST_Msk) >> SYSCTRL_LVD_RST_ST_Pos) + +/** + * @brief Clear LVD Reset Pending + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_LVDRst_Clr(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_LVD_RST_ST_Msk) + +/** + * @brief Judge WWDG Reset or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 Isn't WWDG Reset + * @retval 1 Is WWDG Reset + */ +#define __LL_SYSCTRL_IsWWDGRst(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_WWDG_RST_ST_Msk) >> SYSCTRL_WWDG_RST_ST_Pos) + +/** + * @brief Clear WWDG Reset Pending + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_WWDGRst_Clr(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_WWDG_RST_ST_Msk) + +/** + * @brief Judge IWDG Reset or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 Isn't IWDG Reset + * @retval 1 Is IWDG Reset + */ +#define __LL_SYSCTRL_IsIWDGRst(__SYSCTRL__) \ + (READ_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_IWDG_RST_ST_Msk) >> SYSCTRL_IWDG_RST_ST_Pos) + +/** + * @brief Clear IWDG Reset Pending + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_IWDGRst_Clr(__SYSCTRL__) SET_BIT((__SYSCTRL__)->SRSTSR, SYSCTRL_IWDG_RST_ST_Msk) + + +/** + * @brief SYSCTRL Control Register Unlock + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CTRLReg_Unlock(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->KEY, 0x3fac87e4) + +/** + * @brief SYSCTRL FLS Register Unlock + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_FLSReg_Unlock(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->KEY, 0x1f2e3c4a) + +/** + * @brief SYSCTRL Reg Lock + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_Reg_Lock(__SYSCTRL__) WRITE_REG((__SYSCTRL__)->KEY, 0x00) + +/** + * @brief Judge SYSCTRL CTRL Register is unlock or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 SYSCTRL CTRL Register is lock + * @retval 1 SYSCTRL CTRL Register is unlock + */ +#define __LL_SYSCTRL_IsCTRLRegUnlock(__SYSCTRL__) (READ_REG((__SYSCTRL__)->KEY) == 0x3fac87e4) + +/** + * @brief Judge SYSCTRL FLS Register is unlock or not + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @retval 0 SYSCTRL FLS Register is lock + * @retval 1 SYSCTRL FLS Register is unlock + */ +#define __LL_SYSCTRL_IsFLSRegUnlock(__SYSCTRL__) (READ_REG((__SYSCTRL__)->KEY) == 0x1f2e3c4a) + + +/** + * @brief PMU In Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param val Register Value + * @return None + */ +#define __LL_SYSCTRL_PMU_In_Set(__SYSCTRL__, val) \ + MODIFY_REG((__SYSCTRL__)->PMUCR, SYSCTRL_PMU_IN_Msk, ((val & 0x3fUL) << SYSCTRL_PMU_IN_Pos)) + +/** + * @brief CUR Resistance Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param res Resistance Register Value + * @return None + */ +#define __LL_SYSCTRL_CUR_RES_Set(__SYSCTRL__, res) \ + MODIFY_REG((__SYSCTRL__)->PMUCR, SYSCTRL_CUR_RES_Msk, ((res & 0x3fUL) << SYSCTRL_CUR_RES_Pos)) + +/** + * @brief CUR CAL Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param val Register Value + * @return None + */ +#define __LL_SYSCTRL_CUR_CAL_Set(__SYSCTRL__, val) \ + MODIFY_REG((__SYSCTRL__)->PMUCR, SYSCTRL_CUR_CAL_Msk, ((val & 0x3UL) << SYSCTRL_CUR_CAL_Pos)) + +/** + * @brief AVDD DRD Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AVDD_DRD_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_AVDD_DRD_Msk) + +/** + * @brief AVDD DRD Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AVDD_DRD_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_AVDD_DRD_Msk) + +/** + * @brief AVDD Voltage Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param vol AVDD Voltage + * @return None + */ +#define __LL_SYSCTRL_AVDD_VOL_Sel(__SYSCTRL__, vol) MODIFY_REG((__SYSCTRL__)->PMUCR, SYSCTRL_AVDD_SET_Msk, vol) + +/** + * @brief VDD Voltage Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param vol VDD Voltage + * @return None + */ +#define __LL_SYSCTRL_VDD_VOL_Sel(__SYSCTRL__, vol) MODIFY_REG((__SYSCTRL__)->PMUCR, SYSCTRL_VDD_SET_Msk, vol) + +/** + * @brief CUR Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CUR_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_CUR_ENABLE_Msk) + +/** + * @brief CUR Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_CUR_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_CUR_ENABLE_Msk) + +/** + * @brief AVDDLDO Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AVDDLDO_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_AVDDLDO_ENABLE_Msk) + +/** + * @brief AVDDLDO Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_AVDDLDO_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_AVDDLDO_ENABLE_Msk) + +/** + * @brief Temperature Sensor Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_TempSensor_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_TEMPSENSOR_ENABLE_Msk) + +/** + * @brief Temperature Sensor Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_TempSensor_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_TEMPSENSOR_ENABLE_Msk) + +/** + * @brief Band Gap Voltage Set + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @param vol Voltage Register Value + * @return None + */ +#define __LL_SYSCTRL_BandGapVol_Set(__SYSCTRL__, vol) \ + MODIFY_REG((__SYSCTRL__)->PMUCR, SYSCTRL_BGR_VOL_Msk, ((vol & 0x1fUL) << SYSCTRL_BGR_VOL_Pos)) + +/** + * @brief BGR DRD Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_BGR_DRD_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_BGR_DRD_Msk) + +/** + * @brief BGR DRD Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_BGR_DRD_Dis(__SYSCTRL__) CLEAR_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_BGR_DRD_Msk) + +/** + * @brief BGR Filter Enable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_BGR_Filter_En(__SYSCTRL__) SET_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_BGR_FILTER_Msk) + +/** + * @brief BGR Filter Disable + * @param __SYSCTRL__ Specifies SYSCTRL peripheral + * @return None + */ +#define __LL_SYSCTRL_BGR_Filter_Dis(__SYSCTRL__) \ + __LL_SYSCTRL_CtrlREG_OPT(CLEAR_BIT((__SYSCTRL__)->PMUCR, SYSCTRL_BGR_FILTER_Msk)) + + +/** + * @brief SYSCTRL CTRL Register Operation + * @param expression SYSCTRL CTRL Register Read/Write Operation + * @note Only Write Operation need Unlock before Operation + * @return None + */ +#define __LL_SYSCTRL_CtrlREG_OPT(expression) \ + do { \ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); \ + expression; \ + __LL_SYSCTRL_Reg_Lock(SYSCTRL); \ + } while(0) + +/** + * @brief SYSCTRL FLS Register Operation + * @param expression SYSCTRL FLS Register Read/Write Operation + * @note Only Write Operation need Unlock before Operation + * @return None + */ +#define __LL_SYSCTRL_FlsREG_OPT(expression) \ + do { \ + __LL_SYSCTRL_FLSReg_Unlock(SYSCTRL); \ + expression; \ + __LL_SYSCTRL_Reg_Lock(SYSCTRL); \ + } while(0) + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup SYSCTRL_LL_Exported_Types SYSCTRL LL Exported Types + * @brief SYSCTRL LL Exported Types + * @{ + */ + +/** + * @brief SYSCTRL CLK Div Definition + */ +typedef enum { + SYSCTRL_CLK_DIV_IVD = 0,/*!< SYSCTRL CLK DIV IND */ + SYSCTRL_CLK_DIV_1, /*!< SYSCTRL CLK DIV 1 */ + SYSCTRL_CLK_DIV_2, /*!< SYSCTRL CLK DIV 2 */ + SYSCTRL_CLK_DIV_3, /*!< SYSCTRL CLK DIV 3 */ + SYSCTRL_CLK_DIV_4, /*!< SYSCTRL CLK DIV 4 */ + SYSCTRL_CLK_DIV_5, /*!< SYSCTRL CLK DIV 5 */ + SYSCTRL_CLK_DIV_6, /*!< SYSCTRL CLK DIV 6 */ + SYSCTRL_CLK_DIV_7, /*!< SYSCTRL CLK DIV 7 */ + SYSCTRL_CLK_DIV_8, /*!< SYSCTRL CLK DIV 8 */ + SYSCTRL_CLK_DIV_9, /*!< SYSCTRL CLK DIV 9 */ + SYSCTRL_CLK_DIV_10, /*!< SYSCTRL CLK DIV 10 */ + SYSCTRL_CLK_DIV_11, /*!< SYSCTRL CLK DIV 11 */ + SYSCTRL_CLK_DIV_12, /*!< SYSCTRL CLK DIV 12 */ + SYSCTRL_CLK_DIV_13, /*!< SYSCTRL CLK DIV 13 */ + SYSCTRL_CLK_DIV_14, /*!< SYSCTRL CLK DIV 14 */ + SYSCTRL_CLK_DIV_15, /*!< SYSCTRL CLK DIV 15 */ + SYSCTRL_CLK_DIV_16, /*!< SYSCTRL CLK DIV 16 */ + SYSCTRL_CLK_DIV_17, /*!< SYSCTRL CLK DIV 17 */ + SYSCTRL_CLK_DIV_18, /*!< SYSCTRL CLK DIV 18 */ + SYSCTRL_CLK_DIV_19, /*!< SYSCTRL CLK DIV 19 */ + SYSCTRL_CLK_DIV_20, /*!< SYSCTRL CLK DIV 20 */ + SYSCTRL_CLK_DIV_21, /*!< SYSCTRL CLK DIV 21 */ + SYSCTRL_CLK_DIV_22, /*!< SYSCTRL CLK DIV 22 */ + SYSCTRL_CLK_DIV_23, /*!< SYSCTRL CLK DIV 23 */ + SYSCTRL_CLK_DIV_24, /*!< SYSCTRL CLK DIV 24 */ + SYSCTRL_CLK_DIV_25, /*!< SYSCTRL CLK DIV 25 */ + SYSCTRL_CLK_DIV_26, /*!< SYSCTRL CLK DIV 26 */ + SYSCTRL_CLK_DIV_27, /*!< SYSCTRL CLK DIV 27 */ + SYSCTRL_CLK_DIV_28, /*!< SYSCTRL CLK DIV 28 */ + SYSCTRL_CLK_DIV_29, /*!< SYSCTRL CLK DIV 29 */ + SYSCTRL_CLK_DIV_30, /*!< SYSCTRL CLK DIV 30 */ + SYSCTRL_CLK_DIV_31, /*!< SYSCTRL CLK DIV 31 */ + SYSCTRL_CLK_DIV_32, /*!< SYSCTRL CLK DIV 32 */ + SYSCTRL_CLK_DIV_33, /*!< SYSCTRL CLK DIV 33 */ + SYSCTRL_CLK_DIV_34, /*!< SYSCTRL CLK DIV 34 */ + SYSCTRL_CLK_DIV_35, /*!< SYSCTRL CLK DIV 35 */ + SYSCTRL_CLK_DIV_36, /*!< SYSCTRL CLK DIV 36 */ + SYSCTRL_CLK_DIV_37, /*!< SYSCTRL CLK DIV 37 */ + SYSCTRL_CLK_DIV_38, /*!< SYSCTRL CLK DIV 38 */ + SYSCTRL_CLK_DIV_39, /*!< SYSCTRL CLK DIV 39 */ + SYSCTRL_CLK_DIV_40, /*!< SYSCTRL CLK DIV 40 */ + SYSCTRL_CLK_DIV_41, /*!< SYSCTRL CLK DIV 41 */ + SYSCTRL_CLK_DIV_42, /*!< SYSCTRL CLK DIV 42 */ + SYSCTRL_CLK_DIV_43, /*!< SYSCTRL CLK DIV 43 */ + SYSCTRL_CLK_DIV_44, /*!< SYSCTRL CLK DIV 44 */ + SYSCTRL_CLK_DIV_45, /*!< SYSCTRL CLK DIV 45 */ + SYSCTRL_CLK_DIV_46, /*!< SYSCTRL CLK DIV 46 */ + SYSCTRL_CLK_DIV_47, /*!< SYSCTRL CLK DIV 47 */ + SYSCTRL_CLK_DIV_48, /*!< SYSCTRL CLK DIV 48 */ + SYSCTRL_CLK_DIV_49, /*!< SYSCTRL CLK DIV 49 */ + SYSCTRL_CLK_DIV_50, /*!< SYSCTRL CLK DIV 50 */ + SYSCTRL_CLK_DIV_51, /*!< SYSCTRL CLK DIV 51 */ + SYSCTRL_CLK_DIV_52, /*!< SYSCTRL CLK DIV 52 */ + SYSCTRL_CLK_DIV_53, /*!< SYSCTRL CLK DIV 53 */ + SYSCTRL_CLK_DIV_54, /*!< SYSCTRL CLK DIV 54 */ + SYSCTRL_CLK_DIV_55, /*!< SYSCTRL CLK DIV 55 */ + SYSCTRL_CLK_DIV_56, /*!< SYSCTRL CLK DIV 56 */ + SYSCTRL_CLK_DIV_57, /*!< SYSCTRL CLK DIV 57 */ + SYSCTRL_CLK_DIV_58, /*!< SYSCTRL CLK DIV 58 */ + SYSCTRL_CLK_DIV_59, /*!< SYSCTRL CLK DIV 59 */ + SYSCTRL_CLK_DIV_60, /*!< SYSCTRL CLK DIV 60 */ + SYSCTRL_CLK_DIV_61, /*!< SYSCTRL CLK DIV 61 */ + SYSCTRL_CLK_DIV_62, /*!< SYSCTRL CLK DIV 62 */ + SYSCTRL_CLK_DIV_63, /*!< SYSCTRL CLK DIV 63 */ + SYSCTRL_CLK_DIV_64, /*!< SYSCTRL CLK DIV 64 */ + SYSCTRL_CLK_DIV_65, /*!< SYSCTRL CLK DIV 65 */ + SYSCTRL_CLK_DIV_66, /*!< SYSCTRL CLK DIV 66 */ + SYSCTRL_CLK_DIV_67, /*!< SYSCTRL CLK DIV 67 */ + SYSCTRL_CLK_DIV_68, /*!< SYSCTRL CLK DIV 68 */ + SYSCTRL_CLK_DIV_69, /*!< SYSCTRL CLK DIV 69 */ + SYSCTRL_CLK_DIV_70, /*!< SYSCTRL CLK DIV 70 */ + SYSCTRL_CLK_DIV_71, /*!< SYSCTRL CLK DIV 71 */ + SYSCTRL_CLK_DIV_72, /*!< SYSCTRL CLK DIV 72 */ + SYSCTRL_CLK_DIV_73, /*!< SYSCTRL CLK DIV 73 */ + SYSCTRL_CLK_DIV_74, /*!< SYSCTRL CLK DIV 74 */ + SYSCTRL_CLK_DIV_75, /*!< SYSCTRL CLK DIV 75 */ + SYSCTRL_CLK_DIV_76, /*!< SYSCTRL CLK DIV 76 */ + SYSCTRL_CLK_DIV_77, /*!< SYSCTRL CLK DIV 77 */ + SYSCTRL_CLK_DIV_78, /*!< SYSCTRL CLK DIV 78 */ + SYSCTRL_CLK_DIV_79, /*!< SYSCTRL CLK DIV 79 */ + SYSCTRL_CLK_DIV_80, /*!< SYSCTRL CLK DIV 80 */ + SYSCTRL_CLK_DIV_81, /*!< SYSCTRL CLK DIV 81 */ + SYSCTRL_CLK_DIV_82, /*!< SYSCTRL CLK DIV 82 */ + SYSCTRL_CLK_DIV_83, /*!< SYSCTRL CLK DIV 83 */ + SYSCTRL_CLK_DIV_84, /*!< SYSCTRL CLK DIV 84 */ + SYSCTRL_CLK_DIV_85, /*!< SYSCTRL CLK DIV 85 */ + SYSCTRL_CLK_DIV_86, /*!< SYSCTRL CLK DIV 86 */ + SYSCTRL_CLK_DIV_87, /*!< SYSCTRL CLK DIV 87 */ + SYSCTRL_CLK_DIV_88, /*!< SYSCTRL CLK DIV 88 */ + SYSCTRL_CLK_DIV_89, /*!< SYSCTRL CLK DIV 89 */ + SYSCTRL_CLK_DIV_90, /*!< SYSCTRL CLK DIV 90 */ + SYSCTRL_CLK_DIV_91, /*!< SYSCTRL CLK DIV 91 */ + SYSCTRL_CLK_DIV_92, /*!< SYSCTRL CLK DIV 92 */ + SYSCTRL_CLK_DIV_93, /*!< SYSCTRL CLK DIV 93 */ + SYSCTRL_CLK_DIV_94, /*!< SYSCTRL CLK DIV 94 */ + SYSCTRL_CLK_DIV_95, /*!< SYSCTRL CLK DIV 95 */ + SYSCTRL_CLK_DIV_96, /*!< SYSCTRL CLK DIV 96 */ + SYSCTRL_CLK_DIV_97, /*!< SYSCTRL CLK DIV 97 */ + SYSCTRL_CLK_DIV_98, /*!< SYSCTRL CLK DIV 98 */ + SYSCTRL_CLK_DIV_99, /*!< SYSCTRL CLK DIV 99 */ + SYSCTRL_CLK_DIV_100, /*!< SYSCTRL CLK DIV 100 */ + SYSCTRL_CLK_DIV_101, /*!< SYSCTRL CLK DIV 101 */ + SYSCTRL_CLK_DIV_102, /*!< SYSCTRL CLK DIV 102 */ + SYSCTRL_CLK_DIV_103, /*!< SYSCTRL CLK DIV 103 */ + SYSCTRL_CLK_DIV_104, /*!< SYSCTRL CLK DIV 104 */ + SYSCTRL_CLK_DIV_105, /*!< SYSCTRL CLK DIV 105 */ + SYSCTRL_CLK_DIV_106, /*!< SYSCTRL CLK DIV 106 */ + SYSCTRL_CLK_DIV_107, /*!< SYSCTRL CLK DIV 107 */ + SYSCTRL_CLK_DIV_108, /*!< SYSCTRL CLK DIV 108 */ + SYSCTRL_CLK_DIV_109, /*!< SYSCTRL CLK DIV 109 */ + SYSCTRL_CLK_DIV_110, /*!< SYSCTRL CLK DIV 110 */ + SYSCTRL_CLK_DIV_111, /*!< SYSCTRL CLK DIV 111 */ + SYSCTRL_CLK_DIV_112, /*!< SYSCTRL CLK DIV 112 */ + SYSCTRL_CLK_DIV_113, /*!< SYSCTRL CLK DIV 113 */ + SYSCTRL_CLK_DIV_114, /*!< SYSCTRL CLK DIV 114 */ + SYSCTRL_CLK_DIV_115, /*!< SYSCTRL CLK DIV 115 */ + SYSCTRL_CLK_DIV_116, /*!< SYSCTRL CLK DIV 116 */ + SYSCTRL_CLK_DIV_117, /*!< SYSCTRL CLK DIV 117 */ + SYSCTRL_CLK_DIV_118, /*!< SYSCTRL CLK DIV 118 */ + SYSCTRL_CLK_DIV_119, /*!< SYSCTRL CLK DIV 119 */ + SYSCTRL_CLK_DIV_120, /*!< SYSCTRL CLK DIV 120 */ + SYSCTRL_CLK_DIV_121, /*!< SYSCTRL CLK DIV 121 */ + SYSCTRL_CLK_DIV_122, /*!< SYSCTRL CLK DIV 122 */ + SYSCTRL_CLK_DIV_123, /*!< SYSCTRL CLK DIV 123 */ + SYSCTRL_CLK_DIV_124, /*!< SYSCTRL CLK DIV 124 */ + SYSCTRL_CLK_DIV_125, /*!< SYSCTRL CLK DIV 125 */ + SYSCTRL_CLK_DIV_126, /*!< SYSCTRL CLK DIV 126 */ + SYSCTRL_CLK_DIV_127, /*!< SYSCTRL CLK DIV 127 */ + SYSCTRL_CLK_DIV_128, /*!< SYSCTRL CLK DIV 128 */ + SYSCTRL_CLK_DIV_129, /*!< SYSCTRL CLK DIV 129 */ + SYSCTRL_CLK_DIV_130, /*!< SYSCTRL CLK DIV 130 */ + SYSCTRL_CLK_DIV_131, /*!< SYSCTRL CLK DIV 131 */ + SYSCTRL_CLK_DIV_132, /*!< SYSCTRL CLK DIV 132 */ + SYSCTRL_CLK_DIV_133, /*!< SYSCTRL CLK DIV 133 */ + SYSCTRL_CLK_DIV_134, /*!< SYSCTRL CLK DIV 134 */ + SYSCTRL_CLK_DIV_135, /*!< SYSCTRL CLK DIV 135 */ + SYSCTRL_CLK_DIV_136, /*!< SYSCTRL CLK DIV 136 */ + SYSCTRL_CLK_DIV_137, /*!< SYSCTRL CLK DIV 137 */ + SYSCTRL_CLK_DIV_138, /*!< SYSCTRL CLK DIV 138 */ + SYSCTRL_CLK_DIV_139, /*!< SYSCTRL CLK DIV 139 */ + SYSCTRL_CLK_DIV_140, /*!< SYSCTRL CLK DIV 140 */ + SYSCTRL_CLK_DIV_141, /*!< SYSCTRL CLK DIV 141 */ + SYSCTRL_CLK_DIV_142, /*!< SYSCTRL CLK DIV 142 */ + SYSCTRL_CLK_DIV_143, /*!< SYSCTRL CLK DIV 143 */ + SYSCTRL_CLK_DIV_144, /*!< SYSCTRL CLK DIV 144 */ + SYSCTRL_CLK_DIV_145, /*!< SYSCTRL CLK DIV 145 */ + SYSCTRL_CLK_DIV_146, /*!< SYSCTRL CLK DIV 146 */ + SYSCTRL_CLK_DIV_147, /*!< SYSCTRL CLK DIV 147 */ + SYSCTRL_CLK_DIV_148, /*!< SYSCTRL CLK DIV 148 */ + SYSCTRL_CLK_DIV_149, /*!< SYSCTRL CLK DIV 149 */ + SYSCTRL_CLK_DIV_150, /*!< SYSCTRL CLK DIV 150 */ + SYSCTRL_CLK_DIV_151, /*!< SYSCTRL CLK DIV 151 */ + SYSCTRL_CLK_DIV_152, /*!< SYSCTRL CLK DIV 152 */ + SYSCTRL_CLK_DIV_153, /*!< SYSCTRL CLK DIV 153 */ + SYSCTRL_CLK_DIV_154, /*!< SYSCTRL CLK DIV 154 */ + SYSCTRL_CLK_DIV_155, /*!< SYSCTRL CLK DIV 155 */ + SYSCTRL_CLK_DIV_156, /*!< SYSCTRL CLK DIV 156 */ + SYSCTRL_CLK_DIV_157, /*!< SYSCTRL CLK DIV 157 */ + SYSCTRL_CLK_DIV_158, /*!< SYSCTRL CLK DIV 158 */ + SYSCTRL_CLK_DIV_159, /*!< SYSCTRL CLK DIV 159 */ + SYSCTRL_CLK_DIV_160, /*!< SYSCTRL CLK DIV 160 */ + SYSCTRL_CLK_DIV_161, /*!< SYSCTRL CLK DIV 161 */ + SYSCTRL_CLK_DIV_162, /*!< SYSCTRL CLK DIV 162 */ + SYSCTRL_CLK_DIV_163, /*!< SYSCTRL CLK DIV 163 */ + SYSCTRL_CLK_DIV_164, /*!< SYSCTRL CLK DIV 164 */ + SYSCTRL_CLK_DIV_165, /*!< SYSCTRL CLK DIV 165 */ + SYSCTRL_CLK_DIV_166, /*!< SYSCTRL CLK DIV 166 */ + SYSCTRL_CLK_DIV_167, /*!< SYSCTRL CLK DIV 167 */ + SYSCTRL_CLK_DIV_168, /*!< SYSCTRL CLK DIV 168 */ + SYSCTRL_CLK_DIV_169, /*!< SYSCTRL CLK DIV 169 */ + SYSCTRL_CLK_DIV_170, /*!< SYSCTRL CLK DIV 170 */ + SYSCTRL_CLK_DIV_171, /*!< SYSCTRL CLK DIV 171 */ + SYSCTRL_CLK_DIV_172, /*!< SYSCTRL CLK DIV 172 */ + SYSCTRL_CLK_DIV_173, /*!< SYSCTRL CLK DIV 173 */ + SYSCTRL_CLK_DIV_174, /*!< SYSCTRL CLK DIV 174 */ + SYSCTRL_CLK_DIV_175, /*!< SYSCTRL CLK DIV 175 */ + SYSCTRL_CLK_DIV_176, /*!< SYSCTRL CLK DIV 176 */ + SYSCTRL_CLK_DIV_177, /*!< SYSCTRL CLK DIV 177 */ + SYSCTRL_CLK_DIV_178, /*!< SYSCTRL CLK DIV 178 */ + SYSCTRL_CLK_DIV_179, /*!< SYSCTRL CLK DIV 179 */ + SYSCTRL_CLK_DIV_180, /*!< SYSCTRL CLK DIV 180 */ + SYSCTRL_CLK_DIV_181, /*!< SYSCTRL CLK DIV 181 */ + SYSCTRL_CLK_DIV_182, /*!< SYSCTRL CLK DIV 182 */ + SYSCTRL_CLK_DIV_183, /*!< SYSCTRL CLK DIV 183 */ + SYSCTRL_CLK_DIV_184, /*!< SYSCTRL CLK DIV 184 */ + SYSCTRL_CLK_DIV_185, /*!< SYSCTRL CLK DIV 185 */ + SYSCTRL_CLK_DIV_186, /*!< SYSCTRL CLK DIV 186 */ + SYSCTRL_CLK_DIV_187, /*!< SYSCTRL CLK DIV 187 */ + SYSCTRL_CLK_DIV_188, /*!< SYSCTRL CLK DIV 188 */ + SYSCTRL_CLK_DIV_189, /*!< SYSCTRL CLK DIV 189 */ + SYSCTRL_CLK_DIV_190, /*!< SYSCTRL CLK DIV 190 */ + SYSCTRL_CLK_DIV_191, /*!< SYSCTRL CLK DIV 191 */ + SYSCTRL_CLK_DIV_192, /*!< SYSCTRL CLK DIV 192 */ + SYSCTRL_CLK_DIV_193, /*!< SYSCTRL CLK DIV 193 */ + SYSCTRL_CLK_DIV_194, /*!< SYSCTRL CLK DIV 194 */ + SYSCTRL_CLK_DIV_195, /*!< SYSCTRL CLK DIV 195 */ + SYSCTRL_CLK_DIV_196, /*!< SYSCTRL CLK DIV 196 */ + SYSCTRL_CLK_DIV_197, /*!< SYSCTRL CLK DIV 197 */ + SYSCTRL_CLK_DIV_198, /*!< SYSCTRL CLK DIV 198 */ + SYSCTRL_CLK_DIV_199, /*!< SYSCTRL CLK DIV 199 */ + SYSCTRL_CLK_DIV_200, /*!< SYSCTRL CLK DIV 200 */ + SYSCTRL_CLK_DIV_201, /*!< SYSCTRL CLK DIV 201 */ + SYSCTRL_CLK_DIV_202, /*!< SYSCTRL CLK DIV 202 */ + SYSCTRL_CLK_DIV_203, /*!< SYSCTRL CLK DIV 203 */ + SYSCTRL_CLK_DIV_204, /*!< SYSCTRL CLK DIV 204 */ + SYSCTRL_CLK_DIV_205, /*!< SYSCTRL CLK DIV 205 */ + SYSCTRL_CLK_DIV_206, /*!< SYSCTRL CLK DIV 206 */ + SYSCTRL_CLK_DIV_207, /*!< SYSCTRL CLK DIV 207 */ + SYSCTRL_CLK_DIV_208, /*!< SYSCTRL CLK DIV 208 */ + SYSCTRL_CLK_DIV_209, /*!< SYSCTRL CLK DIV 209 */ + SYSCTRL_CLK_DIV_210, /*!< SYSCTRL CLK DIV 210 */ + SYSCTRL_CLK_DIV_211, /*!< SYSCTRL CLK DIV 211 */ + SYSCTRL_CLK_DIV_212, /*!< SYSCTRL CLK DIV 212 */ + SYSCTRL_CLK_DIV_213, /*!< SYSCTRL CLK DIV 213 */ + SYSCTRL_CLK_DIV_214, /*!< SYSCTRL CLK DIV 214 */ + SYSCTRL_CLK_DIV_215, /*!< SYSCTRL CLK DIV 215 */ + SYSCTRL_CLK_DIV_216, /*!< SYSCTRL CLK DIV 216 */ + SYSCTRL_CLK_DIV_217, /*!< SYSCTRL CLK DIV 217 */ + SYSCTRL_CLK_DIV_218, /*!< SYSCTRL CLK DIV 218 */ + SYSCTRL_CLK_DIV_219, /*!< SYSCTRL CLK DIV 219 */ + SYSCTRL_CLK_DIV_220, /*!< SYSCTRL CLK DIV 220 */ + SYSCTRL_CLK_DIV_221, /*!< SYSCTRL CLK DIV 221 */ + SYSCTRL_CLK_DIV_222, /*!< SYSCTRL CLK DIV 222 */ + SYSCTRL_CLK_DIV_223, /*!< SYSCTRL CLK DIV 223 */ + SYSCTRL_CLK_DIV_224, /*!< SYSCTRL CLK DIV 224 */ + SYSCTRL_CLK_DIV_225, /*!< SYSCTRL CLK DIV 225 */ + SYSCTRL_CLK_DIV_226, /*!< SYSCTRL CLK DIV 226 */ + SYSCTRL_CLK_DIV_227, /*!< SYSCTRL CLK DIV 227 */ + SYSCTRL_CLK_DIV_228, /*!< SYSCTRL CLK DIV 228 */ + SYSCTRL_CLK_DIV_229, /*!< SYSCTRL CLK DIV 229 */ + SYSCTRL_CLK_DIV_230, /*!< SYSCTRL CLK DIV 230 */ + SYSCTRL_CLK_DIV_231, /*!< SYSCTRL CLK DIV 231 */ + SYSCTRL_CLK_DIV_232, /*!< SYSCTRL CLK DIV 232 */ + SYSCTRL_CLK_DIV_233, /*!< SYSCTRL CLK DIV 233 */ + SYSCTRL_CLK_DIV_234, /*!< SYSCTRL CLK DIV 234 */ + SYSCTRL_CLK_DIV_235, /*!< SYSCTRL CLK DIV 235 */ + SYSCTRL_CLK_DIV_236, /*!< SYSCTRL CLK DIV 236 */ + SYSCTRL_CLK_DIV_237, /*!< SYSCTRL CLK DIV 237 */ + SYSCTRL_CLK_DIV_238, /*!< SYSCTRL CLK DIV 238 */ + SYSCTRL_CLK_DIV_239, /*!< SYSCTRL CLK DIV 239 */ + SYSCTRL_CLK_DIV_240, /*!< SYSCTRL CLK DIV 240 */ + SYSCTRL_CLK_DIV_241, /*!< SYSCTRL CLK DIV 241 */ + SYSCTRL_CLK_DIV_242, /*!< SYSCTRL CLK DIV 242 */ + SYSCTRL_CLK_DIV_243, /*!< SYSCTRL CLK DIV 243 */ + SYSCTRL_CLK_DIV_244, /*!< SYSCTRL CLK DIV 244 */ + SYSCTRL_CLK_DIV_245, /*!< SYSCTRL CLK DIV 245 */ + SYSCTRL_CLK_DIV_246, /*!< SYSCTRL CLK DIV 246 */ + SYSCTRL_CLK_DIV_247, /*!< SYSCTRL CLK DIV 247 */ + SYSCTRL_CLK_DIV_248, /*!< SYSCTRL CLK DIV 248 */ + SYSCTRL_CLK_DIV_249, /*!< SYSCTRL CLK DIV 249 */ + SYSCTRL_CLK_DIV_250, /*!< SYSCTRL CLK DIV 250 */ + SYSCTRL_CLK_DIV_251, /*!< SYSCTRL CLK DIV 251 */ + SYSCTRL_CLK_DIV_252, /*!< SYSCTRL CLK DIV 252 */ + SYSCTRL_CLK_DIV_253, /*!< SYSCTRL CLK DIV 253 */ + SYSCTRL_CLK_DIV_254, /*!< SYSCTRL CLK DIV 254 */ + SYSCTRL_CLK_DIV_255, /*!< SYSCTRL CLK DIV 255 */ + SYSCTRL_CLK_DIV_256, /*!< SYSCTRL CLK DIV 256 */ +} SYSCTRL_ClkDivETypeDef; + +/** + * @brief SYSCTRL SYSCLK Source Definition + */ +typedef enum { + SYSCLK_SRC_RC32K = 0, /*!< SYSCLK Source RC32K */ + SYSCLK_SRC_RC8M = 1, /*!< SYSCLK Source RC8M */ + SYSCLK_SRC_PLL0DivClk = 2, /*!< SYSCLK Source PLL0 Div Clk */ + SYSCLK_SRC_HOSC = 3, /*!< SYSCLK Source HOSC */ +} SYSCTRL_SysclkSrcETypeDef; + +/** + * @brief SYSCTRL GPIOA Debounce Clock Source Definition + */ +typedef enum { + GPIOA_DBC_CLK_SRC_RC8M = SYSCTRL_GPIOA_DBCCLK_SRC_RC8M, /*!< GPIOA DBC CLK Source RC8M */ + GPIOA_DBC_CLK_SRC_XOSC = SYSCTRL_GPIOA_DBCCLK_SRC_XOSC, /*!< GPIOA DBC CLK Source XOSC */ + GPIOA_DBC_CLK_SRC_SYSCLK = SYSCTRL_GPIOA_DBCCLK_SRC_SYSCLK, /*!< GPIOA DBC CLK Source SYSCLK */ + GPIOA_DBC_CLK_SRC_RC32K = SYSCTRL_GPIOA_DBCCLK_SRC_RC32K, /*!< GPIOA DBC CLK Source RC32K */ +} SYSCTRL_GPIOADbcClkSrcETypeDef; + +/** + * @brief SYSCTRL GPIOB Debounce Clock Source Definition + */ +typedef enum { + GPIOB_DBC_CLK_SRC_RC8M = SYSCTRL_GPIOB_DBCCLK_SRC_RC8M, /*!< GPIOB DBC CLK Source RC8M */ + GPIOB_DBC_CLK_SRC_XOSC = SYSCTRL_GPIOB_DBCCLK_SRC_XOSC, /*!< GPIOB DBC CLK Source XOSC */ + GPIOB_DBC_CLK_SRC_SYSCLK = SYSCTRL_GPIOB_DBCCLK_SRC_SYSCLK, /*!< GPIOB DBC CLK Source SYSCLK */ + GPIOB_DBC_CLK_SRC_RC32K = SYSCTRL_GPIOB_DBCCLK_SRC_RC32K, /*!< GPIOB DBC CLK Source RC32K */ +} SYSCTRL_GPIOBDbcClkSrcETypeDef; + +/** + * @brief SYSCTRL GPIOC Debounce Clock Source Definition + */ +typedef enum { + GPIOC_DBC_CLK_SRC_RC8M = SYSCTRL_GPIOC_DBCCLK_SRC_RC8M, /*!< GPIOC DBC CLK Source RC8M */ + GPIOC_DBC_CLK_SRC_XOSC = SYSCTRL_GPIOC_DBCCLK_SRC_XOSC, /*!< GPIOC DBC CLK Source XOSC */ + GPIOC_DBC_CLK_SRC_SYSCLK = SYSCTRL_GPIOC_DBCCLK_SRC_SYSCLK, /*!< GPIOC DBC CLK Source SYSCLK */ + GPIOC_DBC_CLK_SRC_RC32K = SYSCTRL_GPIOC_DBCCLK_SRC_RC32K, /*!< GPIOC DBC CLK Source RC32K */ +} SYSCTRL_GPIOCDbcClkSrcETypeDef; + +/** + * @brief SYSCTRL GPIOD Debounce Clock Source Definition + */ +typedef enum { + GPIOD_DBC_CLK_SRC_RC8M = SYSCTRL_GPIOD_DBCCLK_SRC_RC8M, /*!< GPIOD DBC CLK Source RC8M */ + GPIOD_DBC_CLK_SRC_XOSC = SYSCTRL_GPIOD_DBCCLK_SRC_XOSC, /*!< GPIOD DBC CLK Source XOSC */ + GPIOD_DBC_CLK_SRC_SYSCLK = SYSCTRL_GPIOD_DBCCLK_SRC_SYSCLK, /*!< GPIOD DBC CLK Source SYSCLK */ + GPIOD_DBC_CLK_SRC_RC32K = SYSCTRL_GPIOD_DBCCLK_SRC_RC32K, /*!< GPIOD DBC CLK Source RC32K */ +} SYSCTRL_GPIODDbcClkSrcETypeDef; + +/** + * @brief SYSCTRL Dflash Clock Source Definition + */ +typedef enum { + DFLASH_CLK_SRC_RC8M = SYSCTRL_DFLASH_MEMCLK_SRC_RC8M, /*!< Dflash CLK Source RC8M */ + DFLASH_CLK_SRC_PLL0DivClk = SYSCTRL_DFLASH_MEMCLK_SRC_PLL0DivClk, /*!< Dflash CLK Source PLL0 Div Clk */ + DFLASH_CLK_SRC_PLL1DivClk = SYSCTRL_DFLASH_MEMCLK_SRC_PLL1DivClk, /*!< Dflash CLK Source PLL1 Div Clk */ + DFLASH_CLK_SRC_PLL2DivClk = SYSCTRL_DFLASH_MEMCLK_SRC_PLL2DivClk, /*!< Dflash CLK Source PLL2 Div Clk */ +} SYSCTRL_DflashClkSrcETypeDef; + +/** + * @brief SYSCTRL Eflash Clock Source Definition + */ +typedef enum { + EFLASH_CLK_SRC_RC8M = SYSCTRL_EFLASH_MEMCLK_SRC_RC8M, /*!< Eflash CLK Source RC8M */ + EFLASH_CLK_SRC_PLL0DivClk = SYSCTRL_EFLASH_MEMCLK_SRC_PLL0DivClk, /*!< Eflash CLK Source PLL0 Div Clk */ + EFLASH_CLK_SRC_PLL1DivClk = SYSCTRL_EFLASH_MEMCLK_SRC_PLL1DivClk, /*!< Eflash CLK Source PLL1 Div Clk */ + EFLASH_CLK_SRC_PLL2DivClk = SYSCTRL_EFLASH_MEMCLK_SRC_PLL2DivClk, /*!< Eflash CLK Source PLL2 Div Clk */ +} SYSCTRL_EflashClkSrcETypeDef; + +/** + * @brief SYSCTRL ADC Function Clock Source Definition + */ +typedef enum { + ADC_FUNC_CLK_SRC_RC8M = SYSCTRL_ADC_FUNCLK_SRC_RC8M, /*!< ADC Function CLK Source RC8M */ + ADC_FUNC_CLK_SRC_HOSC = SYSCTRL_ADC_FUNCLK_SRC_HOSC, /*!< ADC Function CLK Source HOSC */ + ADC_FUNC_CLK_SRC_PLL0 = SYSCTRL_ADC_FUNCLK_SRC_PLL0, /*!< ADC Function CLK Source PLL0 */ + ADC_FUNC_CLK_SRC_PLL1 = SYSCTRL_ADC_FUNCLK_SRC_PLL1, /*!< ADC Function CLK Source PLL1 */ +} SYSCTRL_ADCFuncClkSrcETypeDef; + +/** + * @brief SYSCTRL HRPWM Function Clock Source Definition + */ +typedef enum { + HRPWM_FUNC_CLK_SRC_RC8M = SYSCTRL_HRPWM_FUNCLK_SRC_RC8M, /*!< HRPWM Function CLK Source RC8M */ + HRPWM_FUNC_CLK_SRC_HOSC = SYSCTRL_HRPWM_FUNCLK_SRC_HOSC, /*!< HRPWM Function CLK Source HOSC */ + HRPWM_FUNC_CLK_SRC_PLL0 = SYSCTRL_HRPWM_FUNCLK_SRC_PLL0, /*!< HRPWM Function CLK Source PLL0 */ + HRPWM_FUNC_CLK_SRC_PLL1 = SYSCTRL_HRPWM_FUNCLK_SRC_PLL1, /*!< HRPWM Function CLK Source PLL1 */ +} SYSCTRL_HRPWMFuncClkSrcETypeDef; + +/** + * @brief SYSCTRL PLLCLK Source Definition + */ +typedef enum { + PLLCLK_SRC_XOSC = 0, /*!< PLLCLK Source XOSC */ + PLLCLK_SRC_RC8M = 1, /*!< PLLCLK Source RC8M */ + PLLCLK_SRC_DFT = 3, /*!< PLLCLK Source DFT */ +} SYSCTRL_PllClkSrcETypeDef; + +/** + * @brief SYSCTRL SYSCLK Config Definition + */ +typedef struct __SYSCTRL_SysclkUserCfgTypeDef { + SYSCTRL_SysclkSrcETypeDef sysclk_src; /*!< SYSCLK Source */ + SYSCTRL_PllClkSrcETypeDef pll0clk_src; /*!< PLLCLK Source */ + uint32_t sysclk_src_freq; /*!< SYSCLK Source Freq */ + uint32_t pll0clk_src_freq; /*!< PLLCLK Source Freq */ + uint32_t sysclk_freq; /*!< SYSCLK Freq */ + SYSCTRL_ClkDivETypeDef apb0_clk_div; /*!< APB0 clock Div */ + SYSCTRL_ClkDivETypeDef apb1_clk_div; /*!< APB1 clock Div */ +} SYSCTRL_SysclkUserCfgTypeDef; + +/** + * @brief SYSCTRL PLL1/2 Config Definition + */ +typedef struct __SYSCTRL_PLLUserCfgTypeDef { + SYSCTRL_PllClkSrcETypeDef pll_clk_src; /*!< PLLCLK Source */ + uint32_t pll_in_freq; /*!< PLLCLK Input Freq */ + uint32_t pll_user_freq; /*!< PLLCLK User Freq */ +} SYSCTRL_PLLUserCfgTypeDef; + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup SYSCTRL_LL_Exported_Functions SYSCTRL LL Exported Functions + * @brief SYSCTRL LL Exported Functions + * @{ + */ + +/** @addtogroup SYSCTRL_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_SYSCTRL_SysclkInit(SYSCTRL_TypeDef *Instance, SYSCTRL_SysclkUserCfgTypeDef *sysclk_cfg); +LL_StatusETypeDef LL_SYSCTRL_GPIOA_DbcClkCfg(SYSCTRL_GPIOADbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +LL_StatusETypeDef LL_SYSCTRL_GPIOB_DbcClkCfg(SYSCTRL_GPIOBDbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +LL_StatusETypeDef LL_SYSCTRL_GPIOC_DbcClkCfg(SYSCTRL_GPIOCDbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +LL_StatusETypeDef LL_SYSCTRL_GPIOD_DbcClkCfg(SYSCTRL_GPIODDbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +LL_StatusETypeDef LL_SYSCTRL_DFLASH_ClkCfg(SYSCTRL_DflashClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +LL_StatusETypeDef LL_SYSCTRL_EFLASH_ClkCfg(SYSCTRL_EflashClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +LL_StatusETypeDef LL_SYSCTRL_ADC_FuncClkCfg(SYSCTRL_ADCFuncClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +LL_StatusETypeDef LL_SYSCTRL_HRPWM_FuncClkCfg(SYSCTRL_HRPWMFuncClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div); +uint32_t LL_SYSCTRL_SysclkGet(void); +uint32_t LL_SYSCTRL_AHBClkGet(void); +uint32_t LL_SYSCTRL_APB0ClkGet(void); +uint32_t LL_SYSCTRL_APB1ClkGet(void); +/** + * @} + */ + + +/** @addtogroup SYSCTRL_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_SYSCTRL_Pll0Cfg(SYSCTRL_TypeDef *Instance, SYSCTRL_PLLUserCfgTypeDef *pll0_cfg); +LL_StatusETypeDef LL_SYSCTRL_Pll1Cfg(SYSCTRL_TypeDef *Instance, SYSCTRL_PLLUserCfgTypeDef *pll1_cfg); +LL_StatusETypeDef LL_SYSCTRL_Pll2Cfg(SYSCTRL_TypeDef *Instance, SYSCTRL_PLLUserCfgTypeDef *pll2_cfg); +/** + * @} + */ + + +/** @addtogroup SYSCTRL_LL_Exported_Functions_Group3 + * @{ + */ +void LL_SYSCTRL_LSTMR_ClkEnRstRelease(void); +void LL_SYSCTRL_LSTMR_ClkDisRstAssert(void); +void LL_SYSCTRL_UART1_ClkEnRstRelease(void); +void LL_SYSCTRL_UART1_ClkDisRstAssert(void); +void LL_SYSCTRL_UART0_ClkEnRstRelease(void); +void LL_SYSCTRL_UART0_ClkDisRstAssert(void); +void LL_SYSCTRL_I2C1_ClkEnRstRelease(void); +void LL_SYSCTRL_I2C1_ClkDisRstAssert(void); +void LL_SYSCTRL_I2C0_ClkEnRstRelease(void); +void LL_SYSCTRL_I2C0_ClkDisRstAssert(void); +void LL_SYSCTRL_ECU_ClkEnRstRelease(void); +void LL_SYSCTRL_ECU_ClkDisRstAssert(void); +void LL_SYSCTRL_IIR4_ClkEnRstRelease(void); +void LL_SYSCTRL_IIR4_ClkDisRstAssert(void); +void LL_SYSCTRL_IIR3_ClkEnRstRelease(void); +void LL_SYSCTRL_IIR3_ClkDisRstAssert(void); +void LL_SYSCTRL_IIR2_ClkEnRstRelease(void); +void LL_SYSCTRL_IIR2_ClkDisRstAssert(void); +void LL_SYSCTRL_IIR1_ClkEnRstRelease(void); +void LL_SYSCTRL_IIR1_ClkDisRstAssert(void); +void LL_SYSCTRL_IIR0_ClkEnRstRelease(void); +void LL_SYSCTRL_IIR0_ClkDisRstAssert(void); +void LL_SYSCTRL_DALI_ClkEnRstRelease(void); +void LL_SYSCTRL_DALI_ClkDisRstAssert(void); +void LL_SYSCTRL_FPLL2_RstRelease(void); +void LL_SYSCTRL_FPLL2_RstAssert(void); +void LL_SYSCTRL_FPLL1_RstRelease(void); +void LL_SYSCTRL_FPLL1_RstAssert(void); +void LL_SYSCTRL_FPLL0_RstRelease(void); +void LL_SYSCTRL_FPLL0_RstAssert(void); +void LL_SYSCTRL_USB_ClkEnRstRelease(void); +void LL_SYSCTRL_USB_ClkDisRstAssert(void); +void LL_SYSCTRL_DFLASH_ClkEnRstRelease(void); +void LL_SYSCTRL_DFLASH_ClkDisRstAssert(void); +void LL_SYSCTRL_EFLASH_ClkEnRstRelease(void); +void LL_SYSCTRL_EFLASH_ClkDisRstAssert(void); +void LL_SYSCTRL_HRPWM_ClkEnRstRelease(void); +void LL_SYSCTRL_HRPWM_ClkDisRstAssert(void); +void LL_SYSCTRL_ADC_ClkEnRstRelease(void); +void LL_SYSCTRL_ADC_ClkDisRstAssert(void); +void LL_SYSCTRL_DAC_ClkEnRstRelease(void); +void LL_SYSCTRL_DAC_ClkDisRstAssert(void); +void LL_SYSCTRL_CMP_ClkEnRstRelease(void); +void LL_SYSCTRL_CMP_ClkDisRstAssert(void); +void LL_SYSCTRL_GPIOD_ClkEnRstRelease(void); +void LL_SYSCTRL_GPIOD_ClkDisRstAssert(void); +void LL_SYSCTRL_GPIOC_ClkEnRstRelease(void); +void LL_SYSCTRL_GPIOC_ClkDisRstAssert(void); +void LL_SYSCTRL_GPIOB_ClkEnRstRelease(void); +void LL_SYSCTRL_GPIOB_ClkDisRstAssert(void); +void LL_SYSCTRL_GPIOA_ClkEnRstRelease(void); +void LL_SYSCTRL_GPIOA_ClkDisRstAssert(void); +void LL_SYSCTRL_HSTMR_ClkEnRstRelease(void); +void LL_SYSCTRL_HSTMR_ClkDisRstAssert(void); +void LL_SYSCTRL_CAN_ClkEnRstRelease(void); +void LL_SYSCTRL_CAN_ClkDisRstAssert(void); +void LL_SYSCTRL_DMA_ClkEnRstRelease(void); +void LL_SYSCTRL_DMA_ClkDisRstAssert(void); + +void LL_SYSCTRL_AllPeriphRstAssert(void); +void LL_SYSCTRL_AllPeriphRstRelease(void); +/** + * @} + */ + + +/** @addtogroup SYSCTRL_LL_Exported_Functions_Group4 + * @{ + */ +void LL_SYSCTRL_PMUCfg(void); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_SYSCTRL_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_tmr.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_tmr.h new file mode 100644 index 0000000000..00aea7fab3 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_tmr.h @@ -0,0 +1,847 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_tmr.h + * @author MCD Application Team + * @brief Header for TMR LL module driver + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_TMR_H_ +#define _TAE32F53XX_LL_TMR_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup TMR_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup TMR_LL_Exported_Types TMR LL Exported Types + * @brief TMR LL Exported Types + * @{ + */ + +/** + * @brief TMR Continuous Mode + */ +typedef enum { + TMR_CONTINUOUS_MODE_ENABLE = 0x00000000U, /*!< TMR performed in Continuous counting mode */ + TMR_CONTINUOUS_MODE_DISABLE = TMR_CR_MS, /*!< TMR performed in Single counting mode */ +} TMR_ContinuousETypeDef; + +/** + * @brief TMR Update Event Enable + */ +typedef enum { + TMR_UPDATE_ENABLE = 0x00000000U, /*!< Update event generation enabled */ + TMR_UPDATE_DISABLE = TMR_CR_UDIS, /*!< Update event generation disabled */ +} TMR_UpdateETypeDef; + +/** + * @brief TMR_Update_Request_Source TMR Update Request Source + */ +typedef enum { + TMR_UPDATE_SOURCE_REGULAR = 0x00000000U, /*!< Counter overflow or Setting the UG bit generates an update request */ + TMR_UPDATE_SOURCE_COUNTER = TMR_CR_URS, /*!< Only counter overflow generates an update request */ +} TMR_UpdateSrcETypeDef; + +/** + * @brief TMR Auto-Reload Preload + */ +typedef enum { + TMR_AUTORELOAD_PRELOAD_DISABLE = 0x00000000U, /*!< Disable auto-reload preload feature */ + TMR_AUTORELOAD_PRELOAD_ENABLE = TMR_CR_ARPE, /*!< Enable auto-reload preload feature */ +} TMR_AutoReloadETypeDef; + +/** + * @brief TMR Clock Souce + */ +typedef enum { + TMR_CLKSOURCE_INTERNAL = TMR_CR_CKSRC_0, /*!< Internal clock source */ + TMR_CLKSOURCE_ETR_RISING = TMR_CR_CKSRC_1, /*!< External clock source rising edge */ + TMR_CLKSOURCE_ETR_FALLING = TMR_CR_CKSRC_2, /*!< External clock source falling edge */ + TMR_CLKSOURCE_ETR_BOTHEDGE = TMR_CR_CKSRC_3, /*!< External clock source both rising and falling edge */ +} TMR_ClkSrcETypeDef; + +/** + * @brief TMR PWM Wave Export + */ +typedef enum { + TMR_EXT_PWM_WAVE_DISABLE = 0x00000000U, /*!< Disable the export of the PWM Wave */ + TMR_EXT_PWM_WAVE_ENABLE = TMR_ETER_PWMOE, /*!< Enable the export of the PWM Wave */ +} TMR_Ext_PWMETypeDef; + +/** + * @brief TMR Capture Compare Event Trigger Export + */ +typedef enum { + TMR_EXT_CC_TRIGGER_DISABLE = 0x00000000U, /*!< Disable the export of the Capture Compare Trigger */ + TMR_EXT_CC_TRIGGER_ENABLE = TMR_ETER_CCTE, /*!< Enable the export of the Capture Compare Trigger */ +} TMR_Ext_CCETypeDef; + +/** + * @brief TMR TRGO Trigger Export + */ +typedef enum { + TMR_EXT_TRGO_TRIGGER_DISABLE = 0x00000000U, /*!< Disable the export of the TRGO signal (source from Update Event) Trigger */ + TMR_EXT_TRGO_TRIGGER_ENABLE = TMR_ETER_UTE, /*!< Enable the export of the TRGO signal (source from Update Event) Trigger */ +} TMR_Ext_TRGOETypeDef; + +/** + * @brief TMR Event Source + */ +typedef enum { + TMR_EVENTSOURCE_UG = TMR_EGR_UG, /*!< Reinitialize the counter and generates an update of the registers */ + TMR_EVENTSOURCE_CCG = TMR_EGR_CCG, /*!< A capture/compare event is generated */ +} TMR_EventSRCETypeDef; + +/** @brief TMR Input Capture Selection + */ +typedef enum { + TMR_ICSELECTION_TMR0 = TMR_CCCR_ICSRS_0, /*!< TMR input capture source TMR0 io (specific to (LS)TMR0/1/2/3). */ + TMR_ICSELECTION_TMR4 = TMR_CCCR_ICSRS_0, /*!< TMR input capture source TMR4 io (specific to (HS)TMR4/5/6/7). */ + + TMR_ICSELECTION_TMR1 = TMR_CCCR_ICSRS_1, /*!< TMR input capture source TMR1 io (specific to (LS)TMR0/1/2/3). */ + TMR_ICSELECTION_TMR5 = TMR_CCCR_ICSRS_1, /*!< TMR input capture source TMR5 io (specific to (HS)TMR4/5/6/7). */ + + TMR_ICSELECTION_TMR2 = TMR_CCCR_ICSRS_2, /*!< TMR input capture source TMR2 io (specific to (LS)TMR0/1/2/3). */ + TMR_ICSELECTION_TMR6 = TMR_CCCR_ICSRS_2, /*!< TMR input capture source TMR6 io (specific to (HS)TMR4/5/6/7). */ + + TMR_ICSELECTION_TMR3 = TMR_CCCR_ICSRS_3, /*!< TMR input capture source TMR3 io (specific to (LS)TMR0/1/2/3). */ + TMR_ICSELECTION_TMR7 = TMR_CCCR_ICSRS_3, /*!< TMR input capture source TMR7 io (specific to (HS)TMR4/5/6/7). */ + + TMR_ICSELECTION_CMP0 = TMR_CCCR_ICSRS_4, /*!< The internal CMP0 output single + will be selected as the input source of LSTMR or HSTMR */ + + TMR_ICSELECTION_CMP1 = TMR_CCCR_ICSRS_5, /*!< The internal CMP1 output single + will be selected as the input source of LSTMR or HSTMR */ + + TMR_ICSELECTION_CMP2 = TMR_CCCR_ICSRS_6, /*!< The internal CMP2 output single + will be selected as the input source of LSTMR or HSTMR */ + + TMR_ICSELECTION_CMP3 = TMR_CCCR_ICSRS_7, /*!< The internal CMP3 output single + will be selected as the input source of LSTMR or HSTMR */ +} TMR_ICSelETypeDef; + +/** + * @brief TMR Input Capture Polarity + */ +typedef enum { + TMR_ICPOLARITY_RISING = 0x00000000U, /*!< Capture triggered by rising edge on timer input */ + TMR_ICPOLARITY_FALLING = TMR_CCCR_CCP_0, /*!< Capture triggered by falling edge on timer input */ + TMR_ICPOLARITY_BOTHEDGE = TMR_CCCR_CCP_1, /*!< Capture triggered by both rising and falling edges on timer input */ +} TMR_ICPolarityETypeDef; + +/** + * @brief TMR Output Compare and PWM Modes + */ +typedef enum { + TMR_OCMODE_FROZEN = TMR_CCCR_OCM_0, /*!< Frozen */ + TMR_OCMODE_ACTIVE = TMR_CCCR_OCM_1, /*!< active on match */ + TMR_OCMODE_INACTIVE = TMR_CCCR_OCM_2, /*!< inactive on match */ + TMR_OCMODE_TOGGLE = TMR_CCCR_OCM_3, /*!< Toggle */ + TMR_OCMODE_FORCED_INACTIVE = TMR_CCCR_OCM_4, /*!< Force inactive */ + TMR_OCMODE_FORCED_ACTIVE = TMR_CCCR_OCM_5, /*!< Force active */ + TMR_OCMODE_PWM1 = TMR_CCCR_OCM_6, /*!< PWM mode 1 */ + TMR_OCMODE_PWM2 = TMR_CCCR_OCM_7, /*!< PWM mode 2 */ +} TMR_OCModeETypeDef; + +/** + * @brief TMR_OCPreload_Enable TMR OCPreload Enable + */ +typedef enum { + TMR_OCPRELOAD_DISABLE = 0x00000000U, /*!< TMR OCPreload Disable */ + TMR_OCPRELOAD_ENABLE = TMR_CCCR_OCPE, /*!< TMR OCPreload Enable */ +} TMR_OCPreloadETypeDef; + +/** + * @brief TMR Complementary Output Compare Polarity + */ +typedef enum { + TMR_OCPOLARITY_HIGH = 0x00000000U, /*!< Output Compare polarity active high */ + TMR_OCPOLARITY_LOW = TMR_CCCR_CCP_0, /*!< Output Compare polarity active low */ +} TMR_OCPolarityETypeDef; + +/** + * @brief Timer Base Unit Initialization Structure definition + * @note Please notice that TMR can enable either Input Capture mode or Output Compare mode. + */ +typedef struct __TMR_TB_InitTypeDef { + TMR_ClkSrcETypeDef ClockSource; /*!< Specifies the Clock Source. */ + + uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the TMR clock. + This parameter can be a number in range of: + For low-speed timer(TMR0/1/2/3): from Min 0x0 to Max 0x0000FFFF + For high-speed timer(TMR4/5/6/7): from Min 0x0 to Max 0xFFFFFFFF */ + + uint32_t StartValue; /*!< Specifies the timer counter start value. + This parameter can be a number in range of: + For low-speed timer(TMR0/1/2/3): from Min 0x0 to Max 0x0000FFFF + For high-speed timer(TMR4/5/6/7): from Min 0x0 to Max 0xFFFFFFFF */ + + uint32_t EndValue; /*!< Specifies the timer counter end value. + This parameter can be a number in range of: + For low-speed timer(TMR0/1/2/3): from Min 0x0 to Max 0x0000FFFF + For high-speed timer(TMR4/5/6/7): from Min 0x0 to Max 0xFFFFFFFF */ + + TMR_ContinuousETypeDef ContinuousMode; /*!< Specifies the timer continuous mode enable or disable. */ + + TMR_AutoReloadETypeDef AutoReloadPreload; /*!< Specifies the auto-reload preload. */ + + TMR_UpdateETypeDef UpdateEnable; /*!< Specifies the Update event enable or not. */ + + TMR_UpdateSrcETypeDef UpdateSource; /*!< Specifies the Update request Source */ +} TMR_TB_InitTypeDef; + +/** + * @brief Timer Input Capture Initialization Structure definition + * @note Please notice that TMR can enable either Input Capture mode or Output Compare mode. + */ +typedef struct __TMR_IC_InitTypeDef { + LL_FuncStatusETypeDef ICEnable; /*!< Specifies enable the Input Capture feature or not. + This parameter can be ENABLE or DISABLE */ + + TMR_ICPolarityETypeDef ICPolarity; /*!< Specifies the active edge of the input signal. */ + + TMR_ICSelETypeDef ICSelection; /*!< Specifies the input source to be used. */ + + uint32_t ICFilter; /*!< Specifies the input capture filter. + This parameter can be a number between 0x0 and 0xFF */ +} TMR_IC_InitTypeDef; + +/** + * @brief Timer Output Compare Initialization Structure definition + * @note Please notice that TMR can enable either Input Capture mode or Output Compare mode. + */ +typedef struct __TMR_OC_InitTypeDef { + LL_FuncStatusETypeDef OCEnable; /*!< Specifies enable the Output Compare feature or not. + This parameter can be ENABLE or DISABLE */ + + TMR_OCPolarityETypeDef OCPolarity; /*!< Specifies the output polarity. */ + + TMR_OCPreloadETypeDef OCPreload; /*!< Timer Output Compare Preload Enable */ + + TMR_OCModeETypeDef OCMode; /*!< Specifies the TMR mode. */ + + uint32_t OCValue; /*!< Specifies the compare value which loaded into Capture Compare Register. + This parameter can be a number in range of: + For low-speed timer(TMR0/1/2/3): from Min 0x0 to Max 0x0000FFFF + For high-speed timer(TMR4/5/6/7): from Min 0x0 to Max 0xFFFFFFFF */ +} TMR_OC_InitTypeDef; + +/** + * @brief Timer Export Trigger Initialization Structure definition + */ +typedef struct __TMR_EXT_InitTypeDef { + LL_FuncStatusETypeDef ExtEnable; /*!< Specifies enable the Export Event Trigger feature or not. + This parameter can be ENABLE or DISABLE */ + + TMR_Ext_PWMETypeDef ExtPWMWave; /*!< Specifies PWM Wave (output compare) export to internal signal or not. */ + + TMR_Ext_CCETypeDef ExtCCTrigger; /*!< Specifies Capture Compare Trigger Event export to internal signal or not. */ + + TMR_Ext_TRGOETypeDef ExtTRGOTrigger;/*!< Specifies TMR TRGO signal (source from Update Event) export to internal signal or not. */ +} TMR_EXT_InitTypeDef; + +/** + * @brief Timer Initialization Structure definition + * @note Please notice that TMR can be configured to either Input Capture mode or Output Compare mode. + * Witch means that either ICEnable or OCEnable in the Initialization Structure can be enable the feature. + */ +typedef struct __TMR_InitTypeDef { + TMR_TB_InitTypeDef TBInit; /*!< Timer Base Unit Initialization Structure definition */ + + TMR_IC_InitTypeDef ICInit; /*!< Timer Input Capture Initialization Structure definition */ + + TMR_OC_InitTypeDef OCInit; /*!< Timer Output Compare Initialization Structure */ + + TMR_EXT_InitTypeDef ExtInit; /*!< Timer Export Event Trigger feature Initialization Structure */ +} TMR_InitTypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup TMR_LL_Exported_Constants TMR LL Exported Constants + * @brief TMR LL Exported Constants + * @{ + */ + +/** @defgroup TMR_Interrupt_definition TMR Interrupt Definition + * @{ + */ +#define TMR_IT_UIE TMR_CR_UIE /*!< Update interrupt */ +#define TMR_IT_OVIE TMR_CR_OVIE /*!< Counter Overflow interrupt */ +/** + * @} + */ + +/** @defgroup TMR_CC_Interrupt_definition TMR Capture/Compare Interrupt Definition + * @{ + */ +#define TMR_IT_ICIE TMR_CCCR_ICIE /*!< Input Capture interrupt */ +#define TMR_IT_ICOIE TMR_CCCR_ICOIE /*!< Input Capture OverCapture interrupt */ +#define TMR_IT_OCIE TMR_CCCR_OCIE /*!< Output Compare Match interrupt */ +/** + * @} + */ + +/** @defgroup TMR_Flag_definition TMR Flag Definition + * @{ + */ +#define TMR_FLAG_OVIF TMR_ISR_OVIF /*!< Timer Counter Overflow Interrupt Flag */ +#define TMR_FLAG_ICOIF TMR_ISR_ICOIF /*!< Timer Input Capture OverCapture Interrupt Flag */ +#define TMR_FLAG_ICIF TMR_ISR_ICIF /*!< Timer Input Capture Interrupt Flag */ +#define TMR_FLAG_OCIF TMR_ISR_OCIF /*!< Timer Output Compare Interrupt Flag */ +#define TMR_FLAG_UIF TMR_ISR_UIF /*!< Timer Counter Update Interrupt Flag */ +/** + * @} + */ + +/** @defgroup TMR_Sync_definition Timer Group synchronization Definition + * @{ + */ +#define TMRGRP_SYNC_TMR0 TMRGRP_SYNC0EN /*!< Select TMR0(specific to TMRGRP0) */ +#define TMRGRP_SYNC_TMR4 TMRGRP_SYNC0EN /*!< Select TMR4(specific to TMRGRP1) */ + +#define TMRGRP_SYNC_TMR1 TMRGRP_SYNC1EN /*!< Select TMR1(specific to TMRGRP0) */ +#define TMRGRP_SYNC_TMR5 TMRGRP_SYNC1EN /*!< Select TMR5(specific to TMRGRP1) */ + +#define TMRGRP_SYNC_TMR2 TMRGRP_SYNC2EN /*!< Select TMR2(specific to TMRGRP0) */ +#define TMRGRP_SYNC_TMR6 TMRGRP_SYNC2EN /*!< Select TMR6(specific to TMRGRP1) */ + +#define TMRGRP_SYNC_TMR3 TMRGRP_SYNC3EN /*!< Select TMR2(specific to TMRGRP0) */ +#define TMRGRP_SYNC_TMR7 TMRGRP_SYNC3EN /*!< Select TMR6(specific to TMRGRP1) */ + +#define TMRGRP_SYNC_ALL TMRGRP_SYNCALLEN /*!< Select all TMRs in TMRGRPx(x = 0 or 1) */ +/** + * @} + */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup TMR_LL_Exported_Macros TMR LL Exported Macros + * @brief TMR LL Exported Macros + * @{ + */ + +/** + * @brief Enable TMR Base Unit on runtime + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR, TMR_CR_CEN) + +/** + * @brief Disable TMR Base Unit on runtime + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR, TMR_CR_CEN) + +/** + * @brief Enable TMR Capture/Compare feature on runtime + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_CC_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CCCR, TMR_CCCR_CCE) + +/** + * @brief Disable TMR Capture/Compare feature on runtime + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_CC_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CCCR, TMR_CCCR_CCE) + + +/** + * @brief Enable the specified TMR Basic Unit Interrupt + * @param __INSTANCE__ TMR peripheral + * @param __INTERRUPT__ specifies the TMR base unit interrupt source to enable. + * This parameter can be any combination of @ref TMR_Interrupt_definition: + * @arg TMR_IT_UIE: Update interrupt + * @arg TMR_IT_OVIE: Counter Overflow interrupt + * @return None + */ +#define __LL_TMR_IT_ENABLE(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) + +/** + * @brief Disable the specified TMR Basic Unit Interrupt + * @param __INSTANCE__ TMR peripheral + * @param __INTERRUPT__ specifies the TMR base unit interrupt source to disable. + * This parameter can be any combination of @ref TMR_Interrupt_definition: + * @arg TMR_IT_UIE: Update interrupt + * @arg TMR_IT_OVIE: Counter Overflow interrupt + * @return None + */ +#define __LL_TMR_IT_DISABLE(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) + +/** + * @brief Check whether the specified TMR Basic Unit interrupt source is set or not. + * @param __INSTANCE__ TMR peripheral + * @param __INTERRUPT__ specifies the TMR interrupt source to check. + * This parameter can be any combination of @ref TMR_Interrupt_definition: + * @arg TMR_IT_UIE: Update interrupt + * @arg TMR_IT_OVIE: Counter Overflow interrupt + * @return The state of __INTERRUPT__ (SET or RESET). + */ +#define __LL_TMR_IT_CHECK_SOURCE(__INSTANCE__, __INTERRUPT__) ((READ_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) \ + == (__INTERRUPT__)) ? SET : RESET) + +/** + * @brief Enable the specified Capture/Compare Interrupt + * @param __INSTANCE__ TMR peripheral + * @param __INTERRUPT__ specifies the TMR Capture/Compare interrupt source to enable. + * This parameter can be any combination of @ref TMR_CC_Interrupt_definition: + * @arg TMR_IT_ICIE: Input Capture interrupt + * @arg TMR_IT_ICOIE: Input Capture OverCapture interrupt + * @arg TMR_IT_OCIE: Output Compare Match interrupt + * @return None + */ +#define __LL_TMR_CC_IT_ENABLE(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CCCR, (__INTERRUPT__)) + +/** + * @brief Disable Input Capture Interrupt + * @param __INSTANCE__ TMR peripheral + * @param __INTERRUPT__ specifies the TMR Capture/Compare interrupt source to disable. + * This parameter can be any combination of @ref TMR_CC_Interrupt_definition: + * @arg TMR_IT_ICIE: Input Capture interrupt + * @arg TMR_IT_ICOIE: Input Capture OverCapture interrupt + * @arg TMR_IT_OCIE: Output Compare Matched interrupt + * @return None + */ +#define __LL_TMR_CC_IT_DISABLE(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CCCR, (__INTERRUPT__)) + + +/** + * @brief Check whether the specified TMR Capture/Compare interrupt source is set or not. + * @param __INSTANCE__ TMR peripheral + * @param __INTERRUPT__ specifies the TMR Capture/Compare interrupt source to check. + * This parameter can be any combination of @ref TMR_CC_Interrupt_definition: + * @arg TMR_IT_ICIE: Input Capture interrupt + * @arg TMR_IT_ICOIE: Input Capture OverCapture interrupt + * @arg TMR_IT_OCIE: Output Compare Matched interrupt + * @return he state of __INTERRUPT__ (SET or RESET). + */ +#define __LL_TMR_CC_IT_CHECK_SOURCE(__INSTANCE__, __INTERRUPT__) \ + ((READ_BIT((__INSTANCE__)->CCCR, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** + * @brief Check whether the specified TMR interrupt flag is set or not. + * @param __INSTANCE__ TMR peripheral. + * @param __FLAG__ specifies the TMR flags to check. + * This parameter can be any combination of @ref TMR_Flag_definition: + * @arg TMR_FLAG_OVIF: Counter Overflow Interrupt Flag + * @arg TMR_FLAG_ICOIF: Input Capture OverCapture Interrupt Flag + * @arg TMR_FLAG_ICIF: Input Capture Interrupt Flag + * @arg TMR_FLAG_OCIF: Output Compare Interrupt Flag + * @arg TMR_FLAG_UIF: Counter Update Interrupt Flag + * @return The state of __FLAG__ (SET or RESET). + */ +#define __LL_TMR_GET_FLAG(__INSTANCE__, __FLAG__) \ + ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) + +/** + * @brief Clear the specified TMR interrupt flags + * @param __INSTANCE__ TMR peripheral + * @param __FLAG__ specifies the TMR flags to clear. + * This parameter can be any combination of @ref TMR_Flag_definition: + * @arg TMR_FLAG_OVIF: Counter Overflow Interrupt Flag + * @arg TMR_FLAG_ICOIF: Input Capture OverCapture Interrupt Flag + * @arg TMR_FLAG_ICIF: Input Capture Interrupt Flag + * @arg TMR_FLAG_OCIF: Output Compare Interrupt Flag + * @arg TMR_FLAG_UIF: Counter Update Interrupt Flag + * @return None + */ +#define __LL_TMR_CLEAR_FLAG(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__)) + +/** + * @brief Enable TMR Auto-Reload feature + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_AUTORELOAD_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR, TMR_CR_ARPE) + +/** + * @brief Disable TMR Auto-Reload feature + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_AUTORELOAD_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR, TMR_CR_ARPE) + +/** + * @brief Enable TMR Output Compare Preload feature + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_OC_PRELOAD_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CCCR, TMR_CCCR_OCPE) + +/** + * @brief Disable TMR Output Compare Preload feature + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_OC_PRELOAD_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CCCR, TMR_CCCR_OCPE) + +/** + * @brief Enable TMR Update event (UDIS) + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_UPDATE_ENABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR, TMR_CR_UDIS) + +/** + * @brief Disable TMR Update event (UDIS) + * @param __INSTANCE__ TMR peripheral + * @return None + */ +#define __LL_TMR_UPDATE_DISABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR, TMR_CR_UDIS) + +/** + * @brief Selection of the Update Request Source (URS) bit of the TMRx_CR register. + * @param __INSTANCE__ TMR peripheral + * @param __SOURCE__ specifies the Update Request Source + * This parameter can be one of the following values in @ref TMR_Update_Request_Source: + * @arg TMR_UPDATE_SOURCE_REGULAR: Counter overflow or Setting the UG bit generates an update request + * @arg TMR_UPDATE_SOURCE_COUNTER: Only counter overflow generates an update request + * @note To generate the update request, Update event should be enabled(reset UDIS bit in TMRx_CR register). + * @return None + */ +#define __LL_TMR_UPDATE_SOURCE(__INSTANCE__, __SOURCE__) MODIFY_REG((__INSTANCE__)->CR, TMR_CR_URS_Msk, (__SOURCE__)) + +/** + * @brief Set the TMR Prescaler on runtime. + * @param __INSTANCE__ TMR peripheral + * @param __PRESC__ specifies the Prescaler new value. + * @retval None + */ +#define __LL_TMR_SET_PRESCALER(__INSTANCE__, __PRESC__) WRITE_REG((__INSTANCE__)->PSCR, (__PRESC__)) + +/** + * @brief Get the TMR Prescaler on runtime. + * @param __INSTANCE__ TMR peripheral + * @retval 16-bit or 32-bit value of the timer prescaler register (TMRx_PSCR) + */ +#define __LL_TMR_GET_PRESCALER(__INSTANCE__) READ_REG((__INSTANCE__)->PSCR) + +/** + * @brief Set the TMR Start value on runtime. + * @param __INSTANCE__ TMR peripheral + * @param __START__ specifies the new starting value. + * @retval None + */ +#define __LL_TMR_SET_START_VAL(__INSTANCE__, __START__) WRITE_REG((__INSTANCE__)->CSVR, (__START__)) + +/** + * @brief Get the TMR Start value on runtime. + * @param __INSTANCE__ TMR peripheral + * @retval 16-bit or 32-bit value of the timer start value register (TMRx_CSVR) + */ +#define __LL_TMR_GET_START_VAL(__INSTANCE__) READ_REG((__INSTANCE__)->CSVR) + +/** + * @brief Set the TMR End value on runtime. + * @param __INSTANCE__ TMR peripheral + * @param __END__ specifies the new ending value. + * @retval None + */ +#define __LL_TMR_SET_END_VAL(__INSTANCE__, __END__) WRITE_REG((__INSTANCE__)->CEVR, (__END__)) + +/** + * @brief Get the TMR End value on runtime. + * @param __INSTANCE__ TMR peripheral + * @retval 16-bit or 32-bit value of the timer end value register (TMRx_CEVR) + */ +#define __LL_TMR_GET_END_VAL(__INSTANCE__) READ_REG((__INSTANCE__)->CEVR) + +/** + * @brief Set the TMR Counter Register value on runtime. + * @param __INSTANCE__ TMR peripheral + * @param __COUNTER__ specifies the Counter register new value. + * @return None + */ +#define __LL_TMR_SET_COUNTER(__INSTANCE__, __COUNTER__) WRITE_REG((__INSTANCE__)->CNTR, (__COUNTER__)) + +/** + * @brief Get the TMR Counter Register value on runtime. + * @param __INSTANCE__ TMR peripheral + * @return 16-bit or 32-bit value of the timer counter register (TMRx_CNTR) + */ +#define __LL_TMR_GET_COUNTER(__INSTANCE__) READ_REG((__INSTANCE__)->CNTR) + +/** + * @brief Set the TMR Capture Compare Register(TMRx_CCR) value on runtime. + * @note This macro normally used when the TMR is configured in Output Compare mode. + * User can use the macro to change the compare value on runtime without calling + * another time Config function. + * @note The new value will take effect immediately when Output Compare Preload (OCPE) + * is disabled. Otherwise it will take effect by following condition: + * - Update event generated by counter overflow only (if Update event enabled) + * - Compare Matching event with the older value. + * - Software generate by setting the CCG bit in TMRx_EGR register + * @param __INSTANCE__ TMR peripheral + * @param __COMPARE__ specifies the Counter register new value. + * @return None + */ +#define __LL_TMR_SET_COMPARE(__INSTANCE__, __COMPARE__) WRITE_REG((__INSTANCE__)->CCR, (__COMPARE__)) + +/** + * @brief Get the TMR Capture Compare Register(TMRx_CCR) value on runtime. + * @note This macro normally used when the TMR is configured in Input Capture mode. + * User can use the macro to get the new capture value on runtime when a Capture event + * is generated by fllowing condition: + * - Input source trigger an edge matches the Input Capture Polarity edge configuration (CCP) + * - Software generate by setting the CCG bit in TMRx_EGR register + * @param __INSTANCE__ TMR peripheral + * @return 16-bit or 32-bit value of the timer capture compare register (TMRx_CCR) + */ +#define __LL_TMR_GET_CAPTURE(__INSTANCE__) READ_REG((__INSTANCE__)->CCR) + +/** + * @brief Set the input channel polarity. + * @param __INSTANCE__ Timer peripheral + * @param __POLARITY__ This parameter can be one of the following values in @ref TMR_Input_Capture_Polarity: + * @arg @ref TMR_ICPOLARITY_RISING :Capture triggered by rising edge on timer input + * @arg @ref TMR_ICPOLARITY_FALLING :Capture triggered by falling edge on timer input + * @arg @ref TMR_ICPOLARITY_BOTHEDGE :Capture triggered by both rising and falling edges on timer input + * @retval None + */ +#define __LL_TMR_POLARITY_SET(__INSTANCE__, __POLARITY__) MODIFY_REG((__INSTANCE__)->CCCR, TMR_CCCR_CCP_Msk, (__POLARITY__)) + +/** + * @brief Set the TMR Ouput Compare Mode on runtime. + * @param __INSTANCE__ TMR peripheral + * @param __OCMODE__ TMR Output Compare and PWM Modes + * This parameter can be one of @ref TMR_Output_Compare_and_PWM_modes + * @return None + */ +#define __LL_TMR_SET_OCMODE(__INSTANCE__, __OCMODE__) MODIFY_REG((__INSTANCE__)->CCCR, TMR_CCCR_OCM_Msk, (__OCMODE__)) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup TMR_LL_Exported_Functions + * @{ + */ + +/** @addtogroup TMR_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_TMR_Init(TMR_TypeDef *Instance, TMR_InitTypeDef *Init); +LL_StatusETypeDef LL_TMR_DeInit(TMR_TypeDef *Instance); +void LL_TMR_MspInit(TMR_TypeDef *Instance); +void LL_TMR_MspDeInit(TMR_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup TMR_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_TMR_TB_Config(TMR_TypeDef *Instance, TMR_TB_InitTypeDef *sConfig); +LL_StatusETypeDef LL_TMR_IC_Config(TMR_TypeDef *Instance, TMR_IC_InitTypeDef *sConfig); +LL_StatusETypeDef LL_TMR_OC_Config(TMR_TypeDef *Instance, TMR_OC_InitTypeDef *sConfig); +LL_StatusETypeDef LL_TMR_EXT_Config(TMR_TypeDef *Instance, TMR_EXT_InitTypeDef *sConfig); +/** + * @} + */ + + +/** @addtogroup TMR_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_TMR_Start(TMR_TypeDef *Instance); +LL_StatusETypeDef LL_TMR_Stop(TMR_TypeDef *Instance); +LL_StatusETypeDef LL_TMR_Start_IT(TMR_TypeDef *Instance); +LL_StatusETypeDef LL_TMR_Stop_IT(TMR_TypeDef *Instance); +LL_StatusETypeDef LL_TMR_Start_Synchro(TMRGRP_TypeDef *TMRGRPx, uint32_t SynchroMask); +LL_StatusETypeDef LL_TMR_Stop_Synchro(TMRGRP_TypeDef *TMRGRPx, uint32_t SynchroMask); +LL_StatusETypeDef LL_TMR_EventGenerate(TMR_TypeDef *Instance, TMR_EventSRCETypeDef EventSource); +/** + * @} + */ + + +/** @addtogroup TMR_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_TMR_IRQHandler(TMR_TypeDef *Instance); +void LL_TMR_TB_UpdateCallback(TMR_TypeDef *Instance); +void LL_TMR_TB_OverflowCallback(TMR_TypeDef *Instance); +void LL_TMR_IC_CaptureCallback(TMR_TypeDef *Instance); +void LL_TMR_IC_OverCaptureCallback(TMR_TypeDef *Instance); +void LL_TMR_OC_CompareMatchedCallback(TMR_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup TMR_LL_Private_Macros TMR LL Private Macros + * @brief TMR LL Private Macros + * @{ + */ + +/** + * @brief Judge is LSTMR instance or not + * @param __INSTANCE__ instance to judge + * @retval 0 isn't LSTMR instance + * @retval 1 is LSTMR instance + */ +#define IS_TMR_LSTMR_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TMR0) || \ + ((__INSTANCE__) == TMR1) || \ + ((__INSTANCE__) == TMR2) || \ + ((__INSTANCE__) == TMR3)) + +/** + * @brief Judge is HSTMR instance or not + * @param __INSTANCE__ instance to judge + * @retval 0 isn't HSTMR instance + * @retval 1 is HSTMR instance + */ +#define IS_TMR_HSTMR_INSTANCE(__INSTANCE__) (((__INSTANCE__) == TMR4) || \ + ((__INSTANCE__) == TMR5) || \ + ((__INSTANCE__) == TMR6) || \ + ((__INSTANCE__) == TMR7)) + +/** + * @brief Judge is LSTMR prescaler or not + * @param __PRESCALER__ prescaler to judge + * @retval 0 isn't LSTMR prescaler + * @retval 1 is LSTMR prescaler + */ +#define IS_TMR_LSTMR_PRESCALER(__PRESCALER__) ((__PRESCALER__) <= 0xFFFFU ) + +/** + * @brief Judge is HSTMR prescaler or not + * @param __PRESCALER__ prescaler to judge + * @retval 0 isn't HSTMR prescaler + * @retval 1 is HSTMR prescaler + */ +#define IS_TMR_HSTMR_PRSCALER(__PRESCALER__) ((__PRESCALER__) <= 0xFFFFFFFFU ) + +/** + * @brief Judge is LSTMR start value or not + * @param __VAL__ value to judge + * @retval 0 is LSTMR start value + * @retval 1 is LSTMR start value + */ +#define IS_TMR_LSTMR_START_VAL(__VAL__) ((__VAL__) <= 0xFFFFUL) + +/** + * @brief Judge is HSTMR start value or not + * @param __VAL__ value to judge + * @retval 0 is HSTMR start value + * @retval 1 is HSTMR start value + */ +#define IS_TMR_HSTMR_START_VAL(__VAL__) ((__VAL__) <= 0xFFFFFFFFUL) + +/** + * @brief Judge is LSTMR end value or not + * @param __VAL__ value to judge + * @retval 0 is LSTMR end value + * @retval 1 is LSTMR end value + */ +#define IS_TMR_LSTMR_END_VAL(__VAL__) ((__VAL__) <= 0xFFFFUL) + +/** + * @brief Judge is HSTMR end value or not + * @param __VAL__ value to judge + * @retval 0 is HSTMR end value + * @retval 1 is HSTMR end value + */ +#define IS_TMR_HSTMR_END_VAL(__VAL__) ((__VAL__) <= 0xFFFFFFFFUL) + +/** + * @brief Judge is LSTMR compare value or not + * @param __VAL__ value to judge + * @retval 0 isn't LSTMR compare value + * @retval 1 is LSTMR compare value + */ +#define IS_TMR_LSTMR_COMPARE_VAL(__VAL__) ((__VAL__) <= 0xFFFFUL) + +/** + * @brief Judge is HSTMR compare value or not + * @param __VAL__ value to judge + * @retval 0 isn't HSTMR compare value + * @retval 1 is HSTMR compare value + */ +#define IS_TMR_HSTMR_COMPARE_VAL(__VAL__) ((__VAL__) <= 0xFFFFFFFFUL) + + +/** + * @brief Judge is TMR input capture filter or not + * @param __FILTER__ filter to judge + * @retval 0 isn't TMR input capture filter + * @retval 1 is TMR input capture filter + */ +#define IS_TMR_ICFILTER(__FILTER__) ((__FILTER__) <= 0xFFUL) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_TMR_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_uart.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_uart.h new file mode 100644 index 0000000000..86a36aa297 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_uart.h @@ -0,0 +1,873 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_uart.h + * @author MCD Application Team + * @brief Header file for UART LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_UART_H_ +#define _TAE32F53XX_LL_UART_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" +#ifdef LL_DMA_MODULE_ENABLED +#include "tae32f53xx_ll_dma.h" +#endif + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup UART_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup UART_LL_Exported_Types UART LL Exported Types + * @brief UART LL Exported Types + * @{ + */ + +/** + * @brief UART interrupt ID type definition + */ +typedef enum { + UART_INT_ID_MODEM_STA = 0x0, /*!< modem status */ + UART_INT_ID_NO_INT_PENDING = 0x1, /*!< no interrupt pending */ + UART_INT_ID_TX_EMPTY = 0x2, /*!< THR register empty */ + UART_INT_ID_RX_AVL = 0x4, /*!< received data available */ + UART_INT_ID_RX_LINE_STA = 0x6, /*!< receiver line status */ + UART_INT_ID_BUSY_DET = 0x7, /*!< busy detect */ + UART_INT_ID_CHAR_TIMEOUT = 0xc, /*!< character timeout */ +} UART_IntIdETypeDef; + +/** + * @brief UART data length type definition + */ +typedef enum { + UART_DAT_LEN_5b = 0, /*!< Data length 5bits */ + UART_DAT_LEN_6b = 1, /*!< Data length 6bits */ + UART_DAT_LEN_7b = 2, /*!< Data length 7bits */ + UART_DAT_LEN_8b = 3, /*!< Data length 8bits */ + UART_DAT_LEN_9b = 4, /*!< Data length 9bits */ +} UART_DatLenETypeDef; + +/** + * @brief UART stop length type definition + */ +typedef enum { + UART_STOP_LEN_1b, /*!< Stop length 1bit */ + UART_STOP_LEN_1b5, /*!< Stop length 1.5bit */ + UART_STOP_LEN_2b, /*!< Stop length 2bits */ +} UART_StopLenETypeDef; + +/** + * @brief UART parity type definition + */ +typedef enum { + UART_PARITY_NO, /*!< Parity no */ + UART_PARITY_ODD, /*!< Parity odd */ + UART_PARITY_EVEN, /*!< Parity even */ +} UART_ParityETypeDef; + +/** + * @brief UART tx empty trigger level type definition + */ +typedef enum { + UART_TX_EMPTY_TRI_LVL_EMPTY = UART_TX_FIFO_TRIG_EMPTY, /*!< tx empty trigger level empty */ + UART_TX_EMPTY_TRI_LVL_2CAHR = UART_TX_FIFO_TRIG_2CHAR, /*!< tx empty trigger level 2char */ + UART_TX_EMPTY_TRI_LVL_QUARTER = UART_TX_FIFO_TRIG_QUARTER, /*!< tx empty trigger level quarter */ + UART_TX_EMPTY_TRI_LVL_HALF = UART_TX_FIFO_TRIG_HALF, /*!< tx empty trigger level half */ +} UART_TxEmptyTriLvlETypeDef; + +/** + * @brief UART rx available trigger level type definition + */ +typedef enum { + UART_RX_AVL_TRI_LVL_1CHAR = UART_RX_FIFO_TRIG_1CHAR, /*!< rx available trigger level 1char */ + UART_RX_AVL_TRI_LVL_QUARTER = UART_RX_FIFO_TRIG_QUARTER, /*!< rx available trigger level quarter */ + UART_RX_AVL_TRI_LVL_HALF = UART_RX_FIFO_TRIG_HALF, /*!< rx available trigger level half */ + UART_RX_AVL_TRI_LVL_FULL_LESS_2 = UART_RX_FIFO_TRIG_2LESS_FULL, /*!< rx available trigger level full less 2 */ +} UART_RxAvlTriLvlETypeDef; + +/** + * @brief UART DE polarity type definition + */ +typedef enum { + UART_DE_POL_ACT_LOW, /*!< DE polarity active low */ + UART_DE_POL_ACT_HIGH, /*!< DE polarity active high */ +} UART_DePolETypeDef; + + +/** + * @brief UART Init Structure definition + */ +typedef struct __UART_InitTypeDef { + uint32_t baudrate; /*!< baudrate */ + UART_DatLenETypeDef dat_len; /*!< data length */ + UART_StopLenETypeDef stop_len; /*!< stop length */ + UART_ParityETypeDef parity; /*!< parity */ + UART_TxEmptyTriLvlETypeDef tx_tl; /*!< tx empty trigger level */ + UART_RxAvlTriLvlETypeDef rx_tl; /*!< rx available trigger level */ + bool U9BAddrMatchMode_Enable; /*!< 9_bit addr match enable */ + uint8_t U9BRxAddress; /*!< 9_bit Receive addr */ +} UART_InitTypeDef; + +/** + * @brief UART RS485 Mode Config Structure definition + */ +typedef struct __UART_Rs485CfgTypeDef { + bool de_en; /*!< DE Singal Enable control */ + uint8_t de_assert_time; /*!< Driver enable assertion time */ + uint8_t de_deassert_time; /*!< Driver enable de-assertion time */ + UART_DePolETypeDef de_polarity; /*!< DE Singal Polarity */ +} UART_Rs485CfgTypeDef; + +/** + * @brief UART DMA Status + */ +typedef enum { + UART_DMA_STATE_RESET = 0, /*!< DMA State Reset: not yet initialized or disabled */ + UART_DMA_STATE_READY, /*!< DMA State Ready: initialized and ready for use */ + UART_DMA_STATE_BUSY, /*!< DMA State Busy: process is ongoing */ + UART_DMA_STATE_ERROR, /*!< DMA State Error: process is Error */ + UART_DMA_STATE_FINISH, /*!< DMA State Finish: process has been finished */ +} UART_DMAStatusTypeDef; + +/** + * @brief I2C frame definition + */ +typedef struct __UART_FrameTypeDef { + UART_TypeDef *Instance; /*!< UART Reg base address */ + uint8_t *buf; /*!< buffer pointer */ + uint16_t buf_len; /*!< buffer length */ +#ifdef LL_DMA_MODULE_ENABLED + DMA_ChannelETypeDef dma_tx_ch; /*!< UART Tx DMA Channel */ + DMA_ChannelETypeDef dma_rx_ch; /*!< UART Rx DMA Channel */ +#endif + UART_DMAStatusTypeDef TXdma_status; /*!< UART DMA status */ + UART_DMAStatusTypeDef RXdma_status; /*!< UART DMA status */ +} UART_DMAHandleTypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup UART_LL_Exported_Macros UART LL Exported Macros + * @brief UART LL Exported Macros + * @{ + */ + +/** + * @brief RX buffer 8bits read + * @param __UART__ Specifies UART peripheral + * @return 8bits read value + */ +#define __LL_UART_RxBuf8bits_Read(__UART__) (READ_BIT((__UART__)->RBR, UART_RBR_LSB_8bits_Msk)) + +/** + * @brief RX buffer 9bits read + * @param __UART__ Specifies UART peripheral + * @return 9bits read value + */ +#define __LL_UART_RxBuf9bits_Read(__UART__) (READ_BIT((__UART__)->RBR, UART_RBR_9bits_Msk)) + +/** + * @brief TX buffer 8bits write + * @param __UART__ Specifies UART peripheral + * @param val write value + * @return None + */ +#define __LL_UART_TxBuf8bits_Write(__UART__, val) \ + MODIFY_REG((__UART__)->THR, UART_THR_LSB_8bits_Msk, (((val) & 0xffUL) << UART_THR_LSB_8bits_Pos)) + +/** + * @brief TX buffer 9bits write + * @param __UART__ Specifies UART peripheral + * @param val write value + * @return None + */ +#define __LL_UART_TxBuf9bits_Write(__UART__, val) \ + MODIFY_REG((__UART__)->THR, UART_THR_9bits_Msk, (((val) & 0x1ffUL) << UART_THR_LSB_8bits_Pos)) + +/** + * @brief divisor latch low wirte + * @param __UART__ Specifies UART peripheral + * @param val wirte value + * @return None + */ +#define __LL_UART_DivLatchLow_Write(__UART__, val) WRITE_REG((__UART__)->DLL, (val & UART_DLL_DLL_Msk)) + +/** + * @brief divisor latch high wirte + * @param __UART__ Specifies UART peripheral + * @param val wirte value + * @return None + */ +#define __LL_UART_DivLatchHigh_Write(__UART__, val) WRITE_REG((__UART__)->DLH, (val & UART_DLH_DLH_Msk)) + +/** + * @brief programmable THRE interrupt enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_THRE_INT_En(__UART__) SET_BIT((__UART__)->IER, UART_IER_PTIME_Msk) + +/** + * @brief programmable THRE interrupt disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_THRE_INT_Dis(__UART__) CLEAR_BIT((__UART__)->IER, UART_IER_PTIME_Msk) + +/** + * @brief modem status interrupt enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_ModemSta_INT_En(__UART__) SET_BIT((__UART__)->IER, UART_IER_EDSSI_Msk) + +/** + * @brief modem status interrupt disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_ModemSta_INT_Dis(__UART__) CLEAR_BIT((__UART__)->IER, UART_IER_EDSSI_Msk) + +/** + * @brief RX line status interrupt enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RxLineSta_INT_En(__UART__) SET_BIT((__UART__)->IER, UART_IER_ELSI_Msk) + +/** + * @brief RX line status interrupt disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RxLineSta_INT_Dis(__UART__) CLEAR_BIT((__UART__)->IER, UART_IER_ELSI_Msk) + +/** + * @brief TX holding register empty interrupt enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_TxHoldEmpyt_INT_En(__UART__) SET_BIT((__UART__)->IER, UART_IER_ETBEI_Msk) + +/** + * @brief TX holding register empty interrupt disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_TxHoldEmpyt_INT_Dis(__UART__) CLEAR_BIT((__UART__)->IER, UART_IER_ETBEI_Msk) + +/** + * @brief RX data available interrupt enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RxDatAvl_INT_En(__UART__) SET_BIT((__UART__)->IER, UART_IER_ERBFI_Msk) + +/** + * @brief RX data available interrupt disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RxDatAvl_INT_Dis(__UART__) CLEAR_BIT((__UART__)->IER, UART_IER_ERBFI_Msk) + +/** + * @brief Judge is FIFOs enable or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't FIFOs enable + * @retval 3 is FIFOs enable + */ +#define __LL_UART_IsFIFOsEn(__UART__) (READ_BIT((__UART__)->IIR, UART_IIR_FIFOSE_Msk) >> UART_IIR_FIFOSE_Pos) + +/** + * @brief Interrupt ID get + * @param __UART__ Specifies UART peripheral + * @return Interrupt ID + */ +#define __LL_UART_INT_ID_Get(__UART__) (READ_BIT((__UART__)->IIR, UART_IIR_IID_Msk) >> UART_IIR_IID_Pos) + +/** + * @brief FCR register write + * @param __UART__ Specifies UART peripheral + * @param val write val + * @return None + */ +#define __LL_UART_FCR_Write(__UART__, val) WRITE_REG((__UART__)->FCR, val) + +/** + * @brief Divisor latch access set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DivLatchAccess_Set(__UART__) SET_BIT((__UART__)->LCR, UART_LCR_DLAB_Msk) + +/** + * @brief Divisor latch access clear + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DivLatchAccess_Clr(__UART__) CLEAR_BIT((__UART__)->LCR, UART_LCR_DLAB_Msk) + +/** + * @brief Break control set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_BreakCtrl_Set(__UART__) SET_BIT((__UART__)->LCR, UART_LCR_BC_Msk) + +/** + * @brief Break control clear + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_BreakCtrl_Clr(__UART__) CLEAR_BIT((__UART__)->LCR, UART_LCR_BC_Msk) + +/** + * @brief Stick parity set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_StickParity_Set(__UART__) SET_BIT((__UART__)->LCR, UART_LCR_Stick_Parity_Msk) + +/** + * @brief Stick parity clear + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_StickParity_Clr(__UART__) CLEAR_BIT((__UART__)->LCR, UART_LCR_Stick_Parity_Msk) + +/** + * @brief Even parity set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_EvenParity_Set(__UART__) SET_BIT((__UART__)->LCR, UART_LCR_EPS_Msk) + +/** + * @brief Even parity clear + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_EvenParity_Clr(__UART__) CLEAR_BIT((__UART__)->LCR, UART_LCR_EPS_Msk) + +/** + * @brief Parity enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_Parity_En(__UART__) SET_BIT((__UART__)->LCR, UART_LCR_PEN_Msk) + +/** + * @brief Parity disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_Parity_Dis(__UART__) CLEAR_BIT((__UART__)->LCR, UART_LCR_PEN_Msk) + +/** + * @brief Judge parity is enable or not + * @param __UART__ Specifies UART peripheral + * @retval 0 Parity isn't enable + * @retval 1 Parity is enable + */ +#define __LL_UART_IsParityEn(__UART__) (READ_BIT((__UART__)->LCR, UART_LCR_PEN_Msk) >> UART_LCR_PEN_Pos) + +/** + * @brief Stop 1bit set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_Stop1Bit_Set(__UART__) CLEAR_BIT((__UART__)->LCR, UART_LCR_STOP_Msk) + +/** + * @brief Stop 2bits set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_Stop2bits_Set(__UART__) SET_BIT((__UART__)->LCR, UART_LCR_STOP_Msk) + +/** + * @brief Data length select + * @param __UART__ Specifies UART peripheral + * @param val select value + * @return None + */ +#define __LL_UART_DatLen_Sel(__UART__, val) MODIFY_REG((__UART__)->LCR, UART_LCR_DLS_Msk, ((val & 0x3UL) << UART_LCR_DLS_Pos)) + +/** + * @brief Judge is character address or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't character address + * @retval 1 is character address + */ +#define __LL_UART_IsCharacterAddr(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_ADDR_RCVD_Msk) >> UART_LSR_ADDR_RCVD_Pos) + +/** + * @brief Judge is RX FIFO error or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't RX FIFO error + * @retval 1 is RX FIFO error + */ +#define __LL_UART_IsRxFIFOErr(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_RFE_Msk) >> UART_LSR_RFE_Pos) + +/** + * @brief Judge is TX empty or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't TX empty + * @retval 1 is TX empty + */ +#define __LL_UART_IsTxEmpty(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_TEMT_Msk) >> UART_LSR_TEMT_Pos) + +/** + * @brief Judge is TX hold register empty or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't TX hold register empty + * @retval 1 is TX hold register empty + */ +#define __LL_UART_IsTxHoldRegEmpty(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_THRE_Msk) >> UART_LSR_THRE_Pos) + +/** + * @brief Judge is break interrupt or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't break interrupt + * @retval 1 is break interrupt + */ +#define __LL_UART_IsBreakInt(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_BI_Msk) >> UART_LSR_BI_Pos) + +/** + * @brief Judge is frame error or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't frame error + * @retval 1 is frame error + */ +#define __LL_UART_IsFrameErr(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_FE_Msk) >> UART_LSR_FE_Pos) + +/** + * @brief Judge is parity error or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't parity error + * @retval 1 is parity error + */ +#define __LL_UART_IsParityErr(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_PE_Msk) >> UART_LSR_PE_Pos) + +/** + * @brief Judge is overrun error or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't overrun error + * @retval 1 is overrun error + */ +#define __LL_UART_IsOverrunErr(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_OE_Msk) >> UART_LSR_OE_Pos) + +/** + * @brief Judge is data ready or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't data ready + * @retval 1 is data ready + */ +#define __LL_UART_IsDatReady(__UART__) (READ_BIT((__UART__)->LSR, UART_LSR_DR_Msk) >> UART_LSR_DR_Pos) + +/** + * @brief Line status get + * @param __UART__ Specifies UART peripheral + * @return Line status + */ +#define __LL_UART_LineSta_Get(__UART__) READ_BIT((__UART__)->LSR, UART_LSR_ALL_BIT_Msk) + +/** + * @brief Judge is RXFIFO full or not + * @param __UART__ Specifies UART peripheral + * @retval 0 isn't RXFIFO full + * @retval 1 is RXFIFO full + */ +#define __LL_UART_IsRxFIFOFull(__UART__) (READ_BIT((__UART__)->USR, UART_USR_RFF_Msk) >> UART_USR_RFF_Pos) + +/** + * @brief Judge is RXFIFO not empty or not + * @param __UART__ Specifies UART peripheral + * @retval 0 RXFIFO is empty + * @retval 1 RXFIFO is not empty + */ +#define __LL_UART_IsRxFIFONotEmpty(__UART__) (READ_BIT((__UART__)->USR, UART_USR_RFNE_Msk) >> UART_USR_RFNE_Pos) + +/** + * @brief Judge is TXFIFO empty or not + * @param __UART__ Specifies UART peripheral + * @retval 0 TXFIFO is not empty + * @retval 1 TXFIFO is empty + */ +#define __LL_UART_IsTxFIFOEmpty(__UART__) (READ_BIT((__UART__)->USR, UART_USR_TFE_Msk) >> UART_USR_TFE_Pos) + +/** + * @brief Judge is TXFIFO not full or not + * @param __UART__ Specifies UART peripheral + * @retval 0 TXFIFO is full + * @retval 1 TXFIFO is not full + */ +#define __LL_UART_IsTxFIFONotFull(__UART__) (READ_BIT((__UART__)->USR, UART_USR_TFNF_Msk) >> UART_USR_TFNF_Pos) + +/** + * @brief TXFIFO level get + * @param __UART__ Specifies UART peripheral + * @return TXFIFO level + */ +#define __LL_UART_TxFIFOLevel_Get(__UART__) (READ_BIT((__UART__)->TFL, UART_TFL_TFL_Msk) >> UART_TFL_TFL_Pos) + +/** + * @brief RXFIFO level get + * @param __UART__ Specifies UART peripheral + * @return RXFIFO level + */ +#define __LL_UART_RxFIFOLevel_Get(__UART__) (READ_BIT((__UART__)->RFL, UART_RFL_RFL_Msk) >> UART_RFL_RFL_Pos) + +/** + * @brief TX halt enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_TxHalt_En(__UART__) SET_BIT((__UART__)->HTX, UART_HTX_HTX_Msk) + +/** + * @brief TX halt disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_TxHalt_Dis(__UART__) CLEAR_BIT((__UART__)->HTX, UART_HTX_HTX_Msk) + +/** + * @brief TX mode set + * @param __UART__ Specifies UART peripheral + * @param mode tx mode + * @return None + */ +#define __LL_UART_TxMode_Set(__UART__, mode) MODIFY_REG((__UART__)->TCR, UART_TCR_XFER_MODE_Msk, mode) + +/** + * @brief DE signal active high set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DE_ActHigh_Set(__UART__) SET_BIT((__UART__)->TCR, UART_TCR_DE_POL_Msk) + +/** + * @brief DE signal active low set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DE_ActLow_Set(__UART__) CLEAR_BIT((__UART__)->TCR, UART_TCR_DE_POL_Msk) + +/** + * @brief RE signal active high set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RE_ActHigh_Set(__UART__) SET_BIT((__UART__)->TCR, UART_TCR_RE_POL_Msk) + +/** + * @brief RE signal active low set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RE_ActLow_Set(__UART__) CLEAR_BIT((__UART__)->TCR, UART_TCR_RE_POL_Msk) + +/** + * @brief RS485 mode enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RS485Mode_En(__UART__) SET_BIT((__UART__)->TCR, UART_TCR_RS485_EN_Msk) + +/** + * @brief RS485 mode disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RS485Mode_Dis(__UART__) CLEAR_BIT((__UART__)->TCR, UART_TCR_RS485_EN_Msk) + +/** + * @brief DE enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DE_En(__UART__) SET_BIT((__UART__)->DE_EN, UART_DE_EN_DE_EN_Msk) + +/** + * @brief DE disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DE_Dis(__UART__) CLEAR_BIT((__UART__)->DE_EN, UART_DE_EN_DE_EN_Msk) + +/** + * @brief RE enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_RE_En(__UART__) SET_BIT((__UART__)->RE_EN, UART_RE_EN_RE_EN_Msk) + +/** + * @brief DE deassertion time set + * @param __UART__ Specifies UART peripheral + * @param val set value + * @return None + */ +#define __LL_UART_DE_DeAssertTime_Set(__UART__, val) \ + MODIFY_REG((__UART__)->DET, UART_DET_DE_DEASSERT_TIME_Msk, ((val & 0xffUL) << UART_DET_DE_DEASSERT_TIME_Pos)) + +/** + * @brief DE assertion time set + * @param __UART__ Specifies UART peripheral + * @param val set value + * @return None + */ +#define __LL_UART_DE_AssertTime_Set(__UART__, val) \ + MODIFY_REG((__UART__)->DET, UART_DET_DE_ASSERT_TIME_Msk, ((val & 0xffUL) << UART_DET_DE_ASSERT_TIME_Pos)) + +/** + * @brief RE to DE turn around time set + * @param __UART__ Specifies UART peripheral + * @param val set value + * @return None + */ +#define __LL_UART_REtoDE_TurnAroundTime_Set(__UART__, val) \ + MODIFY_REG((__UART__)->TAT, UART_TAT_RE_TO_DE_TIME_Msk, ((val & 0xffffUL) << UART_TAT_RE_TO_DE_TIME_Pos)) + +/** + * @brief DE to RE turn around time set + * @param __UART__ Specifies UART peripheral + * @param val set value + * @return None + */ +#define __LL_UART_DEtoRE_TurnAroundTime_Set(__UART__, val) \ + MODIFY_REG((__UART__)->TAT, UART_TAT_DE_TO_RE_TIME_Msk, ((val & 0xffffUL) << UART_TAT_DE_TO_RE_TIME_Pos)) + +/** + * @brief Divisor latch fraction set + * @param __UART__ Specifies UART peripheral + * @param val set value + * @return None + */ +#define __LL_UART_DivLatchFrac_Set(__UART__, val) MODIFY_REG((__UART__)->DLF, UART_DLF_DLF_Msk, ((val & 0xfUL) << UART_DLF_DLF_Pos)) + +/** + * @brief RAR set + * @param __UART__ Specifies UART peripheral + * @param addr set address + * @return None + */ +#define __LL_UART_RAR_Set(__UART__, addr) MODIFY_REG((__UART__)->RAR, UART_RAR_RAR_Msk, ((addr & 0xffUL) << UART_RAR_RAR_Pos)) + +/** + * @brief TAR set + * @param __UART__ Specifies UART peripheral + * @param addr set address + * @return None + */ +#define __LL_UART_TAR_Set(__UART__, addr) MODIFY_REG((__UART__)->TAR, UART_TAR_TAR_Msk, ((addr & 0xffUL) << UART_TAR_TAR_Pos)) + +/** + * @brief TX mode 9bits set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_TxMode9bits_Set(__UART__) SET_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_TRANSMIT_MODE_Msk) + +/** + * @brief TX mode 8bits set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_TxMode8bits_Set(__UART__) CLEAR_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_TRANSMIT_MODE_Msk) + +/** + * @brief TX mode status get + * @param __UART__ Specifies UART peripheral + * @retval 0 TX mode is 8bits + * @retval 1 TX mode is 9bits + */ +#define __LL_UART_TxModeSta_Get(__UART__) \ + (READ_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_TRANSMIT_MODE_Msk) >> UART_LCR_EXT_TRANSMIT_MODE_Pos) + +/** + * @brief Send address set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_SendAddr_Start(__UART__) SET_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_SEND_ADDR_Msk) + +/** + * @brief Send data set + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_SendDat_Start(__UART__) CLEAR_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_SEND_ADDR_Msk) + +/** + * @brief Address match mode enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_AddrMatchMode_En(__UART__) SET_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_ADDR_MATCH_Msk) + +/** + * @brief Address match mode disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_AddrMatchMode_Dis(__UART__) CLEAR_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_ADDR_MATCH_Msk) + +/** + * @brief Data length extension 9bits enable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DatLen9bitsExt_En(__UART__) SET_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_DLS_E_Msk) + +/** + * @brief Data length extension 9bits disable + * @param __UART__ Specifies UART peripheral + * @return None + */ +#define __LL_UART_DatLen9bitsExt_Dis(__UART__) CLEAR_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_DLS_E_Msk) + +/** + * @brief Judge data length extension 9bits is enable or not + * @param __UART__ Specifies UART peripheral + * @retval 0 Data length extension 9bits isn't enable + * @retval 1 Data length extension 9bits is enable + */ +#define __LL_UART_IsDatLen9bitsEn(__UART__) (READ_BIT((__UART__)->LCR_EXT, UART_LCR_EXT_DLS_E_Msk) >> UART_LCR_EXT_DLS_E_Pos) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup UART_LL_Exported_Functions + * @{ + */ + +/** @addtogroup UART_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_UART_Init(UART_TypeDef *Instance, UART_InitTypeDef *Init); +LL_StatusETypeDef LL_UART_DeInit(UART_TypeDef *Instance); +void LL_UART_MspInit(UART_TypeDef *Instance); +void LL_UART_MspDeInit(UART_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup UART_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_UART_Transmit_CPU(UART_TypeDef *Instance, uint8_t *pData, uint16_t Size, uint32_t Timeout); +LL_StatusETypeDef LL_UART_Receive_CPU(UART_TypeDef *Instance, uint8_t *pData, uint16_t Size, uint32_t Timeout); + +LL_StatusETypeDef LL_UART_Transmit_IT(UART_TypeDef *Instance); +LL_StatusETypeDef LL_UART_Receive_IT(UART_TypeDef *Instance); + +#ifdef LL_DMA_MODULE_ENABLED +LL_StatusETypeDef LL_UART_Transmit_DMA(UART_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + UART_DMAHandleTypeDef *huart, uint32_t Timeout); +LL_StatusETypeDef LL_UART_Receive_DMA(UART_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + UART_DMAHandleTypeDef *huart, uint32_t Timeout); +#endif + +/** + * @} + */ + + +/** @addtogroup UART_LL_Exported_Functions_Group3 + * @{ + */ +LL_StatusETypeDef LL_Uart_9bit_SendAddress(UART_TypeDef *Instance, uint8_t TxAddr); +LL_StatusETypeDef LL_UART_RS485Cfg(UART_TypeDef *Instance, UART_Rs485CfgTypeDef *cfg); +uint8_t LL_UART_TxFIFOLVL_GET(UART_TypeDef *Instance); +uint8_t LL_UART_RxFIFOLVL_GET(UART_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup UART_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_UART_IRQHandler(UART_TypeDef *Instance); + +void LL_UART_ModemStaCallback(UART_TypeDef *Instance); +void LL_UART_TxEmptyCallback(UART_TypeDef *Instance); +void LL_UART_RxAvailableCallback(UART_TypeDef *Instance); +void LL_UART_RxLineStaCallback(UART_TypeDef *Instance); +void LL_UART_BusyDetCallback(UART_TypeDef *Instance); +void LL_UART_CharTimeOutCallback(UART_TypeDef *Instance); + +void LL_UART_BreakErrCallback(UART_TypeDef *Instance); +void LL_UART_FrameErrCallback(UART_TypeDef *Instance); +void LL_UART_ParityErrCallback(UART_TypeDef *Instance); +void LL_UART_RxOverrunErrCallback(UART_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_UART_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_usb.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_usb.h new file mode 100644 index 0000000000..aebd0eacfd --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_usb.h @@ -0,0 +1,1234 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_usb.h + * @author MCD Application Team + * @brief Header file of USB LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_USB_H_ +#define _TAE32F53XX_LL_USB_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup USB_LL + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup USB_LL_Exported_Macros USB LL Exported Macros + * @brief USB LL Exported Macros + * @{ + */ + +/** + * @brief Set Function Address + * @param __USB__ Specifies USB peripheral + * @param func_addr Function Address + * @return None + */ +#define __LL_USB_FuncAddr_Set(__USB__, func_addr) \ + MODIFY_REG((__USB__)->FADDR, USB_FUNC_ADDR_Msk, ((func_addr & 0x7FUL) << USB_FUNC_ADDR_Pos)) + + +/** + * @brief Enable the SUSPENDM output + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_SuspendDMOut_En(__USB__) SET_BIT((__USB__)->POWER, USB_SUSPEND_DM_EN_Msk) + +/** + * @brief Disable the SUSPENDM output + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_SuspendDMOut_Dis(__USB__) CLEAR_BIT((__USB__)->POWER, USB_SUSPEND_DM_EN_Msk) + +/** + * @brief Enable HighSpeed + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_HighSpeed_En(__USB__) SET_BIT((__USB__)->POWER, USB_HS_EN_Msk) + +/** + * @brief Disable HighSpeed + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_HighSpeed_Dis(__USB__) CLEAR_BIT((__USB__)->POWER, USB_HS_EN_Msk) + +/** + * @brief Enable Soft Connect + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_SoftConn_En(__USB__) SET_BIT((__USB__)->POWER, USB_SOFT_CONN_EN_Msk) + +/** + * @brief Disable Soft Connect + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_SoftConn_Dis(__USB__) CLEAR_BIT((__USB__)->POWER, USB_SOFT_CONN_EN_Msk) + + +/** + * @brief Get Endpoint 0 and TX Endpoint Interrupt Status + * @param __USB__ Specifies USB peripheral + * @return Endpoint 0 and TX Endpoint Interrupt Status + */ +#define __LL_USB_EP0AndEPxTX_IntSta_Get(__USB__) ((__USB__)->INTRTX) + + +/** + * @brief Get RX Endpoint Interrupt Status + * @param __USB__ Specifies USB peripheral + * @return RX Interrupt Status + */ +#define __LL_USB_EPx_RXIntSta_Get(__USB__) ((__USB__)->INTRRX) + + +/** + * @brief Enable Endpoint 0 and TX Endpoint Interrupt + * @param __USB__ Specifies USB peripheral + * @param ep_num USB_EpNumETypeDef Type Endpoint Number + * @return None + */ +#define __LL_USB_EP0AndEPxTX_Int_EN(__USB__, ep_num) \ + do { \ + if(ep_num >= EP_NUMS){ \ + break; \ + } \ + uint16_t ep0_and_epxtx_int_en_bitmask[] = {USB_EP0_INT_EN_Msk, USB_TX_EP1_INT_EN_Msk, USB_TX_EP2_INT_EN_Msk}; \ + SET_BIT((__USB__)->INTRTXE, ep0_and_epxtx_int_en_bitmask[ep_num]); \ + } while(0) + +/** + * @brief Disable Endpoint 0 and TX Endpoint Interrupt + * @param __USB__ Specifies USB peripheral + * @param ep_num USB_EpNumETypeDef Type Endpoint Number + * @return None + */ +#define __LL_USB_EP0AndEPxTX_Int_Dis(__USB__, ep_num) \ + do { \ + if(ep_num >= EP_NUMS){ \ + break; \ + } \ + uint16_t ep0_and_epxtx_int_en_bitmask[] = {USB_EP0_INT_EN_Msk, USB_TX_EP1_INT_EN_Msk, USB_TX_EP2_INT_EN_Msk}; \ + CLEAR_BIT((__USB__)->INTRTXE, ep0_and_epxtx_int_en_bitmask[ep_num]); \ + } while(0) + + +/** + * @brief Enable RX Endpoint Interrupt + * @param __USB__ Specifies USB peripheral + * @param ep_num USB_EpNumETypeDef Type Endpoint Number + * @return None + */ +#define __LL_USB_EPx_RXInt_En(__USB__, ep_num) \ + do { \ + if(ep_num >= EP_NUMS){ \ + break; \ + } \ + uint16_t epxrx_int_en_bitmask[] = {0, USB_RX_EP1_INT_EN_Msk, USB_RX_EP2_INT_EN_Msk}; \ + SET_BIT((__USB__)->INTRRXE, epxrx_int_en_bitmask[ep_num]); \ + } while(0) + +/** + * @brief Disable RX Endpoint Interrupt + * @param __USB__ Specifies USB peripheral + * @param ep_num USB_EpNumETypeDef Type Endpoint Number + * @return None + */ +#define __LL_USB_EPx_RXInt_Dis(__USB__, ep_num) \ + do { \ + if(ep_num >= EP_NUMS){ \ + break; \ + } \ + uint16_t epxrx_int_en_bitmask[] = {0, USB_RX_EP1_INT_EN_Msk, USB_RX_EP2_INT_EN_Msk}; \ + CLEAR_BIT((__USB__)->INTRRXE, epxrx_int_en_bitmask[ep_num]); \ + } while(0) + + +/** + * @brief Get USB Controler Interrupt Status + * @param __USB__ Specifies USB peripheral + * @return USB Controler Interrupt Status + */ +#define __LL_USB_IntSta_Get(__USB__) (READ_BIT((__USB__)->INTRUSB, USB_CTRL_INT_ALL_Msk) >> USB_SUSPEND_INT_STA_Pos) + + +/** + * @brief Enable USB Controler Interrupt + * @param __USB__ Specifies USB peripheral + * @param int_bit_mask Interrupt BitMask to Be Enable + * @return None + */ +#define __LL_USB_Int_EN(__USB__, int_bit_mask) SET_BIT((__USB__)->INTRUSBE, int_bit_mask) + +/** + * @brief Disable USB Controler Interrupt + * @param __USB__ Specifies USB peripheral + * @param int_bit_mask Interrupt BitMask to be Disable + * @return None + */ +#define __LL_USB_Int_Dis(__USB__, int_bit_mask) CLEAR_BIT((__USB__)->INTRUSBE, int_bit_mask) + + +/** + * @brief Get Frame Number + * @param __USB__ Specifies USB peripheral + * @return Frame Number + */ +#define __LL_USB_FrameNum_Get(__USB__) (READ_BIT((__USB__)->FRAME, USB_FRAME_NUM_Msk) >> USB_FRAME_NUM_Pos) + + +/** + * @brief Set Endpoint Index + * @param __USB__ Specifies USB peripheral + * @param idx Index to be Set + * @return None + */ +#define __LL_USB_EPIndex_Set(__USB__, idx) \ + MODIFY_REG((__USB__)->INDEX, USB_EP_INDEX_Msk, ((idx & 0xFUL) << USB_EP_INDEX_Pos)) + + +/** + * @brief Set TX Max Payload + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @param max_payload Max Payload to be Set + * @return None + */ +#define __LL_USB_EPx_TXMaxPayload_Set(__USB__, max_payload) \ + MODIFY_REG((__USB__)->TXMAXP, USB_EPX_TX_MAX_PAYLD_Msk, ((max_payload & 0xFFFFUL) << USB_EPX_TX_MAX_PAYLD_Pos)) + +/** + * @brief Get TX Max Payload + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return TX Max Payload + */ +#define __LL_USB_EPx_TXMaxPayload_Get(__USB__) \ + (READ_BIT((__USB__)->TXMAXP, USB_EPX_TX_MAX_PAYLD_Msk) >> USB_EPX_TX_MAX_PAYLD_Pos) + + +/** + * @brief Judge Endpoint 0 RX Packet Ready or not + * @param __USB__ Specifies USB peripheral + * @retval 0 RX Packet Not Ready + * @retval 1 RX Packet Ready + */ +#define __LL_USB_EP0_IsRXPktRdy(__USB__) (READ_BIT((__USB__)->TX_CSR0, USB_EP0_RX_PKT_RDY_Msk) >> USB_EP0_RX_PKT_RDY_Pos) + +/** + * @brief Clear Endpoint 0 RX Packet Ready + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EP0_RXPktRdy_Clr(__USB__) SET_BIT((__USB__)->TX_CSR0, USB_EP0_CLR_RX_PKT_RDY_Msk) + +/** + * @brief Set Endpoint 0 TX Packet Ready + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EP0_TXPktRdy_Set(__USB__) SET_BIT((__USB__)->TX_CSR0, USB_EP0_TX_PKT_RDY_Msk) + +/** + * @brief Judge Endpoint 0 TX Packet Ready or not + * @param __USB__ Specifies USB peripheral + * @retval 0 TX Packet Not Ready + * @retval 1 TX Packet Ready + */ +#define __LL_USB_EP0_IsTXPktRdy(__USB__) (READ_BIT((__USB__)->TX_CSR0, USB_EP0_TX_PKT_RDY_Msk) >> USB_EP0_TX_PKT_RDY_Pos) + +/** + * @brief Set Endpoint 0 to Send Stall + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EP0_SendStall_Set(__USB__) SET_BIT((__USB__)->TX_CSR0, USB_EP0_SEND_STALL_Msk) + +/** + * @brief Judge Endpoint 0 has Sent Stall or not + * @param __USB__ Specifies USB peripheral + * @retval 0 Hasn't Sent Stall + * @retval 1 Has Sent Stall + */ +#define __LL_USB_EP0_IsSentStall(__USB__) (READ_BIT((__USB__)->TX_CSR0, USB_EP0_SENT_STALL_Msk) >> USB_EP0_SENT_STALL_Pos) + +/** + * @brief Clear Endpoint 0 Sent Stall Status + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EP0_SentStall_Clr(__USB__) CLEAR_BIT((__USB__)->TX_CSR0, USB_EP0_SENT_STALL_Msk) + +/** + * @brief Set Endpoint 0 Data End + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EP0_DataEnd_Set(__USB__) SET_BIT((__USB__)->TX_CSR0, USB_EP0_DATA_END_Msk) + +/** + * @brief Judge Endpoint 0 has SetupEnd or not + * @param __USB__ Specifies USB peripheral + * @retval 0 Hasn't Setup End + * @retval 1 Has Setup End + */ +#define __LL_USB_EP0_IsSetupEnd(__USB__) (READ_BIT((__USB__)->TX_CSR0, USB_EP0_SETUP_END_Msk) >> USB_EP0_SETUP_END_Pos) + +/** + * @brief Clear Endpoint 0 SetupEnd Status + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EP0_SetupEnd_Clr(__USB__) SET_BIT((__USB__)->TX_CSR0, USB_EP0_CLR_SETUP_END_Msk) + +/** + * @brief Flush Endpoint 0 FIFO + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EP0_FlushFIFO(__USB__) SET_BIT((__USB__)->TX_CSR0, USB_EP0_FLUSH_FIFO_Msk) + + +/** + * @brief Enable TX Packet Ready Auto Set Function + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXPktRdyAutoSet_En(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_AUTO_SET_Msk) + +/** + * @brief Disable TX Packet Ready Auto Set Function + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXPktRdyAutoSet_Dis(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_AUTO_SET_Msk) + +/** + * @brief Enable Endpoint TX ISO + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXISO_En(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_ISO_EN_Msk) + +/** + * @brief Disable Endpoint TX ISO + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXISO_Dis(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_ISO_EN_Msk) + +/** + * @brief Enable Endpoint TX + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TX_En(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_DIR_MODE_Msk) + +/** + * @brief Enable Endpoint RX + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RX_En(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_DIR_MODE_Msk) + +/** + * @brief Enable Endpoint TX DMA Request + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXDMAReq_En(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_DMA_REQ_EN_Msk) + +/** + * @brief Disable Endpoint TX DMA Request + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXDMAReq_Dis(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_DMA_REQ_EN_Msk) + +/** + * @brief Set Endpoint TX to Force Data Toggle + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXForceDataTog_Set(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_FRC_DATA_TOG_Msk) + +/** + * @brief Clear Endpoint TX to Force Data Toggle + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXForceDataTog_Clr(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_FRC_DATA_TOG_Msk) + +/** + * @brief Set Endpoint TX DMA Request Mode to 0 + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXDMAReqMode0_Set(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_DMA_REQ_MODE_Msk) + +/** + * @brief Set Endpoint TX DMA Request Mode to 1 + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXDMAReqMode1_Set(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_DMA_REQ_MODE_Msk) + +/** + * @brief Judge TX ISO Endpoint Is Incomplete or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Complete + * @retval 1 Incomplete + */ +#define __LL_USB_EPx_IsTXISOInComp(__USB__) \ + (READ_BIT((__USB__)->TX_CSRX, USB_EPX_TX_ISO_INCOMP_Msk) >> USB_EPX_TX_ISO_INCOMP_Pos) + +/** + * @brief Clear TX Endpoint Data Toggle + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXDataTog_Clr(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_CLR_DATA_TOG_Msk) + +/** + * @brief Judge TX Endpoint has Sent Stall or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Hasn't Sent Stall + * @retval 1 Has Sent Stall + */ +#define __LL_USB_EPx_IsTXSentStall(__USB__) \ + (READ_BIT((__USB__)->TX_CSRX, USB_EPX_TX_SENT_STALL_Msk) >> USB_EPX_TX_SENT_STALL_Pos) + +/** + * @brief Clear TX Endpoint Sent Stall Status + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXSentStall_Clr(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_SENT_STALL_Msk) + +/** + * @brief Enable TX Endpoint to Send Stall + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXSendStall_En(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_SEND_STALL_Msk) + +/** + * @brief Disable TX Endpoint to Send Stall + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXSendStall_Dis(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_SEND_STALL_Msk) + +/** + * @brief Flush TX Endpoint FIFO + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXFlushFIFO(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_FLUSH_FIFO_Msk) + +/** + * @brief Judge TX Endpoint FIFO Is UnderRun or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't UnderRun + * @retval 1 Is UnderRun + */ +#define __LL_USB_EPx_IsTXFIFOUnderRun(__USB__) \ + (READ_BIT((__USB__)->TX_CSRX, USB_EPX_TX_UNDER_RUN_Msk) >> USB_EPX_TX_UNDER_RUN_Pos) + +/** + * @brief Clear TX Endpoint UnderRun Status + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXFIFOUnderRun_Clr(__USB__) CLEAR_BIT((__USB__)->TX_CSRX, USB_EPX_TX_UNDER_RUN_Msk) + +/** + * @brief Judge TX Endpoint FIFO Is NoEmpty or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't NoEmpty + * @retval 1 Is NoEmpty + */ +#define __LL_USB_EPx_IsTXFIFONoEmpty(__USB__) \ + (READ_BIT((__USB__)->TX_CSRX, USB_EPX_TX_FIFO_NOT_EPY_Msk) >> USB_EPX_TX_FIFO_NOT_EPY_Pos) + +/** + * @brief Set TX Endpoint Packet Ready + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_TXPktRdy_Set(__USB__) SET_BIT((__USB__)->TX_CSRX, USB_EPX_TX_PKT_RDY_Msk) + +/** + * @brief Judge Endpoint TX Packet Ready or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't Packet Ready + * @retval 1 Is Packet Ready + */ +#define __LL_USB_EPx_IsTXPktRdy(__USB__) \ + (READ_BIT((__USB__)->TX_CSRX, USB_EPX_TX_PKT_RDY_Msk) >> USB_EPX_TX_PKT_RDY_Pos) + + +/** + * @brief Set RX Max Payload + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @param max_payload Max Payload to be Set + * @return None + */ +#define __LL_USB_EPx_RXMaxPayload_Set(__USB__, max_payload) \ + MODIFY_REG((__USB__)->RXMAXP, USB_EPX_RX_MAX_PAYLD_Msk, ((max_payload & 0xFFFFUL) << USB_EPX_RX_MAX_PAYLD_Pos)) + +/** + * @brief Get RX Max Payload + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return RX Max Payload + */ +#define __LL_USB_EPx_RXMaxPayload_Get(__USB__) \ + (READ_BIT((__USB__)->RXMAXP, USB_EPX_RX_MAX_PAYLD_Msk) >> USB_EPX_RX_MAX_PAYLD_Pos) + + +/** + * @brief Enable RX Packet Ready Auto Clear Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXPktRdyAutoClr_En(__USB__) SET_BIT((__USB__)->RXCSRN, USB_EPX_RX_AUTO_CLR_Msk) + +/** + * @brief Disable RX Packet Ready Auto Clear Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXPktRdyAutoClr_Dis(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_AUTO_CLR_Msk) + +/** + * @brief Enable Endpoint RX ISO + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXISO_En(__USB__) SET_BIT((__USB__)->RXCSRN, USB_EPX_RX_ISO_EN_Msk) + +/** + * @brief Disable Endpoint RX ISO + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXISO_Dis(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_ISO_EN_Msk) + +/** + * @brief Enable Endpoint RX DMA Request + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXDMAReq_En(__USB__) SET_BIT((__USB__)->RXCSRN, USB_EPX_RX_DMQ_REQ_EN_Msk) + +/** + * @brief Disable Endpoint RX DMA Request + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXDMAReq_Dis(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_DMQ_REQ_EN_Msk) + +/** + * @brief Judge RX ISO Endpoint PID Error or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't PID Error + * @retval 1 Is PID Error + */ +#define __LL_USB_EPx_IsRXISOPIDErr(__USB__) \ + (READ_BIT((__USB__)->RXCSRN, USB_EPX_RX_ISO_PID_ERR_Msk) >> USB_EPX_RX_ISO_PID_ERR_Pos) + +/** + * @brief Set Endpoint RX DMA Request Mode to 0 + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXDMAReqMode0_Set(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_DMA_REQ_MODE_Msk) + +/** + * @brief Set Endpoint RX DMA Request Mode to 1 + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXDMAReqMode1_Set(__USB__) SET_BIT((__USB__)->RXCSRN, USB_EPX_RX_DMA_REQ_MODE_Msk) + +/** + * @brief Judge RX ISO Endpoint Is Incomplete or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Complete + * @retval 1 Incomplete + */ +#define __LL_USB_EPx_IsRXISOInComp(__USB__) \ + (READ_BIT((__USB__)->RXCSRN, USB_EPX_RX_ISO_INCOMP_Msk) >> USB_EPX_RX_ISO_INCOMP_Pos) + +/** + * @brief Clear RX Endpoint Data Toggle + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXDataTog_Clr(__USB__) SET_BIT((__USB__)->RXCSRN, USB_EPX_RX_CLR_DATA_TOG_Msk) + +/** + * @brief Judge RX Endpoint has Sent Stall or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Hasn't Sent Stall + * @retval 1 Has Sent Stall + */ +#define __LL_USB_EPx_IsRXSentStall(__USB__) \ + (READ_BIT((__USB__)->RXCSRN, USB_EPX_RX_SENT_STALL_Msk) >> USB_EPX_RX_SENT_STALL_Pos) + +/** + * @brief Clear RX Endpoint Sent Stall Status + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXSentStall_Clr(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_SENT_STALL_Msk) + +/** + * @brief Enable RX Endpoint to Send Stall + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXSendStall_En(__USB__) SET_BIT((__USB__)->RXCSRN, USB_EPX_RX_SEND_STALL_Msk) + +/** + * @brief Disable RX Endpoint to Send Stall + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXSendStall_Dis(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_SEND_STALL_Msk) + +/** + * @brief Flush RX Endpoint FIFO + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXFlushFIFO(__USB__) SET_BIT((__USB__)->RXCSRN, USB_EPX_RX_FLUSH_FIFO_Msk) + +/** + * @brief Judge RX ISO Endpoint Data Error or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't Data Error + * @retval 1 Is Data Error + */ +#define __LL_USB_EPx_IsISORXDataErr(__USB__) \ + (READ_BIT((__USB__)->RXCSRN, USB_EPX_RX_ISO_DATA_ERR_Msk) >> USB_EPX_RX_ISO_DATA_ERR_Pos) + +/** + * @brief Judge RX ISO Endpoint FIFO Is OverRun or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't OverRun + * @retval 1 Is OverRun + */ +#define __LL_USB_EPx_IsISORXFIFOOverRun(__USB__) \ + (READ_BIT((__USB__)->RXCSRN, USB_EPX_RX_OVER_RUN_Msk) >> USB_EPX_RX_OVER_RUN_Pos) + +/** + * @brief Clear RX ISO Endpoint OverrRun Status + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_ISORXFIFOOverRun_Clr(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_OVER_RUN_Msk) + +/** + * @brief Judge RX FIFO Full or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't Full + * @retval 1 Is Full + */ +#define __LL_USB_EPx_IsRXFIFOFull(__USB__) \ + (READ_BIT((__USB__)->RXCSRN, USB_EPX_RX_FIFO_FULL_Msk) >> USB_EPX_RX_FIFO_FULL_Pos) + +/** + * @brief Judge Endpoint RX Packet Ready or not + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't Packet Ready + * @retval 1 Is Packet Ready + */ +#define __LL_USB_EPx_IsRXPktRdy(__USB__) \ + (READ_BIT((__USB__)->RXCSRN, USB_EPX_RX_PKT_RDY_Msk) >> USB_EPX_RX_PKT_RDY_Pos) + +/** + * @brief Clear RX Endpoint Packet Ready Status + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_EPx_RXPktRdy_Clr(__USB__) CLEAR_BIT((__USB__)->RXCSRN, USB_EPX_RX_PKT_RDY_Msk) + + +/** + * @brief Get Endpoint RX Counter + * @note Must Set Endpoint Index first Before Call This Macro Function + * @param __USB__ Specifies USB peripheral + * @return RX Counter + */ +#define __LL_USB_RXCount_Get(__USB__) (READ_BIT((__USB__)->RXCOUNT, USB_RX_CNT_Msk) >> USB_RX_CNT_Pos) + + +/** + * @brief Write Single Byte to Endpoint TX FIFO + * @param __USB__ Specifies USB peripheral + * @param ep_num USB_EpNumETypeDef Type Endpoint Number + * @param dat Data to be Written + * @return None + */ +#define __LL_USB_EPFIFOWriteByte(__USB__, ep_num, dat) do{ (__USB__)->EP_FIFO[ep_num][0] = dat; }while(0) + +/** + * @brief Read Single Byte form Endpoint RX FIFO + * @param __USB__ Specifies USB peripheral + * @param ep_num USB_EpNumETypeDef Type Endpoint Number + * @return Read Byte Data + */ +#define __LL_USB_EPFIFOReadByte(__USB__, ep_num) ((__USB__)->EP_FIFO[ep_num][0]) + + +/** + * @brief Config DM Output Hardware + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMOutputHardware(__USB__) CLEAR_BIT((__USB__)->UCFG0, USB_DM_OE_EN_Msk) + +/** + * @brief Config DM Output Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMOutputNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DM_OE_EN_Msk | USB_DM_OE_Msk) + +/** + * @brief Disable DM Output + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMOutputDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_DP_OE_EN_Msk) + +/** + * @brief Config DP Output Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPOutputNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DP_OE_EN_Msk | USB_DP_OE_Msk) + +/** + * @brief Disable DP Output + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPOutputDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_DM_IE_EN_Msk) + +/** + * @brief Config DM Input Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMInputNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DM_IE_EN_Msk | USB_DM_IE_Msk) + +/** + * @brief Disable DM Input + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMInputDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_DP_IE_EN_Msk) + +/** + * @brief Config DP Input Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPInputNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DP_IE_EN_Msk | USB_DP_IE_Msk) + +/** + * @brief Disable DP Input + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPInputDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_DM_PD_EN_Msk) + +/** + * @brief Config DM PullDown Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMPullDownNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DM_PD_EN_Msk | USB_DM_PD_Msk) + +/** + * @brief Disable DM PullDown + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMPullDownDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_DM_PU_EN_Msk) + +/** + * @brief Config DM PullUp Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMPullUpNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DM_PU_EN_Msk | USB_DM_PU_Msk) + +/** + * @brief Disable DM PullUp + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DMPullUpDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_DP_PD_EN_Msk) + +/** + * @brief Config DP PullDown Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPPullDownNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DP_PD_EN_Msk | USB_DP_PD_Msk) + +/** + * @brief Disable DP PullDown + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPPullDownDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_DP_PU_EN_Msk) + +/** + * @brief Config DP PullUp Normal + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPPullUpNormal(__USB__) SET_BIT((__USB__)->UCFG0, USB_DP_PU_EN_Msk | USB_DP_PU_Msk) + +/** + * @brief Disable DP PullUp + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_DPPullUpDisable(__USB__) MODIFY_REG((__USB__)->UCFG0, 0x3UL<UCFG0, USB_VBUS_VALID_THRES_Msk) + +/** + * @brief Clear Vbus Above VBusValid Threshold + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_VbusValidThreshold_Clr(__USB__) CLEAR_BIT((__USB__)->UCFG0, USB_VBUS_VALID_THRES_Msk) + +/** + * @brief Set Vbus Above Vbus A-device Session Threshold + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_VbusAboveAdevSessThres_Set(__USB__) SET_BIT((__USB__)->UCFG0, USB_VBUS_A_SESS_THRES_Msk) + +/** + * @brief Clear Vbus Above Vbus A-device Session Threshold + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_VbusAboveAdevSessThres_Clr(__USB__) CLEAR_BIT((__USB__)->UCFG0, USB_VBUS_A_SESS_THRES_Msk) + +/** + * @brief Set Vbus Above Session End Threshold + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_VbusAboveSessEndThres_Set(__USB__) SET_BIT((__USB__)->UCFG0, USB_VBUS_SESS_END_THRES_Msk) + +/** + * @brief Clear Vbus Above Session End Threshold + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_VbusAboveSessEndThres_Clr(__USB__) CLEAR_BIT((__USB__)->UCFG0, USB_VBUS_SESS_END_THRES_Msk) + +/** + * @brief Set Mini-AB Connector ID Pin + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_MiniABConnectorID_Set(__USB__) SET_BIT((__USB__)->UCFG0, USB_MINI_AB_CONN_ID_Msk) + +/** + * @brief Clear Mini-AB Connector ID Pin + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_MiniABConnectorID_Clr(__USB__) CLEAR_BIT((__USB__)->UCFG0, USB_MINI_AB_CONN_ID_Msk) + +/** + * @brief Enable USB PHY + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_PHY_En(__USB__) SET_BIT((__USB__)->UCFG0, USB_PHY_EN_Msk) + +/** + * @brief Disable USB PHY + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_PHY_Dis(__USB__) CLEAR_BIT((__USB__)->UCFG0, USB_PHY_EN_Msk) + + +/** + * @brief Enable Interrupt Send to CPU + * @param __USB__ Specifies USB peripheral + * @param int_bit_mask Interrupt BitMask to be Enable + * @return None + */ +#define __LL_USB_INTSendToCPU_En(__USB__, int_bit_mask) SET_BIT((__USB__)->UCFG1, int_bit_mask) + +/** + * @brief Disable Interrupt Send to CPU + * @param __USB__ Specifies USB peripheral + * @param int_bit_mask Interrupt BitMask to be Disable + * @return None + */ +#define __LL_USB_INTSendToCPU_Dis(__USB__, int_bit_mask) CLEAR_BIT((__USB__)->UCFG1, int_bit_mask) + + +/** + * @brief Get SendState + * @param __USB__ Specifies USB peripheral + * @retval 0 Reserved + * @retval 1 Setup + * @retval 2 Out + * @retval 3 IN + */ +#define __LL_USB_SendState_Get(__USB__) (READ_BIT((__USB__)->UCFG2, USB_SEND_STATE_Msk) >> USB_SEND_STATE_Pos) + +/** + * @brief Judge Is IN Packet or not + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't IN Packet + * @retval 1 Is IN Packet + */ +#define __LL_USB_IsInPacket(__USB__) (READ_BIT((__USB__)->UCFG2, USB_IN_STATE_Msk) >> USB_IN_STATE_Pos) + +/** + * @brief Judge Is OUT Packet or not + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't OUT Packet + * @retval 1 Is OUT Packet + */ +#define __LL_USB_IsOutPacket(__USB__) (READ_BIT((__USB__)->UCFG2, USB_OUT_STATE_Msk) >> USB_OUT_STATE_Pos) + +/** + * @brief Judge Is Setup Packet or not + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't Setup Packet + * @retval 1 Is Setup Packet + */ +#define __LL_USB_IsSetupPacket(__USB__) (READ_BIT((__USB__)->UCFG2, USB_SETUP_STATE_Msk) >> USB_SETUP_STATE_Pos) + +/** + * @brief Set Debounce Max + * @param __USB__ Specifies USB peripheral + * @param debouce debouce to be set + * @return None + */ +#define __LL_USB_DebouceMax_Set(__USB__, debouce) \ + MODIFY_REG((__USB__)->UCFG2, USB_DEBOUCE_MAX_Msk, ((debouce & 0x3FFFUL) << USB_DEBOUCE_MAX_Pos)) + +/** + * @brief Enable Disconnect Interrupt + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_Disconn_Int_En(__USB__) SET_BIT((__USB__)->UCFG2, USB_DISCONN_INT_EN_Msk) + +/** + * @brief Disable Disconnect Interrupt + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_Disconn_Int_Dis(__USB__) CLEAR_BIT((__USB__)->UCFG2, USB_DISCONN_INT_EN_Msk) + +/** + * @brief Judge Is Disconnect Interrupt or not + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't Disconnect Interrupt + * @retval 1 Is Disconnect Interrupt + */ +#define __LL_USB_IsDisconn(__USB__) (READ_BIT((__USB__)->UCFG2, USB_DISCONN_INT_STA_Msk) >> USB_DISCONN_INT_STA_Pos) + +/** + * @brief Clear Disconnect Interrupt Pending + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_Disconn_Clr(__USB__) SET_BIT((__USB__)->UCFG2, USB_DISCONN_INT_STA_Msk) + +/** + * @brief Enable Connect Interrupt + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_Conn_Int_En(__USB__) SET_BIT((__USB__)->UCFG2, USB_CONN_INT_EN_Msk) + +/** + * @brief Disable Connect Interrupt + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_Conn_Int_Dis(__USB__) CLEAR_BIT((__USB__)->UCFG2, USB_CONN_INT_EN_Msk) + +/** + * @brief Judge Is Connect Interrupt or not + * @param __USB__ Specifies USB peripheral + * @retval 0 Isn't Connect Interrupt + * @retval 1 Is Connect Interrupt + */ +#define __LL_USB_IsConn(__USB__) (READ_BIT((__USB__)->UCFG2, USB_CONN_INT_STA_Msk) >> USB_CONN_INT_STA_Pos) + +/** + * @brief Clear Connect Interrupt Pending + * @param __USB__ Specifies USB peripheral + * @return None + */ +#define __LL_USB_Conn_Clr(__USB__) SET_BIT((__USB__)->UCFG2, USB_CONN_INT_STA_Msk) + +/** + * @} + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup USB_LL_Exported_Types USB LL Exported Types + * @brief USB LL Exported Types + * @{ + */ + +/** + * @brief USB Endpoint Number + */ +typedef enum { + EP_NUM_0 = 0, /*!< Endpoint Number 0 */ + EP_NUM_1 = 1, /*!< Endpoint Number 1 */ + EP_NUM_2 = 2, /*!< Endpoint Number 2 */ + EP_NUMS = 3, /*!< Endpoint Numbers */ +} USB_EpNumETypeDef; + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup USB_LL_Exported_Functions + * @{ + */ + +/** @addtogroup USB_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_USB_Init(USB_TypeDef *Instance); +LL_StatusETypeDef LL_USB_DeInit(USB_TypeDef *Instance); +void LL_USB_MspInit(USB_TypeDef *Instance); +void LL_USB_MspDeInit(USB_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup USB_LL_Exported_Functions_Group2 + * @{ + */ +void LL_USB_CtrlIRQHandler(USB_TypeDef *Instance); +void LL_USB_CtrlSuspendCallback(USB_TypeDef *Instance); +void LL_USB_CtrlResumeCallback(USB_TypeDef *Instance); +void LL_USB_CtrlResetCallback(USB_TypeDef *Instance); +void LL_USB_CtrlSofCallback(USB_TypeDef *Instance); +void LL_USB_CtrlSessEndCallback(USB_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup USB_LL_Exported_Functions_Group3 + * @{ + */ +void LL_USB_DetIRQHandler(USB_TypeDef *Instance); +void LL_USB_DetConnectCallback(USB_TypeDef *Instance); +void LL_USB_DetDisonnectCallback(USB_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup USB_LL_Exported_Functions_Group4 + * @{ + */ +void LL_USB_EpIRQHandler(USB_TypeDef *Instance); +void LL_USB_Ep0SetupCallback(USB_TypeDef *Instance); +void LL_USB_Ep0InCallback(USB_TypeDef *Instance); +void LL_USB_Ep0OutCallback(USB_TypeDef *Instance); +void LL_USB_Ep1InCallback(USB_TypeDef *Instance); +void LL_USB_Ep1OutCallback(USB_TypeDef *Instance); +void LL_USB_Ep2InCallback(USB_TypeDef *Instance); +void LL_USB_Ep2OutCallback(USB_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_USB_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_wwdg.h b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_wwdg.h new file mode 100644 index 0000000000..b78da632f3 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/inc/tae32f53xx_ll_wwdg.h @@ -0,0 +1,296 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_wwdg.h + * @author MCD Application Team + * @brief Header file of WWDG LL module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_WWDG_H_ +#define _TAE32F53XX_LL_WWDG_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll_def.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup WWDG_LL + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/** @defgroup WWDG_LL_Exported_Types WWDG LL Exported Types + * @brief WWDG LL Exported Types + * @{ + */ + +/** + @brief WWDG Early Wakeup Interrupt Mode + */ +typedef enum { + WWDG_EWI_DISABLE = 0x00000000U, /*!< Rsest */ + WWDG_EWI_ENABLE = WWDG_CR_EWIE, /*!< Early Wakeup Interrupt */ +} WWDG_EWIETypeDef; + +/** + * @brief WWDG Init structure definition + */ +typedef struct __WWDG_InitTypeDef { + uint32_t Prescaler; /*!< Specifies the prescaler value of the WWDG. + This parameter must be a number Min_Data = 0x00 and Max_Data = 0xFFFF */ + + uint32_t Window; /*!< Specifies the WWDG window value to be compared to the downcounter. + This parameter must be a number Min_Data = 0x40 and Max_Data = 0xFFFF */ + + uint32_t Counter; /*!< Specifies the WWDG free-running downcounter value. + This parameter must be a number between Min_Data = 0x40 and Max_Data = 0xFFFF */ + + WWDG_EWIETypeDef EWIMode; /*!< Specifies if WWDG Early Wakeup Interupt is enable or not. */ +} WWDG_InitTypeDef; + +/** + * @} + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup WWDG_LL_Exported_Constants WWDG LL Exported Constants + * @brief WWDG LL Exported Constants + * @{ + */ + +/** @defgroup WWDG_Interrupt_definition WWDG Interrupt definition + * @{ + */ +#define WWDG_IT_EWIE WWDG_CR_EWIE /*!< Early wakeup interrupt */ +/** + * @} + */ + +/** @defgroup WWDG_Flag_definition WWDG Flag definition + * @brief WWDG Flag definition + * @{ + */ +#define WWDG_FLAG_EWIF WWDG_ISR_EWIF /*!< Early wakeup interrupt flag */ +/** + * @} + */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup WWDG_LL_Exported_Macros WWDG LL Exported Macros + * @brief WWDG LL Exported Macros + * @{ + */ + +/** + * @brief Enable the WWDG peripheral. + * @param __INSTANCE__ WWDG peripheral + * @retval None + */ +#define __LL_WWDG_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR, WWDG_CR_WEN) + +/** + * @brief Disable the WWDG peripheral. + * @param __INSTANCE__ WWDG peripheral + * @retval None + */ +#define __LL_WWDG_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR, WWDG_CR_WEN) + +/** + * @brief Enable the specified WWDG interrupt. + * @param __INSTANCE__ WWDG peripheral + * @param __INTERRUPT__ specifies the interrupt to enable. + * This parameter can be one of the following values: + * @arg WWDG_IT_EWIE: Early wakeup interrupt + * @retval None + */ +#define __LL_WWDG_IT_ENABLE(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) + +/** + * @brief Disable the specified WWDG interrupt. + * @param __INSTANCE__ WWDG peripheral + * @param __INTERRUPT__ specifies the interrupt to enable. + * This parameter can be one of the following values: + * @arg WWDG_IT_EWIE: Early wakeup interrupt + * @retval None + */ +#define __LL_WWDG_IT_DISABLE(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) + +/** + * @brief Check whether the specified WWDG flag is set or not. + * @param __INSTANCE__ WWDG peripheral + * @param __FLAG__ specifies the flag to check. + * This parameter can be one of the following values: + * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag + * @retval The new state of WWDG_FLAG (SET or RESET). + */ + +#define __LL_WWDG_GET_FLAG(__INSTANCE__, __FLAG__) ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET) +/** + * @brief Clears the WWDG's pending flags. + * @param __INSTANCE__ WWDG peripheral + * @param __FLAG__ specifies the flag to clear. + * This parameter can be one of the following values: + * @arg WWDG_FLAG_EWIF: Early wakeup interrupt flag + * @retval None + */ + +#define __LL_WWDG_CLEAR_FLAG(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__)) + +/** + * @brief Checks if the specified WWDG interrupt source is enabled or disabled. + * @param __INSTANCE__ WWDG peripheral + * @param __INTERRUPT__ specifies the WWDG interrupt source to check. + * This parameter can be one of the following values: + * @arg WWDG_IT_EWIE: Early Wakeup Interrupt + * @retval state of __INTERRUPT__ (SET or RESET). + */ +#define __LL_WWDG_CHECK_IT_SOURCE(__INSTANCE__, __INTERRUPT__) \ + ((READ_BIT((__INSTANCE__)->CR, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) + +/** + * @brief Get the WWDG Counter Register value on runtime. + * @param __INSTANCE__ WWDG peripheral + * @retval 16-bit value of the WWDG counter register (WWDG_CVR) + */ +#define __LL_WWDG_GET_COUNTER(__INSTANCE__) (READ_REG((__INSTANCE__)->CVR)) + +/** + * @brief Set the WWDG Counter Register value to refresh WWDG. + * @param __INSTANCE__ WWDG peripheral + * @param __COUNTER__ specifies WWDG counter value to refresh with + * @retval None + */ +#define __LL_WWDG_SET_COUNTER(__INSTANCE__, __COUNTER__) WRITE_REG((__INSTANCE__)->CVR, __COUNTER__) + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @addtogroup WWDG_LL_Exported_Functions + * @{ + */ + +/** @addtogroup WWDG_LL_Exported_Functions_Group1 + * @{ + */ +LL_StatusETypeDef LL_WWDG_Init(WWDG_TypeDef *Instance, WWDG_InitTypeDef *Init); +LL_StatusETypeDef LL_WWDG_DeInit(WWDG_TypeDef *Instance); +void LL_WWDG_MspInit(WWDG_TypeDef *Instance); +void LL_WWDG_MspDeInit(WWDG_TypeDef *Instance); +/** + * @} + */ + + +/** @addtogroup WWDG_LL_Exported_Functions_Group2 + * @{ + */ +LL_StatusETypeDef LL_WWDG_Refresh(WWDG_TypeDef *Instance, uint16_t Counter); +/** + * @} + */ + + +/** @addtogroup WWDG_LL_Exported_Functions_Interrupt + * @{ + */ +void LL_WWDG_IRQHandler(WWDG_TypeDef *Instance); +void LL_WWDG_EarlyWakeUpCallback(WWDG_TypeDef *Instance); +/** + * @} + */ + +/** + * @} + */ + + +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/** @defgroup WWDG_LL_Private_Macros WWDG LL Private Macros + * @brief WWDG LL Private Macros + * @{ + */ + +/** + * @brief Judge is WWDG prescaler or not + * @param __PRESCALER__ prescaler to judge + * @retval 0 isn't WWDG prescaler + * @retval 1 is WWDG prescaler + */ +#define IS_WWDG_PRESCALER(__PRESCALER__) ((__PRESCALER__) <= 0xFFFFUL) + +/** + * @brief Judge is WWDG window or not + * @param __WINDOW__ window to judge + * @retval 0 isn't WWDG window + * @retval 1 is WWDG window + */ +#define IS_WWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= 0xFFFFUL) + +/** + * @brief Judge is WWDG counter or not + * @param __COUNTER__ counter to judge + * @retval 0 isn't WWDG counter + * @retval 1 is WWDG counter + */ +#define IS_WWDG_COUNTER(__COUNTER__) ((__COUNTER__) <= 0xFFFFUL) + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_WWDG_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll.c new file mode 100644 index 0000000000..103398d152 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll.c @@ -0,0 +1,529 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll.c + * @author MCD Application Team + * @brief LL module driver. + * This is the common part of the LL initialization + * + @verbatim + ============================================================================== + ##### How to use this driver ##### + ============================================================================== + [..] + The common LL driver contains a set of generic and common APIs that can be + used by the PPP peripheral drivers and the user to start using the LL. + [..] + The LL contains two APIs' categories: + (+) Common LL APIs + (+) Services LL APIs + @endverbatim + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "TAE32F53xx LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @defgroup TAE32F53xx_LL_Driver TAE32F53xx LL Driver + * @brief TAE32F53xx LL Driver + * @{ + */ + +/** @defgroup TAE32F53xx_LL TAE32F53xx LL + * @brief TAE32F53xx LL + * @{ + */ + +#ifdef LL_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/** @defgroup TAE32F53xx_LL_Private_Macros TAE32F53xx LL Private Macros + * @brief TAE32F53xx LL Private Macros + * @{ + */ + +/** + * @brief Judge is Tick freq or not + * @param FREQ Freq to be judged + * @retval 0 isn't Tick freq + * @retval 1 is Tick freq + */ +#define IS_TICKFREQ(FREQ) (((FREQ) == LL_TICK_FREQ_10HZ) || \ + ((FREQ) == LL_TICK_FREQ_100HZ) || \ + ((FREQ) == LL_TICK_FREQ_1KHZ)) + +/** + * @} + */ + +/* Private variables ---------------------------------------------------------*/ +/** @defgroup TAE32F53xx_LL_Private_Variables TAE32F53xx LL Private Variables + * @brief TAE32F53xx LL Private Variables + * @{ + */ + +/** + * @brief SysTick counter + */ +__IO uint32_t uwTick; + +/** + * @brief SysTick interrupt priority + */ +uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS) - 1; + +/** + * @brief SysTick interrupt frequency + */ +LL_TickFreqETypeDef uwTickFreq = LL_TICK_FREQ_DEFAULT; + +/** + * @} + */ + +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup TAE32F53xx_LL_Exported_Functions TAE32F53xx LL Exported Functions + * @brief TAE32F53xx LL Exported Functions + * @{ + */ + +/** @defgroup TAE32F53xx_LL_Exported_Functions_Group1 TAE32F53xx Initialization and de-initialization Functions + * @brief Initialization and de-initialization functions + * +@verbatim + =============================================================================== + ##### Initialization and de-initialization functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Initializes the Flash interface, the NVIC allocation and initial clock + configuration. It initializes the systick also when timeout is needed + and the backup domain when enabled. + (+) de-Initializes common part of the LL. + (+) Configure The time base source to have 1ms time base with a dedicated + Tick interrupt priority. + (++) SysTick timer is used by default as source of time base, but user + can eventually implement his proper time base source (a general purpose + timer for example or other time source), keeping in mind that Time base + duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and + handled in milliseconds basis. + (++) Time base configuration function (LL_InitTick ()) is called automatically + at the beginning of the program after reset by LL_Init() + (++) Source of time base is configured to generate interrupts at regular + time intervals. Care must be taken if LL_Delay() is called from a + peripheral ISR process, the Tick interrupt line must have higher priority + (numerically lower) than the peripheral interrupt. Otherwise the caller + ISR process will be blocked. + (++) functions affecting time base configurations are declared as __WEAK + to make override possible in case of other implementations in user file. +@endverbatim + * @{ + */ + +/** + * @brief This function is used to initialize the LL Library; it must be the first + * instruction to be executed in the main program (before to call any other + * LL function), it performs the following: + * Configure the Flash prefetch. + * Configures the SysTick to generate an interrupt each 1 millisecond, + * which is clocked by the LSI (at this stage, the clock is not yet + * configured and thus the system is running from the internal LSI at 32 KHz). + * Set NVIC Group Priority to 4. + * Calls the LL_MspInit() callback function defined in user file + * "tae32f53xx_ll_msp.c" to do the global low level hardware initialization + * + * @note SysTick is used as time base for the LL_Delay() function, the application + * need to ensure that the SysTick time base is always set to 1 millisecond + * to have correct LL operation. + * @param None + * @retval LL status + */ +LL_StatusETypeDef LL_Init(void) +{ +#ifdef LL_FLASH_MODULE_ENABLED + /* Configure Flash prefetch */ +#if PREFETCH_ENABLE + /* Prefetch enable */ + __LL_FLASH_I_BUS_PREFETCH_ENABLE(); + __LL_FLASH_D_BUS_PREFETCH_ENABLE(); +#else + /* Prefetch disable */ + __LL_FLASH_I_BUS_PREFETCH_DISABLE(); + __LL_FLASH_D_BUS_PREFETCH_DISABLE(); +#endif /* PREFETCH_ENABLE */ +#endif /* LL_FLASH_MODULE_ENABLED */ + + /* Set Interrupt Group Priority */ + LL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_3); + + /* Use systick as time base source and configure 1ms tick (default clock after Reset is LSI) */ + LL_InitTick(TICK_INT_PRIORITY); + + /* Init the low level hardware */ + LL_MspInit(); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief This function de-Initializes common part of the LL and stops the systick of time base. + * @note This function is optional. + * @param None + * @retval LL status + */ +LL_StatusETypeDef LL_DeInit(void) +{ + /* Reset of all peripherals */ + LL_SYSCTRL_AllPeriphRstAssert(); + + /* De-Init the low level hardware */ + LL_MspDeInit(); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Initialize the MSP. + * @param None + * @retval None + */ +__WEAK void LL_MspInit(void) +{ + /* NOTE : This function should not be modified, when the callback is needed, + the LL_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the MSP. + * @param None + * @retval None + */ +__WEAK void LL_MspDeInit(void) +{ + /* NOTE : This function should not be modified, when the callback is needed, + the LL_MspDeInit could be implemented in the user file + */ +} + + +/** + * @brief This function configures the source of the time base. + * The time source is configured to have 1ms time base with a dedicated + * Tick interrupt priority. + * @note This function is called automatically at the beginning of program after + * reset by LL_Init(). + * @note In the default implementation, SysTick timer is the source of time base. + * It is used to generate interrupts at regular time intervals. + * Care must be taken if LL_Delay() is called from a peripheral ISR process, + * The SysTick interrupt must have higher priority (numerically lower) + * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. + * The function is declared as __WEAK to be overwritten in case of other + * implementation in user file. + * @param TickPriority Tick interrupt priority. + * @retval LL status + */ +__WEAK LL_StatusETypeDef LL_InitTick(uint32_t TickPriority) +{ + /* Configure the SysTick to have interrupt in 1ms time basis*/ + if (LL_SYSTICK_Config(LL_SYSCTRL_SysclkGet() / (1000U / uwTickFreq)) > 0U) { + return LL_ERROR; + } + + /* Configure the SysTick IRQ priority */ + if (TickPriority < (1UL << __NVIC_PRIO_BITS)) { + LL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U); + uwTickPrio = TickPriority; + } else { + return LL_ERROR; + } + + /* Return function status */ + return LL_OK; +} + + +/** + * @} + */ + +/** @defgroup TAE32F53xx_LL_Exported_Functions_Group2 TAE32F53xx LL Control functions + * @brief TAE32F53xx LL Control functions + * +@verbatim + =============================================================================== + ##### LL Control functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Provide a tick value in millisecond + (+) Provide a blocking delay in millisecond + (+) Suspend the time base source interrupt + (+) Resume the time base source interrupt + (+) Get the LL API driver version + (+) Get the unique device identifier +@endverbatim + * @{ + */ + +/** + * @brief This function is called to increment a global variable "uwTick" + * used as application time base. + * @note In the default implementation, this variable is incremented each 1ms + * in SysTick ISR. + * @note This function is declared as __WEAK to be overwritten in case of other + * implementations in user file. + * @param None + * @retval None + */ +__WEAK void LL_IncTick(void) +{ + uwTick += uwTickFreq; +} + +/** + * @brief Provides a tick value in millisecond + * @note This function is declared as __WEAK to be overwritten in case of other + * implementations in user file. + * @param None + * @retval tick value + */ +__WEAK uint32_t LL_GetTick(void) +{ + return uwTick; +} + +/** + * @brief This function returns a tick priority + * @param None + * @retval tick priority + */ +uint32_t LL_GetTickPrio(void) +{ + return uwTickPrio; +} + +/** + * @brief Set new tick Freq + * @param Freq New tick freq + * @retval LL status + */ +LL_StatusETypeDef LL_SetTickFreq(LL_TickFreqETypeDef Freq) +{ + LL_StatusETypeDef status = LL_OK; + assert_param(IS_TICKFREQ(Freq)); + + if (uwTickFreq != Freq) { + /* Apply the new tick Freq */ + status = LL_InitTick(uwTickPrio); + + if (status == LL_OK) { + uwTickFreq = Freq; + } + } + + return status; +} + +/** + * @brief Get tick frequency + * @param None + * @retval tick period in Hz + */ +LL_TickFreqETypeDef LL_GetTickFreq(void) +{ + return uwTickFreq; +} + +/** + * @brief This function provides minimum delay (in milliseconds) based + * on variable incremented. + * @note In the default implementation , SysTick timer is the source of time base. + * It is used to generate interrupts at regular time intervals where uwTick + * is incremented. + * @note This function is declared as __WEAK to be overwritten in case of other + * implementations in user file. + * @param Delay specifies the delay time length, in milliseconds. + * @retval None + */ +__WEAK void LL_Delay(uint32_t Delay) +{ + uint32_t tickstart = LL_GetTick(); + uint32_t wait = Delay; + + /* Add a freq to guarantee minimum wait */ + if (wait < LL_MAX_DELAY) { + wait += (uint32_t)(uwTickFreq); + } + + while ((LL_GetTick() - tickstart) < wait) { + } +} + +/** + * @brief Suspend Tick increment. + * @note In the default implementation , SysTick timer is the source of time base. It is + * used to generate interrupts at regular time intervals. Once LL_SuspendTick() + * is called, the SysTick interrupt will be disabled and so Tick increment + * is suspended. + * @note This function is declared as __WEAK to be overwritten in case of other + * implementations in user file. + * @param None + * @retval None + */ +__WEAK void LL_SuspendTick(void) +{ + /* Disable SysTick Interrupt */ + CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); +} + +/** + * @brief Resume Tick increment. + * @note In the default implementation , SysTick timer is the source of time base. It is + * used to generate interrupts at regular time intervals. Once LL_ResumeTick() + * is called, the SysTick interrupt will be enabled and so Tick increment + * is resumed. + * @note This function is declared as __WEAK to be overwritten in case of other + * implementations in user file. + * @param None + * @retval None + */ +__WEAK void LL_ResumeTick(void) +{ + /* Enable SysTick Interrupt */ + SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk); +} + +/** + * @brief Get the LL revision + * @param None + * @retval version 0xXYZR (8bits for each decimal, R for RC) + */ +uint32_t LL_GetHalVersion(void) +{ + return __TAE32F53xx_LL_VERSION; +} + +/** + * @brief Returns words of the device unique identifier (UID based on 128 bits) + * @param UID[] device unique identifier store buffer + * @return None + */ +void LL_GetUID(uint32_t *UID[4]) +{ + //:TODO: return the device UID +} + +/** + * @} + */ + + +/** @defgroup TAE32F53xx_LL_Exported_Functions_Group3 TAE32F53xx LL Misc Functions + * @brief TAE32F53xx LL Misc Functions + * @{ + */ + +/** + * @brief LL Show Platform Information + * @param None + * @return None + */ +void LL_ShowInfo(void) +{ + DBG_LogRaw("\n======================== Platform Information =======================\n"); + + DBG_LogRaw("Tai-Action TAE32F53xx SDK "SDK_STAGE_STR" V%d.%d.%d "__DATE__" "__TIME__"\n\n", \ + __TAE32F53xx_LL_VERSION_MAIN, __TAE32F53xx_LL_VERSION_SUB1, __TAE32F53xx_LL_VERSION_SUB2); + + DBG_LogRaw("CPU clock %9u Hz\n", LL_SYSCTRL_SysclkGet()); + DBG_LogRaw("AHB clock %9u Hz\n", LL_SYSCTRL_AHBClkGet()); + DBG_LogRaw("APB0 clock %9u Hz\n", LL_SYSCTRL_APB0ClkGet()); + DBG_LogRaw("APB1 clock %9u Hz\n", LL_SYSCTRL_APB1ClkGet()); + + DBG_LogRaw("HSE clock %9u Hz\n", HSE_VALUE); + DBG_LogRaw("HSI clock %9u Hz\n", HSI_VALUE); + DBG_LogRaw("LSI clock %9u Hz\n", LSI_VALUE); + + DBG_LogRaw("=====================================================================\n\n"); +} + +/** + * @brief Delay 1ms + * @param ms The time to delay in 1ms Unit + * @return None + */ +void delay_ms(uint32_t ms) +{ + LL_Delay(ms); +} + +/** + * @brief printf array + * @param ptr printf array pointer + * @param len array len + * @retval None + */ +void printf_array(void *ptr, uint32_t len) +{ + uint32_t cnt = 0; + uint8_t *p_ptr = (uint8_t *)ptr; + + while (len--) { + DBG_LogRaw("%02x ", *p_ptr); + cnt++; + p_ptr++; + + if (!(cnt & 0x0f)) { + DBG_LogRaw("\r\n"); + } + } + + if ((cnt & 0x0f) != 0x0f) { + DBG_LogRaw("\r\n"); + } +} + +/** + * @} + */ + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_adc.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_adc.c new file mode 100644 index 0000000000..48ff73d4f8 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_adc.c @@ -0,0 +1,1390 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_adc.c + * @author MCD Application Team + * @brief ADC LL module driver. + * + ****************************************************************************** + @verbatim + * ============================================================================== + * ##### ADC peripheral features ##### + * ============================================================================== + * [..] + * (+) Interrupt generation at the end of regular conversion and in case of + * analog watchdog or overrun events. + * + * (+) Single and continuous conversion modes. + * + * (+) Scan mode for conversion of several channels sequentially. + * + * (+) Data alignment with in-built data coherency. + * + * (+) Programmable sampling time (channel wise) + * + * (+) External trigger (timer or EXTI) with configurable polarity + * + * (+) DMA request generation for transfer of conversions data of regular group. + * + * (+) Configurable delay between conversions in Dual interleaved mode. + * + * (+) ADC channels selectable single/differential input. + * + * (+) ADC calibration shared on 4 group offset & gain compensation instances. + * + * (+) ADC conversion of regular group. + * + * (+) ADC supply requirements: 1.62 V to 3.6 V. + * + * (+) ADC single input range: 0 to Vref. Vref is 3V + * + * (+) ADC Differential input range: from Vref- (connected to IN-) to Vref+ (connected to + * IN+ or to an external voltage reference). + @endverbatim + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" +#include "string.h" +#include "stdlib.h" + + +#define DBG_TAG "ADC LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup ADC_LL ADC LL + * @brief ADC LL module driver + * @{ + */ + +#ifdef LL_ADC_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/** @defgroup ADC_LL_Private_Variables ADC LL Private Variables + * @brief ADC LL Private Variables + * @{ + */ + +/** + * @brief ADC Calibration temp offset param + */ +volatile static int16_t temp_offset = 0; + +/** + * @brief ADC Calibration temp gain param + */ +volatile static uint16_t temp_gain = 0; + +/** + * @brief ADC Calibration Data struct param + */ +volatile ADC_CalibrationDataTypeDef pCoef = {0}; + +/** + * @brief ADC Calibration Data static param + */ +static const uint32_t Calib_check_data[3] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; + +/** + * @brief ADC Calibration read data array + */ +static uint32_t Calib_read_data[3] = {0}; +/** + * @} + */ + + +/* Private function prototypes -----------------------------------------------*/ +/** @defgroup ADC_LL_Private_Functions ADC LL Private Functions + * @brief ADC LL Private Functions + * @{ + */ +static void LL_ADC_ReadCoef(void); +static void LL_ADC_OverSamp_Mode(ADC_TypeDef *Instance, int16_t offset); +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup ADC_LL_Exported_Functions ADC LL Exported Functions + * @brief ADC LL Exported Functions + * @{ + */ + +/** @defgroup ADC_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and Configuration functions + * @{ + */ + +/** + * @brief Initialize some features of ADC instance. + * @note These parameters have an impact on ADC scope: ADC instance. + * Affects both group regular and group injected + * Refer to corresponding unitary functions into + * @ref ADC_LL_EF_Configuration_ADC_Instance . + * @note The setting of these parameters by function @ref LL_ADC_Init() + * is conditioned to ADC state: + * ADC instance must be disabled. + * @param Instance ADC instance + * @param ADC_InitStruct Pointer to a @ref ADC_REG_InitTypeDef structure + * @retval An LL_StatusETypeDef enumeration value: + * - SUCCESS: ADC registers are initialized + * - ERROR: ADC registers are not initialized + */ +LL_StatusETypeDef LL_ADC_Init(ADC_TypeDef *Instance, ADC_InitTypeDef *ADC_InitStruct) +{ + LL_StatusETypeDef status = LL_OK; + /*hardware level Initialize*/ + LL_ADC_MspInit(Instance); + /* Check the parameters */ + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + assert_param(IS_ADC_SYNCHRONIZATION(ADC_InitStruct->Synchronization)); + assert_param(IS_ADC_ANOLOGSET(ADC_InitStruct->AnologCfg)); + assert_param(IS_ADC_OVR_DATA_BEHAVIOR(ADC_InitStruct->Overrun)); + + /*Check whether the SOC has been calibrated*/ + LL_ADC_ReadCoef(); + + /* Note: Hardware constraint (refer to description of this function): */ + /* ADC instance must be disabled. */ + if (__LL_ADC_REG_IsConversionOngoing(Instance) == 0UL) { + /* Configuration of ADC hierarchical scope: */ + /* - ADC instance */ + /* - Set ADC Synchronization */ + MODIFY_REG(Instance->CR1, ADC_CR1_SYNCEN, ADC_InitStruct->Synchronization); + + //WRITE_REG(Instance->CR2, ADC_InitStruct->AnologCfg); + /*only ADC0 valid paramter*/ + //WRITE_REG(ADC0->CR2, ADC_InitStruct->AnologCfg); + + if (Instance == ADC0) { + WRITE_REG(Instance->CR2, ADC_InitStruct->AnologCfg); + } else if (Instance == ADC1) { + /*only ADC0 valid paramter*/ + WRITE_REG(Instance->CR2, ADC_InitStruct->AnologCfg); + WRITE_REG(ADC0->CR2, ADC_InitStruct->AnologCfg); + } + + while (!(Instance->ISR & BIT(8))); + + /* Configuration of Oversampler: */ + /* - Oversampling Ratio */ + /* - Right bit shift */ + /* - Triggered mode */ + /* - Oversampling mode (continued/resumed) */ + + if (ADC_InitStruct->RegOversampMode && !(ADC_InitStruct->InjOversampMode)) { + SET_BIT(Instance->CR1, ADC_CR1_ROVSE); + } else if (ADC_InitStruct->InjOversampMode && !(ADC_InitStruct->RegOversampMode)) { + SET_BIT(Instance->CR1, ADC_CR1_JOVSE); + } else { + SET_BIT(Instance->CR1, ADC_CR1_ROVSE | ADC_CR1_JOVSE); + } + + assert_param(IS_ADC_OVERSAMPMODE_SET(ADC_InitStruct->OverSampling.OverSampResetMode)); + assert_param(IS_ADC_TRIGOVERSAMP(ADC_InitStruct->OverSampling.TrigOverSamp)); + assert_param(IS_ADC_OVERSAMPSHIFT(ADC_InitStruct->OverSampling.OverSampShiftBit)); + assert_param(IS_ADC_OVERSAMPRATIO(ADC_InitStruct->OverSampling.OverSampRatio)); + + MODIFY_REG(Instance->CR1, + ADC_CR1_ROVSM + | ADC_CR1_TROVS + | ADC_CR1_OVSS + | ADC_CR1_OVSR + | ADC_CR1_OVRMOD + , + ADC_InitStruct->OverSampling.OverSampResetMode + | ADC_InitStruct->OverSampling.TrigOverSamp + | ADC_InitStruct->OverSampling.OverSampShiftBit + | ADC_InitStruct->OverSampling.OverSampRatio + | ADC_InitStruct->Overrun + ); + /*Normal interrupt config*/ + WRITE_REG(Instance->IER, ADC_InitStruct->NormInterrupt); + + } else { + /* Initialization error: ADC instance is not disabled. */ + status = LL_ERROR; + } + + return status; +} + +/** + * @brief De-initialize registers of the selected ADC instance + * to their default reset values. + * @note To reset all ADC instances quickly (perform a hard reset), + * @note If this functions returns error status, it means that ADC instance + * is in an unknown state. + * In this case, perform a hard reset using high level + * clock source RCC ADC reset. + * @param Instance ADC instance + * @retval An LL_StatusETypeDef enumeration value: + * - SUCCESS: ADC registers are de-initialized + * - ERROR: ADC registers are not de-initialized + */ +LL_StatusETypeDef LL_ADC_DeInit(ADC_TypeDef *Instance) +{ + LL_StatusETypeDef status = LL_OK; + + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + + /* Disable ADC instance if not already disabled. */ + /* Set ADC group regular trigger source to SW start to ensure to not */ + /* have an external trigger event occurring during the conversion stop */ + /* ADC disable process. */ + __LL_ADC_REG_SetTriggerSource(Instance, ADC_REG_TRIG_SOFTWARE); + + /* Stop potential ADC conversion on going on ADC group regular. */ + if (__LL_ADC_REG_IsConversionOngoing(Instance) != 0UL) { + if (__LL_ADC_REG_IsStopConversionOngoing(Instance) == 0UL) { + __LL_ADC_REG_StopConversion(Instance); + } + } + + /* Set ADC group injected trigger source to SW start to ensure to not */ + /* have an external trigger event occurring during the conversion stop */ + /* ADC disable process. */ + __LL_ADC_INJ_SetTriggerSource(Instance, ADC_INJ_TRIG_SOFTWARE); + + /* Stop potential ADC conversion on going on ADC group injected. */ + if (__LL_ADC_INJ_IsConversionOngoing(Instance) != 0UL) { + if (__LL_ADC_INJ_IsStopConversionOngoing(Instance) == 0UL) { + __LL_ADC_INJ_StopConversion(Instance); + } + } + + /* Check whether ADC state is compliant with expected state */ + if (READ_BIT(Instance->CR0, (ADC_CR0_JADSTP | ADC_CR0_ADSTP | ADC_CR0_JADSTART | ADC_CR0_ADSTART)) == 0UL) { + /* ========== Reset ADC registers ========== */ + /* Reset register IER */ + CLEAR_BIT(Instance->IER, + (ADC_IER_ADRDYIE + | ADC_IER_EOCIE + | ADC_IER_EOSIE + | ADC_IER_OVRIE + | ADC_IER_EOSMPIE + | ADC_IER_JEOCIE + | ADC_IER_JEOSIE + | ADC_IER_AWD0IE + | ADC_IER_AWD1IE + | ADC_IER_AWD2IE + ) + ); + + /* Reset register ISR */ + SET_BIT(Instance->ISR, + (ADC_ISR_ADRDY + | ADC_ISR_EOC + | ADC_ISR_EOS + | ADC_ISR_OVR + | ADC_ISR_EOSMP + | ADC_ISR_JEOC + | ADC_ISR_JEOS + | ADC_ISR_AWD0 + | ADC_ISR_AWD1 + | ADC_ISR_AWD2 + ) + ); + /* Reset register SIER */ + CLEAR_BIT(Instance->SIER, (ADC_SIER_CHANNEL)); + /* Reset register SISR */ + SET_BIT(Instance->SISR, (ADC_SISR_CHANNEL)); + + /* Reset register HIER */ + CLEAR_BIT(Instance->HIER, (ADC_HIER_CHANNEL)); + /* Reset register SISR */ + SET_BIT(Instance->HISR, (ADC_HISR_CHANNEL)); + + /* Reset register SIER */ + CLEAR_BIT(Instance->FIER, (ADC_FIER_CHANNEL)); + /* Reset register SISR */ + SET_BIT(Instance->FISR, (ADC_FISR_CHANNEL)); + + /* Reset register CR1 */ + CLEAR_BIT(Instance->CR1, + (ADC_CR1_SYNCEN | ADC_CR1_JAUTO | ADC_CR1_JDISCEN + | ADC_CR1_DISCNUM | ADC_CR1_DISCEN | ADC_CR1_CONT + | ADC_CR1_OVRMOD | ADC_CR1_ROVSM | ADC_CR1_TROVS + | ADC_CR1_OVSS | ADC_CR1_OVSR | ADC_CR1_JOVSE + | ADC_CR1_ROVSE) + ); + + /* Reset register CR2 */ + CLEAR_BIT(Instance->CR2, + (ADC_CR2_ISEL | ADC_CR2_TBOMOD | ADC_CR2_TBIMOD + | ADC_CR2_TB_EN | ADC_CR2_CH_EN | ADC_CR2_FADC_EN + | ADC_CR2_REF_EN | ADC_CR2_BIAS_EN) + ); + + /* Reset register DIFSEL */ + CLEAR_BIT(Instance->DIFSEL, (ADC_DIFSEL_DIFSEL)); + + /* Reset register SMPR0 */ + CLEAR_BIT(Instance->SMPR0, + (ADC_SMPR0_SMP7 | ADC_SMPR0_SMP6 | ADC_SMPR0_SMP5 + | ADC_SMPR0_SMP4 | ADC_SMPR0_SMP3 | ADC_SMPR0_SMP2 + | ADC_SMPR0_SMP1 | ADC_SMPR0_SMP0) + ); + + /* Reset register SMPR1 */ + CLEAR_BIT(Instance->SMPR1, (ADC_SMPR1_SMP11 | ADC_SMPR1_SMP10 | ADC_SMPR1_SMP9 | ADC_SMPR1_SMP8)); + + /* Reset register CALR0 */ + CLEAR_BIT(Instance->SMPR0, + (ADC_CALR0_CAL7 | ADC_CALR0_CAL6 | ADC_CALR0_CAL5 + | ADC_CALR0_CAL4 | ADC_CALR0_CAL3 | ADC_CALR0_CAL2 + | ADC_CALR0_CAL1 | ADC_CALR0_CAL0) + ); + + /* Reset register CALR1 */ + CLEAR_BIT(Instance->SMPR1, (ADC_CALR1_CAL11 | ADC_CALR1_CAL10 | ADC_CALR1_CAL9 | ADC_CALR1_CAL8)); + + /* Reset register AWD0CR TR0 */ + CLEAR_BIT(Instance->AWDCR[0], ADC_AWD0CR_AWD0FILT | ADC_AWD0CR_AWD0CH); + CLEAR_BIT(Instance->TR[0], ADC_TR0_HT0 | ADC_TR0_LT0); + + /* Reset register AWD1CR TR1 */ + CLEAR_BIT(Instance->AWDCR[1], ADC_AWD1CR_AWD1FILT | ADC_AWD1CR_AWD1CH); + CLEAR_BIT(Instance->TR[1], ADC_TR1_HT1 | ADC_TR1_LT1); + + /* Reset register AWD2CR TR2 */ + CLEAR_BIT(Instance->AWDCR[2], ADC_AWD2CR_AWD2FILT | ADC_AWD2CR_AWD2CH); + CLEAR_BIT(Instance->TR[2], ADC_TR2_HT2 | ADC_TR2_LT2); + + /* Reset register SQR0*/ + CLEAR_BIT(Instance->SQR0, + (ADC_SQR0_SQ8 | ADC_SQR0_SQ7 | ADC_SQR0_SQ6 + | ADC_SQR0_SQ5 | ADC_SQR0_SQ4 | ADC_SQR0_SQ3 + | ADC_SQR0_SQ2 | ADC_SQR0_SQ1) + ); + + /* Reset register SQR1 */ + CLEAR_BIT(Instance->SQR1, + (ADC_SQR1_SQ16 | ADC_SQR1_SQ15 | ADC_SQR1_SQ14 + | ADC_SQR1_SQ13 | ADC_SQR1_SQ12 | ADC_SQR1_SQ11 + | ADC_SQR1_SQ10 | ADC_SQR1_SQ9) + ); + + /* Reset register LR */ + CLEAR_BIT(Instance->LR, (ADC_LR_LEN | ADC_LR_EXTEN | ADC_LR_EXTSEL)); + + /* Reset register JSQR */ + CLEAR_BIT(Instance->JSQR, ADC_JSQR_JSQ4 | ADC_JSQR_JSQ3 | ADC_JSQR_JSQ2 | ADC_JSQR_JSQ1); + + /* Reset register JLR */ + CLEAR_BIT(Instance->JLR, (ADC_JLR_JLEN | ADC_JLR_JEXTSEL | ADC_JLR_JEXTEN)); + + /* Reset register DR */ + /* Note: bits in access mode read only, no direct reset applicable */ + + /* Reset register OFR0 */ + CLEAR_BIT(Instance->OFR[0], ADC_OFR0_OFFSET); + /* Reset register OFR1 */ + CLEAR_BIT(Instance->OFR[1], ADC_OFR1_OFFSET); + /* Reset register OFR2 */ + CLEAR_BIT(Instance->OFR[2], ADC_OFR2_OFFSET); + /* Reset register OFR3 */ + CLEAR_BIT(Instance->OFR[3], ADC_OFR3_OFFSET); + + /* Reset register GCR0 */ + CLEAR_BIT(Instance->GCR[0], ADC_GCR0_GAIN); + /* Reset register GCR1 */ + CLEAR_BIT(Instance->GCR[1], ADC_GCR1_GAIN); + /* Reset register GCR2 */ + CLEAR_BIT(Instance->GCR[2], ADC_GCR2_GAIN); + /* Reset register GCR3 */ + CLEAR_BIT(Instance->GCR[3], ADC_GCR3_GAIN); + + /* Reset register DOFR0 */ + CLEAR_BIT(Instance->DOFR[0], ADC_DOFR0_OFFSET); + /* Reset register DOFR1 */ + CLEAR_BIT(Instance->DOFR[1], ADC_DOFR1_OFFSET); + /* Reset register DOFR2 */ + CLEAR_BIT(Instance->DOFR[2], ADC_DOFR2_OFFSET); + /* Reset register DOFR3 */ + CLEAR_BIT(Instance->DOFR[3], ADC_DOFR3_OFFSET); + + /* Reset register DGCR0 */ + CLEAR_BIT(Instance->DGCR[0], ADC_DGCR0_GAIN); + /* Reset register DGCR1 */ + CLEAR_BIT(Instance->DGCR[1], ADC_DGCR1_GAIN); + /* Reset register DGCR2 */ + CLEAR_BIT(Instance->DGCR[2], ADC_DGCR2_GAIN); + /* Reset register DGCR3 */ + CLEAR_BIT(Instance->DGCR[3], ADC_DGCR3_GAIN); + + /* Reset registers JDR1, JDR2, JDR3, JDR4 */ + /* Note: bits in access mode read only, no direct reset applicable */ + + /* Reset register ECR0 */ + CLEAR_BIT(Instance->ECR[0], ADC_ECR0_ADSRC | ADC_ECR0_PSRCU | ADC_ECR0_PSRCD + | ADC_ECR0_AWD2SEL | ADC_ECR0_AWD1SEL | ADC_ECR0_AWD0SEL); + + /* Reset register ECR1 */ + CLEAR_BIT(Instance->ECR[1], ADC_ECR1_ADSRC | ADC_ECR1_PSRCU | ADC_ECR1_PSRCD + | ADC_ECR1_AWD2SEL | ADC_ECR1_AWD1SEL | ADC_ECR1_AWD0SEL); + + /* Reset register ECR2 */ + CLEAR_BIT(Instance->ECR[2], ADC_ECR2_ADSRC | ADC_ECR2_PSRCU | ADC_ECR2_PSRCD + | ADC_ECR2_AWD2SEL | ADC_ECR2_AWD1SEL | ADC_ECR2_AWD0SEL); + + /* Reset register ECR3 */ + CLEAR_BIT(Instance->ECR[3], ADC_ECR3_ADSRC | ADC_ECR3_PSRCU | ADC_ECR3_PSRCD + | ADC_ECR3_AWD2SEL | ADC_ECR3_AWD1SEL | ADC_ECR3_AWD0SEL); + + /* Reset register DMA_CR */ + for (uint8_t i = 0; i < 12; i++) { + CLEAR_BIT(Instance->DMA_CR[i].TCR, ADC_DMA_TCR_CIRC | ADC_DMA_TCR_STP | ADC_DMA_TCR_START); + CLEAR_BIT(Instance->DMA_CR[i].TAR, ADC_DMA_TAR_ADDR); + CLEAR_BIT(Instance->DMA_CR[i].TLR, ADC_DMA_TLR_LENG); + } + + } else { + /* ADC instance is in an unknown state */ + /* Need to performing a hard reset of ADC instance, using high level */ + /* clock source RCC ADC reset. */ + status = LL_ERROR; + } + + return status; +} + +/** + * @brief Initialize some features of ADC group regular. + * @note These parameters have an impact on ADC scope: ADC group regular. + * @note The setting of these parameters by function @ref LL_ADC_Init() + * is conditioned to ADC state: + * ADC instance must be disabled. + * Each feature can be updated afterwards with a unitary function + * and potentially with ADC in a different state than disabled, + * refer to description of each function for setting + * conditioned to ADC state. + * @param Instance ADC instance + * @param ADC_REG_InitStruct Pointer to a @ref ADC_REG_InitTypeDef structure + * @retval An StatusETypeDef enumeration value: + * - SUCCESS: ADC registers are initialized + * - ERROR: ADC registers are not initialized + */ +LL_StatusETypeDef LL_ADC_REG_Init(ADC_TypeDef *Instance, ADC_REG_InitTypeDef *ADC_REG_InitStruct) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + assert_param(IS_ADC_CHANNEL(ADC_REG_InitStruct->Channel)); + assert_param(IS_ADC_REG_TRIG_SOURCE(ADC_REG_InitStruct->TriggerSource)); + assert_param(IS_ADC_REG_SEQ_LENGTH(ADC_REG_InitStruct->SequencerLength)); + assert_param(IS_ADC_REG_SEQ_POS(ADC_REG_InitStruct->SequencerPos)); + + if (ADC_REG_InitStruct->SequencerLength != ADC_REG_SEQ_LENGTH_1) { + assert_param(IS_ADC_REG_SEQ_DISCONT(ADC_REG_InitStruct->SequencerDiscont)); + } + + if (ADC_REG_InitStruct->Channel == ADC_CHANNEL_TEMPSENSOR) { + /*Enable temperature sensor detection*/ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_ADCBuf_En(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + } + + assert_param(IS_ADC_REG_CONTINUOUS_MODE(ADC_REG_InitStruct->ContinuousMode)); + assert_param(IS_ADC_REG_DIFFERSEL(ADC_REG_InitStruct->DifferSel)); + assert_param(IS_ADC_REG_SAMPTIMCLK(ADC_REG_InitStruct->SampTimClk)); + + if (__LL_ADC_REG_IsConversionOngoing(Instance) == 0UL) { + /* Configuration of ADC hierarchical scope: */ + /* - ADC group regular */ + /* - Set ADC group regular trigger source */ + /* - Set ADC group regular sequencer length */ + /* - Set ADC group regular sequencer discontinuous mode */ + /* - Set ADC group regular continuous mode */ + /* - Set ADC group regular overrun behavior */ + /* Note: ADC trigger edge is set to value 0x0 by */ + /* setting of trigger source to SW start. */ + /* Set ADC group regular sequencer length */ + if (ADC_REG_InitStruct->SequencerLength == ADC_REG_SEQ_LENGTH_1) { + MODIFY_REG(Instance->LR, + ADC_LR_EXTSEL + | ADC_LR_EXTEN + | ADC_LR_LEN + , + ADC_REG_InitStruct->TriggerSource + | ADC_REG_InitStruct->SequencerLength + ); + MODIFY_REG(Instance->SQR0, + ADC_SQR0_SQ1, + ADC_REG_InitStruct->Channel + ); + } else { + MODIFY_REG(Instance->LR, + ADC_LR_EXTSEL + | ADC_LR_EXTEN + | ADC_LR_LEN + , + ADC_REG_InitStruct->TriggerSource + | ADC_REG_InitStruct->SequencerLength + ); + + if (ADC_REG_InitStruct->SequencerPos > 7) { + MODIFY_REG(Instance->SQR1, + (ADC_SQR1_SQ9 << ((ADC_REG_InitStruct->SequencerPos - 8U) << 2U)), + (ADC_REG_InitStruct->Channel << ((ADC_REG_InitStruct->SequencerPos - 8U) << 2U)) + ); + } else { + MODIFY_REG(Instance->SQR0, + ADC_SQR0_SQ1 << (ADC_REG_InitStruct->SequencerPos << 2U), + (ADC_REG_InitStruct->Channel << (ADC_REG_InitStruct->SequencerPos << 2U)) + ); + } + } + + /*Continuous mode and discontinuous mode cannot be set to 1 at the same time*/ + CLEAR_BIT(Instance->CR1, ADC_CR1_CONT | ADC_CR1_DISCEN); + + if (ADC_REG_InitStruct->ContinuousMode == ADC_REG_CONV_CONTINUOUS) { + SET_BIT(Instance->CR1, ADC_CR1_CONT); + } else { + MODIFY_REG(Instance->CR1, + ADC_CR1_DISCEN + | ADC_CR1_DISCNUM + | ADC_CR1_CONT + , + ADC_REG_InitStruct->SequencerDiscont + | ADC_REG_InitStruct->ContinuousMode + ); + } + + /*Sampling time and calibration parameter set selection*/ + if (ADC_REG_InitStruct->Channel > 7) { + MODIFY_REG(Instance->SMPR1, + ADC_SMPR1_SMP8 << ((ADC_REG_InitStruct->Channel - 8U) << 2U), + ADC_REG_InitStruct->SampTimClk << ((ADC_REG_InitStruct->Channel - 8U) << 2U) + ); + } else { + MODIFY_REG(Instance->SMPR0, + ADC_SMPR0_SMP0 << (ADC_REG_InitStruct->Channel << 2U), + ADC_REG_InitStruct->SampTimClk << (ADC_REG_InitStruct->Channel << 2U) + ); + } + + /*configure the channel sample interrupt*/ + if (ADC_REG_InitStruct->SampInterrupt == ENABLE) { + __LL_ADC_ENABLE_IT_DONE(Instance, ADC_REG_InitStruct->Channel); + } else { + __LL_ADC_DISABLE_IT_DONE(Instance, ADC_REG_InitStruct->Channel); + } + + /*Differential single-end Offset/Gain setting*/ + SET_BIT(Instance->DIFSEL, (ADC_DIFSEL_DIFSEL & (ADC_REG_InitStruct->DifferSel << ADC_REG_InitStruct->Channel))); + } else { + /* Initialization error: ADC instance is not disabled. */ + status = LL_ERROR; + } + + return status; +} + +/** + * @brief Initialize some features of ADC group injected. + * @note These parameters have an impact on ADC scope: ADC group injected. + * @note The setting of these parameters by function @ref LL_ADC_Init() + * is conditioned to ADC state: + * ADC instance must be disabled. + * @note After using this function, other features must be configured + * using LL unitary functions. + * The minimum configuration remaining to be done is: + * - Set ADC group injected sequencer: + * map channel on the selected sequencer rank. + * Refer to function @ref LL_ADC_INJ_SetSequencerRanks(). + * @param Instance ADC instance + * @param ADC_INJ_InitStruct Pointer to a @ref ADC_INJ_InitTypeDef structure + * @retval An LL_StatusETypeDef enumeration value: + * - SUCCESS: ADC registers are initialized + * - ERROR: ADC registers are not initialized + */ +LL_StatusETypeDef LL_ADC_INJ_Init(ADC_TypeDef *Instance, ADC_INJ_InitTypeDef *ADC_INJ_InitStruct) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + assert_param(IS_ADC_CHANNEL(ADC_INJ_InitStruct->Channel)); + assert_param(IS_ADC_INJ_JSEQ_POS(ADC_INJ_InitStruct->SequencerPos)); + assert_param(IS_ADC_INJ_TRIG_SOURCE(ADC_INJ_InitStruct->TriggerSource)); + assert_param(IS_ADC_INJ_SEQ_SCAN_LENGTH(ADC_INJ_InitStruct->SequencerLength)); + assert_param(IS_ADC_INJ_SEQ_SCAN_DISCONT_MODE(ADC_INJ_InitStruct->SequencerDiscont)); + assert_param(IS_ADC_INJ_TRIG_AUTO(ADC_INJ_InitStruct->TrigAuto)); + + /* Note: Hardware constraint (refer to description of this function): */ + /* ADC instance must be disabled. */ + if (__LL_ADC_INJ_IsConversionOngoing(Instance) == 0UL) { + if (ADC_INJ_InitStruct->Channel == ADC_CHANNEL_TEMPSENSOR) { + /*Enable temperature sensor detection*/ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_ADCBuf_En(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + } + + /* Configuration of ADC hierarchical scope: */ + /* - ADC group injected */ + /* - Set ADC group injected trigger source */ + /* - Set ADC group injected sequencer length */ + /* - Set ADC group injected sequencer discontinuous mode */ + /* - Set ADC group injected conversion trigger: independent or */ + /* from ADC group regular (injected auto ) */ + MODIFY_REG(Instance->CR1, + ADC_CR1_JDISCEN + | ADC_CR1_JAUTO + , + ADC_INJ_InitStruct->SequencerDiscont + | ADC_INJ_InitStruct->TrigAuto + ); + + MODIFY_REG(Instance->JLR, + ADC_JLR_JEXTSEL + | ADC_JLR_JEXTEN + | ADC_JLR_JLEN + , + ADC_INJ_InitStruct->TriggerSource + | ADC_INJ_InitStruct->SequencerLength + ); + /*JSQR sequence position*/ + MODIFY_REG(Instance->JSQR, (ADC_JSQR_JSQ1 << ADC_INJ_InitStruct->SequencerPos), + ADC_INJ_InitStruct->Channel << ADC_INJ_InitStruct->SequencerPos); + } else { + /* Initialization error: ADC instance is not disabled. */ + status = LL_ERROR; + } + + + return status; +} + +/** + * @brief Initializes the ADC MSP. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_MspInit(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the ADC MSP + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_MspDeInit(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + +/** @defgroup ADC_LL_Exported_Functions_Group2 ADC Config Functions + * @brief ADC Config Functions + * + @verbatim + =============================================================================== + ##### Peripheral Control functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Configure the adc to ecu paramter + (+) Configure the analog watchdog + (+) Configure the DMA Transfer + (+) Configure the calibration paramter + (+) Configure the oversamping + @endverbatim + * + * @{ + */ + + +/** + * @brief Initialize some features of ADC and ECU linkage related register. + * @note These parameters have an impact on ADC scope: ADC to ECU register ECR0~3. + * @note The setting of these parameters by function @ref LL_ADC_Init() + * is conditioned to ADC state: + * ADC instance must be disabled. + * @param Instance ADC instance + * @param ADC_ECU_Config Pointer to a @ref ADC_ECU_Config structure + * @retval An LL_StatusETypeDef enumeration value: + * - SUCCESS: ADC registers are initialized + * - ERROR: ADC registers are not initialized + */ +LL_StatusETypeDef LL_ADC_ECU_Config(ADC_TypeDef *Instance, ADC_ECUConfTypeDef *ADC_ECU_Config) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + assert_param(IS_ADC_ECU_GROUPSEL(ADC_ECU_Config->GroupSel)); + assert_param(IS_ADC_CHANNEL(ADC_ECU_Config->AddrDataSel)); + assert_param(IS_ADC_CHANNEL(ADC_ECU_Config->AWD0SourceSel)); + assert_param(IS_ADC_CHANNEL(ADC_ECU_Config->AWD1SourceSel)); + assert_param(IS_ADC_CHANNEL(ADC_ECU_Config->AWD2SourceSel)); + assert_param(IS_ADC_REG_AWD_SEL(ADC_ECU_Config->PingPongUpZero)); + assert_param(IS_ADC_REG_AWD_SEL(ADC_ECU_Config->PingPongDownZero)); + + /* Note: Hardware constraint (refer to description of this function): */ + /* ADC instance must be disabled. */ + if (__LL_ADC_REG_IsConversionOngoing(Instance) == 0UL) { + /* Configuration of ADC hierarchical scope: */ + /* - ADC to ECU control paramter */ + /* - Set ADC address data flag */ + /* - Set ADC ping pong up zero anolog watchdog */ + /* - Set ADC ping pong down zero anolog watchdog */ + /* - Set ADC anolog watchdog x detected channel */ + MODIFY_REG(Instance->ECR[ADC_ECU_Config->GroupSel], + ADC_ECR0_ADSRC + | ADC_ECR0_PSRCU + | ADC_ECR0_PSRCD + | ADC_ECR0_AWD2SEL + | ADC_ECR0_AWD1SEL + | ADC_ECR0_AWD0SEL + , + (ADC_ECU_Config->AddrDataSel << 16U) + | (ADC_ECU_Config->PingPongUpZero << 14U) + | (ADC_ECU_Config->PingPongDownZero << 12U) + | (ADC_ECU_Config->AWD2SourceSel << 8U) + | (ADC_ECU_Config->AWD1SourceSel << 4U) + | ADC_ECU_Config->AWD0SourceSel + ); + } else { + /* Initialization error: ADC instance is not disabled. */ + status = LL_ERROR; + } + + return status; +} + +/** + * @brief Configure the analog watchdog. + * @note Possibility to update parameters on the fly: + * This function initializes the selected analog watchdog, successive + * calls to this function can be used to reconfigure some parameters + * of structure "ADC_AnalogWDGCfgTypeDef" on the fly, without resetting + * the ADC. + * The same watchdog can monitor multiple channels simultaneously. + * @param Instance ADC instance + * @param AnalogWDGConfig Structure of ADC analog watchdog configuration + * @retval LL status + */ +LL_StatusETypeDef LL_ADC_AnalogWDGConfig(ADC_TypeDef *Instance, ADC_AnalogWDGCfgTypeDef *AnalogWDGConfig) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + assert_param(IS_ADC_REG_AWD_SEL(AnalogWDGConfig->WatchdogNumber)); + assert_param(IS_ADC_AWD_CHANNEL(AnalogWDGConfig->Channel)); + assert_param(IS_ADC_REG_AWD_FILTER(AnalogWDGConfig->Filtering)); + + /* - Analog watchdog channels */ + if ((__LL_ADC_REG_IsConversionOngoing(Instance) == 0UL) && (__LL_ADC_INJ_IsConversionOngoing(Instance) == 0UL)) { + /* Configuration of analog watchdog:*/ + /* Set the filtering \ channel configuration */ + MODIFY_REG(Instance->AWDCR[AnalogWDGConfig->WatchdogNumber], + ADC_AWD0CR_AWD0CH | ADC_AWD0CR_AWD0FILT, + (AnalogWDGConfig->Channel) + | (AnalogWDGConfig->Filtering) + ); + /* Set the watchdog high and low threshold */ + MODIFY_REG(Instance->TR[AnalogWDGConfig->WatchdogNumber], + ADC_TR0_HT0 | ADC_TR0_LT0, + (AnalogWDGConfig->LowThreshold & ADC_TR0_LT0) + | ((AnalogWDGConfig->HighThreshold & ADC_TR0_LT0) << ADC_TR0_HT0_Pos) + ); + } else { + status = LL_ERROR; + } + + return status; +} + +/** + * @brief Configure the DMA transfer. + * @note Possibility to update parameters on the fly: + * This function initializes the selected channel, + * Only one channel can be configured at a time. + * You cannot use the same address for different channels. + * @param Instance ADC instance + * @param DMATransferConfig Structure of ADC DMA transfer configuration + * @retval LL status + */ +LL_StatusETypeDef LL_ADC_DMATransferConfig(ADC_TypeDef *Instance, ADC_DMATransferCfgTypeDef *DMATransferConfig) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + assert_param(IS_ADC_CHANNEL(DMATransferConfig->Channel)); + assert_param(IS_ADC_REG_DMA_TRANSFER(DMATransferConfig->TransferMode)); + + /* - DMA Transfer channels */ + if ((__LL_ADC_REG_IsConversionOngoing(Instance) == 0UL) && (__LL_ADC_INJ_IsConversionOngoing(Instance) == 0UL)) { + MODIFY_REG(Instance->DMA_CR[DMATransferConfig->Channel].TAR, + ADC_DMA_TAR_ADDR, + (DMATransferConfig->Address) + ); + MODIFY_REG(Instance->DMA_CR[DMATransferConfig->Channel].TLR, + ADC_DMA_TLR_LENG, + (DMATransferConfig->Length) + ); + MODIFY_REG(Instance->DMA_CR[DMATransferConfig->Channel].TCR, + ADC_DMA_TCR_START | ADC_DMA_TCR_CIRC, + (DMATransferConfig->TransferMode) + ); + + if (DMATransferConfig->HalfInterrupt == ENABLE) { + __LL_ADC_ENABLE_IT_HALF(Instance, DMATransferConfig->Channel); + } else { + __LL_ADC_DISABLE_IT_HALF(Instance, DMATransferConfig->Channel); + } + + if (DMATransferConfig->FullInterrupt == ENABLE) { + __LL_ADC_ENABLE_IT_FULL(Instance, DMATransferConfig->Channel); + } else { + __LL_ADC_DISABLE_IT_FULL(Instance, DMATransferConfig->Channel); + } + + } else { + status = LL_ERROR; + } + + return status; +} + +/** + * @brief Configure the calibration parameters. + * @note Possibility to update parameters on the fly: + * This function initializes the selected channel, + * A total of four sets of calibration parameters can be selected for 12 channels. + * @param Instance ADC instance + * @param CalibrationConfig Structure of ADC DMA transfer configuration + * @retval LL status + */ +LL_StatusETypeDef LL_ADC_CalibrationConfig(ADC_TypeDef *Instance, ADC_CalibrationTypeDef *CalibrationConfig) +{ + LL_StatusETypeDef status = LL_OK; + + temp_offset = 0; + temp_gain = 0; + + /* Check the parameters */ + assert_param(IS_ADC_ALL_INSTANCE(Instance)); + assert_param(IS_ADC_CHANNEL(CalibrationConfig->Channel)); + assert_param(IS_LL_ADC_CALCOEFSEL(CalibrationConfig->CalibrationGroup)); + + /* Determine if the ADC is started */ + if ((__LL_ADC_REG_IsConversionOngoing(Instance) == 0UL) && (__LL_ADC_INJ_IsConversionOngoing(Instance) == 0UL)) { + + __LL_ADC_SetCalGroup(Instance, CalibrationConfig->Channel, CalibrationConfig->CalibrationGroup); + + /*Determines whether the selected channel is single-ended or differential*/ + if (__LL_ADC_GetChannelSingleDiff(Instance, CalibrationConfig->Channel)) { + + temp_offset = (int16_t)(pCoef.DiffOffset + (((int32_t)CalibrationConfig->Offset << 13) / pCoef.DiffGain)); + temp_gain = (uint16_t)((uint32_t)(CalibrationConfig->Gain * pCoef.DiffGain) >> 13); + + LL_ADC_OverSamp_Mode(Instance, temp_offset); + + MODIFY_REG(Instance->DOFR[CalibrationConfig->CalibrationGroup], + ADC_DOFR0_OFFSET, + (temp_offset) + ); + MODIFY_REG(Instance->DGCR[CalibrationConfig->CalibrationGroup], + ADC_DGCR0_GAIN, + (temp_gain) + ); + } else { + + temp_offset = (int16_t)(pCoef.SingleOffset + (((int32_t)CalibrationConfig->Offset << 13) / pCoef.SingleGain)); + temp_gain = (uint16_t)((uint32_t)(CalibrationConfig->Gain * pCoef.SingleGain) >> 13); + + LL_ADC_OverSamp_Mode(Instance, temp_offset); + + MODIFY_REG(Instance->OFR[CalibrationConfig->CalibrationGroup], + ADC_OFR0_OFFSET, + (temp_offset) + ); + MODIFY_REG(Instance->GCR[CalibrationConfig->CalibrationGroup], + ADC_GCR0_GAIN, + (temp_gain) + ); + } + + } else { + status = LL_ERROR; + } + + return status; +} + +/** + * @brief Convert to actual degrees Celsius + * @note Temperature = (Vout - 1.34) / 0.005 + * @retval LL status + */ +float LL_ADC_TemperatureCovert(uint16_t voltage_data) +{ + float voltage_realvalue = 0; + float temper_realvalue = 0; + + voltage_realvalue = (3.0 * voltage_data * 1000) / 8192.0; + + temper_realvalue = (voltage_realvalue - 1340) / 5; + + return temper_realvalue; + +} + +/** + * @} + */ + + +/** @defgroup ADC_LL_Exported_Functions_Interrupt Interrupt handler and call back + * @brief Interrupt handler and call back + * @{ + */ + +/** + * @brief ADC Ready detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_AdRdyCallback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_AdRdyCallback could be implemented in the user file + */ +} + +/** + * @brief ADC EoSmp detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_EosmpCallback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_EoSmpCallback could be implemented in the user file + */ +} + +/** + * @brief ADC Anolog WatchDog 2 detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_AnologWD2Callback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_AnologWD2Callback could be implemented in the user file + */ +} + +/** + * @brief ADC Anolog WatchDog 1 detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_AnologWD1Callback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_AnologWD1Callback could be implemented in the user file + */ +} + +/** + * @brief ADC Anolog WatchDog 0 detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_AnologWD0Callback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_AnologWD0Callback could be implemented in the user file + */ +} + +/** + * @brief ADC OverRun detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_OverRunCallback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_OverRunCallback could be implemented in the user file + */ +} + +/** + * @brief ADC injected end of sequencer detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_JeosCallback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_JeosCallback could be implemented in the user file + */ +} + +/** + * @brief ADC regular end of sequencer detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_EosCallback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_EosCallback could be implemented in the user file + */ +} + +/** + * @brief ADC injected end of conversion detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_JeocCallback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_JeocCallback could be implemented in the user file + */ +} + +/** + * @brief ADC regualr end of conversion detection callback. + * @param Instance ADC instance + * @return None + */ +__WEAK void LL_ADC_EocCallback(ADC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_EocCallback could be implemented in the user file + */ +} + +/** + * @brief ADC Sample done detection callback. + * @param Instance ADC instance + * @param Channel 0~11 + * @return None + */ +__WEAK void LL_ADC_SampCallback(ADC_TypeDef *Instance, uint8_t Channel) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_SampCallback could be implemented in the user file + */ +} + +/** + * @brief ADC DMA Half detection callback. + * @param Instance ADC instance + * @param Channel 0~11 + * @return None + */ +__WEAK void LL_ADC_HalfCallback(ADC_TypeDef *Instance, uint8_t Channel) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_HalfCallback could be implemented in the user file + */ +} + +/** + * @brief ADC DMA Full detection callback. + * @param Instance ADC instance + * @param Channel 0~11 + * @return None + */ +__WEAK void LL_ADC_FullCallback(ADC_TypeDef *Instance, uint8_t Channel) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ADC_FullCallback could be implemented in the user file + */ +} +/** + * @brief This function handles ADC Normal interrupts requests. + * @param Instance ADC instance + * @return None + */ +void LL_ADC_NORM_IRQHandler(ADC_TypeDef *Instance) +{ + if ((__LL_ADC_GET_IT_ADRDY(Instance)) && (__LL_ADC_GET_FLAG_ADRDY(Instance))) { + __LL_ADC_CLEAR_FLAG_ADRDY(Instance); + + /*Handle something*/ + LL_ADC_AdRdyCallback(Instance); + } + + if ((__LL_ADC_GET_IT_EOSMP(Instance)) && (__LL_ADC_GET_FLAG_EOSMP(Instance))) { + __LL_ADC_CLEAR_FLAG_EOSMP(Instance); + + /*Handle something*/ + LL_ADC_EosmpCallback(Instance); + } + + if ((__LL_ADC_GET_IT_AWD2(Instance)) && (__LL_ADC_GET_FLAG_AWD2(Instance))) { + __LL_ADC_CLEAR_FLAG_AWD2(Instance); + + /*Handle something*/ + LL_ADC_AnologWD2Callback(Instance); + } + + if ((__LL_ADC_GET_IT_AWD1(Instance)) && (__LL_ADC_GET_FLAG_AWD1(Instance))) { + __LL_ADC_CLEAR_FLAG_AWD1(Instance); + + /*Handle something*/ + LL_ADC_AnologWD1Callback(Instance); + } + + if ((__LL_ADC_GET_IT_AWD0(Instance)) && (__LL_ADC_GET_FLAG_AWD0(Instance))) { + __LL_ADC_CLEAR_FLAG_AWD0(Instance); + + /*Handle something*/ + LL_ADC_AnologWD0Callback(Instance); + } + + if ((__LL_ADC_GET_IT_OVR(Instance)) && (__LL_ADC_GET_FLAG_OVR(Instance))) { + __LL_ADC_CLEAR_FLAG_OVR(Instance); + + /*Handle something*/ + LL_ADC_OverRunCallback(Instance); + } + + if ((__LL_ADC_GET_IT_JEOS(Instance)) && (__LL_ADC_GET_FLAG_JEOS(Instance))) { + __LL_ADC_CLEAR_FLAG_JEOS(Instance); + + /*Handle something*/ + LL_ADC_JeosCallback(Instance); + } + + if ((__LL_ADC_GET_IT_JEOC(Instance)) && (__LL_ADC_GET_FLAG_JEOC(Instance))) { + __LL_ADC_CLEAR_FLAG_JEOC(Instance); + + /*Handle something*/ + LL_ADC_JeocCallback(Instance); + } + + if ((__LL_ADC_GET_IT_EOS(Instance)) && (__LL_ADC_GET_FLAG_EOS(Instance))) { + __LL_ADC_CLEAR_FLAG_EOS(Instance); + + /*Handle something*/ + LL_ADC_EosCallback(Instance); + } + + if ((__LL_ADC_GET_IT_EOC(Instance)) && (__LL_ADC_GET_FLAG_EOC(Instance))) { + __LL_ADC_CLEAR_FLAG_EOC(Instance); + + /*Handle something*/ + LL_ADC_EocCallback(Instance); + } + +} + +/** + * @brief This function handles ADC Sample interrupts requests. + * @param Instance ADC instance + * @param Channel 0~11 + * @return None + */ +void LL_ADC_SAMP_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel) +{ + if ((__LL_ADC_GET_IT_DONE(Instance, Channel)) && (__LL_ADC_GET_FLAG_DONE(Instance, Channel))) { + __LL_ADC_CLEAR_FLAG_DONE(Instance, Channel); + + /*Handle something*/ + LL_ADC_SampCallback(Instance, Channel); + } +} + +/** + * @brief This function handles ADC Dma Half interrupts requests. + * @param Instance ADC instance + * @param Channel 0~11 + * @return None + */ +void LL_ADC_HALF_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel) +{ + if ((__LL_ADC_GET_IT_HALF(Instance, Channel)) && (__LL_ADC_GET_FLAG_HALF(Instance, Channel))) { + __LL_ADC_CLEAR_FLAG_HALF(Instance, Channel); + + /*Handle something*/ + LL_ADC_HalfCallback(Instance, Channel); + } +} + +/** + * @brief This function handles ADC Dma Full interrupts requests. + * @param Instance ADC instance + * @param Channel 0~11 + * @return None + */ +void LL_ADC_FULL_IRQHandler(ADC_TypeDef *Instance, uint8_t Channel) +{ + if ((__LL_ADC_GET_IT_FULL(Instance, Channel)) && (__LL_ADC_GET_FLAG_FULL(Instance, Channel))) { + __LL_ADC_CLEAR_FLAG_FULL(Instance, Channel); + + /*Handle something*/ + LL_ADC_FullCallback(Instance, Channel); + } +} +/** + * @} + */ + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ +/** @addtogroup ADC_LL_Private_Functions + * @{ + */ + +/** + * @brief Read ADC single-ended self-calibration data + * @note No external calls + * @return None + */ +static void LL_ADC_ReadCoef(void) +{ + Calib_read_data[0] = SYSCTRL->SINGLE; + Calib_read_data[1] = SYSCTRL->DIFFER; + Calib_read_data[2] = SYSCTRL->SINGLE_BUFF; + + /* Determinate whether the SoC has been calibrated. If it has not been calibrated, + the standard register is written into the user configuration data; + if the calibration criterion reads the calibration data*/ + if (memcmp(&Calib_check_data, &Calib_read_data, sizeof(Calib_read_data)) == 0) { + /* CALB_SE*/ + pCoef.SingleGain = 8192; + /* CALA_SE*/ + pCoef.SingleOffset = 0; + /* CALB_DF*/ + pCoef.DiffGain = 8192; + /* CALA_DF*/ + pCoef.DiffOffset = 0; + /* CALB_WB*/ + pCoef.SingleBuffGain = 8192; + /* CALA_WB*/ + pCoef.SingleBuffOffset = 0; + } else { + /* CALB_SE*/ + pCoef.SingleGain = (uint16_t)Calib_read_data[0]; + /* CALA_SE*/ + pCoef.SingleOffset = (int16_t)(Calib_read_data[0] >> 16); + /* CALB_DF*/ + pCoef.DiffGain = (uint16_t)Calib_read_data[1]; + /* CALA_DF*/ + pCoef.DiffOffset = (int16_t)(Calib_read_data[1] >> 16); + /* CALB_WB*/ + pCoef.SingleBuffGain = (uint16_t)Calib_read_data[2]; + /* CALA_WB*/ + pCoef.SingleBuffOffset = (int16_t)(Calib_read_data[2] >> 16); + } + +} + +/** + * @brief The calibration coefficient varies with the change of oversampling + * @note No external calls + * @param Instance ADC instance + * @param offset ADC offset + * @return None + */ +static void LL_ADC_OverSamp_Mode(ADC_TypeDef *Instance, int16_t offset) +{ + int8_t temp_mode = 0; + + temp_mode = (__LL_ADC_GetOverSamplingShift(Instance) >> ADC_CR1_OVSS_Pos) - \ + (__LL_ADC_GetOverSamplingRatio(Instance) >> ADC_CR1_OVSR_Pos); + + if ((temp_mode - 1) >= 0) { + temp_offset = offset >> (temp_mode - 1); + } else { + temp_offset = offset << (abs(temp_mode) + 1); + } +} + +/** + * @} + */ + + +#endif /* LL_ADC_MODULE_ENABLE */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_can.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_can.c new file mode 100644 index 0000000000..9b678f2f3a --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_can.c @@ -0,0 +1,565 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_can.c + * @author MCD Application Team + * @brief CAN LL Module Driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "CAN LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup CAN_LL CAN LL + * @brief CAN LL Module Driver + * @{ + */ + +#ifdef LL_CAN_MODULE_ENABLED + +/* Private define ------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/** @addtogroup CAN_LL_Private_Functions + * @{ + */ +LL_StatusETypeDef LL_CAN_AcceptFilCfg(CAN_TypeDef *Instance, CAN_AcceptFilCfgTypeDef *fil_cfg); +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup CAN_LL_Exported_Functions CAN LL Exported Functions + * @brief CAN LL Exported Functions + * @{ + */ + +/** @defgroup CAN_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and de-initialization functions + * @{ + */ + +/** + * @brief CAN LL Init + * @param Instance Specifies CAN peripheral + * @param user_cfg user config pointer + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_CAN_Init(CAN_TypeDef *Instance, CAN_UserCfgTypeDef *user_cfg) +{ + assert_param(Instance); + assert_param(user_cfg); + + /* Init the low level hardware eg. Clock, NVIC */ + LL_CAN_MspInit(Instance); + + /* Set reset status to config some register which can config in reset status only */ + __LL_CAN_Reset_Set(Instance); + + //Baudrate config + assert_param(user_cfg->baudrate); + __LL_CAN_SS_Prescaler_Set(Instance, (LL_SYSCTRL_AHBClkGet() / 10 / user_cfg->baudrate - 1)); + + //Bit timing config + __LL_CAN_SS_BitTimingSeg1_Set(Instance, user_cfg->bit_timing_seg1); + __LL_CAN_SS_BitTimingSeg2_Set(Instance, user_cfg->bit_timing_seg2); + __LL_CAN_SS_SyncJumpWidth_Set(Instance, user_cfg->bit_timing_sjw); + + //Acceptance filter config + for (uint8_t i = 0; i < user_cfg->accept_fil_cfg_num; i++) { + LL_CAN_AcceptFilCfg(Instance, (CAN_AcceptFilCfgTypeDef *)&user_cfg->accept_fil_cfg_ptr[i]); + } + + /*Clear reset status to config other register */ + __LL_CAN_Reset_Clr(Instance); + + //RX buffer almost full and error warning limit set + __LL_CAN_RxBufAlmostFullLimit_Set(Instance, user_cfg->rx_almost_full_limit); + __LL_CAN_ErrWarnLimit_Set(Instance, user_cfg->err_limit); + + return LL_OK; +} + +/** + * @brief CAN LL DeInit + * @param Instance Specifies CAN peripheral + * @return Status of the DeInitialization + */ +LL_StatusETypeDef LL_CAN_DeInit(CAN_TypeDef *Instance) +{ + /* DeInit the low level hardware eg. Clock, NVIC */ + LL_CAN_MspDeInit(Instance); + + return LL_OK; +} + +/** + * @brief Initializes the CAN MSP. + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_MspInit(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the CAN MSP + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_MspDeInit(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + +/** @defgroup CAN_LL_Exported_Functions_Group2 Send data functions + * @brief Send data functions + * @{ + */ + +/** + * @brief CAN LL send standard primary transmit buffer + * @param Instance Specifies CAN peripheral + * @param buf_fmt buffer format pointer + * @param buf buffer pointer + * @return success send length in byte + */ +uint32_t LL_CAN_SendStandard_PTB(CAN_TypeDef *Instance, CAN_TxBufFormatTypeDef *buf_fmt, uint32_t *buf) +{ + uint32_t i, j; + + assert_param(Instance); + assert_param(buf_fmt); + assert_param(buf); + + //TX buffer select PTB + __LL_CAN_TxBufSel_PTB(Instance); + + //Write buffer format data to TX buffer + Instance->TXBUF[0] = *((uint32_t *)buf_fmt); + Instance->TXBUF[1] = *(((uint32_t *)buf_fmt) + 1); + + //Write data to TX buffer + for (i = 0, j = 0; i < buf_fmt->data_len_code; i += 4, j++) { + Instance->TXBUF[2 + j] = *buf++; + } + + //TX primary enable + __LL_CAN_TxPriEn_Set(Instance); + + //Wait TX complete + while (__LL_CAN_TxPriEn_Get(Instance)); + + return buf_fmt->data_len_code; +} + +/** + * @brief CAN LL send standard secondary transmit buffer + * @param Instance Specifies CAN peripheral + * @param buf_fmt buffer format pointer + * @param buf buffer pointer + * @return success send length in byte + */ +uint32_t LL_CAN_SendStandard_STB(CAN_TypeDef *Instance, CAN_TxBufFormatTypeDef *buf_fmt, uint32_t *buf) +{ + uint32_t i, j; + + assert_param(Instance); + assert_param(buf_fmt); + assert_param(buf); + + //TX buffer select STB + __LL_CAN_TxBufSel_STB(Instance); + + //Write buffer format data to TX buffer + Instance->TXBUF[0] = *((uint32_t *)buf_fmt); + Instance->TXBUF[1] = *(((uint32_t *)buf_fmt) + 1); + + //Write data to TX buffer + for (i = 0, j = 0; i < buf_fmt->data_len_code; i += 4, j++) { + Instance->TXBUF[2 + j] = *buf++; + } + + //TX buffer Secondary next + __LL_CAN_TxSecNext_Set(Instance); + + //TX secondary send one start + __LL_CAN_TxSecOne_Set(Instance); + + //Wait TX complete + while (__LL_CAN_TxSecOne_Get(Instance)); + + return buf_fmt->data_len_code; +} + +/** + * @brief CAN LL send a multi-package standard secondary transmit buffer + * @param Instance Specifies CAN peripheral + * @param buf_fmt buffer format pointer + * @param buf buffer pointer + * @param send_cnt send packets count + * @return success send length in byte + */ +uint32_t LL_CAN_SendStandard_STB_Multi(CAN_TypeDef *Instance, CAN_TxBufFormatTypeDef *buf_fmt, + uint32_t *buf, uint32_t send_cnt) +{ + uint32_t i, j, cnt; + + assert_param(Instance); + assert_param(buf_fmt); + assert_param(buf); + + //TX buffer select STB + __LL_CAN_TxBufSel_STB(Instance); + + for (cnt = 0; cnt < send_cnt; cnt++) { + //Write buffer format data to TX buffer + Instance->TXBUF[0] = *((uint32_t *)buf_fmt); + Instance->TXBUF[1] = *(((uint32_t *)buf_fmt) + 1); + + //Write data to TX buffer + for (i = 0, j = 0; i < buf_fmt->data_len_code; i += 4, j++) { + Instance->TXBUF[2 + j] = *buf++; + } + + //TX buffer Secondary next + __LL_CAN_TxSecNext_Set(Instance); + + //TX buffer Secondary full and send + if (__LL_CAN_IsTxSecBufFull(Instance)) { + //TX secondary send all start + __LL_CAN_TxSecAll_Set(Instance); + + //Wait TX complete + while (__LL_CAN_TxSecAll_Get(Instance)); + } + } + + //TX secondary send all start + __LL_CAN_TxSecAll_Set(Instance); + + //Wait TX complete + while (__LL_CAN_TxSecAll_Get(Instance)); + + return buf_fmt->data_len_code * send_cnt; +} + +/** + * @} + */ + +/** @defgroup CAN_LL_Exported_Functions_Interrupt CAN Interrupt handler and call back + * @brief CAN Interrupt handler and call back + * @{ + */ + +/** + * @brief CAN IRQ Handler + * @param Instance Specifies CAN peripheral + * @note All interrupt pending will be reset immediately after a read access + * @return None + */ +void LL_CAN_IRQHandler(CAN_TypeDef *Instance) +{ + uint8_t txrx_int_sta = __LL_CAN_IntSta_Get(Instance); + uint8_t err_int_sta = __LL_CAN_ErrIntSta_Get(Instance); + + if (txrx_int_sta & CAN_RX_INT_STA_Msk) { + LL_CAN_RxCallback(Instance); + } + + if (txrx_int_sta & CAN_RX_BUF_OVER_INT_STA_Msk) { + LL_CAN_RxOverCallback(Instance); + } + + if (txrx_int_sta & CAN_RX_BUF_FULL_INT_STA_Msk) { + LL_CAN_RxFullCallback(Instance); + } + + if (txrx_int_sta & CAN_RX_BUF_ALMOST_FULL_INT_STA_Msk) { + LL_CAN_RxAlmostFullCallback(Instance); + } + + if (txrx_int_sta & CAN_TX_PRI_INT_STA_Msk) { + LL_CAN_TxPriCallback(Instance); + } + + if (txrx_int_sta & CAN_TX_SEC_INT_STA_Msk) { + LL_CAN_TxSecCallback(Instance); + } + + if (txrx_int_sta & CAN_ERR_INT_STA_Msk) { + LL_CAN_ErrCallback(Instance); + } + + if (txrx_int_sta & CAN_ABORT_INT_STA_Msk) { + LL_CAN_AbortCallback(Instance); + } + + + if (err_int_sta & CAN_ERR_PASS_INT_STA_Msk) { + LL_CAN_ErrPassiveCallback(Instance); + } + + if (err_int_sta & CAN_ARB_LOST_INT_STA_Msk) { + LL_CAN_ArbLostCallback(Instance); + } + + if (err_int_sta & CAN_BUS_ERR_INT_STA_Msk) { + LL_CAN_BusErrCallback(Instance); + } +} + + +/** + * @brief CAN RX interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_RxCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_RxCallback could be implemented in the user file + */ +} + +/** + * @brief CAN RX over interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_RxOverCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_RxOverCallback could be implemented in the user file + */ +} + +/** + * @brief CAN RX full interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_RxFullCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_RxFullCallback could be implemented in the user file + */ +} + +/** + * @brief CAN RX almost full interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_RxAlmostFullCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_RxAlmostFullCallback could be implemented in the user file + */ +} + +/** + * @brief CAN TX primary interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_TxPriCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_TxPriCallback could be implemented in the user file + */ +} + +/** + * @brief CAN TX secondary interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_TxSecCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_TxSecCallback could be implemented in the user file + */ +} + +/** + * @brief CAN error interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_ErrCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_ErrCallback could be implemented in the user file + */ +} + +/** + * @brief CAN abort interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_AbortCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_AbortCallback could be implemented in the user file + */ +} + +/** + * @brief CAN error passive interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_ErrPassiveCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_ErrPassiveCallback could be implemented in the user file + */ +} + +/** + * @brief CAN arbitration lost interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_ArbLostCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_ArbLostCallback could be implemented in the user file + */ +} + +/** + * @brief CAN bus error interrupt callback + * @param Instance Specifies CAN peripheral + * @return None + */ +__WEAK void LL_CAN_BusErrCallback(CAN_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CAN_BusErrCallback could be implemented in the user file + */ +} + + +/** + * @} + */ + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ +/** @defgroup CAN_LL_Private_Functions CAN LL Private Functions + * @brief CAN LL Private Functions + * @{ + */ + +/** + * @brief CAN LL acceptance filter config + * @param Instance Specifies CAN peripheral + * @param fil_cfg filter config pointer + * @return Config result + */ +LL_StatusETypeDef LL_CAN_AcceptFilCfg(CAN_TypeDef *Instance, CAN_AcceptFilCfgTypeDef *fil_cfg) +{ + assert_param(Instance); + assert_param(fil_cfg); + + //Check in reset status or not + if (!__LL_CAN_ResetSta_Get(Instance)) { + LOG_E("Acceptance filter register can config in reset status only!\n"); + return LL_ERROR; + } + + //CAN acceptance filter Code and Mask config + __LL_CAN_AcceptFilAddr_Set(Instance, fil_cfg->slot); + __LL_CAN_AcceptFilContentSel_Code(Instance); + __LL_CAN_AcceptFilCodeOrMaskVal_Set(Instance, fil_cfg->code_val); + __LL_CAN_AcceptFilContentSel_Mask(Instance); + __LL_CAN_AcceptFilCodeOrMaskVal_Set(Instance, fil_cfg->mask_val); + + //CAN acceptance filter enable + __LL_CAN_AcceptFil_En(Instance, ((uint8_t)fil_cfg->slot)); + + return LL_OK; +} + + +/** + * @} + */ + +#endif /* LL_CAN_MODULE_ENABLED */ + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_cmp.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_cmp.c new file mode 100644 index 0000000000..4a31133b57 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_cmp.c @@ -0,0 +1,396 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_cmp.c + * @author MCD Application Team + * @brief Source file for CMP Moudle + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "CMP LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup CMP_LL CMP LL + * @brief CMP LL module driver. + * @{ + */ + +#ifdef LL_CMP_MODULE_ENABLED + +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup CMP_LL_Exported_Functions CMP LL Exported Functions + * @brief CMP LL Exported Functions + * @{ + */ + +/** @defgroup CMP_LL_Exported_Functions_Group1 Initialization and De-Initialization functions + * @brief Initialization and De-Initialization functions +@verbatim + ============================================================================== + ##### Initialization and De-Initialization functions ##### + ============================================================================== + [..] + This section provides functions allowing to: + (+) Initialize the CMP peripheral. + (+) De-initialize the CMP peripheral. +@endverbatim + * @{ + */ + +/** + * @brief Initialize the CMP peripheral + * @param Instance CMP peripheral instance + * @return status of the initialization + */ +LL_StatusETypeDef LL_CMP_Init(CMP_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_CMP_ALL_INSTANCE(Instance)); + + /* Init the low level hardware */ + LL_CMP_MspInit(Instance); + + /* Clear interrupt pending flags */ + __LL_CMP_PENDING_FLAG_CLEAR(Instance, CMP_FLAG_ALLIF); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Deinitialize the CMP peripheral + * @param Instance CMP peripheral instance + * @return status of the initialization + */ +LL_StatusETypeDef LL_CMP_DeInit(CMP_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_CMP_ALL_INSTANCE(Instance)); + + for (uint8_t chnnum = 0; chnnum < CMP_CHN_NB; ++chnnum) { + /* Disable CMP channel FALIE/RISIE interrupts */ + __LL_CMP_IT_DISABLE(Instance, chnnum, CMP_IT_FALIE | CMP_IT_RISIE); + + /* Disable CMP channel */ + __LL_CMP_DISABLE(Instance, chnnum); + } + + /* DeInit the low level hardware */ + LL_CMP_MspDeInit(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Initializes the CMP MSP. + * @param Instance CMP peripheral + * @return None + */ +__WEAK void LL_CMP_MspInit(CMP_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_CMP_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the CMP MSP + * @param Instance CMP peripheral + * @return None + */ +__WEAK void LL_CMP_MspDeInit(CMP_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CMP_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + + +/** @defgroup CMP_LL_Exported_Functions_Group2 CMP Peripheral Control functions + * @brief CMP Peripheral Control functions +@verbatim + =============================================================================== + ##### Peripheral Control functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Configure CMP channels. + +@endverbatim + * @{ + */ + +/** + * @brief Configures the selected CMP channel. + * @param Instance CMP peripheral + * @param Channel The selected CMP channel. + * This parameter can be one of the following values: + * @arg CMP_CHANNEL_0: CMP Channel0 selected + * @arg CMP_CHANNEL_1: CMP Channel1 selected + * @arg CMP_CHANNEL_2: CMP Channel2 selected + * @arg CMP_CHANNEL_3: CMP Channel3 selected + * @param sConfig CMP configuration structure. + * @return LL Status + */ +LL_StatusETypeDef LL_CMP_ChannelConfig(CMP_TypeDef *Instance, uint32_t Channel, CMP_ChannelConfTypeDef *sConfig) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the parameters */ + assert_param(IS_CMP_ALL_INSTANCE(Instance)); + assert_param(IS_CMP_CHANNEL(Channel)); + assert_param(IS_CMP_NUMBER(chnnum)); + assert_param(sConfig != NULL); + assert_param(IS_CMP_INPUT_MINUS(sConfig->InputMinus)); + assert_param(IS_CMP_HYSTERESIS(sConfig->Hysteresis)); + assert_param(IS_CMP_BLANKING_SOURCE(Channel, sConfig->BlankingSource)); + assert_param(IS_CMP_OUTPUT_DEBOUNCE(sConfig->OutputDebounce)); + assert_param(IS_CMP_OUTPUT_DEBOUNCE_VAL(sConfig->OutputDebounceValue)); + assert_param(IS_CMP_OUTPUT_POLARITY(sConfig->OutputPolarity)); + assert_param(IS_CMP_TRIGGER_IT(sConfig->TriggerInterrupt)); + + /* Set Debounce Vaule */ + if (sConfig->OutputDebounceValue == CMP_OUTPUT_DEBOUNCE_ENABLE) { + __LL_CMP_DEBOUNCE_VALUE_SET(Instance, chnnum, sConfig->OutputDebounceValue); + } + + /* Reset and Calculate CR register value depending on sConfig */ + MODIFY_REG(Instance->CR[chnnum], + (CMP_CR_OPOL_Msk + | CMP_CR_ODEB_Msk + | CMP_CR_BLANKING_Msk + | CMP_CR_INM_Msk + | CMP_CR_HYST_Msk + | CMP_CR_FALIE_Msk + | CMP_CR_RISIE_Msk + ), + (sConfig->OutputPolarity + | sConfig->OutputDebounce + | sConfig->BlankingSource + | sConfig->InputMinus + | sConfig->Hysteresis + | sConfig->TriggerInterrupt)); + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup CMP_LL_Exported_Functions_Group3 CMP IO operation functions + * @brief CMP IO operation functions + * +@verbatim + ============================================================================== + ##### IO operation functions ##### + ============================================================================== + [..] This section provides functions allowing to: + (+) Start/Stop CMP. + +@endverbatim + * @{ + */ + +/** + * @brief Enables CMP Channel conversion + * @param Instance CMP peripheral instance + * @param Channel The selected CMP channel. + * This parameter can be one of the following values: + * @arg CMP_CHANNEL_0: CMP Channel0 selected + * @arg CMP_CHANNEL_1: CMP Channel1 selected + * @arg CMP_CHANNEL_2: CMP Channel2 selected + * @arg CMP_CHANNEL_3: CMP Channel3 selected + * @return LL Status + */ +LL_StatusETypeDef LL_CMP_Start(CMP_TypeDef *Instance, uint32_t Channel) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the parameters */ + assert_param(IS_CMP_ALL_INSTANCE(Instance)); + assert_param(IS_CMP_CHANNEL(Channel)); + assert_param(IS_CMP_NUMBER(chnnum)); + + /* Enable the CMP channel */ + __LL_CMP_ENABLE(Instance, chnnum); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Disable CMP Channel conversion + * @param Instance CMP peripheral instance + * @param Channel The selected CMP channel. + * This parameter can be one of the following values: + * @arg CMP_CHANNEL_0: CMP Channel0 selected + * @arg CMP_CHANNEL_1: CMP Channel1 selected + * @arg CMP_CHANNEL_2: CMP Channel2 selected + * @arg CMP_CHANNEL_3: CMP Channel3 selected + * @return LL Status + */ +LL_StatusETypeDef LL_CMP_Stop(CMP_TypeDef *Instance, uint32_t Channel) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the CMP parameters */ + assert_param(IS_CMP_ALL_INSTANCE(Instance)); + assert_param(IS_CMP_CHANNEL(Channel)); + assert_param(IS_CMP_NUMBER(chnnum)); + + /* Enable CMP Channel */ + __LL_CMP_DISABLE(Instance, chnnum); + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup CMP_LL_Exported_Functions_Interrupt CMP Interrupt management + * @brief CMP Interrupt management +@verbatim + =============================================================================== + ##### Initerrupt management ##### + =============================================================================== + [..] + This section provides CMP interrupt handler and callback functions. + +@endverbatim + * @{ + */ + +/** + * @brief This function handles CMP interrupts requests. + * @param Instance CMP peripheral + * @return None + */ +void LL_CMP_IRQHandler(CMP_TypeDef *Instance) +{ + uint32_t irqtemp = READ_REG(Instance->SR); + + /* Check the CMP parameters */ + assert_param(IS_CMP_ALL_INSTANCE(Instance)); + + for (uint8_t chnnum = 0; chnnum < CMP_CHN_NB; ++chnnum) { + if ((__LL_CMP_IT_CHECK_SOURCE(Instance, chnnum, CMP_IT_FALIE) != RESET) && + ((irqtemp & (CMP_SR_FALIF_0 << chnnum)) != RESET)) { + /* Chear the CMP_CHx FALIF pending flag */ + __LL_CMP_PENDING_FLAG_CLEAR(Instance, (CMP_SR_FALIF_0 << chnnum)); + + /* CMP falling edge trigger user callback */ + LL_CMP_FailingEdgeTrigCallback(Instance, (0x1UL << chnnum)); + } + + if ((__LL_CMP_IT_CHECK_SOURCE(Instance, chnnum, CMP_IT_RISIE) != RESET) && + ((irqtemp & (CMP_SR_RISIF_0 << chnnum)) != RESET)) { + /* Chear the CMP_CHx RISIF pending flag */ + __LL_CMP_PENDING_FLAG_CLEAR(Instance, (CMP_SR_RISIF_0 << chnnum)); + + /* CMP rising edge trigger user callback */ + LL_CMP_RisingEdgeTrigCallback(Instance, (0x1UL << chnnum)); + } + } +} + +/** + * @brief CMP_CHx failing edge interrupt callback function + * @param Instance CMP peripheral + * @param Channel The handling CMP channel + * @return None + */ +__WEAK void LL_CMP_FailingEdgeTrigCallback(CMP_TypeDef *Instance, uint32_t Channel) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + LL_UNUSED(Channel); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CMP_FailingEdgeTrigCallback could be implemented in the user file + */ +} + +/** + * @brief CMP_CHx rising edge interrupt callback function + * @param Instance CMP peripheral + * @param Channel The handling CMP channel + * @return None + */ +__WEAK void LL_CMP_RisingEdgeTrigCallback(CMP_TypeDef *Instance, uint32_t Channel) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + LL_UNUSED(Channel); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_CMP_RisingEdgeTrigCallback could be implemented in the user file + */ +} + +/** + * @} + */ + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ + +#endif /* LL_CMP_MODULE_ENABLED */ + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_cortex.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_cortex.c new file mode 100644 index 0000000000..8bf5ec6027 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_cortex.c @@ -0,0 +1,448 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_cortex.c + * @author MCD Application Team + * @brief CORTEX LL module driver. + * This file provides firmware functions to manage the following + * functionalities of the CORTEX: + * + Initialization and de-initialization functions + * + Peripheral Control functions + * + @verbatim + ============================================================================== + ##### How to use this driver ##### + ============================================================================== + + [..] + *** How to configure Interrupts using CORTEX LL driver *** + =========================================================== + [..] + This section provides functions allowing to configure the NVIC interrupts (IRQ). + The Cortex-M3 exceptions are managed by CMSIS functions. + + (#) Configure the NVIC Priority Grouping using LL_NVIC_SetPriorityGrouping() + function according to the following table. + (#) Configure the priority of the selected IRQ Channels using LL_NVIC_SetPriority(). + (#) Enable the selected IRQ Channels using LL_NVIC_EnableIRQ(). + (#) please refer to programming manual for details in how to configure priority. + + -@- When the NVIC_PRIORITYGROUP_0 is selected, IRQ preemption is no more possible. + The pending IRQ priority will be managed only by the sub priority. + + -@- IRQ priority order (sorted by highest to lowest priority): + (+@) Lowest preemption priority + (+@) Lowest sub priority + (+@) Lowest hardware priority (IRQ number) + + [..] + *** How to configure Systick using CORTEX LL driver *** + ======================================================== + [..] + Setup SysTick Timer for time base. + + (+) The LL_SYSTICK_Config()function calls the SysTick_Config() function which + is a CMSIS function that: + (++) Configures the SysTick Reload register with value passed as function parameter. + (++) Configures the SysTick IRQ priority to the lowest value 0x07. + (++) Resets the SysTick Counter register. + (++) Configures the SysTick Counter clock source to be Core Clock Source (HCLK). + (++) Enables the SysTick Interrupt. + (++) Starts the SysTick Counter. + + (+) You can change the SysTick Clock source to be HCLK_Div8 by calling the function + LL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK_DIV8) just after the + LL_SYSTICK_Config() function call. The LL_SYSTICK_CLKSourceConfig() function is defined below. + + (+) You can change the SysTick IRQ priority by calling the + LL_NVIC_SetPriority(SysTick_IRQn,...) function just after the LL_SYSTICK_Config() function + call. The LL_NVIC_SetPriority() call the NVIC_SetPriority() function which is a CMSIS function. + + (+) To adjust the SysTick time base, use the following formula: + + Reload Value = SysTick Counter Clock (Hz) x Desired Time base (s) + (++) Reload Value is the parameter to be passed for LL_SYSTICK_Config() function + (++) Reload Value should not exceed 0xFFFFFF + + @endverbatim + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "Cortex LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** + * @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup CORTEX_LL CORTEX LL + * @brief CORTEX LL module driver + * @{ + */ + +#ifdef LL_CORTEX_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup CORTEX_LL_Exported_Functions CORTEX LL Exported Functions + * @brief CORTEX LL Exported Functions + * @{ + */ + +/** @defgroup CORTEX_LL_Exported_Functions_Group1 NVIC Priority Config Functions + * @brief NVIC Priority Config Functions + * @{ + */ + +/** @brief Sets the priority grouping field (preemption priority and subpriority) + * using the required unlock sequence. + * @param PriorityGroup: The priority grouping bits length. + * This parameter can be one of the following values: + * @arg NVIC_PRIORITYGROUP_0: 0 bit for pre-emption priority, + * 3 bits for subpriority + * @arg NVIC_PRIORITYGROUP_1: 1 bit for pre-emption priority, + * 2 bits for subpriority + * @arg NVIC_PRIORITYGROUP_2: 2 bits for pre-emption priority, + * 1 bits for subpriority + * @arg NVIC_PRIORITYGROUP_3: 3 bits for pre-emption priority, + * 0 bit for subpriority + * @note When the NVIC_PriorityGroup_0 is selected, IRQ preemption is no more possible. + * The pending IRQ priority will be managed only by the subpriority. + * @return None + */ +void LL_NVIC_SetPriorityGrouping(uint32_t PriorityGroup) +{ + /* Check the parameters */ + assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup)); + + /* Set the PRIGROUP[10:8] bits according to the PriorityGroup parameter value */ + NVIC_SetPriorityGrouping(PriorityGroup); +} + +/** + * @brief Gets the priority grouping field from the NVIC Interrupt Controller. + * @return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field) + */ +uint32_t LL_NVIC_GetPriorityGrouping(void) +{ + /* Get the PRIGROUP[10:8] field value */ + return NVIC_GetPriorityGrouping(); +} + +/** + * @brief Sets the priority of an interrupt. + * @param IRQn: External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file tae32f53xx.h) + * @param PreemptPriority: The preemption priority for the IRQn channel. + * This parameter can be a value between 0 and 7 + * A lower priority value indicates a higher priority + * @param SubPriority: the subpriority level for the IRQ channel. + * This parameter can be a value between 0 and 7 + * A lower priority value indicates a higher priority. + * @note The table below gives the allowed values of the pre-emption priority and subpriority according + * to the Priority Grouping configuration performed by LL_NVIC_SetPriorityGrouping() function. + * ========================================================================================= + * NVIC_PriorityGroup | PreemptPriority | SubPriority | Description + * ========================================================================================= + * NVIC_PRIORITYGROUP_0 | 0 | 0-7 | 0 bit for pre-emption priority + * | | | 3 bits for subpriority + * ----------------------------------------------------------------------------------------- + * NVIC_PRIORITYGROUP_1 | 0-1 | 0-3 | 1 bit for pre-emption priority + * | | | 2 bits for subpriority + * ----------------------------------------------------------------------------------------- + * NVIC_PRIORITYGROUP_2 | 0-3 | 0-1 | 2 bits for pre-emption priority + * | | | 1 bits for subpriority + * ----------------------------------------------------------------------------------------- + * NVIC_PRIORITYGROUP_3 | 0-7 | 0 | 3 bits for pre-emption priority + * | | | 0 bit for subpriority + * ========================================================================================= + * @return None + */ +void LL_NVIC_SetPriority(IRQn_Type IRQn, uint32_t PreemptPriority, uint32_t SubPriority) +{ + uint32_t prioritygroup = 0x00U; + + /* Check the parameters */ + assert_param(IS_NVIC_SUB_PRIORITY(SubPriority)); + assert_param(IS_NVIC_PREEMPTION_PRIORITY(PreemptPriority)); + + prioritygroup = NVIC_GetPriorityGrouping(); + + NVIC_SetPriority(IRQn, NVIC_EncodePriority(prioritygroup, PreemptPriority, SubPriority)); +} + +/** + * @brief Gets the priority of an interrupt. + * @param IRQn: External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file (tae32f53xx.h)) + * @param PriorityGroup: the priority grouping bits length. + * This parameter can be one of the following values: + * @arg NVIC_PRIORITYGROUP_0: 0 bits for preemption priority + * 3 bits for subpriority + * @arg NVIC_PRIORITYGROUP_1: 1 bits for preemption priority + * 2 bits for subpriority + * @arg NVIC_PRIORITYGROUP_2: 2 bits for preemption priority + * 1 bits for subpriority + * @arg NVIC_PRIORITYGROUP_3: 3 bits for preemption priority + * 0 bits for subpriority + * @param pPreemptPriority: Pointer on the Preemptive priority value (starting from 0). + * @param pSubPriority: Pointer on the Subpriority value (starting from 0). + * @return None + */ +void LL_NVIC_GetPriority(IRQn_Type IRQn, uint32_t PriorityGroup, uint32_t *pPreemptPriority, uint32_t *pSubPriority) +{ + /* Check the parameters */ + assert_param(IS_NVIC_PRIORITY_GROUP(PriorityGroup)); + + /* Get priority for Cortex-M system or device specific interrupts */ + NVIC_DecodePriority(NVIC_GetPriority(IRQn), PriorityGroup, pPreemptPriority, pSubPriority); +} +/** + * @} + */ + + +/** @defgroup CORTEX_LL_Exported_Functions_Group2 NVIC Enable and Pending Config Functions + * @brief NVIC Enable and Pending Config Functions + * @{ + */ + +/** + * @brief Enables a device specific interrupt in the NVIC interrupt controller. + * @note To configure interrupts priority correctly, the NVIC_PriorityGroupConfig() + * function should be called before. + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file (tae32f53xx.h)) + * @return None + */ +void LL_NVIC_EnableIRQ(IRQn_Type IRQn) +{ + /* Check the parameters */ + assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); + + /* Enable interrupt */ + NVIC_EnableIRQ(IRQn); +} + +/** + * @brief Disables a device specific interrupt in the NVIC interrupt controller. + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file (tae32f53xx.h)) + * @return None + */ +void LL_NVIC_DisableIRQ(IRQn_Type IRQn) +{ + /* Check the parameters */ + assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); + + /* Disable interrupt */ + NVIC_DisableIRQ(IRQn); +} + +/** + * @brief Sets Pending bit of an external interrupt. + * @param IRQn External interrupt number + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file (tae32f53xx.h)) + * @return None + */ +void LL_NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + /* Check the parameters */ + assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); + + /* Set interrupt pending */ + NVIC_SetPendingIRQ(IRQn); +} + +/** + * @brief Gets Pending Interrupt (reads the pending register in the NVIC + * and returns the pending bit for the specified interrupt). + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file (tae32f53xx.h)) + * @return pending status + * @retval 0 Interrupt status is not pending. + * @retval 1 Interrupt status is pending. + */ +uint32_t LL_NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + /* Check the parameters */ + assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); + + /* Return 1 if pending else 0 */ + return NVIC_GetPendingIRQ(IRQn); +} + +/** + * @brief Clears the pending bit of an external interrupt. + * @param IRQn External interrupt number. + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file (tae32f53xx.h)) + * @return None + */ +void LL_NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + /* Check the parameters */ + assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); + + /* Clear pending interrupt */ + NVIC_ClearPendingIRQ(IRQn); +} + +/** + * @brief Gets active interrupt ( reads the active register in NVIC and returns the active bit). + * @param IRQn External interrupt number + * This parameter can be an enumerator of IRQn_Type enumeration + * (For the complete TAE32F53xx Devices IRQ Channels list, please refer to the appropriate CMSIS device file (tae32f53xx.h)) + * @return status: - 0 Interrupt status is not pending. + * - 1 Interrupt status is pending. + */ +uint32_t LL_NVIC_GetActive(IRQn_Type IRQn) +{ + /* Check the parameters */ + assert_param(IS_NVIC_DEVICE_IRQ(IRQn)); + + /* Return 1 if active else 0 */ + return NVIC_GetActive(IRQn); +} + +/** + * @brief Initiates a system reset request to reset the MCU. + * @param None + * @return None + */ +void LL_NVIC_SystemReset(void) +{ + /* System Reset */ + NVIC_SystemReset(); +} +/** + * @} + */ + + +/** @defgroup CORTEX_LL_Exported_Functions_Group3 SYSTICK Config Functions + * @brief SYSTICK Config Functions + * @{ + */ + +/** + * @brief Configures the SysTick clock source. + * @param CLKSource: specifies the SysTick clock source. + * This parameter can be one of the following values: + * @arg SYSTICK_CLKSOURCE_HCLK_DIV8: AHB clock divided by 8 selected as SysTick clock source. + * @arg SYSTICK_CLKSOURCE_HCLK: AHB clock selected as SysTick clock source. + * @return None + */ +void LL_SYSTICK_CLKSourceConfig(uint32_t CLKSource) +{ + /* Check the parameters */ + assert_param(IS_SYSTICK_CLK_SOURCE(CLKSource)); + + if (CLKSource == SYSTICK_CLKSOURCE_HCLK) { + SysTick->CTRL |= SYSTICK_CLKSOURCE_HCLK; + } else { + SysTick->CTRL &= ~SYSTICK_CLKSOURCE_HCLK; + } +} + +/** + * @brief Initializes the System Timer and its interrupt, and starts the System Tick Timer. + * Counter is in free running mode to generate periodic interrupts. + * @param TicksNumb: Specifies the ticks Number of ticks between two interrupts. + * @retval status: - 0 Function succeeded. + * - 1 Function failed. + */ +uint32_t LL_SYSTICK_Config(uint32_t TicksNumb) +{ + return SysTick_Config(TicksNumb); +} +/** + * @} + */ + + +/** @defgroup CORTEX_LL_Exported_Functions_Interrupt CORTEX Interrupt management + * @brief CORTEX Interrupt management + * +@verbatim + ============================================================================== + ##### Interrupt Management ##### + ============================================================================== + [..] + This section provides CORTEX interrupt handler functions. +@endverbatim + * @{ + */ + +/** + * @brief This function handles SYSTICK interrupts requests. + * @param None + * @return None + */ +void LL_SYSTICK_IRQHandler(void) +{ + LL_SYSTICK_Callback(); +} + +/** + * @brief SYSTICK callback. + * @param None + * @retval None + */ +__WEAK void LL_SYSTICK_Callback(void) +{ + /* NOTE : This function Should not be modified, when the callback is needed, + the LL_SYSTICK_Callback could be implemented in the user file + */ +} +/** + * @} + */ + + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_CORTEX_MODULE_ENABLE */ + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dac.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dac.c new file mode 100644 index 0000000000..06af9b714e --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dac.c @@ -0,0 +1,601 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dac.c + * @author MCD Application Team + * @brief Source file for DAC Module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "DAC LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup DAC_LL DAC LL + * @brief DAC LL module driver + * @{ + */ + +#ifdef LL_DAC_MODULE_ENABLED + +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup DAC_LL_Exported_Functions DAC LL Exported Functions + * @brief DAC LL Exported Functions + * @{ + */ + +/** @defgroup DAC_LL_Exported_Functions_Group1 Initialization and De-Initialization functions + * @brief Initialization and De-Initialization functions + +@verbatim + ============================================================================== + ##### Initialization and De-Initialization functions ##### + ============================================================================== + [..] + This section provides functions allowing to: + (+) Initialize the DAC peripheral. + (+) De-initialize the DAC peripheral. + +@endverbatim + * @{ + */ + +/** + * @brief Initialize the DAC peripheral + * @param Instance DAC peripheral instance + * @return status of the initialization + */ +LL_StatusETypeDef LL_DAC_Init(DAC_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + + /* Init the low level hardware */ + LL_DAC_MspInit(Instance); + + /* Clear interrupt pending flags */ + __LL_DAC_PENDING_FLAG_CLEAR(Instance, DAC_FLAG_ALLIF); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Deinitialize the DAC peripheral + * @param Instance DAC peripheral instance + * @return status of the initialization + */ +LL_StatusETypeDef LL_DAC_DeInit(DAC_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + + for (uint8_t chnnum = 0; chnnum < DAC_CHN_NB; ++chnnum) { + /* Disable DAC Channel wave */ + CLEAR_BIT(Instance->CR[chnnum], DAC_CR_TGE_Msk | DAC_CR_STE_Msk); + + /* Disable DONE/DONEB interrupts */ + __LL_DAC_IT_DISABLE(Instance, chnnum, DAC_IT_DIE | DAC_IT_DBIE); + + /* Disable DAC Channel Output */ + __LL_DAC_OUTPUT_DISABLE(Instance, chnnum); + + /* Disable DAC Channel */ + __LL_DAC_DISABLE(Instance, chnnum); + } + + /* DeInit the low level hardware */ + LL_DAC_MspDeInit(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Initializes the DAC MSP. + * @param Instance DAC peripheral + * @return None + */ +__WEAK void LL_DAC_MspInit(DAC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_DAC_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the DAC MSP + * @param Instance DAC peripheral + * @return None + */ +__WEAK void LL_DAC_MspDeInit(DAC_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DAC_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + + +/** @defgroup DAC_LL_Exported_Functions_Group2 DAC Peripheral Control functions + * @brief DAC Peripheral Control functions +@verbatim + =============================================================================== + ##### Peripheral Control functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Configure channels. + (+) Sawtooth/Tranigle wave generate configure + +@endverbatim + * @{ + */ + +/** + * @brief Configures the selected DAC channel. + * @param Instance DAC peripheral + * @param Channel The selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @param sConfig DAC configuration structure. + * @return LL Status + */ +LL_StatusETypeDef LL_DAC_ChannelConfig(DAC_TypeDef *Instance, uint32_t Channel, DAC_ChannelConfTypeDef *sConfig) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNEL(Channel)); + assert_param(IS_DAC_NUMBER(chnnum)); + assert_param(sConfig != NULL); + assert_param(IS_DAC_CHANNEL_OUTPUT_SEL(sConfig->Output)); + assert_param(IS_DAC_CHANNEL_DONE_IT_PENDING_CFG(sConfig->DoneIntPending)); + assert_param(IS_DAC_CHANNEL_DONEB_IT_PENDING_CFG(sConfig->DoneBIntPending)); + + /* Reset and Calculate CR register value depending on sConfig */ + MODIFY_REG(Instance->CR[chnnum], + (DAC_CR_PEN_Msk | DAC_CR_OEN_Msk + | DAC_CR_TGE_Msk | DAC_CR_STE_Msk + | DAC_CR_DIE_Msk | DAC_CR_DBIE_Msk), + (sConfig->Output + | sConfig->DoneIntPending + | sConfig->DoneBIntPending)); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Enable the selected DAC channel sawtooth wave generation. + * @param Instance DAC peripheral + * @param Channel The selected DAC channel. + * @param sConfig DAC sawtooth configuration structure. + * @return LL Status + */ +LL_StatusETypeDef LL_DAC_SawtoothWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_SawtoothConfTypeDef *sConfig) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNEL(Channel)); + assert_param(IS_DAC_NUMBER(chnnum)); + assert_param(sConfig != NULL); + assert_param(IS_DAC_SAWTOOTH_RESET_DATA(sConfig->ResetData)); + assert_param(IS_DAC_SAWTOOTH_STEP_DATA(sConfig->StepData)); + assert_param(IS_DAC_SAWTOOTH_POLARITY(sConfig->Polarity)); + assert_param(IS_DAC_SAWTOOTH_RESET_TRIGGER(sConfig->ResetTrigger)); + assert_param(IS_DAC_SAWTOOTH_STEP_TRIGGER(sConfig->StepTrigger)); + assert_param(sConfig->StepTrigger != sConfig->ResetTrigger); + + /* Configure the sawtooth wave */ + MODIFY_REG(Instance->CR[chnnum], + (DAC_CR_TGE_Msk + | DAC_CR_STE_Msk + | DAC_CR_STDIR_Msk + | DAC_CR_STINCTRIG_Msk + | DAC_CR_STRSTTRIG_Msk), + (sConfig->Polarity + | (sConfig->StepTrigger << DAC_CR_STINCTRIG_Pos) + | (sConfig->ResetTrigger << DAC_CR_STRSTTRIG_Pos))); + + /* Configure the sawtooth wave generation data parameters */ + WRITE_REG(Instance->SIDR[chnnum], sConfig->StepData); + WRITE_REG(Instance->SRDR[chnnum], sConfig->ResetData << 4); + + /* Enable sawtooth wave */ + SET_BIT(Instance->CR[chnnum], DAC_CR_STE); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Enable the selected DAC channel triangle wave generation. + * @param Instance DAC peripheral + * @param Channel The selected DAC channel. + * @param sConfig DAC triangle configuration structure. + * @return LL Status + */ +LL_StatusETypeDef LL_DAC_TriangleWaveGenerate(DAC_TypeDef *Instance, uint32_t Channel, DAC_TriangleConfTypeDef *sConfig) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNEL(Channel)); + assert_param(IS_DAC_NUMBER(chnnum)); + assert_param(sConfig != NULL); + assert_param(IS_DAC_TRIANGLE_INITIALDIRECTION(sConfig->InitialDirection)); + assert_param(IS_DAC_TRIANGLE_AMPLITUDE(sConfig->Amplitude)); + assert_param(IS_DAC_TRIANGLE_STEP_TRIGGER(sConfig->StepTrigger)); + + /* Configure the triangle wave */ + MODIFY_REG(Instance->CR[chnnum], + (DAC_CR_TGE_Msk + | DAC_CR_STE_Msk + | DAC_CR_TGDIR_Msk + | DAC_CR_TGAMP_Msk + | DAC_CR_TGTRIG_Msk), + (sConfig->InitialDirection + | sConfig->Amplitude + | (sConfig->StepTrigger << DAC_CR_TGTRIG_Pos))); + + /* Enable triangle wave */ + SET_BIT(Instance->CR[chnnum], DAC_CR_TGE); + + /* Return function status */ + return LL_OK; +} +/** + * @} + */ + + +/** @defgroup DAC_LL_Exported_Functions_Group3 DAC IO operation functions + * @brief DAC IO operation functions + * +@verbatim + ============================================================================== + ##### IO operation functions ##### + ============================================================================== + [..] This section provides functions allowing to: + (+) Start/Stop DAC Output. + (+) Simple value conversion. + (+) Singles conversion. + (+) Get result of conversion. + +@endverbatim + * @{ + */ + +/** + * @brief Enables DAC Channel conversion + * @param Instance DAC peripheral instance + * @param Channel The selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @return LL Status + */ +LL_StatusETypeDef LL_DAC_Start(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNEL(Channel)); + assert_param(IS_DAC_NUMBER(chnnum)); + + /* Enable DAC Channel */ + __LL_DAC_ENABLE(Instance, chnnum); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Disable DAC Channel conversion + * @param Instance DAC peripheral instance + * @param Channel The selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @return LL Status + */ +LL_StatusETypeDef LL_DAC_Stop(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNEL(Channel)); + assert_param(IS_DAC_NUMBER(chnnum)); + + /* Enable DAC Channel */ + __LL_DAC_DISABLE(Instance, chnnum); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Set the specified data value for DAC channel. + * @param Instance DAC peripheral instance + * @param Channel The selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @param Data Data to be loaded. + * This parameter can be a number in range from 0 to DAC full range 4095(0xFFF), + * witch will be converse to 0 - VCC + * @return LL status + */ +LL_StatusETypeDef LL_DAC_SetValue(DAC_TypeDef *Instance, uint32_t Channel, uint16_t Data) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNEL(Channel)); + assert_param(IS_DAC_NUMBER(chnnum)); + + /* Set the data for DAC channel conversion */ + __LL_DAC_SET_VALUE(Instance, chnnum, Data & 0xFFFUL); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Get the specified DAC channel conversion value on runtime. + * @param Instance DAC peripheral instance + * @param Channel The selected DAC channel. + * This parameter can be one of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @return Current conversion value + */ +uint16_t LL_DAC_GetValue(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Get the channel number */ + uint8_t chnnum = POSITION_VAL(Channel); + + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNEL(Channel)); + assert_param(IS_DAC_NUMBER(chnnum)); + + return __LL_DAC_GET_VALUE(Instance, chnnum) & 0xFFFUL; +} + +/** + * @brief Trig sawtooth wave step + * @param Instance DAC peripheral instance + * @param Channel The selected DAC channel[s]. + * This parameter can be any combination of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @return LL status + */ +LL_StatusETypeDef LL_DAC_SawtoothWaveDataStep(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNELS_MASK(Channel)); + + /* Trigger the selected DAC channel software conversion */ + SET_BIT(Instance->SWTR, (Channel << DAC_SWTR_SWTB0_Pos)); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Trig sawtooth wave reset + * @param Instance DAC peripheral instance + * @param Channel The selected DAC channel[s]. + * This parameter can be any combination of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @return LL status + */ +LL_StatusETypeDef LL_DAC_SawtoothWaveDataReset(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNELS_MASK(Channel)); + + /* Trigger the selected DAC channel software conversion */ + SET_BIT(Instance->SWTR, (Channel << DAC_SWTR_SWT0_Pos)); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Trig triangle wave step + * @param Instance DAC peripheral instance + * @param Channel The selected DAC channel[s]. + * This parameter can be any combination of the following values: + * @arg DAC_CHANNEL_0: DAC Channel0 selected + * @arg DAC_CHANNEL_1: DAC Channel1 selected + * @arg DAC_CHANNEL_2: DAC Channel2 selected + * @arg DAC_CHANNEL_3: DAC Channel3 selected + * @return LL status + */ +LL_StatusETypeDef LL_DAC_TriangleWaveStep(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + assert_param(IS_DAC_CHANNELS_MASK(Channel)); + + /* Trigger the selected DAC channel software conversion */ + SET_BIT(Instance->SWTR, (Channel << DAC_SWTR_SWT0_Pos)); + + /* Return function status */ + return LL_OK; +} +/** + * @} + */ + + +/** @defgroup DAC_LL_Exported_Functions_Interrupt DAC Initerrupt management + * @brief DAC Initerrupt management +@verbatim + =============================================================================== + ##### Initerrupt management ##### + =============================================================================== + [..] + This section provides DAC interrupt handler and callback functions. + +@endverbatim + * @{ + */ + +/** + * @brief This function handles DAC interrupts requests. + * @param Instance DAC peripheral + * @return None + */ +void LL_DAC_IRQHandler(DAC_TypeDef *Instance) +{ + uint32_t irqtemp = READ_REG(Instance->ISR); + /* Check the DAC parameters */ + assert_param(IS_DAC_ALL_INSTANCE(Instance)); + + for (uint8_t chnnum = 0; chnnum < DAC_CHN_NB; ++chnnum) { + if ((__LL_DAC_IT_CHECK_SOURCE(Instance, chnnum, DAC_IT_DIE) != RESET) && + ((irqtemp & (DAC_ISR_D0IF << chnnum)) != RESET)) { + /* Chear the DAC_CHx DONE pending flag */ + __LL_DAC_PENDING_FLAG_CLEAR(Instance, (DAC_ISR_D0IF << chnnum)); + + /* DACx DONE interrupt callback function */ + LL_DAC_ConvDoneCallback(Instance, 0x1UL << chnnum); + } + + if ((__LL_DAC_IT_CHECK_SOURCE(Instance, chnnum, DAC_IT_DBIE) != RESET) && + ((irqtemp & (DAC_ISR_DB0IF << chnnum)) != RESET)) { + /* Chear the DAC_CHx DONEB pending flag */ + __LL_DAC_PENDING_FLAG_CLEAR(Instance, (DAC_ISR_DB0IF << chnnum)); + + /* DACx DONEB interrupt callback function */ + LL_DAC_ConvDoneBCallback(Instance, 0x1UL << chnnum); + + } + } +} + +/** + * @brief DAC_CHx DONE interrupt callback function + * @param Instance DAC peripheral + * @param Channel The handling DAC channel + * @return None + */ +__WEAK void LL_DAC_ConvDoneCallback(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DAC_ConvDoneCallback could be implemented in the user file + */ +} + +/** + * @brief DAC_CHx DONE interrupt callback function + * @param Instance DAC peripheral + * @param Channel The handling DAC channel + * @return None + */ +__WEAK void LL_DAC_ConvDoneBCallback(DAC_TypeDef *Instance, uint32_t Channel) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DAC_ConvDoneBCallback could be implemented in the user file + */ +} +/** + * @} + */ + + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_DAC_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dali.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dali.c new file mode 100644 index 0000000000..26175b6dd1 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dali.c @@ -0,0 +1,717 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dali.c + * @author MCD Application Team + * @brief Source file for DALI module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "DALI LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup DALI_LL DALI LL + * @brief DALI LL module driver. + * @{ + */ + +#ifdef LL_DALI_MODULE_ENABLED + +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup DALI_LL_Exported_Functions DALI LL Exported Functions + * @brief DALI LL Exported Functions + * @{ + */ + +/** @defgroup DALI_LL_Exported_Functions_Group1 Initialization and De-Initialization functions + * @brief Initialization and De-Initialization functions +@verbatim + ============================================================================== + ##### Initialization and De-Initialization functions ##### + ============================================================================== + [..] + This section provides functions allowing to: + (+) Initialize and configure the DALI Module. + (+) De-initialize the DALI Module. +@endverbatim +* @{ +*/ + +/** + * @brief Initialize the DALI peripheral + * @param Instance DALI peripheral instance + * @param Init pointer to a DALI_InitTypeDef structure that contains the configuration + * information for the specified DALI peripheral. + * @return status of the initialization + */ +LL_StatusETypeDef LL_DALI_Init(DALI_TypeDef *Instance, DALI_InitTypeDef *Init) +{ + uint32_t prescaler = LL_SYSCTRL_APB1ClkGet() / 16 / Init->Baudrate; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + assert_param(Init != NULL); + assert_param(IS_DALI_MODE(Init->Mode)); + assert_param(IS_DALI_MESSAGE_LEN(Init->MessageLen)); + assert_param(IS_DALI_POLARITY(Init->Polarity)); + assert_param(IS_DALI_FILTER_ENABLE(Init->Filter)); + assert_param(IS_DALI_FORWARD_DELAY(Init->ForwardDelay)); + assert_param(IS_DALI_BACKWARD_DELAY(Init->BackwardDelay)); + assert_param(IS_DALI_BAUDRATE(Init->Baudrate)); + assert_param(IS_DALI_PRESCALE(prescaler)); + + /* Handle Something */ + LL_DALI_MspInit(Instance); + + /* Disable DALI before configuration */ + __LL_DALI_DISABLE(Instance); + + /* Clear all pending flags */ + __LL_DALI_PENDING_FLAG_CLEAR(Instance, (DALI_FLAG_BEIF + | DALI_FLAG_FEIF + | DALI_FLAG_BDIF + | DALI_FLAG_FDIF)); + + /* Configures: Forward frame message length, Polarity, Working mode */ + WRITE_REG(Instance->CR, (Init->MessageLen | Init->Polarity | Init->Mode)); + + /* Configures: Filter feature enable, Filter counter value */ + if (Init->Filter == DALI_FILTER_ENABLE) { + assert_param(IS_DALI_FILTER_COUNTER(Init->FilterCounter)); + + WRITE_REG(Instance->FCR, (Init->Filter | Init->FilterCounter)); + } else { + WRITE_REG(Instance->FCR, 0); + } + + /* Configures: Prescaler */ + WRITE_REG(Instance->PSCR, (DALI_PSCR_FTR_Msk | (prescaler & DALI_PSCR_PSC_Msk))); + + /* Configures: Timing control */ + WRITE_REG(Instance->TCR, ((Init->BackwardDelay << 16) + | (Init->ForwardDelay))); + + /* Enable DALI module */ + __LL_DALI_ENABLE(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief DeInitializes the DALI + * @param Instance DALI peripheral instance + * @return status of the initialization + */ +LL_StatusETypeDef LL_DALI_DeInit(DALI_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + + /* Disable DALI before configuration */ + __LL_DALI_DISABLE(Instance); + + /* Handle Something */ + LL_DALI_MspDeInit(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Initializes the DALI MSP. + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_MspInit(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the DALI MSP + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_MspDeInit(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + + +/** @defgroup DALI_LL_Exported_Functions_Group2 DALI Peripheral State functions + * @brief DALI Peripheral State functions +@verbatim + =============================================================================== + ##### Peripheral State functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Peripheral State functions +@endverbatim + * @{ + */ + +/** + * @brief Wait for a DALI operation to complete. + * @param Timeout Maximum DALI operation timeout + * @return LL Status + */ +LL_StatusETypeDef LL_DALI_WaitForLastOperation(DALI_TypeDef *Instance, uint32_t Timeout) +{ + uint32_t tickstart = LL_GetTick(); + + /* Wait for the DALI operation to complete by polling on BUSY flag to be reset. + Even if the DALI operation fails, the BUSY flag will be reset and an error + flag will be set */ + while (__LL_DALI_STATUS_FLAG_GET(Instance, DALI_FLAG_BSY) != RESET) { + if (Timeout != LL_WAIT_FOREVER) { + if ((Timeout == 0U) || ((LL_GetTick() - tickstart) > Timeout)) { + return LL_TIMEOUT; + } + } + } + + /* Check if any errors occurred */ + if ((__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_FEIF) != RESET) || + (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_BEIF) != RESET)) { + return LL_ERROR; + } + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup DALI_LL_Exported_Functions_Group3 DALI IO operation functions + * @brief DALI IO operation functions + * +@verbatim + ============================================================================== + ##### IO operation functions ##### + ============================================================================== + [..] This section provides functions allowing to: + (+) DALI Master Transmit forward frame (with or without interruption). + (+) DALI Master Receive backward frame (with or without interruption). + (+) DALI Slave Transmit backward frame (with or without interruption). + (+) DALI Slave Receive forward frame (with or without interruption). +@endverbatim + * @{ + */ + +/** + * @brief DALI Master transmit forward data + * @note This function can only be used when DALI working in MASTER mode + * @param Instance DALI peripheral + * @param ForwardData forward frame data + * @return LL Status + */ +LL_StatusETypeDef LL_DALI_Master_Transmit(DALI_TypeDef *Instance, uint32_t ForwardData) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Write Data to Forward Data Register */ + WRITE_REG(Instance->FDR, ForwardData & 0xFFFFFFUL); + + /* Start transmission */ + SET_BIT(Instance->CR, DALI_CR_TS); + + /* Wait until operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + if (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_FDIF) != SET) { + status = LL_FAILED; + } + + /* Clear forward done flag */ + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_FDIF); + } + } + + /* Return function status */ + return status; +} + +/** + * @brief DALI Master transmit forward data with interrupt + * @note This function can only be used when DALI working in MASTER mode + * @param Instance DALI peripheral + * @param ForwardData forward frame data + * @return LL Status + */ +LL_StatusETypeDef LL_DALI_Master_Transmit_IT(DALI_TypeDef *Instance, uint32_t ForwardData) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Write Data to Forward Data Register */ + WRITE_REG(Instance->FDR, ForwardData & 0xFFFFFFUL); + + /* Enable FDIE interrupts */ + __LL_DALI_IT_ENABLE(Instance, DALI_IT_FDIE); + + /* Start transmission */ + SET_BIT(Instance->CR, DALI_CR_TS); + } + + /* Return function status */ + return status; +} + +/** + * @brief DALI Master receive backward data + * @note This function can only be used when DALI working in MASTER mode + * @param Instance DALI peripheral + * @param BackwardData Specifies the data pointer to read in. + * @return LL status + */ +LL_StatusETypeDef LL_DALI_Master_Receive(DALI_TypeDef *Instance, uint8_t *BackwardData) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + assert_param(BackwardData != NULL); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + + /* Check and clear BDIF flag */ + if (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_BDIF) != RESET) { + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_BDIF); + + *BackwardData = READ_REG(Instance->BDR) & 0xFFUL; + } else { + status = LL_FAILED; + } + } + + /* Return function status */ + return status; +} + +/** + * @brief DALI Master receive backward data with interrupt + * @note This function can only be used when DALI working in MASTER mode + * @param Instance DALI peripheral + * @note Use __LL_DALI_MSTR_READ_BACKWARD_DATA() to get the backword data in IRQ callbacks + * @return LL status + */ +LL_StatusETypeDef LL_DALI_Master_Receive_IT(DALI_TypeDef *Instance) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Enable BDIE interrupts */ + __LL_DALI_IT_ENABLE(Instance, DALI_IT_BDIE); + } + + /* Return function status */ + return status; +} + +/** + * @brief DALI Slave transmit backward data + * @note This function can only be used when DALI working in SLAVE mode + * @param Instance DALI peripheral + * @param BackwardData backward frame data + * @return LL status + */ +LL_StatusETypeDef LL_DALI_Slave_Transmit(DALI_TypeDef *Instance, uint8_t BackwardData) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Write Data to Forward Data Register */ + WRITE_REG(Instance->BDR, BackwardData); + + /* Start transmission */ + SET_BIT(Instance->CR, DALI_CR_TS); + + /* Wait until operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + if (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_BDIF) != SET) { + status = LL_FAILED; + } + + /* Clear forward done flag */ + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_BDIF); + } + } + + /* Return function status */ + return status; +} + +/** + * @brief DALI Slave transmit backward data with interrupt + * @note This function can only be used when DALI working in SLAVE mode + * @param Instance DALI peripheral + * @param BackwardData backward frame data + * @return LL status + */ +LL_StatusETypeDef LL_DALI_Slave_Transmit_IT(DALI_TypeDef *Instance, uint8_t BackwardData) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Write Data to Forward Data Register */ + WRITE_REG(Instance->BDR, BackwardData); + + /* Enable BDIE interrupts */ + __LL_DALI_IT_ENABLE(Instance, DALI_IT_BDIE); + + /* Start transmission */ + SET_BIT(Instance->CR, DALI_CR_TS); + + } + + /* Return function status */ + return status; +} + +/** + * @brief DALI Slave receive forward data + * @note This function can only be used when DALI working in SLAVE mode + * @param Instance DALI peripheral + * @param ForwardData Specifies the data pointer to read in. + * @return LL status + */ +LL_StatusETypeDef LL_DALI_Slave_Receive(DALI_TypeDef *Instance, uint32_t *ForwardData) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + assert_param(ForwardData != NULL); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + + /* Check and clear FDIF flag */ + if (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_FDIF) != RESET) { + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_FDIF); + + *ForwardData = READ_REG(Instance->FDR) & 0xFFFFFFUL; + } else { + status = LL_FAILED; + } + } + + /* Return function status */ + return status; +} + +/** + * @brief DALI Slave receive forward data with interrupt + * @note This function can only be used when DALI working in SLAVE mode + * @param Instance DALI peripheral + * @note Use __LL_DALI_SLV_READ_FORWARD_DATA() to get the forward data in IRQ callbacks + * @return LL status + */ +LL_StatusETypeDef LL_DALI_Slave_Receive_IT(DALI_TypeDef *Instance) +{ + LL_StatusETypeDef status; + + /* Check the parameters */ + assert_param(IS_DALI_ALL_INSTANCE(Instance)); + + /* Wait until last operation complete */ + if ((status = LL_DALI_WaitForLastOperation(Instance, DALI_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Enable FDIE interrupts */ + __LL_DALI_IT_ENABLE(Instance, DALI_IT_FDIE); + } + + /* Return function status */ + return status; +} + +/** + * @} + */ + + +/** @defgroup DALI_LL_Exported_Functions_Interrupt DALI Initerrupt management + * @brief DALI Initerrupt management +@verbatim + =============================================================================== + ##### Initerrupt management ##### + =============================================================================== + [..] + This section provides DALI interrupt handler and callback functions. +@endverbatim + * @{ + */ + +/** + * @brief This function handles DALI interrupts requests. + * @param Instance DALI peripheral + * @return None + */ +void LL_DALI_IRQHandler(DALI_TypeDef *Instance) +{ + if ((__LL_DALI_IT_SOURCE_CHECK(Instance, DALI_IT_FDIE) != RESET) && + (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_FDIF) != RESET)) { + + /* Disable and clear interrupt */ + __LL_DALI_IT_DISABLE(Instance, DALI_IT_FDIE); + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_FDIF); + + if (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_FEIF) != RESET) { + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_FEIF); + + /* Error detected */ + if (READ_BIT(Instance->CR, DALI_CR_MODE_Msk) != DALI_MODE_SLAVE) { + LL_DALI_MstrTransmitErrorCallback(Instance); + } else { + LL_DALI_SlvReceiveErrorCallback(Instance); + } + } else { + + /* Transmission complete */ + if (READ_BIT(Instance->CR, DALI_CR_MODE_Msk) != DALI_MODE_SLAVE) { + LL_DALI_MstrTransmitDoneCallback(Instance); + } else { + LL_DALI_SlvReceiveDoneCallback(Instance); + } + } + } + + if ((__LL_DALI_IT_SOURCE_CHECK(Instance, DALI_IT_BDIE) != RESET) && + (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_BDIF) != RESET)) { + + /* Disable and clear interrupt */ + __LL_DALI_IT_DISABLE(Instance, DALI_IT_BDIE); + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_BDIF); + + if (__LL_DALI_PENDING_FLAG_GET(Instance, DALI_FLAG_BEIF) != RESET) { + __LL_DALI_PENDING_FLAG_CLEAR(Instance, DALI_FLAG_BEIF); + + /* Error detected */ + if (READ_BIT(Instance->CR, DALI_CR_MODE_Msk) != DALI_MODE_SLAVE) { + LL_DALI_MstrRecviveErrorCallback(Instance); + } else { + LL_DALI_SlvTransmitErrorCallback(Instance); + } + } else { + /* Transmission complete */ + if (READ_BIT(Instance->CR, DALI_CR_MODE_Msk) != DALI_MODE_SLAVE) { + LL_DALI_MstrRecviveDoneCallback(Instance); + } else { + LL_DALI_SlvTransmitDoneCallback(Instance); + } + } + } +} + +/** + * @brief DALI Master receive backward frame done callback + * Use __LL_DALI_MSTR_READ_BACKWARD_DATA() to get the backword data + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_MstrRecviveDoneCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_MstrRecviveDoneCallback could be implemented in the user file + */ +} + +/** + * @brief DALI Master receive backward frame failed callback + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_MstrRecviveErrorCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_MstrRecviveErrorCallback could be implemented in the user file + */ +} + +/** + * @brief DALI Master transmit forward frame done callback + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_MstrTransmitDoneCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_MstrTransmitDoneCallback could be implemented in the user file + */ +} + +/** + * @brief DALI Master transmit forward frame failed callback + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_MstrTransmitErrorCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_MstrTransmitErrorCallback could be implemented in the user file + */ +} + +/** + * @brief DALI Slave receive forward frame done callback + * Use __LL_DALI_SLV_READ_FORWARD_DATA() to get the forward data + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_SlvReceiveDoneCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_SlvReceiveDoneCallback could be implemented in the user file + */ +} + +/** + * @brief DALI Slave receive forward frame failed callback + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_SlvReceiveErrorCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_SlvReceiveErrorCallback could be implemented in the user file + */ +} + +/** + * @brief DALI Slave transmit backward frame done callback + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_SlvTransmitDoneCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_SlvTransmitDoneCallback could be implemented in the user file + */ +} + +/** + * @brief DALI Slave transmit backward frame failed callback + * @param Instance DALI peripheral + * @return None + */ +__WEAK void LL_DALI_SlvTransmitErrorCallback(DALI_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_DALI_SlvTransmitErrorCallback could be implemented in the user file + */ +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_DALI_MODULE_ENABLED */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dflash.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dflash.c new file mode 100644 index 0000000000..fb3afceb30 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dflash.c @@ -0,0 +1,431 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dflash.c + * @author MCD Application Team + * @brief Source file for DFLASH module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "DFLASH LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup DFLASH_LL DFLASH LL + * @brief DFLASH LL module driver + * @{ + */ + +#ifdef LL_DFLASH_MODULE_ENABLED + +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup DFLASH_LL_Exported_Functions DFLASH LL Exported Functions + * @brief DFLASH LL Exported Functions + * @{ + */ + +/** @defgroup DFLASH_LL_Exported_Functions_Group1 DFLASH Peripheral State functions + * @brief DFLASH Peripheral State functions +@verbatim + =============================================================================== + ##### Peripheral State functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Peripheral State functions + +@endverbatim + * @{ + */ + +/** + * @brief Wait for a DFLASH operation to complete. + * @param Timeout Maximum DataFlash operation timeout + * @return LL Status + */ +LL_StatusETypeDef LL_DFLASH_WaitForLastOperation(uint32_t Timeout) +{ + uint32_t tickstart = LL_GetTick(); + + /* Wait for the DFLASH operation to complete by polling on BUSY flag to be reset. + Even if the DFLASH operation fails, the BUSY flag will be reset and an error + flag will be set */ + while (__LL_DFLASH_STATUS_FLAG_GET(DFLASH_FLAG_BSY) != RESET) { + if (Timeout != LL_WAIT_FOREVER) { + if ((Timeout == 0U) || ((LL_GetTick() - tickstart) > Timeout)) { + return LL_TIMEOUT; + } + } + } + + /* Check and clear DIF flag */ + if (__LL_DFLASH_PENDING_FLAG_GET(DFLASH_FLAG_DIF) != RESET) { + __LL_DFLASH_PENDING_FLAG_CLEAR(DFLASH_FLAG_DIF); + } + + /* Check if any errors occurred */ + if (__LL_DFLASH_PENDING_FLAG_GET(DFLASH_FLAG_EIF) != RESET) { + return LL_ERROR; + } + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup DFLASH_LL_Exported_Functions_Group2 DFLASH Input and Output operation functions + * @brief DFLASH Input and Output operation functions +@verbatim + =============================================================================== + ##### Input and Output operation functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Byte/Word Program operations functions + (+) Byte/Word Read operations functions + (+) Erase operations functions + +@endverbatim + * @{ + */ + +/** + * @brief Program one byte at a specified address. + * @param Address specifies the address to be programmed. + * @param Data specifies the data to be programmed. + * @note LL_DFLASH_Unlock() should be called before to unlock the DFLASH interface + * LL_DFLASH_Lock() should be called after to lock the DFLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_DFLASH_Program_Byte(uint32_t Address, uint8_t Data) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_DFLASH_ADDRESS_MASK(Address)); + + /* Address mask */ + Address &= DFLASH_PROGRAM_ADDRESS_MASK; + + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Byte Program mode */ + CLEAR_BIT(DFLASH->CR, DFLASH_CR_DS); + + /* Fill the data into DFLASH_DR register */ + WRITE_REG(DFLASH->DR, Data); + + /* Set Address */ + WRITE_REG(DFLASH->ADDR, Address); + + /* Ignore full 0xFF data programming */ + if ((DFLASH->DR & 0xFF) != 0xFFU) { + /* Pragram Start */ + SET_BIT(DFLASH->CR, DFLASH_CR_PS); + + /* Wait until operation complete */ + status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE); + } + } + + /* Return function status */ + return status; +} + +/** + * @brief Program one word at a specified address. + * @param Address specifies the address to be programmed. + * Notice that address must align to a word + * @param Data specifies the data to be programmed. + * @note LL_DFLASH_Unlock() should be called before to unlock the DFLASH interface + * LL_DFLASH_Lock() should be called after to lock the DFLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_DFLASH_Program_Word(uint32_t Address, uint32_t Data) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_DFLASH_ADDRESS_MASK(Address)); + assert_param(IS_DFLASH_ADDRESS_CHECK_ALIGN(Address)); + + /* Address mask */ + Address &= DFLASH_PROGRAM_ADDRESS_MASK; + + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Byte Program mode */ + SET_BIT(DFLASH->CR, DFLASH_CR_DS); + + /* Fill the data into DFLASH_DR register */ + WRITE_REG(DFLASH->DR, Data); + + /* Set Address */ + WRITE_REG(DFLASH->ADDR, Address); + + /* Ignore full 0xFF data programming */ + if (DFLASH->DR != 0xFFFFFFFFU) { + /* Pragram Start */ + SET_BIT(DFLASH->CR, DFLASH_CR_PS); + + /* Wait until operation complete */ + status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE); + } + } + + /* Return function status */ + return status; +} + +/** + * @brief Read one byte from a specified address. + * @param Address specifies the address to read. + * @param Data specifies the data pointer to read in. + * @note LL_DFLASH_Unlock() should be called before to unlock the DFLASH interface + * LL_DFLASH_Lock() should be called after to lock the DFLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_DFLASH_Read_Byte(uint32_t Address, uint8_t *Data) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_DFLASH_ADDRESS_MASK(Address)); + + /* Address mask */ + Address &= DFLASH_PROGRAM_ADDRESS_MASK; + /* Initialize the value of Data */ + *Data = 0; + + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Byte Read mode */ + CLEAR_BIT(DFLASH->CR, DFLASH_CR_DS); + + /* Set Address */ + WRITE_REG(DFLASH->ADDR, Address); + + /* Read Start */ + SET_BIT(DFLASH->CR, DFLASH_CR_RS); + + /* Wait until operation complete */ + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Read the data from DFLASH->DR Registers */ + *Data = READ_REG(DFLASH->DR) & 0xFFU; + } + } + + /* Return function status */ + return status; +} + +/** + * @brief Read one wrod from a specified address. + * @param Address specifies the address to read. + * Notice that address must align to a word + * @param Data specifies the data pointer to read in. + * @note LL_DFLASH_Unlock() should be called before to unlock the DFLASH interface + * LL_DFLASH_Lock() should be called after to lock the DFLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_DFLASH_Read_Word(uint32_t Address, uint32_t *Data) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_DFLASH_ADDRESS_MASK(Address)); + assert_param(IS_DFLASH_ADDRESS_CHECK_ALIGN(Address)); + + /* Address mask */ + Address &= DFLASH_PROGRAM_ADDRESS_MASK; + /* Initialize the value of Data */ + *Data = 0; + + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Byte Read mode */ + CLEAR_BIT(DFLASH->CR, DFLASH_CR_DS); + + /* Set Address */ + WRITE_REG(DFLASH->ADDR, Address); + + /* Read Start */ + SET_BIT(DFLASH->CR, DFLASH_CR_RS); + + /* Wait until operation complete */ + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Read the data from DFLASH->DR Registers */ + *Data = READ_REG(DFLASH->DR); + } + } + + /* Return function status */ + return status; +} + +/** + * @brief DFLASH mass erase. This will mass erase the Main-Memory area. + * @note Please Notice this function has no effect to the Secondary-Memory. + * @note LL_DFLASH_Unlock() should be called before to unlock the DFLASH interface + * LL_DFLASH_Lock() should be called after to lock the DFLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_DFLASH_MassErase(void) +{ + LL_StatusETypeDef status = LL_OK; + + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Set to Mass Erase mode */ + SET_BIT(DFLASH->ECR, DFLASH_ECR_EMODE); + + /* Erase Start */ + SET_BIT(DFLASH->CR, DFLASH_CR_ES); + + /* Wait until operation complete */ + status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE); + } + + /* Return function status */ + return status; +} + +/** + * @brief Erase one specified DFLASH memory sector. This function is effective for both + * Main-Memory and Secondary-Memory areas. + * @param sector The start sector number of the specified sectors to erase. + * This parameter must be a value between 0 and (NB of sectors - 1) + * @note LL_DFLASH_Unlock() should be called before to unlock the DFLASH interface + * LL_DFLASH_Lock() should be called after to lock the DFLASH interface + * @return Status + */ +LL_StatusETypeDef LL_DFLASH_SectorErase(uint16_t Sector) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_DFLASH_NB_SECTORS(Sector)); + + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Set to Sector Erase mode */ + CLEAR_BIT(DFLASH->ECR, DFLASH_ECR_EMODE); + + /* Set Sector to erase */ + MODIFY_REG(DFLASH->ECR, DFLASH_ECR_ESNB_Msk, Sector); + + /* Erase Start */ + SET_BIT(DFLASH->CR, DFLASH_CR_ES); + + /* Wait until operation complete */ + status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE); + } + + /* Return function status */ + return status; +} + +/** + * @brief Erase the specified DFLASH memory multiple sectors. + * @param sector The start sector number of the specified sectors to erase. + * This parameter must be a value between 0 and (NB of sectors - 1) + * @param num Number of sectors to be erased. + * This parameter must be a value between 1 and NB of sectors + * @note Please notice that all specified sectors number must between 0 and (NB of sectors - 1) + * @param *SectorError Pointer to variable that contains the configuration information on faulty + * sector in case of error (0xFFFF means that all the sectors have been correctly erased). + * Set this pointer to NULL if you do not need it. + * @note LL_DFLASH_Unlock() should be called before to unlock the DFLASH interface + * LL_DFLASH_Lock() should be called after to lock the DFLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_DFLASH_MultiSectorsErase(uint16_t Sector, uint16_t Num, uint16_t *SectorError) +{ + LL_StatusETypeDef status = LL_OK; + + assert_param(Num != 0); + assert_param(IS_DFLASH_NB_SECTORS(Sector)); + assert_param(IS_DFLASH_NB_SECTORS(Sector + Num - 1)); + + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /*Initialization of SectorError variable*/ + if (SectorError != NULL) { + *SectorError = 0xFFFF; + } + + /* Set to Sector Erase mode */ + CLEAR_BIT(DFLASH->ECR, DFLASH_ECR_EMODE); + + /* Erase the specified sectors */ + for (uint16_t index = Sector; index < (Sector + Num); index++) { + /* Set current Sector to erase */ + MODIFY_REG(DFLASH->ECR, DFLASH_ECR_ESNB_Msk, index); + + /* Erase Start */ + SET_BIT(DFLASH->CR, DFLASH_CR_ES); + + /* Wait until operation complete */ + if ((status = LL_DFLASH_WaitForLastOperation(DFLASH_TIMEOUT_MAX_VALUE)) != LL_OK) { + /* In case of error, stop erase procedure and return the faulty Sector */ + if (SectorError != NULL) { + *SectorError = index; + } + + break; + } + } + } + + /* Return function status */ + return status; +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_DFLASH_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dma.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dma.c new file mode 100644 index 0000000000..50b63e09ae --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_dma.c @@ -0,0 +1,702 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_dma.c + * @author MCD Application Team + * @brief DMA LL Module Driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "DMA LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup DMA_LL DMA LL + * @brief DMA LL module driver + * @{ + */ + +#ifdef LL_DMA_MODULE_ENABLED + +/* Private define ------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/** @defgroup DMA_LL_Private_Types DMA LL Private Types + * @brief DMA LL Private Types + * @{ + */ + +/** + * @brief DMA LL config type definition + */ +typedef struct __DMA_LLCfgTypeDef { + DMA_SrcBurstLenETypeDef src_burst; /*!< source burst length */ + DMA_DstBurstLenETypeDef dst_burst; /*!< destinationd burst length */ + uint16_t max_burst; +} DMA_LLCfgTypeDef; + +/** + * @brief DMA channel control type definition + */ +typedef struct __DMA_ChCtrlTypeDef { + DMA_StateETypeDef state; /*!< channel state */ + void *end_arg; /*!< argument of transfer complete callback fucntion */ + DMA_IRQCallback end_callback; /*!< transfer complete callback fucntion */ + void *err_arg; /*!< argument of transfer error callback fucntion */ + DMA_IRQCallback err_callback; /*!< transfer error callback fucntion */ +} DMA_ChCtrlTypeDef; + +/** + * @brief DMA Private control type definition + */ +typedef struct __DMA_PriCtrlTypeDef { + uint8_t ch_used; /*!< channel used variable */ + DMA_ChCtrlTypeDef ch_ctrl[DMA_CHN_NB]; /*!< channel control params */ +} DMA_PriCtrlTypeDef; + +/** + * @} + */ + +/* Private variables ---------------------------------------------------------*/ +/** @defgroup DMA_LL_Private_Variables DMA LL Private Variables + * @brief DMA LL Private Variables + * @{ + */ + +/** + * @brief DMA LL config default + */ +static const DMA_LLCfgTypeDef dma_ll_cfg_def = { + .src_burst = DMA_SRC_BURST_LEN_1, /*!< source burst default 1 */ + .dst_burst = DMA_DST_BURST_LEN_1, /*!< destination burst default 1 */ + .max_burst = 0x0, /*!< max burst defalut 0x0 (no limit) */ +}; + + +/** + * @brief DMA private control global variable + */ +static DMA_PriCtrlTypeDef dma_pri_ctrl; + +/** + * @} + */ + + +/* Private macro -------------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup DMA_LL_Exported_Functions DMA LL Exported Functions + * @brief DMA LL Exported Functions + * @{ + */ + +/** @defgroup DMA_LL_Exported_Functions_Group1 DMA Init Function + * @brief DMA Init function + * @{ + */ + +/** + * @brief DMA LL init + * @param Instance Specifies DMA peripheral + * @param ch channel to init + * @param user_cfg user config pointer + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_DMA_Init(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, DMA_UserCfgTypeDef *user_cfg) +{ + DMA_LLCfgTypeDef *ll_cfg = (DMA_LLCfgTypeDef *)&dma_ll_cfg_def; + + //Check config params to be valid + if (Instance == NULL || ch >= DMA_CHANNEL_NUM || user_cfg == NULL) { + LOG_E("Init Params config error!\n"); + return LL_ERROR; + } + + //Burst config + __LL_DMA_SrcBurstLen_Set(Instance, ch, ll_cfg->src_burst); + __LL_DMA_DstBurstLen_Set(Instance, ch, ll_cfg->dst_burst); + __LL_DMA_BurstLenMax_Set(Instance, ch, ll_cfg->max_burst); + + //User config + __LL_DMA_TransType_Set(Instance, ch, user_cfg->trans_type); + __LL_DMA_SrcAddrMode_Set(Instance, ch, user_cfg->src_addr_mode); + __LL_DMA_DstAddrMode_Set(Instance, ch, user_cfg->dst_addr_mode); + __LL_DMA_SrcTransWidth_Set(Instance, ch, user_cfg->src_data_width); + __LL_DMA_DstTransWidth_Set(Instance, ch, user_cfg->dst_data_width); + + //Source and destination handshake mode config + if (user_cfg->trans_type == DMA_TRANS_TYPE_P2M || user_cfg->trans_type == DMA_TRANS_TYPE_P2P) { + __LL_DMA_SrcHandshakeMode_Clr(Instance, ch); + } else { + __LL_DMA_SrcHandshakeMode_Set(Instance, ch); + } + + if (user_cfg->trans_type == DMA_TRANS_TYPE_M2P || user_cfg->trans_type == DMA_TRANS_TYPE_P2P) { + __LL_DMA_DstHandshakeMode_Clr(Instance, ch); + } else { + __LL_DMA_DstHandshakeMode_Set(Instance, ch); + } + + //Channel priority config to default + if (ch == DMA_CHANNEL_0) { + __LL_DMA_ChannelPriLow_Set(Instance, ch); + } else if (ch == DMA_CHANNEL_1) { + __LL_DMA_ChannelPriHigh_Set(Instance, ch); + } + + //Source and destination handshake interface config + if (user_cfg->src_hs_ifc != DMA_SRC_HANDSHAKE_IFC_MEMORY) { + __LL_DMA_SrcHandshakeIfc_Set(Instance, ch, user_cfg->src_hs_ifc); + } + + if (user_cfg->dst_hs_ifc != DMA_DST_HANDSHAKE_IFC_MEMORY) { + __LL_DMA_DstHandshakeIfc_Set(Instance, ch, user_cfg->dst_hs_ifc); + } + + //Peripheral enable + __LL_DMA_Periph_En(Instance); + + //IRQ callback config + dma_pri_ctrl.ch_ctrl[ch].end_callback = user_cfg->end_callback; + dma_pri_ctrl.ch_ctrl[ch].end_arg = user_cfg->end_arg; + dma_pri_ctrl.ch_ctrl[ch].err_callback = user_cfg->err_callback; + dma_pri_ctrl.ch_ctrl[ch].err_arg = user_cfg->err_arg; + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[ch].state = DMA_STATE_READY; + + return LL_OK; +} + +/** + * @brief DMA LL deinit + * @param Instance Specifies DMA peripheral + * @param ch channel to deinit + * @return Status of the DeInitialization + */ +LL_StatusETypeDef LL_DMA_DeInit(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch) +{ + uint8_t i; + + //Check config params to be valid + if (Instance == NULL || ch >= DMA_CHANNEL_NUM) { + LOG_E("Deinit Params config error!\n"); + return LL_ERROR; + } + + //IRQ callback deinit + dma_pri_ctrl.ch_ctrl[ch].end_callback = NULL; + dma_pri_ctrl.ch_ctrl[ch].end_arg = NULL; + dma_pri_ctrl.ch_ctrl[ch].err_callback = NULL; + dma_pri_ctrl.ch_ctrl[ch].err_arg = NULL; + + //Update channel state to Reset + dma_pri_ctrl.ch_ctrl[ch].state = DMA_STATE_RESET; + + //Peripheral disable when all channels close + for (i = 0; i < DMA_CHANNEL_NUM; i++) { + if (dma_pri_ctrl.ch_ctrl[i].state != DMA_STATE_RESET) { + break; + } + } + + if (i == DMA_CHANNEL_NUM) { + __LL_DMA_Periph_Dis(Instance); + } + + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup DMA_LL_Exported_Functions_Group2 DMA Channel Management Functions + * @brief DMA Channel Management Functions + * @{ + */ + +/** + * @brief DMA LL channel request + * @param None + * @return DMA_ChannelETypeDef + */ +DMA_ChannelETypeDef LL_DMA_ChannelRequest(void) +{ + uint8_t i; + DMA_ChannelETypeDef avl_ch = DMA_CHANNEL_INVALID; + + //Search available channel + for (i = 0; i < DMA_CHANNEL_NUM; i++) { + if (!READ_BIT(dma_pri_ctrl.ch_used, BIT(i)) && (dma_pri_ctrl.ch_ctrl[i].state == DMA_STATE_RESET)) { + SET_BIT(dma_pri_ctrl.ch_used, BIT(i)); + avl_ch = (DMA_ChannelETypeDef)i; + break; + } + } + + return avl_ch; +} + +/** + * @brief DMA LL request specific channel + * @param ch specific channel to request + * @return DMA_ChannelETypeDef + */ +DMA_ChannelETypeDef LL_DMA_ChReqSpecific(DMA_ChannelETypeDef ch) +{ + if (ch < DMA_CHANNEL_NUM && !READ_BIT(dma_pri_ctrl.ch_used, BIT(ch)) && (dma_pri_ctrl.ch_ctrl[ch].state == DMA_STATE_RESET)) { + SET_BIT(dma_pri_ctrl.ch_used, BIT(ch)); + } else { + ch = DMA_CHANNEL_INVALID; + } + + return ch; +} + +/** + * @brief DMA LL channel release + * @param ch channel to release + * @return None + */ +void LL_DMA_ChannelRelease(DMA_ChannelETypeDef ch) +{ + if (dma_pri_ctrl.ch_ctrl[ch].state == DMA_STATE_RESET) { + CLEAR_BIT(dma_pri_ctrl.ch_used, BIT(ch)); + } +} +/** + * @} + */ + + +/** @defgroup DMA_LL_Exported_Functions_Group3 DMA Start and Stop Functions + * @brief DMA Start and Stop Functions + * @{ + */ + +/** + * @brief DMA LL start in CPU mode + * @param Instance Specifies DMA peripheral + * @param ch channel to start + * @param src_addr source address + * @param dst_addr destination address + * @param data_len transfer data length + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_DMA_Start_CPU(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, + uint32_t src_addr, uint32_t dst_addr, uint32_t data_len) +{ + uint8_t src_data_width; + uint32_t block_size; + + if (ch >= DMA_CHANNEL_NUM) { + LOG_E("Invalid ch-[%d]!\n", ch); + return LL_ERROR; + } + + //Config block size, which is associate to data length + src_data_width = __LL_DMA_SrcTransWidth_Get(Instance, ch); + + if (src_data_width > 2) { + LOG_E("Source data width config error-[%d]!\n", src_data_width); + return LL_ERROR; + } + + src_data_width = BIT(src_data_width); + block_size = data_len / src_data_width; + + if (block_size > LL_DMA_BLOCK_SIZE_MAX) { + LOG_E("Block size max is %d, while now is %d!\n", LL_DMA_BLOCK_SIZE_MAX, block_size); + return LL_ERROR; + } + + __LL_DMA_BlockTransCnt_Set(Instance, ch, block_size); + + //Check and update channel state + if (dma_pri_ctrl.ch_ctrl[ch].state != DMA_STATE_READY) { + LOG_E("Channel state-[%d] isn't in Ready!\n", dma_pri_ctrl.ch_ctrl[ch].state); + return LL_ERROR; + } + + dma_pri_ctrl.ch_ctrl[ch].state = DMA_STATE_BUSY; + + //Config source and destination peripheral bus master 1/2 + if (src_addr >= LL_DMA_SRMBC_ADDR_START && src_addr <= LL_DMA_SRMBC_ADDR_END) { //SRAMB & SRAMC + __LL_DMA_SrcPeriphBus_Set(Instance, ch, DMA_SRC_PERIPH_BUS_AHB_MST2); + } else { //SRAMA & Peripheral & Flash + __LL_DMA_SrcPeriphBus_Set(Instance, ch, DMA_SRC_PERIPH_BUS_AHB_MST1); + } + + if (dst_addr >= LL_DMA_SRMBC_ADDR_START && dst_addr <= LL_DMA_SRMBC_ADDR_END) { //SRAMB & SRAMC + __LL_DMA_DstPeriphBus_Set(Instance, ch, DMA_DST_PERIPH_BUS_AHB_MST2); + } else { //SRAMA & Peripheral & Flash + __LL_DMA_DstPeriphBus_Set(Instance, ch, DMA_DST_PERIPH_BUS_AHB_MST1); + } + + //source and destination address config + __LL_DMA_SrcAddr_Set(Instance, ch, src_addr); + __LL_DMA_DstAddr_Set(Instance, ch, dst_addr); + + //Channel enable + if (ch == DMA_CHANNEL_0) { + __LL_DMA_Ch0_En(Instance); + } else if (ch == DMA_CHANNEL_1) { + __LL_DMA_Ch1_En(Instance); + } + + return LL_OK; +} + +/** + * @brief DMA LL start in interrupt mode + * @param Instance Specifies DMA peripheral + * @param ch channel to start + * @param src_addr source address + * @param dst_addr destination address + * @param data_len transfer data length + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_DMA_Start_IT(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, + uint32_t src_addr, uint32_t dst_addr, uint32_t data_len) +{ + //Channel interrupt enable + __LL_DMA_Channel_Int_En(Instance, ch); + + //Channel transfer complete and error interrupt enable + if (ch == DMA_CHANNEL_0) { + __LL_DMA_Ch0TransCom_Int_En(Instance); + __LL_DMA_Ch0TransErr_Int_En(Instance); + } else if (ch == DMA_CHANNEL_1) { + __LL_DMA_Ch1TransCom_Int_En(Instance); + __LL_DMA_Ch1TransErr_Int_En(Instance); + } + + return LL_DMA_Start_CPU(Instance, ch, src_addr, dst_addr, data_len); +} + +/** + * @brief DMA LL Stop in CPU mode + * @param Instance Specifies DMA peripheral + * @param ch channel to stop + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_DMA_Stop_CPU(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch) +{ + //Check and update channel state + if (dma_pri_ctrl.ch_ctrl[ch].state == DMA_STATE_RESET) { + LOG_E("Channel state is in RESET!\n"); + return LL_ERROR; + } + + dma_pri_ctrl.ch_ctrl[ch].state = DMA_STATE_READY; + + //Channel disable + if (ch == DMA_CHANNEL_0) { + __LL_DMA_Ch0_Dis(Instance); + } else if (ch == DMA_CHANNEL_1) { + __LL_DMA_Ch1_Dis(Instance); + } + + return LL_OK; +} + +/** + * @brief DMA LL Stop in interrupt mode + * @param Instance Specifies DMA peripheral + * @param ch channel to stop + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_DMA_Stop_IT(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch) +{ + LL_StatusETypeDef ret; + + ret = LL_DMA_Stop_CPU(Instance, ch); + + if (ret != LL_OK) { + return ret; + } + + //Channel interrupt disable + __LL_DMA_Channel_Int_Dis(Instance, ch); + + //Channel transfer complete and error interrupt disable + if (ch == DMA_CHANNEL_0) { + __LL_DMA_Ch0TransCom_Int_Dis(Instance); + __LL_DMA_Ch0TransErr_Int_Dis(Instance); + } else if (ch == DMA_CHANNEL_1) { + __LL_DMA_Ch1TransCom_Int_Dis(Instance); + __LL_DMA_Ch1TransErr_Int_Dis(Instance); + } + + return LL_OK; +} + +/** + * @brief DMA LL wait for transfer complete in CPU mode + * @param Instance Specifies DMA peripheral + * @param ch channel to wait for transfer complete + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_DMA_WaitComplete_CPU(DMA_TypeDef *Instance, DMA_ChannelETypeDef ch, uint32_t timeout) +{ + uint32_t tickstart; + LL_StatusETypeDef ret = LL_ERROR; + + //Check channel state + if (dma_pri_ctrl.ch_ctrl[ch].state != DMA_STATE_BUSY) { + LOG_E("Channel state-[%d] isn't in Busy!\n", dma_pri_ctrl.ch_ctrl[ch].state); + return LL_ERROR; + } + + tickstart = LL_GetTick(); + + switch (ch) { + case DMA_CHANNEL_0: + while (!__LL_DMA_Ch0TransErrSta_Get(Instance)) { //transfer normal, no error + if (__LL_DMA_Ch0TransComSta_Get(Instance)) { //transfer complete + //Clear complete status + __LL_DMA_Ch0TransComSta_Clr(Instance); + ret = LL_OK; + break; + } + + if ((LL_GetTick() - tickstart) > timeout) { //transfer timeout + ret = LL_TIMEOUT; + break; + } + } + + //Clear error status + __LL_DMA_Ch0TransErrSta_Clr(Instance); + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[ch].state = DMA_STATE_READY; + + break; + + case DMA_CHANNEL_1: + while (!__LL_DMA_Ch1TransErrSta_Get(Instance)) { //transfer normal, no error + if (__LL_DMA_Ch1TransComSta_Get(Instance)) { //transfer complete + //Clear complete status + __LL_DMA_Ch1TransComSta_Clr(Instance); + ret = LL_OK; + break; + } + + if ((LL_GetTick() - tickstart) > timeout) { //transfer timeout + ret = LL_TIMEOUT; + break; + } + } + + //Clear error status + __LL_DMA_Ch1TransErrSta_Clr(Instance); + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[ch].state = DMA_STATE_READY; + + break; + + default: + break;; + } + + return ret; +} + +/** + * @} + */ + + +/** @defgroup DMA_LL_Exported_Functions_Interrupt DMA Interrupt handler and call back + * @brief DMA Interrupt handler and call back + * @{ + */ + +/** + * @brief DMA IRQ Handler + * @param Instance Specifies DMA peripheral + * @return None + */ +void LL_DMA_IRQHandler(DMA_TypeDef *Instance) +{ + //Transfer complete interrupt handler + if (__LL_DMA_Ch0TransComIntSta_Get(Instance)) { //Channel 0 transfer complete interrupt + //Disable interrupt in single mode + __LL_DMA_Ch0TransCom_Int_Dis(Instance); + __LL_DMA_Ch0TransErr_Int_Dis(Instance); + + //Clear pending + __LL_DMA_Ch0TransComSta_Clr(Instance); + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].state = DMA_STATE_READY; + + //Interrupt callback + if (dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].end_callback) { + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].end_callback(dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].end_arg); + } + + } + + if (__LL_DMA_Ch1TransComIntSta_Get(Instance)) { //Channel 1 transfer complete interrupt + //Disable interrupt in single mode + __LL_DMA_Ch1TransCom_Int_Dis(Instance); + __LL_DMA_Ch1TransErr_Int_Dis(Instance); + + //Clear pending + __LL_DMA_Ch1TransComSta_Clr(Instance); + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].state = DMA_STATE_READY; + + //Interrupt callback + if (dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].end_callback) { + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].end_callback(dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].end_arg); + } + + } + + + //Transfer error interrupt handler + if (__LL_DMA_Ch0TransErrIntSta_Get(Instance)) { //Channel 0 transfer error interrupt + //Disable interrupt in single mode + __LL_DMA_Ch0TransCom_Int_Dis(Instance); + __LL_DMA_Ch0TransErr_Int_Dis(Instance); + + //Clear pending + __LL_DMA_Ch0TransErrSta_Clr(Instance); + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].state = DMA_STATE_READY; + + //Interrupt callback + if (dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].err_callback) { + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].err_callback(dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].err_arg); + } + + } + + if (__LL_DMA_Ch1TransErrIntSta_Get(Instance)) { //Channel 1 transfer error interrupt + //Disable interrupt in single mode + __LL_DMA_Ch1TransCom_Int_Dis(Instance); + __LL_DMA_Ch1TransErr_Int_Dis(Instance); + + //Clear pending + __LL_DMA_Ch1TransErrSta_Clr(Instance); + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].state = DMA_STATE_READY; + + //Interrupt callback + if (dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].err_callback) { + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].err_callback(dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].err_arg); + } + + } + + + //Block transfer complete interrupt handler + if (__LL_DMA_Ch0BlockTransComIntSta_Get(Instance)) { //Channel 0 block transfer complete interrupt + __LL_DMA_Ch0BlockTransComSta_Clr(Instance); + //:TODO: according to need + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].state = DMA_STATE_READY; + } + + if (__LL_DMA_Ch1BlockTransComIntSta_Get(Instance)) { //Channel 1 block transfer complete interrupt + __LL_DMA_Ch1BlockTransComSta_Clr(Instance); + //:TODO: according to need + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].state = DMA_STATE_READY; + } + + + //Source transfer complete interrupt handler + if (__LL_DMA_Ch0SrcTransComIntSta_Get(Instance)) { //Channel 0 source transfer complete interrupt + __LL_DMA_Ch0SrcTransComSta_Clr(Instance); + //:TODO: according to need + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].state = DMA_STATE_READY; + } + + if (__LL_DMA_Ch1SrcTransComIntSta_Get(Instance)) { //Channel 1 source transfer complete interrupt + __LL_DMA_Ch1SrcTransComSta_Clr(Instance); + //:TODO: according to need + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].state = DMA_STATE_READY; + } + + + //Destination transfer complete interrupt handler + if (__LL_DMA_Ch0DstTransComIntSta_Get(Instance)) { //Channel 0 destination transfer complete interrupt + __LL_DMA_Ch0DstTransComSta_Clr(Instance); + //:TODO: according to need + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_0].state = DMA_STATE_READY; + } + + if (__LL_DMA_Ch1DstTransComIntSta_Get(Instance)) { //Channel 1 destination transfer complete interrupt + __LL_DMA_Ch1DstTransComSta_Clr(Instance); + //:TODO: according to need + + //Update channel state to Ready + dma_pri_ctrl.ch_ctrl[DMA_CHANNEL_1].state = DMA_STATE_READY; + } +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_DMA_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_ecu.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_ecu.c new file mode 100644 index 0000000000..a8c6c162ab --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_ecu.c @@ -0,0 +1,318 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_ecu.c + * @author MCD Application Team + * @brief ECU LL module driver + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "ECU LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup ECU_LL ECU LL + * @brief ECU LL module driver + * @{ + */ + +#ifdef LL_ECU_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup ECU_LL_Exported_Functions ECU LL Exported Functions + * @brief ECU LL Exported Functions + * @{ + */ + +/** @defgroup ECU_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and Configuration functions + * +@verbatim + =============================================================================== + ##### Initialization and de-initialization functions ##### + =============================================================================== + [..] + This section provides functions allowing to initialize and de-initialize the ECU + to be ready for use. + +@endverbatim + * @{ + */ + +/** + * @brief Initializes the ECU peripheral according to the specified parameters in the ECU_Init. + * @param ECU_Init: pointer to a ECU_InitTypeDef structure that contains + * the configuration information for the specified ECU peripheral. + * @return status of the initialization + */ +LL_StatusETypeDef LL_ECU_Init(ECU_TypeDef *Instance, ECU_InitTypeDef *ECU_Init) +{ + /*hardware level Initializes*/ + LL_ECU_MspInit(Instance); + /*check paramter*/ + assert_param(IS_ECU_MODULE(ECU_Init->ModuleEnable)); + assert_param(IS_ECU_AVERAGE(ECU_Init->AverageSel)); + assert_param(IS_ECU_ACSFT(ECU_Init->ACLeftShift)); + assert_param(IS_ECU_APSFT(ECU_Init->APRightShift)); + assert_param(IS_ECU_DATSEL(ECU_Init->DataSel)); + assert_param(IS_ECU_CRSSEL(ECU_Init->CrossZeroSel)); + + if (ECU_Init->ModuleEnable == ENABLE) { + /*ECU control register, enable mdule */ + if (ECU_Init->InterruptEn == ENABLE) { + SET_BIT(Instance->CON, ECU_CON_ENABLE | ECU_CON_INTEN); + } else { + SET_BIT(Instance->CON, ECU_CON_ENABLE); + } + + /*Configure averages the data results*/ + /*Configure The right shift number of power results and + *the left shift number of active power results are configured.*/ + MODIFY_REG(Instance->CON, + ECU_CON_AVGSEL + | ECU_CON_APSFT + | ECU_CON_ACSFT, + ECU_Init->AverageSel + | ECU_Init->APRightShift + | ECU_Init->ACLeftShift + ); + /*Configure the corresponding event selection bits*/ + MODIFY_REG(Instance->PRC, + ECU_PRC_CRSSEL + | ECU_PRC_ADRSEL + | ECU_PRC_DATSEL, + ECU_Init->CrossZeroSel + | ECU_Init->AddressSel + | ECU_Init->DataSel + ); + /*Configure cache voltage and current data storage addresses and offset addresses*/ + /*Configure voltage start address*/ + MODIFY_REG(Instance->V_ADDR1, ECU_V_ADDR1_STADDR, ECU_Init->VStartAddr); + /*Configure voltage offset address*/ + MODIFY_REG(Instance->V_ADDR2, ECU_V_ADDR2_OFADDR, ECU_Init->VOffsetAddr); + /*Configure current start address*/ + MODIFY_REG(Instance->I_ADDR1, ECU_I_ADDR1_STADDR, ECU_Init->IStartAddr); + /*Configure current offset address*/ + MODIFY_REG(Instance->I_ADDR2, ECU_I_ADDR2_OFADDR, ECU_Init->IOffsetAddr); + + return LL_OK; + } else { + return LL_ERROR; + } +} + +/** + * @brief De-initializes the ECU peripheral registers to their default reset values. + * @return status of the de-initialization + */ +LL_StatusETypeDef LL_ECU_DeInit(ECU_TypeDef *Instance) +{ + /*Get the current working status of the ECU*/ + if (__LL_ECU_GET_STA(Instance)) { + /*Disable the module*/ + __LL_ECU_MODULE_DISABLE(Instance); + } + + /*Reset configuration register,Sets the value of the register to restore the default value */ + MODIFY_REG(Instance->CON, + ECU_CON_INTEN | ECU_CON_INT | ECU_CON_AVGSEL | ECU_CON_APSFT | ECU_CON_ACSFT, + (0x8U << ECU_CON_APSFT_Pos) | (0x8U << ECU_CON_ACSFT_Pos) + ); + /*Reset the event selection register*/ + CLEAR_BIT(Instance->PRC, ECU_PRC_DATSEL | ECU_PRC_ADRSEL | ECU_PRC_CRSSEL); + /*Clears the input square root data*/ + CLEAR_REG(Instance->SQRT_IN); + /*Clear the starting address of the voltage buffer*/ + CLEAR_BIT(Instance->V_ADDR1, ECU_V_ADDR1_STADDR); + /*Clear the offset address of the voltage buffer*/ + CLEAR_BIT(Instance->V_ADDR2, ECU_V_ADDR2_OFADDR); + /*Clear the starting address of the current buffer*/ + CLEAR_BIT(Instance->I_ADDR1, ECU_I_ADDR1_STADDR); + /*Clear the offset address of the current buffer*/ + CLEAR_BIT(Instance->I_ADDR2, ECU_I_ADDR2_OFADDR); + + return LL_OK; +} + +/** + * @brief Initializes the ECU MSP. + * @param ECU ECU instance + * @return None + */ +__WEAK void LL_ECU_MspInit(ECU_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ECU_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the ECU MSP + * @param ECU ECU instance + * @return None + */ +__WEAK void LL_ECU_MspDeInit(ECU_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ECU_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + + +/** @defgroup ECU_LL_Exported_Functions_Group2 ECU Read calulate result operation functions + * @brief ECU Read calulate result operation functions + * +@verbatim + =============================================================================== + ##### Read result value functions ##### + =============================================================================== + [..] + This subsection provides a set of functions allowing to manage the ECUs: + (+) Read the ECU SQRT_OUT value + (+) Write the ECU SQRT_IN value + @note For the above operation of reading registers, please determine whether the mark of completion of calculation + is set before reading, or try to read data in the interrupt +@endverbatim + * @{ + */ + +/** + * @brief Set the data input that you want to take the square root of + * @param __VALUE__ input data + * @return None + */ +void LL_ECU_WriteSqrtInData(ECU_TypeDef *Instance, uint32_t SqrtValue) +{ + /*Check whether the last square root calculation was completed.*/ + if (__LL_ECU_SQRT_DONE_FLAG(Instance)) { + /*If not, wait for the flag to clear*/ + while (__LL_ECU_SQRT_DONE_FLAG(Instance)); + } + + /*If complete, write the data you need to take the square root of*/ + MODIFY_REG(Instance->SQRT_IN, ECU_SQRT_INDATA, SqrtValue); + /*Square root enable*/ + __LL_ECU_SQRT_ENABLE(Instance); +} + +/** + * @brief Get the result of square root data + * @param Instance ECU instance + * @return The result of the square root of the input data + */ +uint32_t LL_ECU_ReadSqrtOutData(ECU_TypeDef *Instance) +{ + /*Check whether the last square root calculation was completed.*/ + if (__LL_ECU_SQRT_DONE_FLAG(Instance)) { + /*If not, wait for the flag to clear*/ + while (__LL_ECU_SQRT_DONE_FLAG(Instance)); + } + + /*If completed, the result of the operation is read*/ + return (uint32_t)READ_REG(Instance->SQRT_OUT); +} +/** + * @} + */ + + +/** @defgroup ECU_LL_Exported_Functions_Interrupt ECU IRQ handler management + * @brief ECU IRQ handler management + * +@verbatim + ============================================================================== + ##### IRQ handler management ##### + ============================================================================== + [..] + This section provides ECU IRQ handler function. + +@endverbatim + * @{ + */ + +/** + * @brief This function handles ECU interrupts requests. + * @param ECU ECU instance + * @return None + */ +void LL_ECU_IRQHandler(ECU_TypeDef *Instance) +{ + if (__LL_ECU_DONE_GET_IT(Instance) && __LL_ECU_DONE_GET_FLAG(Instance)) { + __LL_ECU_DONE_CLEAR_FLAG(Instance); + + /*Handle something*/ + LL_ECU_CalDoneCallback(Instance); + } +} + +/** + * @brief ECU parameters calculate completed detection callback. + * @return None + */ +__WEAK void LL_ECU_CalDoneCallback(ECU_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_ECU_CalDoneCallback could be implemented in the user file + */ +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_ECU_MODULE_ENABLE */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_flash.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_flash.c new file mode 100644 index 0000000000..56f525677f --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_flash.c @@ -0,0 +1,491 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_flash.c + * @author MCD Application Team + * @brief FLASH LL module driver. + * This file provides firmware functions to manage the following + * functionalities of the internal FLASH memory: + * + Program operations functions + * + Erase operations functions + * + Peripheral State functions + * + Write Protection Area configure functions + * + Read Protection Level configure functions + * + Interrupt and Callback functions + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "FLASH LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup FLASH_LL FLASH LL + * @brief Flash LL module driver. + * @{ + */ + +#ifdef LL_FLASH_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/** @defgroup FLASH_LL_Private_Variables FLASH LL Private Variables + * @brief FLASH LL Private Variables + * @{ + */ + +/** @brief Variable whitch recorded the error codes. + * This parameter can be any combination of @ref FLASH_Error_Codes + */ +static uint32_t FlashErrorCode = FLASH_ERROR_NONE; + +/** + * @} + */ + + +/* Private function prototypes -----------------------------------------------*/ +/** @defgroup FLASH_LL_Private_Functions FLASH LL Private Functions + * @brief FLASH LL Private Functions + * @{ + */ +static void FLASH_SetErrorCode(void); + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup FLASH_LL_Exported_Functions FLASH LL Exported Functions + * @brief FLASH LL Exported Functions + * @{ + */ + +/** @defgroup FLASH_LL_Exported_Functions_Group1 FLASH Peripheral Control functions + * @brief FLASH Peripheral Control functions +@verbatim + =============================================================================== + ##### Peripheral Control functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Read Protection Level configure + (+) Write Protection Area configure + +@endverbatim + * @{ + */ + +/** + * @brief Read Protection Level configuration. + * @param RDPLevel specifies the read protection level + * This parameter can be a value of @ref FLASH_Read_Protection_Level: + * @arg FLASH_RDP_LEVEL_0 : No protection + * @arg FLASH_RDP_LEVEL_1 : Memory Read protection + * @arg FLASH_RDP_LEVEL_2 : Full chip protection + * @note When enabling read protection level 2, it's no more possible to + * go back to level 1 or level 0. + * @note The function @ref LL_FLASH_Unlock() should be called before to unlock the FLASH interface + * The function @ref LL_FLASH_PF_Unlock() should be called before to unlock the protection feature + * The function @ref LL_FLASH_PF_Launch() should be called after to force the reload of the new configuration + * @return LL Status + */ +LL_StatusETypeDef LL_FLASH_ReadProtectLevelConfig(FLASH_RDPLVETypeDef RDPLevel) +{ + LL_StatusETypeDef status = LL_OK; + + if ((status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Clear error code before operation */ + FlashErrorCode = FLASH_ERROR_NONE; + + /* Configure the RDP level in the userdata register */ + MODIFY_REG(FLASH->RDPR, FLASH_RDPR_RDP_Msk, RDPLevel); + + /* Wait until operation complete */ + status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE); + } + + return status; +} + +/** + * @brief Write Protection configuration. + * @param WRPAreas specifies the area to configure Write Protection. + * This parameter can be any combination value of @ref FLASH_Write_Protection_Area. + * @param WRPState Enable/Disable WRP state for the specifies WPRAreas. + * This parameter can be a value of @ref FLASH_WRP_State: + * @arg FLASH_WRPSTATE_DISABLE: Disable specifies areas WRP + * @arg FLASH_WRPSTATE_ENABLE: Enable specifies areas WRP + * @note Once memory area Write Protection is enabled, user must not program the memory area + * until the protection is disabled. + * @note The function @ref LL_FLASH_Unlock() should be called before to unlock the FLASH interface + * The function @ref LL_FLASH_PF_Unlock() should be called before to unlock the protection feature + * The function @ref LL_FLASH_PF_Launch() should be called after to force the reload of the new configuration + * @return Status + */ +LL_StatusETypeDef LL_FLASH_WriteProtectConfig(FLASH_WRPAREAETypeDef WRPAreas, FLASH_WRPSTETypeDef WRPState) +{ + LL_StatusETypeDef status = LL_OK; + + if ((status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Clear error code before operation */ + FlashErrorCode = FLASH_ERROR_NONE; + + if (WRPState == FLASH_WRPSTATE_ENABLE) { + /* Enable the Write Protection */ + CLEAR_BIT(FLASH->WRPR, WRPAreas); + } else { + /* Disable the Write Protection */ + SET_BIT(FLASH->WRPR, WRPAreas); + } + + /* Wait until operation complete */ + status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE); + } + + return status; +} + +/** + * @} + */ + + +/** @defgroup FLASH_LL_Exported_Functions_Group2 FLASH Peripheral State functions + * @brief FLASH Peripheral State functions +@verbatim + =============================================================================== + ##### Peripheral State functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Peripheral State functions + +@endverbatim + * @{ + */ + +/** + * @brief Wait for a FLASH operation to complete. + * @param Timeout Maximum flash operation timeout + * @return LL Status + */ +LL_StatusETypeDef LL_FLASH_WaitForLastOperation(uint32_t Timeout) +{ + uint32_t tickstart = LL_GetTick(); + + /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset. + Even if the FLASH operation fails, the BUSY flag will be reset and an error + flag will be set */ + while (__LL_FLASH_GET_STATUS_FLAG(FLASH_FLAG_BSY) != RESET) { + if (Timeout != LL_WAIT_FOREVER) { + if ((Timeout == 0U) || ((LL_GetTick() - tickstart) > Timeout)) { + return LL_TIMEOUT; + } + } + } + + /* Check and clear DIF flag */ + if (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_DIF) != RESET) { + __LL_FLASH_CLEAR_PENDING_FLAG(FLASH_FLAG_DIF); + } + + /* Check if any errors occurred */ + if ((__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_RPEIF) != RESET) || + (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_WPEIF) != RESET) || + (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_OPTEIF) != RESET) || + (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_ECCEIF) != RESET)) { + /* Save the error code */ + FLASH_SetErrorCode(); + return LL_ERROR; + } + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Get the specific FLASH error flags. + * @return The returned value can be any combination of @ref FLASH_Error_Codes + */ +uint32_t LL_FLASH_GetError(void) +{ + return FlashErrorCode; +} + +/** + * @} + */ + + +/** @defgroup FLASH_LL_Exported_Functions_Group3 FLASH Input and Output operation functions + * @brief FLASH Input and Output operation functions +@verbatim + =============================================================================== + ##### Input and Output operation functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Program operations functions + (+) Erase operations functions + +@endverbatim + * @{ + */ + +/** + * @brief Program 16 bytes (128 bit) at a specified address. + * @param Address specifies the address to be programmed. + * Notice that address must align to 128 bit + * @param Data[] specifies the data to be programmed. + * FLASH_PROG_DATA_WIDTH bytes will be programmed in a single operation. + * @note LL_FLASH_Unlock() should be called before to unlock the FLASH interface + * LL_FLASH_Lock() should be called after to lock the FLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_FLASH_Program(uint32_t Address, uint8_t Data[FLASH_PROG_DATA_WIDTH]) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(Data != NULL); + assert_param(IS_FLASH_PROGRAM_ADDRESS_ALIGN_128BIT(Address)); + + /* Address mask */ + Address &= FLASH_PROGRAM_ADDRESS_MASK; + + if ((status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Clear error code before operation */ + FlashErrorCode = FLASH_ERROR_NONE; + + /* Fill the data into FLASH Program Control Registers */ + FLASH->DR0 = *((__IO uint32_t *)(Data + 0)); + FLASH->DR1 = *((__IO uint32_t *)(Data + 4)); + FLASH->DR2 = *((__IO uint32_t *)(Data + 8)); + FLASH->DR3 = *((__IO uint32_t *)(Data + 12)); + + /* Set Address */ + FLASH->ADDR = Address; + + /* Ignore full 0xFF data programming */ + if ((FLASH->DR0 != 0xFFFFFFFFU) && + (FLASH->DR1 != 0xFFFFFFFFU) && + (FLASH->DR2 != 0xFFFFFFFFU) && + (FLASH->DR3 != 0xFFFFFFFFU)) { + + /* Pragram Start */ + SET_BIT(FLASH->CR, FLASH_CR_PS); + + /* Wait until operation complete */ + status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE); + } + } + + /* Return function status */ + return status; +} + +/** + * @brief Erase one specified FLASH memory sector. + * @param sector The start sector number of the specified sectors to erase. + * This parameter must be a value between 0 and (NB of sectors - 1) + * @note LL_FLASH_Unlock() should be called before to unlock the FLASH interface + * LL_FLASH_Lock() should be called after to lock the FLASH interface + * @return Status + */ +LL_StatusETypeDef LL_FLASH_SectorErase(uint16_t Sector) +{ + LL_StatusETypeDef status = LL_OK; + + /* Check the parameters */ + assert_param(IS_FLASH_NB_SECTORS(Sector)); + + if ((status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Clear error code before operation */ + FlashErrorCode = FLASH_ERROR_NONE; + + /* Set to Sector Erase mode */ + CLEAR_BIT(FLASH->ECR, FLASH_ECR_EMODE); + + /* Set Sector to erase */ + MODIFY_REG(FLASH->ECR, FLASH_ECR_ESNB_Msk, Sector); + + /* Erase Start */ + SET_BIT(FLASH->CR, FLASH_CR_ES); + + /* Wait until operation complete */ + status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE); + } + + /* Return function status */ + return status; +} + +/** + * @brief Erase the specified FLASH memory multiple sectors. + * @param sector The start sector number of the specified sectors to erase. + * This parameter must be a value between 0 and (NB of sectors - 1) + * @param num Number of sectors to be erased. + * This parameter must be a value between 1 and NB of sectors + * @note Please notice that all specified sectors number must between 0 and (NB of sectors - 1) + * @param *SectorError Pointer to variable that contains the configuration information on faulty + * sector in case of error (0xFFFF means that all the sectors have been correctly erased). + * Set this pointer to NULL if you do not need it. + * @note LL_FLASH_Unlock() should be called before to unlock the FLASH interface + * LL_FLASH_Lock() should be called after to lock the FLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_FLASH_MultiSectorsErase(uint16_t Sector, uint16_t Num, uint16_t *SectorError) +{ + LL_StatusETypeDef status = LL_OK; + + assert_param(Num != 0); + assert_param(IS_FLASH_NB_SECTORS(Sector)); + assert_param(IS_FLASH_NB_SECTORS(Sector + Num - 1)); + + if ((status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Clear error code before operation */ + FlashErrorCode = FLASH_ERROR_NONE; + + /*Initialization of SectorError variable*/ + if (SectorError != NULL) { + *SectorError = 0xFFFF; + } + + /* Set to Sector Erase mode */ + CLEAR_BIT(FLASH->ECR, FLASH_ECR_EMODE); + + /* Erase the specified sectors */ + for (uint16_t index = Sector; index < (Sector + Num); index++) { + /* Set current Sector to erase */ + MODIFY_REG(FLASH->ECR, FLASH_ECR_ESNB_Msk, index); + + /* Erase Start */ + SET_BIT(FLASH->CR, FLASH_CR_ES); + + /* Wait until operation complete */ + if ((status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE)) != LL_OK) { + /* In case of error, stop erase procedure and return the faulty Sector */ + if (SectorError != NULL) { + *SectorError = index; + } + + break; + } + } + } + + /* Return function status */ + return status; +} + +/** + * @brief FLASH memory mass erase. This will erase the entire FLASH memory. + * @note LL_FLASH_Unlock() should be called before to unlock the FLASH interface + * LL_FLASH_Lock() should be called after to lock the FLASH interface + * @return LL Status + */ +LL_StatusETypeDef LL_FLASH_ChipErase(void) +{ + LL_StatusETypeDef status = LL_OK; + + if ((status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE)) == LL_OK) { + /* Clear error code before operation */ + FlashErrorCode = FLASH_ERROR_NONE; + + /* Set to Chip Erase mode */ + SET_BIT(FLASH->ECR, FLASH_ECR_EMODE); + + /* Erase Start */ + SET_BIT(FLASH->CR, FLASH_CR_ES); + + /* Wait until operation complete */ + status = LL_FLASH_WaitForLastOperation(FLASH_TIMEOUT_MAX_VALUE); + } + + /* Return function status */ + return status; +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ +/** @addtogroup FLASH_LL_Private_Functions + * @{ + */ + +/** + * @brief Set the specific FLASH error flag. + * @return None + */ +static void FLASH_SetErrorCode(void) +{ + if (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_RPEIF) != RESET) { + FlashErrorCode |= FLASH_ERROR_RDP; + __LL_FLASH_CLEAR_PENDING_FLAG(FLASH_FLAG_RPEIF); + } + + if (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_WPEIF) != RESET) { + FlashErrorCode |= FLASH_ERROR_WRP; + __LL_FLASH_CLEAR_PENDING_FLAG(FLASH_FLAG_WPEIF); + } + + if (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_OPTEIF) != RESET) { + FlashErrorCode |= FLASH_ERROR_OPT; + __LL_FLASH_CLEAR_PENDING_FLAG(FLASH_FLAG_OPTEIF); + } + + if (__LL_FLASH_GET_PENDING_FLAG(FLASH_FLAG_ECCEIF) != RESET) { + FlashErrorCode |= FLASH_ERROR_ECC; + __LL_FLASH_CLEAR_PENDING_FLAG(FLASH_FLAG_ECCEIF); + } +} + +/** + * @} + */ + + +#endif /* LL_FLASH_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_fpll.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_fpll.c new file mode 100644 index 0000000000..389621e922 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_fpll.c @@ -0,0 +1,166 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_fpll.c + * @author MCD Application Team + * @brief FPLL LL Module Driver + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "FPLL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup FPLL_LL FPLL LL + * @brief FPLL LL Module Driver + * @{ + */ + +#ifdef LL_FPLL_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup FPLL_LL_Exported_Functions FPLL LL Exported Functions + * @brief FPLL LL Exported Functions + * @{ + */ + +/** @defgroup FPLL_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and de-initialization functions + * @{ + */ + +/** + * @brief Initializes the FPLL peripheral + * @param Instance Specifies FPLL peripheral + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_FPLL_Init(FPLL_TypeDef *Instance) +{ + /* Init the low level hardware eg. Clock, NVIC */ + LL_FPLL_MspInit(Instance); + + return LL_OK; +} + +/** + * @brief DeInitializes the FPLL peripheral + * @param Instance Specifies FPLL peripheral + * @return Status of the DeInitialization + */ +LL_StatusETypeDef LL_FPLL_DeInit(FPLL_TypeDef *Instance) +{ + /* Init the low level hardware eg. Clock, NVIC */ + LL_FPLL_MspDeInit(Instance); + + return LL_OK; +} + +/** + * @brief Initializes the FPLL MSP + * @param Instance Specifies FPLL peripheral + * @retval None + */ +__WEAK void LL_FPLL_MspInit(FPLL_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_FPLL_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the FPLL MSP + * @param Instance Specifies FPLL peripheral + * @retval None + */ +__WEAK void LL_FPLL_MspDeInit(FPLL_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_FPLL_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + + +/** @defgroup FPLL_LL_Exported_Functions_Group2 FPLL Config Fucntions + * @brief FPLL Config Fucntions + * @{ + */ + +/** + * @brief FPLL LL Start + * @param Instance Specifies FPLL peripheral + * @param integer FPLL Div integer + * @param frac FPLL Div Fraction + * @return FPLL Start Result + */ +LL_StatusETypeDef LL_FPLL_DivStart(FPLL_TypeDef *Instance, uint16_t integer, uint16_t frac) +{ + if (Instance == NULL) { + LOG_E("FPLL Div config params error!\n"); + return LL_ERROR; + } + + __LL_FPLL_DivInt_Set(Instance, integer); + __LL_FPLL_DivFrac_Set(Instance, frac); + __LL_FPLL_En(Instance); + __LL_FPLL_Start(Instance); + + return LL_OK; +} +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_FPLL_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_gpio.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_gpio.c new file mode 100644 index 0000000000..f70d6e6221 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_gpio.c @@ -0,0 +1,471 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_gpio.c + * @author MCD Application Team + * @brief GPIO LL module driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "GPIO LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup GPIO_LL GPIO LL + * @brief GPIO LL module driver + * @{ + */ + +#ifdef LL_GPIO_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup GPIO_LL_Exported_Functions GPIO LL Exported Functions + * @brief GPIO LL Exported Functions + * @{ + */ + +/** @defgroup GPIO_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and Configuration functions + * +@verbatim + =============================================================================== + ##### Initialization and de-initialization functions ##### + =============================================================================== + [..] + This section provides functions allowing to initialize and de-initialize the GPIOs + to be ready for use. + +@endverbatim + * @{ + */ + +/** + * @brief Initializes the GPIOx peripheral according to the specified parameters in the GPIO_Init. + * @param GPIOx: where x can be (A, B, ... depending on device used) to select the GPIO peripheral + * @param GPIO_Init: pointer to a GPIO_InitTypeDef structure that contains + * the configuration information for the specified GPIO peripheral. + * @return status of the initialization + */ +LL_StatusETypeDef LL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init) +{ + uint32_t position = 0x00U; + uint32_t iocurrent; + /* Check the parameters */ + assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); + assert_param(IS_GPIO_PIN(GPIO_Init->Pin)); + + + /* Configure the port pins */ + while (((GPIO_Init->Pin) >> position) != 0x00U) { + /* Get current io position */ + iocurrent = (GPIO_Init->Pin) & (1UL << position); + + if (iocurrent != 0x00U) { + /*--------------------- GPIO Mode Configuration ------------------------*/ + switch (GPIO_Init->Mode & 0x03U) { + /*In case of Alternate function mode selection*/ + case GPIO_MODE_AF: + + /* Configure IO Direction mode (Input, Output, Alternate or Analog) */ + MODIFY_REG(GPIOx->PMUXR[position >> 3U], 0x0FU << ((position & 0x07U) * 4U), + (GPIO_Init->Alternate & 0x0FU) << ((position & 0x07U) * 4U)); + + /* Configure the IO Output Type */ + MODIFY_REG(GPIOx->OTYPR, 0x01U << position, (GPIO_Init->OType & 0x01U) << position); + + /* Configure the IO Speed */ + MODIFY_REG(GPIOx->OSRR, 0x01U << position, (GPIO_Init->Speed & 0x01U) << position); + break; + + /* In case of Input function mode selection */ + case GPIO_MODE_INPUT: + /* Configure IO Direction mode (Input) */ + MODIFY_REG(GPIOx->PMUXR[position >> 3U], 0x0FU << ((position & 0x07U) * 4U), + GPIO_AF0_INPUT << ((position & 0x07U) * 4U)); + + /* Interrupt Eanble */ + MODIFY_REG(GPIOx->ITER, 0x01U << position, ((GPIO_Init->Mode >> 28U) & 0x01U) << position); + + /* Rising/Falling Edge */ + MODIFY_REG(GPIOx->RFTSR, 0x01U << position, ((GPIO_Init->Mode >> 20U) & 0x01U) << position); + MODIFY_REG(GPIOx->RFTSR, 0x01U << (position + 16U), ((GPIO_Init->Mode >> 21U) & 0x01U) << (position + 16U)); + + /* GPIO Port Interrupt Enable */ + WRITE_REG(GPIOx->IER, (READ_REG(GPIOx->ITER) == 0x00UL) ? 0x00UL : 0x01UL); + + /* Clear Pending */ + WRITE_REG(GPIOx->PR, 0x01U << position); + break; + + /* In case of Output function mode selection */ + case GPIO_MODE_OUTPUT: + + /* Configure the IO Output Type */ + MODIFY_REG(GPIOx->PMUXR[position >> 3U], 0x0FU << ((position & 0x07U) * 4U), + GPIO_AF1_OUTPUT << ((position & 0x07U) * 4U)); + + /* Configure the IO Output Type */ + MODIFY_REG(GPIOx->OTYPR, 0x01U << position, (GPIO_Init->OType & 0x01U) << position); + + /* Configure the IO Speed */ + MODIFY_REG(GPIOx->OSRR, 0x01U << position, (GPIO_Init->Speed & 0x01U) << position); + break; + } + + + /* Activate the Pull-up resistor for the current IO */ + if (GPIO_Init->Pull == GPIO_PULLUP) { + SET_BIT(GPIOx->PUR, 0x01U << position); + CLEAR_BIT(GPIOx->PDR, 0x01U << position); + } + + /* Activate the Pull-dowm resistor for the current IO */ + if (GPIO_Init->Pull == GPIO_PULLDOWN) { + CLEAR_BIT(GPIOx->PUR, 0x01U << position); + SET_BIT(GPIOx->PDR, 0x01U << position); + } + + /* Unactivate the Pull-up or Pull down resistor for the current IO */ + if (GPIO_Init->Pull == GPIO_NOPULL) { + CLEAR_BIT(GPIOx->PUR, 0x01U << position); + CLEAR_BIT(GPIOx->PDR, 0x01U << position); + } + } + + position++; + } + + return LL_OK; +} + +/** + * @brief De-initializes the GPIOx peripheral registers to their default reset values. + * @param GPIOx: where x can be (A, B, ... depending on device used) to select the GPIO peripheral + * @param GPIO_Pin: specifies the port bit to be written. + * This parameter can be any combination of @ref GPIO_pins_define + * @return status of the de-initialization + */ +LL_StatusETypeDef LL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin) +{ + uint32_t position = 0x00U; + uint32_t iocurrent; + /* Check the parameters */ + assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + /* Configure the port pins */ + while ((GPIO_Pin >> position) != 0x00U) { + /* Get current io position */ + iocurrent = GPIO_Pin & (0x1U << position); + + if (iocurrent != 0x00U) { + /*------------------------- GPIO Mode Configuration --------------------*/ + /* Configure the default Alternate Function in current IO */ + MODIFY_REG(GPIOx->PMUXR[position >> 3U], (0x0FU << ((uint32_t)(position & 0x07U) * 4U)), + (GPIO_AF15_ANALOG << ((uint32_t)(position & 0x07U) * 4U))); + + /* Configure the default value for IO Speed */ + CLEAR_BIT(GPIOx->OSRR, 0x01U << position); + + /* Configure the default value IO Output Type */ + CLEAR_BIT(GPIOx->OTYPR, 0x01U << position); + + /* Deactivate the Pull-up and Pull-down resistor for the current IO */ + CLEAR_BIT(GPIOx->PDR, 0x01U << position); + CLEAR_BIT(GPIOx->PUR, 0x01U << position); + + /* Disable Interrupt Mask */ + CLEAR_BIT(GPIOx->ITER, 0x01U << position); + + /* Clear Rising Falling edge configuration */ + CLEAR_BIT(GPIOx->RFTSR, 0x01U << position); + CLEAR_BIT(GPIOx->RFTSR, 0x01U << (position + 16U)); + + /* Disable Interrupt */ + WRITE_REG(GPIOx->IER, (READ_REG(GPIOx->ITER) == 0) ? 0x00 : 0x01); + + /* Clear Pending */ + WRITE_REG(GPIOx->PR, 0x01U << position); + + /* Defalut value of data */ + CLEAR_BIT(GPIOx->DR, 0x01U << position); + } + + position++; + } + + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup GPIO_LL_Exported_Functions_Group2 GPIO Peripheral Control functions + * @brief GPIO Peripheral Control functions +@verbatim + =============================================================================== + ##### Peripheral Control functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) GPIO configure functions + +@endverbatim + * @{ + */ + +/** + * @brief Config the alternate function on runtime. + * @param GPIOx where x can be (A, B, ...) to select the GPIO peripheral for TXF53xx + * @param GPIO_Pin specifies the port bit to read. + * This parameter can be GPIO_PIN_x where x can be (0..15). + * @param Alternate Peripheral to be connected to the selected pins. + * This parameter can be a value of @ref GPIO_Alternate_function_selection + * @return None + */ +void LL_GPIO_AF_Config(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_AFETypeDef Alternate) +{ + uint32_t position = 0x00U; + uint32_t iocurrent; + + /* Check the parameters */ + assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + /* Configure the port pins */ + while (((GPIO_Pin) >> position) != 0x00U) { + /* Get current io position */ + iocurrent = (GPIO_Pin) & (1UL << position); + + if (iocurrent != 0x00U) { + /* Configure IO Direction mode (Input, Output, Alternate or Analog) */ + MODIFY_REG(GPIOx->PMUXR[position >> 3U], 0x0FU << ((position & 0x07U) * 4U), + (Alternate) << ((position & 0x07U) * 4U)); + } + + /* Next pin */ + position++; + } +} + +/** + * @} + */ + + +/** @defgroup GPIO_LL_Exported_Functions_Group3 GPIO IO operation functions + * @brief GPIO Read and Write + * +@verbatim + =============================================================================== + ##### IO operation functions ##### + =============================================================================== + [..] + This subsection provides a set of functions allowing to manage the GPIOs: + (+) Read the GPIOx Pins + (+) Write the GPIOx Pins + (+) Toggle the GPIOx Pins + (+) Write the GPIOx Port + (+) Read the GPIOx Port + +@endverbatim + * @{ + */ + +/** + * @brief Read the specified input port pin + * @param GPIOx where x can be (A, B, ...) to select the GPIO peripheral for TXF53xx + * @param GPIO_Pin specifies the port bit to read. + * This parameter can be GPIO_PIN_x where x can be (0..15). + * @return The input port pin value. + */ +GPIO_PinStateETypeDef LL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) +{ + GPIO_PinStateETypeDef bitstatus; + /* Check the parameters */ + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + if ((GPIOx->DR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET) { + bitstatus = GPIO_PIN_SET; + } else { + bitstatus = GPIO_PIN_RESET; + } + + return bitstatus; +} + +/** + * @brief Set or clear the selected data port bit. + * @param GPIOx: where x can be (A, B, ...) to select the GPIO peripheral. + * @param bit_field: specifies the port bit to read. + * This parameter can be GPIO_Pin_x where x can be (0..15). + * @param PinState specifies the value to be written to the selected bit. + * This parameter can be one of the GPIO_PinState enum values: + * @arg GPIO_PIN_RESET: to clear the port pin + * @arg GPIO_PIN_SET: to set the port pin + * @return None + */ +void LL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinStateETypeDef PinState) +{ + /* Check the parameters */ + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + if (PinState != GPIO_PIN_RESET) { + GPIOx->BSRR = GPIO_Pin; + } else { + GPIOx->BSRR = (uint32_t)GPIO_Pin << 16U; + } +} + +/** + * @brief Toggle the specified GPIO pin. + * @param GPIOx where x can be (A, B, ...) to select the GPIO peripheral. + * @param GPIO_Pin specifies the pin to be toggled. + * @return None + */ +void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); + assert_param(IS_GPIO_PIN(GPIO_Pin)); + + GPIOx->DR ^= (GPIO_Pin & GPIO_PIN_All); +} + +/** + * @brief Write data to the specified GPIO port. + * @param GPIOx where x can be (A, B, ...) to select the GPIO peripheral. + * @param Data data to write. + * @return None + */ +void LL_GPIO_WriteData(GPIO_TypeDef *GPIOx, uint16_t Data) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); + + WRITE_REG(GPIOx->DR, Data); +} + + +/** + * @brief Read data from the specified GPIO port. + * @param GPIOx where x can be (A, B, ...) to select the GPIO peripheral. + * @return GPIO port data + */ +uint16_t LL_GPIO_ReadData(GPIO_TypeDef *GPIOx) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); + + return READ_REG(GPIOx->DR) & 0xFFFFUL; +} + +/** + * @} + */ + + +/** @defgroup GPIO_LL_Exported_Functions_Interrupt GPIO Initerrupt management + * @brief GPIO Initerrupt management + * +@verbatim + ============================================================================== + ##### IRQ handler management ##### + ============================================================================== + [..] + This section provides GPIO IRQ handler function. + +@endverbatim + * @{ + */ + +/** + * @brief This function handles GPIO interrupts requests. + * @param GPIOx GPIO Port + * @return None + */ +void LL_GPIO_IRQHandler(GPIO_TypeDef *GPIOx) +{ + /* Check the parameters */ + assert_param(IS_GPIO_ALL_INSTANCE(GPIOx)); + + for (uint8_t position = 0x00U; position < GPIO_NUMBER; position++) { + if ((__LL_GPIO_IT_CHECK_SOURCE(GPIOx, 0x01U << position) != RESET) && + (__LL_GPIO_GET_IT(GPIOx, 0x01U << position)) != RESET) { + + __LL_GPIO_CLEAR_IT(GPIOx, 0x01U << position); + + /*Handle something*/ + LL_GPIO_ExtTrigCallback(GPIOx, 0x01U << position); + } + } +} + +/** + * @brief GPIO External Trigger detection callback. + * @param GPIOx GPIO Port + * @param GPIO_Pin witch trigger the interruption. + * @return None + */ +__WEAK void LL_GPIO_ExtTrigCallback(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(GPIOx); + LL_UNUSED(GPIO_Pin); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_GPIO_ExtTrigCallback could be implemented in the user file + */ +} +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_GPIO_MODULE_ENABLE */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_hrpwm.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_hrpwm.c new file mode 100644 index 0000000000..75ae37ec11 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_hrpwm.c @@ -0,0 +1,2961 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_hrpwm.c + * @author MCD Application Team + * @brief HRPWM LL module driver + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "HRPWM LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @addtogroup HRPWM_LL HRPWM LL + * @brief HRPWM LL module driver + * @{ + */ + +#ifdef LL_HRPWM_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/** @defgroup HRPWM_LL_Private_Functions HRPWM LL Private Functions + * @brief HRPWM LL Private Functions + * @{ + */ +static void HRPWM_MasterBase_Config(HRPWM_TypeDef *Instance, HRPWM_TimerBaseCfgTypeDef *pTimeBaseCfg); +static void HRPWM_TimingUnitBase_Config(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_TimerBaseCfgTypeDef *pTimeBaseCfg); +static void HRPWM_MasterCompare_Config(HRPWM_TypeDef *Instance, HRPWM_TimerCompareCfgTypeDef *pTimerCompCfg); +static void HRPWM_TimingUnitCompare_Config(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerCompareCfgTypeDef *pTimerCompCfg); +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup HRPWM_LL_Exported_Functions HRPWM LL Exported Functions + * @brief HRPWM LL Exported Functions + * @{ + */ + +/** @defgroup HRPWM_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and Configuration functions +@verbatim + =============================================================================== + ##### Initialization and Time Base Configuration functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Initialize a HRPWM instance + (+) De-initialize a HRPWM instance + (+) Initialize the HRPWM MSP + (+) De-initialize the HRPWM MSP + (+) Start the high-resolution unit and configure relevant paramter (start DLL calibration) + (+) Only Start the high-resolution (start DLL calibration) + (+) Configure the time base unit of a HRPWM timer +@endverbatim + * @{ + */ + +/** + * @brief Initialize a HRPWM instance + * @param pSync pointer to HRPWM_MasterSyncTypeDef + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_Init(HRPWM_TypeDef *Instance, HRPWM_MasterSyncTypeDef *pMasterSync) +{ + + uint32_t hrpwm_mcr; + + /* Init the low level hardware */ + LL_HRPWM_MspInit(Instance); + + /* HRPWM output synchronization configuration (if required) */ + if ((pMasterSync->SyncOptions & HRPWM_SYNCOPTION_MASTER) != (uint32_t)RESET) { + /* Check parameters */ + assert_param(IS_HRPWM_SYNCOUTPUTSOURCE(pMasterSync->SyncOutputSource)); + assert_param(IS_HRPWM_SYNCOUTPUTPOLARITY(pMasterSync->SyncOutputPolarity)); + + /* The synchronization output initialization procedure must be done prior + to the configuration of the MCU outputs (done within LL_HRPWM_MspInit) + */ + + hrpwm_mcr = Instance->Master.MCR; + + /* Set the event to be sent on the synchronization output */ + hrpwm_mcr &= ~(HRPWM_MCR_SYNCOUT_SRC); + hrpwm_mcr |= (pMasterSync->SyncOutputSource & HRPWM_MCR_SYNCOUT_SRC); + + /* Set the polarity of the synchronization output */ + hrpwm_mcr &= ~(HRPWM_MCR_SYNCOUT_POL); + hrpwm_mcr |= (pMasterSync->SyncOutputPolarity & HRPWM_MCR_SYNCOUT_POL); + + /* Set the polarity of the synchronization output */ + hrpwm_mcr &= ~(HRPWM_MCR_SYNCOUT_EN); + hrpwm_mcr |= (pMasterSync->SyncOutputEnable & HRPWM_MCR_SYNCOUT_EN); + + /* Update the HRPWM registers */ + Instance->Master.MCR = hrpwm_mcr; + } + + /* HRPWM input synchronization configuration (if required) MultiplePWM*/ + if ((pMasterSync->SyncOptions & HRPWM_SYNCOPTION_SLAVE) != (uint32_t)RESET) { + /* Check parameters */ + assert_param(IS_HRPWM_SYNINPUTSOURCE(pMasterSync->SyncInputSource)); + + hrpwm_mcr = Instance->Master.MCR; + + /* Set the synchronization input */ + hrpwm_mcr &= ~(HRPWM_MCR_SYNCIN_EN | HRPWM_MCR_SYNCIN_SRC); + hrpwm_mcr |= (pMasterSync->SyncInputSource & (HRPWM_MCR_SYNCIN_EN | HRPWM_MCR_SYNCIN_SRC)); + + /* Update the HRPWM registers */ + Instance->Master.MCR = hrpwm_mcr; + } + + + return LL_OK; +} + +/** + * @brief De-initialize a HRPWM instance + * @param hhrpwm pointer to LL HRPWM handle + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_DeInit(HRPWM_TypeDef *Instance) +{ + /*stop all counter and output*/ + __LL_HRPWM_ALL_TIMER_DISABLE(Instance); + __LL_HRPWM_OUTPUT_STOP(HRPWM_OUTPUT_ODIS0A | HRPWM_OUTPUT_ODIS0B | + HRPWM_OUTPUT_ODIS1A | HRPWM_OUTPUT_ODIS1B | + HRPWM_OUTPUT_ODIS2A | HRPWM_OUTPUT_ODIS2B | + HRPWM_OUTPUT_ODIS3A | HRPWM_OUTPUT_ODIS3B | + HRPWM_OUTPUT_ODIS4A | HRPWM_OUTPUT_ODIS4B | + HRPWM_OUTPUT_ODIS5A | HRPWM_OUTPUT_ODIS5B + ); + /* DeInit the low level hardware */ + LL_HRPWM_MspDeInit(Instance); + + return LL_OK; +} + +/** + * @brief MSP initialization for a HRPWM instance + * @retval None + */ +__WEAK void LL_HRPWM_MspInit(HRPWM_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_HRPWM_MspInit could be implemented in the user file + */ +} + +/** + * @brief MSP de-initialization of a HRPWM instance + * @retval None + */ +__WEAK void LL_HRPWM_MspDeInit(HRPWM_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_HRPWM_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + + +/** @defgroup HRPWM_LL_Exported_Functions_Group2 HRPWM Config Functions + * @brief HRPWM Config Functions + * @{ + */ + +/** + * @brief Start the DLL configuration + * @param CalibrationRate DLL calibration period + * This parameter can be one of the following values: + * @arg HRPWM_DLLCR_DLLGCP + * @retval LL status + * @note LL_HRPWM_DLLCalibration function, just before exiting the function. + */ +LL_StatusETypeDef LL_HRPWM_DLLStartConfig(HRPWM_TypeDef *Instance, HRPWM_DLLCfgTypedef *DLLConfig) +{ + uint32_t temp_dllcr; + /* Check the parameters */ + assert_param(IS_HRPWM_DLLGCP(DLLConfig->CurrentSel)); + + temp_dllcr = Instance->Common.DLLCR; + + /*config dll paramter*/ + temp_dllcr &= ~(HRPWM_DLLCR_DLLGCP | HRPWM_DLLCR_DLLTHRES1 | HRPWM_DLLCR_DLLTHRES0); + temp_dllcr |= (DLLConfig->CurrentSel & HRPWM_DLLCR_DLLGCP) | + ((DLLConfig->ClockDelayThres0 << 11U) & HRPWM_DLLCR_DLLTHRES0) | + ((DLLConfig->ClockDelayThres1 << 6U) & HRPWM_DLLCR_DLLTHRES1); + + /*enable dll and start*/ + temp_dllcr |= (HRPWM_DLLCR_DLLEN | HRPWM_DLLCR_DLLSTART); + + /*configuration current*/ + Instance->Common.DLLCR = temp_dllcr; + + return LL_OK; +} + +/** + * @brief Start the DLL + * @retval LL status + * @note Only enable and start DLL, do not do other related parameter configuration, use the default value. + */ +LL_StatusETypeDef LL_HRPWM_DLLStart(HRPWM_TypeDef *Instance) +{ + /*enable dll and start*/ + Instance->Common.DLLCR |= (HRPWM_DLLCR_DLLEN | HRPWM_DLLCR_DLLSTART); + /*Start 20us after DLL is started, wait for 1ms to stabilize*/ + return LL_OK; +} + +/** + * @brief Configure the time base unit of a timer + * @param hhrpwm pointer to LL HRPWM handle + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @param pTimeBaseCfg pointer to the time base configuration structure + * @note This function must be called prior starting the timer + * @note The time-base unit initialization parameters specify: + * The timer counter operating mode (continuous, one shot), + * The timer clock prescaler, + * The timer period, + * The timer repetition counter. + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_TimerBaseConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_TimerBaseCfgTypeDef *pTimeBaseCfg) +{ + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_SYNCSTART(pTimeBaseCfg->StartOnSync)); + assert_param(IS_HRPWM_SYNCRESET(pTimeBaseCfg->ResetOnSync)); + assert_param(IS_HRPWM_PRESCALERRATIO(pTimeBaseCfg->PrescalerRatio)); + assert_param(IS_HRPWM_MODE(pTimeBaseCfg->Mode)); + + if (TimerIdx == HRPWM_INDEX_MASTER) { + assert_param(IS_HRPWM_MASTER_IT(pTimeBaseCfg->InterruptRequests)); + /* Configure master timer time base unit */ + HRPWM_MasterBase_Config(Instance, pTimeBaseCfg); + } else { + /* Check parameters */ + assert_param(IS_HRPWM_TIMER_IT(pTimeBaseCfg->InterruptRequests)); + assert_param(IS_HRPWM_RST_EVENT(pTimeBaseCfg->ResetTrigger)); + assert_param(IS_HRPWM_RESYNCUPDATE(pTimeBaseCfg->ReSyncUpdate)); + /* Configure timing unit time base unit */ + HRPWM_TimingUnitBase_Config(Instance, TimerIdx, pTimeBaseCfg); + } + + return LL_OK; +} + +/** + * @brief Configure the general behavior of a timer operating in waveform mode + * @param hhrpwm pointer to LL HRPWM handle + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @param TimeBaseCfg pointer to the time base configuration structure + * @note This function must be called prior starting the timer + * @note The time-base unit initialization parameters specify: + * The timer counter operating mode (continuous, one shot), + * The timer clock prescaler, + * The timer period, + * The timer repetition counter. + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_TimerCompareConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerCompareCfgTypeDef *pTimerCompCfg) +{ + /* Check the parameters, Relevant for all HRPWM timers, including the master*/ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_PRELOAD(pTimerCompCfg->PreloadEnable)); + + + if (TimerIdx == HRPWM_INDEX_MASTER) { + /* Configure master timer time base unit */ + HRPWM_MasterCompare_Config(Instance, pTimerCompCfg); + } else { + assert_param(IS_HRPWM_UPDATETRIGGER(pTimerCompCfg->UpdateTrigger)); + /* Configure timing unit time base unit */ + HRPWM_TimingUnitCompare_Config(Instance, TimerIdx, pTimerCompCfg); + } + + return LL_OK; +} +/** + * @} + */ + + +/** @defgroup HRPWM_LL_Exported_Functions_Group3 HRPWM Simple time base mode functions + * @brief HRPWM Simple time base mode functions +@verbatim + =============================================================================== + ##### Simple time base mode functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Start simple time base counter + (+) Stop simple time base counter + -@- When a HRPWM timer operates in simple time base mode, the timer + counter counts from 0 to the period value. +@endverbatim + * @{ + */ + +/** + * @brief Start the counter of a timer operating in simple time base mode. + * @param hhrpwm pointer to HAL HRPWM handle + * @param TimerIdx Timer index. + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval HAL status + */ +LL_StatusETypeDef LL_HRPWM_StartCounter(uint32_t TimerIdx) +{ + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + /* Enable the timer counter */ + __LL_HRPWM_TIMER_ENABLE(TimerIdx); + + return LL_OK; +} + +/** + * @brief Stop the counter of a timer operating in simple time base mode. + * @param hhrpwm pointer to HAL HRPWM handle + * @param TimerIdx Timer index. + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval HAL status + */ +LL_StatusETypeDef LL_HRPWM_StopCounter(uint32_t TimerIdx) +{ + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + /* Disable the timer counter */ + __LL_HRPWM_TIMER_DISABLE(TimerIdx); + + return LL_OK; +} +/** + * @} + */ + + +/** @defgroup HRPWM_LL_Exported_Functions_Group4 HRPWM Simple PWM output mode functions + * @brief HRPWM Simple PWM output functions +@verbatim + =============================================================================== + ##### Simple PWM output functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Configure the contrl refister - rollover mode + (+) Configure the Dual Channel Dac behavior + (+) Configure updown counter rollover mode + -@- When a HRPWM timer operates in simple output compare mode + the output level is set to a programmable value when a match + is found between the compare register and the counter. + Compare unit A is automatically associated to output A + Compare unit B is automatically associated to output B +@endverbatim + * @{ + */ + +/** + * @brief Configure the Dual Channel Dac behavior and updown count rollover mode + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @param pTimerRollOverCfg pointer to the timer RollOver configuration structure + * @note When the timer operates in waveform mode, all the features supported by + * the HRPWM are available without any limitation. + * @retval LL status + * @note This function must be called before starting the timer + */ +LL_StatusETypeDef LL_HRPWM_TimerUintRollOverContrl(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerRollOverCfgTypeDef *pTimerRollOverCfg) +{ + if (TimerIdx == HRPWM_INDEX_MASTER) { + return LL_ERROR; + } + + uint32_t hrpwm_cr1; + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_ROLLOVERMODE(pTimerRollOverCfg->RollOverMode)); + assert_param(IS_HRPWM_OUTPUTROLLOVERMODE(pTimerRollOverCfg->OutputRollOverMode)); + assert_param(IS_HRPWM_ADCROLLOVERMODE(pTimerRollOverCfg->AdcRollOverMode)); + assert_param(IS_HRPWM_FLTROLLOVERMODE(pTimerRollOverCfg->FaultRollOverMode)); + assert_param(IS_HRPWM_EVTROLLOVERMODE(pTimerRollOverCfg->EeventRollOverMode)); + + /* Configure timing unit (Timer 0 to Timer 5) */ + hrpwm_cr1 = Instance->PWM[TimerIdx].CR1; + + if (pTimerRollOverCfg->UpDownMode == HRPWM_CR1_UDM) { + /* Set the UpDown counting Mode */ + hrpwm_cr1 &= ~(HRPWM_CR1_UDM | HRPWM_CR1_ROM | HRPWM_CR1_OUTROM | HRPWM_CR1_ADROM | HRPWM_CR1_FLTROM | + HRPWM_CR1_EEVROM); + hrpwm_cr1 |= ((pTimerRollOverCfg->OutputRollOverMode & HRPWM_CR1_OUTROM) | + (pTimerRollOverCfg->UpDownMode & HRPWM_CR1_UDM) | + (pTimerRollOverCfg->RollOverMode & HRPWM_CR1_ROM) | + (pTimerRollOverCfg->AdcRollOverMode & HRPWM_CR1_ADROM) | + (pTimerRollOverCfg->FaultRollOverMode & HRPWM_CR1_FLTROM) | + (pTimerRollOverCfg->EeventRollOverMode & HRPWM_CR1_EEVROM)); + } + + /* Update the HRPWM registers */ + Instance->PWM[TimerIdx].CR1 |= hrpwm_cr1; + + return LL_OK; +} + +/** + * @brief Configure the Dual Channel Dac behavior of a timer operating in waveform mode + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @param pTimerDacCfg pointer to the timer DualChannel Dac configuration structure + * @note When the timer operates in waveform mode, all the features supported by + * the HRPWM are available without any limitation. + * @retval LL status + * @note This function must be called before starting the timer + */ +LL_StatusETypeDef LL_HRPWM_TimerDualChannelDacConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerDaulDacCfgTypeDef *pTimerDacCfg) +{ + if (TimerIdx == HRPWM_INDEX_MASTER) { + return LL_ERROR; + } + + uint32_t hrpwm_cr1; + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_DUALDAC_RESET(pTimerDacCfg->DualChannelDacReset)); + assert_param(IS_HRPWM_DUALDAC_STEP(pTimerDacCfg->DualChannelDacStep)); + assert_param(IS_HRPWM_DUALDAC_ENABLE(pTimerDacCfg->DualChannelDacEnable)); + + + /* Configure timing unit (Timer 0 to Timer 5) */ + hrpwm_cr1 = Instance->PWM[TimerIdx].CR1; + + if (pTimerDacCfg->DualChannelDacEnable == HRPWM_DAC_DCDE_ENABLE) { + /* Set the DualChannel DAC Reset trigger : requires DCDE enabled */ + hrpwm_cr1 &= ~(HRPWM_CR1_DCDR); + hrpwm_cr1 |= pTimerDacCfg->DualChannelDacReset; + + /* Set the DualChannel DAC Step trigger : requires DCDE enabled */ + hrpwm_cr1 &= ~(HRPWM_CR1_DCDS); + hrpwm_cr1 |= pTimerDacCfg->DualChannelDacStep; + + /* Enable the DualChannel DAC trigger */ + hrpwm_cr1 &= ~(HRPWM_CR1_DCDE); + hrpwm_cr1 |= pTimerDacCfg->DualChannelDacEnable; + } + + /* Update the HRPWM registers */ + Instance->PWM[TimerIdx].CR1 |= hrpwm_cr1; + + return LL_OK; +} + +/** + * @brief Configure timing RollOver Mode (Timer 0 to Timer 5) + * @param TimerIdx Timer index + * @param pRollOverMode: a combination of the timer RollOver Mode configuration + * @arg HRPWM_Timer_RollOver_Mode relevant paramter + * @arg HRPWM_Timer_Output_RollOver_Mode relevant paramter + * @arg HRPWM_Timer_ADTrig_RollOver_Mode relevant paramter + * @arg HRPWM_Timer_Event_RollOver_Mode relevant paramter + * @arg HRPWM_Timer_Fault_RollOver_Mode relevant paramter + * @arg HRPWM_Timer_UpDown_Mode relevant paramter + * eg: HRPWM_FLTROM_ZERO | HRPWM_ADROM_BOTH + * Rollover can be configured in several modes or together, Only valid in updowm counting mode + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_TimerRollOverMode(HRPWM_TypeDef *Instance, uint32_t TimerIdx, uint32_t pRollOverMode) +{ + if (TimerIdx == HRPWM_INDEX_MASTER) { + return LL_ERROR; + } + + uint32_t hrpwm_cr1; + + /* Configure timing unit (Timer 0 to Timer 5) */ + hrpwm_cr1 = Instance->PWM[TimerIdx].CR1; + + /*The following modes are only valid in updown counting mode, so first determine if they are in updown counting mode*/ + if (((hrpwm_cr1 & HRPWM_CR1_UDM) != 0U) || ((pRollOverMode & HRPWM_CR1_UDM) != 0U)) { + /* xxROM bitfield must be reset before programming a new value */ + hrpwm_cr1 &= ~(HRPWM_CR1_ROM | HRPWM_CR1_OUTROM | HRPWM_CR1_ADROM | HRPWM_CR1_FLTROM | HRPWM_CR1_EEVROM); + + /* Update the HRPWM TIMER CR1 register , start updown counter mode*/ + hrpwm_cr1 |= (pRollOverMode & (HRPWM_CR1_ROM | HRPWM_CR1_OUTROM | HRPWM_CR1_ADROM | HRPWM_CR1_FLTROM | HRPWM_CR1_EEVROM)) | + HRPWM_CR1_UDM; + + Instance->PWM[TimerIdx].CR1 |= hrpwm_cr1; + } + + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup HRPWM_LL_Exported_Functions_Group5 HRPWM Configuration functions + * @brief HRPWM Configuration functions +@verbatim + =============================================================================== + ##### HRPWM configuration functions ##### + =============================================================================== + [..] This section provides functions allowing to configure the HRPWM + resources shared by all the HRPWM timers operating in waveform mode: + (+) Configure a fault inputs conditioning + (+) Configure the faults blanking + (+) Configure the faults counter + (+) Configure the faults counter Reset + (+) Configure an ADC trigger + (+) Configure an output level & polarity + (+) Configure dead-time value + (+) Configure chopper output & freq\duty + (+) Configure an external event conditioning + (+) Configure the external events A conditioning + (+) Configure the external events A filter windows and latch +@endverbatim + * @{ + */ + +/** + * @brief Configure the conditioning of fault input + * @param Fault fault input to configure + * This parameter can be one of the following values: + * @arg HRPWM_FAULT_0: Fault input 0 + * @arg HRPWM_FAULT_1: Fault input 1 + * @arg HRPWM_FAULT_2: Fault input 2 + * @arg HRPWM_FAULT_3: Fault input 3 + * @arg HRPWM_FAULT_4: Fault input 4 + * @arg HRPWM_FAULT_5: Fault input 5 + * @param pFaultCfg pointer to the fault conditioning configuration structure + * @param pFaultBlkCfg pointer to the fault blanking conditioning configuration structure + * @note This function must be called before starting the timer and before + * enabling faults inputs + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_FaultConfig(HRPWM_TypeDef *Instance, uint32_t Fault, + HRPWM_FaultCfgTypeDef *pFaultCfg, + HRPWM_FaultBlankingCfgTypeDef *pFaultBlkCfg) +{ + uint32_t hrpwm_fltinr0; + uint32_t hrpwm_fltinr1; + uint32_t hrpwm_fltinr2; + uint32_t hrpwm_fltinr3; + + /* Check parameters */ + assert_param(IS_HRPWM_FAULT(Fault)); + assert_param(IS_HRPWM_FAULT_IT(pFaultCfg->InterruptEn)); + assert_param(IS_HRPWM_FAULTSOURCE(pFaultCfg->Source)); + assert_param(IS_HRPWM_FAULTPOLARITY(pFaultCfg->Polarity)); + assert_param(IS_HRPWM_FAULTFILTER(pFaultCfg->Filter)); + assert_param(IS_HRPWM_FAULTSAMPCLK(pFaultCfg->SampClockDiv)); + assert_param(IS_HRPWM_FAULTBLKEN(pFaultBlkCfg->BlankingEnable)); + assert_param(IS_HRPWM_FAULTBLKSRC(pFaultBlkCfg->BlankingSource)); + assert_param(IS_HRPWM_FAULTRSTMODE(pFaultBlkCfg->ResetMode)); + + + /* Configure fault channel */ + hrpwm_fltinr0 = Instance->Common.FLTINR0; + hrpwm_fltinr1 = Instance->Common.FLTINR1; + hrpwm_fltinr2 = Instance->Common.FLTINR2; + hrpwm_fltinr3 = Instance->Common.FLTINR3; + + switch (Fault) { + case HRPWM_FAULT_0: { + /*clear relevant register bit */ + hrpwm_fltinr0 &= ~(HRPWM_FLTINR0_FLT0SRC | HRPWM_FLTINR0_FLT0P | HRPWM_FLTINR0_FLT0E); + /*Configure fault enable */ + hrpwm_fltinr0 |= (pFaultCfg->Enable & HRPWM_FLTINR0_FLT0E); + /*Configure fault polarity */ + hrpwm_fltinr0 |= (pFaultCfg->Polarity & HRPWM_FLTINR0_FLT0P); + /*Configure fault source */ + hrpwm_fltinr0 |= (pFaultCfg->Source & HRPWM_FLTINR0_FLT0SRC); + /*Configure fault filter counter */ + hrpwm_fltinr1 &= ~(HRPWM_FLTINR1_FLT0F); + hrpwm_fltinr1 |= (pFaultCfg->Filter & HRPWM_FLTINR1_FLT0F); + /*Configure fault blanking function */ + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT0BLKE | HRPWM_FLTINR2_FLT0BLKS | HRPWM_FLTINR2_FLT0RSTM); + hrpwm_fltinr2 |= (pFaultBlkCfg->BlankingEnable & HRPWM_FLTINR2_FLT0BLKE) | + (pFaultBlkCfg->BlankingSource & HRPWM_FLTINR2_FLT0BLKS) | + (pFaultBlkCfg->ResetMode & HRPWM_FLTINR2_FLT0RSTM); + /*Configure fault count the number of edges */ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT0CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT0CNT); + + /*enable interrupt*/ + SET_BIT(Instance->Common.IER, (pFaultCfg->InterruptEn & HRPWM_IT_FLT0)); + } + break; + + case HRPWM_FAULT_1: { + /*clear relevant register bit */ + hrpwm_fltinr0 &= ~(HRPWM_FLTINR0_FLT1SRC | HRPWM_FLTINR0_FLT1P | HRPWM_FLTINR0_FLT1E); + /*Configure fault enable */ + hrpwm_fltinr0 |= ((pFaultCfg->Enable << 4U) & HRPWM_FLTINR0_FLT1E); + /*Configure fault polarity */ + hrpwm_fltinr0 |= ((pFaultCfg->Polarity << 4U) & HRPWM_FLTINR0_FLT1P); + /*Configure fault source */ + hrpwm_fltinr0 |= ((pFaultCfg->Source << 4U) & HRPWM_FLTINR0_FLT1SRC); + /*Configure fault filter counter */ + hrpwm_fltinr1 &= ~(HRPWM_FLTINR1_FLT1F); + hrpwm_fltinr1 |= ((pFaultCfg->Filter << 4U) & HRPWM_FLTINR1_FLT1F); + /*Configure fault blanking function */ + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT1BLKE | HRPWM_FLTINR2_FLT1BLKS | HRPWM_FLTINR2_FLT1RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 4U) & HRPWM_FLTINR2_FLT1BLKE) | + ((pFaultBlkCfg->BlankingSource << 4U) & HRPWM_FLTINR2_FLT1BLKS) | + ((pFaultBlkCfg->ResetMode << 4U) & HRPWM_FLTINR2_FLT1RSTM); + /*Configure fault count the number of edges */ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT1CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT1CNT); + + /*enable interrupt*/ + SET_BIT(Instance->Common.IER, (pFaultCfg->InterruptEn & HRPWM_IT_FLT1)); + } + break; + + case HRPWM_FAULT_2: { + /*clear relevant register bit */ + hrpwm_fltinr0 &= ~(HRPWM_FLTINR0_FLT2SRC | HRPWM_FLTINR0_FLT2P | HRPWM_FLTINR0_FLT2E); + /*Configure fault enable */ + hrpwm_fltinr0 |= ((pFaultCfg->Enable << 8U) & HRPWM_FLTINR0_FLT2E); + /*Configure fault polarity */ + hrpwm_fltinr0 |= ((pFaultCfg->Polarity << 8U) & HRPWM_FLTINR0_FLT2P); + /*Configure fault source */ + hrpwm_fltinr0 |= ((pFaultCfg->Source << 8U) & HRPWM_FLTINR0_FLT2SRC); + /*Configure fault filter counter */ + hrpwm_fltinr1 &= ~(HRPWM_FLTINR1_FLT2F); + hrpwm_fltinr1 |= ((pFaultCfg->Filter << 8U) & HRPWM_FLTINR1_FLT2F); + /*Configure fault blanking function */ + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT2BLKE | HRPWM_FLTINR2_FLT2BLKS | HRPWM_FLTINR2_FLT2RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 8U) & HRPWM_FLTINR2_FLT2BLKE) | + ((pFaultBlkCfg->BlankingSource << 8U) & HRPWM_FLTINR2_FLT2BLKS) | + ((pFaultBlkCfg->ResetMode << 8U) & HRPWM_FLTINR2_FLT2RSTM); + /*Configure fault count the number of edges */ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT2CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT2CNT); + + /*enable interrupt*/ + SET_BIT(Instance->Common.IER, (pFaultCfg->InterruptEn & HRPWM_IT_FLT2)); + } + break; + + case HRPWM_FAULT_3: { + /*clear relevant register bit */ + hrpwm_fltinr0 &= ~(HRPWM_FLTINR0_FLT3SRC | HRPWM_FLTINR0_FLT3P | HRPWM_FLTINR0_FLT3E); + /*Configure fault enable */ + hrpwm_fltinr0 |= ((pFaultCfg->Enable << 12U) & HRPWM_FLTINR0_FLT3E); + /*Configure fault polarity */ + hrpwm_fltinr0 |= ((pFaultCfg->Polarity << 12U) & HRPWM_FLTINR0_FLT3P); + /*Configure fault source */ + hrpwm_fltinr0 |= ((pFaultCfg->Source << 12U) & HRPWM_FLTINR0_FLT3SRC); + /*Configure fault filter counter */ + hrpwm_fltinr1 &= ~(HRPWM_FLTINR1_FLT3F); + hrpwm_fltinr1 |= ((pFaultCfg->Filter << 12U) & HRPWM_FLTINR1_FLT3F); + /*Configure fault blanking function */ + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT3BLKE | HRPWM_FLTINR2_FLT3BLKS | HRPWM_FLTINR2_FLT3RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 12U) & HRPWM_FLTINR2_FLT3BLKE) | + ((pFaultBlkCfg->BlankingSource << 12U) & HRPWM_FLTINR2_FLT3BLKS) | + ((pFaultBlkCfg->ResetMode << 12U) & HRPWM_FLTINR2_FLT3RSTM); + /*Configure fault count the number of edges */ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT3CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT3CNT); + + /*enable interrupt*/ + SET_BIT(Instance->Common.IER, (pFaultCfg->InterruptEn & HRPWM_IT_FLT3)); + } + break; + + case HRPWM_FAULT_4: { + /*clear relevant register bit */ + hrpwm_fltinr0 &= ~(HRPWM_FLTINR0_FLT4SRC | HRPWM_FLTINR0_FLT4P | HRPWM_FLTINR0_FLT4E); + /*Configure fault enable */ + hrpwm_fltinr0 |= ((pFaultCfg->Enable << 16U) & HRPWM_FLTINR0_FLT4E); + /*Configure fault polarity */ + hrpwm_fltinr0 |= ((pFaultCfg->Polarity << 16U) & HRPWM_FLTINR0_FLT4P); + /*Configure fault source */ + hrpwm_fltinr0 |= ((pFaultCfg->Source << 16U) & HRPWM_FLTINR0_FLT4SRC); + /*Configure fault filter counter */ + hrpwm_fltinr1 &= ~(HRPWM_FLTINR1_FLT4F); + hrpwm_fltinr1 |= ((pFaultCfg->Filter << 16U) & HRPWM_FLTINR1_FLT4F); + /*Configure fault blanking function */ + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT4BLKE | HRPWM_FLTINR2_FLT4BLKS | HRPWM_FLTINR2_FLT4RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 16U) & HRPWM_FLTINR2_FLT4BLKE) | + ((pFaultBlkCfg->BlankingSource << 16U) & HRPWM_FLTINR2_FLT4BLKS) | + ((pFaultBlkCfg->ResetMode << 16U) & HRPWM_FLTINR2_FLT4RSTM); + /*Configure fault count the number of edges */ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT4CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT4CNT); + + /*enable interrupt*/ + SET_BIT(Instance->Common.IER, (pFaultCfg->InterruptEn & HRPWM_IT_FLT4)); + } + break; + + case HRPWM_FAULT_5: { + /*clear relevant register bit */ + hrpwm_fltinr0 &= ~(HRPWM_FLTINR0_FLT5SRC | HRPWM_FLTINR0_FLT5P | HRPWM_FLTINR0_FLT5E); + /*Configure fault enable */ + hrpwm_fltinr0 |= ((pFaultCfg->Enable << 20U) & HRPWM_FLTINR0_FLT5E); + /*Configure fault polarity */ + hrpwm_fltinr0 |= ((pFaultCfg->Polarity << 20U) & HRPWM_FLTINR0_FLT5P); + /*Configure fault source */ + hrpwm_fltinr0 |= ((pFaultCfg->Source << 20U) & HRPWM_FLTINR0_FLT5SRC); + /*Configure fault filter counter */ + hrpwm_fltinr1 &= ~(HRPWM_FLTINR1_FLT5F); + hrpwm_fltinr1 |= ((pFaultCfg->Filter << 20U) & HRPWM_FLTINR1_FLT5F); + /*Configure fault blanking function */ + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT5BLKE | HRPWM_FLTINR2_FLT5BLKS | HRPWM_FLTINR2_FLT5RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 20U) & HRPWM_FLTINR2_FLT5BLKE) | + ((pFaultBlkCfg->BlankingSource << 20U) & HRPWM_FLTINR2_FLT5BLKS) | + ((pFaultBlkCfg->ResetMode << 20U) & HRPWM_FLTINR2_FLT5RSTM); + /*Configure fault count the number of edges */ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT5CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT5CNT); + + /*enable interrupt*/ + SET_BIT(Instance->Common.IER, (pFaultCfg->InterruptEn & HRPWM_IT_FLT5)); + } + break; + + case HRPWM_SYSFAULT: { + /*enable interrupt*/ + SET_BIT(Instance->Common.IER, (pFaultCfg->InterruptEn & HRPWM_IT_SYSFLT)); + } + break; + + default: + break; + } + + Instance->Common.FLTINR0 = hrpwm_fltinr0; + /* Configure the fault conditioning block prescaler */ + Instance->Common.FLTINR1 &= (~(HRPWM_FLTINR1_FLTSD)); + Instance->Common.FLTINR1 |= hrpwm_fltinr1 | (pFaultCfg->SampClockDiv & HRPWM_FLTINR1_FLTSD); + + Instance->Common.FLTINR2 = hrpwm_fltinr2; + Instance->Common.FLTINR3 = hrpwm_fltinr3; + + return LL_OK; +} + +/** + * @brief Configure the conditioning of fault blanking + * @param Fault fault input to configure + * This parameter can be one of the following values: + * @arg HRPWM_FAULT_0: Fault input 0 + * @arg HRPWM_FAULT_1: Fault input 1 + * @arg HRPWM_FAULT_2: Fault input 2 + * @arg HRPWM_FAULT_3: Fault input 3 + * @arg HRPWM_FAULT_4: Fault input 4 + * @arg HRPWM_FAULT_5: Fault input 5 + * @param pFaultBlkCfg pointer to the fault blanking conditioning configuration structure + * @note This function must be called before starting the timer and before + * enabling faults inputs, Configure blanking only without enabling; + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_FaultBlankingConfig(HRPWM_TypeDef *Instance, uint32_t Fault, + HRPWM_FaultBlankingCfgTypeDef *pFaultBlkCfg) +{ + uint32_t hrpwm_fltinr2; + + /* Check parameters */ + assert_param(IS_HRPWM_FAULT(Fault)); + assert_param(IS_HRPWM_FAULTBLKEN(pFaultBlkCfg->BlankingEnable)); + assert_param(IS_HRPWM_FAULTBLKSRC(pFaultBlkCfg->BlankingSource)); + assert_param(IS_HRPWM_FAULTRSTMODE(pFaultBlkCfg->ResetMode)); + + /* Configure fault blanking channel */ + hrpwm_fltinr2 = Instance->Common.FLTINR2; + + switch (Fault) { + case HRPWM_FAULT_0: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT0BLKE | HRPWM_FLTINR2_FLT0BLKS | HRPWM_FLTINR2_FLT0RSTM); + hrpwm_fltinr2 |= (pFaultBlkCfg->BlankingEnable & HRPWM_FLTINR2_FLT0BLKE) | + (pFaultBlkCfg->BlankingSource & HRPWM_FLTINR2_FLT0BLKS) | + (pFaultBlkCfg->ResetMode & HRPWM_FLTINR2_FLT0RSTM); + } + break; + + case HRPWM_FAULT_1: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT1BLKE | HRPWM_FLTINR2_FLT1BLKS | HRPWM_FLTINR2_FLT1RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 4U) & HRPWM_FLTINR2_FLT1BLKE) | + ((pFaultBlkCfg->BlankingSource << 4U) & HRPWM_FLTINR2_FLT1BLKS) | + ((pFaultBlkCfg->ResetMode << 4U) & HRPWM_FLTINR2_FLT1RSTM); + } + break; + + case HRPWM_FAULT_2: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT2BLKE | HRPWM_FLTINR2_FLT2BLKS | HRPWM_FLTINR2_FLT2RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 8U) & HRPWM_FLTINR2_FLT2BLKE) | + ((pFaultBlkCfg->BlankingSource << 8U) & HRPWM_FLTINR2_FLT2BLKS) | + ((pFaultBlkCfg->ResetMode << 8U) & HRPWM_FLTINR2_FLT2RSTM); + + } + break; + + case HRPWM_FAULT_3: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT3BLKE | HRPWM_FLTINR2_FLT3BLKS | HRPWM_FLTINR2_FLT3RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 12U) & HRPWM_FLTINR2_FLT3BLKE) | + ((pFaultBlkCfg->BlankingSource << 12U) & HRPWM_FLTINR2_FLT3BLKS) | + ((pFaultBlkCfg->ResetMode << 12U) & HRPWM_FLTINR2_FLT3RSTM); + } + break; + + case HRPWM_FAULT_4: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT4BLKE | HRPWM_FLTINR2_FLT4BLKS | HRPWM_FLTINR2_FLT4RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 16U) & HRPWM_FLTINR2_FLT4BLKE) | + ((pFaultBlkCfg->BlankingSource << 16U) & HRPWM_FLTINR2_FLT4BLKS) | + ((pFaultBlkCfg->ResetMode << 16U) & HRPWM_FLTINR2_FLT4RSTM); + + } + break; + + case HRPWM_FAULT_5: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT5BLKE | HRPWM_FLTINR2_FLT5BLKS | HRPWM_FLTINR2_FLT5RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->BlankingEnable << 20U) & HRPWM_FLTINR2_FLT5BLKE) | + ((pFaultBlkCfg->BlankingSource << 20U) & HRPWM_FLTINR2_FLT5BLKS) | + ((pFaultBlkCfg->ResetMode << 20U) & HRPWM_FLTINR2_FLT5RSTM); + + } + break; + + default: + break; + } + + + Instance->Common.FLTINR2 = hrpwm_fltinr2; + + return LL_OK; +} + +/** + * @brief Configure the Fault Counter (Threshold and Reset Mode) + * @param Fault fault input to configure + * This parameter can be one of the following values: + * @arg HRPWM_FAULT_0: Fault input 0 + * @arg HRPWM_FAULT_1: Fault input 1 + * @arg HRPWM_FAULT_2: Fault input 2 + * @arg HRPWM_FAULT_3: Fault input 3 + * @arg HRPWM_FAULT_4: Fault input 4 + * @arg HRPWM_FAULT_5: Fault input 5 + * @param pFaultBlkCfg: pointer to the fault conditioning configuration structure + * @retval LL status + * @note A fault is considered valid when the number of + * events is equal to the (FLTxCNT[3:0]+1) value + * + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_FaultCounterConfig(HRPWM_TypeDef *Instance, uint32_t Fault, + HRPWM_FaultBlankingCfgTypeDef *pFaultBlkCfg) +{ + uint32_t hrpwm_fltinr2; + uint32_t hrpwm_fltinr3; + + /* Check parameters */ + assert_param(IS_HRPWM_FAULT(Fault)); + assert_param(IS_HRPWM_FAULTRSTMODE(pFaultBlkCfg->ResetMode)); + + + /* Configure fault channel */ + hrpwm_fltinr2 = Instance->Common.FLTINR2; + hrpwm_fltinr3 = Instance->Common.FLTINR3; + + switch (Fault) { + case HRPWM_FAULT_0: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT0RSTM); + hrpwm_fltinr2 |= (pFaultBlkCfg->ResetMode & HRPWM_FLTINR2_FLT0RSTM); + /*The number of effective edges. How many edges are collected is considered as a fault*/ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT0CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT0CNT); + } + break; + + case HRPWM_FAULT_1: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT1RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->ResetMode << 4U) & HRPWM_FLTINR2_FLT1RSTM); + /*The number of effective edges. How many edges are collected is considered as a fault*/ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT1CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT1CNT); + } + break; + + case HRPWM_FAULT_2: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT2RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->ResetMode << 8U) & HRPWM_FLTINR2_FLT2RSTM); + /*The number of effective edges. How many edges are collected is considered as a fault*/ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT2CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT2CNT); + } + break; + + case HRPWM_FAULT_3: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT3RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->ResetMode << 12U) & HRPWM_FLTINR2_FLT3RSTM); + /*The number of effective edges. How many edges are collected is considered as a fault*/ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT3CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT3CNT); + } + break; + + case HRPWM_FAULT_4: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT4RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->ResetMode << 16U) & HRPWM_FLTINR2_FLT4RSTM); + /*The number of effective edges. How many edges are collected is considered as a fault*/ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT4CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT4CNT); + } + break; + + case HRPWM_FAULT_5: { + hrpwm_fltinr2 &= ~(HRPWM_FLTINR2_FLT5RSTM); + hrpwm_fltinr2 |= ((pFaultBlkCfg->ResetMode << 20U) & HRPWM_FLTINR2_FLT5RSTM); + /*The number of effective edges. How many edges are collected is considered as a fault*/ + hrpwm_fltinr3 &= ~(HRPWM_FLTINR3_FLT5CNT); + hrpwm_fltinr3 |= (pFaultBlkCfg->Threshold & HRPWM_FLTINR3_FLT5CNT); + } + break; + + default: + break; + } + + Instance->Common.FLTINR2 = hrpwm_fltinr2; + Instance->Common.FLTINR3 = hrpwm_fltinr3; + + return LL_OK; +} + +/** + * @brief Reset the fault Counter Reset + * @param Fault fault input to configure + * This parameter can be one of the following values: + * @arg HRPWM_FAULT_0: Fault input 0 + * @arg HRPWM_FAULT_1: Fault input 1 + * @arg HRPWM_FAULT_2: Fault input 2 + * @arg HRPWM_FAULT_3: Fault input 3 + * @arg HRPWM_FAULT_4: Fault input 4 + * @arg HRPWM_FAULT_5: Fault input 5 + * @retval LL status + */ +LL_StatusETypeDef LL_HRPWM_FaultCounterReset(uint32_t Fault) +{ + /* Check parameters */ + assert_param(IS_HRPWM_FAULT(Fault)); + + /* Configure fault channel */ + switch (Fault) { + case HRPWM_FAULT_0: { + MODIFY_REG(HRPWM->Common.FLTINR2, HRPWM_FLTINR2_FLT0CRES, HRPWM_FLTINR2_FLT0CRES); + } + break; + + case HRPWM_FAULT_1: { + MODIFY_REG(HRPWM->Common.FLTINR2, HRPWM_FLTINR2_FLT1CRES, HRPWM_FLTINR2_FLT1CRES); + } + break; + + case HRPWM_FAULT_2: { + MODIFY_REG(HRPWM->Common.FLTINR2, HRPWM_FLTINR2_FLT2CRES, HRPWM_FLTINR2_FLT2CRES); + } + break; + + case HRPWM_FAULT_3: { + MODIFY_REG(HRPWM->Common.FLTINR2, HRPWM_FLTINR2_FLT3CRES, HRPWM_FLTINR2_FLT3CRES); + } + break; + + case HRPWM_FAULT_4: { + MODIFY_REG(HRPWM->Common.FLTINR2, HRPWM_FLTINR2_FLT4CRES, HRPWM_FLTINR2_FLT4CRES); + } + break; + + case HRPWM_FAULT_5: { + MODIFY_REG(HRPWM->Common.FLTINR2, HRPWM_FLTINR2_FLT5CRES, HRPWM_FLTINR2_FLT5CRES); + } + break; + + default: + break; + } + + return LL_OK; +} + +/** + * @brief Configure both the ADC trigger register update source and the ADC + * trigger source. + * @param ADCTrigger group ADC trigger to configure + * This parameter can be one of the following values: + * @arg HRPWM_ADCTRIGGER_0: ADC trigger 0 + * @arg HRPWM_ADCTRIGGER_1: ADC trigger 1 + * @arg HRPWM_ADCTRIGGER_2: ADC trigger 2 + * @arg HRPWM_ADCTRIGGER_3: ADC trigger 3 + * @arg HRPWM_ADCTRIGGER_4: ADC trigger 4 + * @arg HRPWM_ADCTRIGGER_5: ADC trigger 5 + * @arg HRPWM_ADCTRIGGER_6: ADC trigger 6 + * @arg HRPWM_ADCTRIGGER_7: ADC trigger 7 + * @param pADCTriggerCfg pointer to the ADC trigger configuration structure + * for Trigger nb (0/2/4/6): pADCTriggerCfg->Trigger parameter + * can be a combination of the following values + * @arg HRPWM_ADCTRIGGEREVENT02_... + * @arg HRPWM_ADCTRIGGEREVENT46_... + * for Trigger nb (1/3/5/7): pADCTriggerCfg->Trigger parameter + * can be one of the following values + * @arg HRPWM_ADCTRIGGEREVENT13_... + * @arg HRPWM_ADCTRIGGEREVENT57... + * @retval LL status + * @note This function must be called before starting the timer + */ +LL_StatusETypeDef LL_HRPWM_ADDATriggerConfig(HRPWM_TypeDef *Instance, HRPWM_ADCTriggerCfgTypeDef *pADCTriggerCfg) +{ + uint32_t hrpwm_cr0; + uint32_t hrpwm_cr2; + uint32_t hrpwm_adpsr; + + /* Check parameters */ + assert_param(IS_HRPWM_ADCTRIGGER(pADCTriggerCfg->TriggerGroup)); + assert_param(IS_HRPWM_ADCTRIGGER_UPDATESRC(pADCTriggerCfg->UpdateSource)); + assert_param(IS_HRPWM_ADCTRIGGER_LENGTH(pADCTriggerCfg->TriggerLength)); + assert_param(IS_HRPWM_ADCTRIGGER_POSTSCALER(pADCTriggerCfg->TriggerPostScaler)); + + /* Set the ADC trigger update source */ + hrpwm_cr0 = Instance->Common.CR0; + hrpwm_cr2 = Instance->Common.CR2; + hrpwm_adpsr = Instance->Common.ADPSR; + + switch (pADCTriggerCfg->TriggerGroup) { + case HRPWM_ADCTRIGGER_0: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC0); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 8U) & HRPWM_CR0_ADUSRC0); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN0); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 0U) & HRPWM_CR2_TLEN0); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC0); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 0U) & HRPWM_ADPSR_ADPSC0); + /* Set the ADC trigger 0 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break; + } + + case HRPWM_ADCTRIGGER_1: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC1); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 11U) & HRPWM_CR0_ADUSRC1); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN1); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 4U) & HRPWM_CR2_TLEN1); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC1); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 4U) & HRPWM_ADPSR_ADPSC1); + /* Set the ADC trigger 1 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break; + } + + case HRPWM_ADCTRIGGER_2: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC2); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 14U) & HRPWM_CR0_ADUSRC2); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN2); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 8U) & HRPWM_CR2_TLEN2); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC2); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 8U) & HRPWM_ADPSR_ADPSC2); + /* Set the ADC trigger 2 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break; + } + + case HRPWM_ADCTRIGGER_3: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC3); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 17U) & HRPWM_CR0_ADUSRC3); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN3); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 12U) & HRPWM_CR2_TLEN3); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC3); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 12U) & HRPWM_ADPSR_ADPSC3); + /* Set the ADC trigger 3 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break; + } + + case HRPWM_ADCTRIGGER_4: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC4); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 20U) & HRPWM_CR0_ADUSRC4); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN4); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 16U) & HRPWM_CR2_TLEN4); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC4); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 16U) & HRPWM_ADPSR_ADPSC4); + /* Set the ADC trigger 4 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break; + } + + case HRPWM_ADCTRIGGER_5: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC5); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 23U) & HRPWM_CR0_ADUSRC5); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN5); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 20U) & HRPWM_CR2_TLEN5); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC5); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 20U) & HRPWM_ADPSR_ADPSC5); + /* Set the ADC trigger 5 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break; + } + + case HRPWM_ADCTRIGGER_6: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC6); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 26U) & HRPWM_CR0_ADUSRC6); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN6); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 24U) & HRPWM_CR2_TLEN6); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC6); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 24U) & HRPWM_ADPSR_ADPSC6); + /* Set the ADC trigger 6 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break; + } + + case HRPWM_ADCTRIGGER_7: { + hrpwm_cr0 &= ~(HRPWM_CR0_ADUSRC7); + hrpwm_cr0 |= ((pADCTriggerCfg->UpdateSource << 29U) & HRPWM_CR0_ADUSRC7); + /*Set trigger pulse length*/ + hrpwm_cr2 &= ~(HRPWM_CR2_TLEN7); + hrpwm_cr2 |= ((pADCTriggerCfg->TriggerLength << 28U) & HRPWM_CR2_TLEN7); + /* Set the ADC trigger postcaler */ + hrpwm_adpsr &= ~(HRPWM_ADPSR_ADPSC7); + hrpwm_adpsr |= ((pADCTriggerCfg->TriggerPostScaler << 28U) & HRPWM_ADPSR_ADPSC7); + /* Set the ADC trigger 7 source */ + Instance->Common.ADTR[pADCTriggerCfg->TriggerGroup] = pADCTriggerCfg->Trigger; + break;; + } + + default: + break; + } + + /* Update the HRPWM registers */ + Instance->Common.CR0 = hrpwm_cr0; + Instance->Common.CR2 = hrpwm_cr2; + Instance->Common.ADPSR = hrpwm_adpsr; + + return LL_OK; +} + +/** + * @brief Configure the output of a timing unit + * @param TimerIdx Timer index + * @param Output timing unit output identifier + * @param pOutputCfg pointer to the output configuration data structure + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_OutputConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_OutputCfgTypeDef *pOutputCfg) +{ + if (TimerIdx == HRPWM_INDEX_MASTER) { + return LL_ERROR; + } + + uint32_t hrpwm_outr; + + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_OUTPUTA_POLARITY(pOutputCfg->OutputAPolarity)); + assert_param(IS_HRPWM_OUTPUTA_IDLELEVEL(pOutputCfg->IdleALevel)); + assert_param(IS_HRPWM_OUTPUTA_FLTLEVEL(pOutputCfg->FaultALevel)); + assert_param(IS_HRPWM_OUTPUTA_CHOPPEREN(pOutputCfg->ChopperAModeEnable)); + assert_param(IS_HRPWM_OUTPUTB_POLARITY(pOutputCfg->OutputBPolarity)); + assert_param(IS_HRPWM_OUTPUTB_IDLELEVEL(pOutputCfg->IdleBLevel)); + assert_param(IS_HRPWM_OUTPUTB_FLTLEVEL(pOutputCfg->FaultBLevel)); + assert_param(IS_HRPWM_OUTPUTB_CHOPPEREN(pOutputCfg->ChopperBModeEnable)); + + assert_param(IS_HRPWM_OUTPUT_CLEAR_EVENT(pOutputCfg->OutputAClearSource)); + assert_param(IS_HRPWM_OUTPUT_CLEAR_EVENT(pOutputCfg->OutputBClearSource)); + assert_param(IS_HRPWM_OUTPUT_SET_EVENT(pOutputCfg->OutputASetSource)); + assert_param(IS_HRPWM_OUTPUT_SET_EVENT(pOutputCfg->OutputBSetSource)); + + hrpwm_outr = Instance->PWM[TimerIdx].OUTR; + + /* Set the output set/reset crossbar */ + Instance->PWM[TimerIdx].SETAR = pOutputCfg->OutputASetSource; + Instance->PWM[TimerIdx].CLRAR = pOutputCfg->OutputAClearSource; + + /* Set the output set/reset crossbar */ + Instance->PWM[TimerIdx].SETBR = pOutputCfg->OutputBSetSource; + Instance->PWM[TimerIdx].CLRBR = pOutputCfg->OutputBClearSource; + + /* Clear output config */ + hrpwm_outr &= ~(HRPWM_OUTR_POLA | + HRPWM_OUTR_IDLESA | + HRPWM_OUTR_FAULTA | + HRPWM_OUTR_CHPA | + HRPWM_OUTR_POLB | + HRPWM_OUTR_IDLESB | + HRPWM_OUTR_FAULTB | + HRPWM_OUTR_CHPB); + + /* Set the polarity */ + hrpwm_outr |= (pOutputCfg->OutputAPolarity) | (pOutputCfg->OutputBPolarity); + + /* Set the IDLE state */ + hrpwm_outr |= (pOutputCfg->IdleALevel) | (pOutputCfg->IdleBLevel); + + /* Set the FAULT state */ + hrpwm_outr |= (pOutputCfg->FaultALevel) | (pOutputCfg->FaultBLevel); + + /* Set the chopper mode */ + hrpwm_outr |= (pOutputCfg->ChopperAModeEnable) | (pOutputCfg->ChopperBModeEnable); + + /* Update HRPWM register */ + Instance->PWM[TimerIdx].OUTR |= hrpwm_outr; + + return LL_OK; + +} + +/** + * @brief Configure the dead-time output of a timing unit + * @param TimerIdx Timer index + * @param Output timing unit output identifier + * @param pOutputCfg pointer to the output configuration data structure + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_DeadTimeConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_DeadTimeCfgTypeDef *pDeaTimedCfg) +{ + uint32_t hrpwm_outr; + uint32_t hrpwm_dtr; + + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_DEADTIME_SDTF(pDeaTimedCfg->FallingSign)); + assert_param(IS_HRPWM_DEADTIME_SDTR(pDeaTimedCfg->RisingSign)); + + hrpwm_outr = Instance->PWM[TimerIdx].OUTR; + hrpwm_dtr = Instance->PWM[TimerIdx].DTR; + + /* Clear deadtime register config */ + hrpwm_outr &= (~HRPWM_OUTR_DTEN); + hrpwm_dtr &= ~(HRPWM_DTR_SDTF | HRPWM_DTR_DTF | HRPWM_DTR_SDTR | HRPWM_DTR_DTR); + + /* Set the fall dead time sign and value */ + hrpwm_dtr |= (pDeaTimedCfg->FallingSign) | ((pDeaTimedCfg->FallingValue << 16U) & HRPWM_DTR_DTF); + + /* Set Set the rise dead time sign and value */ + hrpwm_dtr |= (pDeaTimedCfg->RisingSign) | (pDeaTimedCfg->RisingValue & HRPWM_DTR_DTR); + + /* Eanble dead-time output */ + hrpwm_outr |= (pDeaTimedCfg->DeadTimeEn << 31U); + + /* Update HRPWM register */ + Instance->PWM[TimerIdx].OUTR |= hrpwm_outr; + Instance->PWM[TimerIdx].DTR = hrpwm_dtr; + + return LL_OK; +} + +/** + * @brief Configure the Chopper output of a timing unit + * @param TimerIdx Timer index + * @param Output timing unit output identifier + * @param pOutputCfg pointer to the output configuration data structure + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_ChopperConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_ChopperModeCfgTypeDef *pChopperCfg) +{ + uint32_t hrpwm_outr; + uint32_t hrpwm_chpr; + + /* Check the parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_OUTPUTA_CHOPPEREN(pChopperCfg->ChopperAModeEnable)); + assert_param(IS_HRPWM_OUTPUTB_CHOPPEREN(pChopperCfg->ChopperBModeEnable)); + assert_param(IS_HRPWM_CHOPPER_CARDTY(pChopperCfg->DutyCycle)); + assert_param(IS_HRPWM_CHOPPER_STRPW(pChopperCfg->StartPulse)); + assert_param(IS_HRPWM_CHOPPER_CARFRQ(pChopperCfg->CarrierFreq)); + + + hrpwm_outr = Instance->PWM[TimerIdx].OUTR; + hrpwm_chpr = Instance->PWM[TimerIdx].CHPR; + + /* Clear chopper register config */ + hrpwm_outr &= (~HRPWM_OUTR_CHPB | HRPWM_OUTR_CHPA); + hrpwm_chpr &= ~(HRPWM_CHPR_STRPW | HRPWM_CHPR_CARDTY | HRPWM_CHPR_CARFRQ); + + /* Set the start pulse width */ + hrpwm_chpr |= (pChopperCfg->StartPulse & HRPWM_CHPR_STRPW); + + /* Set the carrier freq */ + hrpwm_chpr |= (pChopperCfg->CarrierFreq & HRPWM_CHPR_CARFRQ); + + /* Set the chopper duty */ + hrpwm_chpr |= (pChopperCfg->DutyCycle & HRPWM_CHPR_CARDTY); + + /* Eanble chopper A\B output */ + hrpwm_outr |= ((pChopperCfg->ChopperAModeEnable & HRPWM_OUTR_CHPA) | + (pChopperCfg->ChopperBModeEnable & HRPWM_OUTR_CHPB)); + + /* Update HRPWM register */ + Instance->PWM[TimerIdx].OUTR |= hrpwm_outr; + Instance->PWM[TimerIdx].CHPR = hrpwm_chpr; + + return LL_OK; +} + +/** + * @brief Configure an external event channel + * @param Event Event channel identifier + * @param pEventCfg pointer to the event channel configuration data structure + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_EventConfig(HRPWM_TypeDef *Instance, uint32_t Event, HRPWM_EventCfgTypeDef *pEventCfg) +{ + + /* Check parameters */ + assert_param(IS_HRPWM_EVENT(Event)); + assert_param(IS_HRPWM_EVENTSOURCE(pEventCfg->Source)); + assert_param(IS_HRPWM_EVENTPOLARITY(pEventCfg->Polarity)); + assert_param(IS_HRPWM_EVENTFILTER(pEventCfg->Filter)); + assert_param(IS_HRPWM_EVENTSAMPCLK(pEventCfg->SampClockDiv)); + assert_param(IS_HRPWM_EVENTFASTMODE(pEventCfg->FastMode)); + assert_param(IS_HRPWM_EVENTSNS(pEventCfg->Sensitivity)); + + + uint32_t hrpwm_eecr0; + uint32_t hrpwm_eecr1; + uint32_t hrpwm_eecr2; + + /* Configure external event channel */ + hrpwm_eecr0 = Instance->Common.EECR0; + hrpwm_eecr1 = Instance->Common.EECR1; + hrpwm_eecr2 = Instance->Common.EECR2; + + hrpwm_eecr2 &= ~(HRPWM_EECR2_EEVSD); + hrpwm_eecr2 |= (pEventCfg->SampClockDiv & HRPWM_EECR2_EEVSD); + + + switch (Event) { + case HRPWM_EVENT_NONE: { + /* Update the HRPWM registers */ + Instance->Common.EECR0 = 0U; + Instance->Common.EECR1 = 0U; + Instance->Common.EECR2 = 0U; + break; + } + + case HRPWM_EVENT_0: { + hrpwm_eecr0 &= ~(HRPWM_EECR0_EE0SRC | HRPWM_EECR0_EE0POL | HRPWM_EECR0_EE0SNS | HRPWM_EECR0_EE0FAST); + hrpwm_eecr0 |= (pEventCfg->Source & HRPWM_EECR0_EE0SRC); + hrpwm_eecr0 |= (pEventCfg->Polarity & HRPWM_EECR0_EE0POL); + hrpwm_eecr0 |= (pEventCfg->Sensitivity & HRPWM_EECR0_EE0SNS); + /* Update the HRPWM registers (all bitfields but EE1FAST bit) */ + Instance->Common.EECR0 = hrpwm_eecr0; + /* Update the HRPWM registers (EE1FAST bit) */ + hrpwm_eecr0 |= (pEventCfg->FastMode & HRPWM_EECR0_EE0FAST); + Instance->Common.EECR0 = hrpwm_eecr0; + /*HRPWM EVENT0 filter*/ + hrpwm_eecr2 &= ~(HRPWM_EECR2_EE0F); + hrpwm_eecr2 |= (pEventCfg->Filter & HRPWM_EECR2_EE0F); + Instance->Common.EECR2 = hrpwm_eecr2; + break; + } + + case HRPWM_EVENT_1: { + hrpwm_eecr0 &= ~(HRPWM_EECR0_EE1SRC | HRPWM_EECR0_EE1POL | HRPWM_EECR0_EE1SNS | HRPWM_EECR0_EE1FAST); + hrpwm_eecr0 |= ((pEventCfg->Source << 6U) & HRPWM_EECR0_EE1SRC); + hrpwm_eecr0 |= ((pEventCfg->Polarity << 6U) & HRPWM_EECR0_EE1POL); + hrpwm_eecr0 |= ((pEventCfg->Sensitivity << 6U) & HRPWM_EECR0_EE1SNS); + /* Update the HRPWM registers (all bitfields but EE1FAST bit) */ + Instance->Common.EECR0 = hrpwm_eecr0; + /* Update the HRPWM registers (EE1FAST bit) */ + hrpwm_eecr0 |= ((pEventCfg->FastMode << 6U) & HRPWM_EECR0_EE1FAST); + Instance->Common.EECR0 = hrpwm_eecr0; + /*HRPWM EVENT1 filter*/ + hrpwm_eecr2 &= ~(HRPWM_EECR2_EE1F); + hrpwm_eecr2 |= ((pEventCfg->Filter << HRPWM_EECR2_EE1F_Pos) & HRPWM_EECR2_EE1F); + Instance->Common.EECR2 = hrpwm_eecr2; + break; + } + + case HRPWM_EVENT_2: { + hrpwm_eecr0 &= ~(HRPWM_EECR0_EE2SRC | HRPWM_EECR0_EE2POL | HRPWM_EECR0_EE2SNS | HRPWM_EECR0_EE2FAST); + hrpwm_eecr0 |= ((pEventCfg->Source << 12U) & HRPWM_EECR0_EE2SRC); + hrpwm_eecr0 |= ((pEventCfg->Polarity << 12U) & HRPWM_EECR0_EE2POL); + hrpwm_eecr0 |= ((pEventCfg->Sensitivity << 12U) & HRPWM_EECR0_EE2SNS); + /* Update the HRPWM registers (all bitfields but EE2FAST bit) */ + Instance->Common.EECR0 = hrpwm_eecr0; + /* Update the HRPWM registers (EE2FAST bit) */ + hrpwm_eecr0 |= ((pEventCfg->FastMode << 12U) & HRPWM_EECR0_EE2FAST); + Instance->Common.EECR0 = hrpwm_eecr0; + /*HRPWM EVENT2 filter*/ + hrpwm_eecr2 &= ~(HRPWM_EECR2_EE2F); + hrpwm_eecr2 |= ((pEventCfg->Filter << HRPWM_EECR2_EE2F_Pos) & HRPWM_EECR2_EE2F); + Instance->Common.EECR2 = hrpwm_eecr2; + break; + } + + case HRPWM_EVENT_3: { + hrpwm_eecr0 &= ~(HRPWM_EECR0_EE3SRC | HRPWM_EECR0_EE3POL | HRPWM_EECR0_EE3SNS | HRPWM_EECR0_EE3FAST); + hrpwm_eecr0 |= ((pEventCfg->Source << 18U) & HRPWM_EECR0_EE3SRC); + hrpwm_eecr0 |= ((pEventCfg->Polarity << 18U) & HRPWM_EECR0_EE3POL); + hrpwm_eecr0 |= ((pEventCfg->Sensitivity << 18U) & HRPWM_EECR0_EE3SNS); + /* Update the HRPWM registers (all bitfields but EE3FAST bit) */ + Instance->Common.EECR0 = hrpwm_eecr0; + /* Update the HRPWM registers (EE3FAST bit) */ + hrpwm_eecr0 |= ((pEventCfg->FastMode << 18U) & HRPWM_EECR0_EE3FAST); + Instance->Common.EECR0 = hrpwm_eecr0; + /*HRPWM EVENT3 filter*/ + hrpwm_eecr2 &= ~(HRPWM_EECR2_EE3F); + hrpwm_eecr2 |= ((pEventCfg->Filter << HRPWM_EECR2_EE3F_Pos) & HRPWM_EECR2_EE3F); + Instance->Common.EECR2 = hrpwm_eecr2; + break; + } + + case HRPWM_EVENT_4: { + hrpwm_eecr0 &= ~(HRPWM_EECR0_EE4SRC | HRPWM_EECR0_EE4POL | HRPWM_EECR0_EE4SNS | HRPWM_EECR0_EE4FAST); + hrpwm_eecr0 |= ((pEventCfg->Source << 24U) & HRPWM_EECR0_EE4SRC); + hrpwm_eecr0 |= ((pEventCfg->Polarity << 24U) & HRPWM_EECR0_EE4POL); + hrpwm_eecr0 |= ((pEventCfg->Sensitivity << 24U) & HRPWM_EECR0_EE4SNS); + /* Update the HRPWM registers (all bitfields but EE4FAST bit) */ + Instance->Common.EECR0 = hrpwm_eecr0; + /* Update the HRPWM registers (EE4FAST bit) */ + hrpwm_eecr0 |= ((pEventCfg->FastMode << 24U) & HRPWM_EECR0_EE4FAST); + Instance->Common.EECR0 = hrpwm_eecr0; + /*HRPWM EVENT4 filter*/ + hrpwm_eecr2 &= ~(HRPWM_EECR2_EE4F); + hrpwm_eecr2 |= ((pEventCfg->Filter << HRPWM_EECR2_EE4F_Pos) & HRPWM_EECR2_EE4F); + Instance->Common.EECR2 = hrpwm_eecr2; + break; + } + + case HRPWM_EVENT_5: { + hrpwm_eecr1 &= ~(HRPWM_EECR1_EE5SRC | HRPWM_EECR1_EE5POL | HRPWM_EECR1_EE5SNS | HRPWM_EECR1_EE5FAST); + hrpwm_eecr1 |= (pEventCfg->Source & HRPWM_EECR1_EE5SRC); + hrpwm_eecr1 |= (pEventCfg->Polarity & HRPWM_EECR1_EE5POL); + hrpwm_eecr1 |= (pEventCfg->Sensitivity & HRPWM_EECR1_EE5SNS); + /* Update the HRPWM registers (all bitfields but EE5FAST bit) */ + Instance->Common.EECR1 = hrpwm_eecr1; + /* Update the HRPWM registers (EE5FAST bit) */ + hrpwm_eecr1 |= (pEventCfg->FastMode & HRPWM_EECR1_EE5FAST); + Instance->Common.EECR1 = hrpwm_eecr1; + /*HRPWM EVENT5 filter*/ + hrpwm_eecr2 &= ~(HRPWM_EECR2_EE5F); + hrpwm_eecr2 |= ((pEventCfg->Filter << HRPWM_EECR2_EE5F_Pos) & HRPWM_EECR2_EE5F); + Instance->Common.EECR2 = hrpwm_eecr2; + break; + } + + default: + break; + } + + return LL_OK; + +} + +/** + * @brief Configure the timer select event A config + * @param TimerIdx Timer index + * @param Event Event channel identifier + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_TimerEventAConfig(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_ExternalEventACfgTypeDef *pEventCfg, + HRPWM_TimerEventFilteringCfgTypeDef *pEventFilter) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_EVENTA_FILTER(pEventFilter->Filter)); + assert_param(IS_HRPWM_EVENTA_LATCH(pEventFilter->Latch)); + assert_param(IS_HRPWM_EVENTA_SOURCE(pEventCfg->Source)); + assert_param(IS_HRPWM_EVENTA_RSTMODE(pEventCfg->ResetMode)); + assert_param(IS_HRPWM_EVENTA_COUNTEREN(pEventCfg->CounterEnable)); + + + uint32_t hrpwm_eefr0 = 0; + uint32_t hrpwm_eefr1 = 0; + + hrpwm_eefr0 = Instance->PWM[TimerIdx].EEFR0; + hrpwm_eefr1 = Instance->PWM[TimerIdx].EEFR1; + + switch (pEventCfg->Source) { + case HRPWM_EEVASEL_SOURCE_EEVENT0: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE0LTCH | HRPWM_EEFR0_EE0FLTR); + hrpwm_eefr0 |= (pEventFilter->Filter & HRPWM_EEFR0_EE0FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EEVASEL_SOURCE_EEVENT1: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE1LTCH | HRPWM_EEFR0_EE1FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 5U) & HRPWM_EEFR0_EE1FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EEVASEL_SOURCE_EEVENT2: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE2LTCH | HRPWM_EEFR0_EE2FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 10U) & HRPWM_EEFR0_EE2FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EEVASEL_SOURCE_EEVENT3: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE3LTCH | HRPWM_EEFR0_EE3FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 15U) & HRPWM_EEFR0_EE3FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EEVASEL_SOURCE_EEVENT4: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE4LTCH | HRPWM_EEFR0_EE4FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 20U) & HRPWM_EEFR0_EE4FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EEVASEL_SOURCE_EEVENT5: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE5LTCH | HRPWM_EEFR0_EE5FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 25U) & HRPWM_EEFR0_EE5FLTR) | (pEventFilter->Latch); + break; + + default : + hrpwm_eefr0 = 0; + break; + } + + Instance->PWM[TimerIdx].EEFR0 = hrpwm_eefr0; + + if (pEventCfg->CounterEnable != 0x0U) { + /*clear event A register */ + hrpwm_eefr1 &= ~(HRPWM_EEFR1_EEVACE | + HRPWM_EEFR1_EEVARSTM | + HRPWM_EEFR1_EEVASEL | + HRPWM_EEFR1_EEVACNT); + /*config event A register */ + hrpwm_eefr1 |= pEventCfg->CounterEnable | + pEventCfg->Source | + pEventCfg->ResetMode | + (pEventCfg->Counter << 8U); + } + + Instance->PWM[TimerIdx].EEFR1 = hrpwm_eefr1; + + return LL_OK; +} + +/** + * @brief Configure the timer select event A config latch or windows + * @param TimerIdx Timer index + * @param Event A filter windows select or latch identifier + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_TimerEventAFilter(HRPWM_TypeDef *Instance, uint32_t TimerIdx, uint32_t Event, + HRPWM_TimerEventFilteringCfgTypeDef *pEventFilter) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + assert_param(IS_HRPWM_EVENT(Event)); + assert_param(IS_HRPWM_EVENTA_FILTER(pEventFilter->Filter)); + assert_param(IS_HRPWM_EVENTA_LATCH(pEventFilter->Latch)); + + + uint32_t hrpwm_eefr0 = 0; + + hrpwm_eefr0 = Instance->PWM[TimerIdx].EEFR0; + + switch (Event) { + case HRPWM_EVENT_0: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE0LTCH | HRPWM_EEFR0_EE0FLTR); + hrpwm_eefr0 |= (pEventFilter->Filter & HRPWM_EEFR0_EE0FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EVENT_1: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE1LTCH | HRPWM_EEFR0_EE1FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 5U) & HRPWM_EEFR0_EE1FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EVENT_2: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE2LTCH | HRPWM_EEFR0_EE2FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 10U) & HRPWM_EEFR0_EE2FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EVENT_3: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE3LTCH | HRPWM_EEFR0_EE3FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 15U) & HRPWM_EEFR0_EE3FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EVENT_4: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE4LTCH | HRPWM_EEFR0_EE4FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 20U) & HRPWM_EEFR0_EE4FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EVENT_5: + hrpwm_eefr0 &= ~(HRPWM_EEFR0_EE5LTCH | HRPWM_EEFR0_EE5FLTR); + hrpwm_eefr0 |= ((pEventFilter->Filter << 25U) & HRPWM_EEFR0_EE5FLTR) | (pEventFilter->Latch); + break; + + case HRPWM_EVENT_NONE: + Instance->PWM[TimerIdx].EEFR0 = 0; + break; + + default : + break; + } + + Instance->PWM[TimerIdx].EEFR0 = hrpwm_eefr0; + + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup HRPWM_LL_Exported_Functions_Group6 HRPWM Timer waveform configuration and functions + * @brief HRPWM timer configuration and control functions +@verbatim + =============================================================================== + ##### HRPWM timer configuration and control functions ##### + =============================================================================== + [..] This section provides functions used to configure and control a + HRPWM timer operating in waveform mode: + (+) software force timer register update + (+) Disable timer register update + (+) Enable timer register update + (+) Enable timer Output start + (+) Enable timer Output stop + (+) Timer Start output + (+) Timer stop output + (+) timer output swap + (+) Software reset counter +@endverbatim + * @{ + */ + +/** + * @brief Force an immediate transfer from the preload to the active registers. + * @param TimerIdx Timer index + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_ForceRegistersUpdate(uint32_t TimerIdx) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + switch (TimerIdx) { + case HRPWM_INDEX_MASTER: { + HRPWM->Common.CR1 |= HRPWM_CR1_MSWU; + break; + } + + case HRPWM_INDEX_SLAVE_0: { + HRPWM->Common.CR1 |= HRPWM_CR1_SWU0; + break; + } + + case HRPWM_INDEX_SLAVE_1: { + HRPWM->Common.CR1 |= HRPWM_CR1_SWU1; + break; + } + + case HRPWM_INDEX_SLAVE_2: { + HRPWM->Common.CR1 |= HRPWM_CR1_SWU2; + break; + } + + case HRPWM_INDEX_SLAVE_3: { + HRPWM->Common.CR1 |= HRPWM_CR1_SWU3; + break; + } + + case HRPWM_INDEX_SLAVE_4: { + HRPWM->Common.CR1 |= HRPWM_CR1_SWU4; + break; + } + + case HRPWM_INDEX_SLAVE_5: { + HRPWM->Common.CR1 |= HRPWM_CR1_SWU5; + break; + } + + default: + break; + } + + return LL_OK; +} + +/** + * @brief Disable transfer from the preload to the active registers. + * @param TimerIdx Timer index + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_DisRegisterUpdate(uint32_t TimerIdx) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + switch (TimerIdx) { + case HRPWM_INDEX_MASTER: { + HRPWM->Common.CR0 |= HRPWM_CR0_MUDIS; + break; + } + + case HRPWM_INDEX_SLAVE_0: { + HRPWM->Common.CR0 |= HRPWM_CR0_UDIS0; + break; + } + + case HRPWM_INDEX_SLAVE_1: { + HRPWM->Common.CR0 |= HRPWM_CR0_UDIS1; + break; + } + + case HRPWM_INDEX_SLAVE_2: { + HRPWM->Common.CR0 |= HRPWM_CR0_UDIS2; + break; + } + + case HRPWM_INDEX_SLAVE_3: { + HRPWM->Common.CR0 |= HRPWM_CR0_UDIS3; + break; + } + + case HRPWM_INDEX_SLAVE_4: { + HRPWM->Common.CR0 |= HRPWM_CR0_UDIS4; + break; + } + + case HRPWM_INDEX_SLAVE_5: { + HRPWM->Common.CR0 |= HRPWM_CR0_UDIS5; + break; + } + + default: + break; + } + + return LL_OK; +} + +/** + * @brief Enable transfer from the preload to the active registers. + * @param TimerIdx Timer index + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_EnRegUpdate(uint32_t TimerIdx) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + switch (TimerIdx) { + case HRPWM_INDEX_MASTER: { + HRPWM->Common.CR0 &= ~(HRPWM_CR0_MUDIS); + break; + } + + case HRPWM_INDEX_SLAVE_0: { + HRPWM->Common.CR0 &= ~(HRPWM_CR0_UDIS0); + break; + } + + case HRPWM_INDEX_SLAVE_1: { + HRPWM->Common.CR0 &= ~(HRPWM_CR0_UDIS1); + break; + } + + case HRPWM_INDEX_SLAVE_2: { + HRPWM->Common.CR0 &= ~(HRPWM_CR0_UDIS2); + break; + } + + case HRPWM_INDEX_SLAVE_3: { + HRPWM->Common.CR0 &= ~(HRPWM_CR0_UDIS3); + break; + } + + case HRPWM_INDEX_SLAVE_4: { + HRPWM->Common.CR0 &= ~(HRPWM_CR0_UDIS4); + break; + } + + case HRPWM_INDEX_SLAVE_5: { + HRPWM->Common.CR0 &= ~(HRPWM_CR0_UDIS5); + break; + } + + default: + break; + } + + return LL_OK; +} + +/** + * @brief Enable output start ,this bit only write 1, can read. + * @param TimerIdx Timer index + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_StartOutput(uint32_t TimerIdx) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + switch (TimerIdx) { + case HRPWM_INDEX_SLAVE_0: { + HRPWM->Common.OENR |= HRPWM_OENR_OEN0A | HRPWM_OENR_OEN0B; + break; + } + + case HRPWM_INDEX_SLAVE_1: { + HRPWM->Common.OENR |= HRPWM_OENR_OEN1A | HRPWM_OENR_OEN1B; + break; + } + + case HRPWM_INDEX_SLAVE_2: { + HRPWM->Common.OENR |= HRPWM_OENR_OEN2A | HRPWM_OENR_OEN2B; + break; + } + + case HRPWM_INDEX_SLAVE_3: { + HRPWM->Common.OENR |= HRPWM_OENR_OEN3A | HRPWM_OENR_OEN3B; + break; + } + + case HRPWM_INDEX_SLAVE_4: { + HRPWM->Common.OENR |= HRPWM_OENR_OEN4A | HRPWM_OENR_OEN4B; + break; + } + + case HRPWM_INDEX_SLAVE_5: { + HRPWM->Common.OENR |= HRPWM_OENR_OEN5A | HRPWM_OENR_OEN5B; + break; + } + + default: + break; + } + + return LL_OK; +} + +/** + * @brief Enable output stop, stop putput , this bit only write 1, can read. + * @param TimerIdx Timer index + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_StopOutput(uint32_t TimerIdx) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + switch (TimerIdx) { + case HRPWM_INDEX_SLAVE_0: { + HRPWM->Common.ODISR |= HRPWM_ODISR_ODIS0A | HRPWM_ODISR_ODIS0B; + break; + } + + case HRPWM_INDEX_SLAVE_1: { + HRPWM->Common.ODISR |= HRPWM_ODISR_ODIS1A | HRPWM_ODISR_ODIS1B; + break; + } + + case HRPWM_INDEX_SLAVE_2: { + HRPWM->Common.ODISR |= HRPWM_ODISR_ODIS2A | HRPWM_ODISR_ODIS2B; + break; + } + + case HRPWM_INDEX_SLAVE_3: { + HRPWM->Common.ODISR |= HRPWM_ODISR_ODIS3A | HRPWM_ODISR_ODIS3B; + break; + } + + case HRPWM_INDEX_SLAVE_4: { + HRPWM->Common.ODISR |= HRPWM_ODISR_ODIS4A | HRPWM_ODISR_ODIS4B; + break; + } + + case HRPWM_INDEX_SLAVE_5: { + HRPWM->Common.ODISR |= HRPWM_ODISR_ODIS5A | HRPWM_ODISR_ODIS5B; + break; + } + + default: + break; + } + + return LL_OK; +} + +/** + * @brief Configure swap output + * @param TimerIdx Timer index + * @param swap: 0: no swap; 1:swap ;So you can exchange the output with each other + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_SwapOutput(uint32_t TimerIdx, uint32_t swap) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + switch (TimerIdx) { + case HRPWM_INDEX_SLAVE_0: { + HRPWM->Common.CR1 &= ~(HRPWM_CR1_SWP0); + HRPWM->Common.CR1 |= ((swap << 16U) & HRPWM_CR1_SWP0); + break; + } + + case HRPWM_INDEX_SLAVE_1: { + HRPWM->Common.CR1 &= ~(HRPWM_CR1_SWP1); + HRPWM->Common.CR1 |= ((swap << 17U) & HRPWM_CR1_SWP1); + break; + } + + case HRPWM_INDEX_SLAVE_2: { + HRPWM->Common.CR1 &= ~(HRPWM_CR1_SWP2); + HRPWM->Common.CR1 |= ((swap << 18U) & HRPWM_CR1_SWP2); + break; + } + + case HRPWM_INDEX_SLAVE_3: { + HRPWM->Common.CR1 &= ~(HRPWM_CR1_SWP3); + HRPWM->Common.CR1 |= ((swap << 19U) & HRPWM_CR1_SWP3); + break; + } + + case HRPWM_INDEX_SLAVE_4: { + HRPWM->Common.CR1 &= ~(HRPWM_CR1_SWP4); + HRPWM->Common.CR1 |= ((swap << 20U) & HRPWM_CR1_SWP4); + break; + } + + case HRPWM_INDEX_SLAVE_5: { + HRPWM->Common.CR1 &= ~(HRPWM_CR1_SWP5); + HRPWM->Common.CR1 |= ((swap << 21U) & HRPWM_CR1_SWP5); + break; + } + + default: + break; + } + + return LL_OK; +} + +/** + * @brief Software reset timer counter. + * @param TimerIdx Timer index + * @retval None + */ +LL_StatusETypeDef LL_HRPWM_ResetCounter(uint32_t TimerIdx) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX(TimerIdx)); + + switch (TimerIdx) { + case HRPWM_INDEX_MASTER: { + HRPWM->Common.CR1 |= HRPWM_CR1_MRST; + break; + } + + case HRPWM_INDEX_SLAVE_0: { + HRPWM->Common.CR1 |= HRPWM_CR1_RST0; + break; + } + + case HRPWM_INDEX_SLAVE_1: { + HRPWM->Common.CR1 |= HRPWM_CR1_RST1; + break; + } + + case HRPWM_INDEX_SLAVE_2: { + HRPWM->Common.CR1 |= HRPWM_CR1_RST2; + break; + } + + case HRPWM_INDEX_SLAVE_3: { + HRPWM->Common.CR1 |= HRPWM_CR1_RST3; + break; + } + + case HRPWM_INDEX_SLAVE_4: { + HRPWM->Common.CR1 |= HRPWM_CR1_RST4; + break; + } + + case HRPWM_INDEX_SLAVE_5: { + HRPWM->Common.CR1 |= HRPWM_CR1_RST5; + break; + } + + default: + break; + } + + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup HRPWM_LL_Exported_Functions_Interrupt HRPWM Initerrupt management + * @brief HRPWM Initerrupt management + * @note Functions called when HRPWM generates an interrupt + * 8 interrupts can be generated by the master timer: + * - Master timer registers update + * - Synchronization event received + * - Master timer repetition event + * - Master Compare a to d event and period event + * 11 interrupts can be generated by each timing unit: + * - Counter reset or roll-over event + * - Output A and output B reset (transition active to inactive) + * - Output A and output B set (transition inactive to active) + * - Timing unit registers update + * - Repetition event + * - Compare 1 to 4 event and period event + * 7 global interrupts are generated for the whole HRPWM: + * - System fault and Fault 0 to 5 (regardless of the timing unit attribution) +@verbatim + =============================================================================== + ##### HRPWM interrupts handling ##### + =============================================================================== + [..] + This subsection provides a set of functions allowing to manage the HRPWM + interrupts: + (+) HRPWM interrupt handler + (+) Callback function called when Fault0 interrupt occurs + (+) Callback function called when Fault1 interrupt occurs + (+) Callback function called when Fault2 interrupt occurs + (+) Callback function called when Fault3 interrupt occurs + (+) Callback function called when Fault4 interrupt occurs + (+) Callback function called when Fault5 interrupt occurs + (+) Callback function called when system Fault interrupt occurs + (+) Callback function called when synchronization input interrupt occurs + (+) Callback function called when a timer register update interrupt occurs + (+) Callback function called when a timer repetition interrupt occurs + (+) Callback function called when a compare A match interrupt occurs + (+) Callback function called when a compare B match interrupt occurs + (+) Callback function called when a compare C match interrupt occurs + (+) Callback function called when a compare D match interrupt occurs + (+) Callback function called when a timer period interrupt occurs + (+) Callback function called when a timer counter reset interrupt occurs + (+) Callback function called when a timer output A set interrupt occurs + (+) Callback function called when a timer output A reset interrupt occurs + (+) Callback function called when a timer output B set interrupt occurs + (+) Callback function called when a timer output B reset interrupt occurs + (+) HRPWM callback function registration + (+) HRPWM callback function unregistration + (+) HRPWM Timer x callback function registration + (+) HRPWM Timer x callback function unregistration + +@endverbatim + * @{ + */ + +/** + * @brief This function handles HRPWM interrupt request. + * @param TimerIdx Timer index + * This parameter can be any value of HRPWM_Timer_Index + * @retval None + */ +void LL_HRPWM_IRQHandler(uint32_t TimerIdx) +{ + /* Check parameters */ + assert_param(IS_HRPWM_INDEX_ALL(TimerIdx)); + + /* HRPWM interrupts handling */ + if (TimerIdx == HRPWM_INDEX_COMMON) { + LL_HRPWM_FLT_IRQHandler(); + } else if (TimerIdx == HRPWM_INDEX_MASTER) { + /* Master related interrupts handling */ + LL_HRPWM_MSTR_IRQHandler(); + } else { + /* Timing unit related interrupts handling */ + LL_HRPWM_SLAVE_IRQHandler(TimerIdx); + } + +} + +/** + * @brief Callback function invoked when a fault 0 interrupt occurred + * @retval None + */ +__WEAK void LL_HRPWM_Fault0Callback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Fault0Callback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when a fault 1 interrupt occurred + * @retval None + */ +__WEAK void LL_HRPWM_Fault1Callback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Fault1Callback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when a fault 2 interrupt occurred + * @retval None + */ +__WEAK void LL_HRPWM_Fault2Callback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Fault2Callback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when a fault 3 interrupt occurred + * @retval None + */ +__WEAK void LL_HRPWM_Fault3Callback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Fault3Callback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when a fault 4 interrupt occurred + * @retval None + */ +__WEAK void LL_HRPWM_Fault4Callback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Fault4Callback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when a fault 5 interrupt occurred + * @retval None + */ +__WEAK void LL_HRPWM_Fault5Callback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Fault5Callback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when a system fault interrupt occurred + * @retval None + */ +__WEAK void LL_HRPWM_SystemFaultCallback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_SystemFaultCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when a synchronization input event is received + * @retval None + */ +__WEAK void LL_HRPWM_SynchronizationEventCallback(void) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(HRPWM); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_SynchronizationEventCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when timer registers are updated + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_RegistersUpdateCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Master_RegistersUpdateCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when timer repetition period has elapsed + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_RepetitionEventCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Master_RepetitionEventCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer counter matches the value + * programmed in the compare A register + * @param hhrpwm pointer to LL HRPWM handle + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_CompareAEventCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Master_CompareAEventCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer counter matches the value + * programmed in the compare B register + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_CompareBEventCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Master_CompareBEventCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer counter matches the value + * programmed in the compare C register + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_CompareCEventCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Master_CompareCEventCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer counter matches the value + * programmed in the compare D register + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_CompareDEventCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Master_CompareDEventCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer counter matches the value programmed in the period register + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_MASTER for master timer + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_PeriodEventCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Master_PeriodEventCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer x counter reset/roll-over event occurs. + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_CounterResetCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Timer_CounterResetCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer x output A is set + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_OutputASetCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Timer_OutputASetCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer x output B is set + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_OutputBSetCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Timer_OutputBSetCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer x output A is reset + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_OutputAResetCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Timer_OutputAResetCallback could be implemented in the user file + */ +} + +/** + * @brief Callback function invoked when the timer x output B is reset + * @param TimerIdx Timer index + * This parameter can be one of the following values: + * @arg HRPWM_INDEX_SLAVE_0 for timer 0 + * @arg HRPWM_INDEX_SLAVE_1 for timer 1 + * @arg HRPWM_INDEX_SLAVE_2 for timer 2 + * @arg HRPWM_INDEX_SLAVE_3 for timer 3 + * @arg HRPWM_INDEX_SLAVE_4 for timer 4 + * @arg HRPWM_INDEX_SLAVE_5 for timer 5 + * @retval None + */ +__WEAK void LL_HRPWM_OutputBResetCallback(uint32_t TimerIdx) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(TimerIdx); + + /* NOTE : This function should not be modified, when the callback is needed, + the LL_HRPWM_Timer_OutputBResetCallback could be implemented in the user file + */ +} + + +/** + * @brief This function handles HRPWM Master interrupts requests. + * @return None + */ +void LL_HRPWM_MSTR_IRQHandler(void) +{ + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_MREP) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_MREP)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_MREP); + + /*Handle something*/ + LL_HRPWM_RepetitionEventCallback(HRPWM_INDEX_MASTER); + } + + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_MUPD) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_MUPD)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_MUPD); + + /*Handle something*/ + LL_HRPWM_RegistersUpdateCallback(HRPWM_INDEX_MASTER); + } + + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_SYNC) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_SYNC)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_SYNC); + + /*Handle something*/ + LL_HRPWM_SynchronizationEventCallback(); + } + + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_MPER) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_MPER)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_MPER); + + /*Handle something*/ + LL_HRPWM_PeriodEventCallback(HRPWM_INDEX_MASTER); + } + + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_MCMPD) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_MCMPD)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_MCMPD); + + /*Handle something*/ + LL_HRPWM_CompareDEventCallback(HRPWM_INDEX_MASTER); + } + + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_MCMPC) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_MCMPC)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_MCMPC); + + /*Handle something*/ + LL_HRPWM_CompareCEventCallback(HRPWM_INDEX_MASTER); + } + + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_MCMPB) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_MCMPB)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_MCMPB); + + /*Handle something*/ + LL_HRPWM_CompareBEventCallback(HRPWM_INDEX_MASTER); + } + + if (__LL_HRPWM_MASTER_GET_IT(HRPWM_MASTER_IT_MCMPA) && __LL_HRPWM_MASTER_GET_ITFLAG(HRPWM_MASTER_FLAG_MCMPA)) { + __LL_HRPWM_MASTER_CLEAR_ITFLAG(HRPWM_MASTER_FLAG_MCMPA); + + /*Handle something*/ + LL_HRPWM_CompareAEventCallback(HRPWM_INDEX_MASTER); + } +} + +/** + * @brief This function handles HRPWM Slave interrupts requests. + * @return None + */ +void LL_HRPWM_SLAVE_IRQHandler(uint32_t TimerIdx) +{ + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_REP) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_REP)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_REP); + + /*Handle something*/ + LL_HRPWM_RepetitionEventCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_RST) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_RST)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_RST); + + /*Handle something*/ + LL_HRPWM_CounterResetCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_CLRB) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_CLRB)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_CLRB); + + /*Handle something*/ + LL_HRPWM_OutputBResetCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_SETB) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_SETB)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_SETB); + + /*Handle something*/ + LL_HRPWM_OutputBSetCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_CLRA) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_CLRA)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_CLRA); + + /*Handle something*/ + LL_HRPWM_OutputAResetCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_SETA) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_SETA)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_SETA); + + /*Handle something*/ + LL_HRPWM_OutputASetCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_UPD) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_UPD)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_UPD); + + /*Handle something*/ + LL_HRPWM_RegistersUpdateCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_PER) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_PER)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_PER); + + /*Handle something*/ + LL_HRPWM_PeriodEventCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_CMPD) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_CMPD)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_CMPD); + + /*Handle something*/ + LL_HRPWM_CompareDEventCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_CMPC) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_CMPC)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_CMPC); + + /*Handle something*/ + LL_HRPWM_CompareCEventCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_CMPB) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_CMPB)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_CMPB); + + /*Handle something*/ + LL_HRPWM_CompareBEventCallback(TimerIdx); + } + + if (__LL_HRPWM_TIMER_GET_IT(TimerIdx, HRPWM_IT_CMPA) && + __LL_HRPWM_TIMER_GET_ITFLAG(TimerIdx, HRPWM_FLAG_CMPA)) { + + __LL_HRPWM_TIMER_CLEAR_ITFLAG(TimerIdx, HRPWM_FLAG_CMPA); + + /*Handle something*/ + LL_HRPWM_CompareAEventCallback(TimerIdx); + } +} + +/** + * @brief This function handles HRPWM Common fault interrupts requests. + * @return None + */ +void LL_HRPWM_FLT_IRQHandler(void) +{ + if (__LL_HRPWM_GET_IT(HRPWM_IT_SYSFLT) && __LL_HRPWM_GET_ITFLAG(HRPWM_FLAG_SYSFLT)) { + + __LL_HRPWM_CLEAR_ITFLAG(HRPWM_FLAG_SYSFLT); + + /*Handle something*/ + LL_HRPWM_SystemFaultCallback(); + } + + if (__LL_HRPWM_GET_IT(HRPWM_IT_FLT5) && __LL_HRPWM_GET_ITFLAG(HRPWM_FLAG_FLT5)) { + + __LL_HRPWM_CLEAR_ITFLAG(HRPWM_FLAG_FLT5); + + /*Handle something*/ + LL_HRPWM_Fault5Callback(); + } + + if (__LL_HRPWM_GET_IT(HRPWM_IT_FLT4) && __LL_HRPWM_GET_ITFLAG(HRPWM_FLAG_FLT4)) { + + __LL_HRPWM_CLEAR_ITFLAG(HRPWM_FLAG_FLT4); + + /*Handle something*/ + LL_HRPWM_Fault4Callback(); + } + + if (__LL_HRPWM_GET_IT(HRPWM_IT_FLT3) && __LL_HRPWM_GET_ITFLAG(HRPWM_FLAG_FLT3)) { + + __LL_HRPWM_CLEAR_ITFLAG(HRPWM_FLAG_FLT3); + + /*Handle something*/ + LL_HRPWM_Fault3Callback(); + } + + if (__LL_HRPWM_GET_IT(HRPWM_IT_FLT2) && __LL_HRPWM_GET_ITFLAG(HRPWM_FLAG_FLT2)) { + + __LL_HRPWM_CLEAR_ITFLAG(HRPWM_FLAG_FLT2); + + /*Handle something*/ + LL_HRPWM_Fault2Callback(); + } + + if (__LL_HRPWM_GET_IT(HRPWM_IT_FLT1) && __LL_HRPWM_GET_ITFLAG(HRPWM_FLAG_FLT1)) { + + __LL_HRPWM_CLEAR_ITFLAG(HRPWM_FLAG_FLT1); + + /*Handle something*/ + LL_HRPWM_Fault1Callback(); + } + + if (__LL_HRPWM_GET_IT(HRPWM_IT_FLT0) && __LL_HRPWM_GET_ITFLAG(HRPWM_FLAG_FLT0)) { + + __LL_HRPWM_CLEAR_ITFLAG(HRPWM_FLAG_FLT0); + + /*Handle something*/ + LL_HRPWM_Fault0Callback(); + } +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ +/** @addtogroup HRPWM_LL_Private_Functions + * @{ + */ +/** + * @brief Configure the master timer in waveform mode + * @param pTimerCompCfg pointer to the timer configuration data structure + * @retval None + */ +static void HRPWM_MasterCompare_Config(HRPWM_TypeDef *Instance, HRPWM_TimerCompareCfgTypeDef *pTimerCompCfg) +{ + uint32_t hrpwm_mcr; + + /* Configure master timer */ + hrpwm_mcr = Instance->Master.MCR; + /* Enable/Disable preload meachanism for timer registers */ + hrpwm_mcr &= ~(HRPWM_MCR_PREEN); + hrpwm_mcr |= pTimerCompCfg->PreloadEnable; + + /* Update the HRPWM registers */ + Instance->Master.MCR |= hrpwm_mcr; + /*Update Compare Value*/ + Instance->Master.MCMPAR = pTimerCompCfg->CompareValueA; + Instance->Master.MCMPBR = pTimerCompCfg->CompareValueB; + Instance->Master.MCMPCR = pTimerCompCfg->CompareValueC; + Instance->Master.MCMPDR = pTimerCompCfg->CompareValueD; +} + +/** + * @brief Configure timing unit (Timer 0 to Timer 5) in waveform mode + * @param TimerIdx Timer index + * @param pTimerCompCfg pointer to the timer configuration data structure + * @retval None + */ +static void HRPWM_TimingUnitCompare_Config(HRPWM_TypeDef *Instance, uint32_t TimerIdx, + HRPWM_TimerCompareCfgTypeDef *pTimerCompCfg) +{ + uint32_t hrpwm_cr0; + + /* Configure master timing unit */ + hrpwm_cr0 = Instance->PWM[TimerIdx].CR0; + + /* UPDGAT bitfield must be reset before programming a new value */ + hrpwm_cr0 &= ~(HRPWM_CR0_MUPD | HRPWM_CR0_UPD0 | HRPWM_CR0_UPD1 | HRPWM_CR0_UPD2 | HRPWM_CR0_UPD3 | + HRPWM_CR0_UPD4 | HRPWM_CR0_UPD5 | HRPWM_UPDATETRIGGER_REP | HRPWM_UPDATETRIGGER_RST); + /* Set the timer update trigger */ + hrpwm_cr0 |= pTimerCompCfg->UpdateTrigger; + + /* Enable/Disable preload meachanism for timer registers */ + hrpwm_cr0 &= ~(HRPWM_CR0_PREEN); + hrpwm_cr0 |= pTimerCompCfg->PreloadEnable; + + /* Update the HRPWM registers */ + Instance->PWM[TimerIdx].CR0 |= hrpwm_cr0; + /* Update Compare Value */ + Instance->PWM[TimerIdx].CMPAR = pTimerCompCfg->CompareValueA; + Instance->PWM[TimerIdx].CMPBR = pTimerCompCfg->CompareValueB; + Instance->PWM[TimerIdx].CMPCR = pTimerCompCfg->CompareValueC; + Instance->PWM[TimerIdx].CMPDR = pTimerCompCfg->CompareValueD; +} + +/** + * @brief Configure the master timer time base + * @param pTimeBaseCfg pointer to the time base configuration structure + * @retval None + */ +static void HRPWM_MasterBase_Config(HRPWM_TypeDef *Instance, HRPWM_TimerBaseCfgTypeDef *pTimeBaseCfg) +{ + uint32_t hrpwm_mcr; + + /* Configure master timer */ + hrpwm_mcr = Instance->Master.MCR; + + /* Set the prescaler ratio */ + hrpwm_mcr &= ~(HRPWM_MCR_CKPSC); + hrpwm_mcr |= pTimeBaseCfg->PrescalerRatio; + + /* Set the operating mode */ + hrpwm_mcr &= ~(HRPWM_MCR_CONT | HRPWM_MCR_RETRIG); + hrpwm_mcr |= pTimeBaseCfg->Mode; + + /* Enable/Disable the timer start upon synchronization event reception */ + hrpwm_mcr &= ~(HRPWM_MCR_SYNCSTRTM); + hrpwm_mcr |= pTimeBaseCfg->StartOnSync; + + /* Enable/Disable the timer reset upon synchronization event reception */ + hrpwm_mcr &= ~(HRPWM_MCR_SYNCRSTM); + hrpwm_mcr |= pTimeBaseCfg->ResetOnSync; + + /*Enable Master interrupt*/ + Instance->Master.MIER = pTimeBaseCfg->InterruptRequests; + + /* Update the HRPWM registers */ + Instance->Master.MCR |= hrpwm_mcr; + Instance->Master.MPER = pTimeBaseCfg->Period; + Instance->Master.MCNTR = (pTimeBaseCfg->RepetitionCounter) << HRPWM_MCNTR_MREP_Pos; +} + +/** + * @brief Configure timing unit (Timer 0 to Timer 5) time base + * @param TimerIdx Timer index + * @param pTimeBaseCfg pointer to the time base configuration structure + * @retval None + */ +static void HRPWM_TimingUnitBase_Config(HRPWM_TypeDef *Instance, uint32_t TimerIdx, HRPWM_TimerBaseCfgTypeDef *pTimeBaseCfg) +{ + uint32_t hrpwm_cr0; + uint32_t hrpwm_rstr; + + /* Configure timing unit (Timer 0 to Timer 5) */ + hrpwm_cr0 = Instance->PWM[TimerIdx].CR0; + + /* Enable/Disable the timer start upon synchronization event reception */ + hrpwm_cr0 &= ~(HRPWM_CR0_SYNCSTRT); + hrpwm_cr0 |= pTimeBaseCfg->StartOnSync; + + /* Enable/Disable the timer reset upon synchronization event reception */ + hrpwm_cr0 &= ~(HRPWM_CR0_SYNCRST); + hrpwm_cr0 |= pTimeBaseCfg->ResetOnSync; + + /* Timing unit Re-Synchronized Update */ + hrpwm_cr0 &= ~(HRPWM_CR0_RSYNCU); + hrpwm_cr0 |= (pTimeBaseCfg->ReSyncUpdate & HRPWM_CR0_RSYNCU); + + /* Set the prescaler ratio */ + hrpwm_cr0 &= ~(HRPWM_CR0_CKPSC); + hrpwm_cr0 |= pTimeBaseCfg->PrescalerRatio; + + /* Set the operating mode */ + hrpwm_cr0 &= ~(HRPWM_CR0_CONT | HRPWM_CR0_RETRIG); + hrpwm_cr0 |= pTimeBaseCfg->Mode; + + /* Set the timer counter reset trigger */ + hrpwm_rstr = pTimeBaseCfg->ResetTrigger; + + /* Update the HRPWM registers */ + Instance->PWM[TimerIdx].CR0 |= hrpwm_cr0; + Instance->PWM[TimerIdx].RSTR = hrpwm_rstr; + Instance->PWM[TimerIdx].PERR = pTimeBaseCfg->Period; + Instance->PWM[TimerIdx].CNTR = (pTimeBaseCfg->RepetitionCounter) << HRPWM_CNTR_REP_Pos; + + /*Enable timer uint interrupt*/ + Instance->PWM[TimerIdx].IER = pTimeBaseCfg->InterruptRequests; +} + +/** + * @} + */ + + +#endif /* LL_HRPWM_MODULE_ENABLE */ + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_i2c.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_i2c.c new file mode 100644 index 0000000000..401c7cd980 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_i2c.c @@ -0,0 +1,2202 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_i2c.c + * @author MCD Application Team + * @brief I2C LL Module Driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + +#define DBG_TAG "I2C" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup I2C_LL I2C LL + * @brief I2C LL Module Driver + * @{ + */ + +#ifdef LL_I2C_MODULE_ENABLED + +/* Private define ------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/** @defgroup I2C_LL_Private_Types I2C LL Private Types + * @brief I2C LL Private Types + * @{ + */ + +/** + * @brief I2C LL Config Type Definition + */ + +typedef struct __I2C_LLCfgTypeDef { + bool restart_en; /*!< Restart enable */ + bool rxfifo_full_hold_en; /*!< RXFIFO full hold enable */ + bool slv_nack_en; /*!< Slave NACK enable */ + bool ack_gen_call_en; /*!< ACK genaral call enable */ + uint8_t sda_setup; /*!< SDA setup time */ +} I2C_LLCfgTypeDef; + + +/** + * @} + */ + + +/* Private macro -------------------------------------------------------------*/ +/** @defgroup I2C_LL_Private_Macros I2C LL Private Macros + * @brief I2C LL Private Macros + * @{ + */ + +/** + * @brief I2C Function Alternative + * @param flag Condition Flag + * @param func_t True Funciton + * @param func_f False Function + * @return None + */ +#define I2C_FUNC_ALTER(flag, func_t, func_f) \ + do{ \ + if((flag)) { \ + func_t; \ + } else { \ + func_f; \ + } \ + } while(0) + +/** + * @} + */ + + +/* Private variables ---------------------------------------------------------*/ +/** @defgroup I2C_LL_Private_Variables I2C LL Private Variables + * @brief I2C LL Private Variables + * @{ + */ + +/** + * @brief Default I2C Hardware Config + */ +static const I2C_LLCfgTypeDef i2c_ll_cfg_def = { + .restart_en = true, + .rxfifo_full_hold_en = false, + .slv_nack_en = false, + .ack_gen_call_en = true, + .sda_setup = 0x64, +}; + +/** + * @} + */ + + +/* Private function prototypes -----------------------------------------------*/ +/** @addtogroup I2C_LL_Private_Functions I2C LL Private function + * @brief I2C LL Private function + * @{ + */ + +#ifdef LL_DMA_MODULE_ENABLED + + static DMA_ChannelETypeDef LL_I2C_DMA_Init(DMA_UserCfgTypeDef *dma_user_cfg); + static LL_StatusETypeDef LL_I2C_DMA_Deinit(DMA_ChannelETypeDef ch); + static void LL_I2C_DMA_TXCHEndCallback(void *arg); + static void LL_I2C_DMA_RXCHEndCallback(void *arg); + static void LL_I2C_DMA_TXCHErrorCallBck(void *arg); + static void LL_I2C_DMA_RXCHErrorCallBck(void *arg); + +#endif +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup I2C_LL_Exported_Functions I2C LL Exported Functions + * @brief I2C LL Exported Functions + * @{ + */ + +/** @defgroup I2C_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and de-initialization functions + * @{ + */ + +/** + * @brief I2C LL Init + * @param Instance Specifies I2C peripheral + * @param user_cfg user config pointer + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_I2C_Init(I2C_TypeDef *Instance, I2C_UserCfgTypeDef *user_cfg) +{ + uint32_t baudrate_cnt; + I2C_LLCfgTypeDef *ll_cfg = (I2C_LLCfgTypeDef *)&i2c_ll_cfg_def; + + /* Init the low level hardware eg. Clock, NVIC */ + LL_I2C_MspInit(Instance); + + /* Disable all interrupt*/ + CLEAR_REG(Instance->INTRMS); + + /* I2C LL Config */ + //I2C Restart Enable/Disable + I2C_FUNC_ALTER(ll_cfg->restart_en, __LL_I2C_MST_Restart_En(Instance), __LL_I2C_MST_Restart_Dis(Instance)); + + //I2C RXFIFO Full Hold Control + I2C_FUNC_ALTER(ll_cfg->rxfifo_full_hold_en, __LL_I2C_RxFIFOFullHold_En(Instance), __LL_I2C_RxFIFOFullHold_Dis(Instance)); + + //I2C Slave NACK Config + I2C_FUNC_ALTER(ll_cfg->slv_nack_en, __LL_I2C_SLV_ForceDataNoAck_Set(Instance), __LL_I2C_SLV_ForceDataNoAck_Clr(Instance)); + + //I2C ACK Gen Call Config + I2C_FUNC_ALTER(ll_cfg->ack_gen_call_en, __LL_I2C_AckGenCall_En(Instance), __LL_I2C_AckGenCall_Dis(Instance)); + + //I2C Spike Filtered Cnt Config + __LL_I2C_FsSpkLen_Set(Instance, (uint32_t)50000000 / LL_SYSCTRL_SysclkGet()); + + //I2C SDA Timing Config + __LL_I2C_SDATxHold_Set(Instance, READ_REG(Instance->SSLCNT) >> 1); + __LL_I2C_SDARxHold_Set(Instance, READ_REG(Instance->SSLCNT) >> 1); + __LL_I2C_SDA_Setup_Set(Instance, ll_cfg->sda_setup); + + + /* I2C user config */ + //I2C Role Mode Config + I2C_FUNC_ALTER(user_cfg->role == I2C_ROLE_MASTER, __LL_I2C_MASTER_Mode_En(Instance), __LL_I2C_MASTER_Mode_Dis(Instance)); + I2C_FUNC_ALTER(user_cfg->role == I2C_ROLE_MASTER, __LL_I2C_SLAVE_Mode_Dis(Instance), __LL_I2C_SLAVE_Mode_En(Instance)); + + //I2C Address Mode Config + if (user_cfg->role == I2C_ROLE_SLAVE) { + I2C_FUNC_ALTER(user_cfg->addr_mode == I2C_ADDR_7BIT, __LL_I2C_SLV_7bAddr_Set(Instance), __LL_I2C_SLV_10bAddr_Set(Instance)); + } + + //I2C Speed Mode and Baudrate Config + assert_param(user_cfg->baudrate); + baudrate_cnt = LL_SYSCTRL_APB0ClkGet() / user_cfg->baudrate / 2; + + if (user_cfg->baudrate <= I2C_SS_SPEED_MAX) { //standard speed + __LL_I2C_Speed_Set(Instance, I2C_SPEED_STD); + __LL_I2C_SS_SCLHcnt_Set(Instance, baudrate_cnt); + __LL_I2C_SS_SCLLcnt_Set(Instance, baudrate_cnt); + } else if (user_cfg->baudrate <= I2C_FS_SPEED_MAX) { //fast speed + __LL_I2C_Speed_Set(Instance, I2C_SPEED_FAST); + __LL_I2C_FS_SCLHcnt_Set(Instance, baudrate_cnt); + __LL_I2C_FS_SCLLcnt_Set(Instance, baudrate_cnt); + } else if (user_cfg->baudrate <= I2C_FS_PLUS_SPEED_MAX) { //fast plus speed + __LL_I2C_Speed_Set(Instance, I2C_SPEED_FAST); + __LL_I2C_FS_SCLHcnt_Set(Instance, baudrate_cnt); + __LL_I2C_FS_SCLLcnt_Set(Instance, baudrate_cnt); + } else if (user_cfg->baudrate <= I2C_HS_SPEED_MAX) { //high speed + LOG_E("Don't support High Speed mode!\n"); + return LL_ERROR; + } else { + LOG_E("Invalid baudrate params: %d\n", user_cfg->baudrate); + return LL_ERROR; + } + + //I2C Slave Address Config + __LL_I2C_SAR_Set(Instance, user_cfg->slave_addr); + + //I2C TXFIFO Transmit Data Enable + __LL_I2C_MST_TxCmdBlock_Clr(Instance); + + if (user_cfg->smbus_enable == ENABLE) { + __LL_I2C_SMBUS_ClkLowMextTimeout_Set(Instance, user_cfg->smbus_master_extend_clk); + __LL_I2C_SMBUS_ClkLowSextTimeout_Set(Instance, user_cfg->smbus_slaver_extend_clk); + } + + //I2C Module Enable + __LL_I2C_Enable(Instance); + + return LL_OK; +} + +/** + * @brief I2C LL DeInit + * @param Instance Specifies I2C peripheral + * @return Status of the DeInitialization + */ +LL_StatusETypeDef LL_I2C_DeInit(I2C_TypeDef *Instance) +{ + //I2C Module Disable + __LL_I2C_Disable(Instance); + + //I2C TXFIFO Transmit Data Disable + __LL_I2C_MST_TxCmdBlock_Set(Instance); + + /* DeInit the low level hardware eg. Clock, NVIC */ + LL_I2C_MspDeInit(Instance); + + return LL_OK; +} + +/** + * @brief Initializes the I2C MSP. + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_MspInit(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the I2C MSP + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_MspDeInit(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + + +/** @defgroup I2C_LL_Exported_Functions_Group2 Read Write Functions + * @brief Read Write Functions + * @{ + */ + +/** + * @brief I2C LL Master Read by CPU + * @param Instance Specifies I2C peripheral + * @param frame read frame pointer + * @return success read length + */ +uint32_t LL_I2C_MasterRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + uint32_t w_cnt = 0, r_cnt = 0; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send read memory address if has memory address to send + if (frame->mem_addr_size == I2C_MEMADDR_SIZE_8BIT) { + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->mem_addr & 0xffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_16BIT) { + __LL_I2C_Timing_RestartAddr16b(Instance, (frame->mem_addr & 0xffffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_32BIT) { + __LL_I2C_Timing_RestartAddr32b(Instance, frame->mem_addr); + } + + if (frame->buf_len == 1) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read, then stop + __LL_I2C_Timing_RestartReadStop(Instance); + } else { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read + __LL_I2C_Timing_RestartRead(Instance); + + //read data loop + for (w_cnt = 0; w_cnt < frame->buf_len - 2; w_cnt++) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //Read, send the read signal actually acts as ii_clk + __LL_I2C_Timing_Read(Instance); + + /* wait RXFIFO not empty */ + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)); + + *frame->buf++ = __LL_I2C_DAT_Read(Instance); + r_cnt++; + } + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //read last byte, then stop + __LL_I2C_Timing_ReadStop(Instance); + } + + //read remain data + for (; r_cnt < frame->buf_len; r_cnt++) { + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)); + + *frame->buf++ = __LL_I2C_DAT_Read(Instance); + } + + /* wait for last data sent */ + while (!__LL_I2C_IsStopDet_Raw(Instance)); + + return r_cnt; +} + + +/** + * @brief I2C LL Slave Read by CPU + * @param Instance Specifies I2C peripheral + * @param frame read frame pointer + @param Timeout Limited operation time + @note The slave cannot initiate a read operation, it can only respond to the read request of the master + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_I2C_SlaveRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + while (frame->buf_len > 0U) { + /* Wait until ReadReq flag is set */ + tickstart = LL_GetTick(); + + /* wait RXFIFO not empty */ + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Clear ReadReq bit */ + __LL_I2C_SLV_ReadReqRawIntSta_Clr(Instance); + + *frame->buf++ = __LL_I2C_DAT_Read(Instance); + frame->buf_len--; + } + + return LL_OK; +} + +/** + * @brief I2C LL Master Write by CPU + * @param Instance Specifies I2C peripheral + * @param frame write frame pointer + * @return success write length + */ +uint32_t LL_I2C_MasterWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + uint32_t w_cnt = 0; + bool need_start = false; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send read memory address if has memory address to send + if (frame->mem_addr_size == I2C_MEMADDR_SIZE_8BIT) { + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->mem_addr & 0xffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_16BIT) { + __LL_I2C_Timing_RestartAddr16b(Instance, (frame->mem_addr & 0xffffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_32BIT) { + __LL_I2C_Timing_RestartAddr32b(Instance, frame->mem_addr); + } else { + need_start = true; + } + + //write data loop + for (w_cnt = 0; w_cnt < frame->buf_len - 1; w_cnt++) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //write data + if (need_start == true) { + need_start = false; + __LL_I2C_Timing_RestartWrite(Instance, *frame->buf++); + } else { + __LL_I2C_Timing_Write(Instance, *frame->buf++); + } + } + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //write last byte, then stop + if (need_start == true) { + need_start = false; + __LL_I2C_Timing_RestartWriteStop(Instance, *frame->buf++); + } else { + __LL_I2C_Timing_WriteStop(Instance, *frame->buf++); + } + + w_cnt++; + + /* wait for last data sent */ + while (__LL_I2C_SLV_IsActivity(Instance)); + + return w_cnt; +} + + +/** + * @brief I2C LL Slave Write by CPU + * @param Instance Specifies I2C peripheral + * @param frame write frame pointer + @note The slave cannot initiate a write request actively, and can only write after the master sends a read command + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_I2C_SlaveWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + while (frame->buf_len > 0U) { + /* Wait until ReadReq flag is set */ + tickstart = LL_GetTick(); + + while (!__LL_I2C_SLV_IsReadReq_Raw(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* I2C Slave Read Request Interrupt Status Clear */ + __LL_I2C_SLV_ReadReqRawIntSta_Clr(Instance); + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + __LL_I2C_DAT_Write(Instance, *frame->buf++); + frame->buf_len--; + } + + //wait slave is not active,to sure data has been sent + while (__LL_I2C_SLV_IsActivity(Instance)); + + return LL_OK; +} + + +/** + * @brief I2C LL Smbus Write by CPU + * @param Instance Specifies I2C peripheral + * @param frame write frame pointer + * @return success write length + */ +uint32_t LL_SMBUS_MasterWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + uint32_t w_cnt = 0; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send Smbus Command + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->command & 0xffUL)); + + //write data loop + for (w_cnt = 0; w_cnt < frame->buf_len - 1; w_cnt++) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + __LL_I2C_Timing_Write(Instance, *frame->buf++); + } + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //write last byte, then stop + __LL_I2C_Timing_WriteStop(Instance, *frame->buf++); + w_cnt++; + + /* wait for last data to be sent */ + while (!__LL_I2C_IsStopDet_Raw(Instance)); + + return w_cnt; +} + + +/** + * @brief I2C LL Slave Read by CPU + * @param Instance Specifies I2C peripheral + * @param frame read frame pointer + @param Timeout Limited operation time + @note The first command received by the slave is the command sent by the master, not the actual information + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SMBUS_SlaveRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + while (frame->buf_len > 0U) { + /* Wait until RxFIFO is not empty */ + tickstart = LL_GetTick(); + + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + *frame->buf++ = __LL_I2C_DAT_Read(Instance); + frame->buf_len--; + } + + return LL_OK; +} + +/** + * @brief I2C LL Smbus Read by CPU + * @param Instance Specifies I2C peripheral + * @param frame read frame pointer + * @return success read length + */ +uint32_t LL_SMBUS_MasterRead_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + uint32_t w_cnt = 0, r_cnt = 0; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send read memory address if has memory address to send + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->command & 0xffUL)); + + if (frame->buf_len == 1) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read, then stop + __LL_I2C_Timing_RestartReadStop(Instance); + } else { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read + __LL_I2C_Timing_RestartRead(Instance); + + //read data loop + for (w_cnt = 0; w_cnt < frame->buf_len - 2; w_cnt++) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //Read, send the read signal actually acts as ii_clk + __LL_I2C_Timing_Read(Instance); + + /* wait RXFIFO not empty */ + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)); + + *frame->buf++ = __LL_I2C_DAT_Read(Instance); + r_cnt++; + } + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //read last byte, then stop + __LL_I2C_Timing_ReadStop(Instance); + } + + //read remain data + for (; r_cnt < frame->buf_len; r_cnt++) { + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)); + + *frame->buf++ = __LL_I2C_DAT_Read(Instance); + } + + /* wait for last data sent */ + while (!__LL_I2C_IsStopDet_Raw(Instance)); + + return r_cnt; +} + + +/** + * @brief I2C LL Smbus Write by CPU + * @param Instance Specifies I2C peripheral + * @param frame write frame pointer + * @param Timeout Limited operation time + @note The slave cannot initiate a write operation, it can only respond to the read request of the master + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SMBUS_SlaveWrite_CPU(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + while (frame->buf_len > 0U) { + /* Wait until ReadReq flag is set */ + tickstart = LL_GetTick(); + + while (!__LL_I2C_SLV_IsReadReq_Raw(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* I2C Slave Read Request Interrupt Status Clear */ + __LL_I2C_SLV_ReadReqRawIntSta_Clr(Instance); + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + __LL_I2C_DAT_Write(Instance, *frame->buf++); + frame->buf_len--; + } + + //wait slave is not active,to sure data has been sent + while (__LL_I2C_SLV_IsActivity(Instance)); + + return LL_OK; +} + + +/** + * @brief I2C LL Master Write by interrupt + * @param Instance Specifies I2C peripheral + @note Put the user code in LL_I2C_TxEmptyCallback + * @return None + */ +LL_StatusETypeDef LL_SMBUS_MasterWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + __LL_I2C_TxEmpty_INT_Dis(Instance); + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + //start and send Smbus Command + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->command & 0xffUL)); + + if (frame->buf_len > 1) { + //write data + frame->XferCount = frame->buf_len - 1; + + /* I2C TX Empty Interrupt Enable */ + __LL_I2C_TxEmpty_INT_En(Instance); + } else { + __LL_I2C_Timing_WriteStop(Instance, *frame->buf); + } + + return LL_OK; +} + +/** + * @brief I2C LL Master Read by interrupt + * @param Instance Specifies I2C peripheral + @note Put the user code in LL_I2C_RxFullCallback + * @return None + */ +LL_StatusETypeDef LL_SMBUS_MasterRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + __LL_I2C_TxEmpty_INT_Dis(Instance); + + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + //start and send read memory address if has memory address to send + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->command & 0xffUL)); + + frame->XferCount = frame->buf_len; + + /* I2C RX Full Interrupt Enable */ + __LL_I2C_RxFull_INT_En(Instance); + + if (frame->buf_len == 1) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read, then stop + __LL_I2C_Timing_RestartReadStop(Instance); + } else { + //start+TAR, read + __LL_I2C_Timing_RestartRead(Instance); + frame->clk_cnt = frame->buf_len - 2; + frame->XferCount = frame->buf_len; + /* I2C TX Empty Interrupt Enable */ + __LL_I2C_TxEmpty_INT_En(Instance); + } + + return LL_OK; +} + + +/** + * @brief I2C LL Slave Write by interrupt + * @param Instance Specifies I2C peripheral + @note The read operation of the corresponding Master from the Slave, and the data is sent to the Master + Put the user code in LL_I2C_SlvReadReqCallback + * @return None + */ +LL_StatusETypeDef LL_SMBUS_SlaveWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->XferCount = frame->buf_len; + /* I2C Slave Read Request Interrupt Enable */ + __LL_I2C_SLV_ReadReq_INT_En(Instance); + + return LL_OK; +} + +/** + * @brief I2C LL Slave Write by interrupt + * @param Instance Specifies I2C peripheral + @note Write operation of the corresponding Master from the slave to save the data + Put the user code in LL_I2C_SlvReadReqCallback + * @return None + */ +LL_StatusETypeDef LL_SMBUS_SlaveRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->XferCount = frame->buf_len; + /* I2C RX Full Interrupt Enable */ + __LL_I2C_RxFull_INT_En(Instance); + + return LL_OK; +} + + +/** + * @brief I2C LL Master Write by interrupt + * @param Instance Specifies I2C peripheral + @note Put the user code in LL_I2C_TxEmptyCallback + * @return None + */ +LL_StatusETypeDef LL_I2C_MasterWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + bool need_start = false; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + __LL_I2C_TxEmpty_INT_Dis(Instance); + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send read memory address if has memory address to send + if (frame->mem_addr_size == I2C_MEMADDR_SIZE_8BIT) { + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->mem_addr & 0xffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_16BIT) { + __LL_I2C_Timing_RestartAddr16b(Instance, (frame->mem_addr & 0xffffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_32BIT) { + __LL_I2C_Timing_RestartAddr32b(Instance, frame->mem_addr); + } else { + need_start = true; + } + + if (frame->buf_len > 1) { + //write data + if (need_start == true) { + need_start = false; + __LL_I2C_Timing_RestartWrite(Instance, *frame->buf++); + frame->XferCount = frame->buf_len - 2; + } else { + frame->XferCount = frame->buf_len - 1; + } + } + + //write last byte, then stop + if (need_start == true) { + need_start = false; + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + __LL_I2C_Timing_RestartWriteStop(Instance, *frame->buf); + } else { + /* I2C TX Empty Interrupt Enable */ + __LL_I2C_TxEmpty_INT_En(Instance); + } + + return LL_OK; +} + + + +/** + * @brief I2C LL Slave Write by interrupt + * @param Instance Specifies I2C peripheral + @note The read operation of the corresponding Master from the Slave, and the data is sent to the Master + Put the user code in LL_I2C_SlvReadReqCallback + * @return None + */ +LL_StatusETypeDef LL_I2C_SlaveWrite_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->XferCount = frame->buf_len; + + /* I2C Slave Read Request Interrupt Enable */ + __LL_I2C_SLV_ReadReq_INT_En(Instance); + + return LL_OK; +} + + +/** + * @brief I2C LL Master Read by interrupt + * @param Instance Specifies I2C peripheral + @note Put the user code in LL_I2C_RxFullCallback + * @return None + */ +LL_StatusETypeDef LL_I2C_MasterRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + __LL_I2C_TxEmpty_INT_Dis(Instance); + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + /* I2C RX Full Interrupt Enable */ + __LL_I2C_RxFull_INT_En(Instance); + + //start and send read memory address if has memory address to send + if (frame->mem_addr_size == I2C_MEMADDR_SIZE_8BIT) { + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->mem_addr & 0xffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_16BIT) { + __LL_I2C_Timing_RestartAddr16b(Instance, (frame->mem_addr & 0xffffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_32BIT) { + __LL_I2C_Timing_RestartAddr32b(Instance, frame->mem_addr); + } + + if (frame->buf_len == 1) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read, then stop + __LL_I2C_Timing_RestartReadStop(Instance); + } else { + //start+TAR, read + __LL_I2C_Timing_RestartRead(Instance); + frame->clk_cnt = frame->buf_len - 2; + frame->XferCount = frame->buf_len; + /* I2C TX Empty Interrupt Enable */ + __LL_I2C_TxEmpty_INT_En(Instance); + } + + return LL_OK; + +} + +/** + * @brief I2C LL Slave Write by interrupt + * @param Instance Specifies I2C peripheral + @note Write operation of the corresponding Master from the slave to save the data + Put the user code in LL_I2C_SlvReadReqCallback + * @return None + */ +LL_StatusETypeDef LL_I2C_SlaveRead_IT(I2C_TypeDef *Instance, I2C_FrameTypeDef *frame) +{ + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->XferCount = frame->buf_len; + /* I2C RX Full Interrupt Enable */ + __LL_I2C_RxFull_INT_En(Instance); + + return LL_OK; +} + +#ifdef LL_DMA_MODULE_ENABLED + +/** + * @brief I2C LL Slave Write by DMA + * @param Instance Specifies I2C peripheral + * @param dma_user_cfg user dma config pointer + * @param frame write frame pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_I2C_MasterWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + bool need_start = false; + frame->dma_tx_ch = DMA_CHANNEL_INVALID; + uint32_t tickstart; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->Instance = Instance; + frame->TXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_TXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_TXCHErrorCallBck; + + /* Wait until I2C DMA Init ok */ + tickstart = LL_GetTick(); + + while (frame->dma_tx_ch == DMA_CHANNEL_INVALID) { + frame->dma_tx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + frame->TXdma_status = IIC_DMA_STATE_READY; + + /* TAR config */ + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + /* Send read memory address wiht start singal if user has memory address to send */ + if (frame->mem_addr_size == I2C_MEMADDR_SIZE_8BIT) { + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->mem_addr & 0xffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_16BIT) { + __LL_I2C_Timing_RestartAddr16b(Instance, (frame->mem_addr & 0xffffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_32BIT) { + __LL_I2C_Timing_RestartAddr32b(Instance, frame->mem_addr); + } else { + need_start = true; + } + + /* Enable Transmit DMA func */ + __LL_I2C_TxDMA_En(Instance); + + /* The first data must sent with start singal and the last data should sent with stop singal, + Remaining data can sent by DMA*/ + if (need_start == true) { + need_start = false; + + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + __LL_I2C_Timing_RestartWrite(Instance, *frame->buf++); + + if (frame->buf_len > 2) { + LL_DMA_Start_IT(DMA, frame->dma_tx_ch, (uint32_t)frame->buf, (uint32_t)&Instance->DCMD, frame->buf_len - 1); + frame->TXdma_status = IIC_DMA_STATE_BUSY; + } else { + __LL_I2C_Timing_RestartWriteStop(Instance, *(frame->buf + frame->buf_len - 1)); + } + + } else { + if (frame->buf_len >= 2) { + LL_DMA_Start_IT(DMA, frame->dma_tx_ch, (uint32_t)frame->buf, (uint32_t)&Instance->DCMD, frame->buf_len - 1); + frame->TXdma_status = IIC_DMA_STATE_BUSY; + } else { + __LL_I2C_Timing_WriteStop(Instance, *(frame->buf + frame->buf_len - 1)); + } + } + + return LL_OK; +} + + +/** + * @brief I2C LL Master Read by DMA + * @param Instance Specifies I2C peripheral + * @param dma_user_cfg user dma config pointer + * @param frame Read frame pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_I2C_MasterRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + uint32_t clk_cmd = I2C_CMD_READ; + DMA_UserCfgTypeDef dma_masterclk_cfg; + frame->dma_tx_ch = DMA_CHANNEL_INVALID; + frame->dma_rx_ch = DMA_CHANNEL_INVALID; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->Instance = Instance; + frame->TXdma_status = IIC_DMA_STATE_RESET; + frame->RXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_RXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_RXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_rx_ch == DMA_CHANNEL_INVALID) { + frame->dma_rx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + frame->TXdma_status = IIC_DMA_STATE_READY; + + /* Need a DMA chanl send clock singal to Keep communication with slave */ + dma_masterclk_cfg.trans_type = DMA_TRANS_TYPE_M2P; + dma_masterclk_cfg.src_addr_mode = DMA_SRC_ADDR_MODE_FIX; + dma_masterclk_cfg.dst_addr_mode = DMA_DST_ADDR_MODE_FIX; + dma_masterclk_cfg.src_data_width = DMA_SRC_TRANS_WIDTH_16b; + dma_masterclk_cfg.dst_data_width = DMA_DST_TRANS_WIDTH_16b; + dma_masterclk_cfg.src_hs_ifc = DMA_SRC_HANDSHAKE_IFC_MEMORY; + + if (Instance == I2C0) { + dma_masterclk_cfg.dst_hs_ifc = DMA_DST_HANDSHAKE_IFC_I2C0_TX; + } else { + dma_masterclk_cfg.dst_hs_ifc = DMA_DST_HANDSHAKE_IFC_I2C1_TX; + } + + dma_masterclk_cfg.end_arg = (void *)frame; + dma_masterclk_cfg.end_callback = LL_I2C_DMA_TXCHEndCallback; + dma_masterclk_cfg.err_arg = (void *)frame; + dma_masterclk_cfg.err_callback = LL_I2C_DMA_TXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_tx_ch == DMA_CHANNEL_INVALID) { + frame->dma_tx_ch = LL_I2C_DMA_Init(&dma_masterclk_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + frame->RXdma_status = IIC_DMA_STATE_READY; + + /* TAR config */ + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send read memory address if has memory address to send + if (frame->mem_addr_size == I2C_MEMADDR_SIZE_8BIT) { + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->mem_addr & 0xffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_16BIT) { + __LL_I2C_Timing_RestartAddr16b(Instance, (frame->mem_addr & 0xffffUL)); + } else if (frame->mem_addr_size == I2C_MEMADDR_SIZE_32BIT) { + __LL_I2C_Timing_RestartAddr32b(Instance, frame->mem_addr); + } + + /* Enable Transmit/Receive DMA func */ + __LL_I2C_RxDMA_En(Instance); + __LL_I2C_TxDMA_En(Instance); + + if (frame->buf_len == 1) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read, then stop + __LL_I2C_Timing_RestartReadStop(Instance); + + /* Get the last data */ + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)); + + *(frame->buf + frame->buf_len - 1) = __LL_I2C_DAT_Read(Instance); + + /* wait for last data sent */ + while (!__LL_I2C_IsStopDet_Raw(Instance)); + + } else { + + //start+TAR, read + __LL_I2C_Timing_RestartRead(Instance); + /* Indicates how many clk needs to be sent */ + frame->clk_cnt = frame->buf_len - 1; + /* Master should sent clk to Keep communication with slave,and READ_CMD is U16,means U8 Multiply 2, + The first data has not save yet,but the clock has been sent. And the last read command need sent + with Stop Command,so that the length of ch1 is 2*(buf_len -2),and chn0 is buf_len */ + LL_DMA_Start_IT(DMA, frame->dma_tx_ch, (uint32_t)&clk_cmd, (uint32_t)&Instance->DCMD, 2 * (frame->buf_len - 2)); + LL_DMA_Start_IT(DMA, frame->dma_rx_ch, (uint32_t)&Instance->DCMD, (uint32_t)frame->buf, frame->buf_len); + + frame->TXdma_status = IIC_DMA_STATE_BUSY; + frame->RXdma_status = IIC_DMA_STATE_BUSY; + } + + /* Return Status */ + return LL_OK; + + +} + + +/** + * @brief I2C LL Slave Read by DMA + * @param Instance Specifies I2C peripheral + * @param frame Read frame pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_I2C_SlaveWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + frame->dma_tx_ch = DMA_CHANNEL_INVALID; + + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->Instance = Instance; + frame->TXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_TXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_TXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_tx_ch == DMA_CHANNEL_INVALID) { + frame->dma_tx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Wait for I2C Slave Read Request Interrupt Status Set */ + tickstart = LL_GetTick(); + + while (!__LL_I2C_SLV_IsReadReq_Raw(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Enable Transmit DMA func */ + __LL_I2C_TxDMA_En(Instance); + /* DMA work */ + LL_DMA_Start_IT(DMA, frame->dma_tx_ch, (uint32_t)frame->buf, (uint32_t)&Instance->DCMD, frame->buf_len); + frame->TXdma_status = IIC_DMA_STATE_BUSY; + + return LL_OK; +} + +/** + * @brief I2C LL Slave Write by DMA + * @param Instance Specifies I2C peripheral + * @param frame Write frame pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_I2C_SlaveRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + frame->dma_rx_ch = DMA_CHANNEL_INVALID; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + frame->Instance = Instance; + frame->RXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_RXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_RXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_rx_ch == DMA_CHANNEL_INVALID) { + frame->dma_rx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Wait until ReadFIFO is full */ + tickstart = LL_GetTick(); + + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Enable Receive DMA func */ + __LL_I2C_RxDMA_En(Instance); + /* DMA work */ + LL_DMA_Start_IT(DMA, frame->dma_rx_ch, (uint32_t)&Instance->DCMD, (uint32_t)frame->buf, frame->buf_len); + frame->RXdma_status = IIC_DMA_STATE_BUSY; + + return LL_OK; +} + + +/** + * @brief I2C LL SMBUS Master Write by DMA + * @param Instance Specifies I2C peripheral + * @param frame Write frame pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SMBUS_MasterWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + frame->dma_tx_ch = DMA_CHANNEL_INVALID; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->Instance = Instance; + frame->TXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_TXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_TXCHErrorCallBck; + + /* Wait until ReadReq flag is set */ + tickstart = LL_GetTick(); + + while (frame->dma_tx_ch == DMA_CHANNEL_INVALID) { + frame->dma_tx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + frame->TXdma_status = IIC_DMA_STATE_READY; + + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send Smbus Command + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->command & 0xffUL)); + + /* Enable Transmit DMA func */ + __LL_I2C_TxDMA_En(Instance); + /* DMA work */ + LL_DMA_Start_IT(DMA, frame->dma_tx_ch, (uint32_t)frame->buf, (uint32_t)&Instance->DCMD, frame->buf_len - 1); + frame->TXdma_status = IIC_DMA_STATE_BUSY; + + return LL_OK; +} + +/** + * @brief I2C LL SMBUS Master Write by DMA + * @param Instance Specifies I2C peripheral + * @param frame Read frame pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SMBUS_MasterRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + uint32_t clk_cmd = I2C_CMD_READ; + DMA_UserCfgTypeDef dma_masterclk_cfg; + frame->dma_tx_ch = DMA_CHANNEL_INVALID; + frame->dma_rx_ch = DMA_CHANNEL_INVALID; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->Instance = Instance; + frame->TXdma_status = IIC_DMA_STATE_RESET; + frame->RXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_RXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_RXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_rx_ch == DMA_CHANNEL_INVALID) { + frame->dma_rx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + frame->TXdma_status = IIC_DMA_STATE_READY; + /* Need a DMA chanl send clock singal to Keep communication with slave */ + dma_masterclk_cfg.trans_type = DMA_TRANS_TYPE_M2P; + dma_masterclk_cfg.src_addr_mode = DMA_SRC_ADDR_MODE_FIX; + dma_masterclk_cfg.dst_addr_mode = DMA_DST_ADDR_MODE_FIX; + dma_masterclk_cfg.src_data_width = DMA_SRC_TRANS_WIDTH_16b; + dma_masterclk_cfg.dst_data_width = DMA_DST_TRANS_WIDTH_16b; + dma_masterclk_cfg.src_hs_ifc = DMA_SRC_HANDSHAKE_IFC_MEMORY; + + if (Instance == I2C0) { + dma_masterclk_cfg.dst_hs_ifc = DMA_DST_HANDSHAKE_IFC_I2C0_TX; + } else { + dma_masterclk_cfg.dst_hs_ifc = DMA_DST_HANDSHAKE_IFC_I2C1_TX; + } + + dma_masterclk_cfg.end_arg = (void *)frame; + dma_masterclk_cfg.end_callback = LL_I2C_DMA_TXCHEndCallback; + dma_masterclk_cfg.err_arg = (void *)frame; + dma_masterclk_cfg.err_callback = LL_I2C_DMA_TXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_tx_ch == DMA_CHANNEL_INVALID) { + frame->dma_tx_ch = LL_I2C_DMA_Init(&dma_masterclk_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + frame->RXdma_status = IIC_DMA_STATE_READY; + //TAR config + __LL_I2C_TAR_Set(Instance, frame->target_addr); + + //start and send Smbus command + __LL_I2C_Timing_RestartAddr8b(Instance, (frame->command & 0xffUL)); + + /* Enable Transmit/Receive DMA func */ + __LL_I2C_RxDMA_En(Instance); + __LL_I2C_TxDMA_En(Instance); + + if (frame->buf_len == 1) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + //start+TAR, read, then stop + __LL_I2C_Timing_RestartReadStop(Instance); + + /* Get the last data */ + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)); + + *(frame->buf + frame->buf_len - 1) = __LL_I2C_DAT_Read(Instance); + + /* wait for last data sent */ + while (!__LL_I2C_IsStopDet_Raw(Instance)); + + } else { + //start+TAR, read + __LL_I2C_Timing_RestartRead(Instance); + /* Indicates how many clk needs to be sent */ + frame->clk_cnt = frame->buf_len - 1; + + /* Master should sent clk to Keep communication with slave,and READ_CMD is U16,means U8 Multiply 2, + The first data has not save yet,but the clock has been sent. And the last read command need sent + with Stop Command,so that the length of ch1 is 2*(buf_len -2),and chn0 is buf_len */ + LL_DMA_Start_IT(DMA, frame->dma_tx_ch, (uint32_t)&clk_cmd, (uint32_t)&Instance->DCMD, 2 * (frame->buf_len - 2)); + LL_DMA_Start_IT(DMA, frame->dma_rx_ch, (uint32_t)&Instance->DCMD, (uint32_t)frame->buf, frame->buf_len); + frame->TXdma_status = IIC_DMA_STATE_BUSY; + frame->RXdma_status = IIC_DMA_STATE_BUSY; + } + + /* Return Status */ + return LL_OK; +} + +/** + * @brief I2C LL Slave Write by DMA + * @param Instance Specifies I2C peripheral + * @param frame read frame pointer + @param Timeout Limited operation time + @note The first command received by the slave is the command sent by the master, not the actual information + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SMBUS_SlaveWrite_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + frame->dma_tx_ch = DMA_CHANNEL_INVALID; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->Instance = Instance; + frame->TXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_TXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_TXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_tx_ch == DMA_CHANNEL_INVALID) { + frame->dma_tx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Wait until ReadReq flag is set */ + tickstart = LL_GetTick(); + + /* Make sure slave readreq flag is set, it can't be clear when transmit by DMA */ + while (!__LL_I2C_SLV_IsReadReq_Raw(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Enable Transmit DMA func */ + __LL_I2C_TxDMA_En(Instance); + + /* DMA work */ + LL_DMA_Start_IT(DMA, frame->dma_tx_ch, (uint32_t)frame->buf, (uint32_t)&Instance->DCMD, frame->buf_len); + frame->TXdma_status = IIC_DMA_STATE_BUSY; + /* Return Status */ + return LL_OK; +} + + +/** + * @brief I2C LL SMBUS Slave Read by DMA + * @param Instance Specifies I2C peripheral + * @param frame Wrute frame pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SMBUS_SlaveRead_DMA(I2C_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + I2C_FrameTypeDef *frame, uint32_t Timeout) +{ + uint32_t tickstart; + frame->dma_rx_ch = DMA_CHANNEL_INVALID; + /* Check the I2C initiation struct allocation */ + assert_param(IS_I2C_ALL_INSTANCE(Instance)); + + if ((frame->buf == NULL) || (frame->buf_len == 0U)) { + return LL_ERROR; + } + + frame->Instance = Instance; + frame->RXdma_status = IIC_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)frame; + dma_user_cfg->end_callback = LL_I2C_DMA_TXCHEndCallback; + dma_user_cfg->err_arg = (void *)frame; + dma_user_cfg->err_callback = LL_I2C_DMA_TXCHErrorCallBck; + + /* Wait for DMA chn init successful */ + tickstart = LL_GetTick(); + + while (frame->dma_tx_ch == DMA_CHANNEL_INVALID) { + frame->dma_tx_ch = LL_I2C_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* Wait until ReadReq flag is set */ + tickstart = LL_GetTick(); + + while (!__LL_I2C_SLV_IsReadReq_Raw(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + /* I2C Slave Read Request Interrupt Status Clear */ + __LL_I2C_SLV_ReadReqRawIntSta_Clr(Instance); + + /* Enable Receive DMA func */ + __LL_I2C_RxDMA_En(Instance); + /* DMA work */ + LL_DMA_Start_IT(DMA, frame->dma_rx_ch, (uint32_t)&Instance->DCMD, (uint32_t)frame->buf, frame->buf_len); + frame->RXdma_status = IIC_DMA_STATE_BUSY; + + /* Return Status */ + return LL_OK; +} +#endif +/** + * @} + */ + +/** @defgroup I2C_LL_Exported_Functions_Group3 Interrupt handler and call back + * @brief Interrupt handler and call back + * @{ + */ + +/** + * @brief I2C IRQ Handler + * @param Instance Specifies I2C peripheral + * @return None + */ +void LL_I2C_IRQHandler(I2C_TypeDef *Instance, I2C_FrameTypeDef *irq_frame) +{ + uint32_t i2c_int_sta = __LL_I2C_IntSta_Get(Instance); + + if (i2c_int_sta & I2C_SCL_STK_AT_LOW_INT_STA_Msk) { + LL_I2C_SCLStuckAtLowCallback(Instance); + } + + if (i2c_int_sta & I2C_MST_ON_HOLD_INT_STA_Msk) { + LL_I2C_MstOnHoldCallback(Instance); + } + + if (i2c_int_sta & I2C_RESTART_DET_INT_STA_Msk) { + LL_I2C_SlvRestartDetCallback(Instance); + } + + if (i2c_int_sta & I2C_GEN_CALL_INT_STA_Msk) { + __LL_I2C_SLV_GenCallRawIntSta_Clr(Instance); + LL_I2C_SlvGenCallCallback(Instance); + } + + if (i2c_int_sta & I2C_START_DET_INT_STA_Msk) { + __LL_I2C_StartDetRawIntSta_Clr(Instance); + LL_I2C_StartDetCallback(Instance); + } + + if (i2c_int_sta & I2C_STOP_DET_INT_STA_Msk) { + __LL_I2C_StopDetRawIntSta_Clr(Instance); + LL_I2C_StopDetCallback(Instance); + } + + if (i2c_int_sta & I2C_ACTIVITY_INT_STA_Msk) { + __LL_I2C_ActivityRawIntSta_Clr(Instance); + LL_I2C_ActivityCallback(Instance); + } + + if (i2c_int_sta & I2C_RX_DONE_INT_STA_Msk) { + __LL_I2C_SLV_RxDoneRawIntSta_Clr(Instance); + LL_I2C_SlvRxDoneCallback(Instance); + } + + if (i2c_int_sta & I2C_TX_ABRT_INT_STA_Msk) { + __LL_I2C_TxAbortRawIntSta_Clr(Instance); + LL_I2C_TxAbortCallback(Instance); + } + + if (i2c_int_sta & I2C_RD_REQ_INT_STA_Msk) { + __LL_I2C_SLV_ReadReqRawIntSta_Clr(Instance); + + if ((irq_frame != NULL) && (irq_frame->buf_len != NULL)) { + + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + __LL_I2C_DAT_Write(Instance, *irq_frame->buf++); + irq_frame->XferCount--; + + if (irq_frame->XferCount == 0x0UL) { + /* I2C Slave Read Request Interrupt Disable */ + __LL_I2C_SLV_ReadReq_INT_Dis(Instance); + irq_frame->buf = NULL; + } + + } + + LL_I2C_SlvReadReqCallback(Instance); + } + + if (i2c_int_sta & I2C_TX_EMPTY_INT_STA_Msk) { + //Auto clear according to TXFIFO status + if ((irq_frame != NULL) && (irq_frame->buf_len != NULL)) { + //wait TXFIFO not full + while (!__LL_I2C_IsTxFIFONotFull(Instance)); + + if (irq_frame->clk_cnt == 0x0UL) { + /* Write data to DCMD */ + __LL_I2C_DAT_Write(Instance, *irq_frame->buf++); + + irq_frame->XferCount--; + + /* wait for transmit finish by interrupt */ + if (irq_frame->XferCount == 0x0UL) { + __LL_I2C_Timing_WriteStop(Instance, *irq_frame->buf); + /* I2C TX Empty Interrupt Disable */ + __LL_I2C_TxEmpty_INT_Dis(Instance); + irq_frame->buf = NULL; + } + } else { + //Read, send the read signal actually acts as ii_clk + __LL_I2C_Timing_Read(Instance); + irq_frame->clk_cnt --; + + if (irq_frame->clk_cnt == 0) { + //read last byte, then stop + __LL_I2C_Timing_ReadStop(Instance); + /* I2C TX Empty Interrupt Disable */ + __LL_I2C_TxEmpty_INT_Dis(Instance); + + } + } + } + + LL_I2C_TxEmptyCallback(Instance); + } + + if (i2c_int_sta & I2C_TX_OVER_INT_STA_Msk) { + __LL_I2C_TxOverRawIntSta_Clr(Instance); + LL_I2C_TxOverCallback(Instance); + } + + if (i2c_int_sta & I2C_RX_FULL_INT_STA_Msk) { + //Auto clear according to RXFIFO status + if ((irq_frame != NULL) && (irq_frame->buf_len != NULL)) { + /* wait RXFIFO not empty */ + while (!__LL_I2C_IsRxFIFONotEmpty(Instance)); + + /* Read data from DCMD */ + *irq_frame->buf++ = __LL_I2C_DAT_Read(Instance); + irq_frame->XferCount--; + + if (irq_frame->XferCount == 0) { + /* I2C RX Full Interrupt Disable */ + __LL_I2C_RxFull_INT_Dis(Instance); + irq_frame->buf = NULL; + } + } + + LL_I2C_RxFullCallback(Instance); + } + + if (i2c_int_sta & I2C_RX_OVER_INT_STA_Msk) { + __LL_I2C_RxOverRawIntSta_Clr(Instance); + LL_I2C_RxOverCallback(Instance); + } + + if (i2c_int_sta & I2C_RX_UNDER_INT_STA_Msk) { + __LL_I2C_RxUnderRawIntSta_Clr(Instance); + LL_I2C_RxUnderCallback(Instance); + } + + if (__LL_I2C_SMBUS_IsMstClkExtendTimeout(Instance)) { + __LL_I2C_SMBUS_MstClkExtendTimeoutRawIntSta_Clr(Instance); + LL_SMBUS_MstClkExtTimeoutCallback(Instance); + } + + if (__LL_I2C_SMBUS_IsSlvClkExtendTimeout(Instance)) { + __LL_I2C_SMBUS_SlvClkExtendTimeoutRawIntSta_Clr(Instance); + LL_SMBUS_SlvClkExtTimeoutCallback(Instance); + } +} + +/** + * @brief I2C SCL stuck at low interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_SCLStuckAtLowCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_SCLStuckAtLowCallback could be implemented in the user file + */ +} + +/** + * @brief I2C master on hold interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_MstOnHoldCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_MstOnHoldCallback could be implemented in the user file + */ +} + +/** + * @brief I2C slave restart detect interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_SlvRestartDetCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_SlvRestartDetCallback could be implemented in the user file + */ +} + +/** + * @brief I2C slave genaral call interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_SlvGenCallCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_SlvGenCallCallback could be implemented in the user file + */ +} + +/** + * @brief I2C start detect interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_StartDetCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_StartDetCallback could be implemented in the user file + */ +} + +/** + * @brief I2C stop detect interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_StopDetCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_StopDetCallback could be implemented in the user file + */ +} + +/** + * @brief I2C activity interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_ActivityCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_ActivityCallback could be implemented in the user file + */ +} + +/** + * @brief I2C slave rx done interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_SlvRxDoneCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_SlvRxDoneCallback could be implemented in the user file + */ +} + +/** + * @brief I2C tx abort interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_TxAbortCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_TxAbortCallback could be implemented in the user file + */ +} + +/** + * @brief I2C slave read request interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_SlvReadReqCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_SlvReadReqCallback could be implemented in the user file + */ +} + +/** + * @brief I2C tx empty interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_TxEmptyCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_TxEmptyCallback could be implemented in the user file + */ +} + +/** + * @brief I2C tx over interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_TxOverCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_TxOverCallback could be implemented in the user file + */ +} + +/** + * @brief I2C rx full interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_RxFullCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_RxFullCallback could be implemented in the user file + */ +} + +/** + * @brief I2C rx over interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_RxOverCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_RxOverCallback could be implemented in the user file + */ +} + +/** + * @brief I2C rx under interrupt callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_I2C_RxUnderCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_I2C_RxUnderCallback could be implemented in the user file + */ +} +/** + * @} + */ + + +/** + * @brief SMBUS SlvClkExtendTimeout Callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_SMBUS_SlvClkExtTimeoutCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_SMBUS_SlvClkExtTimeoutCallback could be implemented in the user file + */ + +} + +/** + * @brief SMBUS MstClkExtendTimeout Callback + * @param Instance Specifies I2C peripheral + * @return None + */ +__WEAK void LL_SMBUS_MstClkExtTimeoutCallback(I2C_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_SMBUS_MstClkExtTimeoutCallback could be implemented in the user file + */ + +} + + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ +/** @defgroup I2C_LL_Private_Functions I2C LL Private function + * @brief I2C LL Private function + * @{ + */ +#ifdef LL_DMA_MODULE_ENABLED + +/** + * @brief I2C LL DMA Init + * @param dma_user_cfg user dma config pointer + * @param Timeout Limited operation time + * @return DMA_ChannelETypeDef + */ +static DMA_ChannelETypeDef LL_I2C_DMA_Init(DMA_UserCfgTypeDef *dma_user_cfg) +{ + DMA_ChannelETypeDef ch = DMA_CHANNEL_INVALID; + int ret; + + /* User DAM channel request */ + ch = LL_DMA_ChannelRequest(); + + if (ch == DMA_CHANNEL_INVALID) { + LOG_E("Requset DMA channel Fail!\n"); + return DMA_CHANNEL_INVALID; + } + + /* User DMA init */ + ret = LL_DMA_Init(DMA, ch, dma_user_cfg); + + if (ret) { + LOG_E("DMA LL init fail!\n"); + LL_DMA_ChannelRelease(ch); + ch = DMA_CHANNEL_INVALID; + return DMA_CHANNEL_INVALID; + } + + return ch; +} + + +/** + * @brief I2C LL DMA Deinit + * @param Instance Specifies I2C peripheral + * @param frame frame pointer + * @return LL_StatusETypeDef + */ +static LL_StatusETypeDef LL_I2C_DMA_Deinit(DMA_ChannelETypeDef ch) +{ + /* DMA stop work */ + LL_DMA_Stop_IT(DMA, ch); + + /* Deinit DMA after tranfer completed */ + LL_DMA_DeInit(DMA, ch); + + /* DMA LL channel release */ + LL_DMA_ChannelRelease(ch); + + return LL_OK; +} + + +/** + * @brief I2C DMA TX Channel complete callback + * @param arg Unlimited parameter + * @return None + */ +static void LL_I2C_DMA_TXCHEndCallback(void *arg) +{ + I2C_FrameTypeDef *p_frame = ((I2C_FrameTypeDef *)arg); + + /* The last frame of the Master needs to be sent with stop */ + if (__LL_I2C_IsMasterMode(p_frame->Instance) == ENABLE) { + if (p_frame->clk_cnt != 0) { + __LL_I2C_Timing_ReadStop(p_frame->Instance); + } else { + __LL_I2C_Timing_WriteStop(p_frame->Instance, *(p_frame->buf + p_frame->buf_len - 1)); + } + + /* wait for last data sent */ + while (!__LL_I2C_IsStopDet_Raw(p_frame->Instance)); + } else { + /* Clear ReadReqRaw Status*/ + __LL_I2C_SLV_ReadReqRawIntSta_Clr(p_frame->Instance); + p_frame->clk_cnt = 0; + + /* wait for last data sent */ + while (!__LL_I2C_MST_IsOnHold_Raw(p_frame->Instance)); + } + + /* I2C LL DMA Deinit */ + LL_I2C_DMA_Deinit(p_frame->dma_tx_ch); + + /* Disable Transmit DMA func */ + p_frame->dma_tx_ch = DMA_CHANNEL_INVALID; + + /* process has been finished */ + p_frame->TXdma_status = IIC_DMA_STATE_FINISH; + + /* Disable Transmit DMA func */ + __LL_I2C_TxDMA_Dis(p_frame->Instance); +} + +/** + * @brief I2C DMA RX Channel complete callback + * @param arg Unlimited parameter + * @return None + */ +static void LL_I2C_DMA_RXCHEndCallback(void *arg) +{ + I2C_FrameTypeDef *p_frame = ((I2C_FrameTypeDef *)arg); + + /* wait for last data sent */ + while (!__LL_I2C_IsStopDet_Raw(p_frame->Instance)); + + /* I2C LL DMA Deinit */ + LL_I2C_DMA_Deinit(p_frame->dma_rx_ch); + + p_frame->dma_rx_ch = DMA_CHANNEL_INVALID; + + /* process has been finished */ + p_frame->RXdma_status = IIC_DMA_STATE_FINISH; + + /* Disable Receive DMA func */ + __LL_I2C_RxDMA_Dis(p_frame->Instance); + +} + +/** + * @brief I2C DMA TX Channel Error callback + * @param arg Unlimited parameter + * @return None + */ +static void LL_I2C_DMA_TXCHErrorCallBck(void *arg) +{ + I2C_FrameTypeDef *p_frame = ((I2C_FrameTypeDef *)arg); + + /* I2C LL DMA Deinit */ + LL_I2C_DMA_Deinit(p_frame->dma_tx_ch); + p_frame->dma_tx_ch = DMA_CHANNEL_INVALID; + + /* process has been Error */ + p_frame->TXdma_status = IIC_DMA_STATE_ERROR; + + /* Disable Transmit DMA func */ + __LL_I2C_TxDMA_Dis(p_frame->Instance); +} + +/** + * @brief I2C DMA RX Channel Error callback + * @param arg Unlimited parameter + * @return None + */ +static void LL_I2C_DMA_RXCHErrorCallBck(void *arg) +{ + I2C_FrameTypeDef *p_frame = ((I2C_FrameTypeDef *)arg); + + /* I2C LL DMA Deinit */ + LL_I2C_DMA_Deinit(p_frame->dma_rx_ch); + p_frame->dma_rx_ch = DMA_CHANNEL_INVALID; + + /* process has been Error */ + p_frame->RXdma_status = IIC_DMA_STATE_ERROR; + + /* Disable Transmit DMA func */ + __LL_I2C_RxDMA_Dis(p_frame->Instance); +} + + +#endif /*!< LL_DMA_MODULE_ENABLED */ +/** + * @} + */ + + +#endif /* LL_I2C_MODULE_ENABLED */ + +/** + * @} + */ + +/** + * @} + */ + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_iir.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_iir.c new file mode 100644 index 0000000000..87ddf1beaf --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_iir.c @@ -0,0 +1,428 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_iir.c + * @author MCD Application Team + * @brief IIR LL module driver. + * This file provides firmware functions to manage the following + * functionalities of the IIR peripheral: + * + Initialization and De-Initialization functions + * + Start and Stop functions + * + Get output data function + * + Reset internal buffer function + * + Interrupt and Callback functions + + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "IIR LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup IIR_LL IIR LL + * @brief IIR LL module driver + * @{ + */ + +#ifdef LL_IIR_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup IIR_LL_Exported_functions IIR LL Exported functions + * @brief IIR LL Exported functions + * @{ + */ + +/** @defgroup IIR_LL_Exported_Functions_Group1 Initialization and De-Initialization functions + * @brief Initialization and De-Initialization functions +@verbatim + =============================================================================== + ##### Initialization and De-Initialization functions ##### + =============================================================================== + [..] This section provides a set of functions allowing to initialize and + deinitialize the IIR peripheral + +@endverbatim + * @{ + */ + +/** + * @brief Initializes the IIR peripheral. + * @param Instance Specifies IIR peripheral. + * @param Init pointer to a IIR_InitTypeDef structure that contains the + * configuration information for the specified IIR peripheral. + * @return status of the initialization + */ +LL_StatusETypeDef LL_IIR_Init(IIR_TypeDef *Instance, IIR_InitTypeDef *Init) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + + /* Handle Something */ + LL_IIR_MspInit(Instance); + + /* IIRx_CR0 Configure : IIR Order select, Internal buffer reset and + enable IIR peripheral */ + WRITE_REG(Instance->CR0, (Init->Order | Init->BufferReset)); + + /* Enable the IIR peripheral */ + __LL_IIR_ENABLE(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief De-initializes the IIR peripheral registers to their default reset values. + * @param IIRx where x can be (0, 1, ...) to select the IIR peripheral. + * @retval status of the de-initialization + */ +LL_StatusETypeDef LL_IIR_DeInit(IIR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + + /* Disable IIR */ + __LL_IIR_DISABLE(Instance); + + /* Handle Something */ + LL_IIR_MspDeInit(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Initializes the IIR MSP. + * @param Instance IIR peripheral + * @return None + */ +__WEAK void LL_IIR_MspInit(IIR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_IIR_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the IIR MSP + * @param Instance IIR peripheral + * @return None + */ +__WEAK void LL_IIR_MspDeInit(IIR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_IIR_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + + +/** @defgroup IIR_LL_Exported_Functions_Group2 IIR Peripheral Control functions + * @brief IIR Peripheral Control functions +@verbatim + =============================================================================== + ##### Peripheral Control functions ##### + =============================================================================== + [..] This section provides functions allowing to: + (+) Configure the IIR control registers + (+) Configure the IIR preload control registers + +@endverbatim + * @{ + */ + +/** + * @brief Configures the IIR filter + * @param Instance IIR peripheral. + * @param Config pointer to a IIR_ConfigTypeDef structure that contains + * the configuration information for the specified IIR peripheral. + * @return status of the configuration + */ +LL_StatusETypeDef LL_IIR_FilterConfig(IIR_TypeDef *Instance, IIR_ConfigTypeDef *Config) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + assert_param(IS_IIR_INPUT_DATA_SCALE(Config->InDataScale)); + assert_param(IS_IIR_OUTPUT_DATA_SCALE(Config->OutDataScale)); + assert_param(IS_IIR_FEEDBACK_SCALE(Config->FeedBackScale)); + + /* IIR Scale configure : Output data scale, Input data scale and Feedback scale */ + WRITE_REG(Instance->SCALR, (((uint32_t)(Config->InDataScale << IIR_SCALR_DISCAL_Pos)) | + ((uint32_t)(Config->FeedBackScale << IIR_SCALR_FBSCAL_Pos)) | + ((uint32_t)(Config->OutDataScale << IIR_SCALR_DOSCAL_Pos)))); + + /* IIR Data Input Address */ + WRITE_REG(Instance->DIAR, Config->InDataAddress); + + /* fill the coefficients */ + for (int idx = 0; idx < ARRAY_SIZE(Config->AxCOEF); idx++) { + WRITE_REG(Instance->AxCOEFR[idx], ((uint32_t)(Config->AxCOEF[idx]) & IIR_AxCOEFR_AxCOEF_Msk)); + } + + for (int idx = 0; idx < ARRAY_SIZE(Config->BxCOEF); idx++) { + WRITE_REG(Instance->BxCOEFR[idx], ((uint32_t)(Config->BxCOEF[idx]) & IIR_BxCOEFR_BxCOEF_Msk)); + } + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Configures the IIR filter preload registers + * @note This function is related to IIR Auto-Reload feature. + * Using __LL_IIR_AUTORELAOD_ENABLE() will auto-reload this configures. + * Using LL_IIR_FilterStart[_IT]() will auto-reload this configures(with AutoReload enabled) then start an IIR filter. + * @param Instance IIR peripheral. + * @param Config pointer to a IIR_ConfigTypeDef structure that contains + * the configuration information for the specified IIR peripheral. + * @return status of the configuration + */ +LL_StatusETypeDef LL_IIR_FilterConfig_Preload(IIR_TypeDef *Instance, IIR_ConfigTypeDef *Config) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + assert_param(IS_IIR_INPUT_DATA_SCALE(Config->InDataScale)); + assert_param(IS_IIR_OUTPUT_DATA_SCALE(Config->OutDataScale)); + assert_param(IS_IIR_FEEDBACK_SCALE(Config->FeedBackScale)); + + /* IIR Scale configure : Output data scale, Input data scale and Feedback scale */ + WRITE_REG(Instance->SCALSR, (((uint32_t)(Config->InDataScale << IIR_SCALSR_DISCALS_Pos)) | + ((uint32_t)(Config->FeedBackScale << IIR_SCALSR_FBSCALS_Pos)) | + ((uint32_t)(Config->OutDataScale << IIR_SCALSR_DOSCALS_Pos)))); + + /* IIR Data Input Address */ + WRITE_REG(Instance->DIASR, Config->InDataAddress); + + /* fill the coefficients */ + for (int idx = 0; idx < ARRAY_SIZE(Config->AxCOEF); idx++) { + WRITE_REG(Instance->AxCOEFSR[idx], ((uint32_t)(Config->AxCOEF[idx]) & IIR_AxCOEFSR_AxCOEFS_Msk)); + } + + for (int idx = 0; idx < ARRAY_SIZE(Config->BxCOEF); idx++) { + WRITE_REG(Instance->BxCOEFSR[idx], ((uint32_t)(Config->BxCOEF[idx]) & IIR_BxCOEFSR_BxCOEFS_Msk)); + } + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup IIR_LL_Exported_Functions_Group3 IIR Input and Output operation functions + * @brief IIR Input and Output operation functions +@verbatim + =============================================================================== + ##### Input and Output operation functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) start and stop functions. + (+) start and stop with interrupt functions. + (+) get output data function. + (+) reset internal buffer function. + +@endverbatim + * @{ + */ + +/** + * @brief Start an IIR Filter for current input data + * @param Instance IIR peripheral. + * @param AutoReload specifies IIR Auto-Reload the preloaded configures or not. + * This parameter can be one of the following values: + * @arg IIR_AUTORELOAD_DISABLE: Disable Auto-Reload feature. + * @arg IIR_AUTORELOAD_ENABLE: Auto-Reload the preload configures before starting IIR filter. + * @note The preloaded configures should be configured by calling LL_IIR_FilterConfig_Preload() function, + * before enable Auto-Reload feature. + * @return LL status + */ +LL_StatusETypeDef LL_IIR_FilterStart(IIR_TypeDef *Instance, IIR_ATReloadETypeDef AutoReload) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + + /* Configure the Auto-Reload feature before start the IIR filter */ + if (AutoReload != IIR_AUTORELOAD_DISABLE) { + __LL_IIR_AUTORELOAD_ENABLE(Instance); + } + + /* Start the IIR filter */ + __LL_IIR_FILTER_START(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Start an IIR Filter for current input data with interrupt + * @param Instance IIR peripheral. + * @param AutoReload specifies IIR Auto-Reload the preloaded configures or not. + * This parameter can be one of the following values: + * @arg IIR_AUTORELOAD_DISABLE: Disable Auto-Reload feature. + * @arg IIR_AUTORELOAD_ENABLE: Auto-Reload the preload configures before starting IIR filter. + * @note The preloaded configures should be configured by calling LL_IIR_FilterConfig_Preload() function, + * before enable Auto-Reload feature + * @return LL status + */ +LL_StatusETypeDef LL_IIR_FilterStart_IT(IIR_TypeDef *Instance, IIR_ATReloadETypeDef AutoReload) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + + /* Enable IIR interrupt */ + __LL_IIR_ENABLE_IT(Instance, IIR_IT_FDIE); + + /* Configure the Auto-Reload feature before start the IIR filter */ + if (AutoReload != IIR_AUTORELOAD_DISABLE) { + __LL_IIR_AUTORELOAD_ENABLE(Instance); + } + + /* Start the IIR filter */ + __LL_IIR_FILTER_START(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Get the latest IIR filter output data + * @param Instance IIR peripheral. + * @return IIR filter output data + */ +int16_t LL_IIR_FilterDataGet(IIR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + + /* Return the IIR filter output data */ + return (int16_t)(READ_REG(Instance->DOR) & 0xFFFFUL); +} + +/** + * @brief Reset the IIR internal data buffer. + * @param Instance IIR peripheral. + * @return LL status + */ +LL_StatusETypeDef LL_IIR_FilterBufferReset(IIR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + + /* IIR Internal Buffer Reset control */ + __LL_IIR_FILTER_BUFFER_RESET(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup IIR_LL_Exported_Functions_Interrupt IIR Initerrupt management + * @brief IIR Initerrupt management +@verbatim + =============================================================================== + ##### Initerrupt management ##### + =============================================================================== + [..] + This section provides IIR interrupt handler and callback functions. + +@endverbatim + * @{ + */ + +/** + * @brief This function handles IIR interrupts requests. + * @param Instance IIR peripheral + * @return None + */ +void LL_IIR_IRQHandler(IIR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_IIR_ALL_INSTANCE(Instance)); + + if ((__LL_IIR_IT_CHECK_SOURCE(Instance, IIR_IT_FDIE) != RESET) && (__LL_IIR_GET_FLAG(Instance, IIR_FLAG_FDIF) != RESET)) { + /* Clear the FDIF interrupt flag */ + __LL_IIR_CLEAR_FLAG(Instance, IIR_FLAG_FDIF); + + /* IIR Fliter done callback */ + LL_IIR_FilterDoneCallBack(Instance); + } +} +/** + * @brief IIR Fliter done callback + * @param Instance IIR peripheral + * @return None + */ +__WEAK void LL_IIR_FilterDoneCallBack(IIR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_IIR_FilterDoneCallBack could be implemented in the user file + */ +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_GPIO_MODULE_ENABLE */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_iwdg.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_iwdg.c new file mode 100644 index 0000000000..c42be7d7ec --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_iwdg.c @@ -0,0 +1,329 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_iwdg.c + * @author MCD Application Team + * @brief IWDG LL module driver. + * This file provides firmware functions to manage the following + * functionalities of the Independent Watchdog (IWDG) peripheral: + * + Initialization and De-Initialization functions + * + Refresh function + * + Interrupt and Callback functions + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "IWDG LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup IWDG_LL IWDG LL + * @brief IWDG LL module driver. + * @{ + */ + +#ifdef LL_IWDG_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/** @defgroup IWDG_LL_Private_Defines IWDG LL Private Defines + * @brief IWDG LL Private Defines + * @{ + */ + +/** + * @brief Max delay time for IWDG status register update + */ +#define IWDG_TIMEOUT_VALUE 100U +/** + * @} + */ + + +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup IWDG_LL_Exported_Functions IWDG LL Exported Functions + * @brief IWDG LL Exported Functions + * @{ + */ + +/** @defgroup IWDG_LL_Exported_Functions_Group1 Initialization and De-Initialization functions + * @brief Initialization and De-Initialization functions +@verbatim + =============================================================================== + ##### Initialization and de-initialization functions ##### + =============================================================================== + [..] This section provides a set of functions allowing to initialize and + deinitialize the IWDG peripheral + +@endverbatim + * @{ + */ + +/** + * @brief Initializes the IWDG peripheral according to the specified parameters in the Init. + * @param Instance IWDG peripheral instance + * @param Init pointer to a IWDG_InitTypeDef structure that contains the configuration information + * for the specified IWDG peripheral. + * @return status of the initialization + */ +LL_StatusETypeDef LL_IWDG_Init(IWDG_TypeDef *Instance, IWDG_InitTypeDef *Init) +{ + uint32_t tickstart = 0; + + /* Check the IWDG initiation struct allocation */ + if (Init == NULL) { + return LL_ERROR; + } + + /* Check the parameters */ + assert_param(IS_IWDG_ALL_INSTANCE(Instance)); + assert_param(IS_IWDG_RELOAD_Val(Init->Reload_val)); + + /* Handle Something */ + LL_IWDG_MspInit(Instance); + + /* Start IWDG to work */ + __LL_IWDG_START(Instance); + + /* Enable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers */ + __LL_IWDG_ENABLE_WRITE_ACCESS(Instance); + + /* PSCUPD must be 0 before writting prescaler settings to IWDG_PSCR register */ + tickstart = LL_GetTick(); + + while (__LL_IWDG_GET_FLAG(Instance, IWDG_FLAG_PSCUPD) != RESET) { + if ((LL_GetTick() - tickstart) > IWDG_TIMEOUT_VALUE) { + return LL_TIMEOUT; + } + } + + /* Write to IWDG registers the Prescaler to work with */ + WRITE_REG(Instance->PSCR, Init->Prescaler); + + /* RLVUPD must be 0 before writting reload values to IWDG_RLR register */ + tickstart = LL_GetTick(); + + while (__LL_IWDG_GET_FLAG(Instance, IWDG_FLAG_RLVUPD) != RESET) { + if ((LL_GetTick() - tickstart) > IWDG_TIMEOUT_VALUE) { + return LL_TIMEOUT; + } + } + + /* Write to IWDG registers the Reload values to work with */ + WRITE_REG(Instance->RLR, Init->Reload_val); + + /* Configure the IWDG bahavior after timeout */ + MODIFY_REG(Instance->CR, IWDG_CR_MODE, Init->Mode); + + /* Enable IWDG interrupt when using interrupt mode */ + if (Init->Mode == IWDG_MODE_INTERRUPT) { + __LL_IWDG_ENABLE_IT(Instance, IWDG_IT_TOIE); + } + + /* Disable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers */ + __LL_IWDG_DISABLE_WRITE_ACCESS(Instance); + + /* Reload IWDG counter with value defined in the reload register */ + __LL_IWDG_RELOAD_COUNTER(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief De-initializes the IWDG peripheral. + * @param Instance IWDG peripheral + * @return status of the de-initialization + */ +LL_StatusETypeDef LL_IWDG_DeInit(IWDG_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_IWDG_ALL_INSTANCE(Instance)); + + /* Enable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers */ + __LL_IWDG_ENABLE_WRITE_ACCESS(Instance); + + /* Disable the IWDG peripheral. */ + __LL_IWDG_STOP(Instance); + + /* Disable write access to IWDG_PSCR, IWDG_RLR and IWDG_CR registers */ + __LL_IWDG_DISABLE_WRITE_ACCESS(Instance); + + /* Handle Something */ + LL_IWDG_MspDeInit(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Initializes the IWDG MSP. + * @param Instance IWDG peripheral + * @return None + */ +__WEAK void LL_IWDG_MspInit(IWDG_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_IWDG_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the IWDG MSP + * @param Instance IWDG peripheral + * @return None + */ +__WEAK void LL_IWDG_MspDeInit(IWDG_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_IWDG_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + + +/** @defgroup IWDG_LL_Exported_Functions_Group2 IWDG Input and Output operation functions + * @brief IWDG Input and Output operation functions +@verbatim + =============================================================================== + ##### Input and Output operation functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Refresh the IWDG. + +@endverbatim + * @{ + */ + +/** + * @brief Refresh the IWDG. + * @param Instance: IWDG peripheral + * @return LL_Status + */ +LL_StatusETypeDef LL_IWDG_Refresh(IWDG_TypeDef *Instance) +{ + uint32_t tickstart = 0; + /* Check the parameters */ + assert_param(IS_IWDG_ALL_INSTANCE(Instance)); + + /* Notice that RLVUPD and PSCUPD must be 0 before refreshing IWDG counter */ + while ((__LL_IWDG_GET_FLAG(Instance, IWDG_FLAG_RLVUPD) != RESET) || (__LL_IWDG_GET_FLAG(Instance, IWDG_FLAG_PSCUPD) != RESET)) { + if ((LL_GetTick() - tickstart) > IWDG_TIMEOUT_VALUE) { + return LL_TIMEOUT; + } + } + + /* Reload IWDG counter with value defined in the IWDG_RLR register */ + __LL_IWDG_RELOAD_COUNTER(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup IWDG_LL_Exported_Functions_Interrupt IWDG Initerrupt management + * @brief IWDG Initerrupt management +@verbatim + =============================================================================== + ##### Initerrupt management ##### + =============================================================================== + [..] + This section provides IWDG interrupt handler and callback functions. + +@endverbatim + * @{ + */ + +/** + * @brief This function handles IWDG interrupts requests. + * @param Instance: IWDG peripheral + * @return None + */ +void LL_IWDG_IRQHandler(IWDG_TypeDef *Instance) +{ + if ((__LL_IWDG_IT_CHECK_SOURCE(Instance, IWDG_IT_TOIE) != RESET) && (__LL_IWDG_GET_FLAG(Instance, IWDG_FLAG_TOIF) != RESET)) { + /* Clear the TOIF interrupt flag */ + __LL_IWDG_CLEAR_FLAG(Instance, IWDG_FLAG_TOIF); + + /* IWDG timeout callback */ + LL_IWDG_TimeOutCallBack(Instance); + } +} + +/** + * @brief Timeout callback + * @param Instance IWDG peripheral + * @return None + */ +__WEAK void LL_IWDG_TimeOutCallBack(IWDG_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_IWDG_TimeOutCallBack could be implemented in the user file + */ +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_IWDG_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_lvdctrl.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_lvdctrl.c new file mode 100644 index 0000000000..6437d49311 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_lvdctrl.c @@ -0,0 +1,185 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_lvdctrl.c + * @author MCD Application Team + * @brief LVDCTRL LL Module Driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "LVD" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup LVDCTRL_LL LVDCTRL LL + * @brief LVDCTRL LL Module Driver + * @{ + */ + +#ifdef LL_LVD_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup LVDCTRL_LL_Exported_Functions LVDCTRL LL Exported Functions + * @brief LVDCTRL LL Exported Functions + * @{ + */ + +/** @defgroup LVDCTRL_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and de-initialization functions + * @{ + */ + +/** + * @brief Initializes the LVD peripheral + * @param Instance Specifies LVD peripheral + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_LVD_Init(LVD_TypeDef *Instance) +{ + /* Init the low level hardware eg. Clock, NVIC */ + LL_LVD_MspInit(Instance); + + //Enable LVD Module according to need + __LL_LVDCTRL_VCC_LowVolDet_En(Instance); + __LL_LVDCTRL_AVCC_LowVolDet_En(Instance); + __LL_LVDCTRL_VDD_OverCurDet_En(Instance); + __LL_LVDCTRL_VDD_LowVolDet_En(Instance); + + return LL_OK; +} + +/** + * @brief DeInitializes the LVD peripheral + * @param Instance Specifies LVD peripheral + * @return Status of the DeInitialization + */ +LL_StatusETypeDef LL_LVD_DeInit(LVD_TypeDef *Instance) +{ + /* DeInit the low level hardware eg. Clock, NVIC */ + LL_LVD_MspDeInit(Instance); + + //Disable LVD Module according to need + __LL_LVDCTRL_VCC_LowVolDet_Dis(Instance); + __LL_LVDCTRL_AVCC_LowVolDet_Dis(Instance); + __LL_LVDCTRL_VDD_OverCurDet_Dis(Instance); + __LL_LVDCTRL_VDD_LowVolDet_Dis(Instance); + + return LL_OK; +} + +/** + * @brief Initializes the LVD MSP + * @param Instance Specifies LVD peripheral + * @retval None + */ +__WEAK void LL_LVD_MspInit(LVD_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_LVD_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the LVD MSP + * @param Instance Specifies LVD peripheral + * @retval None + */ +__WEAK void LL_LVD_MspDeInit(LVD_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_LVD_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + + +/** @defgroup LVDCTRL_LL_Exported_Functions_Interrupt LVDCTRL Interrupt Management + * @brief LVDCTRL Interrupt Management + * @{ + */ + +/** + * @brief LL LVDCTRL IRQ Handler + * @param Instance Specifies LVD peripheral + * @retval None + */ +void LL_LVD_CtrlIRQHandler(LVD_TypeDef *Instance) +{ + if (__LL_LVDCTRL_IsVDDOverCur(Instance)) { + LOG_D("VDD Over Current INT.\n"); + //:TODO: add process code according to need + } + + if (__LL_LVDCTRL_IsVDDLowVol(Instance)) { + LOG_D("VDD Low Voltage INT.\n"); + //:TODO: add process code according to need + } + + if (__LL_LVDCTRL_IsVCCLowVol(Instance)) { + LOG_D("VCC Low Voltage INT.\n"); + //:TODO: add process code according to need + } + + if (__LL_LVDCTRL_IsAVCCLowVol(Instance)) { + LOG_D("AVCC Low Voltage INT.\n"); + //:TODO: add process code according to need + } +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_LVD_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_sysctrl.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_sysctrl.c new file mode 100644 index 0000000000..8819f98703 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_sysctrl.c @@ -0,0 +1,1658 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_sysctrl.c + * @author MCD Application Team + * @brief SYSCTRL LL Module Driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "SYSCTRL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup SYSCTRL_LL SYSCTRL LL + * @brief SYSCTRL LL Module Driver + * @{ + */ + + +/* Private define ------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/** @defgroup SYSCTRL_LL_Private_Types SYSCTRL LL Private Types + * @brief SYSCTRL LL Private Types + * @{ + */ + +/** + * @brief SYSCTRL PLL0/1/2 Config Type Define + * @note pll_out_freq is before PLL Post Div + */ +typedef struct __SYSCTRL_PLLCfgTypedef { + uint32_t pll_in_freq; /*!< PLL Input Freq */ + uint32_t pll_out_freq; /*!< PLL Output Freq */ + uint8_t pll_pre_div; /*!< PLL Pre-Div */ + uint16_t fpll_int; /*!< FPLL Integer */ + uint16_t fpll_frac; /*!< FPLL Fraction */ + uint32_t pll_vco_band; /*!< PLL VCO Band */ + uint32_t pll_vco_gain; /*!< PLL VCO Gain */ +} SYSCTRL_PLLCfgTypedef; + +/** + * @} + */ + + +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/** @defgroup SYSCTRL_LL_Private_Variables SYSCTRL LL Private Variables + * @brief SYSCTRL LL Private Variables + * @{ + */ + +/** + * @brief SYSCLK PLL Config Const Array Definition + * @note VCO band&gain config are the same to PLL0/1/2 + */ +static const SYSCTRL_PLLCfgTypedef sysctrl_pll_cfg[] = { + {8000000, 100000000, 1, 6, 0x4000, SYSCTRL_PLL0_BAND_312M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->100M */ + {8000000, 110000000, 1, 6, 0xe000, SYSCTRL_PLL0_BAND_312M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->110M */ + {8000000, 120000000, 1, 7, 0x8000, SYSCTRL_PLL0_BAND_312M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->120M */ + {8000000, 130000000, 1, 8, 0x2000, SYSCTRL_PLL0_BAND_312M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->130M */ + + {8000000, 140000000, 1, 8, 0xc000, SYSCTRL_PLL0_BAND_396M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->140M */ + {8000000, 150000000, 1, 9, 0x6000, SYSCTRL_PLL0_BAND_396M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->150M */ + {8000000, 160000000, 1, 10, 0, SYSCTRL_PLL0_BAND_396M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->160M */ + {8000000, 170000000, 1, 10, 0xa000, SYSCTRL_PLL0_BAND_396M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->170M */ + + {8000000, 180000000, 1, 11, 0x4000, SYSCTRL_PLL0_BAND_466M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->180M */ + {8000000, 190000000, 1, 11, 0xe000, SYSCTRL_PLL0_BAND_466M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->190M */ + {8000000, 200000000, 1, 12, 0x8000, SYSCTRL_PLL0_BAND_466M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->200M */ + + {8000000, 210000000, 1, 13, 0x2000, SYSCTRL_PLL0_BAND_520M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->210M */ + {8000000, 220000000, 1, 13, 0xc000, SYSCTRL_PLL0_BAND_520M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->220M */ + {8000000, 230000000, 1, 14, 0x6000, SYSCTRL_PLL0_BAND_520M, SYSCTRL_PLL0_GVCO_2}, /*!8M,PLL0Out->230M */ +}; + +/** + * @} + */ + + +/* Private function prototypes -----------------------------------------------*/ +/** @defgroup SYSCTRL_LL_Private_Functions SYSCTRL LL Private Functions + * @brief SYSCTRL LL Private Functions + * @{ + */ +static void LL_SYSCTRL_XOSCCfg(SYSCTRL_TypeDef *Instance); +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup SYSCTRL_LL_Exported_Functions SYSCTRL LL Exported Functions + * @brief SYSCTRL LL Exported Functions + * @{ + */ + +/** @defgroup SYSCTRL_LL_Exported_Functions_Group1 SYSCTRL Clock Config Functions + * @brief SYSCTRL Clock Config Functions + * @{ + */ + +/** + * @brief SYSCTRL LL SYSCLK Init + * @param Instance Specifies SYSCTRL peripheral + * @param sysclk_cfg SYSCLK Config Pointer + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_SYSCTRL_SysclkInit(SYSCTRL_TypeDef *Instance, SYSCTRL_SysclkUserCfgTypeDef *sysclk_cfg) +{ + uint16_t sysclk_div, remain; + SYSCTRL_PLLUserCfgTypeDef pll0_cfg; + LL_StatusETypeDef ret = LL_ERROR; + + //Check params to be valid + if (Instance == NULL || sysclk_cfg == NULL) { + LOG_E("SYSCLK init params error!\n"); + return LL_ERROR; + } + + assert_param(sysclk_cfg->sysclk_freq); + + //Auto Freq Config + if (sysclk_cfg->sysclk_src == SYSCLK_SRC_RC32K) { //SYSCLK Source RC32K + sysclk_cfg->sysclk_src_freq = LSI_VALUE; + } else if (sysclk_cfg->sysclk_src == SYSCLK_SRC_RC8M) { //SYSCLK Source RC8M + sysclk_cfg->sysclk_src_freq = HSI_VALUE; + } else if (sysclk_cfg->sysclk_src == SYSCLK_SRC_HOSC) { //SYSCLK Source HOSC + if (!sysclk_cfg->sysclk_src_freq) { //Hardware can AutoSwitch + sysclk_cfg->sysclk_src_freq = HSE_VALUE; + } + } else if (sysclk_cfg->sysclk_src == SYSCLK_SRC_PLL0DivClk) { //SYSCLK Source PLL0DivClk + if (sysclk_cfg->pll0clk_src == PLLCLK_SRC_XOSC) { //PLL0 CLK Source HOSC + if (!sysclk_cfg->pll0clk_src_freq) { //Hardware can AutoSwitch + sysclk_cfg->pll0clk_src_freq = HSE_VALUE; + } + } else if (sysclk_cfg->pll0clk_src == PLLCLK_SRC_RC8M) { //PLL0 CLK Source RC8M + sysclk_cfg->pll0clk_src_freq = HSI_VALUE; + } + } + + //Check APB0/APB1 Clock Div to be valid + if (sysclk_cfg->apb0_clk_div == SYSCTRL_CLK_DIV_IVD) { + sysclk_cfg->apb0_clk_div = SYSCTRL_CLK_DIV_1; + } + + if (sysclk_cfg->apb1_clk_div == SYSCTRL_CLK_DIV_IVD) { + sysclk_cfg->apb1_clk_div = SYSCTRL_CLK_DIV_1; + } + + //Calculate SYSCLK division + if (sysclk_cfg->sysclk_src != SYSCLK_SRC_PLL0DivClk) { + sysclk_div = sysclk_cfg->sysclk_src_freq / sysclk_cfg->sysclk_freq; + remain = sysclk_cfg->sysclk_src_freq % sysclk_cfg->sysclk_freq; + + if (!sysclk_div || remain) { + LOG_E("Can't division %d SYSCLK from %d Source CLK!\n", sysclk_cfg->sysclk_freq, sysclk_cfg->sysclk_src_freq); + return LL_ERROR; + } + } + + //SYSCTRL CTRL Register Unlock + __LL_SYSCTRL_CTRLReg_Unlock(Instance); + + //Config SYSCLK + switch (sysclk_cfg->sysclk_src) { + case SYSCLK_SRC_RC32K: + LOG_I("SYSCLK-[%d] source select RC32K.\n", sysclk_cfg->sysclk_freq); + __LL_SYSCTRL_SysClkSrc_Set(Instance, SYSCTRL_SYSCLK_SRC_RC32K); + __LL_SYSCTRL_SysClkDiv_Set(Instance, sysclk_div); + ret = LL_OK; + break; + + case SYSCLK_SRC_RC8M: + LOG_I("SYSCLK-[%d] source select RC8M.\n", sysclk_cfg->sysclk_freq); + __LL_SYSCTRL_RC8M_En(Instance); + __LL_SYSCTRL_SysClkSrc_Set(Instance, SYSCTRL_SYSCLK_SRC_RC8M); + __LL_SYSCTRL_SysClkDiv_Set(Instance, sysclk_div); + ret = LL_OK; + break; + + case SYSCLK_SRC_PLL0DivClk: + //SYSCLK PLL0 Config + pll0_cfg.pll_clk_src = sysclk_cfg->pll0clk_src; + pll0_cfg.pll_in_freq = sysclk_cfg->pll0clk_src_freq; + pll0_cfg.pll_user_freq = sysclk_cfg->sysclk_freq; + ret = LL_SYSCTRL_Pll0Cfg(Instance, &pll0_cfg); + + //SYCTRL CTRL Reg Unlock because Pll0Cfg function has lock before return + __LL_SYSCTRL_CTRLReg_Unlock(Instance); + + //SYSCLK Source Select PLL0DivClk, and SYSCLK Div set to default 1 + if (ret == LL_OK) { + LOG_I("SYSCLK-[%d] source select PLL0DivClk.\n", sysclk_cfg->sysclk_freq); + __LL_SYSCTRL_SysClkSrc_Set(Instance, SYSCTRL_SYSCLK_SRC_PLLDivClk); + __LL_SYSCTRL_SysClkDiv_Set(Instance, SYSCTRL_CLK_DIV_1); + } + + break; + + case SYSCLK_SRC_HOSC: + LOG_I("SYSCLK-[%d] source select HOSC-[%d].\n", sysclk_cfg->sysclk_freq, sysclk_cfg->sysclk_src_freq); + LL_SYSCTRL_XOSCCfg(Instance); + __LL_SYSCTRL_SysClkSrc_Set(Instance, SYSCTRL_SYSCLK_SRC_HOSC); + __LL_SYSCTRL_SysClkDiv_Set(Instance, sysclk_div); + ret = LL_OK; + break; + + default: + LOG_E("SYSCLK Source Select-[%d] Error!\n", sysclk_cfg->sysclk_src); + ret = LL_ERROR; + break; + } + + if (ret == LL_OK) { + //APB0/APB1 Clock Div Config + __LL_SYSCTRL_APB0ClkDiv_Set(Instance, sysclk_cfg->apb0_clk_div); + __LL_SYSCTRL_APB1ClkDiv_Set(Instance, sysclk_cfg->apb1_clk_div); + + //APB0/APB1/ABH0 Bus Clock Enable + __LL_SYSCTRL_APB0Clk_En(Instance); + __LL_SYSCTRL_APB1Clk_En(Instance); + __LL_SYSCTRL_AHBClk_En(Instance); + + //APB0/APB1/ABH0 Soft Reset Release + __LL_SYSCTRL_APB0BusSoftRst_Release(Instance); + __LL_SYSCTRL_APB1BusSoftRst_Release(Instance); + __LL_SYSCTRL_AHBBusSoftRst_Release(Instance); + + //RAM2/RAM1/RAM0 Bus Clock Enable + __LL_SYSCTRL_RAM2BusClk_En(Instance); + __LL_SYSCTRL_RAM1BusClk_En(Instance); + __LL_SYSCTRL_RAM0BusClk_En(Instance); + } + + //SYSCTRL Register Lock + __LL_SYSCTRL_Reg_Lock(Instance); + + return ret; +} + +/** + * @brief SYSCTRL LL GPIOA Debounce Clock Config + * @param src GPIOA Debounce Clock Source + * @param div GPIOA Debounce Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_GPIOA_DbcClkCfg(SYSCTRL_GPIOADbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_256) { + LOG_E("GPIOA Debounce CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOADbcSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_GPIOADbcClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL GPIOB Debounce Clock Config + * @param src GPIOB Debounce Clock Source + * @param div GPIOB Debounce Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_GPIOB_DbcClkCfg(SYSCTRL_GPIOBDbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_256) { + LOG_E("GPIOB Debounce CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOBDbcSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_GPIOBDbcClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL GPIOC Debounce Clock Config + * @param src GPIOC Debounce Clock Source + * @param div GPIOC Debounce Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_GPIOC_DbcClkCfg(SYSCTRL_GPIOCDbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_256) { + LOG_E("GPIOC Debounce CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOCDbcSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_GPIOCDbcClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL GPIOD Debounce Clock Config + * @param src GPIOD Debounce Clock Source + * @param div GPIOD Debounce Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_GPIOD_DbcClkCfg(SYSCTRL_GPIODDbcClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_256) { + LOG_E("GPIOD Debounce CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIODDbcSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_GPIODDbcClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL DFLASH Clock Config + * @param src DFLASH Clock Source + * @param div DFLASH Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_DFLASH_ClkCfg(SYSCTRL_DflashClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_16) { + LOG_E("DFLASH CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DFLASHMemClkSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_DFLASHMemClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL EFLASH Clock Config + * @param src EFLASH Clock Source + * @param div EFLASH Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_EFLASH_ClkCfg(SYSCTRL_EflashClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_16) { + LOG_E("EFLASH CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_EFLASHMemClkSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_EFLASHMemClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL ADC Function Clock Config + * @param src ADC Function Clock Source + * @param div ADC Function Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_ADC_FuncClkCfg(SYSCTRL_ADCFuncClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_4) { + LOG_E("ADC Function CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_ADCFunClkSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_ADCFunClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL HRPWM Function Clock Config + * @param src HRPWM Function Clock Source + * @param div HRPWM Function Clock Div + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_SYSCTRL_HRPWM_FuncClkCfg(SYSCTRL_HRPWMFuncClkSrcETypeDef src, SYSCTRL_ClkDivETypeDef div) +{ + if (div <= SYSCTRL_CLK_DIV_IVD || div > SYSCTRL_CLK_DIV_4) { + LOG_E("HRPWM Function CLK div-[%d] config error!\n", div); + return LL_ERROR; + } + + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_HRPWMFunClkSrc_Set(SYSCTRL, src); + __LL_SYSCTRL_HRPWMFunClkDiv_Set(SYSCTRL, div); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); + + return LL_OK; +} + +/** + * @brief SYSCTRL LL SYSCLK freq get + * @param None + * @return SYSCLK freq + */ +uint32_t LL_SYSCTRL_SysclkGet(void) +{ + return SystemCoreClock; +} + +/** + * @brief SYSCTRL LL AHB Clock freq get + * @note AHB Clock is equal to SYSCLK + * @param None + * @return AHB Clock freq + */ +uint32_t LL_SYSCTRL_AHBClkGet(void) +{ + return LL_SYSCTRL_SysclkGet(); +} + +/** + * @brief SYSCTRL LL APB0 Clock freq get + * @note APB0 Clock is Div from AHB + * @param None + * @return APB0 Clock freq + */ +uint32_t LL_SYSCTRL_APB0ClkGet(void) +{ + return LL_SYSCTRL_AHBClkGet() / __LL_SYSCTRL_APB0ClkDiv_Get(SYSCTRL); +} + +/** + * @brief SYSCTRL LL APB1 Clock freq get + * @note APB1 Clock is Div from AHB + * @param None + * @return APB1 Clock freq + */ +uint32_t LL_SYSCTRL_APB1ClkGet(void) +{ + return LL_SYSCTRL_AHBClkGet() / __LL_SYSCTRL_APB1ClkDiv_Get(SYSCTRL); +} + +/** + * @} + */ + + +/** @defgroup SYSCTRL_LL_Exported_Functions_Group2 SYSCTRL PLL Config Functions + * @brief SYSCTRL PLL Config Functions + * @{ + */ + +/** + * @brief SYSCTRL ll PLL0 Config + * @param Instance Specifies SYSCTRL peripheral + * @param pll0_cfg PLL0 Config Pointer + * @return LL_StatusETypeDef Config Result + */ +LL_StatusETypeDef LL_SYSCTRL_Pll0Cfg(SYSCTRL_TypeDef *Instance, SYSCTRL_PLLUserCfgTypeDef *pll0_cfg) +{ + uint8_t i, j; + SYSCTRL_ClkDivETypeDef post_div = SYSCTRL_CLK_DIV_IVD; + + if (Instance == NULL || pll0_cfg == NULL) { + LOG_E("PLL0 config params error!\n"); + return LL_ERROR; + } + + for (i = 0; i < ARRAY_SIZE(sysctrl_pll_cfg); i++) { + if (sysctrl_pll_cfg[i].pll_in_freq == pll0_cfg->pll_in_freq) { + for (j = 2; j <= 16; j++) { + if ((sysctrl_pll_cfg[i].pll_out_freq / j) == pll0_cfg->pll_user_freq && \ + !(sysctrl_pll_cfg[i].pll_out_freq % j)) { + post_div = (SYSCTRL_ClkDivETypeDef)j; + break; + } + } + + if (post_div != SYSCTRL_CLK_DIV_IVD) { + break; + } + } + } + + if (i == ARRAY_SIZE(sysctrl_pll_cfg)) { + LOG_E("Don't match pll0_in_freq-[%d] to generate pll0_out_freq-[%d], please add the config to sysctrl_pll_cfg array!\n", \ + pll0_cfg->pll_in_freq, pll0_cfg->pll_user_freq); + return LL_ERROR; + } + + //SYSCTRL CTRL Register Unlock + __LL_SYSCTRL_CTRLReg_Unlock(Instance); + + switch (pll0_cfg->pll_clk_src) { + case PLLCLK_SRC_XOSC: + LL_SYSCTRL_XOSCCfg(Instance); + + LOG_I("PLL0 CLK Source Select XOSC.\n"); + __LL_SYSCTRL_PLL0_RefClk_Set(Instance, SYSCTRL_PLL0_REFCLK_XOSC); + break; + + case PLLCLK_SRC_RC8M: + __LL_SYSCTRL_RC8M_En(Instance); + + LOG_I("PLL0 CLK Source Select RC8M.\n"); + __LL_SYSCTRL_PLL0_RefClk_Set(Instance, SYSCTRL_PLL0_REFCLK_RC8M); + break; + + case PLLCLK_SRC_DFT: + LOG_I("PLL0 CLK Source Select DFT.\n"); + __LL_SYSCTRL_PLL0_RefClk_Set(Instance, SYSCTRL_PLL0_REFCLK_DFT); + break; + + default: + LOG_E("PLL0 CLK Source Select-[%d] Error!\n", pll0_cfg->pll_clk_src); + return LL_ERROR; + } + + //PLL0 Pre-Div Config + if (sysctrl_pll_cfg[i].pll_pre_div == SYSCTRL_CLK_DIV_1) { + __LL_SYSCTRL_PLL0_PreDiv_1(Instance); + } else if (sysctrl_pll_cfg[i].pll_pre_div == SYSCTRL_CLK_DIV_2) { + __LL_SYSCTRL_PLL0_PreDiv_2(Instance); + } else { + LOG_E("PLL0 Pre-Div Config-[%d] Error!\n", sysctrl_pll_cfg[i].pll_pre_div); + } + + //PLL0 Div Config + if (post_div >= SYSCTRL_CLK_DIV_2 && post_div <= SYSCTRL_CLK_DIV_16) { + __LL_SYSCTRL_PLL0_DIV_Set(Instance, post_div); + } else { + LOG_E("PLL0 Post Div Config-[%d] Error!\n", post_div); + } + + //FPLL0 integer/fraction Config & Enable & Start + LL_FPLL_DivStart(FPLL0, sysctrl_pll_cfg[i].fpll_int, sysctrl_pll_cfg[i].fpll_frac); + + //PLL0 VCO Band and Gain Config and Enable + __LL_SYSCTRL_PLL0_Band_Set(Instance, sysctrl_pll_cfg[i].pll_vco_band); + __LL_SYSCTRL_PLL0_GVCO_Set(Instance, sysctrl_pll_cfg[i].pll_vco_gain); + __LL_SYSCTRL_PLL0_En(Instance); + + //Wait for PLL0 Lock + LOG_D("Wait for PLL0 lock output\n"); + + while (!__LL_SYSCTRL_PLL0_IsLocked(Instance)) + ; + + LOG_D("PLL0 lock Success\n"); + + //SYSCTRL Register Lock + __LL_SYSCTRL_Reg_Lock(Instance); + + return LL_OK; +} + +/** + * @brief SYSCTRL ll PLL1 Config + * @note PLL1 don't config post-div, which is used for ADC/HRPWM module generally + * @param Instance Specifies SYSCTRL peripheral + * @param pll1_cfg PLL1 Config Pointer + * @return LL_StatusETypeDef Config Result + */ +LL_StatusETypeDef LL_SYSCTRL_Pll1Cfg(SYSCTRL_TypeDef *Instance, SYSCTRL_PLLUserCfgTypeDef *pll1_cfg) +{ + uint8_t i; + + if (Instance == NULL || pll1_cfg == NULL) { + LOG_E("PLL1 config params error!\n"); + return LL_ERROR; + } + + for (i = 0; i < ARRAY_SIZE(sysctrl_pll_cfg); i++) { + if (sysctrl_pll_cfg[i].pll_in_freq == pll1_cfg->pll_in_freq && \ + sysctrl_pll_cfg[i].pll_out_freq == pll1_cfg->pll_user_freq) { + break; + } + } + + if (i == ARRAY_SIZE(sysctrl_pll_cfg)) { + LOG_E("Don't match pll1_in_freq-[%d] to generate pll1_out_freq-[%d], please add the config to sysctrl_pll_cfg array!\n", \ + pll1_cfg->pll_in_freq, pll1_cfg->pll_user_freq); + return LL_ERROR; + } + + //SYSCTRL CTRL Register Unlock + __LL_SYSCTRL_CTRLReg_Unlock(Instance); + + switch (pll1_cfg->pll_clk_src) { + case PLLCLK_SRC_XOSC: + LL_SYSCTRL_XOSCCfg(Instance); + + LOG_I("PLL1 CLK Source Select XOSC.\n"); + __LL_SYSCTRL_PLL1_RefClk_Set(Instance, SYSCTRL_PLL1_REFCLK_XOSC); + break; + + case PLLCLK_SRC_RC8M: + __LL_SYSCTRL_RC8M_En(Instance); + + LOG_I("PLL1 CLK Source Select RC8M.\n"); + __LL_SYSCTRL_PLL1_RefClk_Set(Instance, SYSCTRL_PLL1_REFCLK_RC8M); + break; + + case PLLCLK_SRC_DFT: + LOG_I("PLL1 CLK Source Select DFT.\n"); + __LL_SYSCTRL_PLL1_RefClk_Set(Instance, SYSCTRL_PLL1_REFCLK_DFT); + break; + + default: + LOG_E("PLL1 CLK Source Select-[%d] Error!\n", pll1_cfg->pll_clk_src); + return LL_ERROR; + } + + //PLL1 Pre-Div Config + if (sysctrl_pll_cfg[i].pll_pre_div == SYSCTRL_CLK_DIV_1) { + __LL_SYSCTRL_PLL1_PreDiv_1(Instance); + } else if (sysctrl_pll_cfg[i].pll_pre_div == SYSCTRL_CLK_DIV_2) { + __LL_SYSCTRL_PLL1_PreDiv_2(Instance); + } else { + LOG_E("PLL1 Pre-Div Config-[%d] Error!\n", sysctrl_pll_cfg[i].pll_pre_div); + } + + //FPLL1 integer/fraction Config & Enable & Start + LL_FPLL_DivStart(FPLL1, sysctrl_pll_cfg[i].fpll_int, sysctrl_pll_cfg[i].fpll_frac); + + //PLL1 VCO Band and Gain Config and Enable + __LL_SYSCTRL_PLL1_Band_Set(Instance, sysctrl_pll_cfg[i].pll_vco_band); + __LL_SYSCTRL_PLL1_GVCO_Set(Instance, sysctrl_pll_cfg[i].pll_vco_gain); + __LL_SYSCTRL_PLL1_En(Instance); + + //Wait for PLL1 Lock + LOG_D("Wait for PLL1 lock output\n"); + + while (!__LL_SYSCTRL_PLL1_IsLocked(Instance)) + ; + + LOG_D("PLL1 lock Success\n"); + + //SYSCTRL Register Lock + __LL_SYSCTRL_Reg_Lock(Instance); + + return LL_OK; +} + +/** + * @brief SYSCTRL ll PLL2 Config + * @param Instance Specifies SYSCTRL peripheral + * @param pll2_cfg PLL2 Config Pointer + * @return LL_StatusETypeDef Config Result + */ +LL_StatusETypeDef LL_SYSCTRL_Pll2Cfg(SYSCTRL_TypeDef *Instance, SYSCTRL_PLLUserCfgTypeDef *pll2_cfg) +{ + uint8_t i, j; + SYSCTRL_ClkDivETypeDef post_div = SYSCTRL_CLK_DIV_IVD; + + if (Instance == NULL || pll2_cfg == NULL) { + LOG_E("PLL2 config params error!\n"); + return LL_ERROR; + } + + for (i = 0; i < ARRAY_SIZE(sysctrl_pll_cfg); i++) { + if (sysctrl_pll_cfg[i].pll_in_freq == pll2_cfg->pll_in_freq) { + for (j = 2; j <= 16; j++) { + if ((sysctrl_pll_cfg[i].pll_out_freq / j) == pll2_cfg->pll_user_freq && !(sysctrl_pll_cfg[i].pll_out_freq % j)) { + post_div = (SYSCTRL_ClkDivETypeDef)j; + break; + } + } + + if (post_div != SYSCTRL_CLK_DIV_IVD) { + break; + } + } + } + + if (i == ARRAY_SIZE(sysctrl_pll_cfg)) { + LOG_E("Don't match pll2_in_freq-[%d] to generate pll2_out_freq-[%d], please add the config to sysctrl_pll_cfg array!\n", \ + pll2_cfg->pll_in_freq, pll2_cfg->pll_user_freq); + return LL_ERROR; + } + + //SYSCTRL CTRL Register Unlock + __LL_SYSCTRL_CTRLReg_Unlock(Instance); + + switch (pll2_cfg->pll_clk_src) { + case PLLCLK_SRC_XOSC: + LL_SYSCTRL_XOSCCfg(Instance); + + LOG_I("PLL2 CLK Source Select XOSC.\n"); + __LL_SYSCTRL_PLL2_RefClk_Set(Instance, SYSCTRL_PLL2_REFCLK_XOSC); + break; + + case PLLCLK_SRC_RC8M: + __LL_SYSCTRL_RC8M_En(Instance); + + LOG_I("PLL2 CLK Source Select RC8M.\n"); + __LL_SYSCTRL_PLL2_RefClk_Set(Instance, SYSCTRL_PLL2_REFCLK_RC8M); + break; + + case PLLCLK_SRC_DFT: + LOG_I("PLL2 CLK Source Select DFT.\n"); + __LL_SYSCTRL_PLL2_RefClk_Set(Instance, SYSCTRL_PLL2_REFCLK_DFT); + break; + + default: + LOG_E("PLL2 CLK Source Select-[%d] Error!\n", pll2_cfg->pll_clk_src); + return LL_ERROR; + } + + //PLL2 Pre-Div Config + if (sysctrl_pll_cfg[i].pll_pre_div == SYSCTRL_CLK_DIV_1) { + __LL_SYSCTRL_PLL2_PreDiv_1(Instance); + } else if (sysctrl_pll_cfg[i].pll_pre_div == SYSCTRL_CLK_DIV_2) { + __LL_SYSCTRL_PLL2_PreDiv_2(Instance); + } else { + LOG_E("PLL2 Pre-Div Config-[%d] Error!\n", sysctrl_pll_cfg[i].pll_pre_div); + } + + //PLL2 Div Config + if (post_div >= SYSCTRL_CLK_DIV_2 && post_div <= SYSCTRL_CLK_DIV_16) { + __LL_SYSCTRL_PLL2_DIV_Set(Instance, post_div); + } else { + LOG_E("PLL2 Post Div Config-[%d] Error!\n", post_div); + } + + //FPLL2 integer/fraction Config & Enable & Start + LL_FPLL_DivStart(FPLL2, sysctrl_pll_cfg[i].fpll_int, sysctrl_pll_cfg[i].fpll_frac); + + //PLL2 VCO Band and Gain Config and Enable + __LL_SYSCTRL_PLL2_Band_Set(Instance, sysctrl_pll_cfg[i].pll_vco_band); + __LL_SYSCTRL_PLL2_GVCO_Set(Instance, sysctrl_pll_cfg[i].pll_vco_gain); + __LL_SYSCTRL_PLL2_En(Instance); + + //Wait for PLL2 Lock + LOG_D("Wait for PLL2 lock output\n"); + + while (!__LL_SYSCTRL_PLL2_IsLocked(Instance)) + ; + + LOG_D("PLL2 lock Success\n"); + + //SYSCTRL Register Lock + __LL_SYSCTRL_Reg_Lock(Instance); + + return LL_OK; +} +/** + * @} + */ + +/** @defgroup SYSCTRL_LL_Exported_Functions_Group3 SYSCTRL Peripherals Clock and Reset control Functions + * @brief SYSCTRL Peripherals Clock and Reset control Functions + * @{ + */ + +/** + * @brief SYSCTRL LSTIMER Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_LSTMR_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_LSTIMERBusClk_En(SYSCTRL); + __LL_SYSCTRL_LSTIMERSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL LSTIMER Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_LSTMR_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_LSTIMERBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_LSTIMERSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL Uart1 Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_UART1_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_UART1BusClk_En(SYSCTRL); + __LL_SYSCTRL_UART1SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL Uart1 Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_UART1_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_UART1BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_UART1SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL Uart0 Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_UART0_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_UART0BusClk_En(SYSCTRL); + __LL_SYSCTRL_UART0SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL Uart0 Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_UART0_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_UART0BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_UART0SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL I2C1 Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_I2C1_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_I2C1BusClk_En(SYSCTRL); + __LL_SYSCTRL_I2C1SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL I2C1 Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_I2C1_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_I2C1BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_I2C1SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL I2C0 Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_I2C0_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_I2C0BusClk_En(SYSCTRL); + __LL_SYSCTRL_I2C0SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL I2C0 Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_I2C0_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_I2C0BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_I2C0SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL ECU Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_ECU_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_ECUBusClk_En(SYSCTRL); + __LL_SYSCTRL_ECUFunClk_En(SYSCTRL); + __LL_SYSCTRL_ECUSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL ECU Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_ECU_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_ECUBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_ECUFunClk_Dis(SYSCTRL); + __LL_SYSCTRL_ECUSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR4 Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_IIR4_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR4BusClk_En(SYSCTRL); + __LL_SYSCTRL_IIR4FunClk_En(SYSCTRL); + __LL_SYSCTRL_IIR4SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR4 Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_IIR4_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR4BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR4FunClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR4SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR3 Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_IIR3_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR3BusClk_En(SYSCTRL); + __LL_SYSCTRL_IIR3FunClk_En(SYSCTRL); + __LL_SYSCTRL_IIR3SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR3 Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_IIR3_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR3BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR3FunClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR3SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR2 Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_IIR2_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR2BusClk_En(SYSCTRL); + __LL_SYSCTRL_IIR2FunClk_En(SYSCTRL); + __LL_SYSCTRL_IIR2SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR2 Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_IIR2_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR2BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR2FunClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR2SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR1 Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_IIR1_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR1BusClk_En(SYSCTRL); + __LL_SYSCTRL_IIR1FunClk_En(SYSCTRL); + __LL_SYSCTRL_IIR1SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR1 Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_IIR1_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR1BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR1FunClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR1SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR0 Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_IIR0_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR0BusClk_En(SYSCTRL); + __LL_SYSCTRL_IIR0FunClk_En(SYSCTRL); + __LL_SYSCTRL_IIR0SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL IIR0 Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_IIR0_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_IIR0BusClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR0FunClk_Dis(SYSCTRL); + __LL_SYSCTRL_IIR0SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DALI Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_DALI_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DALIBusClk_En(SYSCTRL); + __LL_SYSCTRL_DALISoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DALI Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_DALI_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DALIBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_DALISoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL FPLL2 Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_FPLL2_RstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_FPLL2SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL FPLL2 Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_FPLL2_RstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_FPLL2SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL FPLL1 Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_FPLL1_RstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_FPLL1SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL FPLL1 Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_FPLL1_RstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_FPLL1SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL FPLL0 Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_FPLL0_RstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_FPLL0SoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL FPLL0 Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_FPLL0_RstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_FPLL0SoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL USB Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_USB_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_USBBusClk_En(SYSCTRL); + __LL_SYSCTRL_USBFunClk_En(SYSCTRL); + __LL_SYSCTRL_USBSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL USB Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_USB_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_USBBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_USBFunClk_Dis(SYSCTRL); + __LL_SYSCTRL_USBSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DFLASH Bus&Memory Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_DFLASH_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DFLASHBusClk_En(SYSCTRL); + __LL_SYSCTRL_DFLASHMemClk_En(SYSCTRL); + __LL_SYSCTRL_DFLASHSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DFLASH Bus&Memory Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_DFLASH_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DFLASHBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_DFLASHMemClk_Dis(SYSCTRL); + __LL_SYSCTRL_DFLASHSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL EFLASH Bus&Memory Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_EFLASH_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_EFLASHBusClk_En(SYSCTRL); + __LL_SYSCTRL_EFLASHMemClk_En(SYSCTRL); + __LL_SYSCTRL_EFLASHSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL EFLASH Bus&Memory Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_EFLASH_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_EFLASHBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_EFLASHMemClk_Dis(SYSCTRL); + __LL_SYSCTRL_EFLASHSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL HRPWM Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_HRPWM_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_HRPWMBusClk_En(SYSCTRL); + __LL_SYSCTRL_HRPWMFunClk_En(SYSCTRL); + __LL_SYSCTRL_HRPWMSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL HRPWM Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_HRPWM_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_HRPWMBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_HRPWMFunClk_Dis(SYSCTRL); + __LL_SYSCTRL_HRPWMSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL ADC Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_ADC_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_ADCBusClk_En(SYSCTRL); + __LL_SYSCTRL_ADCFunClk_En(SYSCTRL); + __LL_SYSCTRL_ADCSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL ADC Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_ADC_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_ADCBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_ADCFunClk_Dis(SYSCTRL); + __LL_SYSCTRL_ADCSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DAC Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_DAC_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DACBusClk_En(SYSCTRL); + __LL_SYSCTRL_DACSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DAC Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_DAC_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DACBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_DACSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL CMP Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_CMP_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_CMPBusClk_En(SYSCTRL); + __LL_SYSCTRL_CMPSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL CMP Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_CMP_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_CMPBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_CMPSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOD Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOD_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIODBusClk_En(SYSCTRL); + __LL_SYSCTRL_GPIODSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOD Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOD_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIODBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_GPIODSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOC Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOC_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOCBusClk_En(SYSCTRL); + __LL_SYSCTRL_GPIOCSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOC Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOC_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOCBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_GPIOCSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOB Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOB_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOBBusClk_En(SYSCTRL); + __LL_SYSCTRL_GPIOBSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOB Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOB_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOBBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_GPIOBSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOA Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOA_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOABusClk_En(SYSCTRL); + __LL_SYSCTRL_GPIOASoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL GPIOA Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_GPIOA_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_GPIOABusClk_Dis(SYSCTRL); + __LL_SYSCTRL_GPIOASoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL HSTIMER Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_HSTMR_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_HSTIMERBusClk_En(SYSCTRL); + __LL_SYSCTRL_HSTIMERSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL HSTIMER Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_HSTMR_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_HSTIMERBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_HSTIMERSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL CAN Bus&Function Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_CAN_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_CANBusClk_En(SYSCTRL); + __LL_SYSCTRL_CANFunClk_En(SYSCTRL); + __LL_SYSCTRL_CANSoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL CAN Bus&Function Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_CAN_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_CANBusClk_Dis(SYSCTRL); + __LL_SYSCTRL_CANFunClk_Dis(SYSCTRL); + __LL_SYSCTRL_CANSoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DMA Bus Clock Enable and Reset Release + * @param None + * @return None + */ +void LL_SYSCTRL_DMA_ClkEnRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DMABusClk_En(SYSCTRL); + __LL_SYSCTRL_DMASoftRst_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL DMA Bus Clock Disable and Reset Assert + * @param None + * @return None + */ +void LL_SYSCTRL_DMA_ClkDisRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_DMABusClk_Dis(SYSCTRL); + __LL_SYSCTRL_DMASoftRst_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + + +/** + * @brief SYSCTRL LL all peripheral reset assert + * @note All peripheral include system bus(AHB/APB0/APB1) + * @param None + * @return None + */ +void LL_SYSCTRL_AllPeriphRstAssert(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_SysSoftRstAll_Assert(SYSCTRL); + __LL_SYSCTRL_APB0SoftRstAll_Assert(SYSCTRL); + __LL_SYSCTRL_APB1SoftRstAll_Assert(SYSCTRL); + __LL_SYSCTRL_AHBSoftRstAll_Assert(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @brief SYSCTRL LL all peripheral reset release + * @note All peripheral include system bus(AHB/APB0/APB1) + * @param None + * @return None + */ +void LL_SYSCTRL_AllPeriphRstRelease(void) +{ + __LL_SYSCTRL_CTRLReg_Unlock(SYSCTRL); + __LL_SYSCTRL_SysSoftRstAll_Release(SYSCTRL); + __LL_SYSCTRL_APB0SoftRstAll_Release(SYSCTRL); + __LL_SYSCTRL_APB1SoftRstAll_Release(SYSCTRL); + __LL_SYSCTRL_AHBSoftRstAll_Release(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} +/** + * @} + */ + +/** @defgroup SYSCTRL_LL_Exported_Functions_Group4 SYSCTRL Misc Config Functions + * @brief SYSCTRL Misc Config Functions + * @{ + */ + +/** + * @brief SYSCTRL LL PMU Config + * @param None + * @return None + */ +void LL_SYSCTRL_PMUCfg(void) +{ + __LL_SYSCTRL_FLSReg_Unlock(SYSCTRL); + __LL_SYSCTRL_CUR_RES_Set(SYSCTRL, 0); + __LL_SYSCTRL_BGR_DRD_Dis(SYSCTRL); + __LL_SYSCTRL_BGR_Filter_En(SYSCTRL); + __LL_SYSCTRL_Reg_Lock(SYSCTRL); +} + +/** + * @} + */ + +/** + * @} + */ + +/* Private functions ---------------------------------------------------------*/ +/** @addtogroup SYSCTRL_LL_Private_Functions + * @{ + */ + +/** + * @brief SYSCTRL LL XOSC Config + * @param Instance Specifies SYSCTRL peripheral + * @note Must unlock SYSCTRL CTRL Reg before call this function + * @return None + */ +static void LL_SYSCTRL_XOSCCfg(SYSCTRL_TypeDef *Instance) +{ + //Check SYSCTRL CTRL Reg unlock or not + if (!__LL_SYSCTRL_IsCTRLRegUnlock(Instance)) { + LOG_E("SYSCTRL CTRL Reg is Lock, please unlock it before call this function!\n"); + return; + } + + __LL_SYSCTRL_XOSC_En(Instance); +} +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_tmr.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_tmr.c new file mode 100644 index 0000000000..45c138dd21 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_tmr.c @@ -0,0 +1,820 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_tmr.c + * @author MCD Application Team + * @brief TMR LL module driver. + * This file provides firmware functions to manage the following + * functionalities of the Timer (TMR) peripheral: + * + TMR Time Initialization and De-Initialization function + * + TMR Input Capture and Output Compare configure functions + * + TMR Start and Stop functions + * + TMR event software generate function + * + TMR internal trigger signal configure function + * + TMR interrupt handler and callback functions + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "TMR LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup TMR_LL TMR LL + * @brief TMR LL module driver. + * @{ + */ + +#ifdef LL_TMR_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/** @defgroup TMR_LL_Private_Functions TMR LL Private Functions + * @brief TMR LL Private Functions + * @{ + */ +static void TMR_TB_SetConfig(TMR_TypeDef *Instance, TMR_TB_InitTypeDef *Config); +static void TMR_IC_SetConfig(TMR_TypeDef *Instance, TMR_IC_InitTypeDef *Config); +static void TMR_OC_SetConfig(TMR_TypeDef *Instance, TMR_OC_InitTypeDef *Config); +static void TMR_EXT_SetConfig(TMR_TypeDef *Instance, TMR_EXT_InitTypeDef *Config); +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup TMR_LL_Exported_Functions TMR LL Exported Functions + * @brief TMR LL Exported Functions + * @{ + */ + +/** @defgroup TMR_LL_Exported_Functions_Group1 Initialization and De-Initialization functions + * @brief Initialization and De-Initialization functions +@verbatim + ============================================================================== + ##### Initialization and De-Initialization functions ##### + ============================================================================== + [..] + This section provides functions allowing to: + (+) Initialize and configure the TMR base unit. + (+) De-initialize the TMR base unit. + +@endverbatim + * @{ + */ + +/** + * @brief Initialize the TMR peripheral + * @param Instance TMR peripheral instance + * @param Init pointer to a TMR_InitTypeDef structure that contains the configuration + * information for the specified TMR peripheral. + * @note InputCapture and OutputCompare feature must NOT be enabled at the same time + * in one single TMR peripheral. + * @return status of the initialization + */ +LL_StatusETypeDef LL_TMR_Init(TMR_TypeDef *Instance, TMR_InitTypeDef *Init) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + assert_param(Init != NULL); + /* Input Capture and Output Compare can not be enabled in one TMR at the same time */ + assert_param(!((Init->ICInit.ICEnable == ENABLE) && (Init->OCInit.OCEnable == ENABLE))); + + /* Handle Something */ + LL_TMR_MspInit(Instance); + + /* Disable Capture/Compare before initialization */ + __LL_TMR_CC_DISABLE(Instance); + + /* Stop Counter before initialization */ + __LL_TMR_DISABLE(Instance); + + /* Set configuration to TimeBase unit */ + TMR_TB_SetConfig(Instance, &Init->TBInit); + + /* Set configuration for Input Capture feature */ + TMR_IC_SetConfig(Instance, &Init->ICInit); + + /* Set configuration for Output Compare feature */ + TMR_OC_SetConfig(Instance, &Init->OCInit); + + /* Set configuration for Export Trigger Event feature */ + TMR_EXT_SetConfig(Instance, &Init->ExtInit); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief DeInitializes the timer + * @param Instance TMR peripheral instance + * @return status of the initialization + */ +LL_StatusETypeDef LL_TMR_DeInit(TMR_TypeDef *Instance) +{ + /* Check the TMR initiation struct allocation */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + /* Stop Counter */ + __LL_TMR_DISABLE(Instance); + + /* Disable Capture Compare feature */ + __LL_TMR_CC_DISABLE(Instance); + + /* Disable TMR export trigger event feature */ + WRITE_REG(Instance->ETER, 0); + + /* Handle Something */ + LL_TMR_MspDeInit(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Initializes the TMR MSP. + * @param Instance TMR peripheral + * @return None + */ +__WEAK void LL_TMR_MspInit(TMR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_TMR_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the TMR MSP + * @param Instance TMR peripheral + * @return None + */ +__WEAK void LL_TMR_MspDeInit(TMR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_TMR_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + + +/** @defgroup TMR_LL_Exported_Functions_Group2 TMR Peripheral Control functions + * @brief TMR Peripheral Control functions +@verbatim + =============================================================================== + ##### Peripheral Control functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) TMR Input-Capture configure functions + (+) TMR Output-Compare configure functions + +@endverbatim + * @{ + */ + +/** + * @brief User can use this function to reconfigure the TMR TimeBase unit + * according to the specified parameters in the TMR_TB_InitTypeDef on runtime. + * @param Instance TMR peripheral instance + * @param Config TMR TimeBase Unit configuration structure + * @return status of the initialization + */ +LL_StatusETypeDef LL_TMR_TB_Config(TMR_TypeDef *Instance, TMR_TB_InitTypeDef *Config) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + assert_param(Config != NULL); + + /* Set configuration to TimeBase unit */ + TMR_TB_SetConfig(Instance, Config); + + /* Return function status */ + return LL_OK; +} + + +/** + * @brief User can use this function to reconfigure the TMR Input Capture feature + * according to the specified parameters in the TMR_IC_InitTypeDef on runtime. + * @note Use LL_TMR_CC_ENABLE() or LL_TMR_CC_DISABLE() macros to enable or disable + * the Capture Compare feature. + * @param Instance TMR peripheral + * @param Config TMR Input Capture configuration structure + * @return status of the configuration + */ +LL_StatusETypeDef LL_TMR_IC_Config(TMR_TypeDef *Instance, TMR_IC_InitTypeDef *Config) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + assert_param(Config != NULL); + + /* Disable CCE before configuration */ + CLEAR_BIT(Instance->CCCR, TMR_CCCR_CCE); + + /* Set configuration for Input Capture feature */ + TMR_IC_SetConfig(Instance, Config); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief User can use this function to reconfigure the TMR Output Compare feature + * according to the specified parameters in the TMR_OC_InitTypeDef on runtime. + * @note Use LL_TMR_CC_ENABLE() or LL_TMR_CC_DISABLE() macros to enable or disable + * the Capture Compare feature. + * @param Instance TMR peripheral + * @param Config TMR Output Compare configuration structure. + * @return status of the configuration + */ +LL_StatusETypeDef LL_TMR_OC_Config(TMR_TypeDef *Instance, TMR_OC_InitTypeDef *Config) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + assert_param(Config != NULL); + + /* Disable CCE before configuration */ + CLEAR_BIT(Instance->CCCR, TMR_CCCR_CCE); + + /* Set configuration for Output Compare feature */ + TMR_OC_SetConfig(Instance, Config); + + /* Return function status */ + return LL_OK; + +} + +/** + * @brief User can use this function to reconfigure the TMR Export Trigger Event feature + * according to the specified parameters in the TMR_EXT_InitTypeDef on runtime. + * @param Instance TMR peripheral + * @param Config TMR Export Trigger configuration structure. + * @note Please notice if user want to enable or disable the TMR events as the internal signal, + * this configuration function should be called to config the specified events. + * @return status of the configuration + */ +LL_StatusETypeDef LL_TMR_EXT_Config(TMR_TypeDef *Instance, TMR_EXT_InitTypeDef *Config) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + assert_param(Config != NULL); + + /* Set configuration for Export Trigger Event feature */ + TMR_EXT_SetConfig(Instance, Config); + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup TMR_LL_Exported_Functions_Group3 TMR Input and Output operation functions + * @brief TMR Input and Output operation functions +@verbatim + =============================================================================== + ##### Input and Output operation functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) TMR Start and Stop functions + (+) TMR Synchro start function + (+) TMR event software generate function + +@endverbatim + * @{ + */ + +/** + * @brief Start the Timer. + * @param Instance TMR peripheral + * @return LL status + */ +LL_StatusETypeDef LL_TMR_Start(TMR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + /* Start Counter*/ + __LL_TMR_ENABLE(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Stop the Timer. + * @param Instance TMR peripheral + * @return LL status + */ +LL_StatusETypeDef LL_TMR_Stop(TMR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + /* Stop Counter */ + __LL_TMR_DISABLE(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Start the timer with interrupt enabled + * @param Instance TMR peripheral + * @return LL status + */ +LL_StatusETypeDef LL_TMR_Start_IT(TMR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + if ((Instance->CR & TMR_CR_UDIS_Msk) != TMR_CR_UDIS) { + /* TMR Update Interrupt Enable if Update event is enabled */ + __LL_TMR_IT_ENABLE(Instance, TMR_IT_UIE); + } + + /* Check if Capture Compare mode is enabled */ + if ((Instance->CCCR & TMR_CCCR_CCE_Msk) == TMR_CCCR_CCE) { + if ((Instance->CCCR & TMR_CCCR_CCS_Msk) == TMR_CCCR_CCS) { + /* Enable Input Capture interrupt source */ + __LL_TMR_CC_IT_ENABLE(Instance, TMR_IT_ICIE | TMR_IT_ICOIE); + } else { + /* Enable Output Compare interrupt source */ + __LL_TMR_CC_IT_ENABLE(Instance, TMR_IT_OCIE); + } + } + + /* TMR Counter Overflow Interrupt Enable */ + __LL_TMR_IT_ENABLE(Instance, TMR_IT_OVIE); + + /* Start Counter */ + __LL_TMR_ENABLE(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Stop the timer with interrupt disabled + * @param Instance TMR peripheral + * @return LL status + */ +LL_StatusETypeDef LL_TMR_Stop_IT(TMR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + /* TMR Update and Counter Overflow Interrupt Disable */ + __LL_TMR_IT_DISABLE(Instance, TMR_IT_UIE | TMR_IT_OVIE); + + /* Capture Compare interrupt disable */ + __LL_TMR_CC_IT_DISABLE(Instance, (TMR_IT_ICIE | + TMR_IT_ICOIE | + TMR_IT_OCIE)); + + /* Stop Counter */ + __LL_TMR_DISABLE(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Synchro Start the specifies timers. + * @param TMRGRPx TMRGRP peripheral + * @arg TMRGRP0: Group of LSTMRs(TMR0/1/2/3) + * @arg TMRGRP1: Group of HSTMRs(TMR4/5/6/7) + * @param SynchroMask Specifies timer masks to start synchronously. This parameter can be + * any combination of @ref TMRGRP_Sync_definition : + * @arg TMRGRP_SYNC_TMR0 : Select TMR0(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR1 : Select TMR1(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR2 : Select TMR2(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR3 : Select TMR3(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR4 : Select TMR4(specific to TMRGRP1) + * @arg TMRGRP_SYNC_TMR5 : Select TMR5(specific to TMRGRP1) + * @arg TMRGRP_SYNC_TMR6 : Select TMR6(specific to TMRGRP1) + * @arg TMRGRP_SYNC_TMR7 : Select TMR7(specific to TMRGRP1) + * @arg TMRGRP_SYNC_ALL : Select all TMRs in TMRGRPx(x = 0 or 1) + * @note Please notice that only timers in same group can be started synchronously. + * For example for TMRGRP0, SynchroMask of the TMR0/1/2/3 will be started synchronously. + * @note If user wants to use it with specifies timers' interrupt enabled, use __LL_TMR_IT_ENABLE() + * and __LL_TMR_CC_IT_ENABLE() to enable the necessary interrupt sources before starting them. + * @return LL status + */ +LL_StatusETypeDef LL_TMR_Start_Synchro(TMRGRP_TypeDef *TMRGRPx, uint32_t SynchroMask) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_TMRGRP_INSTANCE(TMRGRPx)); + + /* Start specifies timers synchronously */ + WRITE_REG(TMRGRPx->SYNCR, SynchroMask); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Synchro Stop the specifies timers. + * @param TMRGRPx TMRGRP peripheral + * @arg TMRGRP0: Group of LSTMRs(TMR0/1/2/3) + * @arg TMRGRP1: Group of HSTMRs(TMR4/5/6/7) + * @param SynchroMask Specifies timer masks to stop synchronously. This parameter can be + * any combination of @ref TMRGRP_Sync_definition : + * @arg TMRGRP_SYNC_TMR0 : Select TMR0(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR1 : Select TMR1(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR2 : Select TMR2(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR3 : Select TMR3(specific to TMRGRP0) + * @arg TMRGRP_SYNC_TMR4 : Select TMR4(specific to TMRGRP1) + * @arg TMRGRP_SYNC_TMR5 : Select TMR5(specific to TMRGRP1) + * @arg TMRGRP_SYNC_TMR6 : Select TMR6(specific to TMRGRP1) + * @arg TMRGRP_SYNC_TMR7 : Select TMR7(specific to TMRGRP1) + * @arg TMRGRP_SYNC_ALL : Select all TMRs in TMRGRPx(x = 0 or 1) + * @note Please notice that only timers in same group can be stopped synchronously. + * For example for TMRGRP0, SynchroMask of the TMR0/1/2/3 will be stopped synchronously. + * @return LL status + */ +LL_StatusETypeDef LL_TMR_Stop_Synchro(TMRGRP_TypeDef *TMRGRPx, uint32_t SynchroMask) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_TMRGRP_INSTANCE(TMRGRPx)); + + /* Stop specifies timers synchronously */ + WRITE_REG(TMRGRPx->SYNCR, SynchroMask << 4); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief Generate a software event + * @param Instance TMR peripheral + * @param EventSource specifies the event source. + * This parameter can be one of the following values in @ref TMR_Event_Source: + * @arg TMR_EVENTSOURCE_UG: Reinitialize the counter and generates an update of the registers + * @arg TMR_EVENTSOURCE_CCG: Generate a capture/compare event + * @return LL status + */ +LL_StatusETypeDef LL_TMR_EventGenerate(TMR_TypeDef *Instance, TMR_EventSRCETypeDef EventSource) +{ + /* Check the TMR initiation struct allocation */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + /* Generation Timer Counter Update Event */ + WRITE_REG(Instance->EGR, EventSource); + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup TMR_LL_Exported_Functions_Interrupt TMR Interrupt management + * @brief TMR Initerrupt management +@verbatim + =============================================================================== + ##### Initerrupt management ##### + =============================================================================== + [..] + This section provides TMR interrupt handler and callback functions. + +@endverbatim + * @{ + */ + +/** + * @brief This function handles TMR interrupts requests. + * @param Instance TMR peripheral + * @return None + */ +void LL_TMR_IRQHandler(TMR_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + if ((__LL_TMR_IT_CHECK_SOURCE(Instance, TMR_IT_UIE) != RESET) && + (__LL_TMR_GET_FLAG(Instance, TMR_FLAG_UIF) != RESET)) { + /* Clear the Update interrupt flag */ + __LL_TMR_CLEAR_FLAG(Instance, TMR_FLAG_UIF); + + /* TMR Update Interrupt Callback */ + LL_TMR_TB_UpdateCallback(Instance); + } + + if ((__LL_TMR_IT_CHECK_SOURCE(Instance, TMR_IT_OVIE) != RESET) && + (__LL_TMR_GET_FLAG(Instance, TMR_FLAG_OVIF) != RESET)) { + /* Claer the OverFlow interrupt flag */ + __LL_TMR_CLEAR_FLAG(Instance, TMR_FLAG_OVIF); + + /* TMR Counter Overflow Interrupt Callback */ + LL_TMR_TB_OverflowCallback(Instance); + } + + if ((__LL_TMR_CC_IT_CHECK_SOURCE(Instance, TMR_IT_ICIE) != RESET) && + (__LL_TMR_GET_FLAG(Instance, TMR_FLAG_ICIF) != RESET)) { + /* Claer the Capture interrupt flag */ + __LL_TMR_CLEAR_FLAG(Instance, TMR_FLAG_ICIF); + + /* TMR Input Capture Captured Interrupt Callback */ + LL_TMR_IC_CaptureCallback(Instance); + } + + if ((__LL_TMR_CC_IT_CHECK_SOURCE(Instance, TMR_IT_ICOIE) != RESET) && + (__LL_TMR_GET_FLAG(Instance, TMR_FLAG_ICOIF) != RESET)) { + /* Claer the OverCapture interrupt flag */ + __LL_TMR_CLEAR_FLAG(Instance, TMR_FLAG_ICOIF); + + /* Handle Something */ + LL_TMR_IC_OverCaptureCallback(Instance); + } + + if ((__LL_TMR_CC_IT_CHECK_SOURCE(Instance, TMR_IT_OCIE) != RESET) && + (__LL_TMR_GET_FLAG(Instance, TMR_FLAG_OCIF) != RESET)) { + + /* Claer the Compare interrupt flag */ + __LL_TMR_CLEAR_FLAG(Instance, TMR_FLAG_OCIF); + + /* Handle Something*/ + LL_TMR_OC_CompareMatchedCallback(Instance); + } +} + +/** + * @brief TMR TimeBase unit (Counter) update interrupt callback function + * @param Instance TMR peripheral + * @return None + */ +__WEAK void LL_TMR_TB_UpdateCallback(TMR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_TMR_TB_UpdateCallback could be implemented in the user file + */ +} + +/** + * @brief TMR TimeBase unit (Counter) overflow interrupt callback function + * @param Instance TMR peripheral + * @return None + */ +__WEAK void LL_TMR_TB_OverflowCallback(TMR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_TMR_TB_OverflowCallback could be implemented in the user file + */ +} + +/** + * @brief TMR input capture interrupt callback function + * @param Instance TMR peripheral + * @return None + */ +__WEAK void LL_TMR_IC_CaptureCallback(TMR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_TMR_IC_CaptureCallback could be implemented in the user file + */ +} + +/** + * @brief TMR input capture over-capture interrupt callback function + * @param Instance TMR peripheral + * @return None + */ +__WEAK void LL_TMR_IC_OverCaptureCallback(TMR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_TMR_IC_OverCaptureCallback could be implemented in the user file + */ +} + +/** + * @brief TMR output compare matched interrupt callback function + * @param Instance TMR peripheral + * @return None + */ +__WEAK void LL_TMR_OC_CompareMatchedCallback(TMR_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_TMR_OC_CompareMatchedCallback could be implemented in the user file + */ +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ +/** @addtogroup TMR_LL_Private_Functions + * @{ + */ + +/** + * @brief Set Configuration to TimeBase Unit. + * @param Instance TMR peripheral instance + * @param Config TMR TimeBase Unit configuration structure + * @return None + */ +static void TMR_TB_SetConfig(TMR_TypeDef *Instance, TMR_TB_InitTypeDef *Config) +{ + if (IS_TMR_LSTMR_INSTANCE(Instance)) { /* Check if Low-Speed Timer instance */ + assert_param(IS_TMR_LSTMR_PRESCALER(Config->Prescaler)); + assert_param(IS_TMR_LSTMR_END_VAL(Config->EndValue)); + assert_param(IS_TMR_LSTMR_START_VAL(Config->StartValue)); + } else { /* High-Speed Timer instance */ + assert_param(IS_TMR_HSTMR_PRSCALER(Config->Prescaler)); + assert_param(IS_TMR_HSTMR_END_VAL(Config->EndValue)); + assert_param(IS_TMR_HSTMR_START_VAL(Config->StartValue)); + } + + /* Set the Counter Start value*/ + WRITE_REG(Instance->CSVR, Config->StartValue); + + /* Set the Counter End value*/ + WRITE_REG(Instance->CEVR, Config->EndValue); + + /* Set the Prescaler value*/ + WRITE_REG(Instance->PSCR, Config->Prescaler); + + /* Configures: Clock source, Auto-Reload preload, Continuous mode, Update enable and + Update request source */ + WRITE_REG(Instance->CR, (Config->ClockSource | Config->AutoReloadPreload | Config->ContinuousMode | + Config->UpdateSource | Config->UpdateEnable)); +} + +/** + * @brief Set Configuration for Input Capture feature. + * @param Instance TMR peripheral instance + * @param sConfig TMR Input Capture configuration structure + * @return None + */ +static void TMR_IC_SetConfig(TMR_TypeDef *Instance, TMR_IC_InitTypeDef *sConfig) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + /* Check if enable the input capture feature. + Note: To do that TMR clock source must be configured to internal source */ + if ((sConfig->ICEnable == ENABLE) && (READ_BIT(Instance->CR, TMR_CR_CKSRC_Msk) == TMR_CLKSOURCE_INTERNAL)) { + assert_param(IS_TMR_ICFILTER(sConfig->ICFilter)); + + /* Set Input Capture filter */ + WRITE_REG(Instance->ICFR, sConfig->ICFilter); + + /* Configurate the TMRx_CCCR register */ + MODIFY_REG(Instance->CCCR, + (TMR_CCCR_ICSRC_Msk + | TMR_CCCR_CCP_Msk), + (TMR_CCCR_CCS + | sConfig->ICSelection + | sConfig->ICPolarity)); + + /* Set CCE to enable the input-capture feature */ + SET_BIT(Instance->CCCR, TMR_CCCR_CCE); + } +} + +/** + * @brief Set Configuration for Output Compare feature. + * @param Instance TMR peripheral instance + * @param sConfig TMR Output Compare configuration structure + * @return None + */ +static void TMR_OC_SetConfig(TMR_TypeDef *Instance, TMR_OC_InitTypeDef *sConfig) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + /* Check if enable the output compare feature. + Note: To do that TMR clock source must be configured to internal source */ + if ((sConfig->OCEnable == ENABLE) && (READ_BIT(Instance->CR, TMR_CR_CKSRC_Msk) == TMR_CLKSOURCE_INTERNAL)) { + if (IS_TMR_LSTMR_INSTANCE(Instance)) { + assert_param(IS_TMR_LSTMR_COMPARE_VAL(sConfig->OCValue)); + } else { + assert_param(IS_TMR_HSTMR_COMPARE_VAL(sConfig->OCValue)); + } + + /* Disable Output Preload feature before configuration */ + CLEAR_BIT(Instance->CCCR, TMR_CCCR_OCPE); + + /* Set Compare Value */ + WRITE_REG(Instance->CCR, sConfig->OCValue); + + /* Configurate the TMRx_CCCR register */ + MODIFY_REG(Instance->CCCR, + (TMR_CCCR_OCPE_Msk + | TMR_CCCR_CCS_Msk + | TMR_CCCR_OCM_Msk + | TMR_CCCR_CCP_Msk), + (sConfig->OCMode + | sConfig->OCPolarity + | sConfig->OCPreload)); + + /* Set CCE to enable the input-capture feature */ + SET_BIT(Instance->CCCR, TMR_CCCR_CCE); + } +} + +/** + * @brief Set Configuration for TMR Export Trigger Event feature. + * @param Instance TMR peripheral + * @param Config TMR Export Trigger configuration structure. + * @return None + */ +static void TMR_EXT_SetConfig(TMR_TypeDef *Instance, TMR_EXT_InitTypeDef *sConfig) +{ + /* Check the parameters */ + assert_param(IS_TMR_ALL_INSTANCE(Instance)); + + if (sConfig->ExtEnable == ENABLE) { + /* Configure the events */ + MODIFY_REG(Instance->ETER, + (TMR_ETER_CCTPW_Msk + | TMR_ETER_UTPW_Msk + | TMR_ETER_PWMOE_Msk + | TMR_ETER_CCTE_Msk + | TMR_ETER_UTE_Msk), + ((0xFU << TMR_ETER_CCTPW_Pos) | + (0xFU << TMR_ETER_UTPW_Pos) + | sConfig->ExtPWMWave + | sConfig->ExtCCTrigger + | sConfig->ExtTRGOTrigger)); + } else { + WRITE_REG(Instance->ETER, 0); + } +} + +/** + * @} + */ + + +#endif /* LL_TMR_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_uart.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_uart.c new file mode 100644 index 0000000000..c0aa9ec980 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_uart.c @@ -0,0 +1,955 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_uart.c + * @author MCD Application Team + * @brief UART LL Module Driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "UART" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup UART_LL UART LL + * @brief UART LL module driver. + * @{ + */ + +#ifdef LL_UART_MODULE_ENABLED + +/* Private variables ---------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private typedef -----------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/** @defgroup UART_LL_Private_Macros UART LL Private Macros + * @brief UART LL Private Macros + * @{ + */ + +/** + * @brief UART Function Alternative + * @param flag Condition Flag + * @param func_t True Funciton + * @param func_f False Function + * @return None + */ +#define UART_FUNC_ALTER(flag, func_t, func_f) \ + do{ \ + if((flag)) { \ + func_t; \ + } else { \ + func_f; \ + } \ + } while(0) + +/** + * @} + */ + + +/* Private function prototypes -----------------------------------------------*/ +/** @addtogroup UART_LL_Exported_Functions UART LL Exported Functions + * @brief UART LL Exported Functions + * @{ + */ +#ifdef LL_DMA_MODULE_ENABLED + + DMA_ChannelETypeDef LL_UART_DMA_Init(DMA_UserCfgTypeDef *dma_user_cfg); + LL_StatusETypeDef LL_UART_DMA_Deinit(DMA_ChannelETypeDef ch); + void LL_UART_DMA_TXCHEndCallback(void *arg); + void LL_UART_DMA_RXCHEndCallback(void *arg); + void LL_UART_DMA_TXCHErrorCallBck(void *arg); + void LL_UART_DMA_RXCHErrorCallBck(void *arg); + +#endif /*!< LL_DMA_MODULE_ENABLED */ +/** + * @} + */ + +/* Exported functions --------------------------------------------------------*/ +/** @defgroup UART_LL_Exported_Functions UART LL Exported Functions + * @brief UART LL Exported Functions + * @{ + */ + +/** @defgroup UART_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and de-initialization functions + * @{ + */ + +/** + * @brief UART LL init + * @param Instance Specifies UART peripheral + * @param Init init pointer + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_Init(UART_TypeDef *Instance, UART_InitTypeDef *Init) +{ + uint32_t baud_rate; + + /* Init the low level hardware eg. Clock, NVIC */ + LL_UART_MspInit(Instance); + + //Parity config + if (Init->parity == UART_PARITY_NO) { + __LL_UART_Parity_Dis(Instance); + } else { + __LL_UART_Parity_En(Instance); + UART_FUNC_ALTER(Init->parity == UART_PARITY_ODD, __LL_UART_EvenParity_Clr(Instance), __LL_UART_EvenParity_Set(Instance)); + } + + //Stop bit config + UART_FUNC_ALTER(Init->stop_len == UART_STOP_LEN_1b, __LL_UART_Stop1Bit_Set(Instance), __LL_UART_Stop2bits_Set(Instance)); + + //Data length config + if (Init->dat_len == UART_DAT_LEN_9b) { + __LL_UART_DatLen9bitsExt_En(Instance); + __LL_UART_RAR_Set(Instance, Init->U9BRxAddress); + + if (Init->U9BAddrMatchMode_Enable == ENABLE) { + __LL_UART_AddrMatchMode_En(Instance); + __LL_UART_TxMode8bits_Set(Instance); + } else { + __LL_UART_AddrMatchMode_Dis(Instance); + __LL_UART_TxMode9bits_Set(Instance); + } + } else { + __LL_UART_DatLen9bitsExt_Dis(Instance); + __LL_UART_DatLen_Sel(Instance, (uint8_t)Init->dat_len); + } + + //FIFO config, FCR register can write only + __LL_UART_FCR_Write(Instance, Init->rx_tl | Init->tx_tl | UART_FCR_XFIFOR_Msk | UART_FCR_RFIFOR_Msk | UART_FCR_FIFOE_Msk); + + //Baudrate config + __LL_UART_DivLatchAccess_Set(Instance); + + baud_rate = (LL_SYSCTRL_APB0ClkGet() + Init->baudrate / 2) / Init->baudrate; + __LL_UART_DivLatchLow_Write(Instance, (uint8_t)(baud_rate >> 4)); + __LL_UART_DivLatchHigh_Write(Instance, (uint8_t)(baud_rate >> 12)); + __LL_UART_DivLatchFrac_Set(Instance, (baud_rate & 0xFUL)); + + __LL_UART_DivLatchAccess_Clr(Instance); + + return LL_OK; +} + +/** + * @brief UART LL deinit + * @param Instance Specifies UART peripheral + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_DeInit(UART_TypeDef *Instance) +{ + /* DeInit the low level hardware eg. Clock, NVIC */ + LL_UART_MspDeInit(Instance); + + return LL_OK; +} + +/** + * @brief Initializes the UART MSP. + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_MspInit(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the UART MSP + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_MspDeInit(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + + +/** @defgroup UART_LL_Exported_Functions_Group2 UART Transmit and Recieve Function + * @brief UART Transmit Function + * @{ + */ + +/** + * @brief Send an amount of data in blocking mode. + * @note When UART parity is not enabled, and Word Length is configured to 9 bits, + * the sent data is handled as a set of u16. In this case, Size must indicate the number + * of u16 provided through pData. + * @param Instance Specifies UART peripheral + * @param pData Pointer to data buffer (u8 or u16 data elements). + * @param Size Amount of data elements (u8 or u16) to be sent. + * @param Timeout Timeout duration. + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_Transmit_CPU(UART_TypeDef *Instance, uint8_t *pData, uint16_t Size, uint32_t Timeout) +{ + uint8_t *pdata8bits; + uint16_t *pdata16bits; + uint32_t tickstart; + uint32_t TxXferCount = Size; + + /* Check the UART initiation struct allocation */ + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + /* In case of 9bits, pRxData needs to be handled as a uint16_t pointer */ + if (__LL_UART_IsDatLen9bitsEn(Instance) && __LL_UART_TxModeSta_Get(Instance)) { + pdata8bits = NULL; + pdata16bits = (uint16_t *) pData; + } else { + pdata8bits = pData; + pdata16bits = NULL; + } + + //Transmit data loop + while (TxXferCount) { + //Wait TxFIFO to be not full + tickstart = LL_GetTick(); + + while (!__LL_UART_IsTxFIFONotFull(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + if (pdata16bits) { + __LL_UART_TxBuf9bits_Write(Instance, *pdata16bits++); + } else { + __LL_UART_TxBuf8bits_Write(Instance, *pdata8bits++); + } + + /* Wait for UART Transmit completed */ + while (!__LL_UART_IsTxEmpty(Instance)); + + TxXferCount--; + } + + return LL_OK; +} + +/** + * @brief Receive an amount of data in blocking mode. + * @note When UART parity is not enabled, and Word Length is configured to 9 bits , + * the received data is handled as a set of u16. In this case, Size must indicate the number + * of u16 available through pData. + * @param Instance Specifies UART peripheral + * @param pData Pointer to data buffer (u8 or u16 data elements). + * @param Size Amount of data elements (u8 or u16) to be received. + * @param Timeout Timeout duration. + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_Receive_CPU(UART_TypeDef *Instance, uint8_t *pData, uint16_t Size, uint32_t Timeout) +{ + uint8_t *pdata8bits; + uint16_t *pdata16bits; + uint32_t tickstart; + uint32_t RxXferCount = Size; + + //Check the UART initiation struct allocation + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + //In case of 9bits, pRxData needs to be handled as a uint16_t pointer + if (__LL_UART_IsDatLen9bitsEn(Instance)) { + pdata8bits = NULL; + pdata16bits = (uint16_t *) pData; + } else { + pdata8bits = pData; + pdata16bits = NULL; + } + + //Receive data loop + while (RxXferCount) { + //Wait RxFIFO to be not empty + tickstart = LL_GetTick(); + + while (!__LL_UART_IsRxFIFONotEmpty(Instance)) { + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + //Read data from RxFIFO + if (pdata16bits) { + *pdata16bits++ = (uint16_t)(__LL_UART_RxBuf9bits_Read(Instance)); + } else { + *pdata8bits++ = (uint8_t)(__LL_UART_RxBuf8bits_Read(Instance)); + } + + RxXferCount--; + } + + return LL_OK; +} + +/** + * @brief Send an amount of data in interrupt mode. + * @param Instance Specifies UART peripheral + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_Transmit_IT(UART_TypeDef *Instance) +{ + /* Check the UART initiation struct allocation */ + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + /* Enable Transmit Holding Register Empty Interrupt */ + __LL_UART_TxHoldEmpyt_INT_En(Instance); + + return LL_OK; +} + +/** + * @brief Receive an amount of data in blocking mode. + * @param Instance Specifies UART peripheral + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_Receive_IT(UART_TypeDef *Instance) +{ + /* Check the UART initiation struct allocation */ + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + /* RX data available interrupt */ + __LL_UART_RxDatAvl_INT_En(Instance); + + return LL_OK; +} + +#ifdef LL_DMA_MODULE_ENABLED +/** + * @brief UART LL Transmit by DMA + * @param Instance Specifies UART peripheral + * @param dma_user_cfg user dma config pointer + * @param huart uart transmit by DMA handle pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_Transmit_DMA(UART_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + UART_DMAHandleTypeDef *huart, uint32_t Timeout) +{ + uint8_t *pdata8bits; + uint16_t *pdata16bits; + huart->dma_tx_ch = DMA_CHANNEL_INVALID; + uint32_t tickstart; + + /* Check the UART initiation struct allocation */ + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + if ((huart->buf == NULL) || (huart->buf_len == 0U)) { + return LL_ERROR; + } + + //In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer + if (__LL_UART_IsDatLen9bitsEn(Instance) && __LL_UART_TxModeSta_Get(Instance)) { + pdata8bits = NULL; + pdata16bits = (uint16_t *) huart->buf; + } else { + pdata8bits = huart->buf; + pdata16bits = NULL; + } + + if (pdata16bits) { + dma_user_cfg->dst_data_width = DMA_DST_TRANS_WIDTH_16b; + } else { + dma_user_cfg->dst_data_width = DMA_DST_TRANS_WIDTH_8b; + } + + huart->Instance = Instance; + huart->TXdma_status = UART_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)huart; + dma_user_cfg->end_callback = LL_UART_DMA_TXCHEndCallback; + dma_user_cfg->err_arg = (void *)huart; + dma_user_cfg->err_callback = LL_UART_DMA_TXCHErrorCallBck; + + tickstart = LL_GetTick(); + + while (huart->dma_tx_ch == DMA_CHANNEL_INVALID) { + huart->dma_tx_ch = LL_UART_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + huart->TXdma_status = UART_DMA_STATE_READY; + + if (pdata16bits) { + LL_DMA_Start_IT(DMA, huart->dma_tx_ch, (uint32_t)pdata16bits, (uint32_t)&Instance->THR, huart->buf_len); + } else { + LL_DMA_Start_IT(DMA, huart->dma_tx_ch, (uint32_t)pdata8bits, (uint32_t)&Instance->THR, huart->buf_len); + } + + huart->TXdma_status = UART_DMA_STATE_BUSY; + + return LL_OK; +} + +/** + * @brief UART LL Receive through DMA + * @param Instance Specifies UART peripheral + * @param huart uart transmit by DMA handle pointer + * @param dma_user_cfg user dma config pointer + * @param Timeout Limited operation time + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_Receive_DMA(UART_TypeDef *Instance, DMA_UserCfgTypeDef *dma_user_cfg, + UART_DMAHandleTypeDef *huart, uint32_t Timeout) +{ + uint8_t *pdata8bits; + uint16_t *pdata16bits; + huart->dma_rx_ch = DMA_CHANNEL_INVALID; + uint32_t tickstart; + + /* Check the UART initiation struct allocation */ + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + if ((huart->buf == NULL) || (huart->buf_len == 0U)) { + return LL_ERROR; + } + + //In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer + if (__LL_UART_IsDatLen9bitsEn(Instance)) { + pdata8bits = NULL; + pdata16bits = (uint16_t *) huart->buf; + } else { + pdata8bits = huart->buf; + pdata16bits = NULL; + } + + if (pdata16bits) { + dma_user_cfg->src_data_width = DMA_SRC_TRANS_WIDTH_16b; + } else { + dma_user_cfg->src_data_width = DMA_SRC_TRANS_WIDTH_8b; + } + + huart->Instance = Instance; + huart->RXdma_status = UART_DMA_STATE_RESET; + + dma_user_cfg->end_arg = (void *)huart; + dma_user_cfg->end_callback = LL_UART_DMA_RXCHEndCallback; + dma_user_cfg->err_arg = (void *)huart; + dma_user_cfg->err_callback = LL_UART_DMA_RXCHErrorCallBck; + + tickstart = LL_GetTick(); + + while (huart->dma_rx_ch == DMA_CHANNEL_INVALID) { + huart->dma_rx_ch = LL_UART_DMA_Init(dma_user_cfg); + + if ((LL_GetTick() - tickstart) > Timeout) { + return LL_TIMEOUT; + } + } + + huart->RXdma_status = UART_DMA_STATE_READY; + + if (pdata16bits) { + LL_DMA_Start_IT(DMA, huart->dma_rx_ch, (uint32_t)&Instance->RBR, (uint32_t)pdata16bits, huart->buf_len); + } else { + LL_DMA_Start_IT(DMA, huart->dma_rx_ch, (uint32_t)&Instance->RBR, (uint32_t)pdata8bits, huart->buf_len); + } + + huart->RXdma_status = UART_DMA_STATE_BUSY; + + return LL_OK; +} +#endif + +/** + * @} + */ + + +/** @defgroup UART_LL_Exported_Functions_Group3 UART Misc Functions + * @brief UART Misc Functions + * @{ + */ + +/** + * @brief UART LL 9BIT Transmit Addr Send + * @param Instance Specifies UART peripheral + * @param TxAddr 9BIT Transmit Addr Send + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_Uart_9bit_SendAddress(UART_TypeDef *Instance, uint8_t TxAddr) +{ + /* Check the UART initiation struct allocation */ + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + if (__LL_UART_IsDatLen9bitsEn(Instance)) { + if (!(__LL_UART_TxModeSta_Get(Instance))) { + /* Transmit Address set */ + __LL_UART_TAR_Set(Instance, TxAddr); + /* Send address */ + __LL_UART_SendAddr_Start(Instance); + return LL_OK; + } else { + __LL_UART_TxBuf9bits_Write(Instance, TxAddr | UART_THR_MSB_9thbit); + __LL_UART_SendDat_Start(Instance); + return LL_OK; + } + + } else { + return LL_ERROR; + } +} + + +/** + * @brief UART LL RS485 Config + * @param Instance Specifies UART peripheral + * @param Cfg RS485 config pointer + @note The receive funtion is Enable by default + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_RS485Cfg(UART_TypeDef *Instance, UART_Rs485CfgTypeDef *Cfg) +{ + /* Check the UART initiation struct allocation */ + assert_param(IS_UART_ALL_INSTANCE(Instance)); + + //RS485 mode enable + __LL_UART_RS485Mode_En(Instance); + + //DE signal enable and palarity config + UART_FUNC_ALTER(Cfg->de_en == ENABLE, __LL_UART_DE_En(Instance), __LL_UART_DE_Dis(Instance)); + + /* The receive funtion is Enable by default*/ + __LL_UART_RE_En(Instance); + + UART_FUNC_ALTER(Cfg->de_polarity == UART_DE_POL_ACT_LOW, __LL_UART_DE_ActLow_Set(Instance), __LL_UART_DE_ActHigh_Set(Instance)); + + //DE assert/deassert time config + __LL_UART_DE_AssertTime_Set(Instance, Cfg->de_assert_time); + __LL_UART_DE_DeAssertTime_Set(Instance, Cfg->de_deassert_time); + + return LL_OK; +} + +/** + * @brief This indicates the number of data entries in the transmit FIFO + * @param Instance UART peripheral + * @return the number of data entries in the transmit FIFO + */ +uint8_t LL_UART_TxFIFOLVL_GET(UART_TypeDef *Instance) +{ + return __LL_UART_TxFIFOLevel_Get(Instance); +} + +/** + * @brief This indicates the number of data entries in the receive FIFO. + * @param Instance UART peripheral + * @return the number of data entries in the receive FIFO. + */ +uint8_t LL_UART_RxFIFOLVL_GET(UART_TypeDef *Instance) +{ + return __LL_UART_RxFIFOLevel_Get(Instance); +} + +/** + * @} + */ + + +/** @defgroup UART_LL_Exported_Functions_Interrupt UART Interrupt handler and callback + * @brief UART Interrupt handler and callback + * @{ + */ + +/** + * @brief UART LL IRQ Handler + * @param Instance &#& + * @return None + */ +void LL_UART_IRQHandler(UART_TypeDef *Instance) +{ + uint8_t int_id = __LL_UART_INT_ID_Get(Instance); + + switch (int_id) { + case UART_INT_ID_MODEM_STA: + LL_UART_ModemStaCallback(Instance); + break; + + case UART_INT_ID_TX_EMPTY: + LL_UART_TxEmptyCallback(Instance); + break; + + case UART_INT_ID_RX_AVL: + LL_UART_RxAvailableCallback(Instance); + break; + + case UART_INT_ID_RX_LINE_STA: + LL_UART_RxLineStaCallback(Instance); + break; + + case UART_INT_ID_BUSY_DET: + LL_UART_BusyDetCallback(Instance); + break; + + case UART_INT_ID_CHAR_TIMEOUT: + LL_UART_CharTimeOutCallback(Instance); + break; + + default: + LOG_E("Error interrupt ID!\n"); + break; + } +} + + +/** + * @brief UART LL Modem Status Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_ModemStaCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_ModemStaCallback could be implemented in the user file + */ +} + +/** + * @brief UART LL Tx Empty Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_TxEmptyCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_TxEmptyCallback could be implemented in the user file + */ + +} + +/** + * @brief UART LL Rx Available Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_RxAvailableCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_RxAvailableCallback could be implemented in the user file + */ +} + +/** + * @brief UART LL RX Line Status Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_RxLineStaCallback(UART_TypeDef *Instance) +{ + uint32_t line_sta = __LL_UART_LineSta_Get(Instance); + + if (line_sta & UART_LSR_RFE_Msk) { + if (line_sta & UART_LSR_BI_Msk) { + LL_UART_BreakErrCallback(Instance); + } + + if (line_sta & UART_LSR_FE_Msk) { + LL_UART_FrameErrCallback(Instance); + } + + if (line_sta & UART_LSR_PE_Msk) { + LL_UART_ParityErrCallback(Instance); + } + + if (line_sta & UART_LSR_OE_Msk) { + LL_UART_RxOverrunErrCallback(Instance); + } + } +} + +/** + * @brief UART LL Busy Detect Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_BusyDetCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_BusyDetCallback could be implemented in the user file + */ +} + +/** + * @brief UART LL Character Timeout Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_CharTimeOutCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_CharTimeOutCallback could be implemented in the user file + */ +} + + +/** + * @brief UART LL Break Error Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_BreakErrCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_BreakErrCallback could be implemented in the user file + */ + +} + +/** + * @brief UART LL Frame Error Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_FrameErrCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_FrameErrCallback could be implemented in the user file + */ + +} + +/** + * @brief UART LL Parity Error Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_ParityErrCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_ParityErrCallback could be implemented in the user file + */ + +} + +/** + * @brief UART LL RX Overrun Error Interrupt Callback + * @param Instance Specifies UART peripheral + * @return None + */ +__WEAK void LL_UART_RxOverrunErrCallback(UART_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_UART_RxOverrunErrCallback could be implemented in the user file + */ + +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ +/** @defgroup UART_LL_Private_Functions UART LL Private function + * @brief UART LL Private function + * @{ + */ + + +#ifdef LL_DMA_MODULE_ENABLED +/** + * @brief UART LL DMA Init + * @param dma_user_cfg user dma config pointer + * @param Timeout Limited operation time + * @return DMA_ChannelETypeDef + */ +DMA_ChannelETypeDef LL_UART_DMA_Init(DMA_UserCfgTypeDef *dma_user_cfg) +{ + DMA_ChannelETypeDef ch = DMA_CHANNEL_INVALID; + int ret; + + /* User DAM channel request */ + ch = LL_DMA_ChannelRequest(); + + if (ch == DMA_CHANNEL_INVALID) { + LOG_E("Requset DMA channel Fail!\n"); + return DMA_CHANNEL_INVALID; + } + + /* User DMA init */ + ret = LL_DMA_Init(DMA, ch, dma_user_cfg); + + if (ret) { + LOG_E("DMA LL init fail!\n"); + LL_DMA_ChannelRelease(ch); + ch = DMA_CHANNEL_INVALID; + return DMA_CHANNEL_INVALID; + } + + return ch; +} + +/** + * @brief UART LL DMA Deinit + * @param Instance Specifies UART peripheral + * @param frame frame pointer + * @return LL_StatusETypeDef + */ +LL_StatusETypeDef LL_UART_DMA_Deinit(DMA_ChannelETypeDef ch) +{ + /* Deinit DMA after tranfer completed */ + LL_DMA_DeInit(DMA, ch); + + /* DMA LL channel release */ + LL_DMA_ChannelRelease(ch); + + /* DMA stop work */ + LL_DMA_Stop_IT(DMA, ch); + + return LL_OK; +} + +/** + * @brief UART DMA TX Channel complete callback + * @param arg Unlimited parameter + * @return None + */ +void LL_UART_DMA_TXCHEndCallback(void *arg) +{ + UART_DMAHandleTypeDef *p_frame = ((UART_DMAHandleTypeDef *)arg); + + /* Wait for UART Transmit completed */ + while (!__LL_UART_IsTxEmpty(p_frame->Instance)); + + /* UART LL DMA Deinit */ + LL_UART_DMA_Deinit(p_frame->dma_tx_ch); + + /* Disable Transmit DMA func */ + p_frame->dma_tx_ch = DMA_CHANNEL_INVALID; + + /* process has been finished */ + p_frame->TXdma_status = UART_DMA_STATE_FINISH; +} + +/** + * @brief UART DMA RX Channel complete callback + * @param arg Unlimited parameter + * @return None + */ +void LL_UART_DMA_RXCHEndCallback(void *arg) +{ + UART_DMAHandleTypeDef *p_frame = ((UART_DMAHandleTypeDef *)arg); + + /* UART LL DMA Deinit */ + LL_UART_DMA_Deinit(p_frame->dma_rx_ch); + + p_frame->dma_rx_ch = DMA_CHANNEL_INVALID; + + /* process has been finished */ + p_frame->RXdma_status = UART_DMA_STATE_FINISH; +} + +/** + * @brief UART DMA TX Channel Error callback + * @param arg Unlimited parameter + * @return None + */ +void LL_UART_DMA_TXCHErrorCallBck(void *arg) +{ + UART_DMAHandleTypeDef *p_frame = ((UART_DMAHandleTypeDef *)arg); + + /* UART LL DMA Deinit */ + LL_UART_DMA_Deinit(p_frame->dma_tx_ch); + + p_frame->dma_tx_ch = DMA_CHANNEL_INVALID; + + /* process has been Error */ + p_frame->TXdma_status = UART_DMA_STATE_ERROR; +} + +/** + * @brief UART DMA RX Channel Error callback + * @param arg Unlimited parameter + * @return None + */ +void LL_UART_DMA_RXCHErrorCallBck(void *arg) +{ + UART_DMAHandleTypeDef *p_frame = ((UART_DMAHandleTypeDef *)arg); + + /* UART LL DMA Deinit */ + LL_UART_DMA_Deinit(p_frame->dma_rx_ch); + + p_frame->dma_rx_ch = DMA_CHANNEL_INVALID; + + /* process has been Error */ + p_frame->RXdma_status = UART_DMA_STATE_ERROR; +} + +#endif /* LL_DMA_MODULE_ENABLED */ +/** + * @} + */ + + +#endif /* LL_UART_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_usb.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_usb.c new file mode 100644 index 0000000000..a3248f562a --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_usb.c @@ -0,0 +1,558 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_usb.c + * @author MCD Application Team + * @brief USB LL Module Driver. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "USB LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup USB_LL USB LL + * @brief USB LL Module Driver. + * @{ + */ + + +#ifdef LL_USB_MODULE_ENABLED + + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup USB_LL_Exported_Functions USB LL Exported Functions + * @brief USB LL Exported Functions + * @{ + */ + +/** @defgroup USB_LL_Exported_Functions_Group1 Initialization and de-initialization functions + * @brief Initialization and Configuration functions + * + @verbatim + =============================================================================== + ##### Initialization and de-initialization functions ##### + =============================================================================== + [..] + This section provides functions allowing to initialize and de-initialize the USB + to be ready for use. + + @endverbatim + * @{ + */ + +/** + * @brief Initializes the USB peripheral + * @param Instance Specifies USB peripheral + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_USB_Init(USB_TypeDef *Instance) +{ + /* Init the low level hardware eg. Clock, NVIC */ + LL_USB_MspInit(Instance); + + //USB Hardware Config + __LL_USB_DMOutputHardware(Instance); + __LL_USB_DPOutputHardware(Instance); + __LL_USB_DMInputHardware(Instance); + __LL_USB_DPInputHardware(Instance); + + __LL_USB_DMPullDownDisable(Instance); + __LL_USB_DMPullUpNormal(Instance); + __LL_USB_DPPullDownDisable(Instance); + __LL_USB_DPPullUpNormal(Instance); + + __LL_USB_VbusValidThreshold_Set(Instance); + __LL_USB_VbusAboveAdevSessThres_Set(Instance); + __LL_USB_VbusAboveSessEndThres_Set(Instance); + __LL_USB_MiniABConnectorID_Set(Instance); + __LL_USB_PHY_En(Instance); + + //USB Power Control + __LL_USB_SoftConn_En(Instance); + __LL_USB_HighSpeed_Dis(Instance); + __LL_USB_SuspendDMOut_En(Instance); + + //USB Detect Interrupt Config + __LL_USB_DebouceMax_Set(Instance, 0x80); + __LL_USB_Conn_Clr(Instance); + __LL_USB_Conn_Int_En(Instance); + __LL_USB_Disconn_Clr(Instance); + __LL_USB_Disconn_Int_En(Instance); + + //USB Interrupt Enable + __LL_USB_Int_EN(Instance, USB_CTRL_INT_ALL_Msk); + __LL_USB_EP0AndEPxTX_Int_EN(Instance, EP_NUM_0); + + //USB INT Send To CPU Config + __LL_USB_INTSendToCPU_En(Instance, USB_CTRL_INT_TO_CPU_Msk); + __LL_USB_INTSendToCPU_En(Instance, USB_EP_INT_TO_CPU_Msk); + __LL_USB_INTSendToCPU_En(Instance, USB_LPM_INT_TO_CPU_Msk); + + return LL_OK; +} + +/** + * @brief DeInitializes the USB peripheral + * @param Instance Specifies USB peripheral + * @return Status of the Initialization + */ +LL_StatusETypeDef LL_USB_DeInit(USB_TypeDef *Instance) +{ + //USB INT Send To CPU Config + __LL_USB_INTSendToCPU_Dis(Instance, USB_CTRL_INT_TO_CPU_Msk); + __LL_USB_INTSendToCPU_Dis(Instance, USB_EP_INT_TO_CPU_Msk); + __LL_USB_INTSendToCPU_Dis(Instance, USB_LPM_INT_TO_CPU_Msk); + + //USB Interrupt Disable + __LL_USB_Int_Dis(Instance, USB_CTRL_INT_ALL_Msk); + __LL_USB_EP0AndEPxTX_Int_Dis(Instance, EP_NUM_0); + + //USB Detect Interrupt Config + __LL_USB_Conn_Clr(Instance); + __LL_USB_Conn_Int_Dis(Instance); + __LL_USB_Disconn_Clr(Instance); + __LL_USB_Disconn_Int_Dis(Instance); + + //USB Power Control + __LL_USB_SoftConn_Dis(Instance); + __LL_USB_SuspendDMOut_Dis(Instance); + + //USB Hardware Config + __LL_USB_DMOutputNormal(Instance); + __LL_USB_DPOutputNormal(Instance); + __LL_USB_DMInputNormal(Instance); + __LL_USB_DPInputNormal(Instance); + __LL_USB_DMPullDownNormal(Instance); + __LL_USB_DMPullUpNormal(Instance); + __LL_USB_DPPullDownNormal(Instance); + __LL_USB_DPPullUpNormal(Instance); + + __LL_USB_VbusValidThreshold_Clr(Instance); + __LL_USB_VbusAboveAdevSessThres_Clr(Instance); + __LL_USB_VbusAboveSessEndThres_Clr(Instance); + __LL_USB_MiniABConnectorID_Clr(Instance); + __LL_USB_PHY_Dis(Instance); + + /* DeInit the low level hardware eg. Clock, NVIC */ + LL_USB_MspDeInit(Instance); + + return LL_OK; +} + +/** + * @brief Initializes the USB MSP. + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_MspInit(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_MspInit could be implemented in the user file + */ +} + +/** + * @brief DeInitializes the USB MSP + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_MspDeInit(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_MspDeInit could be implemented in the user file + */ +} +/** + * @} + */ + + +/** @defgroup USB_LL_Exported_Functions_Group2 USB Controler Initerrupt Management + * @brief USB Controler Initerrupt Management + * + @verbatim + ============================================================================== + ##### IRQ handler management ##### + ============================================================================== + [..] + This section provides USB Controler IRQ handler function. + @endverbatim + * @{ + */ + +/** + * @brief LL USB Controler IRQ Handler + * @param Instance Specifies USB peripheral + * @return None + */ +void LL_USB_CtrlIRQHandler(USB_TypeDef *Instance) +{ + uint8_t usb_ctrl_int_sta = __LL_USB_IntSta_Get(Instance); + + if (usb_ctrl_int_sta & USB_SUSPEND_INT_STA_Msk) { + LL_USB_CtrlSuspendCallback(Instance); + } + + if (usb_ctrl_int_sta & USB_RESUME_INT_STA_Msk) { + LL_USB_CtrlResumeCallback(Instance); + } + + if (usb_ctrl_int_sta & USB_RST_INT_STA_Msk) { + LL_USB_CtrlResetCallback(Instance); + } + + if (usb_ctrl_int_sta & USB_SOF_INT_STA_Msk) { + LL_USB_CtrlSofCallback(Instance); + } + + if (usb_ctrl_int_sta & USB_SESS_END_INT_STA_Msk) { + LL_USB_CtrlSessEndCallback(Instance); + } +} + +/** + * @brief USB Controler Suspend Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_CtrlSuspendCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_CtrlSuspendCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Controler Resume Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_CtrlResumeCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_CtrlResumeCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Controler Reset Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_CtrlResetCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_CtrlResetCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Controler SOF Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_CtrlSofCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_CtrlSofCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Controler Session End Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_CtrlSessEndCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_CtrlSessEndCallback could be implemented in the USB Middleware file + */ +} +/** + * @} + */ + + +/** @defgroup USB_LL_Exported_Functions_Group3 USB Detect Initerrupt Management + * @brief USB Detect Initerrupt Management + * + @verbatim + ============================================================================== + ##### IRQ handler management ##### + ============================================================================== + [..] + This section provides USB Detect IRQ handler function. + @endverbatim + * @{ + */ + +/** + * @brief LL USB Detect IRQ Handler + * @param Instance Specifies USB peripheral + * @return None + */ +void LL_USB_DetIRQHandler(USB_TypeDef *Instance) +{ + if (__LL_USB_IsConn(Instance)) { + __LL_USB_Conn_Clr(Instance); + LL_USB_DetConnectCallback(Instance); + } + + if (__LL_USB_IsDisconn(Instance)) { + __LL_USB_Disconn_Clr(Instance); + LL_USB_DetDisonnectCallback(Instance); + } +} + +/** + * @brief USB Detect Connect Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_DetConnectCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_DetConnectCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Detect Disconnect Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_DetDisonnectCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_DetDisonnectCallback could be implemented in the USB Middleware file + */ +} +/** + * @} + */ + + +/** @defgroup USB_LL_Exported_Functions_Group4 USB Endpoint Initerrupt Management + * @brief USB Endpoint Initerrupt Management + * + @verbatim + ============================================================================== + ##### IRQ handler management ##### + ============================================================================== + [..] + This section provides USB Endpoint IRQ handler function. + @endverbatim + * @{ + */ + +/** + * @brief LL USB Endpoint IRQ Handler + * @param Instance Specifies USB peripheral + * @return None + */ +void LL_USB_EpIRQHandler(USB_TypeDef *Instance) +{ + uint8_t ep0_epxtx_int_sta, epx_rx_int_sta; + + //Get all endpoint interrupt status + epx_rx_int_sta = __LL_USB_EPx_RXIntSta_Get(Instance); + ep0_epxtx_int_sta = __LL_USB_EP0AndEPxTX_IntSta_Get(Instance); + + if (ep0_epxtx_int_sta & USB_EP0_INT_STA_Msk) { /* Endpoint 0 Interrupt */ + //USB Endpoint Index Set + __LL_USB_EPIndex_Set(Instance, EP_NUM_0); + + if (__LL_USB_IsSetupPacket(Instance) && __LL_USB_EP0_IsRXPktRdy(Instance)) { //Endpoint 0 Setup + LL_USB_Ep0SetupCallback(Instance); + } else if (__LL_USB_IsInPacket(Instance)) { //Endpoint 0 IN + LL_USB_Ep0InCallback(Instance); + } else if (__LL_USB_IsOutPacket(Instance) && __LL_USB_EP0_IsRXPktRdy(Instance)) { //Endpoint 0 OUT + LL_USB_Ep0OutCallback(Instance); + } + } else if (ep0_epxtx_int_sta & USB_TX_EP1_INT_STA_Msk) { /* Endpoint 1 IN Interrupt */ + //USB Endpoint Index Set + __LL_USB_EPIndex_Set(Instance, EP_NUM_1); + LL_USB_Ep1InCallback(Instance); + } else if (ep0_epxtx_int_sta & USB_TX_EP2_INT_STA_Msk) { /* Endpoint 2 IN Interrupt */ + //USB Endpoint Index Set + __LL_USB_EPIndex_Set(Instance, EP_NUM_2); + LL_USB_Ep2InCallback(Instance); + } else if (epx_rx_int_sta & USB_RX_EP1_INT_STA_Msk) { /* Endpoint 1 OUT Interrupt */ + //USB Endpoint Index Set + __LL_USB_EPIndex_Set(Instance, EP_NUM_1); + LL_USB_Ep1OutCallback(Instance); + } else if (epx_rx_int_sta & USB_RX_EP2_INT_STA_Msk) { /* Endpoint 2 OUT Interrupt */ + //USB Endpoint Index Set + __LL_USB_EPIndex_Set(Instance, EP_NUM_2); + LL_USB_Ep2OutCallback(Instance); + } +} + +/** + * @brief USB Endpoint 0 Setup Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_Ep0SetupCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_Ep0SetupCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Endpoint 0 In Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_Ep0InCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_Ep0InCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Endpoint 0 Out Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_Ep0OutCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_Ep0OutCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Endpoint 1 In Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_Ep1InCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_Ep1InCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Endpoint 1 Out Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_Ep1OutCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_Ep1OutCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Endpoint 2 In Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_Ep2InCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_Ep2InCallback could be implemented in the USB Middleware file + */ +} + +/** + * @brief USB Endpoint 2 Out Callback + * @param Instance Specifies USB peripheral + * @return None + */ +__WEAK void LL_USB_Ep2OutCallback(USB_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + /* NOTE: This function should not be modified, when the callback is needed, + the LL_USB_Ep2OutCallback could be implemented in the USB Middleware file + */ +} +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_USB_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_wwdg.c b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_wwdg.c new file mode 100644 index 0000000000..5f95852d46 --- /dev/null +++ b/bsp/tae32f5300/Libraries/TAE32F53xx_StdPeriph_Driver/src/tae32f53xx_ll_wwdg.c @@ -0,0 +1,268 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_wwdg.c + * @author MCD Application Team + * @brief WWDG LL module driver. + * This file provides firmware functions to manage the following + * functionalities of the Window Watchdog (WWDG) peripheral: + * + Initialization and de-initialization functions + * + Refresh function + * + Interrupt and Callback functions + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" + + +#define DBG_TAG "WWDG LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_LL_Driver + * @{ + */ + +/** @defgroup WWDG_LL WWDG LL + * @brief WWDG LL module driver + * @{ + */ + +#ifdef LL_WWDG_MODULE_ENABLED + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/** @defgroup WWDG_LL_Exported_Functions WWDG LL Exported Functions + * @brief WWDG LL Exported Functions + * @{ + */ + +/** @defgroup WWDG_LL_Exported_Functions_Group1 Initialization and De-Initialization functions + * @brief Initialization and Configuration functions. + * +@verbatim + ============================================================================== + ##### Initialization and De-Initialization functions ##### + ============================================================================== + [..] This section provides a set of functions allowing to initialize and + deinitialize the WWDG peripheral + +@endverbatim + * @{ + */ + +/** + * @brief Initialize the WWDG according to the specified. + * parameters in the WWDG_InitTypeDef of associated handle. + * @param Instance WWDG peripheral + * @param Init pointer to a WWDG_HandleTypeDef structure that contains + * the configuration information for the specified WWDG module. + * @return LL status + */ +LL_StatusETypeDef LL_WWDG_Init(WWDG_TypeDef *Instance, WWDG_InitTypeDef *Init) +{ + /* Check the WWDG handle allocation */ + if (Init == NULL) { + return LL_ERROR; + } + + /* Check the parameters */ + assert_param(IS_WWDG_ALL_INSTANCE(Instance)); + assert_param(IS_WWDG_PRESCALER(Init->Prescaler)); + assert_param(IS_WWDG_WINDOW(Init->Window)); + assert_param(IS_WWDG_COUNTER(Init->Counter)); + + /* Handle Something */ + LL_WWDG_MspInit(Instance); + + /* Set WWDG Counter */ + WRITE_REG(Instance->CVR, Init->Counter); + + /* Set WWDG Prescaler */ + WRITE_REG(Instance->PSCR, Init->Prescaler); + + /* Set WWDG Window Val */ + WRITE_REG(Instance->WVR, Init->Window); + + /* SET Early Interrupt */ + MODIFY_REG(Instance->CR, WWDG_CR_EWIE, Init->EWIMode); + + /* Start WWDG Counter */ + __LL_WWDG_ENABLE(Instance); + + /* Return function status */ + return LL_OK; +} + +/** + * @brief De-initializes the WWDG peripheral. + * @param Instance WWDG peripheral + * @return status of the de-initialization + */ +LL_StatusETypeDef LL_WWDG_DeInit(WWDG_TypeDef *Instance) +{ + /* Check the parameters */ + assert_param(IS_WWDG_ALL_INSTANCE(Instance)); + + /*Disable WWDG*/ + __LL_WWDG_DISABLE(Instance); + + /* Handle Something */ + LL_WWDG_MspDeInit(Instance); + + /* Return function status */ + return LL_OK; +} + +__WEAK void LL_WWDG_MspInit(WWDG_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_WWDG_MspInit could be implemented in the user file + */ +} + +__WEAK void LL_WWDG_MspDeInit(WWDG_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_WWDG_MspDeInit could be implemented in the user file + */ +} + +/** + * @} + */ + + +/** @defgroup WWDG_LL_Exported_Functions_Group2 WWDG Input and Output operation functions + * @brief WWDG Input and Output operation functions +@verbatim + =============================================================================== + ##### Input and Output operation functions ##### + =============================================================================== + [..] + This section provides functions allowing to: + (+) Refresh the WWDG. + +@endverbatim + * @{ + */ + +/** + * @brief Refresh the WWDG. + * @param Instance WWDG peripheral + * @param Counter Counter value to refresh with + * @return LL status + */ +LL_StatusETypeDef LL_WWDG_Refresh(WWDG_TypeDef *Instance, uint16_t Counter) +{ + /* Check the parameters */ + assert_param(IS_WWDG_ALL_INSTANCE(Instance)); + assert_param(IS_WWDG_COUNTER(Counter)); + + /* Write to WWDG CR the WWDG Counter value to refresh with */ + __LL_WWDG_SET_COUNTER(Instance, Counter); + + /* Return function status */ + return LL_OK; +} + +/** + * @} + */ + + +/** @defgroup WWDG_LL_Exported_Functions_Interrupt WWDG Interrupt management + * @brief WWDG Initerrupt management +@verbatim + =============================================================================== + ##### Initerrupt management ##### + =============================================================================== + [..] + This section provides WWDG interrupt handler and callback functions. + +@endverbatim + * @{ + */ + +/** + * @brief Handle WWDG interrupt request. + * @param Instance: WWDG peripheral + * @return None + */ +void LL_WWDG_IRQHandler(WWDG_TypeDef *Instance) +{ + /* Check if Early Wakeup Interrupt is enable */ + if ((__LL_WWDG_CHECK_IT_SOURCE(Instance, WWDG_IT_EWIE) != RESET) && (__LL_WWDG_GET_FLAG(Instance, WWDG_FLAG_EWIF) != RESET)) { + + /* Clear Flag */ + __LL_WWDG_CLEAR_FLAG(Instance, WWDG_FLAG_EWIF); + + /* Early Wakeup callback */ + LL_WWDG_EarlyWakeUpCallback(Instance); + } +} + +/** + * @brief WWDG Early Wakeup callback. + * @param Instance WWDG peripheral + * @return None + */ +__WEAK void LL_WWDG_EarlyWakeUpCallback(WWDG_TypeDef *Instance) +{ + /* Prevent unused argument(s) compilation warning */ + LL_UNUSED(Instance); + + /* NOTE: This function should not be modified, when the callback is needed, + the LL_WWDG_EarlyWakeupCallback could be implemented in the user file + */ +} + +/** + * @} + */ + +/** + * @} + */ + + +/* Private functions ---------------------------------------------------------*/ + + +#endif /* LL_WWDG_MODULE_ENABLED */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/README.md b/bsp/tae32f5300/README.md new file mode 100644 index 0000000000..3dd03d29a2 --- /dev/null +++ b/bsp/tae32f5300/README.md @@ -0,0 +1,127 @@ +# 珠海泰为 TAE32F5300_EVAL_BOARD 开发板 BSP 说明 + +## 简介 + +本文档为 TAE32F5300_EVAL_BOARD 开发板的 BSP (板级支持包) 说明。 + +主要内容如下: + +- 开发板资源介绍 +- BSP 快速上手 +- 进阶使用方法 + +通过阅读快速上手章节开发者可以快速地上手该 BSP,将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。 + +## 开发板介绍 + +![image-20210905115438031](.\figures\TAE32_EVBorad.png) + +TAE32F5300_EVAL_BOARD 是珠海泰为官方推出的开发板,搭载 TAE32F5300 芯片,基于 ARM Cortex-M3 内核,最高主频 90 MHz,内置硬件加速器(ERPU),具有丰富的板载资源,包括 can 收发电路、485 收发电路,音频输入接口、USB 接口、LED、按键等。 + +TAE32F5300_EVAL_BOARD 开发板常用 ** 板载资源 ** 如下: + +- MCU:TAE32F5300,主频 90MHz,75KBFLASH ,内置 16KB 容量数据 FLASH 存储器, 内置 16KB 系统 SRAM+8KB 算法 SRAM(两块 SRAM 4KB+4KB) +- 板载资源 + - 蜂鸣器 + - USB + - LED + - 按键 + - 音频输入口 + - 可调电阻 + - 温湿度传感器接口 + - EEPROM + - 蓝牙模块接口 + - RS485 + - CAN + - uart lcd +- 调试接口:标准 JTAG/SWD。 + +开发板更多详细信息请参考珠海泰为 [TAE32F5300_EVAL_BOARD](http://www.tai-action.com/) + +## 外设支持 + +本 BSP 目前对外设的支持情况如下: + +| ** 板载外设 ** | ** 支持情况 ** | ** 备注 ** | +| :------------ | :-----------: | :-----------------------------------: | +| LED | 支持 | LED | +| ** 片上外设 ** | ** 支持情况 ** | ** 备注 ** | +| :------------ | :-----------: | :-----------------------------------: | +| GPIO | 支持 | PA0, PA1... PI15 ---> PIN: 0, 1...144 | +| UART | 支持 | UART0~1 | +| I2C | 支持 | 软件 I2C | +| LED | 支持 | LED1~3 | + + +## 使用说明 + +使用说明分为如下两个章节: + +- 快速上手 + + 本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。 + +- 进阶使用 + + 本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。 + + +### 快速上手 + +本 BSP 为开发者提供 MDK5 工程,暂不支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。 + +#### 硬件连接 + +#### CMSIS-DAP 接线 + +| TAE32 开发板 | CMSIS-DAP | +| :---------- | :-------: | +| SWDIO | SWDIO | +| SWCLK | SWCLK | +| VCC | 3.3v | +| GND | GND | + +串口转 USB 接线 + +| TAE32 开发板 | 串口转 USB | +| :---------- | :-------: | +| RXD(PA10) | TXD | +| TXD(PA11) | RXD | +| GND | GND | + +#### 编译下载 + +双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。 + +> 工程默认配置使用 CMSIS-DAP 下载程序,点击下载按钮即可下载程序到开发板。 + +#### 运行结果 + +下载程序成功之后,系统会自动运行,观察开发板上 LED 的运行效果,PB6 每 500ms 闪烁一次。 +``` + \ | / +- RT - Thread Operating System + / | \ 4.0.4 build Aug 29 2021 + 2006 - 2021 Copyright by rt-thread team +msh > +``` + +### 进阶使用 + +此 BSP 默认只开启了 GPIO 和 串口 0 的功能,更多高级功能需要利用 env 工具对 BSP 进行配置,步骤如下: + +1. 在 bsp 下打开 env 工具。 + +2. 输入 `menuconfig` 命令配置工程,配置好之后保存退出。 + +3. 输入 `pkgs --update` 命令更新软件包。 + +4. 输入 `scons --target=mdk5` 命令重新生成工程。 + +## 注意事项 + +## 联系人信息 + +维护人: + +- qinweizhong 邮箱:<369247354@qq.com> \ No newline at end of file diff --git a/bsp/tae32f5300/SConscript b/bsp/tae32f5300/SConscript new file mode 100644 index 0000000000..24bb4646ab --- /dev/null +++ b/bsp/tae32f5300/SConscript @@ -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') diff --git a/bsp/tae32f5300/SConstruct b/bsp/tae32f5300/SConstruct new file mode 100644 index 0000000000..64fb270f47 --- /dev/null +++ b/bsp/tae32f5300/SConstruct @@ -0,0 +1,43 @@ +import os +import sys +import rtconfig + +print("############sconstruct##############") +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 = 'TAE32F53xx.' + 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', + 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 = env["LINKCOM"] + ' --map project.map') + +Export('RTT_ROOT') +Export('rtconfig') + +# prepare building environment +print("######################env:") +print(env) +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) + +# make a building +DoBuilding(TARGET, objs) diff --git a/bsp/tae32f5300/application/SConscript b/bsp/tae32f5300/application/SConscript new file mode 100644 index 0000000000..6f66f7ab73 --- /dev/null +++ b/bsp/tae32f5300/application/SConscript @@ -0,0 +1,12 @@ +import rtconfig +from building import * + +cwd = GetCurrentDir() +CPPPATH = [cwd, str(Dir('#'))] +src = Split(""" +main.c +""") + +group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/tae32f5300/application/main.c b/bsp/tae32f5300/application/main.c new file mode 100644 index 0000000000..f86f07e29b --- /dev/null +++ b/bsp/tae32f5300/application/main.c @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2006-2019, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-05 qinweizhong add support for tae32 + */ +#include "rtthread.h" +#include "board.h" + +#define LED_PIN 42 + +int main(void) +{ + int count = 1; + rt_pin_mode(LED_PIN, PIN_MODE_OUTPUT); + + while (count++) + { + rt_pin_write(LED_PIN, PIN_HIGH); + rt_thread_mdelay(500); + rt_pin_write(LED_PIN, PIN_LOW); + rt_thread_mdelay(500); + + rt_kprintf("count %d\r\n", count); + } +} diff --git a/bsp/tae32f5300/application/main.h b/bsp/tae32f5300/application/main.h new file mode 100644 index 0000000000..059031647f --- /dev/null +++ b/bsp/tae32f5300/application/main.h @@ -0,0 +1,73 @@ +/** + ****************************************************************************** + * @file main.h + * @author MCD Application Team + * @brief Header for main.c module + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _MAIN_H_ +#define _MAIN_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_ll.h" +//#include "dbg/user_debug.h" +#include + + +/** @addtogroup TAE32F53xx_Examples + * @{ + */ + +/** @addtogroup TAE32F53xx_Template + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/* Exported types ------------------------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _MAIN_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/board/SConscript b/bsp/tae32f5300/board/SConscript new file mode 100644 index 0000000000..6b3f27dfb0 --- /dev/null +++ b/bsp/tae32f5300/board/SConscript @@ -0,0 +1,17 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() + +# add the general board. +src = Split(""" +board.c +tae32f53xx_ll_msp.c +""") + +CPPPATH = [cwd] + +group = DefineGroup('Board', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/tae32f5300/board/board.c b/bsp/tae32f5300/board/board.c new file mode 100644 index 0000000000..8bec0168d2 --- /dev/null +++ b/bsp/tae32f5300/board/board.c @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2006-2019, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-05 qinweizhong add support for tae32 + */ +#include "board.h" + +#define _SCB_BASE (0xE000E010UL) +#define _SYSTICK_CTRL (*(rt_uint32_t *)(_SCB_BASE + 0x0)) +#define _SYSTICK_LOAD (*(rt_uint32_t *)(_SCB_BASE + 0x4)) +#define _SYSTICK_VAL (*(rt_uint32_t *)(_SCB_BASE + 0x8)) +#define _SYSTICK_CALIB (*(rt_uint32_t *)(_SCB_BASE + 0xC)) +#define _SYSTICK_PRI (*(rt_uint8_t *)(0xE000ED23UL)) + +static uint32_t _SysTick_Config(rt_uint32_t ticks) +{ + if ((ticks - 1) > 0xFFFFFF) + { + return 1; + } + + _SYSTICK_LOAD = ticks - 1; + _SYSTICK_PRI = 0x01; + _SYSTICK_VAL = 0; + _SYSTICK_CTRL = 0x07; + + return 0; +} + +#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) +#define RT_HEAP_SIZE 2048 +static uint32_t rt_heap[RT_HEAP_SIZE];/* heap default size: 4K(1024 * 4)*/ +RT_WEAK void *rt_heap_begin_get(void) +{ + return rt_heap; +} + +RT_WEAK void *rt_heap_end_get(void) +{ + return rt_heap + RT_HEAP_SIZE; +} +#endif + +/** + * This function will initial your board. + */ +void rt_hw_board_init() +{ + /* System Clock Update */ + SystemClock_Config(); + /* System Tick Configuration */ + LL_Init(); + _SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); + + /* Call components board initial (use INIT_BOARD_EXPORT()) */ +#ifdef RT_USING_COMPONENTS_INIT + rt_components_board_init(); +#endif + +#if defined(RT_USING_USER_MAIN) && defined(RT_USING_HEAP) + rt_system_heap_init(rt_heap_begin_get(), rt_heap_end_get()); +#endif +#ifdef RT_USING_CONSOLE + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); +#endif +} + +void SysTick_Handler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + + rt_tick_increase(); + + /* leave interrupt */ + rt_interrupt_leave(); +} + +void rt_hw_console_output(const char *str) +{ + rt_size_t i = 0, size = 0; + char a = '\r'; + + size = rt_strlen(str); + for (i = 0; i < size; i++) + { + if (*(str + i) == '\n') + { + /*Wait TXFIFO to be no full*/ + while (!__LL_UART_IsTxFIFONotFull(UART0)) {}; + + /*Send data to UART*/ + __LL_UART_TxBuf9bits_Write(UART0, (uint16_t)a); + } + while (!__LL_UART_IsTxFIFONotFull(UART0)) {}; + + /*Send data to UART*/ + __LL_UART_TxBuf9bits_Write(UART0, (uint16_t)(*(str + i))); + } +} + +char rt_hw_console_getchar(void) +{ + /* note: ch default value < 0 */ + int ch = -1; + if (__LL_UART_IsDatReady(UART0)) + { + /* receive data */ + ch = __LL_UART_RxBuf9bits_Read(UART0); + } + else + { + rt_thread_mdelay(10); + } + return ch; +} + +void SystemClock_Config(void) +{ + LL_StatusETypeDef ret; + SYSCTRL_SysclkUserCfgTypeDef sysclk_cfg; + + /*FPLL0 Init*/ + LL_FPLL_Init(FPLL0); + + /*SYSCLK Clock Config*/ + sysclk_cfg.sysclk_src = SYSCLK_SRC_PLL0DivClk; + sysclk_cfg.sysclk_freq = 90000000UL; + sysclk_cfg.pll0clk_src = PLLCLK_SRC_XOSC; + sysclk_cfg.pll0clk_src_freq = HSE_VALUE; + sysclk_cfg.apb0_clk_div = SYSCTRL_CLK_DIV_1; + sysclk_cfg.apb1_clk_div = SYSCTRL_CLK_DIV_1; + ret = LL_SYSCTRL_SysclkInit(SYSCTRL, &sysclk_cfg); + + if (ret == LL_OK) + { + SystemCoreClockUpdate(sysclk_cfg.sysclk_freq); + } + + /*eFlash Memory CLK Source and Div Config*/ + LL_SYSCTRL_EFLASH_ClkCfg(EFLASH_CLK_SRC_PLL0DivClk, SYSCTRL_CLK_DIV_9); +} diff --git a/bsp/tae32f5300/board/board.h b/bsp/tae32f5300/board/board.h new file mode 100644 index 0000000000..cf06e44330 --- /dev/null +++ b/bsp/tae32f5300/board/board.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2006-2019, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-05 qinweizhong add support for tae32 + */ + +#include +#include +#include +#include + +#include "main.h" +#include "tae32f53xx.h" + +void SystemClock_Config(void); diff --git a/bsp/tae32f5300/board/dbg/tae32f53xx_dbg.h b/bsp/tae32f5300/board/dbg/tae32f53xx_dbg.h new file mode 100644 index 0000000000..5358f8076e --- /dev/null +++ b/bsp/tae32f5300/board/dbg/tae32f53xx_dbg.h @@ -0,0 +1,258 @@ +/** + ****************************************************************************** + * @file tae32f53xx_dbg.h + * @author MCD Application Team + * @brief The macro definitions for dbg + * + ============================================================================== + ##### How to use ##### + ============================================================================== + * + * If you want to use debug macro, you can use as following steps: + * + * Step 1: Macros in "tae32f53xx_dbg_conf.h" + * a. Define the TAE_USING_DBG to enable the feature + * #define TAE_USING_DBG + * + * b. Define the print interface for dbg + * #define TAE_DBG_PRINT(...) printf(__VA_ARGS__) + * + * c. Other optional macros define, such as TAE_USING_DBG_COLOR + * + * Step 2: Macros in your C/C++ file + * a. Define the debug tag and level for dbg. If you did not define this, + default definition will be used. + * #define DBG_TAG "TAG" // must be string + * #define DBG_LVL DBG_INFO // others DBG_ERROR, DBG_WARNING, DBG_LOG. + * DBG_LOG > DBG_INFO > DBG_WARNING > DBG_ERROR + * + * b. Include this header file + * #include "tae32f53xx_dbg.h" // this must after of DBG_LVL, DBG_TAG or other options + * + * Step 3: LOG_X macro to print out logs in your C/C++ file + * PLEASE NOTE: LOG_X is related to the DBG_LVL that defined in Step 2. Using LOG_X + * witch higher then DBG_LVL will be ignored. + * LOG_D("this is a debug log!"); + * LOG_I("this is a info log!") + * LOG_W("this is a warning log!") + * LOG_E("this is a error log!"); + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_DBG_H_ +#define _TAE32F53XX_DBG_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include "tae32f53xx_dbg_conf.h" + + +/** @addtogroup TAE_Utilities + * @{ + */ + +/** @defgroup TAE_Debug TAE Debug + * @brief TAE Debug + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/** @defgroup TAE_Debug_Exported_Constants TAE Debug Exported Constants + * @brief TAE Debug Exported Constants + * @{ + */ + +#ifdef TAE_USING_DBG + +/* DEBUG level */ +#define DBG_NONE 0 +#define DBG_ERROR 1 +#define DBG_WARNING 2 +#define DBG_INFO 3 +#define DBG_LOG 4 + +/* The color for terminal (foreground) */ +#define BLACK 30 +#define RED 31 +#define GREEN 32 +#define YELLOW 33 +#define BLUE 34 +#define PURPLE 35 +#define CYAN 36 +#define WHITE 37 +#define CLEAR_ALL 0 + +#ifndef DBG_TAG +#define DBG_TAG "DBG" +#endif + +#ifndef DBG_LVL +#define DBG_LVL DBG_WARNING +#endif + +#ifndef TAE_DBG_PRINT +#define TAE_DBG_PRINT(fmt, ...) +#endif + +#endif /* TAE_USING_DBG */ + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup TAE_Debug_Exported_Macros TAE Debug Exported Macros + * @brief TAE Debug Exported Macros + * @{ + */ + +#ifdef TAE_USING_DBG + +#ifdef TAE_USING_DBG_COLOR +#define _DBG_COLOR(color) TAE_DBG_PRINT("\033["#color"m") +#define _DBG_LOG_HEAD(lvl_name, color) TAE_DBG_PRINT("\033["#color"m[" lvl_name "@" DBG_TAG "] ") +#define _DBG_LOG_END() TAE_DBG_PRINT("\033[0m") +#else +#define _DBG_COLOR(color) +#define _DBG_LOG_HEAD(lvl_name, color) TAE_DBG_PRINT("[" lvl_name "@" DBG_TAG "] ") +#define _DBG_LOG_END() TAE_DBG_PRINT("") +#endif /* TAE_USING_DBG_COLOR */ + + +#define DBG_LogRaw(...) TAE_DBG_PRINT(__VA_ARGS__) + +#define DBG_Log(lvl_name, color, fmt, ...) \ + do { \ + _DBG_LOG_HEAD(lvl_name, color); \ + TAE_DBG_PRINT(fmt, ##__VA_ARGS__); \ + _DBG_COLOR(0); \ + } while (0) + +#define DBG_LogLine(lvl_name, color, fmt, ...) \ + do { \ + _DBG_LOG_HEAD(lvl_name, color); \ + TAE_DBG_PRINT(fmt, ##__VA_ARGS__); \ + _DBG_COLOR(0); \ + _DBG_LOG_END(); \ + } while (0) + +#define DBG_Here() \ + if ((DBG_LVL) >= DBG_INFO) { \ + _DBG_LOG_HEAD("I", 32); \ + TAE_DBG_PRINT("Here is %s:%d", __FUNCTION__, \ + __LINE__); \ + _DBG_COLOR(0); \ + _DBG_LOG_END(); \ + } + +#define DBG_Enter() \ + if ((DBG_LVL) >= DBG_INFO) { \ + _DBG_LOG_HEAD("I", 32); \ + TAE_DBG_PRINT("Enter function %s", __FUNCTION__); \ + _DBG_COLOR(0); \ + _DBG_LOG_END(); \ + } + +#define DBG_Exit() \ + if ((DBG_LVL) >= DBG_INFO) { \ + _DBG_LOG_HEAD("I", 32); \ + TAE_DBG_PRINT("Exit function %s", __FUNCTION__); \ + _DBG_COLOR(0); \ + _DBG_LOG_END(); \ + } + +#else + +#define DBG_Log(level, fmt, ...) +#define DBG_LogLine(lvl_name, color, fmt, ...) +#define DBG_LogRaw(...) +#define DBG_Here() +#define DBG_Enter() +#define DBG_Exit() + +#endif /* TAE_USING_DBG */ + + +#if (DBG_LVL >= DBG_LOG) +#define LOG_D(fmt, ...) DBG_LogLine("D", CLEAR_ALL, fmt, ##__VA_ARGS__) +#else +#define LOG_D(fmt, ...) +#endif + +#if (DBG_LVL >= DBG_INFO) +#define LOG_I(fmt, ...) DBG_LogLine("I", GREEN, fmt, ##__VA_ARGS__) +#else +#define LOG_I(fmt, ...) +#endif + +#if (DBG_LVL >= DBG_WARNING) +#define LOG_W(fmt, ...) DBG_LogLine("W", YELLOW, fmt, ##__VA_ARGS__) +#else +#define LOG_W(fmt, ...) +#endif + +#if (DBG_LVL >= DBG_ERROR) +#define LOG_E(fmt, ...) DBG_LogLine("E", RED, fmt, ##__VA_ARGS__) +#else +#define LOG_E(fmt, ...) +#endif + +#define LOG_R(...) DBG_LogRaw(__VA_ARGS__) + +#define LOG_Enter() DBG_Enter() + +#define LOG_Exit() DBG_Exit() + +#define LOG_Here() DBG_Here() + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_DBG_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/board/linker_scripts/link.icf b/bsp/tae32f5300/board/linker_scripts/link.icf new file mode 100644 index 0000000000..3a80cf803b --- /dev/null +++ b/bsp/tae32f5300/board/linker_scripts/link.icf @@ -0,0 +1,65 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_4.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x00000000; +define symbol __ICFEDIT_region_IROM1_end__ = 0x001FFFFF; +define symbol __ICFEDIT_region_IROM2_start__ = 0x03000000; +define symbol __ICFEDIT_region_IROM2_end__ = 0x030017FF; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x1FFE0000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x1FFFFFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x2001FFFF; +define symbol __ICFEDIT_region_IRAM3_start__ = 0x20020000; +define symbol __ICFEDIT_region_IRAM3_end__ = 0x2003FFFF; +define symbol __ICFEDIT_region_IRAM4_start__ = 0x20040000; +define symbol __ICFEDIT_region_IRAM4_end__ = 0x20057FFF; +define symbol __ICFEDIT_region_IRAM5_start__ = 0x20058000; +define symbol __ICFEDIT_region_IRAM5_end__ = 0x2005FFFF; +define symbol __ICFEDIT_region_IRAM6_start__ = 0x200F0000; +define symbol __ICFEDIT_region_IRAM6_end__ = 0x200F0FFF; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; + +define symbol __ICFEDIT_region_RAM_end__ = __ICFEDIT_region_IRAM6_end__; +export symbol __ICFEDIT_region_RAM_end__; + + +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x2100; +define symbol __ICFEDIT_size_proc_stack__ = 0x0; +define symbol __ICFEDIT_size_heap__ = 0x2000; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region ROM_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__] + | mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__]; +define region RAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__] + | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__] + | mem:[from __ICFEDIT_region_IRAM3_start__ to __ICFEDIT_region_IRAM3_end__] + | mem:[from __ICFEDIT_region_IRAM4_start__ to __ICFEDIT_region_IRAM4_end__] + | mem:[from __ICFEDIT_region_IRAM5_start__ to __ICFEDIT_region_IRAM5_end__] + | mem:[from __ICFEDIT_region_IRAM6_start__ to __ICFEDIT_region_IRAM6_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +initialize by copy { readwrite }; +do not initialize { section .noinit }; + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in ROM_region { readonly }; +place in RAM_region { readwrite, last block CSTACK, block HEAP }; \ No newline at end of file diff --git a/bsp/tae32f5300/board/linker_scripts/link.lds b/bsp/tae32f5300/board/linker_scripts/link.lds new file mode 100644 index 0000000000..af109a6da6 --- /dev/null +++ b/bsp/tae32f5300/board/linker_scripts/link.lds @@ -0,0 +1,203 @@ + /** + ******************************************************************************* + * @file hc32f4a0_flash.lds + * @brief Linker script for HC32F4A0 Device with 2MByte FLASH, 512KByte RAM. + @verbatim + Change Logs: + Date Author Notes + 2020-09-15 Chengy First version + @endverbatim + ******************************************************************************* + * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved. + * + * This software component is licensed by HDSC under BSD 3-Clause license + * (the "License"); You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ + +/* Use contiguous memory regions for simple. */ +MEMORY +{ + FLASH (rx): ORIGIN = 0x00000000, LENGTH = 2M + OTP (rx): ORIGIN = 0x03000000, LENGTH = 6876 + RAM (rwx): ORIGIN = 0x1FFE0000, LENGTH = 512K + RAMB (rwx): ORIGIN = 0x200F0000, LENGTH = 4K +} + +ENTRY(Reset_Handler) + +SECTIONS +{ + .vectors : + { + . = ALIGN(4); + KEEP(*(.vectors)) + . = ALIGN(4); + } >FLASH + + .icg_sec 0x00000400 : + { + KEEP(*(.icg_sec)) + } >FLASH + + .text : + { + . = ALIGN(4); + *(.text) + *(.text*) + *(.glue_7) + *(.glue_7t) + *(.eh_frame) + + KEEP(*(.init)) + KEEP(*(.fini)) + . = ALIGN(4); + } >FLASH + + .rodata : + { + . = ALIGN(4); + *(.rodata) + *(.rodata*) + . = ALIGN(4); + } >FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } >FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } >FLASH + __exidx_end = .; + + .preinit_array : + { + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array : + { + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array : + { + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + __etext = ALIGN(4); + + .otp_sec : + { + KEEP(*(.otp_sec)) + } >OTP + + .otp_lock_sec 0x03001800 : + { + KEEP(*(.otp_lock_sec)) + } >OTP + + .data : AT (__etext) + { + . = ALIGN(4); + __data_start__ = .; + *(vtable) + *(.data) + *(.data*) + . = ALIGN(4); + *(.ramfunc) + *(.ramfunc*) + . = ALIGN(4); + __data_end__ = .; + } >RAM + + __etext_ramb = __etext + ALIGN (SIZEOF(.data), 4); + .ramb_data : AT (__etext_ramb) + { + . = ALIGN(4); + __data_start_ramb__ = .; + *(.ramb_data) + *(.ramb_data*) + . = ALIGN(4); + __data_end_ramb__ = .; + } >RAMB + + .bss : + { + . = ALIGN(4); + _sbss = .; + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + . = ALIGN(4); + _ebss = .; + __bss_end__ = _ebss; + } >RAM + + .ramb_bss : + { + . = ALIGN(4); + __bss_start_ramb__ = .; + *(.ramb_bss) + *(.ramb_bss*) + . = ALIGN(4); + __bss_end_ramb__ = .; + } >RAMB + + .heap_stack (COPY) : + { + . = ALIGN(8); + __end__ = .; + PROVIDE(end = .); + PROVIDE(_end = .); + *(.heap*) + . = ALIGN(8); + __HeapLimit = .; + + __StackLimit = .; + *(.stack*) + . = ALIGN(8); + __StackTop = .; + } >RAM + + /DISCARD/ : + { + libc.a (*) + libm.a (*) + libgcc.a (*) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } + + PROVIDE(_stack = __StackTop); + PROVIDE(_Min_Heap_Size = __HeapLimit - __HeapBase); + PROVIDE(_Min_Stack_Size = __StackTop - __StackLimit); + + __RamEnd = ORIGIN(RAM) + LENGTH(RAM); + ASSERT(__StackTop <= __RamEnd, "region RAM overflowed with stack") +} diff --git a/bsp/tae32f5300/board/linker_scripts/tae32f53xx_ac5_flash.sct b/bsp/tae32f5300/board/linker_scripts/tae32f53xx_ac5_flash.sct new file mode 100644 index 0000000000..b41d86675c --- /dev/null +++ b/bsp/tae32f5300/board/linker_scripts/tae32f53xx_ac5_flash.sct @@ -0,0 +1,127 @@ +#! armcc -E +; command above MUST be in first line (no comment above!) + +/* +;-------- <<< Use Configuration Wizard in Context Menu >>> ------------------- +*/ + +/*--------------------- Flash Configuration ---------------------------------- +; Flash Configuration +; Flash Base Address <0x0-0xFFFFFFFF:8> +; Flash Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __ROM_BASE 0x08000000 +#define __ROM_SIZE 0x00012C00 + +/*--------------------- RAMCODE Section Configuration ------------------------ +; RAMCODE Configuration +; RAMCODE in which MCU +; <3=> TAE32F5300 +; <2=> TAE32F5600 +; RAMCODE Base Address is different in different MCUs +; Unsupported if your MCU is not in the list +; RAMCODE Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMCODE_BASE 0x18000000 +#define __RAMCODE_SIZE 0x00000000 + +/*--------------------- Embedded RAMA Configuration -------------------------- +; RAMA Configuration +; RAMA Base Address <0x0-0xFFFFFFFF:8> +; RAMA Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMA_BASE 0x20000000 +#define __RAMA_SIZE 0x00004000 + +/*--------------------- Embedded RAMB Configuration -------------------------- +; RAMB Configuration +; RAMB Base Address <0x0-0xFFFFFFFF:8> +; RAMB Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMB_BASE 0x20004000 +#define __RAMB_SIZE 0x00001000 + +/*--------------------- Embedded RAMC Configuration -------------------------- +; RAMC Configuration +; RAMC Base Address <0x0-0xFFFFFFFF:8> +; RAMC Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __RAMC_BASE 0x20005000 +#define __RAMC_SIZE 0x00001000 + +/*--------------------- Stack / Heap Configuration --------------------------- +; Stack / Heap Configuration +; Stack and Heap will be placed in RAMA +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + *----------------------------------------------------------------------------*/ +#define __STACK_SIZE 0x00000400 +#define __HEAP_SIZE 0x00000000 + +/* +;------------- <<< end of configuration section >>> --------------------------- +*/ + + +/*---------------------------------------------------------------------------- + User Stack & Heap boundary definition + *----------------------------------------------------------------------------*/ +#define __STACK_TOP (__RAMA_BASE + __RAMA_SIZE) /* starts at end of RAMA */ +#define __HEAP_BASE (AlignExpr(+0, 8)) /* starts after RW_RAMA section, 8 byte aligned */ + + +/*---------------------------------------------------------------------------- + Scatter File Definitions definition + *----------------------------------------------------------------------------*/ +#define __RO_BASE __ROM_BASE +#define __RO_SIZE __ROM_SIZE + +#define __RW_CODE_BASE __RAMCODE_BASE +#define __RW_CODE_SIZE __RAMCODE_SIZE + +#define __RW_BASE (__RAMA_BASE + __RAMCODE_SIZE) +#define __RW_SIZE (__RAMA_SIZE - __RAMCODE_SIZE - __STACK_SIZE - __HEAP_SIZE) + + +LR_ROM __RO_BASE __RO_SIZE { ; load region size_region + ER_ROM __RO_BASE __RO_SIZE { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + +#if __RW_CODE_SIZE > 0 + RW_CODE __RW_CODE_BASE __RW_CODE_SIZE { + *.o (RAMCODE) + } +#endif + + RW_RAMA __RW_BASE __RW_SIZE { ; RWA data + *.o (SECTION_RAMA) + .ANY (+RW +ZI) + } + +#if __HEAP_SIZE > 0 + ARM_LIB_HEAP __HEAP_BASE EMPTY __HEAP_SIZE { ; Reserve empty region for heap + } +#endif + + ARM_LIB_STACK __STACK_TOP EMPTY -__STACK_SIZE { ; Reserve empty region for stack + } + + RW_RAMB __RAMB_BASE __RAMB_SIZE { ; RWB region + *.o (SECTION_RAMB) + } + + RW_RAMC __RAMC_BASE __RAMC_SIZE { ; RWC region + *.o (SECTION_RAMC) + } +} + diff --git a/bsp/tae32f5300/board/tae32f53xx_dbg_conf.h b/bsp/tae32f5300/board/tae32f53xx_dbg_conf.h new file mode 100644 index 0000000000..f02e6b8f97 --- /dev/null +++ b/bsp/tae32f5300/board/tae32f53xx_dbg_conf.h @@ -0,0 +1,110 @@ +/** + ****************************************************************************** + * @file tae32f53xx_dbg_conf.h + * @author MCD Application Team + * @brief Configuration for dbg + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_DBG_CONF_H_ +#define _TAE32F53XX_DBG_CONF_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* Includes ------------------------------------------------------------------*/ +#include + + +/** @addtogroup TAE32F53xx_Examples + * @{ + */ + +/** @addtogroup TAE32F53xx_Template + * @{ + */ + + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/** @defgroup TAE32F53xx_Debug_Conf_Exported_Constants TAE32F53xx Debug Conf Exported Constants + * @brief TAE32F53xx Debug Conf Exported Constants + * @{ + */ + +/** + * @brief Define TAE_USING_DBG to enable dbg + */ +#define TAE_USING_DBG + +/** + * @brief Define TAE_USING_DBG_COLOR to enable dbg color mode + */ +//#define TAE_USING_DBG_COLOR + +/** + * @} + */ + + +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup TAE32F53xx_Debug_Conf_Exported_Macros TAE32F53xx Debug Conf Exported Macros + * @brief TAE32F53xx Debug Conf Exported Macros + * @{ + */ + +/** + * @brief Define your own print interface here + */ +#ifdef TAE_USING_DBG +#define TAE_DBG_PRINT(fmt, ...) printf(fmt, ##__VA_ARGS__) +#else +#define TAE_DBG_PRINT(fmt, ...) +#endif + +/** + * @} + */ + + +/* Exported functions --------------------------------------------------------*/ +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_DBG_CONF_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/board/tae32f53xx_ll_conf.h b/bsp/tae32f5300/board/tae32f53xx_ll_conf.h new file mode 100644 index 0000000000..2453f74d44 --- /dev/null +++ b/bsp/tae32f5300/board/tae32f53xx_ll_conf.h @@ -0,0 +1,305 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_conf.h + * @author MCD Application Team + * @brief LL configuration file. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _TAE32F53XX_LL_CONF_H_ +#define _TAE32F53XX_LL_CONF_H_ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** @addtogroup TAE32F53xx_Examples + * @{ + */ + +/** @addtogroup TAE32F53xx_Template + * @{ + */ + + +/* Exported constants --------------------------------------------------------*/ +/** @defgroup CONFIG_LL_Exported_Constants CONFIG LL Exported Constants + * @brief CONFIG LL Exported Constants + * @{ + */ + +/** @defgroup CONFIG_LL_Module_Selection CONFIG LL Module Selection + * @brief CONFIG LL Module Selection + * @note This is the list of modules to be used in the LL driver + * @{ + */ + +/* Internal Class Peripheral */ +#define LL_MODULE_ENABLED /*!< LL Module Enable */ +#define LL_CORTEX_MODULE_ENABLED /*!< Cortex Module Enable */ +#define LL_FPLL_MODULE_ENABLED /*!< FPLL Module Enable */ +#define LL_LVD_MODULE_ENABLED /*!< LVD Module Enable */ +#define LL_DMA_MODULE_ENABLED /*!< DMA Module Enable */ +#define LL_FLASH_MODULE_ENABLED /*!< FLASH Module Enable */ +#define LL_DFLASH_MODULE_ENABLED /*!< DFLASH Module Enable */ +#define LL_WWDG_MODULE_ENABLED /*!< WWDG Module Enable */ +#define LL_IWDG_MODULE_ENABLED /*!< IWDG Module Enable */ +#define LL_TMR_MODULE_ENABLED /*!< TMR Module Enable */ +#define LL_IIR_MODULE_ENABLED /*!< IIR Module Enable */ + +/* Interface Class Peripheral */ +#define LL_GPIO_MODULE_ENABLED /*!< GPIO Module Enable */ +#define LL_UART_MODULE_ENABLED /*!< UART Module Enable */ +#define LL_I2C_MODULE_ENABLED /*!< I2C Module Enable */ +#define LL_CAN_MODULE_ENABLED /*!< CAN Module Enable */ +#define LL_DALI_MODULE_ENABLED /*!< DALI Module Enable */ +#define LL_USB_MODULE_ENABLED /*!< USB Module Enable */ + +/* Analog Class Peripheral */ +#define LL_ADC_MODULE_ENABLED /*!< ADC Module Enable */ +#define LL_DAC_MODULE_ENABLED /*!< DAC Module Enable */ +#define LL_CMP_MODULE_ENABLED /*!< CMP Module Enable */ +#define LL_ECU_MODULE_ENABLED /*!< ECU Module Enable */ +#define LL_HRPWM_MODULE_ENABLED /*!< HRPWM Module Enable */ + +/** + * @} + */ + + +/** @defgroup CONFIG_LL_Oscillator_Values_Adaptation CONFIG LL Oscillator Values Adaptation + * @brief CONFIG LL Oscillator Values Adaptation + * @{ + */ + +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the FPLL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the FPLL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) +#define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ +#endif + +/** + * @brief Internal Low Speed oscillator (LSI) value. + * Defines the value of the Internal Low Speed oscillator in Hz. + * @note The real value may vary depending on the variations in voltage and temperature. + */ +#if !defined (LSI_VALUE) +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif + +/** + * @} + */ + + +/** @defgroup CONFIG_LL_System_Configuration CONFIG LL System Configuration + * @brief CONFIG LL System Configuration + * @note This is the LL system configuration section + * @{ + */ + +#define TICK_INT_PRIORITY 0x07U /*!< tick interrupt priority, set to lowest */ +#define USE_RTOS 0U /*!< Support for RTOS (Unsupported in current version) */ +#define PREFETCH_ENABLE 1U /*!< Flash prefetch feature */ + +/** + * @} + */ + +/** + * @} + */ + + +/* Includes ------------------------------------------------------------------*/ +#include "stdbool.h" +#include "tae32f53xx_ll_sysctrl.h" + + +/* Internal Class Peripheral */ +#ifdef LL_CORTEX_MODULE_ENABLED +#include "tae32f53xx_ll_cortex.h" +#endif + +#ifdef LL_FPLL_MODULE_ENABLED +#include "tae32f53xx_ll_fpll.h" +#endif + +#ifdef LL_LVD_MODULE_ENABLED +#include "tae32f53xx_ll_lvdctrl.h" +#endif + +#ifdef LL_DMA_MODULE_ENABLED +#include "tae32f53xx_ll_dma.h" +#endif + +#ifdef LL_FLASH_MODULE_ENABLED +#include "tae32f53xx_ll_flash.h" +#endif + +#ifdef LL_DFLASH_MODULE_ENABLED +#include "tae32f53xx_ll_dflash.h" +#endif + +#ifdef LL_WWDG_MODULE_ENABLED +#include "tae32f53xx_ll_wwdg.h" +#endif + +#ifdef LL_IWDG_MODULE_ENABLED +#include "tae32f53xx_ll_iwdg.h" +#endif + +#ifdef LL_TMR_MODULE_ENABLED +#include "tae32f53xx_ll_tmr.h" +#endif + +#ifdef LL_IIR_MODULE_ENABLED +#include "tae32f53xx_ll_iir.h" +#endif + + +/* Interface Class Peripheral */ +#ifdef LL_GPIO_MODULE_ENABLED +#include "tae32f53xx_ll_gpio.h" +#endif + +#ifdef LL_UART_MODULE_ENABLED +#include "tae32f53xx_ll_uart.h" +#endif + +#ifdef LL_I2C_MODULE_ENABLED +#include "tae32f53xx_ll_i2c.h" +#endif + +#ifdef LL_CAN_MODULE_ENABLED +#include "tae32f53xx_ll_can.h" +#endif + +#ifdef LL_DALI_MODULE_ENABLED +#include "tae32f53xx_ll_dali.h" +#endif + +#ifdef LL_USB_MODULE_ENABLED +#include "tae32f53xx_ll_usb.h" +#endif + + +/* Analog Class Peripheral */ +#ifdef LL_ADC_MODULE_ENABLED +#include "tae32f53xx_ll_adc.h" +#endif + +#ifdef LL_DAC_MODULE_ENABLED +#include "tae32f53xx_ll_dac.h" +#endif + +#ifdef LL_CMP_MODULE_ENABLED +#include "tae32f53xx_ll_cmp.h" +#endif + +#ifdef LL_ECU_MODULE_ENABLED +#include "tae32f53xx_ll_ecu.h" +#endif + +#ifdef LL_HRPWM_MODULE_ENABLED +#include "tae32f53xx_ll_hrpwm.h" +#endif + + +/* Exported types ------------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +/** @defgroup CONFIG_LL_Exported_Macros CONFIG LL Exported Macros + * @brief CONFIG LL Exported Macros + * @{ + */ + +/** @defgroup CONFIG_LL_Assert_Selection CONFIG LL Assert Selection + * @brief CONFIG LL Assert Selection + * @{ + */ + +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the LL drivers code + */ +//#define USE_FULL_ASSERT + + +#ifdef USE_FULL_ASSERT + +void assert_failed(uint8_t *file, uint32_t line); + +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +/** + * @} + */ + +/** + * @} + */ + + +/* Exported functions ------------------------------------------------------- */ +/* Private types -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private constants ---------------------------------------------------------*/ +/* Private macros ------------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ + + +/** + * @} + */ + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _TAE32F53XX_LL_CONF_H_ */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/board/tae32f53xx_ll_msp.c b/bsp/tae32f5300/board/tae32f53xx_ll_msp.c new file mode 100644 index 0000000000..2e5ffea7d1 --- /dev/null +++ b/bsp/tae32f5300/board/tae32f53xx_ll_msp.c @@ -0,0 +1,266 @@ +/** + ****************************************************************************** + * @file tae32f53xx_ll_msp.c + * @author MCD Application Team + * @brief LL MSP module. + * + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 Tai-Action. + * All rights reserved.

+ * + * This software is licensed by Tai-Action under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Includes ------------------------------------------------------------------*/ +#include "main.h" + + +#define DBG_TAG "MSP LL" +#define DBG_LVL DBG_ERROR +#include "dbg/tae32f53xx_dbg.h" + + +/** @addtogroup TAE32F53xx_Examples + * @{ + */ + +/** @addtogroup TAE32F53xx_UART_TxPolling_RxIT_Example + * @{ + */ + + +/* Private typedef -----------------------------------------------------------*/ +/* Private define ------------------------------------------------------------*/ +/* Private macro -------------------------------------------------------------*/ +/* Private variables ---------------------------------------------------------*/ +/* Private function prototypes -----------------------------------------------*/ +/* Exported functions --------------------------------------------------------*/ +/* Private functions ---------------------------------------------------------*/ +/** @defgroup UART_TxPolling_RxIT_MSP_LL_Private_Functions UART_TxPolling_RxIT MSP LL Private Functions + * @brief UART_TxPolling_RxIT MSP LL Private Functions + * @{ + */ + +/** + * @brief Initializes the Global MSP. + * @param None + * @retval None + */ +void LL_MspInit(void) +{ + //SYSCTRL PMU Config + LL_SYSCTRL_PMUCfg(); + +#ifdef LL_GPIO_MODULE_ENABLED + //GPIO Msp Init + LL_SYSCTRL_GPIOA_ClkEnRstRelease(); + LL_SYSCTRL_GPIOB_ClkEnRstRelease(); + LL_SYSCTRL_GPIOC_ClkEnRstRelease(); + LL_SYSCTRL_GPIOD_ClkEnRstRelease(); +#endif + +#ifdef LL_DMA_MODULE_ENABLED + //DMA Msp Init + LL_SYSCTRL_DMA_ClkEnRstRelease(); + + //NVIC DMA Interrupt Enable + LL_NVIC_EnableIRQ(DMA_IRQn); +#endif +} + +/** + * @brief DeInitializes the Global MSP. + * @param None + * @retval None + */ +void LL_MspDeInit(void) +{ +#ifdef LL_GPIO_MODULE_ENABLED + //GPIO Msp DeInit + LL_SYSCTRL_GPIOA_ClkDisRstAssert(); + LL_SYSCTRL_GPIOB_ClkDisRstAssert(); + LL_SYSCTRL_GPIOC_ClkDisRstAssert(); + LL_SYSCTRL_GPIOD_ClkDisRstAssert(); +#endif + +#ifdef LL_DMA_MODULE_ENABLED + //DMA Msp DeInit + LL_SYSCTRL_DMA_ClkDisRstAssert(); + + //NVIC DMA Interrupt Disable + LL_NVIC_DisableIRQ(DMA_IRQn); +#endif +} + +/** + * @brief Initializes the FPLL MSP. + * @param Instance Specifies FPLL peripheral + * @retval None + */ +void LL_FPLL_MspInit(FPLL_TypeDef *Instance) +{ + //Check FPLL Instance to be Valid + if (!IS_FPLL_ALL_INSTANCE(Instance)) + { + return; + } + + //FPLL Soft Reset Release + if (Instance == FPLL0) + { + LL_SYSCTRL_FPLL0_RstRelease(); + } + else if (Instance == FPLL1) + { + LL_SYSCTRL_FPLL1_RstRelease(); + } + else if (Instance == FPLL2) + { + LL_SYSCTRL_FPLL2_RstRelease(); + } +} + +/** + * @brief DeInitializes the FPLL MSP. + * @param Instance Specifies FPLL peripheral + * @retval None + */ +void LL_FPLL_MspDeInit(FPLL_TypeDef *Instance) +{ + //Check FPLL Instance to be Valid + if (!IS_FPLL_ALL_INSTANCE(Instance)) + { + return; + } + + //FPLL Soft Reset Assert + if (Instance == FPLL0) + { + LL_SYSCTRL_FPLL0_RstAssert(); + } + else if (Instance == FPLL1) + { + LL_SYSCTRL_FPLL1_RstAssert(); + } + else if (Instance == FPLL2) + { + LL_SYSCTRL_FPLL2_RstAssert(); + } +} + +/** + * @brief Initializes the UART MSP. + * @param Instance Specifies UART peripheral + * @retval None + */ +void LL_UART_MspInit(UART_TypeDef *Instance) +{ + GPIO_InitTypeDef UART_GPIO_Init; + + //Check UART Instance to be Valid + if (!IS_UART_ALL_INSTANCE(Instance)) + { + return; + } + + if (Instance == UART0) + { + //UART0 Pinmux Config: PA10 & PA11 + UART_GPIO_Init.Pin = GPIO_PIN_7; + UART_GPIO_Init.Mode = GPIO_MODE_AF; + UART_GPIO_Init.Alternate = GPIO_AF10_UART0; + LL_GPIO_Init(GPIOC, &UART_GPIO_Init); + + UART_GPIO_Init.Pin = GPIO_PIN_10 | GPIO_PIN_11; + UART_GPIO_Init.Mode = GPIO_MODE_AF; + UART_GPIO_Init.OType = GPIO_OTYPE_PP; + UART_GPIO_Init.Pull = GPIO_NOPULL; + UART_GPIO_Init.Speed = GPIO_SPEED_FREQ_LOW; + UART_GPIO_Init.Alternate = GPIO_AF10_UART0; + LL_GPIO_Init(GPIOA, &UART_GPIO_Init); + + //UART0 Bus Clock Enable and Soft Reset Release + LL_SYSCTRL_UART0_ClkEnRstRelease(); + + //NVIC UART0 Interrupt Enable + LL_NVIC_EnableIRQ(UART0_IRQn); + } + else if (Instance == UART1) + { + //UART1 Pinmux Config: PB8 & PB9 + UART_GPIO_Init.Pin = GPIO_PIN_8 | GPIO_PIN_9; + UART_GPIO_Init.Mode = GPIO_MODE_AF; + UART_GPIO_Init.OType = GPIO_OTYPE_PP; + UART_GPIO_Init.Pull = GPIO_NOPULL; + UART_GPIO_Init.Speed = GPIO_SPEED_FREQ_LOW; + UART_GPIO_Init.Alternate = GPIO_AF10_UART1; + LL_GPIO_Init(GPIOB, &UART_GPIO_Init); + + //UART1 Bus Clock Enable and Soft Reset Release + LL_SYSCTRL_UART1_ClkEnRstRelease(); + + //NVIC UART1 Interrupt Enable + LL_NVIC_EnableIRQ(UART1_IRQn); + } +} + +/** + * @brief DeInitializes the UART MSP. + * @param Instance Specifies UART peripheral + * @retval None + */ +void LL_UART_MspDeInit(UART_TypeDef *Instance) +{ + //Check UART Instance to be Valid + if (!IS_UART_ALL_INSTANCE(Instance)) + { + return; + } + + if (Instance == UART0) + { + //NVIC UART0 Interrupt Disable + LL_NVIC_DisableIRQ(UART0_IRQn); + + //UART0 Bus Clock Disable and Soft Reset Assert + LL_SYSCTRL_UART0_ClkDisRstAssert(); + + //UART0 Pinmux DeInit + LL_GPIO_DeInit(GPIOA, GPIO_PIN_10 | GPIO_PIN_11); + } + else if (Instance == UART1) + { + //NVIC UART1 Interrupt Disable + LL_NVIC_DisableIRQ(UART1_IRQn); + + //UART1 Bus Clock Disable and Soft Reset Assert + LL_SYSCTRL_UART1_ClkDisRstAssert(); + + //UART1 Pinmux DeInit + LL_GPIO_DeInit(GPIOB, GPIO_PIN_8 | GPIO_PIN_9); + } +} + +/** + * @} + */ + + +/** + * @} + */ + +/** + * @} + */ + + +/************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/ + diff --git a/bsp/tae32f5300/drivers/Kconfig b/bsp/tae32f5300/drivers/Kconfig new file mode 100644 index 0000000000..46e8ed25ec --- /dev/null +++ b/bsp/tae32f5300/drivers/Kconfig @@ -0,0 +1,285 @@ +menu "Hardware Drivers Config" + +config MCU_TAE32F53xx + bool + select ARCH_ARM_CORTEX_M3 + select RT_USING_COMPONENTS_INIT + select RT_USING_USER_MAIN + default y + +menu "Onboard Peripheral Drivers" + +endmenu + +menu "On-chip Peripheral Drivers" + config BSP_USING_GPIO + bool "Enable GPIO" + select RT_USING_PIN + default y + + 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 y + + config BSP_UART0_RX_USING_DMA + bool "Enable UART0 RX DMA" + depends on BSP_USING_UART0 && RT_SERIAL_USING_DMA + default n + + config BSP_UART0_TX_USING_DMA + bool "Enable UART0 TX DMA" + depends on BSP_USING_UART0 && RT_SERIAL_USING_DMA + default n + + config BSP_USING_UART1 + bool "Enable UART1" + default n + + config BSP_UART1_RX_USING_DMA + bool "Enable UART1 RX DMA" + depends on BSP_USING_UART1 && RT_SERIAL_USING_DMA + default n + + config BSP_UART1_TX_USING_DMA + bool "Enable UART1 TX DMA" + depends on BSP_USING_UART1 && RT_SERIAL_USING_DMA + default n + endif + + menuconfig BSP_USING_I2C1 + bool "Enable I2C1 BUS (software simulation)" + default y + select RT_USING_I2C + select RT_USING_I2C_BITOPS + select RT_USING_PIN + if BSP_USING_I2C1 + config BSP_I2C1_SCL_PIN + int "i2c1 scl pin number" + range 1 176 + default 51 + config BSP_I2C1_SDA_PIN + int "I2C1 sda pin number" + range 1 176 + default 90 + endif + + menuconfig BSP_USING_SPI + bool "Enable SPI BUS" + default n + select RT_USING_SPI + if BSP_USING_SPI + config BSP_USING_SPI1 + bool "Enable SPI1 BUS" + default n + + config BSP_SPI1_TX_USING_DMA + bool "Enable SPI1 TX DMA" + depends on BSP_USING_SPI1 + default n + + config BSP_SPI1_RX_USING_DMA + bool "Enable SPI1 RX DMA" + depends on BSP_USING_SPI1 + select BSP_SPI1_TX_USING_DMA + default n + + config BSP_USING_SPI2 + bool "Enable SPI2 BUS" + default n + + config BSP_SPI2_TX_USING_DMA + bool "Enable SPI2 TX DMA" + depends on BSP_USING_SPI2 + default n + + config BSP_SPI2_RX_USING_DMA + bool "Enable SPI2 RX DMA" + depends on BSP_USING_SPI2 + select BSP_SPI2_TX_USING_DMA + default n + + config BSP_USING_SPI3 + bool "Enable SPI3 BUS" + default n + + config BSP_SPI3_TX_USING_DMA + bool "Enable SPI3 TX DMA" + depends on BSP_USING_SPI3 + default n + + config BSP_SPI3_RX_USING_DMA + bool "Enable SPI3 RX DMA" + depends on BSP_USING_SPI3 + select BSP_SPI3_TX_USING_DMA + default n + + config BSP_USING_SPI4 + bool "Enable SPI4 BUS" + default n + + config BSP_SPI4_TX_USING_DMA + bool "Enable SPI4 TX DMA" + depends on BSP_USING_SPI4 + default n + + config BSP_SPI4_RX_USING_DMA + bool "Enable SPI4 RX DMA" + depends on BSP_USING_SPI4 + select BSP_SPI4_TX_USING_DMA + default n + + config BSP_USING_SPI5 + bool "Enable SPI5 BUS" + default n + + config BSP_SPI5_RX_USING_DMA + bool "Enable SPI5 TX DMA" + depends on BSP_USING_SPI5 + default n + + config BSP_SPI5_RX_USING_DMA + bool "Enable SPI5 RX DMA" + depends on BSP_USING_SPI5 + select BSP_SPI5_TX_USING_DMA + default n + + config BSP_USING_SPI6 + bool "Enable SPI6 BUS" + default n + + config BSP_SPI6_TX_USING_DMA + bool "Enable SPI6 TX DMA" + depends on BSP_USING_SPI6 + default n + + config BSP_SPI6_RX_USING_DMA + bool "Enable SPI6 RX DMA" + depends on BSP_USING_SPI6 + select BSP_SPI6_TX_USING_DMA + default n + endif + + menuconfig BSP_USING_RTC + bool "Enable RTC" + select RT_USING_RTC + select RT_USING_LIBC + default n + + if BSP_USING_RTC + choice + prompt "Select clock source" + default BSP_RTC_USING_LRC + + config BSP_RTC_USING_XTAL32 + bool "RTC USING XTAL32" + + config BSP_RTC_USING_LRC + bool "RTC USING LRC" + endchoice + endif + + menuconfig BSP_USING_PWM + bool "Enable PWM" + default n + select RT_USING_PWM + if BSP_USING_PWM + menuconfig BSP_USING_PWM1 + bool "Enable timer1 output pwm" + default n + if BSP_USING_PWM1 + config BSP_USING_PWM1_CH1 + bool "Enable PWM1 channel1" + default n + + config BSP_USING_PWM1_CH2 + bool "Enable PWM1 channel2" + default n + + config BSP_USING_PWM1_CH3 + bool "Enable PWM1 channel3" + default n + + config BSP_USING_PWM1_CH4 + bool "Enable PWM1 channel4" + default n + endif + + menuconfig BSP_USING_PWM2 + bool "Enable timer2 output pwm" + default n + if BSP_USING_PWM2 + config BSP_USING_PWM2_CH1 + bool "Enable PWM2 channel1" + default n + + config BSP_USING_PWM2_CH2 + bool "Enable PWM2 channel2" + default n + + config BSP_USING_PWM2_CH3 + bool "Enable PWM2 channel3" + default n + + config BSP_USING_PWM2_CH4 + bool "Enable PWM2 channel4" + default n + endif + endif + + menuconfig BSP_USING_TIMER + bool "Enable TIMER" + default n + select RT_USING_HWTIMER + if BSP_USING_TIMER + config BSP_USING_TIMER5 + bool "Enable TIMER5" + default n + + config BSP_USING_TIMER6 + bool "Enable TIMER6" + default n + + config BSP_USING_TIMER7 + bool "Enable TIMER7" + default n + + config BSP_USING_TIMER8 + bool "Enable TIMER8" + default n + endif + + menuconfig BSP_USING_PULSE_ENCODER + bool "Enable Pulse Encoder" + default n + select RT_USING_PULSE_ENCODER + if BSP_USING_PULSE_ENCODER + config BSP_USING_PULSE_ENCODER9 + bool "Enable Pulse Encoder9" + default n + + config BSP_USING_PULSE_ENCODER10 + bool "Enable Pulse Encoder10" + default n + + config BSP_USING_PULSE_ENCODER11 + bool "Enable Pulse Encoder11" + default n + + config BSP_USING_PULSE_ENCODER12 + bool "Enable Pulse Encoder12" + default n + endif + +endmenu + +menu "Board extended module Drivers" + +endmenu + +endmenu + diff --git a/bsp/tae32f5300/drivers/SConscript b/bsp/tae32f5300/drivers/SConscript new file mode 100644 index 0000000000..444957d70f --- /dev/null +++ b/bsp/tae32f5300/drivers/SConscript @@ -0,0 +1,23 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() + +# add the general drivers. +src = Split(""" +""") + +# add serial driver code +if GetDepend('BSP_USING_UART') or GetDepend('BSP_USING_UART1'): + src += ['drv_uart.c'] + +# add gpio driver code +if GetDepend(['BSP_USING_GPIO']): + src += ['drv_gpio.c'] + +CPPPATH = [cwd] + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/tae32f5300/drivers/drv_gpio.c b/bsp/tae32f5300/drivers/drv_gpio.c new file mode 100644 index 0000000000..67a6549cb0 --- /dev/null +++ b/bsp/tae32f5300/drivers/drv_gpio.c @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-05 qinweizhong first version + */ +#include +#include +#include +#include +#include +#include "drv_gpio.h" + +#define TAE32_PIN(index, gpio, gpio_index) \ +{ \ + 0, GPIO##gpio, GPIO_PIN_##gpio_index \ +} + +#define TAE32_PIN_DEFAULT \ +{ \ + -1, 0, 0 \ +} + +/* TAE32 GPIO driver */ +struct pin_index +{ + int index; + GPIO_TypeDef *gpio; + uint32_t pin; +}; + +static const struct pin_index _pin_map[] = +{ + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, + TAE32_PIN(2, C, 13), + TAE32_PIN(3, C, 14), + TAE32_PIN(4, C, 15), + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, + TAE32_PIN(10, A, 0), + TAE32_PIN(11, A, 1), + TAE32_PIN(12, A, 2), + TAE32_PIN(13, A, 3), + TAE32_PIN(14, A, 4), + TAE32_PIN(15, A, 5), + TAE32_PIN(16, A, 6), + TAE32_PIN(17, A, 7), + TAE32_PIN(18, B, 0), + TAE32_PIN(19, B, 1), + TAE32_PIN(20, B, 2), + TAE32_PIN(21, B, 10), + TAE32_PIN(22, B, 11), + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, + TAE32_PIN(25, B, 12), + TAE32_PIN(26, B, 13), + TAE32_PIN(27, B, 14), + TAE32_PIN(28, B, 15), + TAE32_PIN(29, A, 8), + TAE32_PIN(30, A, 9), + TAE32_PIN(31, A, 10), + TAE32_PIN(32, A, 11), + TAE32_PIN(33, A, 12), + TAE32_PIN(34, A, 13), + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, + TAE32_PIN(37, A, 14), + TAE32_PIN(38, A, 15), + TAE32_PIN(39, B, 3), + TAE32_PIN(40, B, 4), + TAE32_PIN(41, B, 5), + TAE32_PIN(42, B, 6), + TAE32_PIN(43, B, 7), + TAE32_PIN_DEFAULT, + TAE32_PIN(45, B, 8), + TAE32_PIN(46, B, 9), + TAE32_PIN_DEFAULT, + TAE32_PIN_DEFAULT, +}; + +#define ITEM_NUM(items) sizeof(items) / sizeof(items[0]) + +const struct pin_index *get_pin(uint8_t pin) +{ + const struct pin_index *index; + + if (pin < ITEM_NUM(_pin_map)) + { + index = &_pin_map[pin]; + if (index->gpio == 0) + index = RT_NULL; + } + else + { + index = RT_NULL; + } + return index; +}; + +void _pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value) +{ + const struct pin_index *index; + + index = get_pin(pin); + if (index == RT_NULL) + { + return; + } + if (value == PIN_LOW) + { + LL_GPIO_WritePin(index->gpio, index->pin, GPIO_PIN_RESET); + } + else + { + LL_GPIO_WritePin(index->gpio, index->pin, GPIO_PIN_SET); + } +} + +int _pin_read(rt_device_t dev, rt_base_t pin) +{ + int value; + const struct pin_index *index; + + value = PIN_LOW; + index = get_pin(pin); + if (index == RT_NULL) + { + return PIN_LOW; + } + if (LL_GPIO_ReadPin(index->gpio, index->pin) == GPIO_PIN_RESET) + { + value = PIN_LOW; + } + else + { + value = PIN_HIGH; + } + return value; +} + +void _pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode) +{ + const struct pin_index *index; + GPIO_InitTypeDef GPIO_InitStructure; + + index = get_pin(pin); + if (index == RT_NULL) + { + return; + } + /* Configure GPIO_InitStructure */ + GPIO_InitStructure.Pin = index->pin; + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT; + GPIO_InitStructure.OType = GPIO_OTYPE_PP; + GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW; + if (mode == PIN_MODE_OUTPUT) + { + /* output setting */ + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT; + GPIO_InitStructure.OType = GPIO_OTYPE_PP; + } + else if (mode == PIN_MODE_OUTPUT_OD) + { + /* output setting: od. */ + GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT; + GPIO_InitStructure.OType = GPIO_OTYPE_OD; + } + else if (mode == PIN_MODE_INPUT) + { + /* input setting: not pull. */ + GPIO_InitStructure.Mode = GPIO_MODE_INPUT; + } + else if (mode == PIN_MODE_INPUT_PULLUP) + { + /* input setting: pull up. */ + GPIO_InitStructure.Pull = GPIO_PULLUP; + GPIO_InitStructure.Mode = GPIO_MODE_INPUT; + } + else + { + /* input setting:default. */ + GPIO_InitStructure.Pull = GPIO_PULLDOWN; + GPIO_InitStructure.Mode = GPIO_MODE_INPUT; + } + LL_GPIO_Init(index->gpio, &GPIO_InitStructure); +} + +rt_err_t _pin_attach_irq(struct rt_device *device, rt_int32_t pin, + rt_uint32_t mode, void (*hdr)(void *args), void *args) +{ + return -RT_ERROR; +} + +rt_err_t _pin_detach_irq(struct rt_device *device, rt_int32_t pin) +{ + return -RT_ERROR; +} + +rt_err_t _pin_irq_enable(struct rt_device *device, rt_base_t pin, + rt_uint32_t enabled) +{ + return -RT_ERROR; +} + +const static struct rt_pin_ops _pin_ops = +{ + _pin_mode, + _pin_write, + _pin_read, + _pin_attach_irq, + _pin_detach_irq, + _pin_irq_enable, + RT_NULL, +}; + +int rt_hw_pin_init(void) +{ + int result; + + result = rt_device_pin_register("pin", &_pin_ops, RT_NULL); + return result; +} +INIT_BOARD_EXPORT(rt_hw_pin_init); diff --git a/bsp/tae32f5300/drivers/drv_gpio.h b/bsp/tae32f5300/drivers/drv_gpio.h new file mode 100644 index 0000000000..ef6bd1d00d --- /dev/null +++ b/bsp/tae32f5300/drivers/drv_gpio.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-05 qinweizhong first version + */ + +#ifndef __DRV_GPIO_H__ +#define __DRV_GPIO_H__ + +int rt_hw_pin_init(void); + +#endif diff --git a/bsp/tae32f5300/drivers/drv_uart.c b/bsp/tae32f5300/drivers/drv_uart.c new file mode 100644 index 0000000000..0987ac74ac --- /dev/null +++ b/bsp/tae32f5300/drivers/drv_uart.c @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-05 qinweizhong first version + */ +#include +#include "drv_uart.h" +#include "tae32f53xx_ll.h" +#include +#include "drv_uart.h" + +/* uart driver */ +struct tae32_uart +{ + UART_TypeDef *uart; + IRQn_Type irq; +}; + +static void uart_init(void) +{ + UART_InitTypeDef uart_init; + uart_init.baudrate = 115200; + uart_init.dat_len = UART_DAT_LEN_8b; + uart_init.stop_len = UART_STOP_LEN_1b; + uart_init.parity = UART_PARITY_NO; + uart_init.tx_tl = UART_TX_EMPTY_TRI_LVL_EMPTY; + uart_init.rx_tl = UART_RX_AVL_TRI_LVL_1CHAR; + LL_UART_Init(UART0, &uart_init); + + __LL_UART_RxDatAvl_INT_En(UART0); +} + +static rt_err_t _uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg) +{ + struct tae32_uart *uart; + UART_InitTypeDef UART_InitStructure; + RT_ASSERT(serial != RT_NULL); + RT_ASSERT(cfg != RT_NULL); + uart = (struct tae32_uart *)serial->parent.user_data; + UART_InitStructure.baudrate = cfg->baud_rate; + if (cfg->data_bits == DATA_BITS_8) + UART_InitStructure.dat_len = UART_DAT_LEN_8b; + if (cfg->stop_bits == STOP_BITS_1) + UART_InitStructure.stop_len = UART_STOP_LEN_1b; + else if (cfg->stop_bits == STOP_BITS_2) + UART_InitStructure.stop_len = UART_STOP_LEN_2b; + UART_InitStructure.parity = UART_PARITY_NO; + UART_InitStructure.tx_tl = UART_TX_EMPTY_TRI_LVL_EMPTY; + UART_InitStructure.rx_tl = UART_RX_AVL_TRI_LVL_1CHAR; + LL_UART_Init(uart->uart, &UART_InitStructure); + + return RT_EOK; +} + +static rt_err_t _uart_control(struct rt_serial_device *serial, int cmd, void *arg) +{ + struct tae32_uart *uart; + RT_ASSERT(serial != RT_NULL); + uart = (struct tae32_uart *)serial->parent.user_data; + switch (cmd) + { + case RT_DEVICE_CTRL_CLR_INT: + /* disable rx irq */ + NVIC_DisableIRQ(uart->irq); + __LL_UART_RxDatAvl_INT_Dis(uart->uart); + break; + case RT_DEVICE_CTRL_SET_INT: + /* enable rx irq */ + NVIC_EnableIRQ(uart->irq); + /* enable interrupt */ + __LL_UART_RxDatAvl_INT_En(uart->uart); + break; + } + return RT_EOK; +} + +static int _uart_putc(struct rt_serial_device *serial, char c) +{ + struct tae32_uart *uart; + RT_ASSERT(serial != RT_NULL); + uart = (struct tae32_uart *)serial->parent.user_data; + while (!__LL_UART_IsTxFIFONotFull(uart->uart)) {}; + __LL_UART_TxBuf9bits_Write(uart->uart, (uint16_t)c); + return 1; +} + +static int _uart_getc(struct rt_serial_device *serial) +{ + int ch; + struct tae32_uart *uart; + RT_ASSERT(serial != RT_NULL); + uart = (struct tae32_uart *)serial->parent.user_data; + ch = -1; + if (__LL_UART_IsDatReady(uart->uart)) + { + ch = __LL_UART_RxBuf9bits_Read(uart->uart); + } + else + { + rt_thread_mdelay(10); + } + return ch; +} + +static const struct rt_uart_ops _uart_ops = +{ + _uart_configure, + _uart_control, + _uart_putc, + _uart_getc, +}; + +#if defined(BSP_USING_UART0) +/* UART0 device driver structure */ +static struct tae32_uart uart0; +struct rt_serial_device serial0; +void UART0_IRQHandler(void) +{ + struct tae32_uart *uart; + uart = &uart0; + /* enter interrupt */ + rt_interrupt_enter(); + if (__LL_UART_INT_ID_Get(uart->uart) == UART_INT_ID_RX_AVL) + { + rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND); + } + if (__LL_UART_INT_ID_Get(uart->uart) != UART_INT_ID_RX_AVL) + { + /* clear interrupt */ + } + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif /* BSP_USING_UART1 */ + +#if defined(BSP_USING_UART1) +/* UART2 device driver structure */ +static struct tae32_uart uart1; +struct rt_serial_device serial1; +void UART1_IRQHandler(void) +{ + struct tae32_uart *uart; + uart = &uart1; + /* enter interrupt */ + rt_interrupt_enter(); + if (__LL_UART_INT_ID_Get(uart->uart) == UART_INT_ID_RX_AVL) + { + rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND); + } + if (__LL_UART_INT_ID_Get(uart->uart) != UART_INT_ID_RX_AVL) + { + /* clear interrupt */ + } + /* leave interrupt */ + rt_interrupt_leave(); +} +#endif /* BSP_USING_UART1 */ + +int rt_hw_uart_init(void) +{ + struct tae32_uart *uart; + struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; +#ifdef BSP_USING_UART0 + uart = &uart0; + uart->uart = UART0; + uart->irq = UART0_IRQn; + config.baud_rate = BAUD_RATE_115200; + serial0.ops = &_uart_ops; + serial0.config = config; + uart_init(); + + /* register UART1 device */ + rt_hw_serial_register(&serial0, "uart0", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, + uart); +#endif /* BSP_USING_UART0 */ + +#ifdef BSP_USING_UART1 + uart = &uart1; + uart->uart = UART1; + uart->irq = UART1_IRQn; + config.baud_rate = BAUD_RATE_115200; + serial2.ops = &_uart_ops; + serial2.config = config; + /* register UART1 device */ + rt_hw_serial_register(&serial1, "uart1", + RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, + uart); +#endif /* BSP_USING_UART1 */ + return 0; +} +INIT_BOARD_EXPORT(rt_hw_uart_init); diff --git a/bsp/tae32f5300/drivers/drv_uart.h b/bsp/tae32f5300/drivers/drv_uart.h new file mode 100644 index 0000000000..1b83fb1a55 --- /dev/null +++ b/bsp/tae32f5300/drivers/drv_uart.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2006-2021, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-09-05 qinweizhong first version + */ + +#ifndef __DRV_UART_H__ +#define __DRV_UART_H__ + +int rt_hw_uart_init(void); + +#endif diff --git a/bsp/tae32f5300/figures/TAE32_EVBorad.png b/bsp/tae32f5300/figures/TAE32_EVBorad.png new file mode 100644 index 0000000000..09896cd26f Binary files /dev/null and b/bsp/tae32f5300/figures/TAE32_EVBorad.png differ diff --git a/bsp/tae32f5300/rtconfig.h b/bsp/tae32f5300/rtconfig.h new file mode 100644 index 0000000000..c6a9bf37a3 --- /dev/null +++ b/bsp/tae32f5300/rtconfig.h @@ -0,0 +1,191 @@ +#ifndef RT_CONFIG_H__ +#define RT_CONFIG_H__ + +/* Automatically generated file; DO NOT EDIT. */ +/* RT-Thread Project Configuration */ + +/* RT-Thread Kernel */ + +#define RT_NAME_MAX 8 +#define RT_ALIGN_SIZE 4 +#define RT_THREAD_PRIORITY_32 +#define RT_THREAD_PRIORITY_MAX 32 +#define RT_TICK_PER_SECOND 100 +#define RT_USING_OVERFLOW_CHECK +#define RT_USING_HOOK +#define RT_USING_IDLE_HOOK +#define RT_IDLE_HOOK_LIST_SIZE 4 +#define IDLE_THREAD_STACK_SIZE 256 +#define RT_USING_TIMER_SOFT +#define RT_TIMER_THREAD_PRIO 4 +#define RT_TIMER_THREAD_STACK_SIZE 512 + +/* kservice optimization */ + +#define RT_DEBUG + +/* Inter-Thread communication */ + +#define RT_USING_SEMAPHORE +#define RT_USING_MUTEX +#define RT_USING_EVENT +#define RT_USING_MAILBOX +#define RT_USING_MESSAGEQUEUE + +/* Memory Management */ + +#define RT_USING_MEMPOOL +#define RT_USING_SMALL_MEM +#define RT_USING_HEAP + +/* Kernel Device Object */ + +#define RT_USING_DEVICE +#define RT_USING_CONSOLE +#define RT_CONSOLEBUF_SIZE 128 +#define RT_CONSOLE_DEVICE_NAME "uart0" +#define RT_VER_NUM 0x40004 +#define ARCH_ARM +#define RT_USING_CPU_FFS +#define ARCH_ARM_CORTEX_M +#define ARCH_ARM_CORTEX_M3 + +/* RT-Thread Components */ + +#define RT_USING_COMPONENTS_INIT +#define RT_USING_USER_MAIN +#define RT_MAIN_THREAD_STACK_SIZE 2048 +#define RT_MAIN_THREAD_PRIORITY 10 + +/* C++ features */ + + +/* Command shell */ + +#define RT_USING_FINSH +#define RT_USING_MSH +#define FINSH_THREAD_NAME "tshell" +#define FINSH_THREAD_PRIORITY 20 +#define FINSH_THREAD_STACK_SIZE 2048 +#define FINSH_USING_HISTORY +#define FINSH_HISTORY_LINES 5 +#define FINSH_USING_SYMTAB +#define FINSH_CMD_SIZE 80 +#define MSH_USING_BUILT_IN_COMMANDS +#define FINSH_USING_DESCRIPTION +#define FINSH_ARG_MAX 10 + +/* Device virtual file system */ + + +/* Device Drivers */ + +#define RT_USING_DEVICE_IPC +#define RT_PIPE_BUFSZ 512 +#define RT_USING_SERIAL +#define RT_USING_SERIAL_V1 +#define RT_SERIAL_RB_BUFSZ 64 +#define RT_USING_I2C +#define RT_USING_I2C_BITOPS +#define RT_USING_PIN + +/* Using USB */ + + +/* POSIX layer and C standard library */ + +#define RT_USING_LIBC +#define RT_LIBC_DEFAULT_TIMEZONE 8 + +/* Network */ + +/* Socket abstraction layer */ + + +/* Network interface device */ + + +/* light weight TCP/IP stack */ + + +/* AT commands */ + + +/* VBUS(Virtual Software BUS) */ + + +/* Utilities */ + + +/* RT-Thread Utestcases */ + + +/* RT-Thread online packages */ + +/* IoT - internet of things */ + + +/* Wi-Fi */ + +/* Marvell WiFi */ + + +/* Wiced WiFi */ + + +/* IoT Cloud */ + + +/* security packages */ + + +/* language packages */ + + +/* multimedia packages */ + + +/* tools packages */ + + +/* system packages */ + +/* acceleration: Assembly language or algorithmic acceleration packages */ + + +/* Micrium: Micrium software products porting for RT-Thread */ + + +/* peripheral libraries and drivers */ + + +/* AI packages */ + + +/* miscellaneous packages */ + +/* samples: kernel and components samples */ + + +/* entertainment: terminal games and other interesting software packages */ + + +/* Hardware Drivers Config */ + +#define MCU_TAE32F53xx + +/* Onboard Peripheral Drivers */ + +/* On-chip Peripheral Drivers */ + +#define BSP_USING_GPIO +#define BSP_USING_UART +#define BSP_USING_UART0 +#define BSP_USING_I2C1 +#define BSP_I2C1_SCL_PIN 51 +#define BSP_I2C1_SDA_PIN 90 + +/* Board extended module Drivers */ + + +#endif diff --git a/bsp/tae32f5300/rtconfig.py b/bsp/tae32f5300/rtconfig.py new file mode 100644 index 0000000000..edec213c70 --- /dev/null +++ b/bsp/tae32f5300/rtconfig.py @@ -0,0 +1,49 @@ +import os + +# toolchains options +ARCH='arm' +CPU='cortex-m3' +CROSS_TOOL='keil' + +print("############rtconfig##############") + +# cross_tool provides the cross compiler +# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR +if CROSS_TOOL == 'keil': + PLATFORM = 'armcc' + EXEC_PATH = r'D:\Keil_v5' + +if os.getenv('RTT_EXEC_PATH'): + EXEC_PATH = os.getenv('RTT_EXEC_PATH') + +BUILD = 'debug' +MCU_TYPE = 'TAE32F53xx' + +if PLATFORM == 'armcc': + # toolchains + CC = 'armcc' + AS = 'armasm' + AR = 'armar' + LINK = 'armlink' + TARGET_EXT = 'axf' + + DEVICE = ' --cpu ' + CPU + CFLAGS = '-c ' + DEVICE + ' --apcs=interwork --c99' + AFLAGS = DEVICE + ' --apcs=interwork ' + LFLAGS = DEVICE + ' --scatter "drivers/linker_scripts/tae32f53xx_ac5_sram.sct" --info sizes --info totals --info unused --info veneers --list rtthread.map --strict' + + CFLAGS += ' -I' + EXEC_PATH + '/ARM/ARMCC/INC' + LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/ARMCC/LIB' + + CFLAGS += ' -D__MICROLIB ' + AFLAGS += ' --pd "__MICROLIB SETA 1" ' + LFLAGS += ' --library_type=microlib ' + EXEC_PATH += '/arm/armcc/bin/' + + if BUILD == 'debug': + CFLAGS += ' -g -O0' + AFLAGS += ' -g' + else: + CFLAGS += ' -O2' + + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' diff --git a/bsp/tae32f5300/template.uvoptx b/bsp/tae32f5300/template.uvoptx new file mode 100644 index 0000000000..3fd1f18f54 --- /dev/null +++ b/bsp/tae32f5300/template.uvoptx @@ -0,0 +1,171 @@ + + + + 1.0 + +
### uVision Project, (C) Keil Software
+ + + *.c + *.s*; *.src; *.a* + *.obj; *.o + *.lib + *.txt; *.h; *.inc + *.plm + *.cpp + 0 + + + + 0 + 0 + + + + rtthread + 0x4 + ARM-ADS + + 12000000 + + 1 + 1 + 0 + 1 + 0 + + + 1 + 65535 + 0 + 0 + 0 + + + 79 + 66 + 8 + .\build\keil\List\ + + + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 0 + + + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + + + 0 + 0 + 1 + + 255 + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 1 + 2 + + + + + + + + + + + BIN\CMSIS_AGDI.dll + + + + 0 + CMSIS_AGDI + -X"Any" -UAny -O206 -S3 -C0 -P00 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0TAE32F53xx_75KB_sz480.FLM -FS08000000 -FL012C00 -FP0($$Device:TAE32F5300$Flash\TAE32F53xx_75KB_sz480.FLM) + + + 0 + UL2CM3 + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TAE32F53xx_75KB_sz480 -FS08000000 -FL012C00 -FP0($$Device:TAE32F5300$Flash\TAE32F53xx_75KB_sz480.FLM)) + + + + + 0 + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + 0 + 0 + 0 + + + + + + + +
diff --git a/bsp/tae32f5300/template.uvprojx b/bsp/tae32f5300/template.uvprojx new file mode 100644 index 0000000000..680ed277ae --- /dev/null +++ b/bsp/tae32f5300/template.uvprojx @@ -0,0 +1,387 @@ + + + + 2.1 + +
### uVision Project, (C) Keil Software
+ + + + rtthread + 0x4 + ARM-ADS + 5060960::V5.06 update 7 (build 960)::.\ARMCC + + + TAE32F5300 + Tai-Action + Tai-Action.TAE32F53xx_DFP.1.2.0 + https://www.keil.com/pack/ + IRAM(0x20000000,0x4000) IRAM2(0x20004000,0x1000) IRAM3(0x20005000,0x1000) IROM(0x08000000,0x12c00) IROM2(0x18000000,0x4000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0TAE32F53xx_75KB_sz480 -FS08000000 -FL012C00 -FP0($$Device:TAE32F5300$Flash\TAE32F53xx_75KB_sz480.FLM)) + 0 + + + + + + + + + + + $$Device:TAE32F5300$SVD\TAE32F53xx.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\build\keil\Obj\ + rtthread + 1 + 0 + 1 + 1 + 0 + .\build\keil\List\ + 1 + 0 + 0 + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 0 + 0 + + + 0 + 0 + 0 + 0 + + + 1 + 0 + .\AfterBuildHandler.bat $J #L + .\FLASH\AfterBuildHandler.bat $J #L + 0 + 0 + 0 + 0 + + 0 + + + + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + -REMAP -MPU + DCM.DLL + -pCM3 + SARMCM3.DLL + -MPU + TCM.DLL + -pCM3 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 1 + 4096 + + 1 + BIN\UL2CM3.DLL + + + + + + 0 + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + "Cortex-M3" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 0 + 1 + 1 + 16 + 1 + 0 + 0 + 0 + 4 + 4 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 1 + 0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 1 + 0x8000000 + 0x12c00 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x8000000 + 0x12c00 + + + 1 + 0x18000000 + 0x4000 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x4000 + + + 0 + 0x20004000 + 0x1000 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + USE_STDPERIPH_DRIVER + + + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + .\board\linker_scripts\tae32f53xx_ac5_flash.sct + + + --diag_suppress=L6314W + + + + + + + + + + + + + + +