diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_common_tables.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_common_tables.h new file mode 100644 index 0000000000000000000000000000000000000000..8742a5699153c3d67e998d300ecb9045ec1b5962 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_common_tables.h @@ -0,0 +1,136 @@ +/* ---------------------------------------------------------------------- +* Copyright (C) 2010-2014 ARM Limited. All rights reserved. +* +* $Date: 19. October 2015 +* $Revision: V.1.4.5 a +* +* Project: CMSIS DSP Library +* Title: arm_common_tables.h +* +* Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions +* +* Target Processor: Cortex-M4/Cortex-M3 +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* - Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* - Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* - Neither the name of ARM LIMITED nor the names of its contributors +* may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* -------------------------------------------------------------------- */ + +#ifndef _ARM_COMMON_TABLES_H +#define _ARM_COMMON_TABLES_H + +#include "arm_math.h" + +extern const uint16_t armBitRevTable[1024]; +extern const q15_t armRecipTableQ15[64]; +extern const q31_t armRecipTableQ31[64]; +/* extern const q31_t realCoefAQ31[1024]; */ +/* extern const q31_t realCoefBQ31[1024]; */ +extern const float32_t twiddleCoef_16[32]; +extern const float32_t twiddleCoef_32[64]; +extern const float32_t twiddleCoef_64[128]; +extern const float32_t twiddleCoef_128[256]; +extern const float32_t twiddleCoef_256[512]; +extern const float32_t twiddleCoef_512[1024]; +extern const float32_t twiddleCoef_1024[2048]; +extern const float32_t twiddleCoef_2048[4096]; +extern const float32_t twiddleCoef_4096[8192]; +#define twiddleCoef twiddleCoef_4096 +extern const q31_t twiddleCoef_16_q31[24]; +extern const q31_t twiddleCoef_32_q31[48]; +extern const q31_t twiddleCoef_64_q31[96]; +extern const q31_t twiddleCoef_128_q31[192]; +extern const q31_t twiddleCoef_256_q31[384]; +extern const q31_t twiddleCoef_512_q31[768]; +extern const q31_t twiddleCoef_1024_q31[1536]; +extern const q31_t twiddleCoef_2048_q31[3072]; +extern const q31_t twiddleCoef_4096_q31[6144]; +extern const q15_t twiddleCoef_16_q15[24]; +extern const q15_t twiddleCoef_32_q15[48]; +extern const q15_t twiddleCoef_64_q15[96]; +extern const q15_t twiddleCoef_128_q15[192]; +extern const q15_t twiddleCoef_256_q15[384]; +extern const q15_t twiddleCoef_512_q15[768]; +extern const q15_t twiddleCoef_1024_q15[1536]; +extern const q15_t twiddleCoef_2048_q15[3072]; +extern const q15_t twiddleCoef_4096_q15[6144]; +extern const float32_t twiddleCoef_rfft_32[32]; +extern const float32_t twiddleCoef_rfft_64[64]; +extern const float32_t twiddleCoef_rfft_128[128]; +extern const float32_t twiddleCoef_rfft_256[256]; +extern const float32_t twiddleCoef_rfft_512[512]; +extern const float32_t twiddleCoef_rfft_1024[1024]; +extern const float32_t twiddleCoef_rfft_2048[2048]; +extern const float32_t twiddleCoef_rfft_4096[4096]; + + +/* floating-point bit reversal tables */ +#define ARMBITREVINDEXTABLE__16_TABLE_LENGTH ((uint16_t)20 ) +#define ARMBITREVINDEXTABLE__32_TABLE_LENGTH ((uint16_t)48 ) +#define ARMBITREVINDEXTABLE__64_TABLE_LENGTH ((uint16_t)56 ) +#define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208 ) +#define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440 ) +#define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448 ) +#define ARMBITREVINDEXTABLE1024_TABLE_LENGTH ((uint16_t)1800) +#define ARMBITREVINDEXTABLE2048_TABLE_LENGTH ((uint16_t)3808) +#define ARMBITREVINDEXTABLE4096_TABLE_LENGTH ((uint16_t)4032) + +extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE__16_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE__32_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE__64_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE1024_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE2048_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE4096_TABLE_LENGTH]; + +/* fixed-point bit reversal tables */ +#define ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH ((uint16_t)12 ) +#define ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH ((uint16_t)24 ) +#define ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH ((uint16_t)56 ) +#define ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH ((uint16_t)112 ) +#define ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH ((uint16_t)240 ) +#define ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH ((uint16_t)480 ) +#define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992 ) +#define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984) +#define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032) + +extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED___16_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED___32_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED___64_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED__128_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED__256_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED__512_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH]; +extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH]; + +/* Tables for Fast Math Sine and Cosine */ +extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1]; +extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1]; +extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1]; + +#endif /* ARM_COMMON_TABLES_H */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_const_structs.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_const_structs.h new file mode 100644 index 0000000000000000000000000000000000000000..726d06eb692f0539165e4e0f675eab0b1f2b59c4 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_const_structs.h @@ -0,0 +1,79 @@ +/* ---------------------------------------------------------------------- +* Copyright (C) 2010-2014 ARM Limited. All rights reserved. +* +* $Date: 19. March 2015 +* $Revision: V.1.4.5 +* +* Project: CMSIS DSP Library +* Title: arm_const_structs.h +* +* Description: This file has constant structs that are initialized for +* user convenience. For example, some can be given as +* arguments to the arm_cfft_f32() function. +* +* Target Processor: Cortex-M4/Cortex-M3 +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* - Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* - Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* - Neither the name of ARM LIMITED nor the names of its contributors +* may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* -------------------------------------------------------------------- */ + +#ifndef _ARM_CONST_STRUCTS_H +#define _ARM_CONST_STRUCTS_H + +#include "arm_math.h" +#include "arm_common_tables.h" + + 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/nuvoton_nuc472/Libraries/CMSIS/Include/arm_math.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_math.h new file mode 100644 index 0000000000000000000000000000000000000000..d33f8a9b3b57f9b146dc5da036b06281d17a4594 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/arm_math.h @@ -0,0 +1,7154 @@ +/* ---------------------------------------------------------------------- +* Copyright (C) 2010-2015 ARM Limited. All rights reserved. +* +* $Date: 20. October 2015 +* $Revision: V1.4.5 b +* +* Project: CMSIS DSP Library +* Title: arm_math.h +* +* Description: Public header file for CMSIS DSP Library +* +* Target Processor: Cortex-M7/Cortex-M4/Cortex-M3/Cortex-M0 +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* - Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* - Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* - Neither the name of ARM LIMITED nor the names of its contributors +* may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. + * -------------------------------------------------------------------- */ + +/** + \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 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 + * - Filters + * - Matrix functions + * - Transforms + * - Motor control functions + * - Statistical functions + * - Support functions + * - Interpolation functions + * + * The library has 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. + * - arm_cortexM7lfdp_math.lib (Little endian and Double Precision Floating Point Unit on Cortex-M7) + * - arm_cortexM7bfdp_math.lib (Big endian and Double Precision Floating Point Unit on Cortex-M7) + * - arm_cortexM7lfsp_math.lib (Little endian and Single Precision Floating Point Unit on Cortex-M7) + * - arm_cortexM7bfsp_math.lib (Big endian and Single Precision Floating Point Unit on Cortex-M7) + * - arm_cortexM7l_math.lib (Little endian on Cortex-M7) + * - arm_cortexM7b_math.lib (Big endian on Cortex-M7) + * - arm_cortexM4lf_math.lib (Little endian and Floating Point Unit on Cortex-M4) + * - arm_cortexM4bf_math.lib (Big endian and Floating Point Unit on Cortex-M4) + * - arm_cortexM4l_math.lib (Little endian on Cortex-M4) + * - arm_cortexM4b_math.lib (Big endian on Cortex-M4) + * - arm_cortexM3l_math.lib (Little endian on Cortex-M3) + * - arm_cortexM3b_math.lib (Big endian on Cortex-M3) + * - arm_cortexM0l_math.lib (Little endian on Cortex-M0 / CortexM0+) + * - arm_cortexM0b_math.lib (Big endian on Cortex-M0 / CortexM0+) + * + * 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-M7/M4/M3/M0/M0+ with little endian and big endian. Same header file will be used for floating point unit(FPU) variants. + * Define the appropriate pre processor MACRO ARM_MATH_CM7 or ARM_MATH_CM4 or ARM_MATH_CM3 or + * ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application. + * + * Examples + * -------- + * + * The library ships with a number of examples which demonstrate how to use the library functions. + * + * Toolchain Support + * ------------ + * + * The library has been developed and tested with MDK-ARM version 5.14.0.0 + * The library is being tested in GCC and IAR toolchains and updates on this activity will be made available shortly. + * + * Building the Library + * ------------ + * + * The library installer contains a project file to re build libraries on MDK-ARM Tool chain in the CMSIS\\DSP_Lib\\Source\\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 pre processor MACROs detailed above. + * + * Pre-processor Macros + * ------------ + * + * Each library project have differant pre-processor macros. + * + * - UNALIGNED_SUPPORT_DISABLE: + * + * Define macro UNALIGNED_SUPPORT_DISABLE, If the silicon does not support unaligned memory access + * + * - 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_CMx: + * + * Define macro ARM_MATH_CM4 for building the library on Cortex-M4 target, ARM_MATH_CM3 for building library on Cortex-M3 target + * and ARM_MATH_CM0 for building library on Cortex-M0 target, ARM_MATH_CM0PLUS for building library on Cortex-M0+ target, and + * ARM_MATH_CM7 for building the library on cortex-M7. + * + * - __FPU_PRESENT: + * + * Initialize macro __FPU_PRESENT = 1 when building on FPU supported Targets. Enable this macro for M4bf and M4lf libraries + * + *
+ * 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_Lib | Software license agreement (license.txt) | + * |\b CMSIS\\DSP_Lib\\Examples | Example projects demonstrating the usage of the library functions | + * |\b CMSIS\\DSP_Lib\\Source | Source files for rebuilding the library | + * + *
+ * Revision History of CMSIS-DSP + * ------------ + * Please refer to \ref ChangeLog_pg. + * + * Copyright Notice + * ------------ + * + * Copyright (C) 2010-2015 ARM Limited. All rights reserved. + */ + + +/** + * @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 the function arm_mat_init_f32(), arm_mat_init_q31() + * and 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 + */ +#ifndef _ARM_MATH_H +#define _ARM_MATH_H + +/* ignore some GCC warnings */ +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +#define __CMSIS_GENERIC /* disable NVIC and Systick functions */ + +#if defined(ARM_MATH_CM7) + #include "core_cm7.h" +#elif defined (ARM_MATH_CM4) + #include "core_cm4.h" +#elif defined (ARM_MATH_CM3) + #include "core_cm3.h" +#elif defined (ARM_MATH_CM0) + #include "core_cm0.h" + #define ARM_MATH_CM0_FAMILY +#elif defined (ARM_MATH_CM0PLUS) + #include "core_cm0plus.h" + #define ARM_MATH_CM0_FAMILY +#else + #error "Define according the used Cortex core ARM_MATH_CM7, ARM_MATH_CM4, ARM_MATH_CM3, ARM_MATH_CM0PLUS or ARM_MATH_CM0" +#endif + +#undef __CMSIS_GENERIC /* enable NVIC and Systick functions */ +#include "string.h" +#include "math.h" +#ifdef __cplusplus +extern "C" +{ +#endif + + + /** + * @brief Macros required for reciprocal calculation in Normalized LMS + */ + +#define DELTA_Q31 (0x100) +#define DELTA_Q15 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_SIZE 256 +#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 Macro for Unaligned Support + */ +#ifndef UNALIGNED_SUPPORT_DISABLE + #define ALIGN4 +#else + #if defined (__GNUC__) + #define ALIGN4 __attribute__((aligned(4))) + #else + #define ALIGN4 __align(4) + #endif +#endif /* #ifndef UNALIGNED_SUPPORT_DISABLE */ + + /** + * @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, /**< Generated by matrix inversion if the 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 definition to read/write two 16 bit values. + */ +#if defined __CC_ARM + #define __SIMD32_TYPE int32_t __packed + #define CMSIS_UNUSED __attribute__((unused)) + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __SIMD32_TYPE int32_t + #define CMSIS_UNUSED __attribute__((unused)) + +#elif defined __GNUC__ + #define __SIMD32_TYPE int32_t + #define CMSIS_UNUSED __attribute__((unused)) + +#elif defined __ICCARM__ + #define __SIMD32_TYPE int32_t __packed + #define CMSIS_UNUSED + +#elif defined __CSMC__ + #define __SIMD32_TYPE int32_t + #define CMSIS_UNUSED + +#elif defined __TASKING__ + #define __SIMD32_TYPE __unaligned int32_t + #define CMSIS_UNUSED + +#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)) + +#if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) + /** + * @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 __INLINE 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 __INLINE 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 __INLINE 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 __INLINE 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 __INLINE q63_t mult32x64( + q63_t x, + q31_t y) + { + return ((((q63_t) (x & 0x00000000FFFFFFFF) * y) >> 32) + + (((q63_t) (x >> 32) * y))); + } + +/* + #if defined (ARM_MATH_CM0_FAMILY) && defined ( __CC_ARM ) + #define __CLZ __clz + #endif + */ +/* note: function can be removed when all toolchain support __CLZ for Cortex-M0 */ +#if defined (ARM_MATH_CM0_FAMILY) && ((defined (__ICCARM__)) ) + static __INLINE uint32_t __CLZ( + q31_t data); + + static __INLINE uint32_t __CLZ( + q31_t data) + { + uint32_t count = 0; + uint32_t mask = 0x80000000; + + while((data & mask) == 0) + { + count += 1u; + mask = mask >> 1u; + } + + return (count); + } +#endif + + /** + * @brief Function to Calculates 1/in (reciprocal) value of Q31 Data type. + */ + + static __INLINE uint32_t arm_recip_q31( + q31_t in, + q31_t * dst, + 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 __INLINE uint32_t arm_recip_q15( + q15_t in, + q15_t * dst, + 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 C custom defined intrinisic function for only M0 processors + */ +#if defined(ARM_MATH_CM0_FAMILY) + static __INLINE q31_t __SSAT( + q31_t x, + uint32_t y) + { + int32_t posMax, negMin; + uint32_t i; + + posMax = 1; + for (i = 0; i < (y - 1); i++) + { + posMax = posMax * 2; + } + + if(x > 0) + { + posMax = (posMax - 1); + + if(x > posMax) + { + x = posMax; + } + } + else + { + negMin = -posMax; + + if(x < negMin) + { + x = negMin; + } + } + return (x); + } +#endif /* end of ARM_MATH_CM0_FAMILY */ + + + /* + * @brief C custom defined intrinsic function for M3 and M0 processors + */ +#if defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) + + /* + * @brief C custom defined QADD8 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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 for M3 and M0 processors + */ + static __INLINE 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) )); + } + +#endif /* defined (ARM_MATH_CM3) || defined (ARM_MATH_CM0_FAMILY) */ + + + /** + * @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. */ + 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. */ + 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. */ + 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. */ + 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, + 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, + 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, + q15_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + /** + * @brief Processing function for the fast Q15 FIR filter for Cortex-M3 and Cortex-M4. + * @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, + 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 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, + 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, + q31_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + /** + * @brief Processing function for the fast Q31 FIR filter for Cortex-M3 and Cortex-M4. + * @param[in] S points to an instance of the Q31 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_fast_q31( + const arm_fir_instance_q31 * S, + 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, + 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, + 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, + 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. */ + 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. */ + 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. */ + float32_t *pCoeffs; /**< Points to the array of coefficients. The array is of length 5*numStages. */ + } arm_biquad_casd_df1_inst_f32; + + + /** + * @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, + 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, + 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, + 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, + 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, + 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, + 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, + 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] pState points to the state buffer. + */ + void arm_biquad_cascade_df1_init_f32( + arm_biquad_casd_df1_inst_f32 * S, + uint8_t numStages, + float32_t * pCoeffs, + float32_t * pState); + + + /** + * @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 . */ +#ifdef ARM_MATH_CM0_FAMILY + 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( + q7_t * pSrcA, + 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( + q15_t * pSrcA, + 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( + q31_t * pSrcA, + 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( + float32_t * pSrcA, + 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. */ + q15_t *pTwiddle; /**< points to the Sin twiddle factor table. */ + 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. */ + q15_t *pTwiddle; /**< points to the twiddle factor table. */ + 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. */ + q31_t *pTwiddle; /**< points to the Twiddle factor table. */ + 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. */ + q31_t *pTwiddle; /**< points to the twiddle factor table. */ + 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. */ + float32_t *pTwiddle; /**< points to the Twiddle factor table. */ + 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. */ + float32_t *pTwiddle; /**< points to the Twiddle factor table. */ + 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. */ + } arm_cfft_instance_q15; + +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. */ + } arm_cfft_instance_q31; + +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. */ + } arm_cfft_instance_f32; + + void arm_cfft_f32( + const arm_cfft_instance_f32 * S, + float32_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. */ + q15_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ + q15_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ + const arm_cfft_instance_q15 *pCfft; /**< points to the complex FFT instance. */ + } 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. */ + q31_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ + q31_t *pTwiddleBReal; /**< points to the imag twiddle factor table. */ + const arm_cfft_instance_q31 *pCfft; /**< points to the complex FFT instance. */ + } 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. */ + float32_t *pTwiddleAReal; /**< points to the real twiddle factor table. */ + 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 floating-point RFFT/RIFFT function. + */ +typedef struct + { + arm_cfft_instance_f32 Sint; /**< Internal CFFT structure. */ + uint16_t fftLenRFFT; /**< length of the real sequence */ + 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( + 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. */ + float32_t *pTwiddle; /**< points to the twiddle factor table. */ + 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. */ + q31_t *pTwiddle; /**< points to the twiddle factor table. */ + 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. */ + q15_t *pTwiddle; /**< points to the twiddle factor table. */ + 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( + float32_t * pSrcA, + 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( + q7_t * pSrcA, + 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( + q15_t * pSrcA, + 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( + q31_t * pSrcA, + 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( + float32_t * pSrcA, + 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( + q7_t * pSrcA, + 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( + q15_t * pSrcA, + 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( + q31_t * pSrcA, + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + float32_t * pSrcA, + 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( + q7_t * pSrcA, + 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( + q15_t * pSrcA, + 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( + q31_t * pSrcA, + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + float32_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q31_t * pSrcA, + uint32_t srcALen, + 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( + q31_t * pSrcA, + uint32_t srcALen, + 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( + q7_t * pSrcA, + uint32_t srcALen, + 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( + q7_t * pSrcA, + uint32_t srcALen, + 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( + float32_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q31_t * pSrcA, + uint32_t srcALen, + 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( + q31_t * pSrcA, + uint32_t srcALen, + 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( + q7_t * pSrcA, + uint32_t srcALen, + 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( + q7_t * pSrcA, + uint32_t srcALen, + 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. */ + 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. */ + 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 the floating-point FIR decimator. + */ + typedef struct + { + uint8_t M; /**< decimation factor. */ + uint16_t numTaps; /**< number of coefficients in the filter. */ + 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 the 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 input samples to process per call. + */ + void arm_fir_decimate_f32( + const arm_fir_decimate_instance_f32 * S, + 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 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_f32( + arm_fir_decimate_instance_f32 * S, + uint16_t numTaps, + uint8_t M, + 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, + 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, + 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, + 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, + 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( + arm_fir_decimate_instance_q31 * S, + 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, + 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. */ + 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. */ + 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. */ + 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, + 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, + 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, + 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, + 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, + 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, + 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. */ + 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, + 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, + 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. */ + 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. */ + 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. */ + 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, + 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, + 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, + float64_t * pSrc, + float64_t * pDst, + uint32_t blockSize); + + + /** + * @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, + 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, + 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, + 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. */ + 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. */ + 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. */ + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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. */ + 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, + 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. */ + 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, + 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( + float32_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q15_t * pSrcA, + uint32_t srcALen, + q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst); + + + /** + * @brief Correlation 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 2 * max(srcALen, srcBLen) - 1. + */ + + void arm_correlate_fast_q15( + q15_t * pSrcA, + uint32_t srcALen, + q15_t * pSrcB, + uint32_t srcBLen, + q15_t * pDst); + + + /** + * @brief Correlation 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 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( + q15_t * pSrcA, + uint32_t srcALen, + 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( + q31_t * pSrcA, + uint32_t srcALen, + q31_t * pSrcB, + uint32_t srcBLen, + q31_t * pDst); + + + /** + * @brief Correlation 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 2 * max(srcALen, srcBLen) - 1. + */ + void arm_correlate_fast_q31( + q31_t * pSrcA, + uint32_t srcALen, + 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( + q7_t * pSrcA, + uint32_t srcALen, + 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( + q7_t * pSrcA, + uint32_t srcALen, + 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. */ + 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. */ + 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. */ + 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. */ + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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( + 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( + 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( + 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( + 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( + 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( + 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 out processed output sample. + */ + static __INLINE 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 out processed output sample. + * + * Scaling and Overflow Behavior: + * \par + * 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 __INLINE 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 out processed output sample. + * + * Scaling and Overflow Behavior: + * \par + * 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 __INLINE q15_t arm_pid_q15( + arm_pid_instance_q15 * S, + q15_t in) + { + q63_t acc; + q15_t out; + +#ifndef ARM_MATH_CM0_FAMILY + __SIMD32_TYPE *vstate; + + /* 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] */ + vstate = __SIMD32_CONST(S->state); + acc = (q63_t)__SMLALD((uint32_t)S->A1, (uint32_t)*vstate, (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((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 + */ + static __INLINE 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 + * + * Scaling and Overflow Behavior: + * \par + * 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 __INLINE 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 + */ + + /** + * @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( + q7_t * pSrc, + q31_t * pDst, + uint32_t blockSize); + + + + /** + * @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 + */ + static __INLINE 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 + * + * Scaling and Overflow Behavior: + * \par + * 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 __INLINE 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 + */ + + /** + * @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( + q7_t * pSrc, + q15_t * pDst, + uint32_t blockSize); + + + + /** + * @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 + * + * The function implements the forward Park transform. + * + */ + static __INLINE 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 + * + * Scaling and Overflow Behavior: + * \par + * 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 __INLINE 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 + */ + + /** + * @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( + q7_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + + /** + * @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 + */ + static __INLINE 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 + * + * Scaling and Overflow Behavior: + * \par + * 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 __INLINE 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 + */ + + + /** + * @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( + q31_t * pSrc, + float32_t * pDst, + uint32_t blockSize); + + /** + * @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 __INLINE 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) + { + /* 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 __INLINE 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 __INLINE 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 __INLINE 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); + + + /** + * @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 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. + */ + static __INLINE arm_status arm_sqrt_f32( + float32_t in, + float32_t * pOut) + { + if(in >= 0.0f) + { + +#if (__FPU_USED == 1) && defined ( __CC_ARM ) + *pOut = __sqrtf(in); +#elif (__FPU_USED == 1) && (defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) + *pOut = __builtin_sqrtf(in); +#elif (__FPU_USED == 1) && defined(__GNUC__) + *pOut = __builtin_sqrtf(in); +#elif (__FPU_USED == 1) && defined ( __ICCARM__ ) && (__VER__ >= 6040000) + __ASM("VSQRT.F32 %0,%1" : "=t"(*pOut) : "t"(in)); +#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 square root of input value. + * @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. + */ + 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 square root of input value. + * @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. + */ + arm_status arm_sqrt_q15( + q15_t in, + q15_t * pOut); + + /** + * @} end of SQRT group + */ + + + /** + * @brief floating-point Circular write function. + */ + static __INLINE 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 __INLINE 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, 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 = (int32_t) (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 == (int32_t *) 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 __INLINE 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 __INLINE 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, 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 = (int32_t) (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 == (q15_t *) 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 __INLINE 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 __INLINE 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, 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 = (int32_t) (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 == (q7_t *) 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + q15_t * pSrcA, + 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( + q31_t * pSrcA, + 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( + float32_t * pSrcA, + 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( + q15_t * pSrcCmplx, + 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( + q31_t * pSrcCmplx, + 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( + float32_t * pSrcCmplx, + 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( + 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( + 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( + 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( + 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( + 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( + 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( + 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( + float32_t * pSrc, + uint32_t blockSize, + float32_t * pResult, + uint32_t * pIndex); + + + /** + * @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( + q15_t * pSrcA, + 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( + q31_t * pSrcA, + 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( + float32_t * pSrcA, + 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( + 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( + 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( + float32_t * pSrc, + q7_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( + 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( + 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( + 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( + 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( + q15_t * pSrc, + q7_t * pDst, + uint32_t blockSize); + + + /** + * @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 __INLINE 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->numRows - 1) || yIndex < 0 || yIndex > (S->numCols - 1)) + { + return (0); + } + + /* Calculation of index for two nearest points in X-direction */ + index = (xIndex - 1) + (yIndex - 1) * 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 - 1) + (yIndex) * 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 __INLINE 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->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) + { + 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 __INLINE 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->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) + { + 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 * (0xFFFFF - xfract)) >> 4u); + acc = ((q63_t) out * (0xFFFFF - yfract)); + + /* x2 * (xfract) * (1-yfract) in 1.51 and adding to acc */ + out = (q31_t) (((q63_t) x2 * (0xFFFFF - yfract)) >> 4u); + acc += ((q63_t) out * (xfract)); + + /* y1 * (1 - xfract) * (yfract) in 1.51 and adding to acc */ + out = (q31_t) (((q63_t) y1 * (0xFFFFF - 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 __INLINE 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->numRows - 1) || cI < 0 || cI > (S->numCols - 1)) + { + 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_MATH_CM4 ) || defined( ARM_MATH_CM7) + #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_MATH_CM4 ) || defined( ARM_MATH_CM7) + #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_MATH_CM4 ) || defined( ARM_MATH_CM7) + #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_MATH_CM4 ) || defined( ARM_MATH_CM7) + #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(__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 + +#endif + + +#ifdef __cplusplus +} +#endif + + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +#endif /* _ARM_MATH_H */ + +/** + * + * End of file. + */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_armcc.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_armcc.h new file mode 100644 index 0000000000000000000000000000000000000000..74c49c67defb6382f28a359d5678c5996add541c --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_armcc.h @@ -0,0 +1,734 @@ +/**************************************************************************//** + * @file cmsis_armcc.h + * @brief CMSIS Cortex-M Core Function/Instruction Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#ifndef __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 + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ + */ + +/* intrinsic void __enable_irq(); */ +/* 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 (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + +/** + \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)1); +} + +#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ + + +#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) + +/** + \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 (__FPU_PRESENT == 1U) && (__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 (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + register uint32_t __regfpscr __ASM("fpscr"); + __regfpscr = (fpscr); +#endif +} + +#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ + + + +/*@} 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() do {\ + __schedule_barrier();\ + __isb(0xF);\ + __schedule_barrier();\ + } while (0U) + +/** + \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() do {\ + __schedule_barrier();\ + __dsb(0xF);\ + __schedule_barrier();\ + } while (0U) + +/** + \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() do {\ + __schedule_barrier();\ + __dmb(0xF);\ + __schedule_barrier();\ + } while (0U) + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in integer value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __rev + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in two unsigned short values. + \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 in signed short value + \details Reverses the byte order in a signed short value with sign extension to integer. + \param [in] value Value to reverse + \return Reversed value + */ +#ifndef __NO_EMBEDDED_ASM +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_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] value Value to rotate + \param [in] value 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 (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + #define __RBIT __rbit +#else +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value; 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 (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + +/** + \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) + +#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ + +#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)) + +#endif /* (__CORTEX_M >= 0x04) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_H */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_armcc_V6.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_armcc_V6.h new file mode 100644 index 0000000000000000000000000000000000000000..cd13240ce360250f496f1fd8c04df7ee23c0a8c9 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_armcc_V6.h @@ -0,0 +1,1800 @@ +/**************************************************************************//** + * @file cmsis_armcc_V6.h + * @brief CMSIS Cortex-M Core Function/Instruction Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#ifndef __CMSIS_ARMCC_V6_H +#define __CMSIS_ARMCC_V6_H + + +/* ########################### 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. + */ +__attribute__((always_inline)) __STATIC_INLINE 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. + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get IPSR Register (non-secure) + \details Returns the content of the non-secure IPSR Register when in secure state. + \return IPSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_IPSR_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, ipsr_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Get APSR Register + \details Returns the content of the APSR Register. + \return APSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_APSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get APSR Register (non-secure) + \details Returns the content of the non-secure APSR Register when in secure state. + \return APSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_APSR_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, apsr_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Get xPSR Register + \details Returns the content of the xPSR Register. + \return xPSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_xPSR(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get xPSR Register (non-secure) + \details Returns the content of the non-secure xPSR Register when in secure state. + \return xPSR Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_xPSR_NS(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, xpsr_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Get Process Stack Pointer + \details Returns the current value of the Process Stack Pointer (PSP). + \return PSP Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psp" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSP_NS(void) +{ + register 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) : "sp"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSP_NS(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp_ns, %0" : : "r" (topOfProcStack) : "sp"); +} +#endif + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msp" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSP_NS(void) +{ + register 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) : "sp"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp_ns, %0" : : "r" (topOfMainStack) : "sp"); +} +#endif + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PRIMASK_NS(uint32_t priMask) +{ + __ASM volatile ("MSR primask_ns, %0" : : "r" (priMask) : "memory"); +} +#endif + + +#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__((always_inline)) __STATIC_INLINE 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. + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI(uint32_t value) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_NS(uint32_t value) +{ + __ASM volatile ("MSR basepri_ns, %0" : : "r" (value) : "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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set Base Priority with condition (non_secure) + \details Assigns the given value to the non-secure Base Priority register when in secure state only if BASEPRI masking is disabled, + or the new value increases the BASEPRI priority level. + \param [in] basePri Base Priority value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_MAX_NS(uint32_t value) +{ + __ASM volatile ("MSR basepri_max_ns, %0" : : "r" (value) : "memory"); +} +#endif + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask_ns, %0" : : "r" (faultMask) : "memory"); +} +#endif + + +#endif /* ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ + + +#if (__ARM_ARCH_8M__ == 1U) + +/** + \brief Get Process Stack Pointer Limit + \details Returns the current value of the Process Stack Pointer Limit (PSPLIM). + \return PSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_PSPLIM(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psplim" : "=r" (result) ); + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Get Process Stack Pointer Limit (non-secure) + \details Returns the current value of the non-secure Process Stack Pointer Limit (PSPLIM) when in secure state. + \return PSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_PSPLIM_NS(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psplim_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Process Stack Pointer Limit + \details Assigns the given value to the Process Stack Pointer Limit (PSPLIM). + \param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit) +{ + __ASM volatile ("MSR psplim, %0" : : "r" (ProcStackPtrLimit)); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Set Process Stack Pointer (non-secure) + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit) +{ + __ASM volatile ("MSR psplim_ns, %0\n" : : "r" (ProcStackPtrLimit)); +} +#endif + + +/** + \brief Get Main Stack Pointer Limit + \details Returns the current value of the Main Stack Pointer Limit (MSPLIM). + \return MSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_MSPLIM(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msplim" : "=r" (result) ); + + return(result); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Get Main Stack Pointer Limit (non-secure) + \details Returns the current value of the non-secure Main Stack Pointer Limit(MSPLIM) when in secure state. + \return MSPLIM Register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_MSPLIM_NS(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msplim_ns" : "=r" (result) ); + return(result); +} +#endif + + +/** + \brief Set Main Stack Pointer Limit + \details Assigns the given value to the Main Stack Pointer Limit (MSPLIM). + \param [in] MainStackPtrLimit Main Stack Pointer Limit value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __set_MSPLIM(uint32_t MainStackPtrLimit) +{ + __ASM volatile ("MSR msplim, %0" : : "r" (MainStackPtrLimit)); +} + + +#if (__ARM_FEATURE_CMSE == 3U) && (__ARM_ARCH_PROFILE == 'M') /* ToDo: ARMCC_V6: check predefined macro for mainline */ +/** + \brief Set Main Stack Pointer Limit (non-secure) + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit) +{ + __ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit)); +} +#endif + +#endif /* (__ARM_ARCH_8M__ == 1U) */ + + +#if ((__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=4 */ + +/** + \brief Get FPSCR + \details eturns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +#define __get_FPSCR __builtin_arm_get_fpscr +#if 0 +__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + uint32_t result; + + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + __ASM volatile (""); + return(result); +#else + return(0); +#endif +} +#endif + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Get FPSCR (non-secure) + \details Returns the current value of the non-secure Floating Point Status/Control register when in secure state. + \return Floating Point Status/Control register value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __TZ_get_FPSCR_NS(void) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + uint32_t result; + + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMRS %0, fpscr_ns" : "=r" (result) ); + __ASM volatile (""); + return(result); +#else + return(0); +#endif +} +#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 + */ +#define __set_FPSCR __builtin_arm_set_fpscr +#if 0 +__attribute__((always_inline)) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); + __ASM volatile (""); +#endif +} +#endif + +#if (__ARM_FEATURE_CMSE == 3U) +/** + \brief Set FPSCR (non-secure) + \details Assigns the given value to the non-secure Floating Point Status/Control register when in secure state. + \param [in] fpscr Floating Point Status/Control value to set + */ +__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_FPSCR_NS(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + __ASM volatile (""); /* Empty asm statement works as a scheduling barrier */ + __ASM volatile ("VMSR fpscr_ns, %0" : : "r" (fpscr) : "vfpcc"); + __ASM volatile (""); +#endif +} +#endif + +#endif /* ((__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ + + + +/*@} 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 integer value. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV __builtin_bswap32 + + +/** + \brief Reverse byte order (16 bit) + \details Reverses the byte order in two unsigned short values. + \param [in] value Value to reverse + \return Reversed value + */ +#define __REV16 __builtin_bswap16 /* ToDo: ARMCC_V6: check if __builtin_bswap16 could be used */ +#if 0 +__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} +#endif + + +/** + \brief Reverse byte order in signed short value + \details Reverses the byte order in a signed short value with sign extension to integer. + \param [in] value Value to reverse + \return Reversed value + */ + /* ToDo: ARMCC_V6: check if __builtin_bswap16 could be used */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) +{ + int32_t result; + + __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + 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 + */ + /* ToDo: ARMCC_V6: check if __builtin_arm_rbit is supported */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ + __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value; 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 + */ +#define __CLZ __builtin_clz + + +#if ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) /* ToDo: ARMCC_V6: check if this is ok for cortex >=3 */ + +/** + \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 + + +/** + \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*/ +#define __SSAT(ARG1,ARG2) \ +({ \ + int32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** + \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 +#if 0 +#define __USAT(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) +#endif + + +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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) + */ +__attribute__((always_inline)) __STATIC_INLINE 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) + */ +__attribute__((always_inline)) __STATIC_INLINE 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) + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) ); +} + +#endif /* ((__ARM_ARCH_7M__ == 1U) || (__ARM_ARCH_7EM__ == 1U) || (__ARM_ARCH_8M__ == 1U)) */ + + +#if (__ARM_ARCH_8M__ == 1U) + +/** + \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) + */ +__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDAB(volatile uint8_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldab %0, %1" : "=r" (result) : "Q" (*ptr) ); + 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) + */ +__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDAH(volatile uint16_t *ptr) +{ + uint32_t result; + + __ASM volatile ("ldah %0, %1" : "=r" (result) : "Q" (*ptr) ); + 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) + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDA(volatile uint32_t *ptr) +{ + uint32_t result; + + __ASM volatile ("lda %0, %1" : "=r" (result) : "Q" (*ptr) ); + 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __STLB(uint8_t value, volatile uint8_t *ptr) +{ + __ASM volatile ("stlb %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __STLH(uint16_t value, volatile uint16_t *ptr) +{ + __ASM volatile ("stlh %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __STL(uint32_t value, volatile uint32_t *ptr) +{ + __ASM volatile ("stl %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) ); +} + + +/** + \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 /* (__ARM_ARCH_8M__ == 1U) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (__ARM_FEATURE_DSP == 1U) /* ToDo: ARMCC_V6: This should be ARCH >= ARMv7-M + SIMD */ + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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) \ +({ \ + uint32_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; \ + }) + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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); +} + +__attribute__((always_inline)) __STATIC_INLINE 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 __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; \ + }) + +__attribute__((always_inline)) __STATIC_INLINE uint32_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 == 1U) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#endif /* __CMSIS_ARMCC_V6_H */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_gcc.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_gcc.h new file mode 100644 index 0000000000000000000000000000000000000000..bb89fbba9e40005859e15a8d584e998cbdb6ae59 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/cmsis_gcc.h @@ -0,0 +1,1373 @@ +/**************************************************************************//** + * @file cmsis_gcc.h + * @brief CMSIS Cortex-M Core Function/Instruction Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#ifndef __CMSIS_GCC_H +#define __CMSIS_GCC_H + +/* ignore some GCC warnings */ +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#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. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE 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. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE 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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, control" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Control Register + \details Writes the given value to the Control Register. + \param [in] control Control Register value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control) +{ + __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); +} + + +/** + \brief Get IPSR Register + \details Returns the content of the IPSR Register. + \return IPSR Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE 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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE 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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE 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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); + return(result); +} + + +/** + \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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) +{ + __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); +} + + +/** + \brief Get Main Stack Pointer + \details Returns the current value of the Main Stack Pointer (MSP). + \return MSP Register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void) +{ + register uint32_t result; + + __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); + return(result); +} + + +/** + \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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) +{ + __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); +} + + +/** + \brief Get Priority Mask + \details Returns the current state of the priority mask bit from the Priority Mask Register. + \return Priority Mask value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, primask" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Priority Mask + \details Assigns the given value to the Priority Mask Register. + \param [in] priMask Priority Mask + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) +{ + __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); +} + + +#if (__CORTEX_M >= 0x03U) + +/** + \brief Enable FIQ + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. + Can only be executed in Privileged modes. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE 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. + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE 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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, basepri" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Base Priority + \details Assigns the given value to the Base Priority register. + \param [in] basePri Base Priority value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value) +{ + __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); +} + + +/** + \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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value) +{ + __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory"); +} + + +/** + \brief Get Fault Mask + \details Returns the current value of the Fault Mask register. + \return Fault Mask register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void) +{ + uint32_t result; + + __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); + return(result); +} + + +/** + \brief Set Fault Mask + \details Assigns the given value to the Fault Mask register. + \param [in] faultMask Fault Mask value to set + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) +{ + __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); +} + +#endif /* (__CORTEX_M >= 0x03U) */ + + +#if (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) + +/** + \brief Get FPSCR + \details Returns the current value of the Floating Point Status/Control register. + \return Floating Point Status/Control register value + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + uint32_t result; + + /* Empty asm statement works as a scheduling barrier */ + __ASM volatile (""); + __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); + __ASM volatile (""); + return(result); +#else + return(0); +#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 + */ +__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) +{ +#if (__FPU_PRESENT == 1U) && (__FPU_USED == 1U) + /* Empty asm statement works as a scheduling barrier */ + __ASM volatile (""); + __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); + __ASM volatile (""); +#endif +} + +#endif /* (__CORTEX_M == 0x04U) || (__CORTEX_M == 0x07U) */ + + + +/*@} 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. + */ +__attribute__((always_inline)) __STATIC_INLINE void __NOP(void) +{ + __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. + */ +__attribute__((always_inline)) __STATIC_INLINE void __WFI(void) +{ + __ASM volatile ("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. + */ +__attribute__((always_inline)) __STATIC_INLINE void __WFE(void) +{ + __ASM volatile ("wfe"); +} + + +/** + \brief Send Event + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. + */ +__attribute__((always_inline)) __STATIC_INLINE void __SEV(void) +{ + __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. + */ +__attribute__((always_inline)) __STATIC_INLINE 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. + */ +__attribute__((always_inline)) __STATIC_INLINE 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. + */ +__attribute__((always_inline)) __STATIC_INLINE void __DMB(void) +{ + __ASM volatile ("dmb 0xF":::"memory"); +} + + +/** + \brief Reverse byte order (32 bit) + \details Reverses the byte order in integer value. + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV(uint32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) + return __builtin_bswap32(value); +#else + uint32_t result; + + __ASM volatile ("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 in two unsigned short values. + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __REV16(uint32_t value) +{ + uint32_t result; + + __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) ); + return(result); +} + + +/** + \brief Reverse byte order in signed short value + \details Reverses the byte order in a signed short value with sign extension to integer. + \param [in] value Value to reverse + \return Reversed value + */ +__attribute__((always_inline)) __STATIC_INLINE int32_t __REVSH(int32_t value) +{ +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + return (short)__builtin_bswap16(value); +#else + int32_t result; + + __ASM volatile ("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] value Value to rotate + \param [in] value Number of Bits to rotate + \return Rotated value + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2) +{ + 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 + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) +{ + uint32_t result; + +#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); +#else + int32_t s = 4 /*sizeof(v)*/ * 8 - 1; /* extra shift needed at end */ + + result = value; /* r will be reversed bits of v; first get LSB of v */ + for (value >>= 1U; value; 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 + */ +#define __CLZ __builtin_clz + + +#if (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) + +/** + \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) + */ +__attribute__((always_inline)) __STATIC_INLINE 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) + */ +__attribute__((always_inline)) __STATIC_INLINE 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) + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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. + */ +__attribute__((always_inline)) __STATIC_INLINE void __CLREX(void) +{ + __ASM volatile ("clrex" ::: "memory"); +} + + +/** + \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(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __RES; \ + }) + + +/** + \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(ARG1,ARG2) \ +({ \ + uint32_t __RES, __ARG1 = (ARG1); \ + __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \ + __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 + */ +__attribute__((always_inline)) __STATIC_INLINE 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) + */ +__attribute__((always_inline)) __STATIC_INLINE uint8_t __LDRBT(volatile uint8_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrbt %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 ("ldrbt %0, [%1]" : "=r" (result) : "r" (addr) : "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) + */ +__attribute__((always_inline)) __STATIC_INLINE uint16_t __LDRHT(volatile uint16_t *addr) +{ + uint32_t result; + +#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) + __ASM volatile ("ldrht %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 ("ldrht %0, [%1]" : "=r" (result) : "r" (addr) : "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) + */ +__attribute__((always_inline)) __STATIC_INLINE uint32_t __LDRT(volatile uint32_t *addr) +{ + uint32_t result; + + __ASM volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*addr) ); + 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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRBT(uint8_t value, volatile uint8_t *addr) +{ + __ASM volatile ("strbt %1, %0" : "=Q" (*addr) : "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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRHT(uint16_t value, volatile uint16_t *addr) +{ + __ASM volatile ("strht %1, %0" : "=Q" (*addr) : "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 + */ +__attribute__((always_inline)) __STATIC_INLINE void __STRT(uint32_t value, volatile uint32_t *addr) +{ + __ASM volatile ("strt %1, %0" : "=Q" (*addr) : "r" (value) ); +} + +#endif /* (__CORTEX_M >= 0x03U) || (__CORTEX_SC >= 300U) */ + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +#if (__CORTEX_M >= 0x04U) /* only for Cortex-M4 and above */ + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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; \ + }) + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __UXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SXTB16(uint32_t op1) +{ + uint32_t result; + + __ASM volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1)); + return(result); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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); +} + +__attribute__( ( always_inline ) ) __STATIC_INLINE 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 __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; \ + }) + +__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_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 /* (__CORTEX_M >= 0x04) */ +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +#endif /* __CMSIS_GCC_H */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm0.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm0.h new file mode 100644 index 0000000000000000000000000000000000000000..711dad551702720712e7933bb693699e5ea745fa --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm0.h @@ -0,0 +1,798 @@ +/**************************************************************************//** + * @file core_cm0.h + * @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #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 + @{ + */ + +/* CMSIS CM0 definitions */ +#define __CM0_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM0_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \ + __CM0_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x00U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __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_PCS_VFP + #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 ( __TMS470__ ) + #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 "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#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 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_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. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((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. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((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 Cortex-M0 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. + @{ + */ + +/* Interrupt Priorities are WORD accessible only under ARMv6M */ +/* 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 External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + 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))); + } + else + { + 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))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \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)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__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 */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__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/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm0plus.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm0plus.h new file mode 100644 index 0000000000000000000000000000000000000000..b04aa3905323c5a0376c26989c1a3c9b8f3afe6a --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm0plus.h @@ -0,0 +1,914 @@ +/**************************************************************************//** + * @file core_cm0plus.h + * @brief CMSIS Cortex-M0+ Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #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+ + @{ + */ + +/* CMSIS CM0+ definitions */ +#define __CM0PLUS_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM0PLUS_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM0PLUS_CMSIS_VERSION ((__CM0PLUS_CMSIS_VERSION_MAIN << 16U) | \ + __CM0PLUS_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x00U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __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_PCS_VFP + #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 ( __TMS470__ ) + #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 "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#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 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 */ +#if (__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 (__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 (__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 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. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((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. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((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 Cortex-M0+ 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 (__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. + @{ + */ + +/* Interrupt Priorities are WORD accessible only under ARMv6M */ +/* 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 External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + 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))); + } + else + { + 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))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \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)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__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 */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__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/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm3.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm3.h new file mode 100644 index 0000000000000000000000000000000000000000..b4ac4c7b05a799590575c0b5c8e24c51748ee20b --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm3.h @@ -0,0 +1,1763 @@ +/**************************************************************************//** + * @file core_cm3.h + * @brief CMSIS Cortex-M3 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #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 + @{ + */ + +/* CMSIS CM3 definitions */ +#define __CM3_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM3_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \ + __CM3_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x03U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __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_PCS_VFP + #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 ( __TMS470__ ) + #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 "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#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 __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4U + #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:15; /*!< bit: 9..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_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 RSERVED1[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 (__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 */ + +/* 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 */ + +#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[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + 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 Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION 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 +{ + __IOM 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 */ + __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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY 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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< 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_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__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. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((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. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((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 Cortex-M3 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 (__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. + @{ + */ + +/** + \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 << 8U) ); /* Insert write key and priorty 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 External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \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)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (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 System Reset + \details Initiates a system reset request to reset the MCU. + */ +__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 */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__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 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/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm4.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm4.h new file mode 100644 index 0000000000000000000000000000000000000000..dc840ebf2221382b8ca8e9ed8ce72b99e4027ad1 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm4.h @@ -0,0 +1,1937 @@ +/**************************************************************************//** + * @file core_cm4.h + * @brief CMSIS Cortex-M4 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #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 + @{ + */ + +/* CMSIS CM4 definitions */ +#define __CM4_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM4_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \ + __CM4_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x04U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __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 (__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_PCS_VFP + #if (__FPU_PRESENT == 1) + #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 (__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 (__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 ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #if (__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 (__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 (__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 "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ +#include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ + +#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 __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4U + #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: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 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 RSERVED1[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 */ + +/* 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[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + 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 Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION 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 +{ + __IOM 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 */ + __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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY 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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< 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_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__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 + + +#if (__FPU_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 */ +} 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 */ + +/*@} end of group CMSIS_FPU */ +#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. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((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. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((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 Cortex-M4 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 (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#if (__FPU_PRESENT == 1U) + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point 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. + @{ + */ + +/** + \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 << 8U) ); /* Insert write key and priorty 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 External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \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)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (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 System Reset + \details Initiates a system reset request to reset the MCU. + */ +__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 */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__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 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/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm7.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm7.h new file mode 100644 index 0000000000000000000000000000000000000000..3b7530ad505b57d283cc6f07e7f51b9a54be9a0b --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cm7.h @@ -0,0 +1,2512 @@ +/**************************************************************************//** + * @file core_cm7.h + * @brief CMSIS Cortex-M7 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #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 + @{ + */ + +/* CMSIS CM7 definitions */ +#define __CM7_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __CM7_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \ + __CM7_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_M (0x07U) /*!< Cortex-M Core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __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 (__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_PCS_VFP + #if (__FPU_PRESENT == 1) + #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 (__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 (__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 ( __TMS470__ ) + #if defined __TI_VFP_SUPPORT__ + #if (__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 (__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 (__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 "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ +#include "core_cmSimd.h" /* Compiler specific SIMD Intrinsics */ + +#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 __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: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 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 RSERVED1[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 1 */ + 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 */ + +/* 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_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[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + 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 Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION 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 +{ + __IOM 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 */ + __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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY 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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< 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_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__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 + + +#if (__FPU_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 */ + +/*@} end of group CMSIS_FPU */ +#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. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((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. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((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 Cortex-M4 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 (__MPU_PRESENT == 1U) + #define MPU_BASE (SCS_BASE + 0x0D90UL) /*!< Memory Protection Unit */ + #define MPU ((MPU_Type *) MPU_BASE ) /*!< Memory Protection Unit */ +#endif + +#if (__FPU_PRESENT == 1U) + #define FPU_BASE (SCS_BASE + 0x0F30UL) /*!< Floating Point Unit */ + #define FPU ((FPU_Type *) FPU_BASE ) /*!< Floating Point 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. + @{ + */ + +/** + \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 << 8U) ); /* Insert write key and priorty 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 External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHPR[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \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)SCB->SHPR[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (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 System Reset + \details Initiates a system reset request to reset the MCU. + */ +__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) +{ + uint32_t mvfr0; + + mvfr0 = SCB->MVFR0; + if ((mvfr0 & 0x00000FF0UL) == 0x220UL) + { + return 2UL; /* Double + Single precision FPU */ + } + else if ((mvfr0 & 0x00000FF0UL) == 0x020UL) + { + return 1UL; /* Single precision FPU */ + } + else + { + return 0UL; /* No FPU */ + } +} + + +/*@} end of CMSIS_Core_FpuFunctions */ + + + +/* ########################## Cache functions #################################### */ +/** + \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 ) + + +/** + \brief Enable I-Cache + \details Turns on I-Cache + */ +__STATIC_INLINE void SCB_EnableICache (void) +{ + #if (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; /* invalidate I-Cache */ + SCB->CCR |= (uint32_t)SCB_CCR_IC_Msk; /* enable I-Cache */ + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Disable I-Cache + \details Turns off I-Cache + */ +__STATIC_INLINE void SCB_DisableICache (void) +{ + #if (__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_INLINE void SCB_InvalidateICache (void) +{ + #if (__ICACHE_PRESENT == 1U) + __DSB(); + __ISB(); + SCB->ICIALLU = 0UL; + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Enable D-Cache + \details Turns on D-Cache + */ +__STATIC_INLINE void SCB_EnableDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* 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--); + } while(sets--); + __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_INLINE void SCB_DisableDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* Level 1 data cache */ + __DSB(); + + ccsidr = SCB->CCSIDR; + + SCB->CCR &= ~(uint32_t)SCB_CCR_DC_Msk; /* disable D-Cache */ + + /* 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--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Invalidate D-Cache + \details Invalidates D-Cache + */ +__STATIC_INLINE void SCB_InvalidateDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* 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--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean D-Cache + \details Cleans D-Cache + */ +__STATIC_INLINE void SCB_CleanDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* 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--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief Clean & Invalidate D-Cache + \details Cleans and Invalidates D-Cache + */ +__STATIC_INLINE void SCB_CleanInvalidateDCache (void) +{ + #if (__DCACHE_PRESENT == 1U) + uint32_t ccsidr; + uint32_t sets; + uint32_t ways; + + SCB->CSSELR = (0U << 1U) | 0U; /* 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--); + } while(sets--); + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Invalidate by address + \details Invalidates D-Cache for the given address + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_INLINE void SCB_InvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if (__DCACHE_PRESENT == 1U) + int32_t op_size = dsize; + uint32_t op_addr = (uint32_t)addr; + int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ + + __DSB(); + + while (op_size > 0) { + SCB->DCIMVAC = op_addr; + op_addr += linesize; + op_size -= linesize; + } + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Clean by address + \details Cleans D-Cache for the given address + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_INLINE void SCB_CleanDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if (__DCACHE_PRESENT == 1) + int32_t op_size = dsize; + uint32_t op_addr = (uint32_t) addr; + int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ + + __DSB(); + + while (op_size > 0) { + SCB->DCCMVAC = op_addr; + op_addr += linesize; + op_size -= linesize; + } + + __DSB(); + __ISB(); + #endif +} + + +/** + \brief D-Cache Clean and Invalidate by address + \details Cleans and invalidates D_Cache for the given address + \param[in] addr address (aligned to 32-byte boundary) + \param[in] dsize size of memory block (in number of bytes) +*/ +__STATIC_INLINE void SCB_CleanInvalidateDCache_by_Addr (uint32_t *addr, int32_t dsize) +{ + #if (__DCACHE_PRESENT == 1U) + int32_t op_size = dsize; + uint32_t op_addr = (uint32_t) addr; + int32_t linesize = 32U; /* in Cortex-M7 size of cache line is fixed to 8 words (32 bytes) */ + + __DSB(); + + while (op_size > 0) { + SCB->DCCIMVAC = op_addr; + op_addr += linesize; + op_size -= linesize; + } + + __DSB(); + __ISB(); + #endif +} + + +/*@} end of CMSIS_Core_CacheFunctions */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__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 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/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmFunc.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmFunc.h new file mode 100644 index 0000000000000000000000000000000000000000..652a48af07a93d9a48ea9bfa818eebd6429045da --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmFunc.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * @file core_cmFunc.h + * @brief CMSIS Cortex-M Core Function Access Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CMFUNC_H +#define __CORE_CMFUNC_H + + +/* ########################### Core Function Access ########################### */ +/** \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions + @{ +*/ + +/*------------------ RealView Compiler -----------------*/ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + +/*------------------ ARM Compiler V6 -------------------*/ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #include "cmsis_armcc_V6.h" + +/*------------------ GNU Compiler ----------------------*/ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + +/*------------------ ICC Compiler ----------------------*/ +#elif defined ( __ICCARM__ ) + #include + +/*------------------ TI CCS Compiler -------------------*/ +#elif defined ( __TMS470__ ) + #include + +/*------------------ 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. + */ + +/*------------------ COSMIC Compiler -------------------*/ +#elif defined ( __CSMC__ ) + #include + +#endif + +/*@} end of CMSIS_Core_RegAccFunctions */ + +#endif /* __CORE_CMFUNC_H */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmInstr.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmInstr.h new file mode 100644 index 0000000000000000000000000000000000000000..f474b0e6f362c73223e59af36ad30d2b87b9a61d --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmInstr.h @@ -0,0 +1,87 @@ +/**************************************************************************//** + * @file core_cmInstr.h + * @brief CMSIS Cortex-M Core Instruction Access Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CMINSTR_H +#define __CORE_CMINSTR_H + + +/* ########################## Core Instruction Access ######################### */ +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface + Access to dedicated instructions + @{ +*/ + +/*------------------ RealView Compiler -----------------*/ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + +/*------------------ ARM Compiler V6 -------------------*/ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #include "cmsis_armcc_V6.h" + +/*------------------ GNU Compiler ----------------------*/ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + +/*------------------ ICC Compiler ----------------------*/ +#elif defined ( __ICCARM__ ) + #include + +/*------------------ TI CCS Compiler -------------------*/ +#elif defined ( __TMS470__ ) + #include + +/*------------------ 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. + */ + +/*------------------ COSMIC Compiler -------------------*/ +#elif defined ( __CSMC__ ) + #include + +#endif + +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ + +#endif /* __CORE_CMINSTR_H */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmSimd.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmSimd.h new file mode 100644 index 0000000000000000000000000000000000000000..66bf5c2a725b6d1986ce32f2bd765ebe5aa481ea --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_cmSimd.h @@ -0,0 +1,96 @@ +/**************************************************************************//** + * @file core_cmSimd.h + * @brief CMSIS Cortex-M SIMD Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang system_header /* treat file as system include file */ +#endif + +#ifndef __CORE_CMSIMD_H +#define __CORE_CMSIMD_H + +#ifdef __cplusplus + extern "C" { +#endif + + +/* ################### Compiler specific Intrinsics ########################### */ +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics + Access to dedicated SIMD instructions + @{ +*/ + +/*------------------ RealView Compiler -----------------*/ +#if defined ( __CC_ARM ) + #include "cmsis_armcc.h" + +/*------------------ ARM Compiler V6 -------------------*/ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #include "cmsis_armcc_V6.h" + +/*------------------ GNU Compiler ----------------------*/ +#elif defined ( __GNUC__ ) + #include "cmsis_gcc.h" + +/*------------------ ICC Compiler ----------------------*/ +#elif defined ( __ICCARM__ ) + #include + +/*------------------ TI CCS Compiler -------------------*/ +#elif defined ( __TMS470__ ) + #include + +/*------------------ 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. + */ + +/*------------------ COSMIC Compiler -------------------*/ +#elif defined ( __CSMC__ ) + #include + +#endif + +/*@} end of group CMSIS_SIMD_intrinsics */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __CORE_CMSIMD_H */ diff --git a/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_sc000.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_sc000.h new file mode 100644 index 0000000000000000000000000000000000000000..514dbd81b9f776af5e0f29e65d075866c05a4b5a --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_sc000.h @@ -0,0 +1,926 @@ +/**************************************************************************//** + * @file core_sc000.h + * @brief CMSIS SC000 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #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 + @{ + */ + +/* CMSIS SC000 definitions */ +#define __SC000_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __SC000_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \ + __SC000_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_SC (000U) /*!< Cortex secure core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __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_PCS_VFP + #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 ( __TMS470__ ) + #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 "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#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 __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 (__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. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((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. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((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 SC000 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 (__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. + @{ + */ + +/* Interrupt Priorities are WORD accessible only under ARMv6M */ +/* 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 External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + 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))); + } + else + { + 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))); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \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)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS))); + } +} + + +/** + \brief System Reset + \details Initiates a system reset request to reset the MCU. + */ +__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 */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__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/nuvoton_nuc472/Libraries/CMSIS/Include/core_sc300.h b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_sc300.h new file mode 100644 index 0000000000000000000000000000000000000000..8bd18aa318a982b66863b4e413672eed272d2657 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/Include/core_sc300.h @@ -0,0 +1,1745 @@ +/**************************************************************************//** + * @file core_sc300.h + * @brief CMSIS SC300 Core Peripheral Access Layer Header File + * @version V4.30 + * @date 20. October 2015 + ******************************************************************************/ +/* Copyright (c) 2009 - 2015 ARM LIMITED + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of ARM nor the names of its contributors may be used + to endorse or promote products derived from this software without + specific prior written permission. + * + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + ---------------------------------------------------------------------------*/ + + +#if defined ( __ICCARM__ ) + #pragma system_include /* treat file as system include file for MISRA check */ +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #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 + @{ + */ + +/* CMSIS SC300 definitions */ +#define __SC300_CMSIS_VERSION_MAIN (0x04U) /*!< [31:16] CMSIS HAL main version */ +#define __SC300_CMSIS_VERSION_SUB (0x1EU) /*!< [15:0] CMSIS HAL sub version */ +#define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16U) | \ + __SC300_CMSIS_VERSION_SUB ) /*!< CMSIS HAL version number */ + +#define __CORTEX_SC (300U) /*!< Cortex secure core */ + + +#if defined ( __CC_ARM ) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #define __ASM __asm /*!< asm keyword for ARM Compiler */ + #define __INLINE __inline /*!< inline keyword for ARM Compiler */ + #define __STATIC_INLINE static __inline + +#elif defined ( __GNUC__ ) + #define __ASM __asm /*!< asm keyword for GNU Compiler */ + #define __INLINE inline /*!< inline keyword for GNU Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __ICCARM__ ) + #define __ASM __asm /*!< asm keyword for IAR Compiler */ + #define __INLINE inline /*!< inline keyword for IAR Compiler. Only available in High optimization mode! */ + #define __STATIC_INLINE static inline + +#elif defined ( __TMS470__ ) + #define __ASM __asm /*!< asm keyword for TI CCS Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __TASKING__ ) + #define __ASM __asm /*!< asm keyword for TASKING Compiler */ + #define __INLINE inline /*!< inline keyword for TASKING Compiler */ + #define __STATIC_INLINE static inline + +#elif defined ( __CSMC__ ) + #define __packed + #define __ASM _asm /*!< asm keyword for COSMIC Compiler */ + #define __INLINE inline /*!< inline keyword for COSMIC Compiler. Use -pc99 on compile line */ + #define __STATIC_INLINE static inline + +#else + #error Unknown compiler +#endif + +/** __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_PCS_VFP + #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 ( __TMS470__ ) + #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 "core_cmInstr.h" /* Core Instruction Access */ +#include "core_cmFunc.h" /* Core Function Access */ + +#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 __NVIC_PRIO_BITS + #define __NVIC_PRIO_BITS 4U + #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:15; /*!< bit: 9..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_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 RSERVED1[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 */ + +/* 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 */ + uint32_t RESERVED1[1U]; +} 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[29U]; + __OM uint32_t IWR; /*!< Offset: 0xEF8 ( /W) ITM Integration Write Register */ + __IM uint32_t IRR; /*!< Offset: 0xEFC (R/ ) ITM Integration Read Register */ + __IOM uint32_t IMCR; /*!< Offset: 0xF00 (R/W) ITM Integration Mode Control Register */ + 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 Integration Write Register Definitions */ +#define ITM_IWR_ATVALIDM_Pos 0U /*!< ITM IWR: ATVALIDM Position */ +#define ITM_IWR_ATVALIDM_Msk (1UL /*<< ITM_IWR_ATVALIDM_Pos*/) /*!< ITM IWR: ATVALIDM Mask */ + +/* ITM Integration Read Register Definitions */ +#define ITM_IRR_ATREADYM_Pos 0U /*!< ITM IRR: ATREADYM Position */ +#define ITM_IRR_ATREADYM_Msk (1UL /*<< ITM_IRR_ATREADYM_Pos*/) /*!< ITM IRR: ATREADYM Mask */ + +/* ITM Integration Mode Control Register Definitions */ +#define ITM_IMCR_INTEGRATION_Pos 0U /*!< ITM IMCR: INTEGRATION Position */ +#define ITM_IMCR_INTEGRATION_Msk (1UL /*<< ITM_IMCR_INTEGRATION_Pos*/) /*!< ITM IMCR: INTEGRATION 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 +{ + __IOM 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 */ + __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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR2: ATREADY Position */ +#define TPI_ITATBCTR2_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR2_ATREADY_Pos*/) /*!< TPI ITATBCTR2: ATREADY 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 (0x3UL << 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 (0x3UL << 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_ATREADY_Pos 0U /*!< TPI ITATBCTR0: ATREADY Position */ +#define TPI_ITATBCTR0_ATREADY_Msk (0x1UL /*<< TPI_ITATBCTR0_ATREADY_Pos*/) /*!< TPI ITATBCTR0: ATREADY Mask */ + +/* TPI Integration Mode Control Register Definitions */ +#define TPI_ITCTRL_Mode_Pos 0U /*!< TPI ITCTRL: Mode Position */ +#define TPI_ITCTRL_Mode_Msk (0x1UL /*<< 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_MajorType_Pos 4U /*!< TPI DEVTYPE: MajorType Position */ +#define TPI_DEVTYPE_MajorType_Msk (0xFUL << TPI_DEVTYPE_MajorType_Pos) /*!< TPI DEVTYPE: MajorType Mask */ + +#define TPI_DEVTYPE_SubType_Pos 0U /*!< TPI DEVTYPE: SubType Position */ +#define TPI_DEVTYPE_SubType_Msk (0xFUL /*<< TPI_DEVTYPE_SubType_Pos*/) /*!< TPI DEVTYPE: SubType Mask */ + +/*@}*/ /* end of group CMSIS_TPI */ + + +#if (__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. + \return Masked and shifted value. +*/ +#define _VAL2FLD(field, value) ((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. + \return Masked and shifted bit field value. +*/ +#define _FLD2VAL(field, value) ((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 Cortex-M3 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 (__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. + @{ + */ + +/** + \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 << 8U) ); /* Insert write key and priorty 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 External Interrupt + \details Enables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn) +{ + NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Disable External Interrupt + \details Disables a device-specific interrupt in the NVIC interrupt controller. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn) +{ + NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Pending Interrupt + \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not pending. + \return 1 Interrupt status is pending. + */ +__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Pending Interrupt + \details Sets the pending bit of an external interrupt. + \param [in] IRQn Interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Clear Pending Interrupt + \details Clears the pending bit of an external interrupt. + \param [in] IRQn External interrupt number. Value cannot be negative. + */ +__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn) +{ + NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)); +} + + +/** + \brief Get Active Interrupt + \details Reads the active register in NVIC and returns the active bit. + \param [in] IRQn Interrupt number. + \return 0 Interrupt status is not active. + \return 1 Interrupt status is active. + */ +__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn) +{ + return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL)); +} + + +/** + \brief Set Interrupt Priority + \details Sets the priority of an interrupt. + \note The priority cannot be set for every core interrupt. + \param [in] IRQn Interrupt number. + \param [in] priority Priority to set. + */ +__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) +{ + if ((int32_t)(IRQn) < 0) + { + SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } + else + { + NVIC->IP[((uint32_t)(int32_t)IRQn)] = (uint8_t)((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL); + } +} + + +/** + \brief Get Interrupt Priority + \details Reads the priority of an interrupt. + The interrupt number can be positive to specify an external (device specific) interrupt, + or negative to specify an internal (core) interrupt. + \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)SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] >> (8U - __NVIC_PRIO_BITS))); + } + else + { + return(((uint32_t)NVIC->IP[((uint32_t)(int32_t)IRQn)] >> (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 System Reset + \details Initiates a system reset request to reset the MCU. + */ +__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 */ + + + +/* ################################## SysTick function ############################################ */ +/** + \ingroup CMSIS_Core_FunctionInterface + \defgroup CMSIS_Core_SysTickFunctions SysTick Functions + \brief Functions that configure the System. + @{ + */ + +#if (__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 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/nuvoton_nuc472/Libraries/CMSIS/SConscript b/bsp/nuvoton_nuc472/Libraries/CMSIS/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..904fca4146305571f7b12f37102ced3ffb275488 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/CMSIS/SConscript @@ -0,0 +1,16 @@ +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(""" +""") + +path = [cwd + '/Include',] + +group = DefineGroup('CMSIS', src, depend = [''], CPPPATH = path) + +Return('group') diff --git a/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Include/NUC472_442.h b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Include/NUC472_442.h new file mode 100644 index 0000000000000000000000000000000000000000..687ded12b229c90cb59149c29dd65fbf97bb94b8 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Include/NUC472_442.h @@ -0,0 +1,29109 @@ +/**************************************************************************//** + * @file NUC472_442.h + * @version V1.00 + * $Revision: 173 $ + * $Date: 16/06/07 11:24a $ + * @brief NUC472/NUC442 peripheral access layer header file. + * This file contains all the peripheral register's definitions, + * bits definitions and memory mapping for NuMicro NUC472/NUC442 MCU. + * @note + * Copyright (C) 2017 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +/** + \mainpage NuMicro NUC472/NUC442 MCU Driver Reference Guide + * + * Introduction + * + * This user manual describes the usage of NUC472/NUC442 MCU device driver + * + * Disclaimer + * + * The Software is furnished "AS IS", without warranty as to performance or results, and + * the entire risk as to performance or results is assumed by YOU. Nuvoton disclaims all + * warranties, express, implied or otherwise, with regard to the Software, its use, or + * operation, including without limitation any and all warranties of merchantability, fitness + * for a particular purpose, and non-infringement of intellectual property rights. + * + * Important Notice + * + * Nuvoton Products are neither intended nor warranted for usage in systems or equipment, + * any malfunction or failure of which may cause loss of human life, bodily injury or severe + * property damage. Such applications are deemed, "Insecure Usage". + * + * Insecure usage includes, but is not limited to: equipment for surgical implementation, + * atomic energy control instruments, airplane or spaceship instruments, the control or + * operation of dynamic, brake or safety systems designed for vehicular use, traffic signal + * instruments, all types of safety devices, and other applications intended to support or + * sustain life. + * + * All Insecure Usage shall be made at customer's risk, and in the event that third parties + * lay claims to Nuvoton as a result of customer's Insecure Usage, customer shall indemnify + * the damages and liabilities thus incurred by Nuvoton. + * + * Please note that all data and specifications are subject to change without notice. All the + * trademarks of products and companies mentioned in this document belong to their respective + * owners. + * + * Copyright Notice + * + * Copyright (C) 2015~2017 Nuvoton Technology Corp. All rights reserved. + */ + +#ifndef __NUC472_442_H__ +#define __NUC472_442_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/******************************************************************************/ +/* Processor and Core Peripherals */ +/******************************************************************************/ +/** @addtogroup NUC472_442_CMSIS NUC472/NUC442 Device CMSIS Definitions + Configuration of the Cortex-M4 Processor and Core Peripherals + @{ +*/ + +/** + * @details Interrupt Number Definition. + */ +typedef enum IRQn { + /****** Cortex-M4 Processor Exceptions Numbers ***************************************************/ + NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable 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 */ + + /****** NUC472/NUC442 Specific Interrupt Numbers ********************************************************/ + + BOD_IRQn = 0, /*!< Brown Out detection Interrupt */ + IRC_IRQn = 1, /*!< Internal RC Interrupt */ + PWRWU_IRQn = 2, /*!< Power Down Wake Up Interrupt */ + SRAMF_IRQn = 3, /*!< SRAM Parity Check Failed Interrupt */ + CLKF_IRQn = 4, /*!< Clock Detection Failed Interrupt */ + RTC_IRQn = 6, /*!< Real Time Clock Interrupt */ + TAMPER_IRQn = 7, /*!< Tamper detection Interrupt */ + EINT0_IRQn = 8, /*!< External Input 0 Interrupt */ + EINT1_IRQn = 9, /*!< External Input 1 Interrupt */ + EINT2_IRQn = 10, /*!< External Input 2 Interrupt */ + EINT3_IRQn = 11, /*!< External Input 3 Interrupt */ + EINT4_IRQn = 12, /*!< External Input 4 Interrupt */ + EINT5_IRQn = 13, /*!< External Input 5 Interrupt */ + EINT6_IRQn = 14, /*!< External Input 6 Interrupt */ + EINT7_IRQn = 15, /*!< External Input 7 Interrupt */ + GPA_IRQn = 16, /*!< GPIO Port A Interrupt */ + GPB_IRQn = 17, /*!< GPIO Port B Interrupt */ + GPC_IRQn = 18, /*!< GPIO Port C Interrupt */ + GPD_IRQn = 19, /*!< GPIO Port D Interrupt */ + GPE_IRQn = 20, /*!< GPIO Port E Interrupt */ + GPF_IRQn = 21, /*!< GPIO Port F Interrupt */ + GPG_IRQn = 22, /*!< GPIO Port G Interrupt */ + GPH_IRQn = 23, /*!< GPIO Port H Interrupt */ + GPI_IRQn = 24, /*!< GPIO Port I Interrupt */ + TMR0_IRQn = 32, /*!< Timer 0 Interrupt */ + TMR1_IRQn = 33, /*!< Timer 1 Interrupt */ + TMR2_IRQn = 34, /*!< Timer 2 Interrupt */ + TMR3_IRQn = 35, /*!< Timer 3 Interrupt */ + PDMA_IRQn = 40, /*!< Peripheral DMA Interrupt */ + ADC_IRQn = 42, /*!< ADC Interrupt */ + WDT_IRQn = 46, /*!< Watch Dog Timer Interrupt */ + WWDT_IRQn = 47, /*!< Window Watch Dog Timer Interrupt */ + EADC0_IRQn = 48, /*!< Enhanced ADC 0 Interrupt */ + EADC1_IRQn = 49, /*!< Enhanced ADC 1 Interrupt */ + EADC2_IRQn = 50, /*!< Enhanced ADC 2 Interrupt */ + EADC3_IRQn = 51, /*!< Enhanced ADC 3 Interrupt */ + ACMP_IRQn = 56, /*!< Analog Comparator Interrupt */ + OPA0_IRQn = 60, /*!< OPA 0 Interrupt */ + OPA1_IRQn = 61, /*!< OPA 1 Interrupt */ + ICAP0_IRQn = 62, /*!< Input Capture 0 Interrupt */ + ICAP1_IRQn = 63, /*!< Input Capture 1 Interrupt */ + PWM0CH0_IRQn = 64, /*!< PWM 0 Channel 0 Interrupt */ + PWM0CH1_IRQn = 65, /*!< PWM 0 Channel 1 Interrupt */ + PWM0CH2_IRQn = 66, /*!< PWM 0 Channel 2 Interrupt */ + PWM0CH3_IRQn = 67, /*!< PWM 0 Channel 3 Interrupt */ + PWM0CH4_IRQn = 68, /*!< PWM 0 Channel 4 Interrupt */ + PWM0CH5_IRQn = 69, /*!< PWM 0 Channel 5 Interrupt */ + PWM0_BRK_IRQn = 70, /*!< PWM 0 Brake Interrupt */ + QEI0_IRQn = 71, /*!< QEI 0 Interrupt */ + PWM1CH0_IRQn = 72, /*!< PWM 1 Channel 0 Interrupt */ + PWM1CH1_IRQn = 73, /*!< PWM 1 Channel 1 Interrupt */ + PWM1CH2_IRQn = 74, /*!< PWM 1 Channel 2 Interrupt */ + PWM1CH3_IRQn = 75, /*!< PWM 1 Channel 3 Interrupt */ + PWM1CH4_IRQn = 76, /*!< PWM 1 Channel 4 Interrupt */ + PWM1CH5_IRQn = 77, /*!< PWM 1 Channel 5 Interrupt */ + PWM1BRK_IRQn = 78, /*!< PWM 1 Brake Interrupt */ + QEI1_IRQn = 79, /*!< QEI 1 Interrupt */ + EPWM0_IRQn = 80, /*!< Enhanced PWM 0 Interrupt */ + EPWM0BRK_IRQn = 81, /*!< Enhanced PWM 0 Brake Interrupt */ + EPWM1_IRQn = 82, /*!< Enhanced PWM 1 Interrupt */ + EPWM1BRK_IRQn = 83, /*!< Enhanced PWM 1 Brake Interrupt */ + USBD_IRQn = 88, /*!< USB FS Device Interrupt */ + USBH_IRQn = 89, /*!< USB FS Host Interrupt */ + USB_OTG_IRQn = 90, /*!< USB OTG Interrupt */ + EMAC_TX_IRQn = 92, /*!< Ethernet MAC TX Interrupt */ + EMAC_RX_IRQn = 93, /*!< Ethernet MAC RX Interrupt */ + SPI0_IRQn = 96, /*!< SPI 0 Interrupt */ + SPI1_IRQn = 97, /*!< SPI 1 Interrupt */ + SPI2_IRQn = 98, /*!< SPI 2 Interrupt */ + SPI3_IRQn = 99, /*!< SPI 3 Interrupt */ + UART0_IRQn = 104, /*!< UART 0 Interrupt */ + UART1_IRQn = 105, /*!< UART 1 Interrupt */ + UART2_IRQn = 106, /*!< UART 2 Interrupt */ + UART3_IRQn = 107, /*!< UART 3 Interrupt */ + UART4_IRQn = 108, /*!< UART 4 Interrupt */ + UART5_IRQn = 109, /*!< UART 5 Interrupt */ + I2C0_IRQn = 112, /*!< I2C 0 Interrupt */ + I2C1_IRQn = 113, /*!< I2C 1 Interrupt */ + I2C2_IRQn = 114, /*!< I2C 2 Interrupt */ + I2C3_IRQn = 115, /*!< I2C 3 Interrupt */ + I2C4_IRQn = 116, /*!< I2C 4 Interrupt */ + SC0_IRQn = 120, /*!< Smart Card 0 Interrupt */ + SC1_IRQn = 121, /*!< Smart Card 1 Interrupt */ + SC2_IRQn = 122, /*!< Smart Card 2 Interrupt */ + SC3_IRQn = 123, /*!< Smart Card 3 Interrupt */ + SC4_IRQn = 124, /*!< Smart Card 4 Interrupt */ + SC5_IRQn = 125, /*!< Smart Card 5 Interrupt */ + CAN0_IRQn = 128, /*!< CAN 0 Interrupt */ + CAN1_IRQn = 129, /*!< CAN 1 Interrupt */ + I2S0_IRQn = 132, /*!< I2S 0 Interrupt */ + I2S1_IRQn = 133, /*!< I2S 1 Interrupt */ + SD_IRQn = 136, /*!< SD Host Interrupt */ + PS2D_IRQn = 138, /*!< PS/2 device Interrupt */ + CAP_IRQn = 139, /*!< VCAP Interrupt */ + CRPT_IRQn = 140, /*!< Cryptographic Accelerator Interrupt */ + CRC_IRQn = 141, /*!< CRC Interrupt */ +} +IRQn_Type; + + +/* + * ========================================================================== + * ----------- Processor and Core Peripheral Section ------------------------ + * ========================================================================== + */ + +/* Configuration of the Cortex-M# Processor and Core Peripherals */ +#define __CM4_REV 0x0201 /*!< Core Revision r2p1 */ +#define __NVIC_PRIO_BITS 4 /*!< Number of Bits used for Priority Levels */ +#define __Vendor_SysTickConfig 0 /*!< Set to 1 if different SysTick Config is used */ +#define __MPU_PRESENT 1 /*!< MPU present or not */ +#define __FPU_PRESENT 1 /*!< FPU present or not */ + +/*@}*/ /* end of group NUC472_442_CMSIS */ + + +#include "core_cm4.h" /* Cortex-M4 processor and core peripherals */ +#include "system_NUC472_442.h" /* NUC472/NUC442 System include file */ +#include + +/******************************************************************************/ +/* Device Specific Peripheral registers structures */ +/******************************************************************************/ +/** @addtogroup NUC472_442_Peripherals NUC472/NUC442 Control Register + NUC472/NUC442 Device Specific Peripheral registers structures + @{ +*/ + +#if defined ( __CC_ARM ) +#pragma anon_unions +#endif + + +/*---------------------- Analog Comparator Controller -------------------------*/ +/** + @addtogroup ACMP Analog Comparator Controller(ACMP) + Memory Mapped Structure for ACMP Controller +@{ */ + +typedef struct { + + + /** + * CTL0, CTL1, CTL2 + * =================================================================================================== + * Offset: 0x00~0x08 Analog Comparator 0/1/2 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ACMPEN |Comparator x Enable Control + * | | |0 = Comparator x Disabled. + * | | |1 = Comparator x Enabled. + * | | |Note: The comparator output needs to wait 2 us stable time after ACMPEN is set. + * |[1] |ACMPIE |Comparator x Interrupt Enable Control + * | | |0 = Comparator x interrupt Disabled. + * | | |1 = Comparator x interrupt Enabled. + * |[2] |HYSEN |Comparator x Hysteresis Enable Control + * | | |0 = Comparator x hysteresis Disabled (Default). + * | | |1 = Comparator x hysteresis Enabled (typical range is 20 mV). + * |[3] |ACMPOINV |Comparator x Output Inverse + * | | |0 = Comparator x output inverse Disabled. + * | | |1 = Comparator x output inverse Enabled. + * |[4] |NEGSEL |Comparator x Negative Input Selection + * | | |0 = The source of comparator x negative input is from ACMP0_N pin. + * | | |1 = The internal comparator reference voltage (Band-gap voltage or CRV) is selected as the source of comparator x negative input. + * |[5:7] |POSSEL |Comparator x Positive Input Selection + * | | |000= Input from ACMPx_P0. + * | | |001= Input from ACMPx_P1. + * | | |010= Input from ACMPx_P2. + * | | |011= Input from ACMPx_P3. + * | | |100= Input from OPA0x. (Reserved for ACMP2) + * | | |The other options are reserved. + */ + __IO uint32_t CTL[3]; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x0C Analog Comparator Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ACMPIF0 |Comparator 0 Flag + * | | |This bit is set by hardware whenever the comparator 0 output changes state. + * | | |This will cause an interrupt if ACMP_CTL0[1] is set to 1. + * | | |Write 1 to clear this bit to 0. + * |[1] |ACMPIF1 |Comparator 1 Flag + * | | |This bit is set by hardware whenever the comparator 1 output changes state. + * | | |This will cause an interrupt if ACMP_CTL1[1] is set to 1. + * | | |Write 1 to clear this bit to 0. + * |[2] |ACMPIF2 |Comparator 2 Flag + * | | |This bit is set by hardware whenever the comparator 2 output changes state. + * | | |This will cause an interrupt if ACMP_CTL2[1] is set to 1. + * | | |Write 1 to clear this bit to 0. + * |[3] |ACMPO0 |Comparator 0 Output + * | | |Synchronized to the APB clock to allow reading by software. + * | | |Cleared when the comparator 0 is disabled (ACMP_CTL0[0] = 0). + * |[4] |ACMPO1 |Comparator 1 Output + * | | |Synchronized to the APB clock to allow reading by software. + * | | |Cleared when the comparator 1 is disabled (ACMP_CTL1[0] = 0). + * |[5] |ACMPO2 |Comparator 2 Output + * | | |Synchronized to the APB clock to allow reading by software. + * | | |Cleared when the comparator 2 is disabled (ACMP_CTL2[0] = 0). + */ + __IO uint32_t STATUS; + + /** + * VREF + * =================================================================================================== + * Offset: 0x10 Analog Comparator Reference Voltage Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CRVCTL |Comparator Reference Voltage Setting + * | | |CRV = CRV source voltage * (1/6+VREF[3:0]/24). + * |[6] |CRVSSEL |CRV Source Voltage Selection + * | | |0 = VDDA is selected as CRV source voltage. + * | | |1 = Internal reference voltage is selected as CRV source voltage. + * |[7] |IREFSEL |Internal Reference Selection + * | | |0 = Band-gap voltage is selected as internal reference. + * | | |1 = CRV is selected as internal reference. + */ + __IO uint32_t VREF; + +} ACMP_T; + +/** + @addtogroup ACMP_CONST ACMP Bit Field Definition + Constant Definitions for ACMP Controller +@{ */ + +#define ACMP_CTL_ACMPEN_Pos (0) /*!< ACMP_T::CTL: ACMPEN Position */ +#define ACMP_CTL_ACMPEN_Msk (0x1ul << ACMP_CTL_ACMPEN_Pos) /*!< ACMP_T::CTL: ACMPEN Mask */ + +#define ACMP_CTL_ACMPIE_Pos (1) /*!< ACMP_T::CTL: ACMPIE Position */ +#define ACMP_CTL_ACMPIE_Msk (0x1ul << ACMP_CTL_ACMPIE_Pos) /*!< ACMP_T::CTL: ACMPIE Mask */ + +#define ACMP_CTL_HYSEN_Pos (2) /*!< ACMP_T::CTL: HYSEN Position */ +#define ACMP_CTL_HYSEN_Msk (0x1ul << ACMP_CTL_HYSEN_Pos) /*!< ACMP_T::CTL: HYSEN Mask */ + +#define ACMP_CTL_ACMPOINV_Pos (3) /*!< ACMP_T::CTL: ACMPOINV Position */ +#define ACMP_CTL_ACMPOINV_Msk (0x1ul << ACMP_CTL_ACMPOINV_Pos) /*!< ACMP_T::CTL: ACMPOINV Mask */ + +#define ACMP_CTL_NEGSEL_Pos (4) /*!< ACMP_T::CTL: NEGSEL Position */ +#define ACMP_CTL_NEGSEL_Msk (0x1ul << ACMP_CTL_NEGSEL_Pos) /*!< ACMP_T::CTL: NEGSEL Mask */ + +#define ACMP_CTL_POSSEL_Pos (5) /*!< ACMP_T::CTL: POSSEL Position */ +#define ACMP_CTL_POSSEL_Msk (0x7ul << ACMP_CTL_POSSEL_Pos) /*!< ACMP_T::CTL: POSSEL Mask */ + +#define ACMP_STATUS_ACMPIF0_Pos (0) /*!< ACMP_T::STATUS: ACMPIF0 Position */ +#define ACMP_STATUS_ACMPIF0_Msk (0x1ul << ACMP_STATUS_ACMPIF0_Pos) /*!< ACMP_T::STATUS: ACMPIF0 Mask */ + +#define ACMP_STATUS_ACMPIF1_Pos (1) /*!< ACMP_T::STATUS: ACMPIF1 Position */ +#define ACMP_STATUS_ACMPIF1_Msk (0x1ul << ACMP_STATUS_ACMPIF1_Pos) /*!< ACMP_T::STATUS: ACMPIF1 Mask */ + +#define ACMP_STATUS_ACMPIF2_Pos (2) /*!< ACMP_T::STATUS: ACMPIF2 Position */ +#define ACMP_STATUS_ACMPIF2_Msk (0x1ul << ACMP_STATUS_ACMPIF2_Pos) /*!< ACMP_T::STATUS: ACMPIF2 Mask */ + +#define ACMP_STATUS_ACMPO0_Pos (3) /*!< ACMP_T::STATUS: ACMPO0 Position */ +#define ACMP_STATUS_ACMPO0_Msk (0x1ul << ACMP_STATUS_ACMPO0_Pos) /*!< ACMP_T::STATUS: ACMPO0 Mask */ + +#define ACMP_STATUS_ACMPO1_Pos (4) /*!< ACMP_T::STATUS: ACMPO1 Position */ +#define ACMP_STATUS_ACMPO1_Msk (0x1ul << ACMP_STATUS_ACMPO1_Pos) /*!< ACMP_T::STATUS: ACMPO1 Mask */ + +#define ACMP_STATUS_ACMPO2_Pos (5) /*!< ACMP_T::STATUS: ACMPO2 Position */ +#define ACMP_STATUS_ACMPO2_Msk (0x1ul << ACMP_STATUS_ACMPO2_Pos) /*!< ACMP_T::STATUS: ACMPO2 Mask */ + +#define ACMP_VREF_CRVCTL_Pos (0) /*!< ACMP_T::VREF: CRVCTL Position */ +#define ACMP_VREF_CRVCTL_Msk (0xful << ACMP_VREF_CRVCTL_Pos) /*!< ACMP_T::VREF: CRVCTL Mask */ + +#define ACMP_VREF_CRVSSEL_Pos (6) /*!< ACMP_T::VREF: CRVSSEL Position */ +#define ACMP_VREF_CRVSSEL_Msk (0x1ul << ACMP_VREF_CRVSSEL_Pos) /*!< ACMP_T::VREF: CRVSSEL Mask */ + +#define ACMP_VREF_IREFSEL_Pos (7) /*!< ACMP_T::VREF: IREFSEL Position */ +#define ACMP_VREF_IREFSEL_Msk (0x1ul << ACMP_VREF_IREFSEL_Pos) /*!< ACMP_T::VREF: IREFSEL Mask */ + +/**@}*/ /* ACMP_CONST */ +/**@}*/ /* end of ACMP register group */ + + +/*---------------------- Analog to Digital Converter -------------------------*/ +/** + @addtogroup ADC Analog to Digital Converter(ADC) + Memory Mapped Structure for ADC Controller +@{ */ + +typedef struct { + + + /** + * DAT + * =================================================================================================== + * Offset: 0x00~0x34 ADC Data Register 0~13 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RESULT |A/D Conversion Result + * | | |This field contains conversion result of ADC. + * | | |When DMOF (ADC_CTL[31]) bit is set to 0, 12-bit ADC conversion result with unsigned format will be filled in RESULT[11:0] and zero will be filled in RESULT[15:12]. + * | | |When DMOF (ADC_CTL[31]) bit set to 1, 12-bit ADC conversion result with 2'complement format will be filled in RESULT[11:0] and signed bits to will be filled in RESULT[15:12]. + * |[16] |OV |Overrun Flag (Read Only) + * | | |0 = Data in RESULT (ADC_DATx[15:0]) is recent conversion result. + * | | |1 = Data in RESULT (ADC_DATx[15:0]) is overwrite. + * | | |If converted data in RESULT[15:0] has not been read before new conversion result is loaded to this register, OV is set to 1 and previous conversion result is gone. + * | | |It is cleared by hardware after ADC_DAT register is read. + * |[17] |VALID |Valid Flag (Read Only) + * | | |0 = Data in RESULT (ADC_DATx[15:0]) bits is not valid. + * | | |1 = Data in RESULT (ADC_DATx[15:0]) bits is valid. + * | | |This bit is set to 1 when corresponding channel analog input conversion is completed and cleared by hardware after ADC_DAT register is read. + */ + __I uint32_t DAT[14]; + + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[2]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * CTL + * =================================================================================================== + * Offset: 0x40 ADC Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ADCEN |ADC Enable Control + * | | |0 = ADC analog circuit Disabled. + * | | |1 = ADC analog circuit Enabled. + * | | |Before disabling ADC clock, this bit should be cleared to 0 by software. + * |[1] |ADCIEN |ADC Interrupt Enable Control + * | | |0 = ADC interrupt function Disabled. + * | | |1 = ADC interrupt function Enabled. + * | | |A/D conversion end interrupt request is generated if ADCIEN (ADC_CTL[1]) bit is set to 1. + * |[2:3] |OPMODE |ADC Operation Mode + * | | |00 = Single conversion. + * | | |01 = Reserved. + * | | |10 = Single-cycle scan. + * | | |11 = Continuous scan. + * | | |When changing the operation mode, software should disable SWTRG (ADC_CTL[11]) bit firstly. + * |[4:5] |HWTRGSEL |External Hardware Trigger Source + * | | |00 = A/D conversion is started by external pin (STADC). + * | | |01 = Reserved. + * | | |10 = Reserved. + * | | |11 = PWM0 or PWM1 trigger condition is matched. + * | | |Software should disable HWTRGCOND (ADC_CTL[8]) and SWTRG (ADC_CTL[11]) before changing HWTRGSEL (ADC_CTL[5:4]). + * | | |In hardware trigger mode, the SWTRG (ADC_CTL[11]) bit is set by hardware trigger source. + * |[6:7] |HWTRGCOND |External Pin Trigger Conditions + * | | |These two bits decide external pin (STADC) trigger event. + * | | |The signal must be kept at stable state at least 8 system clocks for level trigger and 4 system clocks at high and low state for edge trigger. + * | | |00 = Low level. + * | | |01 = High level. + * | | |10 = Falling edge. + * | | |11 = Rising edge. + * |[8] |HWTRGEN |External Hardware Trigger Enable Control + * | | |Enable or disable hardware triggering of A/D conversion. + * | | |The hardware trigger source include external pin (STADC) or PWM trigger which is controlled by HWTRGSEL (ADC_CTL[5:4]) register. + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |ADC hardware trigger function is only supported in single-cycle scan mode. + * |[9] |PDMAEN |PDMA Transfer Enable Control + * | | |0 = PDMA data transfer Disabled. + * | | |1 = PDMA data transfer in ADC_DATx Enabled. + * | | |When A/D conversion is completed, the converted data is loaded into ADC_DATx, software can enable this bit to generate a PDMA data transfer request. + * | | |When PDMAEN (ADC_CTL[9]) is set to 1, software must set ADCIEN (ADC_CTL[1]) bit to 0 to disable interrupt. + * |[10] |DIFFEN |Differential Input Mode Enable Control + * | | |0 = Single-end analog input mode. + * | | |1 = Differential analog input mode. + * | | |The A/D analog input ADC0_CH0/ADC0_CH1 consists of a differential pair. + * | | |So as ADC0_CH2/ADC0_CH3, ADC0_CH4/ADC0_CH5, ADC0_CH6/ADC0_CH7, ADC0_CH8/ADC0_CH9 and ADC0_CH10/ADC0_CH11. + * | | |The even channel defines as plus analog input voltage (Vplus) and the odd channel defines as minus analog input voltage (Vminus). + * | | |Differential input voltage (Vdiff) = Vplus - Vminus, where Vplus + * | | |is the analog input; Vminus is the inverted analog input. + * | | |In differential input mode, only the even number of the two corresponding channels needs to be enabled in ADCHER (ADC_CHEN[11:0]). + * | | |The conversion result will be placed to the corresponding data register of the enabled channel. + * |[11] |SWTRG |A/D Conversion Start + * | | |0 = Conversion stopped and A/D converter enter idle state. + * | | |1 = Conversion start. + * | | |The SWTRG (ADC_CTL[11]) bit can be set to 1 from two sources: software and hardware trigger. + * | | |The SWTRG (ADC_CTL[11]) bit will be cleared to 0 by hardware automatically at the ends of single mode and single-cycle scan mode. + * | | |In continuous scan mode, A/D conversion is continuously performed until software write 0 to this bit or chip reset. + * |[16:23] |PWMTRGDLY |PWM Trigger Delay Time + * | | |Setting this field will delay ADC start conversion time after PWM trigger comes. + * | | |PWM trigger delay time is 4 * system clock * PWMTRGDLY (ADC_CTL[23:16]) + * |[31] |DMOF |ADC Differential Input Mode Output Format + * | | |0 = A/D conversion result will be filled in RESULT (ADC_DATx[15:0]) registers with unsigned format. + * | | |1 = A/D conversion result will be filled in RESULT (ADC_DATx[15:0]) registers with 2'complement format. + */ + __IO uint32_t CTL; + + /** + * CHEN + * =================================================================================================== + * Offset: 0x44 ADC Channel Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |CHEN |Analog Input Channel Enable Control + * | | |Set CHEN (ADC_CHEN[11:0]) to enable the corresponding analog input channel (ADC0_CH1 ~ ADC0_CH11). + * | | |If DIFFEN bit is set to 1, only the even number channels need to be enabled. + * | | |0 = ADC input channel Disabled. + * | | |1 = ADC input channel Enabled. + * |[16] |ADTSEN |Internal Temperature Sensor Selection + * | | |0 = Internal temperature sensor is not selected to be the analog input source of ADC. + * | | |1 = Internal temperature sensor is selected to be the analog input source of ADC. + * | | |ADC can only work at Single mode when software selects the temperature sensor voltage as the analog input source of ADC + * |[17] |ADBGEN |Internal Band-Gap Selection + * | | |0 = Internal band-gap is not selected to be the analog input source of ADC. + * | | |1 = Internal band-gap is selected to be the analog input source of ADC. + * | | |ADC can only work at Single mode when software selects the band-gap voltage as the analog input source of ADC + */ + __IO uint32_t CHEN; + + /** + * CMP + * =================================================================================================== + * Offset: 0x48 ADC Compare Register 0/1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ADCMPEN |Compare Enable Control + * | | |0 = Compare function Disabled. + * | | |1 = Compare function Enabled. + * | | |Set this bit to 1 to enable ADC controller to compare CMPDAT (ADC_CMPx[27:16]) with the conversion result of the channel specified by CMPCH (ADC_CMPx[6:3]) when the conversion data of the specified channel is loaded into ADC_DATx register. + * |[1] |ADCMPIE |Compare Interrupt Enable Control + * | | |0 = Compare function interrupt Disabled. + * | | |1 = Compare function interrupt Enabled. + * | | |If the compare function is enabled and the compare condition matches the setting of CMPCOND (ADC_CMPx[2]) and CMPMCNT(ADC_CMPx[11:8]), ADCMPFx (ADC_STATUS0[2:1]) bit will be asserted, in the meanwhile, if ADCMPIE (ADC_CMPx[1])is set to 1, a compare interrupt request is generated. + * |[2] |CMPCOND |Compare Condition + * | | |0 = Set the compare condition as that when a 12-bit A/D conversion result is less than the 12-bit CMPDAT (ADC_CMPx[27:16]), the internal match counter will increase one. + * | | |1 = Set the compare condition as that when a 12-bit A/D conversion result is greater or equal to the 12-bit CMPDAT (ADC_CMPx[27:16]), the internal match counter will increase one. + * | | |Note: When the internal counter reaches the value to CMPMCNT (ADC_CMPx[11:8]) + 1, the ADCMPFx (ADC_STATUS0[2:1]) bit will be set. + * |[3:6] |CMPCH |Compare Channel Selection + * | | |0000 = Channel 0 conversion result is selected to be compared. + * | | |0001 = Channel 1 conversion result is selected to be compared. + * | | |0010 = Channel 2 conversion result is selected to be compared. + * | | |0011 = Channel 3 conversion result is selected to be compared. + * | | |0100 = Channel 4 conversion result is selected to be compared. + * | | |0101 = Channel 5 conversion result is selected to be compared. + * | | |0110 = Channel 6 conversion result is selected to be compared. + * | | |0111 = Channel 7 conversion result is selected to be compared. + * | | |1000 = Channel 8 conversion result is selected to be compared. + * | | |1001 = Channel 9 conversion result is selected to be compared. + * | | |1010 = Channel 10 conversion result is selected to be compared. + * | | |1011 = Channel 11 conversion result is selected to be compared. + * | | |1100 = band-gap voltage result is selected to be compared. + * | | |1101 = temperature sensor conversion result is selected to be compared. + * | | |Others = reserved. + * |[8:11] |CMPMCNT |Compare Match Count + * | | |When the specified ADC channel analog conversion result matches the compare condition defined by CMPCOND (ADC_CMPx[2]), the internal match counter will increase 1. + * | | |When the internal counter reaches the value to CMPMCNT (ADC_CMPx[11:8]) + 1, the ADCMPFx (ADC_STATUS0[2:1]) bit will be set. + * |[16:27] |CMPDAT |Compared Data + * | | |When DMOF (ADC_CTL[31]) bit is set to 0, ADC comparator compares CMPDAT (ADC_CTL[27:16]) with conversion result with unsigned format. + * | | |CMPDAT (ADC_CTL[27:16]) should be filled in unsigned format. + * | | |When DMOF (ADC_CTL[31]) bit is set to 1, ADC comparator compares CMPDAT (ADC_CTL[27:16]) with conversion result with 2'complement format. + * | | |CMPDAT (ADC_CTL[27:16]) should be filled in 2'complement format. + */ + __IO uint32_t CMP[2]; + + /** + * STATUS0 + * =================================================================================================== + * Offset: 0x50 ADC Status Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ADIF |ADC Interrupt Flag + * | | |A status flag that indicates the end of A/D conversion. + * | | |ADIF (ADC_STATUS0[0]) is set to 1 at these two conditions: + * | | |1. When A/D conversion ends in Single mode + * | | |2. When A/D conversion ends on all specified channels in Scan mode + * | | |Note: This flag can be cleared by writing 1 to it. + * |[1] |ADCMPF0 |Compare Flag + * | | |When the selected channel A/D conversion result meets setting condition in ADCMPR0 then this bit is set to 1. + * | | |And it is cleared by writing 1 to self. + * | | |0 = Conversion result in ADC_DATx does not meet ADCMPR0 setting. + * | | |1 = Conversion result in ADC_DATx meets ADCMPR0 setting. + * |[2] |ADCMPF1 |Compare Flag + * | | |When the selected channel A/D conversion result meets setting condition in ADCMPR1 then this bit is set to 1. + * | | |And it is cleared by writing 1 to self. + * | | |0 = Conversion result in ADC_DATx does not meet ADCMPR1 setting. + * | | |1 = Conversion result in ADC_DATx meets ADCMPR1 setting. + * |[3] |BUSY |BUSY/IDLE (Read Only) + * | | |0 = ADC is in idle state. + * | | |1 = ADC is doing conversion. + * | | |This bit is mirror of as SWTRG (ADC_CTL[11]) bit. + * |[4:7] |CHANNEL |Current Conversion Channel (Read Only) + * | | |This field reflects the current conversion channel when BUSY (ADC_STATUS0[3]) = 1. + * | | |When BUSY (ADC_STATUS0[3]) = 0, it shows the number of the next converted channel. + */ + __IO uint32_t STATUS0; + + /** + * STATUS1 + * =================================================================================================== + * Offset: 0x54 ADC Status Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:13] |VALID |Data Valid Flag (Read Only) + * | | |It is a mirror of VALID (ADC_DATx[17]) bit. + * |[16:29] |OV |Overrun Flag (Read Only) + * | | |It is a mirror to OV (ADC_DATx[16]) bit. + */ + __I uint32_t STATUS1; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[2]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * CURDAT + * =================================================================================================== + * Offset: 0x60 ADC PDMA Current Transfer Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:17] |CURDAT |ADC PDMA Current Transfer Data Bit (Read Only) + * | | |When PDMA transferring, read this register can monitor current PDMA transfer data. + */ + __I uint32_t CURDAT; + +} ADC_T; + +/** + @addtogroup ADC_CONST ADC Bit Field Definition + Constant Definitions for ADC Controller +@{ */ + +#define ADC_DAT0_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT0_RESULT_Msk (0xfffful << ADC_DAT0_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT0_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT0_OV_Msk (0x1ul << ADC_DAT0_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT0_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT0_VALID_Msk (0x1ul << ADC_DAT0_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT1_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT1_RESULT_Msk (0xfffful << ADC_DAT1_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT1_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT1_OV_Msk (0x1ul << ADC_DAT1_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT1_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT1_VALID_Msk (0x1ul << ADC_DAT1_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT2_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT2_RESULT_Msk (0xfffful << ADC_DAT2_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT2_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT2_OV_Msk (0x1ul << ADC_DAT2_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT2_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT2_VALID_Msk (0x1ul << ADC_DAT2_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT3_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT3_RESULT_Msk (0xfffful << ADC_DAT3_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT3_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT3_OV_Msk (0x1ul << ADC_DAT3_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT3_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT3_VALID_Msk (0x1ul << ADC_DAT3_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT4_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT4_RESULT_Msk (0xfffful << ADC_DAT4_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT4_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT4_OV_Msk (0x1ul << ADC_DAT4_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT4_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT4_VALID_Msk (0x1ul << ADC_DAT4_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT5_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT5_RESULT_Msk (0xfffful << ADC_DAT5_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT5_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT5_OV_Msk (0x1ul << ADC_DAT5_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT5_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT5_VALID_Msk (0x1ul << ADC_DAT5_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT6_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT6_RESULT_Msk (0xfffful << ADC_DAT6_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT6_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT6_OV_Msk (0x1ul << ADC_DAT6_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT6_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT6_VALID_Msk (0x1ul << ADC_DAT6_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT7_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT7_RESULT_Msk (0xfffful << ADC_DAT7_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT7_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT7_OV_Msk (0x1ul << ADC_DAT7_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT7_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT7_VALID_Msk (0x1ul << ADC_DAT7_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT8_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT8_RESULT_Msk (0xfffful << ADC_DAT8_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT8_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT8_OV_Msk (0x1ul << ADC_DAT8_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT8_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT8_VALID_Msk (0x1ul << ADC_DAT8_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT9_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT9_RESULT_Msk (0xfffful << ADC_DAT9_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT9_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT9_OV_Msk (0x1ul << ADC_DAT9_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT9_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT9_VALID_Msk (0x1ul << ADC_DAT9_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT10_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT10_RESULT_Msk (0xfffful << ADC_DAT10_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT10_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT10_OV_Msk (0x1ul << ADC_DAT10_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT10_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT10_VALID_Msk (0x1ul << ADC_DAT10_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT11_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT11_RESULT_Msk (0xfffful << ADC_DAT11_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT11_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT11_OV_Msk (0x1ul << ADC_DAT11_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT11_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT11_VALID_Msk (0x1ul << ADC_DAT11_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT12_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT12_RESULT_Msk (0xfffful << ADC_DAT12_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT12_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT12_OV_Msk (0x1ul << ADC_DAT12_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT12_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT12_VALID_Msk (0x1ul << ADC_DAT12_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_DAT13_RESULT_Pos (0) /*!< ADC_T::DAT: RESULT Position */ +#define ADC_DAT13_RESULT_Msk (0xfffful << ADC_DAT13_RESULT_Pos) /*!< ADC_T::DAT: RESULT Mask */ + +#define ADC_DAT13_OV_Pos (16) /*!< ADC_T::DAT: OV Position */ +#define ADC_DAT13_OV_Msk (0x1ul << ADC_DAT13_OV_Pos) /*!< ADC_T::DAT: OV Mask */ + +#define ADC_DAT13_VALID_Pos (17) /*!< ADC_T::DAT: VALID Position */ +#define ADC_DAT13_VALID_Msk (0x1ul << ADC_DAT13_VALID_Pos) /*!< ADC_T::DAT: VALID Mask */ + +#define ADC_CTL_ADCEN_Pos (0) /*!< ADC_T::CTL: ADCEN Position */ +#define ADC_CTL_ADCEN_Msk (0x1ul << ADC_CTL_ADCEN_Pos) /*!< ADC_T::CTL: ADCEN Mask */ + +#define ADC_CTL_ADCIEN_Pos (1) /*!< ADC_T::CTL: ADCIEN Position */ +#define ADC_CTL_ADCIEN_Msk (0x1ul << ADC_CTL_ADCIEN_Pos) /*!< ADC_T::CTL: ADCIEN Mask */ + +#define ADC_CTL_OPMODE_Pos (2) /*!< ADC_T::CTL: OPMODE Position */ +#define ADC_CTL_OPMODE_Msk (0x3ul << ADC_CTL_OPMODE_Pos) /*!< ADC_T::CTL: OPMODE Mask */ + +#define ADC_CTL_HWTRGSEL_Pos (4) /*!< ADC_T::CTL: HWTRGSEL Position */ +#define ADC_CTL_HWTRGSEL_Msk (0x3ul << ADC_CTL_HWTRGSEL_Pos) /*!< ADC_T::CTL: HWTRGSEL Mask */ + +#define ADC_CTL_HWTRGCOND_Pos (6) /*!< ADC_T::CTL: HWTRGCOND Position */ +#define ADC_CTL_HWTRGCOND_Msk (0x3ul << ADC_CTL_HWTRGCOND_Pos) /*!< ADC_T::CTL: HWTRGCOND Mask */ + +#define ADC_CTL_HWTRGEN_Pos (8) /*!< ADC_T::CTL: HWTRGEN Position */ +#define ADC_CTL_HWTRGEN_Msk (0x1ul << ADC_CTL_HWTRGEN_Pos) /*!< ADC_T::CTL: HWTRGEN Mask */ + +#define ADC_CTL_PDMAEN_Pos (9) /*!< ADC_T::CTL: PDMAEN Position */ +#define ADC_CTL_PDMAEN_Msk (0x1ul << ADC_CTL_PDMAEN_Pos) /*!< ADC_T::CTL: PDMAEN Mask */ + +#define ADC_CTL_DIFFEN_Pos (10) /*!< ADC_T::CTL: DIFFEN Position */ +#define ADC_CTL_DIFFEN_Msk (0x1ul << ADC_CTL_DIFFEN_Pos) /*!< ADC_T::CTL: DIFFEN Mask */ + +#define ADC_CTL_SWTRG_Pos (11) /*!< ADC_T::CTL: SWTRG Position */ +#define ADC_CTL_SWTRG_Msk (0x1ul << ADC_CTL_SWTRG_Pos) /*!< ADC_T::CTL: SWTRG Mask */ + +#define ADC_CTL_PWMTRGDLY_Pos (16) /*!< ADC_T::CTL: PWMTRGDLY Position */ +#define ADC_CTL_PWMTRGDLY_Msk (0xfful << ADC_CTL_PWMTRGDLY_Pos) /*!< ADC_T::CTL: PWMTRGDLY Mask */ + +#define ADC_CTL_DMOF_Pos (31) /*!< ADC_T::CTL: DMOF Position */ +#define ADC_CTL_DMOF_Msk (0x1ul << ADC_CTL_DMOF_Pos) /*!< ADC_T::CTL: DMOF Mask */ + +#define ADC_CHEN_CHEN_Pos (0) /*!< ADC_T::CHEN: CHEN Position */ +#define ADC_CHEN_CHEN_Msk (0xffful << ADC_CHEN_CHEN_Pos) /*!< ADC_T::CHEN: CHEN Mask */ + +#define ADC_CHEN_ADTSEN_Pos (16) /*!< ADC_T::CHEN: ADTSEN Position */ +#define ADC_CHEN_ADTSEN_Msk (0x1ul << ADC_CHEN_ADTSEN_Pos) /*!< ADC_T::CHEN: ADTSEN Mask */ + +#define ADC_CHEN_ADBGEN_Pos (17) /*!< ADC_T::CHEN: ADBGEN Position */ +#define ADC_CHEN_ADBGEN_Msk (0x1ul << ADC_CHEN_ADBGEN_Pos) /*!< ADC_T::CHEN: ADBGEN Mask */ + +#define ADC_CMP0_ADCMPEN_Pos (0) /*!< ADC_T::CMP: ADCMPEN Position */ +#define ADC_CMP0_ADCMPEN_Msk (0x1ul << ADC_CMP0_ADCMPEN_Pos) /*!< ADC_T::CMP: ADCMPEN Mask */ + +#define ADC_CMP0_ADCMPIE_Pos (1) /*!< ADC_T::CMP: ADCMPIE Position */ +#define ADC_CMP0_ADCMPIE_Msk (0x1ul << ADC_CMP0_ADCMPIE_Pos) /*!< ADC_T::CMP: ADCMPIE Mask */ + +#define ADC_CMP0_CMPCOND_Pos (2) /*!< ADC_T::CMP: CMPCOND Position */ +#define ADC_CMP0_CMPCOND_Msk (0x1ul << ADC_CMP0_CMPCOND_Pos) /*!< ADC_T::CMP: CMPCOND Mask */ + +#define ADC_CMP0_CMPCH_Pos (3) /*!< ADC_T::CMP: CMPCH Position */ +#define ADC_CMP0_CMPCH_Msk (0xful << ADC_CMP0_CMPCH_Pos) /*!< ADC_T::CMP: CMPCH Mask */ + +#define ADC_CMP0_CMPMCNT_Pos (8) /*!< ADC_T::CMP: CMPMCNT Position */ +#define ADC_CMP0_CMPMCNT_Msk (0xful << ADC_CMP0_CMPMCNT_Pos) /*!< ADC_T::CMP: CMPMCNT Mask */ + +#define ADC_CMP0_CMPDAT_Pos (16) /*!< ADC_T::CMP: CMPDAT Position */ +#define ADC_CMP0_CMPDAT_Msk (0xffful << ADC_CMP0_CMPDAT_Pos) /*!< ADC_T::CMP: CMPDAT Mask */ + +#define ADC_CMP1_ADCMPEN_Pos (0) /*!< ADC_T::CMP: ADCMPEN Position */ +#define ADC_CMP1_ADCMPEN_Msk (0x1ul << ADC_CMP1_ADCMPEN_Pos) /*!< ADC_T::CMP: ADCMPEN Mask */ + +#define ADC_CMP1_ADCMPIE_Pos (1) /*!< ADC_T::CMP: ADCMPIE Position */ +#define ADC_CMP1_ADCMPIE_Msk (0x1ul << ADC_CMP1_ADCMPIE_Pos) /*!< ADC_T::CMP: ADCMPIE Mask */ + +#define ADC_CMP1_CMPCOND_Pos (2) /*!< ADC_T::CMP: CMPCOND Position */ +#define ADC_CMP1_CMPCOND_Msk (0x1ul << ADC_CMP1_CMPCOND_Pos) /*!< ADC_T::CMP: CMPCOND Mask */ + +#define ADC_CMP1_CMPCH_Pos (3) /*!< ADC_T::CMP: CMPCH Position */ +#define ADC_CMP1_CMPCH_Msk (0xful << ADC_CMP1_CMPCH_Pos) /*!< ADC_T::CMP: CMPCH Mask */ + +#define ADC_CMP1_CMPMCNT_Pos (8) /*!< ADC_T::CMP: CMPMCNT Position */ +#define ADC_CMP1_CMPMCNT_Msk (0xful << ADC_CMP1_CMPMCNT_Pos) /*!< ADC_T::CMP: CMPMCNT Mask */ + +#define ADC_CMP1_CMPDAT_Pos (16) /*!< ADC_T::CMP: CMPDAT Position */ +#define ADC_CMP1_CMPDAT_Msk (0xffful << ADC_CMP1_CMPDAT_Pos) /*!< ADC_T::CMP: CMPDAT Mask */ + +#define ADC_STATUS0_ADIF_Pos (0) /*!< ADC_T::STATUS0: ADIF Position */ +#define ADC_STATUS0_ADIF_Msk (0x1ul << ADC_STATUS0_ADIF_Pos) /*!< ADC_T::STATUS0: ADIF Mask */ + +#define ADC_STATUS0_ADCMPF0_Pos (1) /*!< ADC_T::STATUS0: ADCMPF0 Position */ +#define ADC_STATUS0_ADCMPF0_Msk (0x1ul << ADC_STATUS0_ADCMPF0_Pos) /*!< ADC_T::STATUS0: ADCMPF0 Mask */ + +#define ADC_STATUS0_ADCMPF1_Pos (2) /*!< ADC_T::STATUS0: ADCMPF1 Position */ +#define ADC_STATUS0_ADCMPF1_Msk (0x1ul << ADC_STATUS0_ADCMPF1_Pos) /*!< ADC_T::STATUS0: ADCMPF1 Mask */ + +#define ADC_STATUS0_BUSY_Pos (3) /*!< ADC_T::STATUS0: BUSY Position */ +#define ADC_STATUS0_BUSY_Msk (0x1ul << ADC_STATUS0_BUSY_Pos) /*!< ADC_T::STATUS0: BUSY Mask */ + +#define ADC_STATUS0_CHANNEL_Pos (4) /*!< ADC_T::STATUS0: CHANNEL Position */ +#define ADC_STATUS0_CHANNEL_Msk (0xful << ADC_STATUS0_CHANNEL_Pos) /*!< ADC_T::STATUS0: CHANNEL Mask */ + +#define ADC_STATUS1_VALID_Pos (0) /*!< ADC_T::STATUS1: VALID Position */ +#define ADC_STATUS1_VALID_Msk (0x3ffful << ADC_STATUS1_VALID_Pos) /*!< ADC_T::STATUS1: VALID Mask */ + +#define ADC_STATUS1_OV_Pos (16) /*!< ADC_T::STATUS1: OV Position */ +#define ADC_STATUS1_OV_Msk (0x3ffful << ADC_STATUS1_OV_Pos) /*!< ADC_T::STATUS1: OV Mask */ + +#define ADC_CURDAT_CURDAT_Pos (0) /*!< ADC_T::CURDAT: CURDAT Position */ +#define ADC_CURDAT_CURDAT_Msk (0x3fffful << ADC_CURDAT_CURDAT_Pos) /*!< ADC_T::CURDAT: CURDAT Mask */ + +/**@}*/ /* ADC_CONST */ +/**@}*/ /* end of ADC register group */ + + +/*---------------------- Controller Area Network Controller -------------------------*/ +/** + @addtogroup CAN Controller Area Network Controller(CAN) + Memory Mapped Structure for CAN Controller +@{ */ + +typedef struct { + + /** + * CAN_IFn_CREQ + * =================================================================================================== + * Offset: 0x20, 0x80 IFn (Register Map Note 2) Command Request Registers + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |MessageNumber|Message Number + * | | |0x01-0x20: Valid Message Number, the Message Object in the Message + * | | |RAM is selected for data transfer. + * | | |0x00: Not a valid Message Number, interpreted as 0x20. + * | | |0x21-0x3F: Not a valid Message Number, interpreted as 0x01-0x1F. + * |[15] |Busy |Busy Flag + * | | |0 = Read/write action has finished. + * | | |1 = Writing to the IFn Command Request Register is in progress. + * | | |This bit can only be read by the software. + */ + __IO uint32_t CREQ; + + /** + * CAN_IFn_CMASK + * =================================================================================================== + * Offset: 0x24, 0x84 IFn Command Mask Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DAT_B |Access Data Bytes [7:4] + * | | |Write Operation: + * | | |0 = Data Bytes [7:4] unchanged. + * | | |1 = Transfer Data Bytes [7:4] to Message Object. + * | | |Read Operation: + * | | |0 = Data Bytes [7:4] unchanged. + * | | |1 = Transfer Data Bytes [7:4] to IFn Message Buffer Register. + * |[1] |DAT_A |Access Data Bytes [3:0] + * | | |Write Operation: + * | | |0 = Data Bytes [3:0] unchanged. + * | | |1 = Transfer Data Bytes [3:0] to Message Object. + * | | |Read Operation: + * | | |0 = Data Bytes [3:0] unchanged. + * | | |1 = Transfer Data Bytes [3:0] to IFn Message Buffer Register. + * |[2] |TxRqst_NewDat|Access Transmission Request Bit When Write Operation + * | | |0 = TxRqst bit unchanged. + * | | |1 = Set TxRqst bit. + * | | |Note: If a transmission is requested by programming bit TxRqst/NewDat in the IFn Command Mask Register, bit TxRqst in the IFn Message Control Register will be ignored. + * | | |Access New Data Bit when Read Operation. + * | | |0 = NewDat bit remains unchanged. + * | | |1 = Clear NewDat bit in the Message Object. + * | | |Note: A read access to a Message Object can be combined with the reset of the control bits IntPnd and NewDat. + * | | |The values of these bits transferred to the IFn Message Control Register always reflect the status before resetting these bits. + * |[3] |ClrIntPnd |Clear Interrupt Pending Bit + * | | |Write Operation: + * | | |When writing to a Message Object, this bit is ignored. + * | | |Read Operation: + * | | |0 = IntPnd bit (CAN_IFn_MCON[13]) remains unchanged. + * | | |1 = Clear IntPnd bit in the Message Object. + * |[4] |Control |Control Access Control Bits + * | | |Write Operation: + * | | |0 = Control Bits unchanged. + * | | |1 = Transfer Control Bits to Message Object. + * | | |Read Operation: + * | | |0 = Control Bits unchanged. + * | | |1 = Transfer Control Bits to IFn Message Buffer Register. + * |[5] |Arb |Access Arbitration Bits + * | | |Write Operation: + * | | |0 = Arbitration bits unchanged. + * | | |1 = Transfer Identifier + Dir (CAN_IFn_ARB2[13]) + Xtd (CAN_IFn_ARB2[14]) + MsgVal (CAN_IFn_APB2[15]) to Message Object. + * | | |Read Operation: + * | | |0 = Arbitration bits unchanged. + * | | |1 = Transfer Identifier + Dir + Xtd + MsgVal to IFn Message Buffer Register. + * |[6] |Mask |Access Mask Bits + * | | |Write Operation: + * | | |0 = Mask bits unchanged. + * | | |1 = Transfer Identifier Mask + MDir + MXtd to Message Object. + * | | |Read Operation: + * | | |0 = Mask bits unchanged. + * | | |1 = Transfer Identifier Mask + MDir + MXtd to IFn Message Buffer Register. + * |[7] |WR_RD |Write / Read Mode + * | | |0 = Read: Transfer data from the Message Object addressed by the Command Request Register into the selected Message Buffer Registers. + * | | |1 = Write: Transfer data from the selected Message Buffer Registers to the Message Object addressed by the Command Request Register. + */ + __IO uint32_t CMASK; + + /** + * CAN_IFn_MASK1 + * =================================================================================================== + * Offset: 0x28, 0x88 IFn Mask 1 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |Msk150 |Identifier Mask 15-0 + * | | |0 = The corresponding bit in the identifier of the message object cannot inhibit the match in the acceptance filtering. + * | | |1 = The corresponding identifier bit is used for acceptance filtering. + */ + __IO uint32_t MASK1; + + /** + * CAN_IFn_MASK2 + * =================================================================================================== + * Offset: 0x2C, 0x8C IFn Mask 2 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:12] |Msk2816 |Identifier Mask 28-16 + * | | |0 = The corresponding bit in the identifier of the message object cannot inhibit the match in the acceptance filtering. + * | | |1 = The corresponding identifier bit is used for acceptance filtering. + * |[14] |MDir |Mask Message Direction + * | | |0 = The message direction bit (Dir (CAN_IFn_ARB2[13])) has no effect on the acceptance filtering. + * | | |1 = The message direction bit (Dir) is used for acceptance filtering. + * |[15] |MXtd |Mask Extended Identifier + * | | |0 = The extended identifier bit (IDE) has no effect on the acceptance filtering. + * | | |1 = The extended identifier bit (IDE) is used for acceptance filtering. + * | | |Note: When 11-bit ("standard") Identifiers are used for a Message Object, the identifiers of received Data Frames are written into bits ID28 to ID18 (CAN_IFn_ARB2[12:2]). + * | | |For acceptance filtering, only these bits together with mask bits Msk28 to Msk18 (CAN_IFn_MASK2[12:2]) are considered. + */ + __IO uint32_t MASK2; + + /** + * CAN_IFn_ARB1 + * =================================================================================================== + * Offset: 0x30, 0x90 IFn Arbitration 1 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |ID150 |Message Identifier 15-0 + * | | |ID28 - ID0, 29-bit Identifier ("Extended Frame"). + * | | |ID28 - ID18, 11-bit Identifier ("Standard Frame") + */ + __IO uint32_t ARB1; + + /** + * CAN_IFn_ARB2 + * =================================================================================================== + * Offset: 0x34, 0x94 IFn Arbitration 2 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:12] |ID2816 |Message Identifier 28-16 + * | | |ID28 - ID0, 29-bit Identifier ("Extended Frame"). + * | | |ID28 - ID18, 11-bit Identifier ("Standard Frame") + * |[13] |Dir |Message Direction + * | | |0 = Direction is receive. + * | | |On TxRqst, a Remote Frame with the identifier of this Message Object is transmitted. + * | | |On reception of a Data Frame with matching identifier, that message is stored in this Message Object. + * | | |1 = Direction is transmit. + * | | |On TxRqst, the respective Message Object is transmitted as a Data Frame. + * | | |On reception of a Remote Frame with matching identifier, the TxRqst bit (CAN_IFn_CMASK[2]) of this Message Object is set (if RmtEn (CAN_IFn_MCON[9]) = one). + * |[14] |Xtd |Extended Identifier + * | | |0 = The 11-bit ("standard") Identifier will be used for this Message Object. + * | | |1 = The 29-bit ("extended") Identifier will be used for this Message Object. + * |[15] |MsgVal |Message Valid + * | | |0 = The Message Object is ignored by the Message Handler. + * | | |1 = The Message Object is configured and should be considered by the Message Handler. + * | | |Note: The application software must reset the MsgVal bit of all unused Messages Objects during the initialization before it resets bit Init (CAN_CON[0]). + * | | |This bit must also be reset before the identifier Id28-0 (CAN_IFn_ARB1/2), the control bits Xtd (CAN_IFn_ARB2[14]), Dir (CAN_IFn_APB2[13]), or the Data Length Code DLC3-0 (CAN_IFn_MCON[3:0]) are modified, or if the Messages Object is no longer required. + */ + __IO uint32_t ARB2; + + /** + * CAN_IFn_MCON + * =================================================================================================== + * Offset: 0x38, 0x98 IFn Message Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |DLC |Data Length Code + * | | |0-8: Data Frame has 0-8 data bytes. + * | | |9-15: Data Frame has 8 data bytes + * | | |Note: The Data Length Code of a Message Object must be defined the same as in all the corresponding objects with the same identifier at other nodes. + * | | |When the Message Handler stores a data frame, it will write the DLC to the value given by the received message. + * | | |Data 0: 1st data byte of a CAN Data Frame + * | | |Data 1: 2nd data byte of a CAN Data Frame + * | | |Data 2: 3rd data byte of a CAN Data Frame + * | | |Data 3: 4th data byte of a CAN Data Frame + * | | |Data 4: 5th data byte of a CAN Data Frame + * | | |Data 5: 6th data byte of a CAN Data Frame + * | | |Data 6: 7th data byte of a CAN Data Frame + * | | |Data 7 : 8th data byte of a CAN Data Frame + * | | |Note: The Data 0 Byte is the first data byte shifted into the shift register of the CAN Core during a reception while the Data 7 byte is the last. + * | | |When the Message Handler stores a Data Frame, it will write all the eight data bytes into a Message Object. + * | | |If the Data Length Code is less than 8, the remaining bytes of the Message Object will be overwritten by unspecified values. + * |[7] |EoB |End Of Buffer + * | | |0 = Message Object belongs to a FIFO Buffer and is not the last Message Object of that FIFO Buffer. + * | | |1 = Single Message Object or last Message Object of a FIFO Buffer. + * | | |Note: This bit is used to concatenate two or more Message Objects (up to 32) to build a FIFO Buffer. + * | | |For single Message Objects (not belonging to a FIFO Buffer), this bit must always be set to one. + * |[8] |TxRqst |Transmit Request + * | | |0 = This Message Object is not waiting for transmission. + * | | |1 = The transmission of this Message Object is requested and is not yet done. + * |[9] |RmtEn |Remote Enable Control + * | | |0 = At the reception of a Remote Frame, TxRqst (CAN_IFn_MCON[8]) is left unchanged. + * | | |1 = At the reception of a Remote Frame, TxRqst is set. + * |[10] |RxIE |Receive Interrupt Enable Control + * | | |0 = IntPnd (CAN_IFn_MCON[13]) will be left unchanged after a successful reception of a frame. + * | | |1 = IntPnd will be set after a successful reception of a frame. + * |[11] |TxIE |Transmit Interrupt Enable Control + * | | |0 = IntPnd (CAN_IFn_MCON[13]) will be left unchanged after the successful transmission of a frame. + * | | |1 = IntPnd will be set after a successful transmission of a frame. + * |[12] |UMask |Use Acceptance Mask + * | | |0 = Mask ignored. + * | | |1 = Use Mask (Msk28-0, MXtd, and MDir) for acceptance filtering. + * | | |Note: If the UMask bit is set to one, the Message Object's mask bits have to be programmed during initialization of the Message Object before MsgVal bit (CAN_IFn_APB2[15]) is set to one. + * |[13] |IntPnd |Interrupt Pending + * | | |0 = This message object is not the source of an interrupt. + * | | |1 = This message object is the source of an interrupt. + * | | |The Interrupt Identifier in the Interrupt Register will point to this message object if there is no other interrupt source with higher priority. + * |[14] |MsgLst |Message Lost (only valid for Message Objects with direction = receive). + * | | |0 = No message lost since last time this bit was reset by the CPU. + * | | |1 = The Message Handler stored a new message into this object when NewDat was still set, the CPU has lost a message. + * |[15] |NewDat |New Data + * | | |0 = No new data has been written into the data portion of this Message Object by the Message Handler since last time this flag was cleared by the application software. + * | | |1 = The Message Handler or the application software has written new data into the data portion of this Message Object. + */ + __IO uint32_t MCON; + + /** + * CAN_IFn_DAT_A1 + * =================================================================================================== + * Offset: 0x3C, 0x9C IFn Data A1 Register (Register Map Note 3) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |Data0 |Data Byte 0 + * | | |1st data byte of a CAN Data Frame + * |[8:15] |Data1 |Data Byte 1 + * | | |2nd data byte of a CAN Data Frame + */ + __IO uint32_t DAT_A1; + + /** + * CAN_IFn_DAT_A2 + * =================================================================================================== + * Offset: 0x40, 0xA0 IFn Data A2 Register (Register Map Note 3) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |Data2 |Data Byte 2 + * | | |3rd data byte of CAN Data Frame + * |[8:15] |Data3 |Data Byte 3 + * | | |4th data byte of CAN Data Frame + */ + __IO uint32_t DAT_A2; + + /** + * CAN_IFn_DAT_B1 + * =================================================================================================== + * Offset: 0x44, 0xA4 IFn Data B1 Register (Register Map Note 3) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |Data4 |Data Byte 4 + * | | |5th data byte of CAN Data Frame + * |[8:15] |Data5 |Data Byte 5 + * | | |6th data byte of CAN Data Frame + */ + __IO uint32_t DAT_B1; + + /** + * CAN_IFn_DAT_B2 + * =================================================================================================== + * Offset: 0x48, 0xA8 IFn Data B2 Register (Register Map Note 3) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |Data6 |Data Byte 6 + * | | |7th data byte of CAN Data Frame. + * |[8:15] |Data7 |Data Byte 7 + * | | |8th data byte of CAN Data Frame. + */ + __IO uint32_t DAT_B2; + /// @cond HIDDEN_SYMBOLS + __I uint32_t RESERVE0[13]; + /// @endcond //HIDDEN_SYMBOLS +} CAN_IF_T; + +typedef struct { + + /** + * CAN_CON + * =================================================================================================== + * Offset: 0x00 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |Init |Init Initialization + * | | |0 = Normal Operation. + * | | |1 = Initialization is started. + * |[1] |IE |Module Interrupt Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |SIE |Status Change Interrupt Enable Control + * | | |0 = Disabled - No Status Change Interrupt will be generated. + * | | |1 = Enabled - An interrupt will be generated when a message transfer is successfully completed or a CAN bus error is detected. + * |[3] |EIE |Error Interrupt Enable Control + * | | |0 = Disabled - No Error Status Interrupt will be generated. + * | | |1 = Enabled - A change in the bits BOff (CAN_STATUS[7]) or EWarn (CAN_STATUS[6]) in the Status Register will generate an interrupt. + * |[5] |DAR |Automatic Re-Transmission Disable Control + * | | |0 = Automatic Retransmission of disturbed messages enabled. + * | | |1 = Automatic Retransmission disabled. + * |[6] |CCE |Configuration Change Enable Control + * | | |0 = No write access to the Bit Timing Register. + * | | |1 = Write access to the Bit Timing Register (CAN_BTIME) allowed. (while Init bit (CAN_CON[0]) = 1). + * |[7] |Test |Test Mode Enable Control + * | | |0 = Normal Operation. + * | | |1 = Test Mode. + */ + __IO uint32_t CON; + + /** + * CAN_STATUS + * =================================================================================================== + * Offset: 0x04 Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |LEC |Last Error Code (Type Of The Last Error To Occur On The CAN Bus) + * | | |The LEC field holds a code, which indicates the type of the last error to occur on the CAN bus. + * | | |This field will be cleared to '0' when a message has been transferred (reception or transmission) without error. + * | | |The unused code '7' may be written by the CPU to check for updates. + * | | |The following table describes the error code. + * |[3] |TxOK |Transmitted A Message Successfully + * | | |0 = Since this bit was reset by the CPU, no message has been successfully transmitted. + * | | |This bit is never reset by the CAN Core. + * | | |1 = Since this bit was last reset by the CPU, a message has been successfully (error free and acknowledged by at least one other node) transmitted. + * |[4] |RxOK |Received A Message Successfully + * | | |0 = No message has been successfully received since this bit was last reset by the CPU. + * | | |This bit is never reset by the CAN Core. + * | | |1 = A message has been successfully received since this bit was last reset by the CPU (independent of the result of acceptance filtering). + * |[5] |EPass |Error Passive (Read Only) + * | | |0 = The CAN Core is error active. + * | | |1 = The CAN Core is in the error passive state as defined in the CAN Specification. + * |[6] |EWarn |Error Warning Status (Read Only) + * | | |0 = Both error counters are below the error warning limit of 96. + * | | |1 = At least one of the error counters in the EML has reached the error warning limit of 96. + * |[7] |BOff |Bus-Off Status (Read Only) + * | | |0 = The CAN module is not in bus-off state. + * | | |1 = The CAN module is in bus-off state. + */ + __IO uint32_t STATUS; + + /** + * CAN_ERR + * =================================================================================================== + * Offset: 0x08 Error Counter Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |TEC |Transmit Error Counter + * | | |Actual state of the Transmit Error Counter. Values between 0 and 255. + * |[8:14] |REC |Receive Error Counter + * | | |Actual state of the Receive Error Counter. Values between 0 and 127. + * |[15] |RP |Receive Error Passive + * | | |0 = The Receive Error Counter is below the error passive level. + * | | |1 = The Receive Error Counter has reached the error passive level as defined in the CAN Specification. + */ + __IO uint32_t ERR; + + /** + * CAN_BTIME + * =================================================================================================== + * Offset: 0x0C Bit Timing Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |BRP |Baud Rate Prescaler + * | | |0x01-0x3F: The value by which the oscillator frequency is divided for generating the bit time quanta. + * | | |The bit time is built up from a multiple of this quanta. + * | | |Valid values for the Baud Rate Prescaler are [ 0 ... 63 ]. + * | | |The actual interpretation by the hardware of this value is such that one more than the value programmed here is used. + * |[6:7] |SJW |(Re)Synchronization Jump Width + * | | |0x0-0x3: Valid programmed values are [0 ... 3]. + * | | |The actual interpretation by the hardware of this value is such that one more than the value programmed here is used. + * |[8:11] |TSeg1 |Time Segment Before The Sample Point Minus Sync_Seg + * | | |0x01-0x0F: valid values for TSeg1 are [1 ... 15]. + * | | |The actual interpretation by the hardware of this value is such that one more than the value programmed is used. + * |[12:14] |TSeg2 |Time Segment After Sample Point + * | | |0x0-0x7: Valid values for TSeg2 are [0 ... 7]. + * | | |The actual interpretation by the hardware of this value is such that one more than the value programmed here is used. + */ + __IO uint32_t BTIME; + + /** + * CAN_IIDR + * =================================================================================================== + * Offset: 0x10 Interrupt Identifier Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |IntId |Interrupt Identifier (Indicates The Source Of The Interrupt) + * | | |If several interrupts are pending, the CAN Interrupt Register will point to the pending interrupt with the highest priority, disregarding their chronological order. + * | | |An interrupt remains pending until the application software has cleared it. + * | | |If IntId is different from 0x0000 and IE (CAN_IFn_MCON[1]) is set, the IRQ interrupt signal to the EIC is active. + * | | |The interrupt remains active until IntId is back to value 0x0000 (the cause of the interrupt is reset) or until IE is reset. + * | | |The Status Interrupt has the highest priority. + * | | |Among the message interrupts, the Message Object' s interrupt priority decreases with increasing message number. + * | | |A message interrupt is cleared by clearing the Message Object's IntPnd bit (CAN_IFn_MCON[13]). + * | | |The Status Interrupt is cleared by reading the Status Register. + */ + __IO uint32_t IIDR; + + /** + * CAN_TEST + * =================================================================================================== + * Offset: 0x14 Test Register (Register Map Note 1) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |Res |Reserved + * | | |There are reserved bits. + * | | |These bits are always read as '0' and must always be written with '0'. + * |[2] |Basic |Basic Mode + * | | |0 = Basic Mode disabled. + * | | |1= IF1 Registers used as Tx Buffer, IF2 Registers used as Rx Buffer. + * |[3] |Silent |Silent Mode + * | | |0 = Normal operation. + * | | |1 = The module is in Silent Mode. + * |[4] |LBack |Loop Back Mode Enable Control + * | | |0 = Loop Back Mode is disabled. + * | | |1 = Loop Back Mode is enabled. + * |[5:6] |Tx10 |Tx[1:0]: Control Of CAN_TX Pin + * | | |00 = Reset value, CAN_TX pin is controlled by the CAN Core. + * | | |01 = Sample Point can be monitored at CAN_TX pin. + * | | |10 = CAN_TX pin drives a dominant ('0') value. + * | | |11 = CAN_TX pin drives a recessive ('1') value. + * |[7] |Rx |Monitors The Actual Value Of CAN_RX Pin (Read Only) + * | | |0 = The CAN bus is dominant (CAN_RX = '0'). + * | | |1 = The CAN bus is recessive (CAN_RX = '1'). + */ + __IO uint32_t TEST; + + /** + * CAN_BRPE + * =================================================================================================== + * Offset: 0x18 Baud Rate Prescaler Extension Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |BRPE |BRPE: Baud Rate Prescaler Extension + * | | |0x00-0x0F: By programming BRPE, the Baud Rate Prescaler can be extended to values up to 1023. + * | | |The actual interpretation by the hardware is that one more than the value programmed by BRPE (MSBs) and BTIME (LSBs) is used. + */ + __IO uint32_t BRPE; + + __I uint32_t RESERVE0[1]; + + __IO CAN_IF_T IF[2]; + + __I uint32_t RESERVE1[8]; + + /** + * CAN_TXREQ1 + * =================================================================================================== + * Offset: 0x100 Transmission Request Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |TxRqst161 |Transmission Request Bits 16-1 (Of All Message Objects) + * | | |0 = This Message Object is not waiting for transmission. + * | | |1 = The transmission of this Message Object is requested and is not yet done. + * | | |These bits are read only. + */ + __IO uint32_t TXREQ1; + + /** + * CAN_TXREQ2 + * =================================================================================================== + * Offset: 0x104 Transmission Request Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |TxRqst3217|Transmission Request Bits 32-17 (Of All Message Objects) + * | | |0 = This Message Object is not waiting for transmission. + * | | |1 = The transmission of this Message Object is requested and is not yet done. + * | | |These bits are read only. + */ + __IO uint32_t TXREQ2; + + __I uint32_t RESERVE2[6]; + + /** + * CAN_NDAT1 + * =================================================================================================== + * Offset: 0x120 New Data Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |NewData161|New Data Bits 16-1 (Of All Message Objects) + * | | |0 = No new data has been written into the data portion of this Message Object by the Message Handler since the last time this flag was cleared by the application software. + * | | |1 = The Message Handler or the application software has written new data into the data portion of this Message Object. + */ + __IO uint32_t NDAT1; + + /** + * CAN_NDAT2 + * =================================================================================================== + * Offset: 0x124 New Data Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |NewData3217|New Data Bits 32-17 (Of All Message Objects) + * | | |0 = No new data has been written into the data portion of this Message Object by the Message Handler since the last time this flag was cleared by the application software. + * | | |1 = The Message Handler or the application software has written new data into the data portion of this Message Object. + */ + __IO uint32_t NDAT2; + + __I uint32_t RESERVE3[6]; + + /** + * CAN_IPND1 + * =================================================================================================== + * Offset: 0x140 Interrupt Pending Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |IntPnd161 |Interrupt Pending Bits 16-1 (Of All Message Objects) + * | | |0 = This message object is not the source of an interrupt. + * | | |1 = This message object is the source of an interrupt. + */ + __IO uint32_t IPND1; + + /** + * CAN_IPND2 + * =================================================================================================== + * Offset: 0x144 Interrupt Pending Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |IntPnd3217|Interrupt Pending Bits 32-17(Of All Message Objects) + * | | |0 = This message object is not the source of an interrupt. + * | | |1 = This message object is the source of an interrupt. + */ + __IO uint32_t IPND2; + + __I uint32_t RESERVE4[6]; + + /** + * CAN_MVLD1 + * =================================================================================================== + * Offset: 0x160 Message Valid Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |MsgVal161 |Message Valid Bits 16-1 (Of All Message Objects) (Read Only) + * | | |0 = This Message Object is ignored by the Message Handler. + * | | |1 = This Message Object is configured and should be considered by the Message Handler. + * | | |Ex. + * | | |CAN_MVLD1[0] means Message object No.1 is valid or not. + * | | |If CAN_MVLD1[0] is set, message object No.1 is configured. + */ + __IO uint32_t MVLD1; + + /** + * CAN_MVLD2 + * =================================================================================================== + * Offset: 0x164 Message Valid Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |MsgVal3217|Message Valid Bits 32-17 (Of All Message Objects) (Read Only) + * | | |0 = This Message Object is ignored by the Message Handler. + * | | |1 = This Message Object is configured and should be considered by the Message Handler. + * | | |Ex.CAN_MVLD2[15] means Message object No.32 is valid or not. + * | | |If CAN_MVLD2[15] is set, message object No.32 is configured. + */ + __IO uint32_t MVLD2; + + /** + * CAN_WU_EN + * =================================================================================================== + * Offset: 0x168 Wake-up Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |WAKUP_EN |Wake-Up Enable Control + * | | |0 = The wake-up function Disabled. + * | | |1 = The wake-up function Enabled. + * | | |Note: User can wake-up system when there is a falling edge in the CAN_Rx pin. + */ + __IO uint32_t WU_EN; + + /** + * CAN_WU_STATUS + * =================================================================================================== + * Offset: 0x16C Wake-up Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |WAKUP_STS |Wake-Up Status + * | | |0 = No wake-up event occurred. + * | | |1 = Wake-up event occurred. + * | | |Note: This bit can be cleared by writing '0'. + */ + __IO uint32_t WU_STATUS; +} CAN_T; + +/** + @addtogroup CAN_CONST CAN Bit Field Definition + Constant Definitions for CAN Controller +@{ */ + +#define CAN_CON_TEST_Pos 7 /*!< CAN_T::CON: TEST Position */ +#define CAN_CON_TEST_Msk (1ul << CAN_CON_TEST_Pos) /*!< CAN_T::CON: TEST Mask */ + +#define CAN_CON_CCE_Pos 6 /*!< CAN_T::CON: CCE Position */ +#define CAN_CON_CCE_Msk (1ul << CAN_CON_CCE_Pos) /*!< CAN_T::CON: CCE Mask */ + +#define CAN_CON_DAR_Pos 5 /*!< CAN_T::CON: DAR Position */ +#define CAN_CON_DAR_Msk (1ul << CAN_CON_DAR_Pos) /*!< CAN_T::CON: DAR Mask */ + +#define CAN_CON_EIE_Pos 3 /*!< CAN_T::CON: EIE Position */ +#define CAN_CON_EIE_Msk (1ul << CAN_CON_EIE_Pos) /*!< CAN_T::CON: EIE Mask */ + +#define CAN_CON_SIE_Pos 2 /*!< CAN_T::CON: SIE Position */ +#define CAN_CON_SIE_Msk (1ul << CAN_CON_SIE_Pos) /*!< CAN_T::CON: SIE Mask */ + +#define CAN_CON_IE_Pos 1 /*!< CAN_T::CON: IE Position */ +#define CAN_CON_IE_Msk (1ul << CAN_CON_IE_Pos) /*!< CAN_T::CON: IE Mask */ + +#define CAN_CON_INIT_Pos 0 /*!< CAN_T::CON: INIT Position */ +#define CAN_CON_INIT_Msk (1ul << CAN_CON_INIT_Pos) /*!< CAN_T::CON: INIT Mask */ + +#define CAN_STATUS_BOFF_Pos 7 /*!< CAN_T::STATUS: BOFF Position */ +#define CAN_STATUS_BOFF_Msk (1ul << CAN_STATUS_BOFF_Pos) /*!< CAN_T::STATUS: BOFF Mask */ + +#define CAN_STATUS_EWARN_Pos 6 /*!< CAN_T::STATUS: EWARN Position */ +#define CAN_STATUS_EWARN_Msk (1ul << CAN_STATUS_EWARN_Pos) /*!< CAN_T::STATUS: EWARN Mask */ + +#define CAN_STATUS_EPASS_Pos 5 /*!< CAN_T::STATUS: EPASS Position */ +#define CAN_STATUS_EPASS_Msk (1ul << CAN_STATUS_EPASS_Pos) /*!< CAN_T::STATUS: EPASS Mask */ + +#define CAN_STATUS_RXOK_Pos 4 /*!< CAN_T::STATUS: RXOK Position */ +#define CAN_STATUS_RXOK_Msk (1ul << CAN_STATUS_RXOK_Pos) /*!< CAN_T::STATUS: RXOK Mask */ + +#define CAN_STATUS_TXOK_Pos 3 /*!< CAN_T::STATUS: TXOK Position */ +#define CAN_STATUS_TXOK_Msk (1ul << CAN_STATUS_TXOK_Pos) /*!< CAN_T::STATUS: TXOK Mask */ + +#define CAN_STATUS_LEC_Pos 0 /*!< CAN_T::STATUS: LEC Position */ +#define CAN_STATUS_LEC_Msk (0x7ul << CAN_STATUS_LEC_Pos) /*!< CAN_T::STATUS: LEC Mask */ + +#define CAN_ERR_RP_Pos 15 /*!< CAN_T::ERR: RP Position */ +#define CAN_ERR_RP_Msk (1ul << CAN_ERR_RP_Pos) /*!< CAN_T::ERR: RP Mask */ + +#define CAN_ERR_REC_Pos 8 /*!< CAN_T::ERR: REC Position */ +#define CAN_ERR_REC_Msk (0x7Ful << CAN_ERR_REC_Pos) /*!< CAN_T::ERR: REC Mask */ + +#define CAN_ERR_TEC_Pos 0 /*!< CAN_T::ERR: TEC Position */ +#define CAN_ERR_TEC_Msk (0xFFul << CAN_ERR_TEC_Pos) /*!< CAN_T::ERR: TEC Mask */ + +#define CAN_BTIME_TSEG2_Pos 12 /*!< CAN_T::BTIME: TSEG2 Position */ +#define CAN_BTIME_TSEG2_Msk (0x7ul << CAN_BTIME_TSEG2_Pos) /*!< CAN_T::BTIME: TSEG2 Mask */ + +#define CAN_BTIME_TSEG1_Pos 8 /*!< CAN_T::BTIME: TSEG1 Position */ +#define CAN_BTIME_TSEG1_Msk (0xFul << CAN_BTIME_TSEG1_Pos) /*!< CAN_T::BTIME: TSEG1 Mask */ + +#define CAN_BTIME_SJW_Pos 6 /*!< CAN_T::BTIME: SJW Position */ +#define CAN_BTIME_SJW_Msk (0x3ul << CAN_BTIME_SJW_Pos) /*!< CAN_T::BTIME: SJW Mask */ + +#define CAN_BTIME_BRP_Pos 0 /*!< CAN_T::BTIME: BRP Position */ +#define CAN_BTIME_BRP_Msk (0x3Ful << CAN_BTIME_BRP_Pos) /*!< CAN_T::BTIME: BRP Mask */ + +#define CAN_IIDR_INTID_Pos 0 /*!< CAN_T::IIDR: INTID Position */ +#define CAN_IIDR_INTID_Msk (0xFFFFul << CAN_IIDR_INTID_Pos) /*!< CAN_T::IIDR: INTID Mask */ + +#define CAN_TEST_RX_Pos 7 /*!< CAN_T::TEST: RX Position */ +#define CAN_TEST_RX_Msk (1ul << CAN_TEST_RX_Pos) /*!< CAN_T::TEST: RX Mask */ + +#define CAN_TEST_TX_Pos 5 /*!< CAN_T::TEST: TX Position */ +#define CAN_TEST_TX_Msk (0x3ul << CAN_TEST_TX_Pos) /*!< CAN_T::TEST: TX Mask */ + +#define CAN_TEST_LBACK_Pos 4 /*!< CAN_T::TEST: LBACK Position */ +#define CAN_TEST_LBACK_Msk (1ul << CAN_TEST_LBACK_Pos) /*!< CAN_T::TEST: LBACK Mask */ + +#define CAN_TEST_SILENT_Pos 3 /*!< CAN_T::TEST: Silent Position */ +#define CAN_TEST_SILENT_Msk (1ul << CAN_TEST_SILENT_Pos) /*!< CAN_T::TEST: Silent Mask */ + +#define CAN_TEST_BASIC_Pos 2 /*!< CAN_T::TEST: Basic Position */ +#define CAN_TEST_BASIC_Msk (1ul << CAN_TEST_BASIC_Pos) /*!< CAN_T::TEST: Basic Mask */ + +#define CAN_BRPE_BRPE_Pos 0 /*!< CAN_T::BRPE: BRPE Position */ +#define CAN_BRPE_BRPE_Msk (0xFul << CAN_BRPE_BRPE_Pos) /*!< CAN_T::BRPE: BRPE Mask */ + +#define CAN_IF_CREQ_BUSY_Pos 15 /*!< CAN_IF_T::CREQ: BUSY Position */ +#define CAN_IF_CREQ_BUSY_Msk (1ul << CAN_IF_CREQ_BUSY_Pos) /*!< CAN_IF_T::CREQ: BUSY Mask */ + +#define CAN_IF_CREQ_MSGNUM_Pos 0 /*!< CAN_IF_T::CREQ: MSGNUM Position */ +#define CAN_IF_CREQ_MSGNUM_Msk (0x3Ful << CAN_IF_CREQ_MSGNUM_Pos) /*!< CAN_IF_T::CREQ: MSGNUM Mask */ + +#define CAN_IF_CMASK_WRRD_Pos 7 /*!< CAN_IF_T::CMASK: WRRD Position */ +#define CAN_IF_CMASK_WRRD_Msk (1ul << CAN_IF_CMASK_WRRD_Pos) /*!< CAN_IF_T::CMASK: WRRD Mask */ + +#define CAN_IF_CMASK_MASK_Pos 6 /*!< CAN_IF_T::CMASK: MASK Position */ +#define CAN_IF_CMASK_MASK_Msk (1ul << CAN_IF_CMASK_MASK_Pos) /*!< CAN_IF_T::CMASK: MASK Mask */ + +#define CAN_IF_CMASK_ARB_Pos 5 /*!< CAN_IF_T::CMASK: ARB Position */ +#define CAN_IF_CMASK_ARB_Msk (1ul << CAN_IF_CMASK_ARB_Pos) /*!< CAN_IF_T::CMASK: ARB Mask */ + +#define CAN_IF_CMASK_CONTROL_Pos 4 /*!< CAN_IF_T::CMASK: CONTROL Position */ +#define CAN_IF_CMASK_CONTROL_Msk (1ul << CAN_IF_CMASK_CONTROL_Pos) /*!< CAN_IF_T::CMASK: CONTROL Mask */ + +#define CAN_IF_CMASK_CLRINTPND_Pos 3 /*!< CAN_IF_T::CMASK: CLRINTPND Position */ +#define CAN_IF_CMASK_CLRINTPND_Msk (1ul << CAN_IF_CMASK_CLRINTPND_Pos) /*!< CAN_IF_T::CMASK: CLRINTPND Mask */ + +#define CAN_IF_CMASK_TXRQSTNEWDAT_Pos 2 /*!< CAN_IF_T::CMASK: TXRQSTNEWDAT Position */ +#define CAN_IF_CMASK_TXRQSTNEWDAT_Msk (1ul << CAN_IF_CMASK_TXRQSTNEWDAT_Pos) /*!< CAN_IF_T::CMASK: TXRQSTNEWDAT Mask */ + +#define CAN_IF_CMASK_DATAA_Pos 1 /*!< CAN_IF_T::CMASK: DATAA Position */ +#define CAN_IF_CMASK_DATAA_Msk (1ul << CAN_IF_CMASK_DATAA_Pos) /*!< CAN_IF_T::CMASK: DATAA Mask */ + +#define CAN_IF_CMASK_DATAB_Pos 0 /*!< CAN_IF_T::CMASK: DATAB Position */ +#define CAN_IF_CMASK_DATAB_Msk (1ul << CAN_IF_CMASK_DATAB_Pos) /*!< CAN_IF_T::CMASK: DATAB Mask */ + +#define CAN_IF_MASK1_MSK_Pos 0 /*!< CAN_IF_T::MASK1: MSK Position */ +#define CAN_IF_MASK1_MSK_Msk (0xFFul << CAN_IF_MASK1_MSK_Pos) /*!< CAN_IF_T::MASK1: MSK Mask */ + +#define CAN_IF_MASK2_MXTD_Pos 15 /*!< CAN_IF_T::MASK2: MXTD Position */ +#define CAN_IF_MASK2_MXTD_Msk (1ul << CAN_IF_MASK2_MXTD_Pos) /*!< CAN_IF_T::MASK2: MXTD Mask */ + +#define CAN_IF_MASK2_MDIR_Pos 14 /*!< CAN_IF_T::MASK2: MDIR Position */ +#define CAN_IF_MASK2_MDIR_Msk (1ul << CAN_IF_MASK2_MDIR_Pos) /*!< CAN_IF_T::MASK2: MDIR Mask */ + +#define CAN_IF_MASK2_MSK_Pos 0 /*!< CAN_IF_T::MASK2: MSK Position */ +#define CAN_IF_MASK2_MSK_Msk (0x1FFul << CAN_IF_MASK2_MSK_Pos) /*!< CAN_IF_T::MASK2: MSK Mask */ + +#define CAN_IF_ARB1_ID_Pos 0 /*!< CAN_IF_T::ARB1: ID Position */ +#define CAN_IF_ARB1_ID_Msk (0xFFFFul << CAN_IF_ARB1_ID_Pos) /*!< CAN_IF_T::ARB1: ID Mask */ + +#define CAN_IF_ARB2_MSGVAL_Pos 15 /*!< CAN_IF_T::ARB2: MSGVAL Position */ +#define CAN_IF_ARB2_MSGVAL_Msk (1ul << CAN_IF_ARB2_MSGVAL_Pos) /*!< CAN_IF_T::ARB2: MSGVAL Mask */ + +#define CAN_IF_ARB2_XTD_Pos 14 /*!< CAN_IF_T::ARB2: XTD Position */ +#define CAN_IF_ARB2_XTD_Msk (1ul << CAN_IF_ARB2_XTD_Pos) /*!< CAN_IF_T::ARB2: XTD Mask */ + +#define CAN_IF_ARB2_DIR_Pos 13 /*!< CAN_IF_T::ARB2: DIR Position */ +#define CAN_IF_ARB2_DIR_Msk (1ul << CAN_IF_ARB2_DIR_Pos) /*!< CAN_IF_T::ARB2: DIR Mask */ + +#define CAN_IF_ARB2_ID_Pos 0 /*!< CAN_IF_T::ARB2: ID Position */ +#define CAN_IF_ARB2_ID_Msk (0x1FFFul << CAN_IF_ARB2_ID_Pos) /*!< CAN_IF_T::ARB2: ID Mask */ + +#define CAN_IF_MCON_NEWDAT_Pos 15 /*!< CAN_IF_T::MCON: NEWDAT Position */ +#define CAN_IF_MCON_NEWDAT_Msk (1ul << CAN_IF_MCON_NEWDAT_Pos) /*!< CAN_IF_T::MCON: NEWDAT Mask */ + +#define CAN_IF_MCON_MSGLST_Pos 14 /*!< CAN_IF_T::MCON: MSGLST Position */ +#define CAN_IF_MCON_MSGLST_Msk (1ul << CAN_IF_MCON_MSGLST_Pos) /*!< CAN_IF_T::MCON: MSGLST Mask */ + +#define CAN_IF_MCON_INTPND_Pos 13 /*!< CAN_IF_T::MCON: INTPND Position */ +#define CAN_IF_MCON_INTPND_Msk (1ul << CAN_IF_MCON_INTPND_Pos) /*!< CAN_IF_T::MCON: INTPND Mask */ + +#define CAN_IF_MCON_UMASK_Pos 12 /*!< CAN_IF_T::MCON: UMASK Position */ +#define CAN_IF_MCON_UMASK_Msk (1ul << CAN_IF_MCON_UMASK_Pos) /*!< CAN_IF_T::MCON: UMASK Mask */ + +#define CAN_IF_MCON_TXIE_Pos 11 /*!< CAN_IF_T::MCON: TXIE Position */ +#define CAN_IF_MCON_TXIE_Msk (1ul << CAN_IF_MCON_TXIE_Pos) /*!< CAN_IF_T::MCON: TXIE Mask */ + +#define CAN_IF_MCON_RXIE_Pos 10 /*!< CAN_IF_T::MCON: RXIE Position */ +#define CAN_IF_MCON_RXIE_Msk (1ul << CAN_IF_MCON_RXIE_Pos) /*!< CAN_IF_T::MCON: RXIE Mask */ + +#define CAN_IF_MCON_RMTEN_Pos 9 /*!< CAN_IF_T::MCON: RMTEN Position */ +#define CAN_IF_MCON_RMTEN_Msk (1ul << CAN_IF_MCON_RMTEN_Pos) /*!< CAN_IF_T::MCON: RMTEN Mask */ + +#define CAN_IF_MCON_TXRQST_Pos 8 /*!< CAN_IF_T::MCON: TXRQST Position */ +#define CAN_IF_MCON_TXRQST_Msk (1ul << CAN_IF_MCON_TXRQST_Pos) /*!< CAN_IF_T::MCON: TXRQST Mask */ + +#define CAN_IF_MCON_EOB_Pos 7 /*!< CAN_IF_T::MCON: EOB Position */ +#define CAN_IF_MCON_EOB_Msk (1ul << CAN_IF_MCON_EOB_Pos) /*!< CAN_IF_T::MCON: EOB Mask */ + +#define CAN_IF_MCON_DLC_Pos 0 /*!< CAN_IF_T::MCON: DLC Position */ +#define CAN_IF_MCON_DLC_Msk (0xFul << CAN_IF_MCON_DLC_Pos) /*!< CAN_IF_T::MCON: DLC Mask */ + +#define CAN_IF_DAT_A1_DATA1_Pos 8 /*!< CAN_IF_T::DAT_A1: DATA1 Position */ +#define CAN_IF_DAT_A1_DATA1_Msk (0xFFul << CAN_IF_DAT_A1_DATA1_Pos) /*!< CAN_IF_T::DAT_A1: DATA1 Mask */ + +#define CAN_IF_DAT_A1_DATA0_Pos 0 /*!< CAN_IF_T::DAT_A1: DATA0 Position */ +#define CAN_IF_DAT_A1_DATA0_Msk (0xFFul << CAN_IF_DAT_A1_DATA0_Pos) /*!< CAN_IF_T::DAT_A1: DATA0 Mask */ + +#define CAN_IF_DAT_A2_DATA3_Pos 8 /*!< CAN_IF_T::DAT_A2: DATA3 Position */ +#define CAN_IF_DAT_A2_DATA3_Msk (0xFFul << CAN_IF_DAT_A2_DATA3_Pos) /*!< CAN_IF_T::DAT_A2: DATA3 Mask */ + +#define CAN_IF_DAT_A2_DATA2_Pos 0 /*!< CAN_IF_T::DAT_A2: DATA2 Position */ +#define CAN_IF_DAT_A2_DATA2_Msk (0xFFul << CAN_IF_DAT_A2_DATA2_Pos) /*!< CAN_IF_T::DAT_A2: DATA2 Mask */ + +#define CAN_IF_DAT_B1_DATA5_Pos 8 /*!< CAN_IF_T::DAT_B1: DATA5 Position */ +#define CAN_IF_DAT_B1_DATA5_Msk (0xFFul << CAN_IF_DAT_B1_DATA5_Pos) /*!< CAN_IF_T::DAT_B1: DATA5 Mask */ + +#define CAN_IF_DAT_B1_DATA4_Pos 0 /*!< CAN_IF_T::DAT_B1: DATA4 Position */ +#define CAN_IF_DAT_B1_DATA4_Msk (0xFFul << CAN_IF_DAT_B1_DATA4_Pos) /*!< CAN_IF_T::DAT_B1: DATA4 Mask */ + +#define CAN_IF_DAT_B2_DATA7_Pos 8 /*!< CAN_IF_T::DAT_B2: DATA7 Position */ +#define CAN_IF_DAT_B2_DATA7_Msk (0xFFul << CAN_IF_DAT_B2_DATA7_Pos) /*!< CAN_IF_T::DAT_B2: DATA7 Mask */ + +#define CAN_IF_DAT_B2_DATA6_Pos 0 /*!< CAN_IF_T::DAT_B2: DATA6 Position */ +#define CAN_IF_DAT_B2_DATA6_Msk (0xFFul << CAN_IF_DAT_B2_DATA6_Pos) /*!< CAN_IF_T::DAT_B2: DATA6 Mask */ + +#define CAN_IF_TXRQST1_TXRQST_Pos 0 /*!< CAN_T::TXRQST1: TXRQST Position */ +#define CAN_IF_TXRQST1_TXRQST_Msk (0xFFFFul << CAN_IF_TXRQST1_TXRQST_Pos) /*!< CAN_T::TXRQST1: TXRQST Mask */ + +#define CAN_IF_TXRQST2_TXRQST_Pos 0 /*!< CAN_T::TXRQST2: TXRQST Position */ +#define CAN_IF_TXRQST2_TXRQST_Msk (0xFFFFul << CAN_IF_TXRQST2_TXRQST_Pos) /*!< CAN_T::TXRQST2: TXRQST Mask */ + +#define CAN_IF_NDAT1_NEWDATA_Pos 0 /*!< CAN_T::NDAT1: NEWDATA Position */ +#define CAN_IF_NDAT1_NEWDATA_Msk (0xFFFFul << CAN_IF_NDAT1_NEWDATA_Pos) /*!< CAN_T::NDAT1: NEWDATA Mask */ + +#define CAN_IF_NDAT2_NEWDATA_Pos 0 /*!< CAN_T::NDAT2: NEWDATA Position */ +#define CAN_IF_NDAT2_NEWDATA_Msk (0xFFFFul << CAN_IF_NDAT2_NEWDATA_Pos) /*!< CAN_T::NDAT2: NEWDATA Mask */ + +#define CAN_IF_IPND1_INTPND_Pos 0 /*!< CAN_T::IPND1: INTPND Position */ +#define CAN_IF_IPND1_INTPND_Msk (0xFFFFul << CAN_IF_IPND1_INTPND_Pos) /*!< CAN_T::IPND1: INTPND Mask */ + +#define CAN_IF_IPND2_INTPND_Pos 0 /*!< CAN_T::IPND2: INTPND Position */ +#define CAN_IF_IPND2_INTPND_Msk (0xFFFFul << CAN_IF_IPND2_INTPND_Pos) /*!< CAN_T::IPND2: INTPND Mask */ + +#define CAN_IF_MVLD1_MSGVAL_Pos 0 /*!< CAN_T::MVLD1: MSGVAL Position */ +#define CAN_IF_MVLD1_MSGVAL_Msk (0xFFFFul << CAN_IF_MVLD1_MSGVAL_Pos) /*!< CAN_T::MVLD1: MSGVAL Mask */ + +#define CAN_IF_MVLD2_MSGVAL_Pos 0 /*!< CAN_T::MVLD2: MSGVAL Position */ +#define CAN_IF_MVLD2_MSGVAL_Msk (0xFFFFul << CAN_IF_MVLD2_MSGVAL_Pos) /*!< CAN_T::MVLD2: MSGVAL Mask */ + +#define CAN_WUEN_WAKUP_EN_Pos 0 /*!< CAN_T::WU_EN: WAKUP_EN Position */ +#define CAN_WUEN_WAKUP_EN_Msk (1ul << CAN_WUEN_WAKUP_EN_Pos) /*!< CAN_T::WU_EN: WAKUP_EN Mask */ + +#define CAN_WUSTATUS_WAKUP_STS_Pos 0 /*!< CAN_T::WU_STATUS: WAKUP_STS Position */ +#define CAN_WUSTATUS_WAKUP_STS_Msk (1ul << CAN_WUSTATUS_WAKUP_STS_Pos) /*!< CAN_T::WU_STATUS: WAKUP_STS Mask */ + +/**@}*/ /* CAN_CONST */ +/**@}*/ /* end of CAN register group */ + + +/*---------------------- Capture Engine -------------------------*/ +/** + @addtogroup CAP Capture Engine(CAP) + Memory Mapped Structure for CAP Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 Image Capture Interface Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CAPEN |Image Capture Interface Enable + * | | |0 = Image Capture Interface Disabled. + * | | |1 = Image Capture Interface Enabled. + * |[3] |ADDRSW |Packet Buffer Address Switch + * | | |0 = Packet buffer address switch Disabled. + * | | |1 = Packet buffer address switch Enabled. + * |[5] |PLNEN |Planar Output Enable + * | | |0 = Planar output Disabled. + * | | |1 = Planar output Enabled. + * |[6] |PKTEN |Packet Output Enable + * | | |0 = Packet output Disabled. + * | | |1 = Packet output Enabled. + * |[16] |SHUTTER |Image Capture Interface Automatically Disable The Capture Interface After A Frame Had Been Captured + * | | |0 = Shutter Disabled. + * | | |1 = Shutter Enabled. + * |[20] |UPDATE |Update Register At New Frame + * | | |0 = Update register at new frame Disabled. + * | | |1 = Update register at new frame Enabled (Auto clear to 0 when register updated). + * |[24] |VPRST |Capture Interface Reset + * | | |0 = Capture interface reset Disabled. + * | | |1 = Capture interface reset Enabled. + */ + __IO uint32_t CTL; + + /** + * PAR + * =================================================================================================== + * Offset: 0x04 Image Capture Interface Parameter Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |INFMT |Sensor Input Data Format + * | | |0 = YCbCr422. + * | | |1 = RGB565. + * |[1] |SENTYPE |Sensor Input Type + * | | |0 = CCIR601. + * | | |1 = CCIR656, VSync & Hsync embedded in the data signal. + * |[2:3] |INDATORD |Sensor Input Data Order + * | | |If INFMT = 0 (YCbCr),. + * | | | Byte 0 1 2 3 + * | | |00 = Y0 U0 Y1 V0. + * | | |01 = Y0 V0 Y1 U0. + * | | |10 = U0 Y0 V0 Y1. + * | | |11 = V0 Y0 U0 Y1. + * | | |If INFMT = 1 (RGB565),. + * | | |00 = Byte0[R[4:0] G[5:3]] Byte1[G[2:0] B[4:0]] + * | | |01 = Byte0[B[4:0] G[5:3]] Byte1[G[2:0] R[4:0]] + * | | |10 = Byte0[G[2:0] B[4:0]] Byte1[R[4:0] G[5:3]] + * | | |11 = Byte0[G[2:0] R[4:0]] Byte1[B[4:0] G[5:3]] + * |[4:5] |OUTFMT |Image Data Format Output To System Memory + * | | |00 = YCbCr422. + * | | |01 = Only output Y. + * | | |10 = RGB555. + * | | |11 = RGB565. + * |[6] |RANGE |Scale Input YUV CCIR601 Color Range To Full Range + * | | |0 = default. + * | | |1 = Scale to full range. + * |[7] |PLNFMT |Planar Output YUV Format + * | | |0 = YUV422. + * | | |1 = YUV420. + * |[8] |PCLKP |Sensor Pixel Clock Polarity + * | | |0 = Input video data and signals are latched by falling edge of Pixel Clock. + * | | |1 = Input video data and signals are latched by rising edge of Pixel Clock. + * |[9] |HSP |Sensor Hsync Polarity + * | | |0 = Sync Low. + * | | |1 = Sync High. + * |[10] |VSP |Sensor Vsync Polarity + * | | |0 = Sync Low. + * | | |1 = Sync High. + * |[11:12] |COLORCTL |Special COLORCTL Processing + * | | |00 = Normal Color. + * | | |01 = Sepia effect, corresponding U,V component value is set at register CAP_SEPIA. + * | | |10 = Negative picture. + * | | |11 = Posterize image, the Y, U, V components posterizing factor are set at register CAP_POSTERIZE. + * |[18] |FBB |Field By Blank + * | | |Hardware will tag field0 or field1 by vertical blanking instead of FIELD flag in CCIR-656 mode. + * | | |0 = Field by blank Disabled. + * | | |1 = Field by blank Enabled. + */ + __IO uint32_t PAR; + + /** + * INT + * =================================================================================================== + * Offset: 0x08 Image Capture Interface Interrupt Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |VINTF |Video Frame End Interrupt + * | | |If this bit shows 1, receiving a frame completed. + * | | |Write 1 to clear it. + * |[1] |MEINTF |Bus Master Transfer Error Interrupt + * | | |If this bit shows 1, Transfer Error occurred. Write 1 to clear it. + * |[3] |ADDRMINTF |Memory Address Match Interrupt + * | | |If this bit shows 1, Memory Address Match Interrupt occurred. + * | | |Write 1 to clear it. + * |[4] |MDINTF |Motion Detection Output Finish Interrupt + * | | |If this bit shows 1, Motion Detection Output Finish Interrupt occurred. + * | | |Write 1 to clear it. + * |[16] |VIEN |Video Frame End Interrupt Enable + * | | |0 = Video frame end interrupt Disabled. + * | | |1 = Video frame end interrupt Enabled. + * |[17] |MEIEN |System Memory Error Interrupt Enable + * | | |0 = System memory error interrupt Disabled. + * | | |1 = System memory error interrupt Enabled. + * |[19] |ADDRMIEN |Address Match Interrupt Enable + * | | |0 = Address match interrupt Disabled. + * | | |1 = Address match interrupt Enabled. + * |[20] |MDIEN |Motion Detection Output Finish Interrupt Enable + * | | |0 = CAP_MD finish interrupt Disabled. + * | | |1 = CAP_MD finish interrupt Enabled. + */ + __IO uint32_t INT; + + /** + * POSTERIZE + * =================================================================================================== + * Offset: 0x0C YUV Component Posterizing Factor Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |VCOMP |V Component Posterizing Factor + * | | |Final_V_Out = Original_V[7:0] & V_Posterizing_Factor. + * |[8:15] |UCOMP |U Component Posterizing Factor + * | | |Final_U_Out = Original_U[7:0] & U_Posterizing_Factor. + * |[16:23] |YCOMP |Y Component Posterizing Factor + * | | |Final_Y_Out = Original_Y[7:0] & Y_Posterizing_Factor. + */ + __IO uint32_t POSTERIZE; + + /** + * MD + * =================================================================================================== + * Offset: 0x10 Motion Detection Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |MDEN |Motion Detection Enable + * | | |0 = CAP_MD Disabled. + * | | |1 = CAP_MD Enabled. + * |[8] |MDBS |Motion Detection Block Size + * | | |0 = 16x16. + * | | |1 = 8x8. + * |[9] |MDSM |Motion Detection Save Mode + * | | |0 = 1 bit DIFF + 7 bit Y Differential. + * | | |1 = 1 bit DIFF only. + * |[10:11] |MDDF |Motion Detection Detect Frequency + * | | |00 = Each frame. + * | | |01 = Every 2 frame. + * | | |10 = Every 3 frame. + * | | |11 = Every 4 frame. + * |[16:20] |MDTHR |Motion Detection Differential Threshold + */ + __IO uint32_t MD; + + /** + * MDADDR + * =================================================================================================== + * Offset: 0x14 Motion Detection Output Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |MDADDR |Motion Detection Output Address Register (Word Alignment) + */ + __IO uint32_t MDADDR; + + /** + * MDYADDR + * =================================================================================================== + * Offset: 0x18 Motion Detection Temp Y Output Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |MDYADDR |Motion Detection Temp Y Output Address Register (Word Alignment) + */ + __IO uint32_t MDYADDR; + + /** + * SEPIA + * =================================================================================================== + * Offset: 0x1C Sepia Effect Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |VCOMP |Define the constant V component while Sepia color effect is turned on. + * |[8:15] |UCOMP |Define the constant U component while Sepia color effect is turned on. + */ + __IO uint32_t SEPIA; + + /** + * CWSP + * =================================================================================================== + * Offset: 0x20 Cropping Window Starting Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |CWSADDRH |Cropping Window Horizontal Starting Address + * |[16:26] |CWSADDRV |Cropping Window Vertical Starting Address + */ + __IO uint32_t CWSP; + + /** + * CWS + * =================================================================================================== + * Offset: 0x24 Cropping Window Size Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |CIWW |Cropping Image Window Width + * |[16:26] |CIWH |Cropping Image Window Height + */ + __IO uint32_t CWS; + + /** + * PKTSL + * =================================================================================================== + * Offset: 0x28 Packet Scaling Vertical/Horizontal Factor Register (LSB) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |PKTSHML |Packet Scaling Horizontal Factor M (Lower 8-Bit) + * | | |Specifies the lower 8-bit of denominator part (M) of the horizontal scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PKDSHMH) to form a 16-bit denominator (M) of vertical factor. + * | | |The output image width will be equal to the image width * N/M. + * | | |Note: The value of N must be equal to or less than M. + * |[8:15] |PKTSHNL |Packet Scaling Horizontal Factor N (Lower 8-Bit) + * | | |Specify the lower 8-bit of numerator part (N) of the horizontal scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PKDSHNH) to form a 16-bit numerator of horizontal factor. + * |[16:23] |PKTSVML |Packet Scaling Vertical Factor M (Lower 8-Bit) + * | | |Specify the lower 8-bit of denominator part (M) of the vertical scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PKDSVMH) to form a 16-bit denominator (M) of vertical factor. + * | | |The output image width will be equal to the image height * N/M. + * | | |Note: The value of N must be equal to or less than M. + * |[24:31] |PKTSVNL |Packet Scaling Vertical Factor N (Lower 8-Bit) + * | | |Specify the lower 8-bit of numerator part (N) of the vertical scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PKDSVNH) to form a 16-bit numerator of vertical factor + */ + __IO uint32_t PKTSL; + + /** + * PLNSL + * =================================================================================================== + * Offset: 0x2C Planar Scaling Vertical/Horizontal Factor Register (LSB) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |PLNSHML |Planar Scaling Horizontal Factor M (Lower 8-Bit) + * | | |Specify the lower 8-bit of denominator part (M) of the horizontal scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PNDSHMH) to form a 16-bit denominator (M) of vertical factor. + * | | |The output image width will be equal to the image width * N/M. + * | | |Note: The value of N must be equal to or less than M. + * |[8:15] |PLNSHNL |Planar Scaling Horizontal Factor N (Lower 8-Bit) + * | | |Specify the lower 8-bit of numerator part (N) of the horizontal scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PNDSHNH) to form a 16-bit numerator of horizontal factor. + * |[16:23] |PLNSVML |Planar Scaling Vertical Factor M (Lower 8-Bit) + * | | |Specify the lower 8-bit of denominator part (M) of the vertical scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PNDSVMH) to form a 16-bit denominator (M) of vertical factor. + * | | |The output image width will be equal to the image height * N/M. + * | | |Note: The value of N must be equal to or less than M. + * |[24:31] |PLNSVNL |Planar Scaling Vertical Factor N (Lower 8-Bit) + * | | |Specify the lower 8-bit of numerator part (N) of the vertical scaling factor. + * | | |The lower 8-bit will be cascaded with higher 8-bit (PNDSVNH) to form a 16-bit numerator of vertical factor. + */ + __IO uint32_t PLNSL; + + /** + * FRCTL + * =================================================================================================== + * Offset: 0x30 Scaling Frame Rate Factor Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |FRM |Scaling Frame Rate Factor M + * | | |Specify the denominator part (M) of the frame rate scaling factor. + * | | |The output image frame rate will be equal to input image frame rate * (N/M). + * | | |Note: The value of N must be equal to or less than M. + * |[8:13] |FRN |Scaling Frame Rate Factor N + * | | |Specify the denominator part (N) of the frame rate scaling factor. + */ + __IO uint32_t FRCTL; + + /** + * STRIDE + * =================================================================================================== + * Offset: 0x34 Frame Output Pixel Stride Width Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:13] |PKTSTRIDE |Packet Frame Output Pixel Stride Width + * | | |The output pixel stride size of packet pipe. + * |[16:29] |PLNSTRIDE |Planar Frame Output Pixel Stride Width + * | | |The output pixel stride size of planar pipe. + */ + __IO uint32_t STRIDE; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * FIFOTH + * =================================================================================================== + * Offset: 0x3C FIFO Threshold Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PLNVFTH |Planar V FIFO Threshold + * |[8:11] |PLNUFTH |Planar U FIFO Threshold + * |[16:20] |PLNYFTH |Planar Y FIFO Threshold + * |[24:28] |PKTFTH |Packet FIFO Threshold + * |[31] |OVF |FIFO Overflow Flag + */ + __IO uint32_t FIFOTH; + + /** + * CMPADDR + * =================================================================================================== + * Offset: 0x40 Compare Memory Base Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CMPADDR |Compare Memory Base Address + * | | |Word aligns address; ignore the bits [1:0]. + */ + __IO uint32_t CMPADDR; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * PKTSM + * =================================================================================================== + * Offset: 0x48 Packet Scaling Vertical/Horizontal Factor Register (MSB) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |PKTSHMH |Packet Scaling Horizontal Factor M (Higher 8-Bit) + * | | |Specify the lower 8-bit of denominator part (M) of the horizontal scaling factor. + * | | |Please refer to the register CAP_PKTSL?for the detailed operation. + * |[8:15] |PKTSHNH |Packet Scaling Horizontal Factor N (Higher 8-Bit) + * | | |Specify the lower 8-bit of numerator part (N) of the horizontal scaling factor. + * | | |Please refer to the register CAP_PKTSL for the detailed operation. + * |[16:23] |PKTSVMH |Packet Scaling Vertical Factor M (Higher 8-Bit) + * | | |Specify the lower 8-bit of denominator part (M) of the vertical scaling factor. + * | | |Please refer to the register CAP_PKTSL to check the cooperation between these two registers. + * |[24:31] |PKTSVNH |Packet Scaling Vertical Factor N (Higher 8-Bit) + * | | |Specify the higher 8-bit of numerator part (N) of the vertical scaling factor. + * | | |Please refer to the register CAP_PKTSL?to check the cooperation between these two registers. + */ + __IO uint32_t PKTSM; + + /** + * PLNSM + * =================================================================================================== + * Offset: 0x4C Planar Scaling Vertical/Horizontal Factor Register (MSB) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |PLNSHMH |Planar Scaling Horizontal Factor M (Higher 8-Bit) + * | | |Specifies the higher 8-bit of denominator part (M) of the horizontal scaling factor + * | | |For detailed programming, please refer to the register “CAP_PLNSL? + * |[8:15] |PLNSHNH |Planar Scaling Horizontal Factor N (Higher 8-Bit) + * | | |Specifies the higher 8-bit of numerator part (N) of the horizontal scaling factor. + * | | |For detailed programming, please refer to the register “CAP_PLNSL? + * |[16:23] |PLNSVMH |Planar Scaling Vertical Factor M (Higher 8-Bit) + * | | |Specifies the lower 8-bit of denominator part (M) of the vertical scaling factor. + * | | |For detailed programming, please refer to the register “CAP_PLNSL? + * |[24:31] |PLNSVNH |Planar Scaling Vertical Factor N (Higher 8-Bit) + * | | |Specifies the higher 8-bit of numerator part (N) of the vertical scaling factor. + * | | |For detailed programming, please refer to the register “CAP_PLNSL? + */ + __IO uint32_t PLNSM; + + /** + * CURADDRP + * =================================================================================================== + * Offset: 0x50 Current Packet System Memory Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CURADDR |Current Packet Output Memory Address + */ + __I uint32_t CURADDRP; + + /** + * CURADDRY + * =================================================================================================== + * Offset: 0x54 Current Planar Y System Memory Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CURADDR |Current Planar Y Output Memory Address + */ + __I uint32_t CURADDRY; + + /** + * CURADDRU + * =================================================================================================== + * Offset: 0x58 Current Planar U System Memory Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CURADDR |Current Planar U Output Memory Address + */ + __I uint32_t CURADDRU; + + /** + * CURVADDR + * =================================================================================================== + * Offset: 0x5C Current Planar V System Memory Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CURADDR |Current Planar V Output Memory Address + */ + __I uint32_t CURVADDR; + + /** + * PKTBA0 + * =================================================================================================== + * Offset: 0x60 System Memory Packet Base Address 0 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |BASEADDR |System Memory Packet Base Address 0 + * | | |Word aligns address; ignore the bits [1:0]. + */ + __IO uint32_t PKTBA0; + + /** + * PKTBA1 + * =================================================================================================== + * Offset: 0x64 System Memory Packet Base Address 1 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |BASEADDR |System Memory Packet Base Address 1 + * | | |Word aligns address; ignore the bits [1:0]. + */ + __IO uint32_t PKTBA1; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[6]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * YBA + * =================================================================================================== + * Offset: 0x80 System Memory Planar Y Base Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |BASEADDR |System Memory Planar Y Base Address + * | | |Word aligns address; ignore the bits [1:0]. + */ + __IO uint32_t YBA; + + /** + * UBA + * =================================================================================================== + * Offset: 0x84 System Memory Planar U Base Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |BASEADDR |System Memory Planar U Base Address + * | | |Word aligns address; ignore the bits [1:0]. + */ + __IO uint32_t UBA; + + /** + * VBA + * =================================================================================================== + * Offset: 0x88 System Memory Planar V Base Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |BASEADDR |System Memory Planar V Base Address + * | | |Word aligns address; ignore the bits [1:0]. + */ + __IO uint32_t VBA; + +} CAP_T; + +/** + @addtogroup CAP_CONST CAP Bit Field Definition + Constant Definitions for CAP Controller +@{ */ + +#define CAP_CTL_CAPEN_Pos (0) /*!< CAP_T::CTL: CAPEN Position */ +#define CAP_CTL_CAPEN_Msk (0x1ul << CAP_CTL_CAPEN_Pos) /*!< CAP_T::CTL: CAPEN Mask */ + +#define CAP_CTL_ADDRSW_Pos (3) /*!< CAP_T::CTL: ADDRSW Position */ +#define CAP_CTL_ADDRSW_Msk (0x1ul << CAP_CTL_ADDRSW_Pos) /*!< CAP_T::CTL: ADDRSW Mask */ + +#define CAP_CTL_PLNEN_Pos (5) /*!< CAP_T::CTL: PLNEN Position */ +#define CAP_CTL_PLNEN_Msk (0x1ul << CAP_CTL_PLNEN_Pos) /*!< CAP_T::CTL: PLNEN Mask */ + +#define CAP_CTL_PKTEN_Pos (6) /*!< CAP_T::CTL: PKTEN Position */ +#define CAP_CTL_PKTEN_Msk (0x1ul << CAP_CTL_PKTEN_Pos) /*!< CAP_T::CTL: PKTEN Mask */ + +#define CAP_CTL_SHUTTER_Pos (16) /*!< CAP_T::CTL: SHUTTER Position */ +#define CAP_CTL_SHUTTER_Msk (0x1ul << CAP_CTL_SHUTTER_Pos) /*!< CAP_T::CTL: SHUTTER Mask */ + +#define CAP_CTL_UPDATE_Pos (20) /*!< CAP_T::CTL: UPDATE Position */ +#define CAP_CTL_UPDATE_Msk (0x1ul << CAP_CTL_UPDATE_Pos) /*!< CAP_T::CTL: UPDATE Mask */ + +#define CAP_CTL_VPRST_Pos (24) /*!< CAP_T::CTL: VPRST Position */ +#define CAP_CTL_VPRST_Msk (0x1ul << CAP_CTL_VPRST_Pos) /*!< CAP_T::CTL: VPRST Mask */ + +#define CAP_PAR_INFMT_Pos (0) /*!< CAP_T::PAR: INFMT Position */ +#define CAP_PAR_INFMT_Msk (0x1ul << CAP_PAR_INFMT_Pos) /*!< CAP_T::PAR: INFMT Mask */ + +#define CAP_PAR_SENTYPE_Pos (1) /*!< CAP_T::PAR: SENTYPE Position */ +#define CAP_PAR_SENTYPE_Msk (0x1ul << CAP_PAR_SENTYPE_Pos) /*!< CAP_T::PAR: SENTYPE Mask */ + +#define CAP_PAR_INDATORD_Pos (2) /*!< CAP_T::PAR: INDATORD Position */ +#define CAP_PAR_INDATORD_Msk (0x3ul << CAP_PAR_INDATORD_Pos) /*!< CAP_T::PAR: INDATORD Mask */ + +#define CAP_PAR_OUTFMT_Pos (4) /*!< CAP_T::PAR: OUTFMT Position */ +#define CAP_PAR_OUTFMT_Msk (0x3ul << CAP_PAR_OUTFMT_Pos) /*!< CAP_T::PAR: OUTFMT Mask */ + +#define CAP_PAR_RANGE_Pos (6) /*!< CAP_T::PAR: RANGE Position */ +#define CAP_PAR_RANGE_Msk (0x1ul << CAP_PAR_RANGE_Pos) /*!< CAP_T::PAR: RANGE Mask */ + +#define CAP_PAR_PLNFMT_Pos (7) /*!< CAP_T::PAR: PLNFMT Position */ +#define CAP_PAR_PLNFMT_Msk (0x1ul << CAP_PAR_PLNFMT_Pos) /*!< CAP_T::PAR: PLNFMT Mask */ + +#define CAP_PAR_PCLKP_Pos (8) /*!< CAP_T::PAR: PCLKP Position */ +#define CAP_PAR_PCLKP_Msk (0x1ul << CAP_PAR_PCLKP_Pos) /*!< CAP_T::PAR: PCLKP Mask */ + +#define CAP_PAR_HSP_Pos (9) /*!< CAP_T::PAR: HSP Position */ +#define CAP_PAR_HSP_Msk (0x1ul << CAP_PAR_HSP_Pos) /*!< CAP_T::PAR: HSP Mask */ + +#define CAP_PAR_VSP_Pos (10) /*!< CAP_T::PAR: VSP Position */ +#define CAP_PAR_VSP_Msk (0x1ul << CAP_PAR_VSP_Pos) /*!< CAP_T::PAR: VSP Mask */ + +#define CAP_PAR_COLORCTL_Pos (11) /*!< CAP_T::PAR: COLORCTL Position */ +#define CAP_PAR_COLORCTL_Msk (0x3ul << CAP_PAR_COLORCTL_Pos) /*!< CAP_T::PAR: COLORCTL Mask */ + +#define CAP_PAR_FBB_Pos (18) /*!< CAP_T::PAR: FBB Position */ +#define CAP_PAR_FBB_Msk (0x1ul << CAP_PAR_FBB_Pos) /*!< CAP_T::PAR: FBB Mask */ + +#define CAP_INT_VINTF_Pos (0) /*!< CAP_T::INT: VINTF Position */ +#define CAP_INT_VINTF_Msk (0x1ul << CAP_INT_VINTF_Pos) /*!< CAP_T::INT: VINTF Mask */ + +#define CAP_INT_MEINTF_Pos (1) /*!< CAP_T::INT: MEINTF Position */ +#define CAP_INT_MEINTF_Msk (0x1ul << CAP_INT_MEINTF_Pos) /*!< CAP_T::INT: MEINTF Mask */ + +#define CAP_INT_ADDRMINTF_Pos (3) /*!< CAP_T::INT: ADDRMINTF Position */ +#define CAP_INT_ADDRMINTF_Msk (0x1ul << CAP_INT_ADDRMINTF_Pos) /*!< CAP_T::INT: ADDRMINTF Mask */ + +#define CAP_INT_MDINTF_Pos (4) /*!< CAP_T::INT: MDINTF Position */ +#define CAP_INT_MDINTF_Msk (0x1ul << CAP_INT_MDINTF_Pos) /*!< CAP_T::INT: MDINTF Mask */ + +#define CAP_INT_VIEN_Pos (16) /*!< CAP_T::INT: VIEN Position */ +#define CAP_INT_VIEN_Msk (0x1ul << CAP_INT_VIEN_Pos) /*!< CAP_T::INT: VIEN Mask */ + +#define CAP_INT_MEIEN_Pos (17) /*!< CAP_T::INT: MEIEN Position */ +#define CAP_INT_MEIEN_Msk (0x1ul << CAP_INT_MEIEN_Pos) /*!< CAP_T::INT: MEIEN Mask */ + +#define CAP_INT_ADDRMIEN_Pos (19) /*!< CAP_T::INT: ADDRMIEN Position */ +#define CAP_INT_ADDRMIEN_Msk (0x1ul << CAP_INT_ADDRMIEN_Pos) /*!< CAP_T::INT: ADDRMIEN Mask */ + +#define CAP_INT_MDIEN_Pos (20) /*!< CAP_T::INT: MDIEN Position */ +#define CAP_INT_MDIEN_Msk (0x1ul << CAP_INT_MDIEN_Pos) /*!< CAP_T::INT: MDIEN Mask */ + +#define CAP_POSTERIZE_VCOMP_Pos (0) /*!< CAP_T::POSTERIZE: VCOMP Position */ +#define CAP_POSTERIZE_VCOMP_Msk (0xfful << CAP_POSTERIZE_VCOMP_Pos) /*!< CAP_T::POSTERIZE: VCOMP Mask */ + +#define CAP_POSTERIZE_UCOMP_Pos (8) /*!< CAP_T::POSTERIZE: UCOMP Position */ +#define CAP_POSTERIZE_UCOMP_Msk (0xfful << CAP_POSTERIZE_UCOMP_Pos) /*!< CAP_T::POSTERIZE: UCOMP Mask */ + +#define CAP_POSTERIZE_YCOMP_Pos (16) /*!< CAP_T::POSTERIZE: YCOMP Position */ +#define CAP_POSTERIZE_YCOMP_Msk (0xfful << CAP_POSTERIZE_YCOMP_Pos) /*!< CAP_T::POSTERIZE: YCOMP Mask */ + +#define CAP_MD_MDEN_Pos (0) /*!< CAP_T::MD: MDEN Position */ +#define CAP_MD_MDEN_Msk (0x1ul << CAP_MD_MDEN_Pos) /*!< CAP_T::MD: MDEN Mask */ + +#define CAP_MD_MDBS_Pos (8) /*!< CAP_T::MD: MDBS Position */ +#define CAP_MD_MDBS_Msk (0x1ul << CAP_MD_MDBS_Pos) /*!< CAP_T::MD: MDBS Mask */ + +#define CAP_MD_MDSM_Pos (9) /*!< CAP_T::MD: MDSM Position */ +#define CAP_MD_MDSM_Msk (0x1ul << CAP_MD_MDSM_Pos) /*!< CAP_T::MD: MDSM Mask */ + +#define CAP_MD_MDDF_Pos (10) /*!< CAP_T::MD: MDDF Position */ +#define CAP_MD_MDDF_Msk (0x3ul << CAP_MD_MDDF_Pos) /*!< CAP_T::MD: MDDF Mask */ + +#define CAP_MD_MDTHR_Pos (16) /*!< CAP_T::MD: MDTHR Position */ +#define CAP_MD_MDTHR_Msk (0x1ful << CAP_MD_MDTHR_Pos) /*!< CAP_T::MD: MDTHR Mask */ + +#define CAP_MDADDR_MDADDR_Pos (0) /*!< CAP_T::MDADDR: MDADDR Position */ +#define CAP_MDADDR_MDADDR_Msk (0xfffffffful << CAP_MDADDR_MDADDR_Pos) /*!< CAP_T::MDADDR: MDADDR Mask */ + +#define CAP_MDYADDR_MDYADDR_Pos (0) /*!< CAP_T::MDYADDR: MDYADDR Position */ +#define CAP_MDYADDR_MDYADDR_Msk (0xfffffffful << CAP_MDYADDR_MDYADDR_Pos) /*!< CAP_T::MDYADDR: MDYADDR Mask */ + +#define CAP_SEPIA_VCOMP_Pos (0) /*!< CAP_T::SEPIA: VCOMP Position */ +#define CAP_SEPIA_VCOMP_Msk (0xfful << CAP_SEPIA_VCOMP_Pos) /*!< CAP_T::SEPIA: VCOMP Mask */ + +#define CAP_SEPIA_UCOMP_Pos (8) /*!< CAP_T::SEPIA: UCOMP Position */ +#define CAP_SEPIA_UCOMP_Msk (0xfful << CAP_SEPIA_UCOMP_Pos) /*!< CAP_T::SEPIA: UCOMP Mask */ + +#define CAP_CWSP_CWSADDRH_Pos (0) /*!< CAP_T::CWSP: CWSADDRH Position */ +#define CAP_CWSP_CWSADDRH_Msk (0xffful << CAP_CWSP_CWSADDRH_Pos) /*!< CAP_T::CWSP: CWSADDRH Mask */ + +#define CAP_CWSP_CWSADDRV_Pos (16) /*!< CAP_T::CWSP: CWSADDRV Position */ +#define CAP_CWSP_CWSADDRV_Msk (0x7fful << CAP_CWSP_CWSADDRV_Pos) /*!< CAP_T::CWSP: CWSADDRV Mask */ + +#define CAP_CWS_CWW_Pos (0) /*!< CAP_T::CWS: CWW Position */ +#define CAP_CWS_CWW_Msk (0xffful << CAP_CWS_CWW_Pos) /*!< CAP_T::CWS: CWW Mask */ + +#define CAP_CWS_CWH_Pos (16) /*!< CAP_T::CWS: CIWH Position */ +#define CAP_CWS_CWH_Msk (0x7fful << CAP_CWS_CWH_Pos) /*!< CAP_T::CWS: CIWH Mask */ + +#define CAP_PKTSL_PKTSHML_Pos (0) /*!< CAP_T::PKTSL: PKTSHML Position */ +#define CAP_PKTSL_PKTSHML_Msk (0xfful << CAP_PKTSL_PKTSHML_Pos) /*!< CAP_T::PKTSL: PKTSHML Mask */ + +#define CAP_PKTSL_PKTSHNL_Pos (8) /*!< CAP_T::PKTSL: PKTSHNL Position */ +#define CAP_PKTSL_PKTSHNL_Msk (0xfful << CAP_PKTSL_PKTSHNL_Pos) /*!< CAP_T::PKTSL: PKTSHNL Mask */ + +#define CAP_PKTSL_PKTSVML_Pos (16) /*!< CAP_T::PKTSL: PKTSVML Position */ +#define CAP_PKTSL_PKTSVML_Msk (0xfful << CAP_PKTSL_PKTSVML_Pos) /*!< CAP_T::PKTSL: PKTSVML Mask */ + +#define CAP_PKTSL_PKTSVNL_Pos (24) /*!< CAP_T::PKTSL: PKTSVNL Position */ +#define CAP_PKTSL_PKTSVNL_Msk (0xfful << CAP_PKTSL_PKTSVNL_Pos) /*!< CAP_T::PKTSL: PKTSVNL Mask */ + +#define CAP_PLNSL_PLNSHML_Pos (0) /*!< CAP_T::PLNSL: PLNSHML Position */ +#define CAP_PLNSL_PLNSHML_Msk (0xfful << CAP_PLNSL_PLNSHML_Pos) /*!< CAP_T::PLNSL: PLNSHML Mask */ + +#define CAP_PLNSL_PLNSHNL_Pos (8) /*!< CAP_T::PLNSL: PLNSHNL Position */ +#define CAP_PLNSL_PLNSHNL_Msk (0xfful << CAP_PLNSL_PLNSHNL_Pos) /*!< CAP_T::PLNSL: PLNSHNL Mask */ + +#define CAP_PLNSL_PLNSVML_Pos (16) /*!< CAP_T::PLNSL: PLNSVML Position */ +#define CAP_PLNSL_PLNSVML_Msk (0xfful << CAP_PLNSL_PLNSVML_Pos) /*!< CAP_T::PLNSL: PLNSVML Mask */ + +#define CAP_PLNSL_PLNSVNL_Pos (24) /*!< CAP_T::PLNSL: PLNSVNL Position */ +#define CAP_PLNSL_PLNSVNL_Msk (0xfful << CAP_PLNSL_PLNSVNL_Pos) /*!< CAP_T::PLNSL: PLNSVNL Mask */ + +#define CAP_FRCTL_FRM_Pos (0) /*!< CAP_T::FRCTL: FRM Position */ +#define CAP_FRCTL_FRM_Msk (0x3ful << CAP_FRCTL_FRM_Pos) /*!< CAP_T::FRCTL: FRM Mask */ + +#define CAP_FRCTL_FRN_Pos (8) /*!< CAP_T::FRCTL: FRN Position */ +#define CAP_FRCTL_FRN_Msk (0x3ful << CAP_FRCTL_FRN_Pos) /*!< CAP_T::FRCTL: FRN Mask */ + +#define CAP_STRIDE_PKTSTRIDE_Pos (0) /*!< CAP_T::STRIDE: PKTSTRIDE Position */ +#define CAP_STRIDE_PKTSTRIDE_Msk (0x3ffful << CAP_STRIDE_PKTSTRIDE_Pos) /*!< CAP_T::STRIDE: PKTSTRIDE Mask */ + +#define CAP_STRIDE_PLNSTRIDE_Pos (16) /*!< CAP_T::STRIDE: PLNSTRIDE Position */ +#define CAP_STRIDE_PLNSTRIDE_Msk (0x3ffful << CAP_STRIDE_PLNSTRIDE_Pos) /*!< CAP_T::STRIDE: PLNSTRIDE Mask */ + +#define CAP_FIFOTH_PLNVFTH_Pos (0) /*!< CAP_T::FIFOTH: PLNVFTH Position */ +#define CAP_FIFOTH_PLNVFTH_Msk (0xful << CAP_FIFOTH_PLNVFTH_Pos) /*!< CAP_T::FIFOTH: PLNVFTH Mask */ + +#define CAP_FIFOTH_PLNUFTH_Pos (8) /*!< CAP_T::FIFOTH: PLNUFTH Position */ +#define CAP_FIFOTH_PLNUFTH_Msk (0xful << CAP_FIFOTH_PLNUFTH_Pos) /*!< CAP_T::FIFOTH: PLNUFTH Mask */ + +#define CAP_FIFOTH_PLNYFTH_Pos (16) /*!< CAP_T::FIFOTH: PLNYFTH Position */ +#define CAP_FIFOTH_PLNYFTH_Msk (0x1ful << CAP_FIFOTH_PLNYFTH_Pos) /*!< CAP_T::FIFOTH: PLNYFTH Mask */ + +#define CAP_FIFOTH_PKTFTH_Pos (24) /*!< CAP_T::FIFOTH: PKTFTH Position */ +#define CAP_FIFOTH_PKTFTH_Msk (0x1ful << CAP_FIFOTH_PKTFTH_Pos) /*!< CAP_T::FIFOTH: PKTFTH Mask */ + +#define CAP_FIFOTH_OVF_Pos (31) /*!< CAP_T::FIFOTH: OVF Position */ +#define CAP_FIFOTH_OVF_Msk (0x1ul << CAP_FIFOTH_OVF_Pos) /*!< CAP_T::FIFOTH: OVF Mask */ + +#define CAP_CMPADDR_CMPADDR_Pos (0) /*!< CAP_T::CMPADDR: CMPADDR Position */ +#define CAP_CMPADDR_CMPADDR_Msk (0xfffffffful << CAP_CMPADDR_CMPADDR_Pos) /*!< CAP_T::CMPADDR: CMPADDR Mask */ + +#define CAP_PKTSM_PKTSHMH_Pos (0) /*!< CAP_T::PKTSM: PKTSHMH Position */ +#define CAP_PKTSM_PKTSHMH_Msk (0xfful << CAP_PKTSM_PKTSHMH_Pos) /*!< CAP_T::PKTSM: PKTSHMH Mask */ + +#define CAP_PKTSM_PKTSHNH_Pos (8) /*!< CAP_T::PKTSM: PKTSHNH Position */ +#define CAP_PKTSM_PKTSHNH_Msk (0xfful << CAP_PKTSM_PKTSHNH_Pos) /*!< CAP_T::PKTSM: PKTSHNH Mask */ + +#define CAP_PKTSM_PKTSVMH_Pos (16) /*!< CAP_T::PKTSM: PKTSVMH Position */ +#define CAP_PKTSM_PKTSVMH_Msk (0xfful << CAP_PKTSM_PKTSVMH_Pos) /*!< CAP_T::PKTSM: PKTSVMH Mask */ + +#define CAP_PKTSM_PKTSVNH_Pos (24) /*!< CAP_T::PKTSM: PKTSVNH Position */ +#define CAP_PKTSM_PKTSVNH_Msk (0xfful << CAP_PKTSM_PKTSVNH_Pos) /*!< CAP_T::PKTSM: PKTSVNH Mask */ + +#define CAP_PLNSM_PLNSHMH_Pos (0) /*!< CAP_T::PLNSM: PLNSHMH Position */ +#define CAP_PLNSM_PLNSHMH_Msk (0xfful << CAP_PLNSM_PLNSHMH_Pos) /*!< CAP_T::PLNSM: PLNSHMH Mask */ + +#define CAP_PLNSM_PLNSHNH_Pos (8) /*!< CAP_T::PLNSM: PLNSHNH Position */ +#define CAP_PLNSM_PLNSHNH_Msk (0xfful << CAP_PLNSM_PLNSHNH_Pos) /*!< CAP_T::PLNSM: PLNSHNH Mask */ + +#define CAP_PLNSM_PLNSVMH_Pos (16) /*!< CAP_T::PLNSM: PLNSVMH Position */ +#define CAP_PLNSM_PLNSVMH_Msk (0xfful << CAP_PLNSM_PLNSVMH_Pos) /*!< CAP_T::PLNSM: PLNSVMH Mask */ + +#define CAP_PLNSM_PLNSVNH_Pos (24) /*!< CAP_T::PLNSM: PLNSVNH Position */ +#define CAP_PLNSM_PLNSVNH_Msk (0xfful << CAP_PLNSM_PLNSVNH_Pos) /*!< CAP_T::PLNSM: PLNSVNH Mask */ + +#define CAP_CURADDRP_CURADDR_Pos (0) /*!< CAP_T::CURADDRP: CURADDR Position */ +#define CAP_CURADDRP_CURADDR_Msk (0xfffffffful << CAP_CURADDRP_CURADDR_Pos) /*!< CAP_T::CURADDRP: CURADDR Mask */ + +#define CAP_CURADDRY_CURADDR_Pos (0) /*!< CAP_T::CURADDRY: CURADDR Position */ +#define CAP_CURADDRY_CURADDR_Msk (0xfffffffful << CAP_CURADDRY_CURADDR_Pos) /*!< CAP_T::CURADDRY: CURADDR Mask */ + +#define CAP_CURADDRU_CURADDR_Pos (0) /*!< CAP_T::CURADDRU: CURADDR Position */ +#define CAP_CURADDRU_CURADDR_Msk (0xfffffffful << CAP_CURADDRU_CURADDR_Pos) /*!< CAP_T::CURADDRU: CURADDR Mask */ + +#define CAP_CURVADDR_CURADDR_Pos (0) /*!< CAP_T::CURVADDR: CURADDR Position */ +#define CAP_CURVADDR_CURADDR_Msk (0xfffffffful << CAP_CURVADDR_CURADDR_Pos) /*!< CAP_T::CURVADDR: CURADDR Mask */ + +#define CAP_PKTBA0_BASEADDR_Pos (0) /*!< CAP_T::PKTBA0: BASEADDR Position */ +#define CAP_PKTBA0_BASEADDR_Msk (0xfffffffful << CAP_PKTBA0_BASEADDR_Pos) /*!< CAP_T::PKTBA0: BASEADDR Mask */ + +#define CAP_PKTBA1_BASEADDR_Pos (0) /*!< CAP_T::PKTBA1: BASEADDR Position */ +#define CAP_PKTBA1_BASEADDR_Msk (0xfffffffful << CAP_PKTBA1_BASEADDR_Pos) /*!< CAP_T::PKTBA1: BASEADDR Mask */ + +#define CAP_YBA_BASEADDR_Pos (0) /*!< CAP_T::YBA: BASEADDR Position */ +#define CAP_YBA_BASEADDR_Msk (0xfffffffful << CAP_YBA_BASEADDR_Pos) /*!< CAP_T::YBA: BASEADDR Mask */ + +#define CAP_UBA_BASEADDR_Pos (0) /*!< CAP_T::UBA: BASEADDR Position */ +#define CAP_UBA_BASEADDR_Msk (0xfffffffful << CAP_UBA_BASEADDR_Pos) /*!< CAP_T::UBA: BASEADDR Mask */ + +#define CAP_VBA_BASEADDR_Pos (0) /*!< CAP_T::VBA: BASEADDR Position */ +#define CAP_VBA_BASEADDR_Msk (0xfffffffful << CAP_VBA_BASEADDR_Pos) /*!< CAP_T::VBA: BASEADDR Mask */ + +/**@}*/ /* CAP_CONST */ +/**@}*/ /* end of CAP register group */ + + +/*---------------------- Enhanced Input Capture Timer -------------------------*/ +/** + @addtogroup ECAP Enhanced Input Capture Timer(ECAP) + Memory Mapped Structure for ECAP Controller +@{ */ + +typedef struct { + + + /** + * CNT + * =================================================================================================== + * Offset: 0x00 Input Capture Counter (24-bit up counter) + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |VAL |Input Capture Timer/Counter + * | | |The input Capture Timer/Counter is a 24-bit up-counting counter. + * | | |The clock source for the counter is from the clock divider output which the CAP_CLK is software optionally divided by 1,4,16 or 32. + */ + __IO uint32_t CNT; + + /** + * HOLD0 + * =================================================================================================== + * Offset: 0x04 Input Capture Counter Hold Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |VAL |Input Capture Counter Hold Register + * | | |When an active input capture channel detects a valid edge signal change, the ECAP_CNT value is latched into the corresponding holding register. + * | | |Each input channel has itself holding register named by ECAP_HOLDx where x is from 0 to 2 to indicate inputs from IC0 to IC2, respectively. + */ + __IO uint32_t HOLD0; + + /** + * HOLD1 + * =================================================================================================== + * Offset: 0x08 Input Capture Counter Hold Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |VAL |Input Capture Counter Hold Register + * | | |When an active input capture channel detects a valid edge signal change, the ECAP_CNT value is latched into the corresponding holding register. + * | | |Each input channel has itself holding register named by ECAP_HOLDx where x is from 0 to 2 to indicate inputs from IC0 to IC2, respectively. + */ + __IO uint32_t HOLD1; + + /** + * HOLD2 + * =================================================================================================== + * Offset: 0x0C Input Capture Counter Hold Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |VAL |Input Capture Counter Hold Register + * | | |When an active input capture channel detects a valid edge signal change, the ECAP_CNT value is latched into the corresponding holding register. + * | | |Each input channel has itself holding register named by ECAP_HOLDx where x is from 0 to 2 to indicate inputs from IC0 to IC2, respectively. + */ + __IO uint32_t HOLD2; + + /** + * CNTCMP + * =================================================================================================== + * Offset: 0x10 Input Capture Counter Compare Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |VAL |Input Capture Counter Compare Register + * | | |If the compare function is enabled (CMPEN = 1), the compare register is loaded with the value that the compare function compares the capture counter (ECAP_CNT) with. + * | | |If the reload control is enabled (RLDEN = 1), an overflow event or capture events will trigger the hardware to reload ECAP_CNTCMP into ECAP_CNT. + */ + __IO uint32_t CNTCMP; + + /** + * CTL0 + * =================================================================================================== + * Offset: 0x14 Input Capture Control Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |NFDIS |Noise Filter Clock Pre-Divide Selection + * | | |To determine the sampling frequency of the Noise Filter clock + * | | |00 = CAP_CLK. + * | | |01 = CAP_CLK/2. + * | | |10 = CAP_CLK/4. + * | | |11 = CAP_CLK/16. + * |[3] |CAPNF_DIS |Input Capture Noise Filter Disable Control + * | | |0 = Noise filter of Input Capture Enabled. + * | | |1 = Noise filter of Input Capture Disabled. + * |[4] |CAPEN0 |Port Pin IC0 Input To Input Capture Unit Enable Control + * | | |0 = IC0 input to Input Capture Unit Disabled. + * | | |1 = IC0 input to Input Capture Unit Enabled. + * |[5] |CAPEN1 |Port Pin IC1 Input To Input Capture Unit Enable Control + * | | |0 = IC1 input to Input Capture Unit Disabled. + * | | |1 = IC1 input to Input Capture Unit Enabled. + * |[6] |CAPEN2 |Port Pin IC2 Input To Input Capture Unit Enable Control + * | | |0 = IC2 input to Input Capture Unit Disabled. + * | | |1 = IC2 input to Input Capture Unit Enabled. + * |[8:9] |CAPSEL0 |CAP0 Input Source Selection + * | | |00 = CAP0 input is from port pin IC0. + * | | |01 = CAP0 input is from signal CPO0 (Analog comparator 0 output). + * | | |10 = CAP0 input is from signal CHA of QEI controller unit x. + * | | |11 = CAP0 input is from signal OPDO0 (OP0 digital output). + * | | |Note: Input capture unit n matches QEI or comparator unit x, where x = 0~1. + * |[10:11] |CAPSEL1 |CAP1 Input Source Selection + * | | |00 = CAP1 input is from port pin IC1. + * | | |01 = CAP1 input is from signal CPO1 (Analog comparator 1 output). + * | | |10 = CAP1 input is from signal CHB of QEI controller unit x. + * | | |11 = CAP1 input is from signal OPDO1 (OP1 digital output). + * | | |Note: Input capture unit n matches QEI or comparator unit x, where x = 0~1. + * |[12:13] |CAPSEL2 |CAP2 Input Source Selection + * | | |00 = CAP2 input is from port pin IC2. + * | | |01 = CAP2 input is from signal CPO2 (Analog comparator 2 output). + * | | |10 = CAP2 input is from signal CHX of QEI controller unit x. + * | | |11 = CAP2 input is from signal ADCMPOx (ADC compare output x). + * | | |Note: Input capture unit n matches QEI or comparator unit x, where x = 0~1. + * |[16] |CAPIEN0 |Input Capture Channel 0 Interrupt Enable Control + * | | |0 = The flag CAPF0 can trigger Input Capture interrupt Disabled. + * | | |1 = The flag CAPF0 can trigger Input Capture interrupt Enabled. + * |[17] |CAPIEN1 |Input Capture Channel 1 Interrupt Enable Control + * | | |0 = The flag CAPF1 can trigger Input Capture interrupt Disabled. + * | | |1 = The flag CAPF1 can trigger Input Capture interrupt Enabled. + * |[18] |CAPIEN2 |Input Capture Channel 2 Interrupt Enable Control + * | | |0 = The flag CAPF2 can trigger Input Capture interrupt Disabled. + * | | |1 = The flag CAPF2 can trigger Input Capture interrupt Enabled. + * |[20] |OVIEN |OVF Trigger Input Capture Interrupt Enable Control + * | | |0 = The flag OVUNF can trigger Input Capture interrupt Disabled. + * | | |1 = The flag OVUNF can trigger Input Capture interrupt Enabled. + * |[21] |CMPIEN |CMPF Trigger Input Capture Interrupt Enable Control + * | | |0 = The flag CMPF can trigger Input Capture interrupt Disabled. + * | | |1 = The flag CMPF can trigger Input Capture interrupt Enabled. + * |[24] |CNTEN |Input Capture Counter Start + * | | |Setting this bit to 1, the capture counter (ECAP_CNT) starts up-counting synchronously with capture clock input (CAP_CLK). + * | | |0 = ECAP_CNT stop counting. + * | | |1 = ECAP_CNT starts up-counting. + * |[25] |CMPCLR |Input Capture Counter Cleared By Compare-Match Control + * | | |If this bit is set to 1, the capture counter (ECAP_CNT) will be cleared to 0 when the compare-match event (CAMCMPF = 1) occurs. + * | | |0 = Compare-match event (CAMCMPF) can clear capture counter (ECAP_CNT) Disabled. + * | | |1 = Compare-match event (CAMCMPF) can clear capture counter (ECAP_CNT) Enabled. + * |[26] |CPTCLR |Input Capture Counter Cleared By Capture Events Control + * | | |If this bit is set to 1, the capture counter (ECAP_CNT) will be cleared to zero when any one of capture events (CAPF0~3) occurs. + * | | |0 = Capture events (CAPF0~3) can clear capture counter (ECAP_CNT) Disabled. + * | | |1 = Capture events (CAPF0~3) can clear capture counter (ECAP_CNT) Enabled. + * |[27] |RLDEN |Reload Function Enable Control + * | | |Setting this bit to enable the reload function. + * | | |If the reload control is enabled, an overflow event (OVF) or capture events (CAPFx) will trigger the hardware to reload ECAP_CNTCMP into ECAP_CNT. + * | | |0 = The reload function Disabled. + * | | |1 = The reload function Enabled. + * |[28] |CMPEN |Compare Function Enable Control + * | | |The compare function in input capture timer/counter is to compare the dynamic counting ECAP_CNT with the compare register ECAP_CNTCMP, if ECAP_CNT value reaches ECAP_CNTCMP, the flag CMPF will be set. + * | | |0 = The compare function Disabled. + * | | |1 = The compare function Enabled. + * |[29] |CAPEN |Input Capture Timer/Counter Enable Control + * | | |0 = Input Capture function Disabled. + * | | |1 = Input Capture function Enabled. + */ + __IO uint32_t CTL0; + + /** + * CTL1 + * =================================================================================================== + * Offset: 0x18 Input Capture Control Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |EDGESEL0 |Channel 0 Captured Edge Selection + * | | |Input capture can detect falling edge change only, rising edge change only or one of both edge change + * | | |00 = Detect rising edge. + * | | |01 = Detect falling edge. + * | | |1x = Detect either rising or falling edge. + * |[2:3] |EDGESEL1 |Channel 1 Captured Edge Selection + * | | |Input capture can detect falling edge change only, rising edge change only or one of both edge change + * | | |00 = Detect rising edge. + * | | |01 = Detect falling edge. + * | | |1x = Detect either rising or falling edge. + * |[4:5] |EDGESEL2 |Channel 2 Captured Edge Selection + * | | |Input capture can detect falling edge change or rising edge change only, or one of both edge changes. + * | | |00 = Detect rising edge. + * | | |01 = Detect falling edge. + * | | |1x = Detect either rising or falling edge. + * |[8:10] |RLDSEL |ECAP_CNT Reload Trigger Source Selection + * | | |If the reload function is enabled RLDEN (ECAP_CTL0[27]) = 1, when a reload trigger event comes, the ECAP_CNT is reloaded with ECAP_CNTCMP. + * | | |RLDSEL[2:0] determines the ECAP_CNT reload trigger source + * | | |000 = CAPF0. + * | | |001 = CAPF1. + * | | |010 = CAPF2. + * | | |100 = OVF. + * | | |Others = Reserved. + * |[12:14] |CLKSEL |Capture Timer Clock Divide Selection + * | | |The capture timer clock has a pre-divider with four divided options controlled by CLKSEL[1:0]. + * | | |000 = CAP_CLK/1. + * | | |001 = CAP_CLK/4. + * | | |010 = CAP_CLK/16. + * | | |011 = CAP_CLK/32. + * | | |100 = CAP_CLK/64. + * | | |101 = CAP_CLK/96. + * | | |110 = CAP_CLK/112. + * | | |111 = CAP_CLK/128. + * |[16:17] |SRCSEL |Capture Timer/Counter Clock Source Selection + * | | |Select the capture timer/counter clock source. + * | | |00 = CAP_CLK (default). + * | | |01 = CAP0. + * | | |10 = CAP1. + * | | |11 = CAP2. + */ + __IO uint32_t CTL1; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x1C Input Capture Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CAPF0 |Input Capture Channel 0 Captured Flag + * | | |When the input capture channel 0 detects a valid edge change at CAP0 input, it will set flag CAPF0 to high. + * | | |0 = No valid edge change is detected at CAP0 input. + * | | |1 = A valid edge change is detected at CAP0 input. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[1] |CAPF1 |Input Capture Channel 1 Captured Flag + * | | |When the input capture channel 1 detects a valid edge change at CAP1 input, it will set flag CAPF1 to high. + * | | |0 = No valid edge change is detected at CAP1 input. + * | | |1 = A valid edge change is detected at CAP1 input. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[2] |CAPF2 |Input Capture Channel 2 Captured Flag + * | | |When the input capture channel 2 detects a valid edge change at CAP2 input, it will set flag CAPF2 to high. + * | | |0 = No valid edge change is detected at CAP2 input. + * | | |1 = A valid edge change is detected at CAP2 input. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[4] |CMPF |Input Capture Compare-Match Flag + * | | |If the input capture compare function is enabled, the flag is set by hardware while capture counter (ECAP_CNT) up counts and reach to the ECAP_CNTCMP value. + * | | |0 = ECAP_CNT does not match with ECAP_CNTCMP value. + * | | |1 = ECAP_CNT counts to the same as ECAP_CNTCMP value. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[5] |OVF |Input Capture Counter Overflow Flag + * | | |Flag is set by hardware when input capture up counter (ECAP_CNT) overflows from 0x00FF_FFFF to zero. + * | | |0 = No overflow occurs in ECAP_CNT. + * | | |1 = ECAP_CNT overflows. + * | | |Note: This bit is only cleared by writing 1 to it. + */ + __IO uint32_t STATUS; + +} ECAP_T; + +/** + @addtogroup ECAP_CONST ECAP Bit Field Definition + Constant Definitions for ECAP Controller +@{ */ + +#define ECAP_CNT_VAL_Pos (0) /*!< ECAP_T::CNT: VAL Position */ +#define ECAP_CNT_VAL_Msk (0xfffffful << ECAP_CNT_VAL_Pos) /*!< ECAP_T::CNT: VAL Mask */ + +#define ECAP_HOLD0_VAL_Pos (0) /*!< ECAP_T::HOLD0: VAL Position */ +#define ECAP_HOLD0_VAL_Msk (0xfffffful << ECAP_HOLD0_VAL_Pos) /*!< ECAP_T::HOLD0: VAL Mask */ + +#define ECAP_HOLD1_VAL_Pos (0) /*!< ECAP_T::HOLD1: VAL Position */ +#define ECAP_HOLD1_VAL_Msk (0xfffffful << ECAP_HOLD1_VAL_Pos) /*!< ECAP_T::HOLD1: VAL Mask */ + +#define ECAP_HOLD2_VAL_Pos (0) /*!< ECAP_T::HOLD2: VAL Position */ +#define ECAP_HOLD2_VAL_Msk (0xfffffful << ECAP_HOLD2_VAL_Pos) /*!< ECAP_T::HOLD2: VAL Mask */ + +#define ECAP_CNTCMP_VAL_Pos (0) /*!< ECAP_T::CNTCMP: VAL Position */ +#define ECAP_CNTCMP_VAL_Msk (0xfffffful << ECAP_CNTCMP_VAL_Pos) /*!< ECAP_T::CNTCMP: VAL Mask */ + +#define ECAP_CTL0_NFDIS_Pos (0) /*!< ECAP_T::CTL0: NFDIS Position */ +#define ECAP_CTL0_NFDIS_Msk (0x3ul << ECAP_CTL0_NFDIS_Pos) /*!< ECAP_T::CTL0: NFDIS Mask */ + +#define ECAP_CTL0_CAPNF_DIS_Pos (3) /*!< ECAP_T::CTL0: CAPNF_DIS Position */ +#define ECAP_CTL0_CAPNF_DIS_Msk (0x1ul << ECAP_CTL0_CAPNF_DIS_Pos) /*!< ECAP_T::CTL0: CAPNF_DIS Mask */ + +#define ECAP_CTL0_CAPEN0_Pos (4) /*!< ECAP_T::CTL0: CAPEN0 Position */ +#define ECAP_CTL0_CAPEN0_Msk (0x1ul << ECAP_CTL0_CAPEN0_Pos) /*!< ECAP_T::CTL0: CAPEN0 Mask */ + +#define ECAP_CTL0_CAPEN1_Pos (5) /*!< ECAP_T::CTL0: CAPEN1 Position */ +#define ECAP_CTL0_CAPEN1_Msk (0x1ul << ECAP_CTL0_CAPEN1_Pos) /*!< ECAP_T::CTL0: CAPEN1 Mask */ + +#define ECAP_CTL0_CAPEN2_Pos (6) /*!< ECAP_T::CTL0: CAPEN2 Position */ +#define ECAP_CTL0_CAPEN2_Msk (0x1ul << ECAP_CTL0_CAPEN2_Pos) /*!< ECAP_T::CTL0: CAPEN2 Mask */ + +#define ECAP_CTL0_CAPSEL0_Pos (8) /*!< ECAP_T::CTL0: CAPSEL0 Position */ +#define ECAP_CTL0_CAPSEL0_Msk (0x3ul << ECAP_CTL0_CAPSEL0_Pos) /*!< ECAP_T::CTL0: CAPSEL0 Mask */ + +#define ECAP_CTL0_CAPSEL1_Pos (10) /*!< ECAP_T::CTL0: CAPSEL1 Position */ +#define ECAP_CTL0_CAPSEL1_Msk (0x3ul << ECAP_CTL0_CAPSEL1_Pos) /*!< ECAP_T::CTL0: CAPSEL1 Mask */ + +#define ECAP_CTL0_CAPSEL2_Pos (12) /*!< ECAP_T::CTL0: CAPSEL2 Position */ +#define ECAP_CTL0_CAPSEL2_Msk (0x3ul << ECAP_CTL0_CAPSEL2_Pos) /*!< ECAP_T::CTL0: CAPSEL2 Mask */ + +#define ECAP_CTL0_CAPIEN0_Pos (16) /*!< ECAP_T::CTL0: CAPIEN0 Position */ +#define ECAP_CTL0_CAPIEN0_Msk (0x1ul << ECAP_CTL0_CAPIEN0_Pos) /*!< ECAP_T::CTL0: CAPIEN0 Mask */ + +#define ECAP_CTL0_CAPIEN1_Pos (17) /*!< ECAP_T::CTL0: CAPIEN1 Position */ +#define ECAP_CTL0_CAPIEN1_Msk (0x1ul << ECAP_CTL0_CAPIEN1_Pos) /*!< ECAP_T::CTL0: CAPIEN1 Mask */ + +#define ECAP_CTL0_CAPIEN2_Pos (18) /*!< ECAP_T::CTL0: CAPIEN2 Position */ +#define ECAP_CTL0_CAPIEN2_Msk (0x1ul << ECAP_CTL0_CAPIEN2_Pos) /*!< ECAP_T::CTL0: CAPIEN2 Mask */ + +#define ECAP_CTL0_OVIEN_Pos (20) /*!< ECAP_T::CTL0: OVIEN Position */ +#define ECAP_CTL0_OVIEN_Msk (0x1ul << ECAP_CTL0_OVIEN_Pos) /*!< ECAP_T::CTL0: OVIEN Mask */ + +#define ECAP_CTL0_CMPIEN_Pos (21) /*!< ECAP_T::CTL0: CMPIEN Position */ +#define ECAP_CTL0_CMPIEN_Msk (0x1ul << ECAP_CTL0_CMPIEN_Pos) /*!< ECAP_T::CTL0: CMPIEN Mask */ + +#define ECAP_CTL0_CNTEN_Pos (24) /*!< ECAP_T::CTL0: CNTEN Position */ +#define ECAP_CTL0_CNTEN_Msk (0x1ul << ECAP_CTL0_CNTEN_Pos) /*!< ECAP_T::CTL0: CNTEN Mask */ + +#define ECAP_CTL0_CMPCLR_Pos (25) /*!< ECAP_T::CTL0: CMPCLR Position */ +#define ECAP_CTL0_CMPCLR_Msk (0x1ul << ECAP_CTL0_CMPCLR_Pos) /*!< ECAP_T::CTL0: CMPCLR Mask */ + +#define ECAP_CTL0_CPTCLR_Pos (26) /*!< ECAP_T::CTL0: CPTCLR Position */ +#define ECAP_CTL0_CPTCLR_Msk (0x1ul << ECAP_CTL0_CPTCLR_Pos) /*!< ECAP_T::CTL0: CPTCLR Mask */ + +#define ECAP_CTL0_RLDEN_Pos (27) /*!< ECAP_T::CTL0: RLDEN Position */ +#define ECAP_CTL0_RLDEN_Msk (0x1ul << ECAP_CTL0_RLDEN_Pos) /*!< ECAP_T::CTL0: RLDEN Mask */ + +#define ECAP_CTL0_CMPEN_Pos (28) /*!< ECAP_T::CTL0: CMPEN Position */ +#define ECAP_CTL0_CMPEN_Msk (0x1ul << ECAP_CTL0_CMPEN_Pos) /*!< ECAP_T::CTL0: CMPEN Mask */ + +#define ECAP_CTL0_CAPEN_Pos (29) /*!< ECAP_T::CTL0: CAPEN Position */ +#define ECAP_CTL0_CAPEN_Msk (0x1ul << ECAP_CTL0_CAPEN_Pos) /*!< ECAP_T::CTL0: CAPEN Mask */ + +#define ECAP_CTL1_EDGESEL0_Pos (0) /*!< ECAP_T::CTL1: EDGESEL0 Position */ +#define ECAP_CTL1_EDGESEL0_Msk (0x3ul << ECAP_CTL1_EDGESEL0_Pos) /*!< ECAP_T::CTL1: EDGESEL0 Mask */ + +#define ECAP_CTL1_EDGESEL1_Pos (2) /*!< ECAP_T::CTL1: EDGESEL1 Position */ +#define ECAP_CTL1_EDGESEL1_Msk (0x3ul << ECAP_CTL1_EDGESEL1_Pos) /*!< ECAP_T::CTL1: EDGESEL1 Mask */ + +#define ECAP_CTL1_EDGESEL2_Pos (4) /*!< ECAP_T::CTL1: EDGESEL2 Position */ +#define ECAP_CTL1_EDGESEL2_Msk (0x3ul << ECAP_CTL1_EDGESEL2_Pos) /*!< ECAP_T::CTL1: EDGESEL2 Mask */ + +#define ECAP_CTL1_RLDSEL_Pos (8) /*!< ECAP_T::CTL1: RLDSEL Position */ +#define ECAP_CTL1_RLDSEL_Msk (0x7ul << ECAP_CTL1_RLDSEL_Pos) /*!< ECAP_T::CTL1: RLDSEL Mask */ + +#define ECAP_CTL1_CLKSEL_Pos (12) /*!< ECAP_T::CTL1: CLKSEL Position */ +#define ECAP_CTL1_CLKSEL_Msk (0x7ul << ECAP_CTL1_CLKSEL_Pos) /*!< ECAP_T::CTL1: CLKSEL Mask */ + +#define ECAP_CTL1_SRCSEL_Pos (16) /*!< ECAP_T::CTL1: SRCSEL Position */ +#define ECAP_CTL1_SRCSEL_Msk (0x3ul << ECAP_CTL1_SRCSEL_Pos) /*!< ECAP_T::CTL1: SRCSEL Mask */ + +#define ECAP_STATUS_CAPF0_Pos (0) /*!< ECAP_T::STATUS: CAPF0 Position */ +#define ECAP_STATUS_CAPF0_Msk (0x1ul << ECAP_STATUS_CAPF0_Pos) /*!< ECAP_T::STATUS: CAPF0 Mask */ + +#define ECAP_STATUS_CAPF1_Pos (1) /*!< ECAP_T::STATUS: CAPF1 Position */ +#define ECAP_STATUS_CAPF1_Msk (0x1ul << ECAP_STATUS_CAPF1_Pos) /*!< ECAP_T::STATUS: CAPF1 Mask */ + +#define ECAP_STATUS_CAPF2_Pos (2) /*!< ECAP_T::STATUS: CAPF2 Position */ +#define ECAP_STATUS_CAPF2_Msk (0x1ul << ECAP_STATUS_CAPF2_Pos) /*!< ECAP_T::STATUS: CAPF2 Mask */ + +#define ECAP_STATUS_CMPF_Pos (4) /*!< ECAP_T::STATUS: CMPF Position */ +#define ECAP_STATUS_CMPF_Msk (0x1ul << ECAP_STATUS_CMPF_Pos) /*!< ECAP_T::STATUS: CMPF Mask */ + +#define ECAP_STATUS_OVF_Pos (5) /*!< ECAP_T::STATUS: OVF Position */ +#define ECAP_STATUS_OVF_Msk (0x1ul << ECAP_STATUS_OVF_Pos) /*!< ECAP_T::STATUS: OVF Mask */ + +/**@}*/ /* ECAP_CONST */ +/**@}*/ /* end of ECAP register group */ + + +/*---------------------- System Clock Controller -------------------------*/ +/** + @addtogroup CLK System Clock Controller(CLK) + Memory Mapped Structure for CLK Controller +@{ */ + +typedef struct { + + + /** + * PWRCTL + * =================================================================================================== + * Offset: 0x00 System Power-down Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |HXTEN |4~24 MHz External High-Speed Crystal Enable Control (Write Protect) + * | | |The bit default value is set by flash controller user configuration register config0 [26:24]. + * | | |When the default clock source is from 4~24 MHz external high-speed crystal, this bit is set to 1 automatically + * | | |0 = HXT Disabled. + * | | |1 = HXT Enabled. + * |[1] |LXTEN |LXT Enable Control (Write Protect) + * | | |0 = LXT Disabled. + * | | |1 = LXT (Normal operation) Enabled. + * |[2] |HIRCEN |HIRC Enable Control (Write Protect) + * | | |0 = HIRC Disabled. + * | | |1 = HIRC Enabled. + * |[3] |LIRCEN |10 KHz Internal Low-Speed Oscillator Enable Control (Write Protect) + * | | |0 = LIRC Disabled. + * | | |1 = LIRC Enabled (default 1). + * |[4] |PDWKDLY |Wake-Up Delay Counter Enable Control (Write Protect) + * | | |When the chip wakes up from Power-down mode, the clock control will delay certain clock cycles to wait system clock stable. + * | | |The delayed clock cycle is 4096 clock cycles when chip work at HXT, and 256 clock cycles when chip works at HIRC. + * | | |0 = Clock cycles delay Disabled. + * | | |1 = Clock cycles delay Enabled. + * |[5] |PDWKIEN |Power-Down Mode Wake-Up Interrupt Enable Control (Write Protect) + * | | |0 = Power-down Mode Wake-up Interrupt Disabled. + * | | |1 = Power-down Mode Wake-up Interrupt Enabled. + * | | |Note: The interrupt will occur when both PDWKIF and PDWKIEN are high. + * |[6] |PDWKIF |Power-Down Mode Wake-Up Interrupt Status + * | | |Set by "power-down wake-up event", it indicates that resume from Power-down mode" + * | | |The flag is set if the GPIO, USB, UART, WDT, CAN, ACMP, BOD, RTC or SDHOST wake-up occurred + * | | |Note1: Write 1 to clear the bit to 0. + * | | |Note2: This bit works only if PDWKIEN (CLK_PWRCTL[5]) set to 1. + * |[7] |PDEN |System Power-Down Enable Control (Write Protect) + * | | |When this bit is set to 1, Power-down mode is enabled and chip power-down behavior will depend on the PDEN bit. + * | | |(a) If the PDEN is 0, then the chip enters Power-down mode immediately after + * | | |the PWR_DOWN_EN bit set. ( default) + * | | |(b) if the PDEN is 1, then the chip keeps active till the CPU sleep mode is also + * | | |active and then the chip enters Power-down mode + * | | |When chip wakes up from Power-down mode, this bit is auto cleared. Users need to set + * | | |this bit again for next power-down. + * | | |In Power-down mode, HXT and the HIRC will be disabled in this mode, but the LXT and + * | | |LIRC are not controlled by Power-down mode. + * | | |In Power-down mode, the PLL and system clock are disabled, and ignored the clock + * | | |source selection. The clocks of peripheral are not controlled by Power-down mode, if the + * | | |peripheral clock source is from LXT or the LIRC. + * | | |0 = Chip operating normally or chip in idle mode by WFI command. + * | | |1 = Chip enters Power-down mode instant or waits CPU sleep command WFI. + * |[8] |PDWTCPU |This Bit Control The Power-Down Entry Condition (Write Protect) + * | | |0 = Chip enters Power-down mode when the PWR_DOWN_EN bit is set to 1. + * | | |1 = Chip enters Power-down mode when the both PDEN and PWR_DOWN_EN bits are set to 1 and CPU run WFI instruction. + * |[9] |DBPDEN |Chip Entering Power-Down Even ICE Connected + * | | |0 = Chip enters power-down disabled in Debug mode. + * | | |1 = Chip enters power-down enabled in Debug mode. + */ + __IO uint32_t PWRCTL; + + /** + * AHBCLK + * =================================================================================================== + * Offset: 0x04 AHB Devices Clock Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1] |PDMACKEN |PDMA Controller Clock Enable Control + * | | |0 = PDMA engine clock Disabled. + * | | |1 = PDMA engine clock Enabled. + * |[2] |ISPCKEN |Flash ISP Controller Clock Enable Control + * | | |0 = Flash ISP engine clock Disabled. + * | | |1 = Flash ISP engine clock Enabled. + * |[3] |EBICKEN |EBI Controller Clock Enable Control + * | | |0 = EBI engine clock Disabled. + * | | |1 = EBI engine clock Enabled. + * |[4] |USBHCKEN |USB HOST Controller Clock Enable Control + * | | |0 = USB HOST engine clock Disabled. + * | | |1 = USB HOST engine clock Enabled. + * |[5] |EMACCKEN |Ethernet Controller Clock Enable Control (NUC472 Only) + * | | |0 = Ethernet Controller engine clock Disabled. + * | | |1 = Ethernet Controller engine clock Enabled. + * |[6] |SDHCKEN |SDHOST Controller Clock Enable Control + * | | |0 = SDHOST engine clock Disabled. + * | | |1 = SDHOST engine clock Enabled. + * |[7] |CRCCKEN |CRC Generator Controller Clock Enable Control + * | | |0 = CRC engine clock Disabled. + * | | |1 = CRC engine clock Enabled. + * |[8] |CAPCKEN |Image Capture Interface Controller Clock Enable Control + * | | |0 = CAP controller's clock Disabled. + * | | |1 = CAP controller's clock Enabled. + * |[9] |SENCKEN |Sensor Clock Enable Control + * | | |0 = Sensor clock Disabled. + * | | |1 = Sensor clock Enabled. + * |[10] |USBDCKEN |USB 2.0 Device Clock Enable Control + * | | |0 = USB device controller's clock Disabled. + * | | |1 = USB device controller's clock Enabled. + * |[12] |CRPTCKEN |Cryptographic Accelerator Clock Enable Control + * | | |0 = Cryptographic Accelerator clock Disabled. + * | | |1 = Cryptographic Accelerator clock Enabled. + */ + __IO uint32_t AHBCLK; + + /** + * APBCLK0 + * =================================================================================================== + * Offset: 0x08 APB Devices Clock Enable Control Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |WDTCKEN |Watchdog Timer Clock Enable Control (Write Protect) + * | | |This bit is the protected bit, which means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |0 = Watchdog Timer Clock Disabled. + * | | |1 = Watchdog Timer Clock Enabled. + * |[1] |RTCCKEN |Real-Time-Clock APB Interface Clock Enable Control + * | | |This bit is used to control the RTC APB clock only, The RTC engine clock source is from the 32.768 kHz external low-speed crystal. + * | | |0 = RTC Clock Disabled. + * | | |1 = RTC Clock Enabled. + * |[2] |TMR0CKEN |Timer0 Clock Enable Control + * | | |0 = Timer0 Clock Disabled. + * | | |1 = Timer0 Clock Enabled. + * |[3] |TMR1CKEN |Timer1 Clock Enable Control + * | | |0 = Timer1 Clock Disabled. + * | | |1 = Timer1 Clock Enabled. + * |[4] |TMR2CKEN |Timer2 Clock Enable Control + * | | |0 = Timer2 Clock Disabled. + * | | |1 = Timer2 Clock Enabled. + * |[5] |TMR3CKEN |Timer3 Clock Enable Control + * | | |0 = Timer3 Clock Disabled. + * | | |1 = Timer3 Clock Enabled. + * |[6] |CLKOCKEN |Clock Output Enable Control + * | | |0 = Clock Output Disabled. + * | | |1 = Clock Output Enabled. + * |[7] |ACMPCKEN |Analog Comparator Clock Enable Control + * | | |0 = Analog Comparator Clock Disabled. + * | | |1 = Analog Comparator Clock Enabled. + * |[8] |I2C0CKEN |I2C0 Clock Enable Control + * | | |0 = I2C0 Clock Disabled. + * | | |1 = I2C0 Clock Enabled. + * |[9] |I2C1CKEN |I2C1 Clock Enable Control + * | | |0 = I2C1 Clock Disabled. + * | | |1 = I2C1 Clock Enabled. + * |[10] |I2C2CKEN |I2C2 Clock Enable Control + * | | |0 = I2C2 Clock Disabled. + * | | |1 = I2C2 Clock Enabled. + * |[11] |I2C3CKEN |I2C3 Clock Enable Control + * | | |0 = I2C3 Clock Disabled. + * | | |1 = I2C3 Clock Enabled. + * |[12] |SPI0CKEN |SPI0 Clock Enable Control + * | | |0 = SPI0 Clock Disabled. + * | | |1= SPI0 Clock Enabled. + * |[13] |SPI1CKEN |SPI1 Clock Enable Control + * | | |0 = SPI1 Clock Disabled. + * | | |1 = SPI1 Clock Enabled. + * |[14] |SPI2CKEN |SPI2 Clock Enable Control + * | | |0 = SPI2 Clock Disabled. + * | | |1 = SPI2 Clock Enabled. + * |[15] |SPI3CKEN |SPI3 Clock Enable Control + * | | |0 = SPI3 Clock Disabled. + * | | |1 = SPI3 Clock Enabled. + * |[16] |UART0CKEN |UART0 Clock Enable Control + * | | |0 = UART0 clock Disabled. + * | | |1 = UART0 clock Enabled. + * |[17] |UART1CKEN |UART1 Clock Enable Control + * | | |0 = UART1 clock Disabled. + * | | |1 = UART1 clock Enabled. + * |[18] |UART2CKEN |UART2 Clock Enable Control + * | | |0 = UART2 clock Disabled. + * | | |1 = UART2 clock Enabled. + * |[19] |UART3CKEN |UART3 Clock Enable Control + * | | |0 = UART3 clock Disabled. + * | | |1 = UART3 clock Enabled. + * |[20] |UART4CKEN |UART4 Clock Enable Control + * | | |0 = UART4 clock Disabled. + * | | |1 = UART4 clock Enabled. + * |[21] |UART5CKEN |UART5 Clock Enable Control + * | | |0 = UART5 clock Disabled. + * | | |1 = UART5 clock Enabled. + * |[24] |CAN0CKEN |CAN Bus Controller-0 Clock Enable Control + * | | |0 = CAN0 clock Disabled. + * | | |1 = CAN0 clock Enabled. + * |[25] |CAN1CKEN |CAN Bus Controller-1 Clock Enable Control + * | | |0 = CAN1 clock Disabled. + * | | |1 = CAN1 clock Enabled. + * |[26] |OTGCKEN |USB 2.0 OTG Device Controller Clock Enable Control + * | | |0 = OTG clock Disabled. + * | | |1 = OTG clock Enabled. + * |[28] |ADCCKEN |Analog-Digital-Converter (ADC) Clock Enable Control + * | | |0 = ADC clock Disabled. + * | | |1 = ADC clock Enabled. + * |[29] |I2S0CKEN |I2S0 Clock Enable Control + * | | |0 = I2S Clock Disabled. + * | | |1 = I2S Clock Enabled. + * |[30] |I2S1CKEN |I2S1 Clock Enable Control + * | | |0 = I2S1 Clock Disabled. + * | | |1 = I2S1 Clock Enabled. + * |[31] |PS2CKEN |PS/2 Clock Enable Control + * | | |0 = PS/2 clock Disabled. + * | | |1 = PS/2 clock Enabled. + */ + __IO uint32_t APBCLK0; + + /** + * APBCLK1 + * =================================================================================================== + * Offset: 0x0C APB Devices Clock Enable Control Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SC0CKEN |SC0 Clock Enable Control + * | | |0 = SC0 Clock Disabled. + * | | |1 = SC0 Clock Enabled. + * |[1] |SC1CKEN |SC1 Clock Enable Control + * | | |0 = SC1 Clock Disabled. + * | | |1 = SC1 Clock Enabled. + * |[2] |SC2CKEN |SC2 Clock Enable Control + * | | |0 = SC2 Clock Disabled. + * | | |1 = SC2 Clock Enabled. + * |[3] |SC3CKEN |SC3 Clock Enable Control + * | | |0 = SC3 Clock Disabled. + * | | |1 = SC3 Clock Enabled. + * |[4] |SC4CKEN |SC4 Clock Enable Control + * | | |0 = SC4 Clock Disabled. + * | | |1 = SC4 Clock Enabled. + * |[5] |SC5CKEN |SC5 Clock Enable Control + * | | |0 = SC5 Clock Disabled. + * | | |1 = SC5 Clock Enabled. + * |[8] |I2C4CKEN |I2C4 Clock Enable Control + * | | |0 = I2C4 Clock Disabled. + * | | |1 = I2C4 Clock Enabled. + * |[16] |PWM0CH01CKEN|PWM0_01 Clock Enable Control + * | | |0 = PWM0_01 Clock Disabled. + * | | |1 = PWM0_01 Clock Enabled. + * |[17] |PWM0CH23CKEN|PWM0_23 Clock Enable Control + * | | |0 = PWM0_23 Clock Disabled. + * | | |1 = PWM0_23 Clock Enabled. + * |[18] |PWM0CH45CKEN|PWM0_45 Clock Enable Control + * | | |0 = PWM0_45 Clock Disabled. + * | | |1 = PWM0_45 Clock Enabled. + * |[19] |PWM1CH01CKEN|PWM1_01 Clock Enable Control + * | | |0 = PWM1_01 Clock Disabled. + * | | |1 = PWM1_01 Clock Enabled. + * |[21] |PWM1CH2345CKEN|PWM1_2345 Clock Enable Control + * | | |0 = PWM1_2345 Clock Disabled. + * | | |1 = PWM1_2345 Clock Enabled. + * |[22] |QEI0CKEN |Quadrature Encoder Interface (QEI0) Clock Enable Control + * | | |0 = QEI0 clock Disabled. + * | | |1 = QEI0 clock Enabled. + * |[23] |QEI1CKEN |Quadrature Encoder Interface (QEI1) Clock Enable Control + * | | |0 = QEI1 clock Disabled. + * | | |1 = QEI1 clock Enabled. + * |[26] |ECAP0CKEN |Enhance CAP (ECAP0) Clock Enable Control + * | | |0 = ECAP0 clock Disabled. + * | | |1 = ECAP0 clock Enabled. + * |[27] |ECAP1CKEN |Enhance CAP (ECAP1) Clock Enable Control + * | | |0 = ECAP1 clock Disabled. + * | | |1 = ECAP1 clock Enabled. + * |[28] |EPWM0CKEN |Enhance PWM0 (EPWM) Clock Enable Control + * | | |0 = EPWM0 clock Disabled. + * | | |1 = EPWM0 clock Enabled. + * |[29] |EPWM1CKEN |Enhance PWM1 (EPWM) Clock Enable Control + * | | |0 = EPWM1 clock Disabled. + * | | |1 = EPWM1 clock Enabled. + * |[30] |OPACKEN |OP Amplifier (OPA) Clock Enable Control + * | | |0 = OPA clock Disabled. + * | | |1 = OPA clock Enabled. + * |[31] |EADCCKEN |Enhance Analog-Digital-Converter (E ADC) Clock Enable Control + * | | |0 = EADC clock Disabled. + * | | |1 = EADC clock Enabled. + */ + __IO uint32_t APBCLK1; + + /** + * CLKSEL0 + * =================================================================================================== + * Offset: 0x10 Clock Source Select Control Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |HCLKSEL |HCLK Clock Source Selection (Write Protect) + * | | |Before clock switching, the related clock sources (both pre-select and new-select) must be turned on + * | | |1. + * | | |The 3-bit default value is reloaded from the value of CFOSC (Config0[26:24]) in user configuration register of Flash controller by any reset. + * | | |Therefore the default value is either 000b or 111b. + * | | |2. + * | | |These bits are protected bit, it means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PLL clock. + * | | |011 = Clock source from LIRC clock. + * | | |100 = Clock source from PLL2 clock. + * | | |111 = Clock source from HIRC clock. + * | | |Other = Reserved. + * |[3:5] |STCLKSEL |Cortex(TM)-M4 SysTick Clock Source Selection (Write Protect) + * | | |If SYST_CSR[2]=0, SysTick uses listed clock source below. + * | | |These bits are protected bit. + * | | |It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from HXT clock/2. + * | | |011 = Clock source from HCLK/2. + * | | |111 = Clock source from HIRC clock/2. + * |[6] |PCLKSEL |PCLK Clock Source Selection (Write Protect) + * | | |These bits are protected bit. + * | | |It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |0 = Clock source from HCLK. + * | | |1 = Clock source from HCLK/2. + * |[8] |USBHSEL |USB Host Clock Source Selection (Write Protect) + * | | |These bits are protected bit. + * | | |It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |0 = Clock source from PLL2. + * | | |1 = Clock source from PLL. + * |[16:17] |CAPSEL |Image Capture Interface Clock Source Selection + * | | |These bits are protected bit. + * | | |It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = Clock source from HCLK. + * | | |11 = Clock source from HIRC clock. + * |[20:21] |SDHSEL |SDHOST Engine Clock Source Selection + * | | |These bits are protected bit. + * | | |It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = Clock source from HCLK. + * | | |11 = Clock source from HIRC clock. + */ + __IO uint32_t CLKSEL0; + + /** + * CLKSEL1 + * =================================================================================================== + * Offset: 0x14 Clock Source Select Control Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |WDTSEL |Watchdog Timer Clock Source Selection (Write Protect) + * | | |These bits are protected bit,and programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + * | | |00 = Clock source from 4~24 MHz external high-speed crystal clock. + * | | |01 = Clock source from LXT clock. + * | | |10 = Clock source from HCLK/2048 clock. + * | | |11 = Clock source from LIRC clock. + * |[2:3] |EADCSEL |ADC Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = Clock source from PCLK. + * | | |11 = Clock source from HIRC clock. + * |[4] |SPI0SEL |SPI0 Clock Source Selection + * | | |0 = Clock source from PLL clock. + * | | |1 = Clock source from PCLK. + * |[5] |SPI1SEL |SPI1 Clock Source Selection + * | | |0 = Clock source from PLL clock. + * | | |1 = Clock source from PCLK. + * |[6] |SPI2SEL |SPI2 Clock Source Selection + * | | |0 = Clock source from PLL clock. + * | | |1 = Clock source from PCLK. + * |[7] |SPI3SEL |SPI3 Clock Source Selection + * | | |0 = Clock source from PLL clock. + * | | |1 = Clock source from PCLK. + * |[8:10] |TMR0SEL |TIMER0 Clock Source Selection + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from external trigger. + * | | |101 = Clock source from LIRC clock. + * | | |111 = Clock source from HIRC clock. + * | | |Others = reserved. + * |[12:14] |TMR1SEL |TIMER1 Clock Source Selection + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from external trigger. + * | | |101 = Clock source from LIRC clock. + * | | |111 = Clock source from HIRC clock. + * | | |Others = reserved. + * |[16:18] |TMR2SEL |TIMER2 Clock Source Selection + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from external trigger. + * | | |101 = Clock source from LIRC clock. + * | | |111 = Clock source from HIRC clock. + * | | |Others = reserved. + * |[20:22] |TMR3SEL |TIMER3 Clock Source Selection + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from external trigger. + * | | |101 = Clock source from LIRC clock. + * | | |111 = Clock source from HIRC clock. + * | | |Others = reserved. + * |[24:25] |UARTSEL |UART Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10/11 = Clock source from HIRC clock. + * |[28:29] |CLKOSEL |Clock Divider Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from LXT clock. + * | | |10 = Clock source from HCLK. + * | | |11 = Clock source from HIRC clock. + * |[30:31] |WWDTSEL |Window Watchdog Timer Clock Source Selection + * | | |00 = Reserved. + * | | |01 = Reserved. + * | | |10 = Clock source from HCLK/2048 clock. + * | | |11 = Clock source from LIRC clock. + */ + __IO uint32_t CLKSEL1; + + /** + * CLKSEL2 + * =================================================================================================== + * Offset: 0x18 Clock Source Select Control Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |PWM0CH01SEL|PWM0_0 And PWM0_1 Clock Source Selection + * | | |PWM0_0 and PWM0_1 uses the same Engine clock source, both of them use the same prescaler. + * | | |The Engine clock source of PWM0_0 and PWM0_1 is defined by PWM0CH01SEL[2:0]. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from HIRC clock. + * | | |100 = Clock source from LIRC clock. + * | | |Other = Reserved. + * |[4:6] |PPWM0CH23SEL|PWM0_2 And PWM0_3 Clock Source Selection + * | | |PWM0_2 and PWM0_3 uses the same Engine clock source, both of them use the same prescaler. + * | | |The Engine clock source of PWM0_2 and PWM0_3 is defined by PPWM0CH23SEL[2:0]. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from HIRC clock. + * | | |100 = Clock source from LIRC clock. + * | | |Other = Reserved. + * |[8:10] |PWM0CH45SEL|PWM0_4 And PWM0_5 Clock Source Selection + * | | |PWM0_4 and PWM0_5 used the same Engine clock source; both of them use the same prescaler. + * | | |The Engine clock source of PWM0_4 and PWM0_5 is defined by PWM0CH45SEL[2:0]. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from HIRC clock. + * | | |100 = Clock source from LIRC clock. + * | | |Other = Reserved. + * |[12:14] |PWM1CH01SEL|PWM1_0 And PWM1_1 Clock Source Selection + * | | |PWM1_0 and PWM1_1 uses the same Engine clock source, both of them use the same prescaler. + * | | |The Engine clock source of PWM1_0 and PWM1_1 is defined by PWM1CH01SEL[2:0]. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from HIRC clock. + * | | |100 = Clock source from LIRC clock. + * | | |Other = Reserved. + * |[16:18] |PWM1CH23SEL|PWM1_2 And PWM1_3 Clock Source Selection + * | | |PWM1_2 and PWM1_3 uses the same Engine clock source, both of them use the same prescaler. + * | | |The Engine clock source of PWM1_2 and PWM1_3 is defined by PWM1CH23SEL[2:0]. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from HIRC clock. + * | | |100= Clock source from LIRC clock. + * | | |Other = Reserved. + * |[20:22] |PWM1CH45SEL|PWM1_4 And PWM1_5 Clock Source Selection + * | | |PWM1_4 and PWM1_5 used the same Engine clock source; both of them use the same prescaler. + * | | |The Engine clock source of PWM1_4 and PWM1_5 is defined by PWM1CH45SEL[2:0]. + * | | |000 = Clock source from HXT clock. + * | | |001 = Clock source from LXT clock. + * | | |010 = Clock source from PCLK. + * | | |011 = Clock source from HIRC clock. + * | | |100 = Clock source from LIRC clock. + * | | |Other = Reserved. + */ + __IO uint32_t CLKSEL2; + + /** + * CLKSEL3 + * =================================================================================================== + * Offset: 0x1C Clock Source Select Control Register 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |SC0SEL |SC0 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = PCLK. + * | | |11 = Clock source from HIRC clock. + * |[2:3] |SC1SEL |SC1 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = PCLK. + * | | |11 = Clock source from HIRC clock. + * |[4:5] |SC2SEL |SC2 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = PCLK. + * | | |11 = Clock source from HIRC clock. + * |[6:7] |SC3SEL |SC3 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = PCLK. + * | | |11 = Clock source from HIRC clock. + * |[8:9] |SC4SEL |SC4 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = PCLK. + * | | |11 = Clock source from HIRC clock. + * |[10:11] |SC5SEL |SC5 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = PCLK. + * | | |11 = Clock source from HIRC clock. + * |[16:17] |I2S0SEL |I2S0 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = Clock source from PCLK. + * | | |11 = Clock source from HIRC clock. + * |[18:19] |I2S1SEL |I2S1 Clock Source Selection + * | | |00 = Clock source from HXT clock. + * | | |01 = Clock source from PLL clock. + * | | |10 = Clock source from PCLK. + * | | |11 = Clock source from HIRC clock. + */ + __IO uint32_t CLKSEL3; + + /** + * CLKDIV0 + * =================================================================================================== + * Offset: 0x20 Clock Divider Number Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |HCLKDIV |HCLK Clock Divide Number From HCLK Clock Source + * | | |HCLK clock frequency = (HCLK clock source frequency) / (HCLKDIV + 1). + * |[4:7] |USBHDIV |USB Host Clock Divide Number From PLL Clock + * | | |USB Host clock frequency = (PLL frequency) / (USBHDIV + 1). + * |[8:11] |UARTDIV |UART Clock Divide Number From UART Clock Source + * | | |UART clock frequency = (UART clock source frequency) / (UARTDIV + 1). + * |[16:23] |ADCDIV |ADC Clock Divide Number From ADC Clock Source + * | | |ADC clock frequency = (ADC clock source frequency) / (ADCDIV + 1). + * |[24:31] |SDHDIV |SDHOST Clock Divide Number From SDHOST Clock Source + * | | |SDHOST clock frequency = (SDHOST clock source frequency) / (SDHDIV + 1). + */ + __IO uint32_t CLKDIV0; + + /** + * CLKDIV1 + * =================================================================================================== + * Offset: 0x24 Clock Divider Number Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SC0DIV |SC0 Clock Divide Number From SC0 Clock Source + * | | |SC0 clock frequency = (SC0 clock source frequency ) / (SC0DIV+ 1). + * |[8:15] |SC1DIV |SC1 Clock Divide Number From SC1 Clock Source + * | | |SC1 clock frequency = (SC1 clock source frequency ) / (SC1DIV + 1). + * |[16:23] |SC2DIV |SC2 Clock Divide Number From SC2 Clock Source + * | | |SC2 clock frequency = (SC2 clock source frequency ) / (SC2DIV + 1). + * |[24:31] |SC3DIV |SC3 Clock Divide Number From SC3 Clock Source + * | | |SC3 clock frequency = (SC3 clock source frequency ) / (SC3DIV+ 1). + */ + __IO uint32_t CLKDIV1; + + /** + * CLKDIV2 + * =================================================================================================== + * Offset: 0x28 Clock Divider Number Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SC4DIV |SC4 Clock Divide Number From SC4 Clock Source + * | | |SC4 clock frequency = (SC4 clock source frequency ) / (SC4DIV + 1). + * |[8:15] |SC5DIV |SC5 Clock Divide Number From SC5 Clock Source + * | | |SC5 clock frequency = (SC5 clock source frequency ) / (SC5DIV + 1). + */ + __IO uint32_t CLKDIV2; + + /** + * CLKDIV3 + * =================================================================================================== + * Offset: 0x2C Clock Divider Number Register 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |CAPDIV |Image Capture Sensor Clock Divide Number From ICAP Clock Source + * | | |Image sensor clock frequency = (ICAP clock source frequency) / (ICAPDIV + 1). + * |[8:15] |VSENSEDIV |Video Pixel Clock Divide Number From ICAP Clock Source + * | | |Video pixel clock frequency = (ICAP clock source frequency) / (VSENSEDIV + 1). + * |[16:23] |EMACDIV |Ethernet Clock Divide Number Form HCLK (NUC472 Only) + * | | |EMAC MDCLK clock frequency = (HCLK) / (EMACDIV + 1). + */ + __IO uint32_t CLKDIV3; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[4]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * PLLCTL + * =================================================================================================== + * Offset: 0x40 PLL Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:8] |FBDIV |PLL Feedback Divider Control Pins + * | | |Refer to the formulas below the table. + * |[9:13] |INDIV |PLL Input Divider Control Pins + * | | |Refer to the formulas below the table. + * |[14:15] |OUTDV |PLL Output Divider Control Pins + * | | |Refer to the formulas below the table. + * |[16] |PD |Power-Down Mode + * | | |If set the PWR_DOWN_EN bit to 1 in CLK_PWRCTL register, the PLL will enter Power-down mode, too. + * | | |0 = PLL is in normal mode. + * | | |1 = PLL is in Power-down mode (default). + * |[17] |BP |PLL Bypass Control + * | | |0 = PLL is in normal mode (default). + * | | |1 = PLL clock output is same as clock input (XTALin). + * |[18] |OE |PLL OE (FOUT Enable) Pin Control + * | | |0 = PLL FOUT Enabled. + * | | |1 = PLL FOUT is fixed low. + * |[19] |PLLSRC |PLL Source Clock Selection + * | | |0 = PLL source clock from HXT. + * | | |1 = PLL source clock from HIRC. + * |[20] |PLLREMAP |PLL Remap Enable Bit + * | | |0 = PLL remap enable. + * | | |1 = PLL remap disable. + */ + __IO uint32_t PLLCTL; + + /** + * PLL2CTL + * =================================================================================================== + * Offset: 0x44 PLL2 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |PLL2DIV |PLL2 Divider Control + * | | |PLL2 clock frequency = (480 MHz) / 2 / (PLL2DIV + 1). + * | | |Note: Max. PLL frequency 240 MHz when XTL12M. + * |[8] |PLL2CKEN |USB OHY 480 MHz Enable Control + * | | |This bit enables USB PHY PLL (480 MHz), and user needs to care extend 12 MHz source. + * | | |0 = USB PHY PLL (480 MHz) Disabled. + * | | |1 = USB PHY PLL (480 MHz) Enabled. + */ + __IO uint32_t PLL2CTL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[2]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * STATUS + * =================================================================================================== + * Offset: 0x50 Clock Status Monitor Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |HXTSTB |4~24 MHz External High-Speed Crystal Clock(HXT) Source Stable Flag + * | | |0 = HXT clock is not stable or disabled. + * | | |1 = HXT clock is stable. + * | | |Note: This bit is read only. + * |[1] |LXTSTB |32.768 KHz External Low-Speed Crystal Clock(LXT) Source Stable Flag + * | | |0 = LXT clock is not stable or disabled. + * | | |1 = LXT clock is stabled. + * | | |Note: This is read only. + * |[2] |PLLSTB |Internal PLL Clock Source Stable Flag + * | | |0 = Internal PLL clock is not stable or disabled. + * | | |1 = Internal PLL clock is stable. + * | | |Note: This bit is read only. + * |[3] |LIRCSTB |10 KHz Internal Low-Speed Oscillator Clock (LIRC)Source Stable Flag + * | | |0 = LIRC clock is not stable or disabled. + * | | |1 = LIRC clock is stable. + * | | |Note: This bit is read only. + * |[4] |HIRCSTB |22.1184 MHz Internal High-Speed Oscillator Clock (HIRC) Clock Source Stable Flag + * | | |0 = HIRC clock is not stable or disabled. + * | | |1 = HIRC clock is stable. + * | | |Note: This bit is read only. + * |[5] |PLL2STB |Internal PLL2 Clock Source Stable Flag + * | | |0 = Internal PLL2 clock is not stable or disabled. + * | | |1 = Internal PLL2 clock is stable. + * | | |Note: This bit is read only. + * |[7] |CLKSFAIL |Clock Switching Fail Flag + * | | |0 = Clock switching success. + * | | |1 = Clock switching failure. + * | | |Note1: This bit is updated when software switches system clock source. + * | | |If switch target clock is stable, this bit will be set to 0. + * | | |If switch target clock is not stable, this bit will be set to 1. + * | | |Note2: Write 1 to clear the bit to 0. + */ + __IO uint32_t STATUS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * CLKOCTL + * =================================================================================================== + * Offset: 0x60 Frequency Divider Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |FSEL |Divider Output Frequency Selection + * | | |The formula of output frequency is: + * | | |Fout = Fin/2(N+1). + * | | |Fin is the input clock frequency. + * | | |Fout is the frequency of divider output clock. + * | | |N is the 4-bit value of FSEL[3:0]. + * |[4] |CLKOEN |Clock Output Enable Control + * | | |0 = Clock Output disabled. + * | | |1 = Clock Output enabled. + * |[5] |DIV1EN |Frequency Divider 1 Enable Control + * | | |0 = Divider output frequency is dependent on FSEL value when FDIVEN is enabled. + * | | |1 = Divider output frequency is input clock frequency. + */ + __IO uint32_t CLKOCTL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE3[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * CLKDCTL + * =================================================================================================== + * Offset: 0x70 Clock Fail Detector Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SYSFDEN |System Clock Detector Enable Control + * | | |0 = system clock fail interrupt disabled. + * | | |1 = system clock fail interrupt enabled. + * |[1] |SYSFIEN |System Clock Detector Interrupt Enable Control + * | | |0 = system clock fail interrupt disabled. + * | | |1 = system clock fail interrupt enabled. + * |[2] |SYSFIF |System Clock Detect Fail Flag + * | | |0 = System clock normal. + * | | |1 = System clock abnormal (write " 1" to clear). + * |[8] |IRCDEN |Internal RC Clock Detector Enable Control + * | | |0 = IRC clock fail interrupt disabled. + * | | |1 = IRC clock fail interrupt enabled. + * |[9] |IRCFIEN |Internal RC Clock Detector Interrupt Enable Control + * | | |0 = IRC clock fail interrupt disabled. + * | | |1 = IRC clock fail interrupt enabled. + * |[10] |IRCFIF |Internal RC Clock Fail Flag + * | | |0 = IRC clock normal. + * | | |1 = IRC abnormal (write "1" to clear) . + */ + __IO uint32_t CLKDCTL; + +} CLK_T; + +/** + @addtogroup CLK_CONST CLK Bit Field Definition + Constant Definitions for CLK Controller +@{ */ + +#define CLK_PWRCTL_HXTEN_Pos (0) /*!< CLK_T::PWRCTL: HXTEN Position */ +#define CLK_PWRCTL_HXTEN_Msk (0x1ul << CLK_PWRCTL_HXTEN_Pos) /*!< CLK_T::PWRCTL: HXTEN Mask */ + +#define CLK_PWRCTL_LXTEN_Pos (1) /*!< CLK_T::PWRCTL: LXTEN Position */ +#define CLK_PWRCTL_LXTEN_Msk (0x1ul << CLK_PWRCTL_LXTEN_Pos) /*!< CLK_T::PWRCTL: LXTEN Mask */ + +#define CLK_PWRCTL_HIRCEN_Pos (2) /*!< CLK_T::PWRCTL: HIRCEN Position */ +#define CLK_PWRCTL_HIRCEN_Msk (0x1ul << CLK_PWRCTL_HIRCEN_Pos) /*!< CLK_T::PWRCTL: HIRCEN Mask */ + +#define CLK_PWRCTL_LIRCEN_Pos (3) /*!< CLK_T::PWRCTL: LIRCEN Position */ +#define CLK_PWRCTL_LIRCEN_Msk (0x1ul << CLK_PWRCTL_LIRCEN_Pos) /*!< CLK_T::PWRCTL: LIRCEN Mask */ + +#define CLK_PWRCTL_PDWKDLY_Pos (4) /*!< CLK_T::PWRCTL: PDWKDLY Position */ +#define CLK_PWRCTL_PDWKDLY_Msk (0x1ul << CLK_PWRCTL_PDWKDLY_Pos) /*!< CLK_T::PWRCTL: PDWKDLY Mask */ + +#define CLK_PWRCTL_PDWKIEN_Pos (5) /*!< CLK_T::PWRCTL: PDWKIEN Position */ +#define CLK_PWRCTL_PDWKIEN_Msk (0x1ul << CLK_PWRCTL_PDWKIEN_Pos) /*!< CLK_T::PWRCTL: PDWKIEN Mask */ + +#define CLK_PWRCTL_PDWKIF_Pos (6) /*!< CLK_T::PWRCTL: PDWKIF Position */ +#define CLK_PWRCTL_PDWKIF_Msk (0x1ul << CLK_PWRCTL_PDWKIF_Pos) /*!< CLK_T::PWRCTL: PDWKIF Mask */ + +#define CLK_PWRCTL_PDEN_Pos (7) /*!< CLK_T::PWRCTL: PDEN Position */ +#define CLK_PWRCTL_PDEN_Msk (0x1ul << CLK_PWRCTL_PDEN_Pos) /*!< CLK_T::PWRCTL: PDEN Mask */ + +#define CLK_PWRCTL_PDWTCPU_Pos (8) /*!< CLK_T::PWRCTL: PDWTCPU Position */ +#define CLK_PWRCTL_PDWTCPU_Msk (0x1ul << CLK_PWRCTL_PDWTCPU_Pos) /*!< CLK_T::PWRCTL: PDWTCPU Mask */ + +#define CLK_PWRCTL_DBPDEN_Pos (9) /*!< CLK_T::PWRCTL: DBPDEN Position */ +#define CLK_PWRCTL_DBPDEN_Msk (0x1ul << CLK_PWRCTL_DBPDEN_Pos) /*!< CLK_T::PWRCTL: DBPDEN Mask */ + +#define CLK_AHBCLK_PDMACKEN_Pos (1) /*!< CLK_T::AHBCLK: PDMACKEN Position */ +#define CLK_AHBCLK_PDMACKEN_Msk (0x1ul << CLK_AHBCLK_PDMACKEN_Pos) /*!< CLK_T::AHBCLK: PDMACKEN Mask */ + +#define CLK_AHBCLK_ISPCKEN_Pos (2) /*!< CLK_T::AHBCLK: ISPCKEN Position */ +#define CLK_AHBCLK_ISPCKEN_Msk (0x1ul << CLK_AHBCLK_ISPCKEN_Pos) /*!< CLK_T::AHBCLK: ISPCKEN Mask */ + +#define CLK_AHBCLK_EBICKEN_Pos (3) /*!< CLK_T::AHBCLK: EBICKEN Position */ +#define CLK_AHBCLK_EBICKEN_Msk (0x1ul << CLK_AHBCLK_EBICKEN_Pos) /*!< CLK_T::AHBCLK: EBICKEN Mask */ + +#define CLK_AHBCLK_USBHCKEN_Pos (4) /*!< CLK_T::AHBCLK: USBHCKEN Position */ +#define CLK_AHBCLK_USBHCKEN_Msk (0x1ul << CLK_AHBCLK_USBHCKEN_Pos) /*!< CLK_T::AHBCLK: USBHCKEN Mask */ + +#define CLK_AHBCLK_EMACCKEN_Pos (5) /*!< CLK_T::AHBCLK: EMACCKEN Position */ +#define CLK_AHBCLK_EMACCKEN_Msk (0x1ul << CLK_AHBCLK_EMACCKEN_Pos) /*!< CLK_T::AHBCLK: EMACCKEN Mask */ + +#define CLK_AHBCLK_SDHCKEN_Pos (6) /*!< CLK_T::AHBCLK: SDHCKEN Position */ +#define CLK_AHBCLK_SDHCKEN_Msk (0x1ul << CLK_AHBCLK_SDHCKEN_Pos) /*!< CLK_T::AHBCLK: SDHCKEN Mask */ + +#define CLK_AHBCLK_CRCCKEN_Pos (7) /*!< CLK_T::AHBCLK: CRCCKEN Position */ +#define CLK_AHBCLK_CRCCKEN_Msk (0x1ul << CLK_AHBCLK_CRCCKEN_Pos) /*!< CLK_T::AHBCLK: CRCCKEN Mask */ + +#define CLK_AHBCLK_CAPCKEN_Pos (8) /*!< CLK_T::AHBCLK: CAPCKEN Position */ +#define CLK_AHBCLK_CAPCKEN_Msk (0x1ul << CLK_AHBCLK_CAPCKEN_Pos) /*!< CLK_T::AHBCLK: CAPCKEN Mask */ + +#define CLK_AHBCLK_SENCKEN_Pos (9) /*!< CLK_T::AHBCLK: SENCKEN Position */ +#define CLK_AHBCLK_SENCKEN_Msk (0x1ul << CLK_AHBCLK_SENCKEN_Pos) /*!< CLK_T::AHBCLK: SENCKEN Mask */ + +#define CLK_AHBCLK_USBDCKEN_Pos (10) /*!< CLK_T::AHBCLK: USBDCKEN Position */ +#define CLK_AHBCLK_USBDCKEN_Msk (0x1ul << CLK_AHBCLK_USBDCKEN_Pos) /*!< CLK_T::AHBCLK: USBDCKEN Mask */ + +#define CLK_AHBCLK_CRPTCKEN_Pos (12) /*!< CLK_T::AHBCLK: CRPTCKEN Position */ +#define CLK_AHBCLK_CRPTCKEN_Msk (0x1ul << CLK_AHBCLK_CRPTCKEN_Pos) /*!< CLK_T::AHBCLK: CRPTCKEN Mask */ + +#define CLK_APBCLK0_WDTCKEN_Pos (0) /*!< CLK_T::APBCLK0: WDTCKEN Position */ +#define CLK_APBCLK0_WDTCKEN_Msk (0x1ul << CLK_APBCLK0_WDTCKEN_Pos) /*!< CLK_T::APBCLK0: WDTCKEN Mask */ + +#define CLK_APBCLK0_RTCCKEN_Pos (1) /*!< CLK_T::APBCLK0: RTCCKEN Position */ +#define CLK_APBCLK0_RTCCKEN_Msk (0x1ul << CLK_APBCLK0_RTCCKEN_Pos) /*!< CLK_T::APBCLK0: RTCCKEN Mask */ + +#define CLK_APBCLK0_TMR0CKEN_Pos (2) /*!< CLK_T::APBCLK0: TMR0CKEN Position */ +#define CLK_APBCLK0_TMR0CKEN_Msk (0x1ul << CLK_APBCLK0_TMR0CKEN_Pos) /*!< CLK_T::APBCLK0: TMR0CKEN Mask */ + +#define CLK_APBCLK0_TMR1CKEN_Pos (3) /*!< CLK_T::APBCLK0: TMR1CKEN Position */ +#define CLK_APBCLK0_TMR1CKEN_Msk (0x1ul << CLK_APBCLK0_TMR1CKEN_Pos) /*!< CLK_T::APBCLK0: TMR1CKEN Mask */ + +#define CLK_APBCLK0_TMR2CKEN_Pos (4) /*!< CLK_T::APBCLK0: TMR2CKEN Position */ +#define CLK_APBCLK0_TMR2CKEN_Msk (0x1ul << CLK_APBCLK0_TMR2CKEN_Pos) /*!< CLK_T::APBCLK0: TMR2CKEN Mask */ + +#define CLK_APBCLK0_TMR3CKEN_Pos (5) /*!< CLK_T::APBCLK0: TMR3CKEN Position */ +#define CLK_APBCLK0_TMR3CKEN_Msk (0x1ul << CLK_APBCLK0_TMR3CKEN_Pos) /*!< CLK_T::APBCLK0: TMR3CKEN Mask */ + +#define CLK_APBCLK0_CLKOCKEN_Pos (6) /*!< CLK_T::APBCLK0: CLKOCKEN Position */ +#define CLK_APBCLK0_CLKOCKEN_Msk (0x1ul << CLK_APBCLK0_CLKOCKEN_Pos) /*!< CLK_T::APBCLK0: CLKOCKEN Mask */ + +#define CLK_APBCLK0_ACMPCKEN_Pos (7) /*!< CLK_T::APBCLK0: ACMPCKEN Position */ +#define CLK_APBCLK0_ACMPCKEN_Msk (0x1ul << CLK_APBCLK0_ACMPCKEN_Pos) /*!< CLK_T::APBCLK0: ACMPCKEN Mask */ + +#define CLK_APBCLK0_I2C0CKEN_Pos (8) /*!< CLK_T::APBCLK0: I2C0CKEN Position */ +#define CLK_APBCLK0_I2C0CKEN_Msk (0x1ul << CLK_APBCLK0_I2C0CKEN_Pos) /*!< CLK_T::APBCLK0: I2C0CKEN Mask */ + +#define CLK_APBCLK0_I2C1CKEN_Pos (9) /*!< CLK_T::APBCLK0: I2C1CKEN Position */ +#define CLK_APBCLK0_I2C1CKEN_Msk (0x1ul << CLK_APBCLK0_I2C1CKEN_Pos) /*!< CLK_T::APBCLK0: I2C1CKEN Mask */ + +#define CLK_APBCLK0_I2C2CKEN_Pos (10) /*!< CLK_T::APBCLK0: I2C2CKEN Position */ +#define CLK_APBCLK0_I2C2CKEN_Msk (0x1ul << CLK_APBCLK0_I2C2CKEN_Pos) /*!< CLK_T::APBCLK0: I2C2CKEN Mask */ + +#define CLK_APBCLK0_I2C3CKEN_Pos (11) /*!< CLK_T::APBCLK0: I2C3CKEN Position */ +#define CLK_APBCLK0_I2C3CKEN_Msk (0x1ul << CLK_APBCLK0_I2C3CKEN_Pos) /*!< CLK_T::APBCLK0: I2C3CKEN Mask */ + +#define CLK_APBCLK0_SPI0CKEN_Pos (12) /*!< CLK_T::APBCLK0: SPI0CKEN Position */ +#define CLK_APBCLK0_SPI0CKEN_Msk (0x1ul << CLK_APBCLK0_SPI0CKEN_Pos) /*!< CLK_T::APBCLK0: SPI0CKEN Mask */ + +#define CLK_APBCLK0_SPI1CKEN_Pos (13) /*!< CLK_T::APBCLK0: SPI1CKEN Position */ +#define CLK_APBCLK0_SPI1CKEN_Msk (0x1ul << CLK_APBCLK0_SPI1CKEN_Pos) /*!< CLK_T::APBCLK0: SPI1CKEN Mask */ + +#define CLK_APBCLK0_SPI2CKEN_Pos (14) /*!< CLK_T::APBCLK0: SPI2CKEN Position */ +#define CLK_APBCLK0_SPI2CKEN_Msk (0x1ul << CLK_APBCLK0_SPI2CKEN_Pos) /*!< CLK_T::APBCLK0: SPI2CKEN Mask */ + +#define CLK_APBCLK0_SPI3CKEN_Pos (15) /*!< CLK_T::APBCLK0: SPI3CKEN Position */ +#define CLK_APBCLK0_SPI3CKEN_Msk (0x1ul << CLK_APBCLK0_SPI3CKEN_Pos) /*!< CLK_T::APBCLK0: SPI3CKEN Mask */ + +#define CLK_APBCLK0_UART0CKEN_Pos (16) /*!< CLK_T::APBCLK0: UART0CKEN Position */ +#define CLK_APBCLK0_UART0CKEN_Msk (0x1ul << CLK_APBCLK0_UART0CKEN_Pos) /*!< CLK_T::APBCLK0: UART0CKEN Mask */ + +#define CLK_APBCLK0_UART1CKEN_Pos (17) /*!< CLK_T::APBCLK0: UART1CKEN Position */ +#define CLK_APBCLK0_UART1CKEN_Msk (0x1ul << CLK_APBCLK0_UART1CKEN_Pos) /*!< CLK_T::APBCLK0: UART1CKEN Mask */ + +#define CLK_APBCLK0_UART2CKEN_Pos (18) /*!< CLK_T::APBCLK0: UART2CKEN Position */ +#define CLK_APBCLK0_UART2CKEN_Msk (0x1ul << CLK_APBCLK0_UART2CKEN_Pos) /*!< CLK_T::APBCLK0: UART2CKEN Mask */ + +#define CLK_APBCLK0_UART3CKEN_Pos (19) /*!< CLK_T::APBCLK0: UART3CKEN Position */ +#define CLK_APBCLK0_UART3CKEN_Msk (0x1ul << CLK_APBCLK0_UART3CKEN_Pos) /*!< CLK_T::APBCLK0: UART3CKEN Mask */ + +#define CLK_APBCLK0_UART4CKEN_Pos (20) /*!< CLK_T::APBCLK0: UART4CKEN Position */ +#define CLK_APBCLK0_UART4CKEN_Msk (0x1ul << CLK_APBCLK0_UART4CKEN_Pos) /*!< CLK_T::APBCLK0: UART4CKEN Mask */ + +#define CLK_APBCLK0_UART5CKEN_Pos (21) /*!< CLK_T::APBCLK0: UART5CKEN Position */ +#define CLK_APBCLK0_UART5CKEN_Msk (0x1ul << CLK_APBCLK0_UART5CKEN_Pos) /*!< CLK_T::APBCLK0: UART5CKEN Mask */ + +#define CLK_APBCLK0_CAN0CKEN_Pos (24) /*!< CLK_T::APBCLK0: CAN0CKEN Position */ +#define CLK_APBCLK0_CAN0CKEN_Msk (0x1ul << CLK_APBCLK0_CAN0CKEN_Pos) /*!< CLK_T::APBCLK0: CAN0CKEN Mask */ + +#define CLK_APBCLK0_CAN1CKEN_Pos (25) /*!< CLK_T::APBCLK0: CAN1CKEN Position */ +#define CLK_APBCLK0_CAN1CKEN_Msk (0x1ul << CLK_APBCLK0_CAN1CKEN_Pos) /*!< CLK_T::APBCLK0: CAN1CKEN Mask */ + +#define CLK_APBCLK0_OTGCKEN_Pos (26) /*!< CLK_T::APBCLK0: OTGCKEN Position */ +#define CLK_APBCLK0_OTGCKEN_Msk (0x1ul << CLK_APBCLK0_OTGCKEN_Pos) /*!< CLK_T::APBCLK0: OTGCKEN Mask */ + +#define CLK_APBCLK0_ADCCKEN_Pos (28) /*!< CLK_T::APBCLK0: ADCCKEN Position */ +#define CLK_APBCLK0_ADCCKEN_Msk (0x1ul << CLK_APBCLK0_ADCCKEN_Pos) /*!< CLK_T::APBCLK0: ADCCKEN Mask */ + +#define CLK_APBCLK0_I2S0CKEN_Pos (29) /*!< CLK_T::APBCLK0: I2S0CKEN Position */ +#define CLK_APBCLK0_I2S0CKEN_Msk (0x1ul << CLK_APBCLK0_I2S0CKEN_Pos) /*!< CLK_T::APBCLK0: I2S0CKEN Mask */ + +#define CLK_APBCLK0_I2S1CKEN_Pos (30) /*!< CLK_T::APBCLK0: I2S1CKEN Position */ +#define CLK_APBCLK0_I2S1CKEN_Msk (0x1ul << CLK_APBCLK0_I2S1CKEN_Pos) /*!< CLK_T::APBCLK0: I2S1CKEN Mask */ + +#define CLK_APBCLK0_PS2CKEN_Pos (31) /*!< CLK_T::APBCLK0: PS2CKEN Position */ +#define CLK_APBCLK0_PS2CKEN_Msk (0x1ul << CLK_APBCLK0_PS2CKEN_Pos) /*!< CLK_T::APBCLK0: PS2CKEN Mask */ + +#define CLK_APBCLK1_SC0CKEN_Pos (0) /*!< CLK_T::APBCLK1: SC0CKEN Position */ +#define CLK_APBCLK1_SC0CKEN_Msk (0x1ul << CLK_APBCLK1_SC0CKEN_Pos) /*!< CLK_T::APBCLK1: SC0CKEN Mask */ + +#define CLK_APBCLK1_SC1CKEN_Pos (1) /*!< CLK_T::APBCLK1: SC1CKEN Position */ +#define CLK_APBCLK1_SC1CKEN_Msk (0x1ul << CLK_APBCLK1_SC1CKEN_Pos) /*!< CLK_T::APBCLK1: SC1CKEN Mask */ + +#define CLK_APBCLK1_SC2CKEN_Pos (2) /*!< CLK_T::APBCLK1: SC2CKEN Position */ +#define CLK_APBCLK1_SC2CKEN_Msk (0x1ul << CLK_APBCLK1_SC2CKEN_Pos) /*!< CLK_T::APBCLK1: SC2CKEN Mask */ + +#define CLK_APBCLK1_SC3CKEN_Pos (3) /*!< CLK_T::APBCLK1: SC3CKEN Position */ +#define CLK_APBCLK1_SC3CKEN_Msk (0x1ul << CLK_APBCLK1_SC3CKEN_Pos) /*!< CLK_T::APBCLK1: SC3CKEN Mask */ + +#define CLK_APBCLK1_SC4CKEN_Pos (4) /*!< CLK_T::APBCLK1: SC4CKEN Position */ +#define CLK_APBCLK1_SC4CKEN_Msk (0x1ul << CLK_APBCLK1_SC4CKEN_Pos) /*!< CLK_T::APBCLK1: SC4CKEN Mask */ + +#define CLK_APBCLK1_SC5CKEN_Pos (5) /*!< CLK_T::APBCLK1: SC5CKEN Position */ +#define CLK_APBCLK1_SC5CKEN_Msk (0x1ul << CLK_APBCLK1_SC5CKEN_Pos) /*!< CLK_T::APBCLK1: SC5CKEN Mask */ + +#define CLK_APBCLK1_I2C4CKEN_Pos (8) /*!< CLK_T::APBCLK1: I2C4CKEN Position */ +#define CLK_APBCLK1_I2C4CKEN_Msk (0x1ul << CLK_APBCLK1_I2C4CKEN_Pos) /*!< CLK_T::APBCLK1: I2C4CKEN Mask */ + +#define CLK_APBCLK1_PWM0CH01CKEN_Pos (16) /*!< CLK_T::APBCLK1: PWM0CH01CKEN Position */ +#define CLK_APBCLK1_PWM0CH01CKEN_Msk (0x1ul << CLK_APBCLK1_PWM0CH01CKEN_Pos) /*!< CLK_T::APBCLK1: PWM0CH01CKEN Mask */ + +#define CLK_APBCLK1_PWM0CH23CKEN_Pos (17) /*!< CLK_T::APBCLK1: PWM0CH23CKEN Position */ +#define CLK_APBCLK1_PWM0CH23CKEN_Msk (0x1ul << CLK_APBCLK1_PWM0CH23CKEN_Pos) /*!< CLK_T::APBCLK1: PWM0CH23CKEN Mask */ + +#define CLK_APBCLK1_PWM0CH45CKEN_Pos (18) /*!< CLK_T::APBCLK1: PWM0CH45CKEN Position */ +#define CLK_APBCLK1_PWM0CH45CKEN_Msk (0x1ul << CLK_APBCLK1_PWM0CH45CKEN_Pos) /*!< CLK_T::APBCLK1: PWM0CH45CKEN Mask */ + +#define CLK_APBCLK1_PWM1CH01CKEN_Pos (19) /*!< CLK_T::APBCLK1: PWM1CH01CKEN Position */ +#define CLK_APBCLK1_PWM1CH01CKEN_Msk (0x1ul << CLK_APBCLK1_PWM1CH01CKEN_Pos) /*!< CLK_T::APBCLK1: PWM1CH01CKEN Mask */ + +#define CLK_APBCLK1_PWM1CH2345CKEN_Pos (21) /*!< CLK_T::APBCLK1: PWM1CH2345CKEN Position */ +#define CLK_APBCLK1_PWM1CH2345CKEN_Msk (0x1ul << CLK_APBCLK1_PWM1CH2345CKEN_Pos) /*!< CLK_T::APBCLK1: PWM1CH2345CKEN Mask */ + +#define CLK_APBCLK1_QEI0CKEN_Pos (22) /*!< CLK_T::APBCLK1: QEI0CKEN Position */ +#define CLK_APBCLK1_QEI0CKEN_Msk (0x1ul << CLK_APBCLK1_QEI0CKEN_Pos) /*!< CLK_T::APBCLK1: QEI0CKEN Mask */ + +#define CLK_APBCLK1_QEI1CKEN_Pos (23) /*!< CLK_T::APBCLK1: QEI1CKEN Position */ +#define CLK_APBCLK1_QEI1CKEN_Msk (0x1ul << CLK_APBCLK1_QEI1CKEN_Pos) /*!< CLK_T::APBCLK1: QEI1CKEN Mask */ + +#define CLK_APBCLK1_ECAP0CKEN_Pos (26) /*!< CLK_T::APBCLK1: ECAP0CKEN Position */ +#define CLK_APBCLK1_ECAP0CKEN_Msk (0x1ul << CLK_APBCLK1_ECAP0CKEN_Pos) /*!< CLK_T::APBCLK1: ECAP0CKEN Mask */ + +#define CLK_APBCLK1_ECAP1CKEN_Pos (27) /*!< CLK_T::APBCLK1: ECAP1CKEN Position */ +#define CLK_APBCLK1_ECAP1CKEN_Msk (0x1ul << CLK_APBCLK1_ECAP1CKEN_Pos) /*!< CLK_T::APBCLK1: ECAP1CKEN Mask */ + +#define CLK_APBCLK1_EPWM0CKEN_Pos (28) /*!< CLK_T::APBCLK1: EPWM0CKEN Position */ +#define CLK_APBCLK1_EPWM0CKEN_Msk (0x1ul << CLK_APBCLK1_EPWM0CKEN_Pos) /*!< CLK_T::APBCLK1: EPWM0CKEN Mask */ + +#define CLK_APBCLK1_EPWM1CKEN_Pos (29) /*!< CLK_T::APBCLK1: EPWM1CKEN Position */ +#define CLK_APBCLK1_EPWM1CKEN_Msk (0x1ul << CLK_APBCLK1_EPWM1CKEN_Pos) /*!< CLK_T::APBCLK1: EPWM1CKEN Mask */ + +#define CLK_APBCLK1_OPACKEN_Pos (30) /*!< CLK_T::APBCLK1: OPACKEN Position */ +#define CLK_APBCLK1_OPACKEN_Msk (0x1ul << CLK_APBCLK1_OPACKEN_Pos) /*!< CLK_T::APBCLK1: OPACKEN Mask */ + +#define CLK_APBCLK1_EADCCKEN_Pos (31) /*!< CLK_T::APBCLK1: EADCCKEN Position */ +#define CLK_APBCLK1_EADCCKEN_Msk (0x1ul << CLK_APBCLK1_EADCCKEN_Pos) /*!< CLK_T::APBCLK1: EADCCKEN Mask */ + +#define CLK_CLKSEL0_HCLKSEL_Pos (0) /*!< CLK_T::CLKSEL0: HCLKSEL Position */ +#define CLK_CLKSEL0_HCLKSEL_Msk (0x7ul << CLK_CLKSEL0_HCLKSEL_Pos) /*!< CLK_T::CLKSEL0: HCLKSEL Mask */ + +#define CLK_CLKSEL0_STCLKSEL_Pos (3) /*!< CLK_T::CLKSEL0: STCLKSEL Position */ +#define CLK_CLKSEL0_STCLKSEL_Msk (0x7ul << CLK_CLKSEL0_STCLKSEL_Pos) /*!< CLK_T::CLKSEL0: STCLKSEL Mask */ + +#define CLK_CLKSEL0_PCLKSEL_Pos (6) /*!< CLK_T::CLKSEL0: PCLKSEL Position */ +#define CLK_CLKSEL0_PCLKSEL_Msk (0x1ul << CLK_CLKSEL0_PCLKSEL_Pos) /*!< CLK_T::CLKSEL0: PCLKSEL Mask */ + +#define CLK_CLKSEL0_USBHSEL_Pos (8) /*!< CLK_T::CLKSEL0: USBHSEL Position */ +#define CLK_CLKSEL0_USBHSEL_Msk (0x1ul << CLK_CLKSEL0_USBHSEL_Pos) /*!< CLK_T::CLKSEL0: USBHSEL Mask */ + +#define CLK_CLKSEL0_CAPSEL_Pos (16) /*!< CLK_T::CLKSEL0: CAPSEL Position */ +#define CLK_CLKSEL0_CAPSEL_Msk (0x3ul << CLK_CLKSEL0_CAPSEL_Pos) /*!< CLK_T::CLKSEL0: CAPSEL Mask */ + +#define CLK_CLKSEL0_SDHSEL_Pos (20) /*!< CLK_T::CLKSEL0: SDHSEL Position */ +#define CLK_CLKSEL0_SDHSEL_Msk (0x3ul << CLK_CLKSEL0_SDHSEL_Pos) /*!< CLK_T::CLKSEL0: SDHSEL Mask */ + +#define CLK_CLKSEL1_WDTSEL_Pos (0) /*!< CLK_T::CLKSEL1: WDTSEL Position */ +#define CLK_CLKSEL1_WDTSEL_Msk (0x3ul << CLK_CLKSEL1_WDTSEL_Pos) /*!< CLK_T::CLKSEL1: WDTSEL Mask */ + +#define CLK_CLKSEL1_ADCSEL_Pos (2) /*!< CLK_T::CLKSEL1: ADCSEL Position */ +#define CLK_CLKSEL1_ADCSEL_Msk (0x3ul << CLK_CLKSEL1_ADCSEL_Pos) /*!< CLK_T::CLKSEL1: ADCSEL Mask */ + +#define CLK_CLKSEL1_SPI0SEL_Pos (4) /*!< CLK_T::CLKSEL1: SPI0SEL Position */ +#define CLK_CLKSEL1_SPI0SEL_Msk (0x1ul << CLK_CLKSEL1_SPI0SEL_Pos) /*!< CLK_T::CLKSEL1: SPI0SEL Mask */ + +#define CLK_CLKSEL1_SPI1SEL_Pos (5) /*!< CLK_T::CLKSEL1: SPI1SEL Position */ +#define CLK_CLKSEL1_SPI1SEL_Msk (0x1ul << CLK_CLKSEL1_SPI1SEL_Pos) /*!< CLK_T::CLKSEL1: SPI1SEL Mask */ + +#define CLK_CLKSEL1_SPI2SEL_Pos (6) /*!< CLK_T::CLKSEL1: SPI2SEL Position */ +#define CLK_CLKSEL1_SPI2SEL_Msk (0x1ul << CLK_CLKSEL1_SPI2SEL_Pos) /*!< CLK_T::CLKSEL1: SPI2SEL Mask */ + +#define CLK_CLKSEL1_SPI3SEL_Pos (7) /*!< CLK_T::CLKSEL1: SPI3SEL Position */ +#define CLK_CLKSEL1_SPI3SEL_Msk (0x1ul << CLK_CLKSEL1_SPI3SEL_Pos) /*!< CLK_T::CLKSEL1: SPI3SEL Mask */ + +#define CLK_CLKSEL1_TMR0SEL_Pos (8) /*!< CLK_T::CLKSEL1: TMR0SEL Position */ +#define CLK_CLKSEL1_TMR0SEL_Msk (0x7ul << CLK_CLKSEL1_TMR0SEL_Pos) /*!< CLK_T::CLKSEL1: TMR0SEL Mask */ + +#define CLK_CLKSEL1_TMR1SEL_Pos (12) /*!< CLK_T::CLKSEL1: TMR1SEL Position */ +#define CLK_CLKSEL1_TMR1SEL_Msk (0x7ul << CLK_CLKSEL1_TMR1SEL_Pos) /*!< CLK_T::CLKSEL1: TMR1SEL Mask */ + +#define CLK_CLKSEL1_TMR2SEL_Pos (16) /*!< CLK_T::CLKSEL1: TMR2SEL Position */ +#define CLK_CLKSEL1_TMR2SEL_Msk (0x7ul << CLK_CLKSEL1_TMR2SEL_Pos) /*!< CLK_T::CLKSEL1: TMR2SEL Mask */ + +#define CLK_CLKSEL1_TMR3SEL_Pos (20) /*!< CLK_T::CLKSEL1: TMR3SEL Position */ +#define CLK_CLKSEL1_TMR3SEL_Msk (0x7ul << CLK_CLKSEL1_TMR3SEL_Pos) /*!< CLK_T::CLKSEL1: TMR3SEL Mask */ + +#define CLK_CLKSEL1_UARTSEL_Pos (24) /*!< CLK_T::CLKSEL1: UARTSEL Position */ +#define CLK_CLKSEL1_UARTSEL_Msk (0x3ul << CLK_CLKSEL1_UARTSEL_Pos) /*!< CLK_T::CLKSEL1: UARTSEL Mask */ + +#define CLK_CLKSEL1_CLKOSEL_Pos (28) /*!< CLK_T::CLKSEL1: CLKOSEL Position */ +#define CLK_CLKSEL1_CLKOSEL_Msk (0x3ul << CLK_CLKSEL1_CLKOSEL_Pos) /*!< CLK_T::CLKSEL1: CLKOSEL Mask */ + +#define CLK_CLKSEL1_WWDTSEL_Pos (30) /*!< CLK_T::CLKSEL1: WWDTSEL Position */ +#define CLK_CLKSEL1_WWDTSEL_Msk (0x3ul << CLK_CLKSEL1_WWDTSEL_Pos) /*!< CLK_T::CLKSEL1: WWDTSEL Mask */ + +#define CLK_CLKSEL2_PWM0CH01SEL_Pos (0) /*!< CLK_T::CLKSEL2: PWM0CH01SEL Position */ +#define CLK_CLKSEL2_PWM0CH01SEL_Msk (0x7ul << CLK_CLKSEL2_PWM0CH01SEL_Pos) /*!< CLK_T::CLKSEL2: PWM0CH01SEL Mask */ + +#define CLK_CLKSEL2_PWM0CH23SEL_Pos (4) /*!< CLK_T::CLKSEL2: PWM0CH23SEL Position */ +#define CLK_CLKSEL2_PWM0CH23SEL_Msk (0x7ul << CLK_CLKSEL2_PWM0CH23SEL_Pos) /*!< CLK_T::CLKSEL2: PWM0CH23SEL Mask */ + +#define CLK_CLKSEL2_PWM0CH45SEL_Pos (8) /*!< CLK_T::CLKSEL2: PWM0CH45SEL Position */ +#define CLK_CLKSEL2_PWM0CH45SEL_Msk (0x7ul << CLK_CLKSEL2_PWM0CH45SEL_Pos) /*!< CLK_T::CLKSEL2: PWM0CH45SEL Mask */ + +#define CLK_CLKSEL2_PWM1CH01SEL_Pos (12) /*!< CLK_T::CLKSEL2: PWM1CH01SEL Position */ +#define CLK_CLKSEL2_PWM1CH01SEL_Msk (0x7ul << CLK_CLKSEL2_PWM1CH01SEL_Pos) /*!< CLK_T::CLKSEL2: PWM1CH01SEL Mask */ + +#define CLK_CLKSEL2_PWM1CH23SEL_Pos (16) /*!< CLK_T::CLKSEL2: PWM1CH23SEL Position */ +#define CLK_CLKSEL2_PWM1CH23SEL_Msk (0x7ul << CLK_CLKSEL2_PWM1CH23SEL_Pos) /*!< CLK_T::CLKSEL2: PWM1CH23SEL Mask */ + +#define CLK_CLKSEL2_PWM1CH45SEL_Pos (20) /*!< CLK_T::CLKSEL2: PWM1CH45SEL Position */ +#define CLK_CLKSEL2_PWM1CH45SEL_Msk (0x7ul << CLK_CLKSEL2_PWM1CH45SEL_Pos) /*!< CLK_T::CLKSEL2: PWM1CH45SEL Mask */ + +#define CLK_CLKSEL3_SC0SEL_Pos (0) /*!< CLK_T::CLKSEL3: SC0SEL Position */ +#define CLK_CLKSEL3_SC0SEL_Msk (0x3ul << CLK_CLKSEL3_SC0SEL_Pos) /*!< CLK_T::CLKSEL3: SC0SEL Mask */ + +#define CLK_CLKSEL3_SC1SEL_Pos (2) /*!< CLK_T::CLKSEL3: SC1SEL Position */ +#define CLK_CLKSEL3_SC1SEL_Msk (0x3ul << CLK_CLKSEL3_SC1SEL_Pos) /*!< CLK_T::CLKSEL3: SC1SEL Mask */ + +#define CLK_CLKSEL3_SC2SEL_Pos (4) /*!< CLK_T::CLKSEL3: SC2SEL Position */ +#define CLK_CLKSEL3_SC2SEL_Msk (0x3ul << CLK_CLKSEL3_SC2SEL_Pos) /*!< CLK_T::CLKSEL3: SC2SEL Mask */ + +#define CLK_CLKSEL3_SC3SEL_Pos (6) /*!< CLK_T::CLKSEL3: SC3SEL Position */ +#define CLK_CLKSEL3_SC3SEL_Msk (0x3ul << CLK_CLKSEL3_SC3SEL_Pos) /*!< CLK_T::CLKSEL3: SC3SEL Mask */ + +#define CLK_CLKSEL3_SC4SEL_Pos (8) /*!< CLK_T::CLKSEL3: SC4SEL Position */ +#define CLK_CLKSEL3_SC4SEL_Msk (0x3ul << CLK_CLKSEL3_SC4SEL_Pos) /*!< CLK_T::CLKSEL3: SC4SEL Mask */ + +#define CLK_CLKSEL3_SC5SEL_Pos (10) /*!< CLK_T::CLKSEL3: SC5SEL Position */ +#define CLK_CLKSEL3_SC5SEL_Msk (0x3ul << CLK_CLKSEL3_SC5SEL_Pos) /*!< CLK_T::CLKSEL3: SC5SEL Mask */ + +#define CLK_CLKSEL3_I2S0SEL_Pos (16) /*!< CLK_T::CLKSEL3: I2S0SEL Position */ +#define CLK_CLKSEL3_I2S0SEL_Msk (0x3ul << CLK_CLKSEL3_I2S0SEL_Pos) /*!< CLK_T::CLKSEL3: I2S0SEL Mask */ + +#define CLK_CLKSEL3_I2S1SEL_Pos (18) /*!< CLK_T::CLKSEL3: I2S1SEL Position */ +#define CLK_CLKSEL3_I2S1SEL_Msk (0x3ul << CLK_CLKSEL3_I2S1SEL_Pos) /*!< CLK_T::CLKSEL3: I2S1SEL Mask */ + +#define CLK_CLKDIV0_HCLKDIV_Pos (0) /*!< CLK_T::CLKDIV0: HCLKDIV Position */ +#define CLK_CLKDIV0_HCLKDIV_Msk (0xful << CLK_CLKDIV0_HCLKDIV_Pos) /*!< CLK_T::CLKDIV0: HCLKDIV Mask */ + +#define CLK_CLKDIV0_USBHDIV_Pos (4) /*!< CLK_T::CLKDIV0: USBHDIV Position */ +#define CLK_CLKDIV0_USBHDIV_Msk (0xful << CLK_CLKDIV0_USBHDIV_Pos) /*!< CLK_T::CLKDIV0: USBHDIV Mask */ + +#define CLK_CLKDIV0_UARTDIV_Pos (8) /*!< CLK_T::CLKDIV0: UARTDIV Position */ +#define CLK_CLKDIV0_UARTDIV_Msk (0xful << CLK_CLKDIV0_UARTDIV_Pos) /*!< CLK_T::CLKDIV0: UARTDIV Mask */ + +#define CLK_CLKDIV0_ADCDIV_Pos (16) /*!< CLK_T::CLKDIV0: ADCDIV Position */ +#define CLK_CLKDIV0_ADCDIV_Msk (0xfful << CLK_CLKDIV0_ADCDIV_Pos) /*!< CLK_T::CLKDIV0: ADCDIV Mask */ + +#define CLK_CLKDIV0_SDHDIV_Pos (24) /*!< CLK_T::CLKDIV0: SDHDIV Position */ +#define CLK_CLKDIV0_SDHDIV_Msk (0xfful << CLK_CLKDIV0_SDHDIV_Pos) /*!< CLK_T::CLKDIV0: SDHDIV Mask */ + +#define CLK_CLKDIV1_SC0DIV_Pos (0) /*!< CLK_T::CLKDIV1: SC0DIV Position */ +#define CLK_CLKDIV1_SC0DIV_Msk (0xfful << CLK_CLKDIV1_SC0DIV_Pos) /*!< CLK_T::CLKDIV1: SC0DIV Mask */ + +#define CLK_CLKDIV1_SC1DIV_Pos (8) /*!< CLK_T::CLKDIV1: SC1DIV Position */ +#define CLK_CLKDIV1_SC1DIV_Msk (0xfful << CLK_CLKDIV1_SC1DIV_Pos) /*!< CLK_T::CLKDIV1: SC1DIV Mask */ + +#define CLK_CLKDIV1_SC2DIV_Pos (16) /*!< CLK_T::CLKDIV1: SC2DIV Position */ +#define CLK_CLKDIV1_SC2DIV_Msk (0xfful << CLK_CLKDIV1_SC2DIV_Pos) /*!< CLK_T::CLKDIV1: SC2DIV Mask */ + +#define CLK_CLKDIV1_SC3DIV_Pos (24) /*!< CLK_T::CLKDIV1: SC3DIV Position */ +#define CLK_CLKDIV1_SC3DIV_Msk (0xfful << CLK_CLKDIV1_SC3DIV_Pos) /*!< CLK_T::CLKDIV1: SC3DIV Mask */ + +#define CLK_CLKDIV2_SC4DIV_Pos (0) /*!< CLK_T::CLKDIV2: SC4DIV Position */ +#define CLK_CLKDIV2_SC4DIV_Msk (0xfful << CLK_CLKDIV2_SC4DIV_Pos) /*!< CLK_T::CLKDIV2: SC4DIV Mask */ + +#define CLK_CLKDIV2_SC5DIV_Pos (8) /*!< CLK_T::CLKDIV2: SC5DIV Position */ +#define CLK_CLKDIV2_SC5DIV_Msk (0xfful << CLK_CLKDIV2_SC5DIV_Pos) /*!< CLK_T::CLKDIV2: SC5DIV Mask */ + +#define CLK_CLKDIV3_CAPDIV_Pos (0) /*!< CLK_T::CLKDIV3: CAPDIV Position */ +#define CLK_CLKDIV3_CAPDIV_Msk (0xfful << CLK_CLKDIV3_CAPDIV_Pos) /*!< CLK_T::CLKDIV3: CAPDIV Mask */ + +#define CLK_CLKDIV3_VSENSEDIV_Pos (8) /*!< CLK_T::CLKDIV3: VSENSEDIV Position */ +#define CLK_CLKDIV3_VSENSEDIV_Msk (0xfful << CLK_CLKDIV3_VSENSEDIV_Pos) /*!< CLK_T::CLKDIV3: VSENSEDIV Mask */ + +#define CLK_CLKDIV3_EMACDIV_Pos (16) /*!< CLK_T::CLKDIV3: EMACDIV Position */ +#define CLK_CLKDIV3_EMACDIV_Msk (0xfful << CLK_CLKDIV3_EMACDIV_Pos) /*!< CLK_T::CLKDIV3: EMACDIV Mask */ + +#define CLK_PLLCTL_FBDIV_Pos (0) /*!< CLK_T::PLLCTL: FBDIV Position */ +#define CLK_PLLCTL_FBDIV_Msk (0x1fful << CLK_PLLCTL_FBDIV_Pos) /*!< CLK_T::PLLCTL: FBDIV Mask */ + +#define CLK_PLLCTL_INDIV_Pos (9) /*!< CLK_T::PLLCTL: INDIV Position */ +#define CLK_PLLCTL_INDIV_Msk (0x1ful << CLK_PLLCTL_INDIV_Pos) /*!< CLK_T::PLLCTL: INDIV Mask */ + +#define CLK_PLLCTL_OUTDV_Pos (14) /*!< CLK_T::PLLCTL: OUTDV Position */ +#define CLK_PLLCTL_OUTDV_Msk (0x3ul << CLK_PLLCTL_OUTDV_Pos) /*!< CLK_T::PLLCTL: OUTDV Mask */ + +#define CLK_PLLCTL_PD_Pos (16) /*!< CLK_T::PLLCTL: PD Position */ +#define CLK_PLLCTL_PD_Msk (0x1ul << CLK_PLLCTL_PD_Pos) /*!< CLK_T::PLLCTL: PD Mask */ + +#define CLK_PLLCTL_BP_Pos (17) /*!< CLK_T::PLLCTL: BP Position */ +#define CLK_PLLCTL_BP_Msk (0x1ul << CLK_PLLCTL_BP_Pos) /*!< CLK_T::PLLCTL: BP Mask */ + +#define CLK_PLLCTL_OE_Pos (18) /*!< CLK_T::PLLCTL: OE Position */ +#define CLK_PLLCTL_OE_Msk (0x1ul << CLK_PLLCTL_OE_Pos) /*!< CLK_T::PLLCTL: OE Mask */ + +#define CLK_PLLCTL_PLLSRC_Pos (19) /*!< CLK_T::PLLCTL: PLLSRC Position */ +#define CLK_PLLCTL_PLLSRC_Msk (0x1ul << CLK_PLLCTL_PLLSRC_Pos) /*!< CLK_T::PLLCTL: PLLSRC Mask */ + +#define CLK_PLLCTL_PLLREMAP_Pos (20) /*!< CLK_T::PLLCTL: PLLREMAP Position */ +#define CLK_PLLCTL_PLLREMAP_Msk (0x1ul << CLK_PLLCTL_PLLREMAP_Pos) /*!< CLK_T::PLLCTL: PLLREMAP Mask */ + +#define CLK_PLL2CTL_PLL2DIV_Pos (0) /*!< CLK_T::PLL2CTL: PLL2DIV Position */ +#define CLK_PLL2CTL_PLL2DIV_Msk (0xfful << CLK_PLL2CTL_PLL2DIV_Pos) /*!< CLK_T::PLL2CTL: PLL2DIV Mask */ + +#define CLK_PLL2CTL_PLL2CKEN_Pos (8) /*!< CLK_T::PLL2CTL: PLL2CKEN Position */ +#define CLK_PLL2CTL_PLL2CKEN_Msk (0x1ul << CLK_PLL2CTL_PLL2CKEN_Pos) /*!< CLK_T::PLL2CTL: PLL2CKEN Mask */ + +#define CLK_STATUS_HXTSTB_Pos (0) /*!< CLK_T::STATUS: HXTSTB Position */ +#define CLK_STATUS_HXTSTB_Msk (0x1ul << CLK_STATUS_HXTSTB_Pos) /*!< CLK_T::STATUS: HXTSTB Mask */ + +#define CLK_STATUS_LXTSTB_Pos (1) /*!< CLK_T::STATUS: LXTSTB Position */ +#define CLK_STATUS_LXTSTB_Msk (0x1ul << CLK_STATUS_LXTSTB_Pos) /*!< CLK_T::STATUS: LXTSTB Mask */ + +#define CLK_STATUS_PLLSTB_Pos (2) /*!< CLK_T::STATUS: PLLSTB Position */ +#define CLK_STATUS_PLLSTB_Msk (0x1ul << CLK_STATUS_PLLSTB_Pos) /*!< CLK_T::STATUS: PLLSTB Mask */ + +#define CLK_STATUS_LIRCSTB_Pos (3) /*!< CLK_T::STATUS: LIRCSTB Position */ +#define CLK_STATUS_LIRCSTB_Msk (0x1ul << CLK_STATUS_LIRCSTB_Pos) /*!< CLK_T::STATUS: LIRCSTB Mask */ + +#define CLK_STATUS_HIRCSTB_Pos (4) /*!< CLK_T::STATUS: HIRCSTB Position */ +#define CLK_STATUS_HIRCSTB_Msk (0x1ul << CLK_STATUS_HIRCSTB_Pos) /*!< CLK_T::STATUS: HIRCSTB Mask */ + +#define CLK_STATUS_PLL2STB_Pos (5) /*!< CLK_T::STATUS: PLL2STB Position */ +#define CLK_STATUS_PLL2STB_Msk (0x1ul << CLK_STATUS_PLL2STB_Pos) /*!< CLK_T::STATUS: PLL2STB Mask */ + +#define CLK_STATUS_CLKSFAIL_Pos (7) /*!< CLK_T::STATUS: CLKSFAIL Position */ +#define CLK_STATUS_CLKSFAIL_Msk (0x1ul << CLK_STATUS_CLKSFAIL_Pos) /*!< CLK_T::STATUS: CLKSFAIL Mask */ + +#define CLK_CLKOCTL_FSEL_Pos (0) /*!< CLK_T::CLKOCTL: FSEL Position */ +#define CLK_CLKOCTL_FSEL_Msk (0xful << CLK_CLKOCTL_FSEL_Pos) /*!< CLK_T::CLKOCTL: FSEL Mask */ + +#define CLK_CLKOCTL_CLKOEN_Pos (4) /*!< CLK_T::CLKOCTL: CLKOEN Position */ +#define CLK_CLKOCTL_CLKOEN_Msk (0x1ul << CLK_CLKOCTL_CLKOEN_Pos) /*!< CLK_T::CLKOCTL: CLKOEN Mask */ + +#define CLK_CLKOCTL_DIV1EN_Pos (5) /*!< CLK_T::CLKOCTL: DIV1EN Position */ +#define CLK_CLKOCTL_DIV1EN_Msk (0x1ul << CLK_CLKOCTL_DIV1EN_Pos) /*!< CLK_T::CLKOCTL: DIV1EN Mask */ + +#define CLK_CLKDCTL_SYSFDEN_Pos (0) /*!< CLK_T::CLKDCTL: SYSFDEN Position */ +#define CLK_CLKDCTL_SYSFDEN_Msk (0x1ul << CLK_CLKDCTL_SYSFDEN_Pos) /*!< CLK_T::CLKDCTL: SYSFDEN Mask */ + +#define CLK_CLKDCTL_SYSFIEN_Pos (1) /*!< CLK_T::CLKDCTL: SYSFIEN Position */ +#define CLK_CLKDCTL_SYSFIEN_Msk (0x1ul << CLK_CLKDCTL_SYSFIEN_Pos) /*!< CLK_T::CLKDCTL: SYSFIEN Mask */ + +#define CLK_CLKDCTL_SYSFIF_Pos (2) /*!< CLK_T::CLKDCTL: SYSFIF Position */ +#define CLK_CLKDCTL_SYSFIF_Msk (0x1ul << CLK_CLKDCTL_SYSFIF_Pos) /*!< CLK_T::CLKDCTL: SYSFIF Mask */ + +#define CLK_CLKDCTL_IRCDEN_Pos (8) /*!< CLK_T::CLKDCTL: IRCDEN Position */ +#define CLK_CLKDCTL_IRCDEN_Msk (0x1ul << CLK_CLKDCTL_IRCDEN_Pos) /*!< CLK_T::CLKDCTL: IRCDEN Mask */ + +#define CLK_CLKDCTL_IRCFIEN_Pos (9) /*!< CLK_T::CLKDCTL: IRCFIEN Position */ +#define CLK_CLKDCTL_IRCFIEN_Msk (0x1ul << CLK_CLKDCTL_IRCFIEN_Pos) /*!< CLK_T::CLKDCTL: IRCFIEN Mask */ + +#define CLK_CLKDCTL_IRCFIF_Pos (10) /*!< CLK_T::CLKDCTL: IRCFIF Position */ +#define CLK_CLKDCTL_IRCFIF_Msk (0x1ul << CLK_CLKDCTL_IRCFIF_Pos) /*!< CLK_T::CLKDCTL: IRCFIF Mask */ + +/**@}*/ /* CLK_CONST */ +/**@}*/ /* end of CLK register group */ + + +/*---------------------- Cyclic Redundancy Check Controller -------------------------*/ +/** + @addtogroup CRC Cyclic Redundancy Check Controller(CRC) + Memory Mapped Structure for CRC Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 CRC Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CRCEN |CRC Channel Enable Control + * | | |0 = CRC function Disabled. + * | | |1 = CRC function Enabled. + * |[1] |CRCRST |CRC Engine Reset + * | | |0 = No effect. + * | | |1 = Reset the internal CRC state machine and internal buffer. + * | | |The contents of control register will not be cleared. + * | | |This bit will automatically be cleared after few clock cycles. + * | | |Note: Setting this bit will reload the initial seed value. + * |[24] |DATREV |Write Data Order Reverse + * | | |0 = No bit order reversed for CRC write data in. + * | | |1 = Bit order reversed for CRC write data in (per byte). + * | | |Note: If the write data is 0xAABBCCDD, the bit order reverse for CRC write data in is 0x55DD33BB + * |[25] |CHKSREV |Checksum Reverse + * | | |0 = No bit order reverse for CRC checksum. + * | | |1 = Bit order reverse for CRC checksum. + * | | |Note: If the checksum data is 0XDD7B0F2E, the bit order reversed for CRC checksum is 0x74F0DEBB. + * |[26] |DATFMT |Write Data Complement + * | | |0 = No bit order reversed for CRC write data in. + * | | |1 = 1's complement for CRC write data in. + * |[27] |CHKSFMT |Checksum Complement + * | | |0 = No bit order reverse for CRC checksum. + * | | |1 = 1's complement for CRC checksum. + * |[28:29] |DATLEN |CPU Write Data Length + * | | |This field indicates the write data length. + * | | |00 = Data length is 8-bit mode. + * | | |01 = Data length is 16-bit mode. + * | | |1x = Data length is 32-bit mode. + * | | |Note: When the data length is 8-bit mode, the valid data is DATA [7:0]; if the data length is 16-bit mode, the valid data is DATA [15:0]. + * |[30:31] |CRCMODE |CRC Polynomial Mode Selection + * | | |00 = CRC-CCITT Polynomial mode. + * | | |01 = CRC-8 Polynomial mode. + * | | |10 = CRC-16 Polynomial mode. + * | | |11 = CRC-32 Polynomial mode. + */ + __IO uint32_t CTL; + + /** + * DAT + * =================================================================================================== + * Offset: 0x04 CRC Write Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DATA |CRC Write Data Bits + * | | |Software can write data to this field to perform CRC operation, or uses PDMA function to get the data from memory + * | | |Note1: The CRC_CTL [DATFMT] and CRC_CTL [DATREV] bit setting will affect this field; for example, if DATREV = 1, if the write data in DATA register is 0xAABBCCDD, the read data from DATA register will be 0x55DD33BB. + */ + __IO uint32_t DAT; + + /** + * SEED + * =================================================================================================== + * Offset: 0x08 CRC Seed Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SEED |CRC Seed Bits + * | | |This field indicates the CRC seed value. + */ + __IO uint32_t SEED; + + /** + * CHECKSUM + * =================================================================================================== + * Offset: 0x0C CRC Checksum Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CHECKSUM |CRC Checksum Bits + * | | |This field indicates the CRC checksum. + */ + __I uint32_t CHECKSUM; + +} CRC_T; + +/** + @addtogroup CRC_CONST CRC Bit Field Definition + Constant Definitions for CRC Controller +@{ */ + +#define CRC_CTL_CRCEN_Pos (0) /*!< CRC_T::CTL: CRCEN Position */ +#define CRC_CTL_CRCEN_Msk (0x1ul << CRC_CTL_CRCEN_Pos) /*!< CRC_T::CTL: CRCEN Mask */ + +#define CRC_CTL_CRCRST_Pos (1) /*!< CRC_T::CTL: CRCRST Position */ +#define CRC_CTL_CRCRST_Msk (0x1ul << CRC_CTL_CRCRST_Pos) /*!< CRC_T::CTL: CRCRST Mask */ + +#define CRC_CTL_DATREV_Pos (24) /*!< CRC_T::CTL: DATREV Position */ +#define CRC_CTL_DATREV_Msk (0x1ul << CRC_CTL_DATREV_Pos) /*!< CRC_T::CTL: DATREV Mask */ + +#define CRC_CTL_CHKSREV_Pos (25) /*!< CRC_T::CTL: CHKSREV Position */ +#define CRC_CTL_CHKSREV_Msk (0x1ul << CRC_CTL_CHKSREV_Pos) /*!< CRC_T::CTL: CHKSREV Mask */ + +#define CRC_CTL_DATFMT_Pos (26) /*!< CRC_T::CTL: DATFMT Position */ +#define CRC_CTL_DATFMT_Msk (0x1ul << CRC_CTL_DATFMT_Pos) /*!< CRC_T::CTL: DATFMT Mask */ + +#define CRC_CTL_CHKSFMT_Pos (27) /*!< CRC_T::CTL: CHKSFMT Position */ +#define CRC_CTL_CHKSFMT_Msk (0x1ul << CRC_CTL_CHKSFMT_Pos) /*!< CRC_T::CTL: CHKSFMT Mask */ + +#define CRC_CTL_DATLEN_Pos (28) /*!< CRC_T::CTL: DATLEN Position */ +#define CRC_CTL_DATLEN_Msk (0x3ul << CRC_CTL_DATLEN_Pos) /*!< CRC_T::CTL: DATLEN Mask */ + +#define CRC_CTL_CRCMODE_Pos (30) /*!< CRC_T::CTL: CRCMODE Position */ +#define CRC_CTL_CRCMODE_Msk (0x3ul << CRC_CTL_CRCMODE_Pos) /*!< CRC_T::CTL: CRCMODE Mask */ + +#define CRC_DAT_DATA_Pos (0) /*!< CRC_T::DAT: DATA Position */ +#define CRC_DAT_DATA_Msk (0xfffffffful << CRC_DAT_DATA_Pos) /*!< CRC_T::DAT: DATA Mask */ + +#define CRC_SEED_SEED_Pos (0) /*!< CRC_T::SEED: SEED Position */ +#define CRC_SEED_SEED_Msk (0xfffffffful << CRC_SEED_SEED_Pos) /*!< CRC_T::SEED: SEED Mask */ + +#define CRC_CHECKSUM_CHECKSUM_Pos (0) /*!< CRC_T::CHECKSUM: CHECKSUM Position */ +#define CRC_CHECKSUM_CHECKSUM_Msk (0xfffffffful << CRC_CHECKSUM_CHECKSUM_Pos) /*!< CRC_T::CHECKSUM: CHECKSUM Mask */ + +/**@}*/ /* CRC_CONST */ +/**@}*/ /* end of CRC register group */ + + +/*---------------------- Cryptographic Accelerator -------------------------*/ +/** + @addtogroup CRPT Cryptographic Accelerator(CRPT) + Memory Mapped Structure for CRPT Controller +@{ */ + +typedef struct { + /** + * INTEN + * =================================================================================================== + * Offset: 0x00 Crypto Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |AESIEN |AES Interrupt Enable Control + * | | |0 = AES interrupt Disabled. + * | | |1 = AES interrupt Enabled. + * | | |In DMA mode, an interrupt will be triggered when amount of data set in AES_DMA_CNT is fed into the AES engine. + * | | |In Non-DMA mode, an interrupt will be triggered when the AES engine finishes the operation. + * |[1] |AESERRIEN |AES Error Flag Enable Control + * | | |0 = AES error interrupt flag Disabled. + * | | |1 = AES error interrupt flag Enabled. + * |[8] |TDESIEN |TDES/DES Interrupt Enable Control + * | | |0 = TDES/DES interrupt Disabled. + * | | |1 = TDES/DES interrupt Enabled. + * | | |In DMA mode, an interrupt will be triggered when amount of data set in TDES_DMA_CNT is fed into the TDES engine. + * | | |In Non-DMA mode, an interrupt will be triggered when the TDES engine finishes the operation. + * |[9] |TDESERRIEN|TDES/DES Error Flag Enable Control + * | | |0 = TDES/DES error interrupt flag Disabled. + * | | |1 = TDES/DES error interrupt flag Enabled. + * |[16] |PRNGIEN |PRNG Interrupt Enable Control + * | | |0 = PRNG interrupt Disabled. + * | | |1 = PRNG interrupt Enabled. + * |[24] |SHAIEN |SHA Interrupt Enable Control + * | | |0 = SHA interrupt Disabled. + * | | |1 = SHA interrupt Enabled. + * | | |In DMA mode, an interrupt will be triggered when amount of data set in SHA _DMA_CNT is fed into the SHA engine. + * | | |In Non-DMA mode, an interrupt will be triggered when the SHA engine finishes the operation. + * |[25] |SHAERRIEN |SHA Error Interrupt Enable Control + * | | |0 = SHA error interrupt flag Disabled. + * | | |1 = SHA error interrupt flag Enabled. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x04 Crypto Interrupt Flag + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |AESIF |AES Finish Interrupt Flag + * | | |This bit is cleared by writing 1, and it has no effect by writing 0. + * | | |0 = No AES interrupt. + * | | |1 = AES encryption/decryption done interrupt. + * |[1] |AESERRIF |AES Error Flag + * | | |This bit is cleared by writing 1, and it has no effect by writing 0. + * | | |0 = No AES error. + * | | |1 = AES encryption/decryption done interrupt. + * |[8] |TDESIF |TDES/DES Finish Interrupt Flag + * | | |This bit is cleared by writing 1, and it has no effect by writing 0. + * | | |0 = No TDES/DES interrupt. + * | | |1 = TDES/DES encryption/decryption done interrupt. + * |[9] |TDESERRIF |TDES/DES Error Flag + * | | |This bit includes the operating and setting error. + * | | |The detailed flag is shown in the TDES _FLAG register. + * | | |This includes operating and setting error. + * | | |This bit is cleared by writing 1, and it has no effect by writing 0. + * | | |0 = No TDES/DES error. + * | | |1 = TDES/DES encryption/decryption error interrupt. + * |[16] |PRNGIF |PRNG Finish Interrupt Flag + * | | |This bit is cleared by writing 1, and it has no effect by writing 0. + * | | |0 = No PRNG interrupt. + * | | |1 = PRNG key generation done interrupt. + * |[24] |SHAIF |SHA Finish Interrupt Flag + * | | |This bit is cleared by writing 1, and it has no effect by writing 0. + * | | |0 = No SHA interrupt. + * | | |1 = SHA operation done interrupt. + * |[25] |SHAERRIF |SHA Error Flag + * | | |This register includes operating and setting error. The detail flag is shown in SHA _FLAG register. + * | | |This bit is cleared by writing 1, and it has no effect by writing 0. + * | | |0 = No SHA error. + * | | |1 = SHA error interrupt. + */ + __IO uint32_t INTSTS; + + /** + * PRNG_CTL + * =================================================================================================== + * Offset: 0x08 PRNG Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |START |Start PRNG Engine + * | | |0 = Stop PRNG engine. + * | | |1 = Generate new key and store the new key to register CRPT_PRNG_KEYx , which will be cleared when the new key is generated. + * |[1] |SEEDRLD |Reload New Seed For PRNG Engine + * | | |0 = Generating key based on the current seed. + * | | |1 = Reload new seed. + * |[2:3] |KEYSZ |PRNG Generate Key Size + * | | |00 = 64 bits. + * | | |01 = 128 bits. + * | | |10 = 192 bits. + * | | |11 = 256 bits. + * |[8] |BUSY |PRNG Busy (Read Only) + * | | |0 = PRNG engine is idle. + * | | |1 = Indicate that the PRNG engine is generating CRPT_PRNG_KEYx. + */ + __IO uint32_t PRNG_CTL; + + /** + * PRNG_SEED + * =================================================================================================== + * Offset: 0x0C Seed for PRNG + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CRPT_PRNG_SEED|Seed For PRNG (Write Only) + * | | |The bits store the seed for PRNG engine. + */ + __O uint32_t PRNG_SEED; + + /** + * PRNG_KEY0 + * =================================================================================================== + * Offset: 0x10 PRNG Generated Key0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY0; + + /** + * PRNG_KEY1 + * =================================================================================================== + * Offset: 0x14 PRNG Generated Key1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY1; + + /** + * PRNG_KEY2 + * =================================================================================================== + * Offset: 0x18 PRNG Generated Key2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY2; + + /** + * PRNG_KEY3 + * =================================================================================================== + * Offset: 0x1C PRNG Generated Key3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY3; + + /** + * PRNG_KEY4 + * =================================================================================================== + * Offset: 0x20 PRNG Generated Key4 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY4; + + /** + * PRNG_KEY5 + * =================================================================================================== + * Offset: 0x24 PRNG Generated Key5 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY5; + + /** + * PRNG_KEY6 + * =================================================================================================== + * Offset: 0x28 PRNG Generated Key6 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY6; + + /** + * PRNG_KEY7 + * =================================================================================================== + * Offset: 0x2C PRNG Generated Key7 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYx |Store PRNG Generated Key (Read Only) + * | | |The bits store the key that is generated by PRNG. + */ + __I uint32_t PRNG_KEY7; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[8]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * AES_FDBCK0 + * =================================================================================================== + * Offset: 0x50 AES Engine Output Feedback Data after Cryptographic Operation + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |FDBCK |AES Feedback Information + * | | |The feedback value is 128 bits in size. + * | | |The AES engine uses the data from AES_FEEEDBACK as the data inputted to AES_IV for the next block in DMA cascade mode. + * | | |The AES engine outputs feedback information for IV in the next block's operation. + * | | |Software can use this feedback information to implement more than four DMA channels. + * | | |Software can store that feedback value temporarily. + * | | |After switching back, fill the stored feedback value to this register in the same channel operation, and then continue the operation with the original setting. + */ + __I uint32_t AES_FDBCK0; + + /** + * AES_FDBCK1 + * =================================================================================================== + * Offset: 0x54 AES Engine Output Feedback Data after Cryptographic Operation + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |FDBCK |AES Feedback Information + * | | |The feedback value is 128 bits in size. + * | | |The AES engine uses the data from AES_FEEEDBACK as the data inputted to AES_IV for the next block in DMA cascade mode. + * | | |The AES engine outputs feedback information for IV in the next block's operation. + * | | |Software can use this feedback information to implement more than four DMA channels. + * | | |Software can store that feedback value temporarily. + * | | |After switching back, fill the stored feedback value to this register in the same channel operation, and then continue the operation with the original setting. + */ + __I uint32_t AES_FDBCK1; + + /** + * AES_FDBCK2 + * =================================================================================================== + * Offset: 0x58 AES Engine Output Feedback Data after Cryptographic Operation + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |FDBCK |AES Feedback Information + * | | |The feedback value is 128 bits in size. + * | | |The AES engine uses the data from AES_FEEEDBACK as the data inputted to AES_IV for the next block in DMA cascade mode. + * | | |The AES engine outputs feedback information for IV in the next block's operation. + * | | |Software can use this feedback information to implement more than four DMA channels. + * | | |Software can store that feedback value temporarily. + * | | |After switching back, fill the stored feedback value to this register in the same channel operation, and then continue the operation with the original setting. + */ + __I uint32_t AES_FDBCK2; + + /** + * AES_FDBCK3 + * =================================================================================================== + * Offset: 0x5C AES Engine Output Feedback Data after Cryptographic Operation + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |FDBCK |AES Feedback Information + * | | |The feedback value is 128 bits in size. + * | | |The AES engine uses the data from AES_FEEEDBACK as the data inputted to AES_IV for the next block in DMA cascade mode. + * | | |The AES engine outputs feedback information for IV in the next block's operation. + * | | |Software can use this feedback information to implement more than four DMA channels. + * | | |Software can store that feedback value temporarily. + * | | |After switching back, fill the stored feedback value to this register in the same channel operation, and then continue the operation with the original setting. + */ + __I uint32_t AES_FDBCK3; + + /** + * TDES_FDBCKH + * =================================================================================================== + * Offset: 0x60 TDES/DES Engine Output Feedback High Word Data after Cryptographic Operation + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |FDBCK |TDES/DES Feedback + * | | |The feedback value is 64 bits in size. + * | | |The TDES/DES engine uses the data from CRPT_TDES_FEEEDBACK as the data inputted to CRPT_TDES_IV for the next block in DMA cascade mode. + * | | |The feedback register is for CBC, CFB, and OFB mode. + * | | |TDES/DES engine outputs feedback information for IV in the next block's operation. + * | | |Software can use this feedback information to implement more than four DMA channels. + * | | |Software can store that feedback value temporarily. + * | | |After switching back, fill the stored feedback value to this register in the same channel operation. + * | | |Then can continue the operation with the original setting. + */ + __I uint32_t TDES_FDBCKH; + + /** + * TDES_FDBCKL + * =================================================================================================== + * Offset: 0x64 TDES/DES Engine Output Feedback Low Word Data after Cryptographic Operation + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |FDBCK |TDES/DES Feedback + * | | |The feedback value is 64 bits in size. + * | | |The TDES/DES engine uses the data from CRPT_TDES_FEEEDBACK as the data inputted to CRPT_TDES_IV for the next block in DMA cascade mode. + * | | |The feedback register is for CBC, CFB, and OFB mode. + * | | |TDES/DES engine outputs feedback information for IV in the next block's operation. + * | | |Software can use this feedback information to implement more than four DMA channels. + * | | |Software can store that feedback value temporarily. + * | | |After switching back, fill the stored feedback value to this register in the same channel operation. + * | | |Then can continue the operation with the original setting. + */ + __I uint32_t TDES_FDBCKL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[38]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * AES_CTL + * =================================================================================================== + * Offset: 0x100 AES Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |START |AES Engine Start + * | | |0 = No effect. + * | | |1 = Start AES engine. BUSY flag will be set. + * | | |Note: This bit is always 0 when it's read back. + * |[1] |STOP |AES Engine Stop + * | | |0 = No effect. + * | | |1 = Stop AES engine. + * | | |Note: This bit is always 0 when it's read back. + * |[2:3] |KEYSZ |AES Key Size + * | | |This bit defines three different key size for AES operation. + * | | |2'b00 = 128 bits key. + * | | |2'b01 = 192 bits key. + * | | |2'b10 = 256 bits key. + * | | |2'b11 = Reserved. + * | | |If the AES accelerator is operating and the corresponding flag BUSY is 1, updating this register has no effect. + * |[5] |DMALAST |AES Last Block + * | | |In DMA mode, this bit must be set as beginning the last DMA cascade round. + * | | |In Non-DMA mode, this bit must be set when feeding in the last block of data in ECB, CBC, CTR, OFB, and CFB mode, and feeding in the (last-1) block of data at CBC-CS1, CBC-CS2, and CBC-CS3 mode. + * | | |This bit is always 0 when it's read back. Must be written again once START is triggered. + * |[6] |DMACSCAD |AES Engine DMA With Cascade Mode + * | | |0 = DMA cascade function Disabled. + * | | |1 = In DMA cascade mode, software can update DMA source address register, destination address register, and byte count register during a cascade operation, without finishing the accelerator operation. + * |[7] |DMAEN |AES Engine DMA Enable Control + * | | |0 = AES DMA engine Disabled. + * | | |The AES engine operates in Non-DMA mode, and gets data from the port CRPT_AES_DATIN. + * | | |1 = AES DMA engine Enabled. + * | | |The AES engine operates in DMA mode, and data movement from/to the engine is done by DMA logic. + * |[8:15] |OPMODE |AES Engine Operation Modes + * | | |0x00 = ECB (Electronic Codebook Mode) + * | | |0x01 = CBC (Cipher Block Chaining Mode). + * | | |0x02 = CFB (Cipher Feedback Mode). + * | | |0x03 = OFB (Output Feedback Mode). + * | | |0x04 = CTR (Counter Mode). + * | | |0x10 = CBC-CS1 (CBC Ciphertext-Stealing 1 Mode). + * | | |0x11 = CBC-CS2 (CBC Ciphertext-Stealing 2 Mode). + * | | |0x12 = CBC-CS3 (CBC Ciphertext-Stealing 3 Mode). + * |[16] |ENCRPT |AES Encryption/Decryption + * | | |0 = AES engine executes decryption operation. + * | | |1 = AES engine executes encryption operation. + * |[22] |OUTSWAP |AES Engine Output Data Swap + * | | |0 = Keep the original order. + * | | |1 = The order that CPU outputs data from the accelerator will be changed from {byte3, byte2, byte1, byte0} to {byte0, byte1, byte2, byte3}. + * |[23] |INSWAP |AES Engine Input Data Swap + * | | |0 = Keep the original order. + * | | |1 = The order that CPU feeds data to the accelerator will be changed from {byte3, byte2, byte1, byte0} to {byte0, byte1, byte2, byte3}. + * |[24:25] |CHANNEL |AES Engine Working Channel + * | | |00 = Current control register setting is for channel 0. + * | | |01 = Current control register setting is for channel 1. + * | | |10 = Current control register setting is for channel 2. + * | | |11 = Current control register setting is for channel 3. + * |[26:30] |KEYUNPRT |Unprotect Key + * | | |Writing 0 to CRPT_AES_CTL [31] and "10110" to CRPT_AES_CTL [30:26] is to unprotect the AES key. + * | | |The KEYUNPRT can be read and written. + * | | |When it is written as the AES engine is operating, BUSY flag is 1, there would be no effect on KEYUNPRT. + * |[31] |KEYPRT |Protect Key + * | | |Read as a flag to reflect KEYPRT. + * | | |0 = No effect. + * | | |1 = Protect the content of the AES key from reading. + * | | |The return value for reading CRPT_AESn_KEYx is not the content of the registers CRPT_AESn_KEYx. + * | | |Once it is set, it can be cleared by asserting KEYUNPRT. + * | | |And the key content would be cleared as well. + */ + __IO uint32_t AES_CTL; + + /** + * AES_STS + * =================================================================================================== + * Offset: 0x104 AES Engine Flag + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BUSY |AES Engine Busy + * | | |0 = The AES engine is idle or finished. + * | | |1 = The AES engine is under processing. + * |[8] |INBUFEMPTY|AES Input Buffer Empty + * | | |0 = There are some data in input buffer waiting for the AES engine to process. + * | | |1 = AES input buffer is empty. + * | | |Software needs to feed data to the AES engine. + * | | |Otherwise, the AES engine will be pending to wait for input data. + * |[9] |INBUFFULL |AES Input Buffer Full Flag + * | | |0 = AES input buffer is not full. Software can feed the data into the AES engine. + * | | |1 = AES input buffer is full. + * | | |Software cannot feed data to the AES engine. + * | | |Otherwise, the flag INBUFERR will be set to 1. + * |[10] |INBUFERR |AES Input Buffer Error Flag + * | | |0 = No error. + * | | |1 = Error happens during feeding data to the AES engine. + * |[12] |CNTERR |AES_CNT Setting Error + * | | |0 = No error in AES_CNT setting. + * | | |1 = AES_CNT is not a multiply of 16 in ECB, CBC, CFB, OFB, and CTR mode. + * |[16] |OUTBUFEMPTY|AES Out Buffer Empty + * | | |0 = AES output buffer is not empty. There are some valid data kept in output buffer. + * | | |1 = AES output buffer is empty. + * | | |Software cannot get data from AES_DATA_OUT. + * | | |Otherwise, the flag OUTBUFERR will be set to 1 since the output buffer is empty. + * |[17] |OUTBUFFULL|AES Out Buffer Full Flag + * | | |0 = AES output buffer is not full. + * | | |1 = AES output buffer is full, and software needs to get data from AES_DATA_OUT. + * | | |Otherwise, the AES engine will be pending since the output buffer is full. + * |[18] |OUTBUFERR |AES Out Buffer Error Flag + * | | |0 = No error. + * | | |1 = Error happens during getting the result from AES engine. + * |[20] |BUSERR |AES DMA Access Bus Error Flag + * | | |0 = No error. + * | | |1 = Bus error will stop DMA operation and AES engine. + */ + __I uint32_t AES_STS; + + /** + * AES_DATIN + * =================================================================================================== + * Offset: 0x108 AES Engine Data Input Port Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DATIN |AES Engine Input Port + * | | |CPU feeds data to AES engine through this port by checking CRPT_AES_STS. Feed data as INBUFFULL is 0. + */ + __IO uint32_t AES_DATIN; + + /** + * AES_DATOUT + * =================================================================================================== + * Offset: 0x10C AES Engine Data Output Port Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DATOUT |AES Engine Output Port + * | | |CPU gets results from the AES engine through this port by checking CRPT_AES_STS. + * | | |Get data as OUTBUFEMPTY is 0. + */ + __I uint32_t AES_DATOUT; + + /** + * AES0_KEY0 + * =================================================================================================== + * Offset: 0x110 AES Key Word 0 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY0; + + /** + * AES0_KEY1 + * =================================================================================================== + * Offset: 0x114 AES Key Word 1 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY1; + + /** + * AES0_KEY2 + * =================================================================================================== + * Offset: 0x118 AES Key Word 2 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY2; + + /** + * AES0_KEY3 + * =================================================================================================== + * Offset: 0x11C AES Key Word 3 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY3; + + /** + * AES0_KEY4 + * =================================================================================================== + * Offset: 0x120 AES Key Word 4 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY4; + + /** + * AES0_KEY5 + * =================================================================================================== + * Offset: 0x124 AES Key Word 5 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY5; + + /** + * AES0_KEY6 + * =================================================================================================== + * Offset: 0x128 AES Key Word 6 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY6; + + /** + * AES0_KEY7 + * =================================================================================================== + * Offset: 0x12C AES Key Word 7 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES0_KEY7; + + /** + * AES0_IV0 + * =================================================================================================== + * Offset: 0x130 AES Initial Vector Word 0 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES0_IV0; + + /** + * AES0_IV1 + * =================================================================================================== + * Offset: 0x134 AES Initial Vector Word 1 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES0_IV1; + + /** + * AES0_IV2 + * =================================================================================================== + * Offset: 0x138 AES Initial Vector Word 2 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES0_IV2; + + /** + * AES0_IV3 + * =================================================================================================== + * Offset: 0x13C AES Initial Vector Word 3 Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES0_IV3; + + /** + * AES0_SADDR + * =================================================================================================== + * Offset: 0x140 AES DMA Source Address Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |AES DMA Source Address + * | | |The AES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The AES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the AES accelerator can read the plain text from system memory and do AES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_SADR are ignored. + * | | |AES_SADR can be read and written. + * | | |Writing to AES_SADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next AES operation. + * | | |In DMA mode, software can update the next AES_SADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES0_SADDR; + + /** + * AES0_DADDR + * =================================================================================================== + * Offset: 0x144 AES DMA Destination Address Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |AES DMA Destination Address + * | | |The AES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The AES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the AES accelerator can write the cipher text back to system memory after the AES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_DADR are ignored. + * | | |AES_DADR can be read and written. + * | | |Writing to AES_DADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next AES operation. + * | | |In DMA mode, software can update the next AES_DADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES0_DADDR; + + /** + * AES0_CNT + * =================================================================================================== + * Offset: 0x148 AES Byte Count Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |AES Byte Count + * | | |The AES_CNT keeps the byte count of source text that is for the AES engine operating in DMA mode. + * | | |The AES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |AES_CNT can be read and written. + * | | |Writing to AES_CNT while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next AES operation. + * | | |According to CBC-CS1, CBC-CS2, and CBC-CS3 standard, the count of operation data must be at least one block. + * | | |Operations that are less than one block will output unexpected result. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, AES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + * | | |In Non-DMA CBC-CS1, CBC-CS2, and CBC-CS3 mode, AES_CNT must be set as byte count for the last two blocks of data before feeding in the last two blocks of data. + */ + __IO uint32_t AES0_CNT; + + /** + * AES1_KEY0 + * =================================================================================================== + * Offset: 0x14C AES Key Word 0 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY0; + + /** + * AES1_KEY1 + * =================================================================================================== + * Offset: 0x150 AES Key Word 1 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY1; + + /** + * AES1_KEY2 + * =================================================================================================== + * Offset: 0x154 AES Key Word 2 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY2; + + /** + * AES1_KEY3 + * =================================================================================================== + * Offset: 0x158 AES Key Word 3 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY3; + + /** + * AES1_KEY4 + * =================================================================================================== + * Offset: 0x15C AES Key Word 4 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY4; + + /** + * AES1_KEY5 + * =================================================================================================== + * Offset: 0x160 AES Key Word 5 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY5; + + /** + * AES1_KEY6 + * =================================================================================================== + * Offset: 0x164 AES Key Word 6 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY6; + + /** + * AES1_KEY7 + * =================================================================================================== + * Offset: 0x168 AES Key Word 7 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES1_KEY7; + + /** + * AES1_IV0 + * =================================================================================================== + * Offset: 0x16C AES Initial Vector Word 0 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES1_IV0; + + /** + * AES1_IV1 + * =================================================================================================== + * Offset: 0x170 AES Initial Vector Word 1 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES1_IV1; + + /** + * AES1_IV2 + * =================================================================================================== + * Offset: 0x174 AES Initial Vector Word 2 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES1_IV2; + + /** + * AES1_IV3 + * =================================================================================================== + * Offset: 0x178 AES Initial Vector Word 3 Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES1_IV3; + + /** + * AES1_SADDR + * =================================================================================================== + * Offset: 0x17C AES DMA Source Address Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |AES DMA Source Address + * | | |The AES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The AES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the AES accelerator can read the plain text from system memory and do AES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_SADR are ignored. + * | | |AES_SADR can be read and written. + * | | |Writing to AES_SADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next AES operation. + * | | |In DMA mode, software can update the next AES_SADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES1_SADDR; + + /** + * AES1_DADDR + * =================================================================================================== + * Offset: 0x180 AES DMA Destination Address Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |AES DMA Destination Address + * | | |The AES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The AES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the AES accelerator can write the cipher text back to system memory after the AES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_DADR are ignored. + * | | |AES_DADR can be read and written. + * | | |Writing to AES_DADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next AES operation. + * | | |In DMA mode, software can update the next AES_DADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES1_DADDR; + + /** + * AES1_CNT + * =================================================================================================== + * Offset: 0x184 AES Byte Count Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |AES Byte Count + * | | |The AES_CNT keeps the byte count of source text that is for the AES engine operating in DMA mode. + * | | |The AES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |AES_CNT can be read and written. + * | | |Writing to AES_CNT while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next AES operation. + * | | |According to CBC-CS1, CBC-CS2, and CBC-CS3 standard, the count of operation data must be at least one block. + * | | |Operations that are less than one block will output unexpected result. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, AES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + * | | |In Non-DMA CBC-CS1, CBC-CS2, and CBC-CS3 mode, AES_CNT must be set as byte count for the last two blocks of data before feeding in the last two blocks of data. + */ + __IO uint32_t AES1_CNT; + + /** + * AES2_KEY0 + * =================================================================================================== + * Offset: 0x188 AES Key Word 0 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY0; + + /** + * AES2_KEY1 + * =================================================================================================== + * Offset: 0x18C AES Key Word 1 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY1; + + /** + * AES2_KEY2 + * =================================================================================================== + * Offset: 0x190 AES Key Word 2 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY2; + + /** + * AES2_KEY3 + * =================================================================================================== + * Offset: 0x194 AES Key Word 3 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY3; + + /** + * AES2_KEY4 + * =================================================================================================== + * Offset: 0x198 AES Key Word 4 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY4; + + /** + * AES2_KEY5 + * =================================================================================================== + * Offset: 0x19C AES Key Word 5 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY5; + + /** + * AES2_KEY6 + * =================================================================================================== + * Offset: 0x1A0 AES Key Word 6 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY6; + + /** + * AES2_KEY7 + * =================================================================================================== + * Offset: 0x1A4 AES Key Word 7 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES2_KEY7; + + /** + * AES2_IV0 + * =================================================================================================== + * Offset: 0x1A8 AES Initial Vector Word 0 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES2_IV0; + + /** + * AES2_IV1 + * =================================================================================================== + * Offset: 0x1AC AES Initial Vector Word 1 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES2_IV1; + + /** + * AES2_IV2 + * =================================================================================================== + * Offset: 0x1B0 AES Initial Vector Word 2 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES2_IV2; + + /** + * AES2_IV3 + * =================================================================================================== + * Offset: 0x1B4 AES Initial Vector Word 3 Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES2_IV3; + + /** + * AES2_SADDR + * =================================================================================================== + * Offset: 0x1B8 AES DMA Source Address Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |AES DMA Source Address + * | | |The AES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The AES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the AES accelerator can read the plain text from system memory and do AES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_SADR are ignored. + * | | |AES_SADR can be read and written. + * | | |Writing to AES_SADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next AES operation. + * | | |In DMA mode, software can update the next AES_SADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES2_SADDR; + + /** + * AES2_DADDR + * =================================================================================================== + * Offset: 0x1BC AES DMA Destination Address Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |AES DMA Destination Address + * | | |The AES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The AES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the AES accelerator can write the cipher text back to system memory after the AES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_DADR are ignored. + * | | |AES_DADR can be read and written. + * | | |Writing to AES_DADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next AES operation. + * | | |In DMA mode, software can update the next AES_DADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES2_DADDR; + + /** + * AES2_CNT + * =================================================================================================== + * Offset: 0x1C0 AES Byte Count Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |AES Byte Count + * | | |The AES_CNT keeps the byte count of source text that is for the AES engine operating in DMA mode. + * | | |The AES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |AES_CNT can be read and written. + * | | |Writing to AES_CNT while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next AES operation. + * | | |According to CBC-CS1, CBC-CS2, and CBC-CS3 standard, the count of operation data must be at least one block. + * | | |Operations that are less than one block will output unexpected result. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, AES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + * | | |In Non-DMA CBC-CS1, CBC-CS2, and CBC-CS3 mode, AES_CNT must be set as byte count for the last two blocks of data before feeding in the last two blocks of data. + */ + __IO uint32_t AES2_CNT; + + /** + * AES3_KEY0 + * =================================================================================================== + * Offset: 0x1C4 AES Key Word 0 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY0; + + /** + * AES3_KEY1 + * =================================================================================================== + * Offset: 0x1C8 AES Key Word 1 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY1; + + /** + * AES3_KEY2 + * =================================================================================================== + * Offset: 0x1CC AES Key Word 2 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY2; + + /** + * AES3_KEY3 + * =================================================================================================== + * Offset: 0x1D0 AES Key Word 3 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY3; + + /** + * AES3_KEY4 + * =================================================================================================== + * Offset: 0x1D4 AES Key Word 4 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY4; + + /** + * AES3_KEY5 + * =================================================================================================== + * Offset: 0x1D8 AES Key Word 5 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY5; + + /** + * AES3_KEY6 + * =================================================================================================== + * Offset: 0x1DC AES Key Word 6 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY6; + + /** + * AES3_KEY7 + * =================================================================================================== + * Offset: 0x1E0 AES Key Word 7 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |AES Key X + * | | |The KEY keeps the security key for AES operation. + * | | |n = 0, 1..3. + * | | |x = 0, 1..7. + * | | |The security key for AES accelerator can be 128, 192, or 256 bits and four, six, or eight 32-bit registers are to store each security key. + * | | |{AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 128-bit security key for AES operation. + * | | |{AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 192-bit security key for AES operation. + * | | |{AES_KEY7, AES_KEY6, AES_KEY5, AES_KEY4, AES_KEY3, AES_KEY2, AES_KEY1, AES_KEY0} stores the 256-bit security key for AES operation. + */ + __IO uint32_t AES3_KEY7; + + /** + * AES3_IV0 + * =================================================================================================== + * Offset: 0x1E4 AES Initial Vector Word 0 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES3_IV0; + + /** + * AES3_IV1 + * =================================================================================================== + * Offset: 0x1E8 AES Initial Vector Word 1 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES3_IV1; + + /** + * AES3_IV2 + * =================================================================================================== + * Offset: 0x1EC AES Initial Vector Word 2 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES3_IV2; + + /** + * AES3_IV3 + * =================================================================================================== + * Offset: 0x1F0 AES Initial Vector Word 3 Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IV |AES Initial Vector Word X + * | | |n = 0, 1..3. + * | | |x = 0, 1..3. + * | | |Four initial vectors (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) are for AES operating in CBC, CFB, and OFB mode. + * | | |Four registers (AES_IV0, AES_IV1, AES_IV2, and AES_IV3) act as Nonce counter when the AES engine is operating in CTR mode. + */ + __IO uint32_t AES3_IV3; + + /** + * AES3_SADDR + * =================================================================================================== + * Offset: 0x1F4 AES DMA Source Address Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |AES DMA Source Address + * | | |The AES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The AES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the AES accelerator can read the plain text from system memory and do AES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_SADR are ignored. + * | | |AES_SADR can be read and written. + * | | |Writing to AES_SADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next AES operation. + * | | |In DMA mode, software can update the next AES_SADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES3_SADDR; + + /** + * AES3_DADDR + * =================================================================================================== + * Offset: 0x1F8 AES DMA Destination Address Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |AES DMA Destination Address + * | | |The AES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The AES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the AES accelerator can write the cipher text back to system memory after the AES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of AES_DADR are ignored. + * | | |AES_DADR can be read and written. + * | | |Writing to AES_DADR while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next AES operation. + * | | |In DMA mode, software can update the next AES_DADR before triggering START. + * | | |The value of AES_SADR and AES_DADR can be the same. + */ + __IO uint32_t AES3_DADDR; + + /** + * AES3_CNT + * =================================================================================================== + * Offset: 0x1FC AES Byte Count Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |AES Byte Count + * | | |The AES_CNT keeps the byte count of source text that is for the AES engine operating in DMA mode. + * | | |The AES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |AES_CNT can be read and written. + * | | |Writing to AES_CNT while the AES accelerator is operating doesn't affect the current AES operation. + * | | |But the value of AES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next AES operation. + * | | |According to CBC-CS1, CBC-CS2, and CBC-CS3 standard, the count of operation data must be at least one block. + * | | |Operations that are less than one block will output unexpected result. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, AES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + * | | |In Non-DMA CBC-CS1, CBC-CS2, and CBC-CS3 mode, AES_CNT must be set as byte count for the last two blocks of data before feeding in the last two blocks of data. + */ + __IO uint32_t AES3_CNT; + + /** + * TDES_CTL + * =================================================================================================== + * Offset: 0x200 TDES/DES Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |START |TDES/DES Engine Start + * | | |0 = No effect. + * | | |1 = Start TDES/DES engine. The flag BUSY would be set. + * | | |Note: The bit is always 0 when it's read back. + * |[1] |STOP |TDES/DES Engine Stop + * | | |0 = No effect. + * | | |1 = Stop TDES/DES engine. + * | | |Note: The bit is always 0 when it's read back. + * |[2] |TMODE |TDES/DES Engine Operating Mode + * | | |0 = Set DES mode for TDES/DES engine. + * | | |1 = Set Triple DES mode for TDES/DES engine. + * |[3] |3KEYS |TDES/DES Key Number + * | | |0 = Select KEY1 and KEY2 in TDES/DES engine. + * | | |1 = Triple keys in TDES/DES engine Enabled. + * |[5] |DMALAST |TDES/DES Engine Start For The Last Block + * | | |In DMA mode, this bit must be set as beginning the last DMA cascade round. + * | | |In Non-DMA mode, this bit must be set as feeding in last block of data. + * |[6] |DMACSCAD |TDES/DES Engine DMA With Cascade Mode + * | | |0 = DMA cascade function Disabled. + * | | |1 = In DMA Cascade mode, software can update DMA source address register, destination address register, and byte count register during a cascade operation, without finishing the accelerator operation. + * |[7] |DMAEN |TDES/DES Engine DMA Enable Control + * | | |0 = TDES_DMA engine Disabled. + * | | |TDES engine operates in Non-DMA mode, and get data from the port CRPT_TDES_DATIN. + * | | |1 = TDES_DMA engine Enabled. + * | | |TDES engine operates in DMA mode, and data movement from/to the engine is done by DMA logic. + * |[8:10] |OPMODE |TDES/DES Engine Operation Mode + * | | |0x00 = ECB (Electronic Codebook Mode). + * | | |0x01 = CBC (Cipher Block Chaining Mode). + * | | |0x02 = CFB (Cipher Feedback Mode). + * | | |0x03 = OFB (Output Feedback Mode). + * | | |0x04 = CTR (Counter Mode). + * | | |Others = CTR (Counter Mode). + * |[16] |ENCRPT |TDES/DES Encryption/Decryption + * | | |0 = TDES engine executes decryption operation. + * | | |1 = TDES engine executes encryption operation. + * |[21] |BLKSWAP |TDES/DES Engine Block Double Word Endian Swap + * | | |0 = Keep the original order, e.g. {WORD_H, WORD_L}. + * | | |1 = When this bit is set to 1, the TDES engine would exchange high and low word in the sequence {WORD_L, WORD_H}. + * |[22] |OUTSWAP |TDES/DES Engine Output Data Swap + * | | |0 = Keep the original order. + * | | |1 = The order that CPU outputs data from the accelerator will be changed from {byte3, byte2, byte1, byte0} to {byte0, byte1, byte2, byte3}. + * |[23] |INSWAP |TDES/DES Engine Input Data Swap + * | | |0 = Keep the original order. + * | | |1 = The order that CPU feeds data to the accelerator will be changed from {byte3, byte2, byte1, byte0} to {byte0, byte1, byte2, byte3}. + * |[24:25] |CHANNEL |TDES/DES Engine Working Channel + * | | |00 = Current control register setting is for channel 0. + * | | |01 = Current control register setting is for channel 1. + * | | |10 = Current control register setting is for channel 2. + * | | |11 = Current control register setting is for channel 3. + * |[26:30] |KEYUNPRT |Unprotected Key + * | | |Writing 0 to CRPT_TDES_CTL [31] and "10110" to CRPT_TDES_CTL [30:26] is to unprotect TDES key. + * | | |The KEYUNPRT can be read and written. + * | | |When it is written as the TDES engine is operating, BUSY flag is 1, there would be no effect on KEYUNPRT. + * |[31] |KEYPRT |Protect Key + * | | |Read as a flag to reflect KEYPRT. + * | | |0 = No effect. + * | | |1 = This bit is to protect the content of TDES key from reading. + * | | |The return value for reading CRPT_ TDESn_KEYxH/L is not the content in the registers CRPT_ TDESn_KEYxH/L. + * | | |Once it is set, it can be cleared by asserting KEYUNPRT. + * | | |The key content would be cleared as well. + */ + __IO uint32_t TDES_CTL; + + /** + * TDES_STS + * =================================================================================================== + * Offset: 0x204 TDES/DES Engine Flag + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BUSY |TDES/DES Engine Busy + * | | |0 = TDES/DES engine is idle or finished. + * | | |1 = TDES/DES engine is under processing. + * |[8] |INBUFEMPTY|TDES/DES In Buffer Empty + * | | |0 = There are some data in input buffer waiting for the TDES/DES engine to process. + * | | |1 = TDES/DES input buffer is empty. + * | | |Software needs to feed data to the TDES/DES engine. + * | | |Otherwise, the TDES/DES engine will be pending to wait for input data. + * |[9] |INBUFFULL |TDES/DES In Buffer Full Flag + * | | |0 = TDES/DES input buffer is not full. Software can feed the data into the TDES/DES engine. + * | | |1 = TDES input buffer is full. + * | | |Software cannot feed data to the TDES/DES engine. + * | | |Otherwise, the flag INBUFERR will be set to 1. + * |[10] |INBUFERR |TDES/DES In Buffer Error Flag + * | | |0 = No error. + * | | |1 = Error happens during feeding data to the TDES/DES engine. + * |[16] |OUTBUFEMPTY|TDES/DES Output Buffer Empty Flag + * | | |0 = TDES/DES output buffer is not empty. There are some valid data kept in output buffer. + * | | |1 = TDES/DES output buffer is empty, Software cannot get data from TDES_DATA_OUT. + * | | |Otherwise the flag OUTBUFERR will be set to 1, since output buffer is empty. + * |[17] |OUTBUFFULL|TDES/DES Output Buffer Full Flag + * | | |0 = TDES/DES output buffer is not full. + * | | |1 = TDES/DES output buffer is full, and software needs to get data from TDES_DATA_OUT. + * | | |Otherwise, the TDES/DES engine will be pending since output buffer is full. + * |[18] |OUTBUFERR |TDES/DES Out Buffer Error Flag + * | | |0 = No error. + * | | |1 = Error happens during getting test result from TDES/DES engine. + * |[20] |BUSERR |TDES/DES DMA Access Bus Error Flag + * | | |0 = No error. + * | | |1 = Bus error will stop DMA operation and TDES/DES engine. + */ + __I uint32_t TDES_STS; + + /** + * TDES0_KEY1H + * =================================================================================================== + * Offset: 0x208 TDES/DES Key 1 High Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES0_KEY1H; + + /** + * TDES0_KEY1L + * =================================================================================================== + * Offset: 0x20C TDES/DES Key 1 Low Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES0_KEY1L; + + /** + * TDES0_KEY2H + * =================================================================================================== + * Offset: 0x210 TDES Key 2 High Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES0_KEY2H; + + /** + * TDES0_KEY2L + * =================================================================================================== + * Offset: 0x214 TDES Key 2 Low Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES0_KEY2L; + + /** + * TDES0_KEY3H + * =================================================================================================== + * Offset: 0x218 TDES Key 3 High Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES0_KEY3H; + + /** + * TDES0_KEY3L + * =================================================================================================== + * Offset: 0x21C TDES Key 3 Low Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES0_KEY3L; + + /** + * TDES0_IVH + * =================================================================================================== + * Offset: 0x220 TDES/DES Initial Vector High Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES0_IVH; + + /** + * TDES0_IVL + * =================================================================================================== + * Offset: 0x224 TDES/DES Initial Vector Low Word Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES0_IVL; + + /** + * TDES0_SADDR + * =================================================================================================== + * Offset: 0x228 TDES/DES DMA Source Address Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |TDES/DES DMA Source Address + * | | |The TDES/DES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The TDES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the TDES/DES accelerator can read the plain text from system memory and do TDES/DES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_SADR are ignored. + * | | |TDES_SADR can be read and written. + * | | |Writing to TDES_SADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_SADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES0_SADDR; + + /** + * TDES0_DADDR + * =================================================================================================== + * Offset: 0x22C TDES/DES DMA Destination Address Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |TDES/DES DMA Destination Address + * | | |The TDES/DES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The TDES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the TDES/DES accelerator can write the cipher text back to system memory after the TDES/DES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_DADR are ignored. + * | | |TDES_DADR can be read and written. + * | | |Writing to TDES_DADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_DADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES0_DADDR; + + /** + * TDES0_CNT + * =================================================================================================== + * Offset: 0x230 TDES/DES Byte Count Register for Channel 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |TDES/DES Byte Count + * | | |The TDES_CNT keeps the byte count of source text that is for the TDES/DES engine operating in DMA mode. + * | | |The TDES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |TDES_CNT can be read and written. + * | | |Writing to TDES_CNT while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next TDES /DES operation. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, TDES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + */ + __IO uint32_t TDES0_CNT; + + /** + * TDES_DATIN + * =================================================================================================== + * Offset: 0x234 TDES/DES Engine Input data Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DATIN |TDES/DES Engine Input Port + * | | |CPU feeds data to TDES/DES engine through this port by checking CRPT_TDES_STS. + * | | |Feed data as INBUFFULL is 0. + */ + __IO uint32_t TDES_DATIN; + + /** + * TDES_DATOUT + * =================================================================================================== + * Offset: 0x238 TDES/DES Engine Output data Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DATOUT |TDES/DES Engine Output Port + * | | |CPU gets result from the TDES/DES engine through this port by checking CRPT_TDES_STS. + * | | |Get data as OUTBUFEMPTY is 0. + */ + __I uint32_t TDES_DATOUT; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TDES1_KEY1H + * =================================================================================================== + * Offset: 0x248 TDES/DES Key 1 High Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES1_KEY1H; + + /** + * TDES1_KEY1L + * =================================================================================================== + * Offset: 0x24C TDES/DES Key 1 Low Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES1_KEY1L; + + /** + * TDES1_KEY2H + * =================================================================================================== + * Offset: 0x250 TDES Key 2 High Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES1_KEY2H; + + /** + * TDES1_KEY2L + * =================================================================================================== + * Offset: 0x254 TDES Key 2 Low Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES1_KEY2L; + + /** + * TDES1_KEY3H + * =================================================================================================== + * Offset: 0x258 TDES Key 3 High Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES1_KEY3H; + + /** + * TDES1_KEY3L + * =================================================================================================== + * Offset: 0x25C TDES Key 3 Low Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES1_KEY3L; + + /** + * TDES1_IVH + * =================================================================================================== + * Offset: 0x260 TDES/DES Initial Vector High Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES1_IVH; + + /** + * TDES1_IVL + * =================================================================================================== + * Offset: 0x264 TDES/DES Initial Vector Low Word Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES1_IVL; + + /** + * TDES1_SADDR + * =================================================================================================== + * Offset: 0x268 TDES/DES DMA Source Address Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |TDES/DES DMA Source Address + * | | |The TDES/DES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The TDES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the TDES/DES accelerator can read the plain text from system memory and do TDES/DES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_SADR are ignored. + * | | |TDES_SADR can be read and written. + * | | |Writing to TDES_SADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_SADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES1_SADDR; + + /** + * TDES1_DADDR + * =================================================================================================== + * Offset: 0x26C TDES/DES DMA Destination Address Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |TDES/DES DMA Destination Address + * | | |The TDES/DES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The TDES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the TDES/DES accelerator can write the cipher text back to system memory after the TDES/DES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_DADR are ignored. + * | | |TDES_DADR can be read and written. + * | | |Writing to TDES_DADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_DADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES1_DADDR; + + /** + * TDES1_CNT + * =================================================================================================== + * Offset: 0x270 TDES/DES Byte Count Register for Channel 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |TDES/DES Byte Count + * | | |The TDES_CNT keeps the byte count of source text that is for the TDES/DES engine operating in DMA mode. + * | | |The TDES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |TDES_CNT can be read and written. + * | | |Writing to TDES_CNT while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next TDES /DES operation. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, TDES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + */ + __IO uint32_t TDES1_CNT; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE3[5]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TDES2_KEY1H + * =================================================================================================== + * Offset: 0x288 TDES/DES Key 1 High Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES2_KEY1H; + + /** + * TDES2_KEY1L + * =================================================================================================== + * Offset: 0x28C TDES/DES Key 1 Low Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES2_KEY1L; + + /** + * TDES2_KEY2H + * =================================================================================================== + * Offset: 0x290 TDES Key 2 High Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES2_KEY2H; + + /** + * TDES2_KEY2L + * =================================================================================================== + * Offset: 0x294 TDES Key 2 Low Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES2_KEY2L; + + /** + * TDES2_KEY3H + * =================================================================================================== + * Offset: 0x298 TDES Key 3 High Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES2_KEY3H; + + /** + * TDES2_KEY3L + * =================================================================================================== + * Offset: 0x29C TDES Key 3 Low Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES2_KEY3L; + + /** + * TDES2_IVH + * =================================================================================================== + * Offset: 0x2A0 TDES/DES Initial Vector High Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES2_IVH; + + /** + * TDES2_IVL + * =================================================================================================== + * Offset: 0x2A4 TDES/DES Initial Vector Low Word Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES2_IVL; + + /** + * TDES2_SADDR + * =================================================================================================== + * Offset: 0x2A8 TDES/DES DMA Source Address Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |TDES/DES DMA Source Address + * | | |The TDES/DES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The TDES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the TDES/DES accelerator can read the plain text from system memory and do TDES/DES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_SADR are ignored. + * | | |TDES_SADR can be read and written. + * | | |Writing to TDES_SADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_SADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES2_SADDR; + + /** + * TDES2_DADDR + * =================================================================================================== + * Offset: 0x2AC TDES/DES DMA Destination Address Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |TDES/DES DMA Destination Address + * | | |The TDES/DES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The TDES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the TDES/DES accelerator can write the cipher text back to system memory after the TDES/DES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_DADR are ignored. + * | | |TDES_DADR can be read and written. + * | | |Writing to TDES_DADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_DADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES2_DADDR; + + /** + * TDES2_CNT + * =================================================================================================== + * Offset: 0x2B0 TDES/DES Byte Count Register for Channel 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |TDES/DES Byte Count + * | | |The TDES_CNT keeps the byte count of source text that is for the TDES/DES engine operating in DMA mode. + * | | |The TDES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |TDES_CNT can be read and written. + * | | |Writing to TDES_CNT while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next TDES /DES operation. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, TDES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + */ + __IO uint32_t TDES2_CNT; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE4[5]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TDES3_KEY1H + * =================================================================================================== + * Offset: 0x2C8 TDES/DES Key 1 High Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES3_KEY1H; + + /** + * TDES3_KEY1L + * =================================================================================================== + * Offset: 0x2CC TDES/DES Key 1 Low Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES3_KEY1L; + + /** + * TDES3_KEY2H + * =================================================================================================== + * Offset: 0x2D0 TDES Key 2 High Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES3_KEY2H; + + /** + * TDES3_KEY2L + * =================================================================================================== + * Offset: 0x2D4 TDES Key 2 Low Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES3_KEY2L; + + /** + * TDES3_KEY3H + * =================================================================================================== + * Offset: 0x2D8 TDES Key 3 High Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES3_KEY3H; + + /** + * TDES3_KEY3L + * =================================================================================================== + * Offset: 0x2DC TDES Key 3 Low Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYH_KEYL |TDES/DES Key X High/Low Word + * | | |The key registers for TDES/DES algorithm calculation + * | | |The security key for the TDES/DES accelerator is 64 bits. + * | | |Thus, it needs two 32-bit registers to store a security key. + * | | |The register TDES_KEYxH is used to keep the bit [63:32] of security key for the TDES/DES operation, while the register TDES_KEYxL is used to keep the bit [31:0]. + */ + __IO uint32_t TDES3_KEY3L; + + /** + * TDES3_IVH + * =================================================================================================== + * Offset: 0x2E0 TDES/DES Initial Vector High Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES3_IVH; + + /** + * TDES3_IVL + * =================================================================================================== + * Offset: 0x2E4 TDES/DES Initial Vector Low Word Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |IVH_IVL |TDES/DES Initial Vector High/Low Word + * | | |Initial vector (IV) is for TDES/DES engine in CBC, CFB, and OFB mode. + * | | |IV is Nonce counter for TDES/DES engine in CTR mode. + */ + __IO uint32_t TDES3_IVL; + + /** + * TDES3_SADDR + * =================================================================================================== + * Offset: 0x2E8 TDES/DES DMA Source Address Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |TDES/DES DMA Source Address + * | | |The TDES/DES accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The TDES_SADR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the TDES/DES accelerator can read the plain text from system memory and do TDES/DES operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_SADR are ignored. + * | | |TDES_SADR can be read and written. + * | | |Writing to TDES_SADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_SADR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_SADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES3_SADDR; + + /** + * TDES3_DADDR + * =================================================================================================== + * Offset: 0x2EC TDES/DES DMA Destination Address Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DADDR |TDES/DES DMA Destination Address + * | | |The TDES/DES accelerator supports DMA function to transfer the cipher text between system memory and embedded FIFO. + * | | |The TDES_DADR keeps the destination address of the data buffer where the engine output's text will be stored. + * | | |Based on the destination address, the TDES/DES accelerator can write the cipher text back to system memory after the TDES/DES operation is finished. + * | | |The start of destination address should be located at word boundary. + * | | |In other words, bit 1 and 0 of TDES_DADR are ignored. + * | | |TDES_DADR can be read and written. + * | | |Writing to TDES_DADR while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_DADR will be updated later on. + * | | |Consequently, software can prepare the destination address for the next TDES/DES operation. + * | | |In DMA mode, software can update the next TDES_DADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t TDES3_DADDR; + + /** + * TDES3_CNT + * =================================================================================================== + * Offset: 0x2F0 TDES/DES Byte Count Register for Channel 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CNT |TDES/DES Byte Count + * | | |The TDES_CNT keeps the byte count of source text that is for the TDES/DES engine operating in DMA mode. + * | | |The TDES_CNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |TDES_CNT can be read and written. + * | | |Writing to TDES_CNT while the TDES/DES accelerator is operating doesn't affect the current TDES/DES operation. + * | | |But the value of TDES_CNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next TDES /DES operation. + * | | |In Non-DMA ECB, CBC, CFB, OFB, and CTR mode, TDES_CNT must be set as byte count for the last block of data before feeding in the last block of data. + */ + __IO uint32_t TDES3_CNT; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE5[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SHA_CTL + * =================================================================================================== + * Offset: 0x300 SHA Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |START |SHA Engine Start + * | | |0 = No effect. + * | | |1 = Start SHA engine. BUSY flag will be set. + * | | |Note: This bit is always 0 when it's read back. + * |[1] |STOP |SHA Engine Stop + * | | |0 = No effect. + * | | |1 = Stop SHA engine. + * | | |Note: This bit is always 0 when it's read back. + * |[5] |DMALAST |SHA Last Block + * | | |In DMA mode, this bit must be set as beginning the last DMA cascade round. + * | | |In Non-DMA mode, this bit must be set as feeding in last byte of data. + * |[7] |DMAEN |SHA Engine DMA Enable Control + * | | |0 = SHA_DMA engine Disabled. + * | | |The SHA engine operates in Non-DMA mode, and gets data from the port CRPT_SHA_DATIN. + * | | |1 = SHA_DMA engine Enabled. + * | | |The SHA engine operates in DMA mode, and data movement from/to the engine is done by DMA logic. + * |[8:10] |OPMODE |SHA Engine Operation Modes + * | | |000 = SHA160. + * | | |100 = SHA256. + * | | |101 = SHA224. + * | | |Note: These bits can be read and written, but writing to them wouldn't take effect as BUSY is 1. + * |[22] |OUTSWAP |SHA Engine Output Data Swap + * | | |0 = Keep the original order. + * | | |1 = The order that CPU feeds data to the accelerator will be changed from {byte3, byte2, byte1, byte0} to {byte0, byte1, byte2, byte3}. + * |[23] |INSWAP |SHA Engine Input Data Swap + * | | |0 = Keep the original order. + * | | |1 = The order that CPU feeds data to the accelerator will be changed from {byte3, byte2, byte1, byte0} to {byte0, byte1, byte2, byte3}. + */ + __IO uint32_t SHA_CTL; + + /** + * SHA_STS + * =================================================================================================== + * Offset: 0x304 SHA Status Flag + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BUSY |SHA Engine Busy + * | | |0 = SHA engine is idle or finished. + * | | |1 = SHA engine is busy. + * |[1] |DMABUSY |SHA Engine DMA Busy Flag + * | | |0 = SHA DMA engine is idle or finished. + * | | |1 = SHA DMA engine is busy. + * |[8] |DMAERR |SHA Engine DMA Error Flag + * | | |0 = Show the SHA engine access normal. + * | | |1 = Show the SHA engine access error. + * |[16] |DATINREQ |SHA Non-DMA Mode Data Input Request + * | | |0 = No effect. + * | | |1 = Request SHA Non-DMA mode data input. + */ + __I uint32_t SHA_STS; + + /** + * SHA_DGST0 + * =================================================================================================== + * Offset: 0x308 SHA Digest Message 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST0; + + /** + * SHA_DGST1 + * =================================================================================================== + * Offset: 0x30C SHA Digest Message 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST1; + + /** + * SHA_DGST2 + * =================================================================================================== + * Offset: 0x310 SHA Digest Message 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST2; + + /** + * SHA_DGST3 + * =================================================================================================== + * Offset: 0x314 SHA Digest Message 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST3; + + /** + * SHA_DGST4 + * =================================================================================================== + * Offset: 0x318 SHA Digest Message 4 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST4; + + /** + * SHA_DGST5 + * =================================================================================================== + * Offset: 0x31C SHA Digest Message 5 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST5; + + /** + * SHA_DGST6 + * =================================================================================================== + * Offset: 0x320 SHA Digest Message 6 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST6; + + /** + * SHA_DGST7 + * =================================================================================================== + * Offset: 0x324 SHA Digest Message 7 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DGST |SHA Digest Message Word + * | | |For SHA-160, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST4. + * | | |For SHA-224, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST6. + * | | |For SHA-256, the digest is stored in CRPT_SHA_DGST0 ~ CRPT_SHA_DGST7. + */ + __I uint32_t SHA_DGST7; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE6[8]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SHA_KEYCNT + * =================================================================================================== + * Offset: 0x348 SHA Key Byte Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEYCNT |SHA Key Byte Count + * | | |The CRPT_SHA_KEYCNT keeps the byte count of key that SHA engine operates. + * | | |The register is 32-bit and the maximum byte count is 4G bytes. + * | | |It can be read and written. + * | | |Writing to the register CRPT_SHA_KEYCNT as the SHA accelerator operating doesn't affect the current SHA operation. + * | | |But the value of SHA _KEY_CNT will be updated later on. + * | | |Consequently, software can prepare the key count for the next SHA operation. + */ + __IO uint32_t SHA_KEYCNT; + + /** + * SHA_SADDR + * =================================================================================================== + * Offset: 0x34C SHA DMA Source Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SADDR |SHA DMA Source Address + * | | |The SHA accelerator supports DMA function to transfer the plain text between system memory and embedded FIFO. + * | | |The CRPT_SHA_SADDR keeps the source address of the data buffer where the source text is stored. + * | | |Based on the source address, the SHA accelerator can read the plain text from system memory and do SHA operation. + * | | |The start of source address should be located at word boundary. + * | | |In other words, bit 1 and 0 of CRPT_SHA_SADDR are ignored. + * | | |CRPT_SHA_SADDR can be read and written. + * | | |Writing to CRPT_SHA_SADDR while the SHA accelerator is operating doesn't affect the current SHA operation. + * | | |But the value of CRPT_SHA_SADDR will be updated later on. + * | | |Consequently, software can prepare the DMA source address for the next SHA operation. + * | | |In DMA mode, software can update the next TDES_SADR before triggering START. + * | | |TDES_SADR and TDES_DADR can be the same in the value. + */ + __IO uint32_t SHA_SADDR; + + /** + * SHA_DMACNT + * =================================================================================================== + * Offset: 0x350 SHA Byte Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DMACNT |SHA Operation Byte Count + * | | |The CRPT_SHA_DMACNT keeps the byte count of source text that is for the SHA engine operating in DMA mode. + * | | |The CRPT_SHA_DMACNT is 32-bit and the maximum of byte count is 4G bytes. + * | | |CRPT_SHA_DMACNT can be read and written. + * | | |Writing to CRPT_SHA_DMACNT while the SHA accelerator is operating doesn't affect the current SHA operation. + * | | |But the value of CRPT_SHA_DMACNT will be updated later on. + * | | |Consequently, software can prepare the byte count of data for the next SHA operation. + * | | |In Non-DMA mode, CRPT_SHA_DMACNT must be set as the byte count of the last block before feeding in the last block of data. + */ + __IO uint32_t SHA_DMACNT; + + /** + * SHA_DATIN + * =================================================================================================== + * Offset: 0x354 SHA Engine Non-DMA Mode Data Input Port Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DATIN |SHA Engine Input Port + * | | |CPU feeds data to SHA engine through this port by checking CRPT_SHA_STS. Feed data as DATINREQ is 1. + */ + __IO uint32_t SHA_DATIN; + +} CRPT_T; + +/** + @addtogroup CRPT_CONST CRPT Bit Field Definition + Constant Definitions for CRPT Controller +@{ */ + +#define CRPT_INTEN_AESIEN_Pos (0) /*!< CRPT_T::INTEN: AESIEN Position */ +#define CRPT_INTEN_AESIEN_Msk (0x1ul << CRPT_INTEN_AESIEN_Pos) /*!< CRPT_T::INTEN: AESIEN Mask */ + +#define CRPT_INTEN_AESERRIEN_Pos (1) /*!< CRPT_T::INTEN: AESERRIEN Position */ +#define CRPT_INTEN_AESERRIEN_Msk (0x1ul << CRPT_INTEN_AESERRIEN_Pos) /*!< CRPT_T::INTEN: AESERRIEN Mask */ + +#define CRPT_INTEN_TDESIEN_Pos (8) /*!< CRPT_T::INTEN: TDESIEN Position */ +#define CRPT_INTEN_TDESIEN_Msk (0x1ul << CRPT_INTEN_TDESIEN_Pos) /*!< CRPT_T::INTEN: TDESIEN Mask */ + +#define CRPT_INTEN_TDESERRIEN_Pos (9) /*!< CRPT_T::INTEN: TDESERRIEN Position */ +#define CRPT_INTEN_TDESERRIEN_Msk (0x1ul << CRPT_INTEN_TDESERRIEN_Pos) /*!< CRPT_T::INTEN: TDESERRIEN Mask */ + +#define CRPT_INTEN_PRNGIEN_Pos (16) /*!< CRPT_T::INTEN: PRNGIEN Position */ +#define CRPT_INTEN_PRNGIEN_Msk (0x1ul << CRPT_INTEN_PRNGIEN_Pos) /*!< CRPT_T::INTEN: PRNGIEN Mask */ + +#define CRPT_INTEN_SHAIEN_Pos (24) /*!< CRPT_T::INTEN: SHAIEN Position */ +#define CRPT_INTEN_SHAIEN_Msk (0x1ul << CRPT_INTEN_SHAIEN_Pos) /*!< CRPT_T::INTEN: SHAIEN Mask */ + +#define CRPT_INTEN_SHAERRIEN_Pos (25) /*!< CRPT_T::INTEN: SHAERRIEN Position */ +#define CRPT_INTEN_SHAERRIEN_Msk (0x1ul << CRPT_INTEN_SHAERRIEN_Pos) /*!< CRPT_T::INTEN: SHAERRIEN Mask */ + +#define CRPT_INTSTS_AESIF_Pos (0) /*!< CRPT_T::INTSTS: AESIF Position */ +#define CRPT_INTSTS_AESIF_Msk (0x1ul << CRPT_INTSTS_AESIF_Pos) /*!< CRPT_T::INTSTS: AESIF Mask */ + +#define CRPT_INTSTS_AESERRIF_Pos (1) /*!< CRPT_T::INTSTS: AESERRIF Position */ +#define CRPT_INTSTS_AESERRIF_Msk (0x1ul << CRPT_INTSTS_AESERRIF_Pos) /*!< CRPT_T::INTSTS: AESERRIF Mask */ + +#define CRPT_INTSTS_TDESIF_Pos (8) /*!< CRPT_T::INTSTS: TDESIF Position */ +#define CRPT_INTSTS_TDESIF_Msk (0x1ul << CRPT_INTSTS_TDESIF_Pos) /*!< CRPT_T::INTSTS: TDESIF Mask */ + +#define CRPT_INTSTS_TDESERRIF_Pos (9) /*!< CRPT_T::INTSTS: TDESERRIF Position */ +#define CRPT_INTSTS_TDESERRIF_Msk (0x1ul << CRPT_INTSTS_TDESERRIF_Pos) /*!< CRPT_T::INTSTS: TDESERRIF Mask */ + +#define CRPT_INTSTS_PRNGIF_Pos (16) /*!< CRPT_T::INTSTS: PRNGIF Position */ +#define CRPT_INTSTS_PRNGIF_Msk (0x1ul << CRPT_INTSTS_PRNGIF_Pos) /*!< CRPT_T::INTSTS: PRNGIF Mask */ + +#define CRPT_INTSTS_SHAIF_Pos (24) /*!< CRPT_T::INTSTS: SHAIF Position */ +#define CRPT_INTSTS_SHAIF_Msk (0x1ul << CRPT_INTSTS_SHAIF_Pos) /*!< CRPT_T::INTSTS: SHAIF Mask */ + +#define CRPT_INTSTS_SHAERRIF_Pos (25) /*!< CRPT_T::INTSTS: SHAERRIF Position */ +#define CRPT_INTSTS_SHAERRIF_Msk (0x1ul << CRPT_INTSTS_SHAERRIF_Pos) /*!< CRPT_T::INTSTS: SHAERRIF Mask */ + +#define CRPT_PRNG_CTL_START_Pos (0) /*!< CRPT_T::PRNG_CTL: START Position */ +#define CRPT_PRNG_CTL_START_Msk (0x1ul << CRPT_PRNG_CTL_START_Pos) /*!< CRPT_T::PRNG_CTL: START Mask */ + +#define CRPT_PRNG_CTL_SEEDRLD_Pos (1) /*!< CRPT_T::PRNG_CTL: SEEDRLD Position */ +#define CRPT_PRNG_CTL_SEEDRLD_Msk (0x1ul << CRPT_PRNG_CTL_SEEDRLD_Pos) /*!< CRPT_T::PRNG_CTL: SEEDRLD Mask */ + +#define CRPT_PRNG_CTL_KEYSZ_Pos (2) /*!< CRPT_T::PRNG_CTL: KEYSZ Position */ +#define CRPT_PRNG_CTL_KEYSZ_Msk (0x3ul << CRPT_PRNG_CTL_KEYSZ_Pos) /*!< CRPT_T::PRNG_CTL: KEYSZ Mask */ + +#define CRPT_PRNG_CTL_BUSY_Pos (8) /*!< CRPT_T::PRNG_CTL: BUSY Position */ +#define CRPT_PRNG_CTL_BUSY_Msk (0x1ul << CRPT_PRNG_CTL_BUSY_Pos) /*!< CRPT_T::PRNG_CTL: BUSY Mask */ + +#define CRPT_PRNG_SEED_SEED_Pos (0) /*!< CRPT_T::PRNG_SEED: SEED Position */ +#define CRPT_PRNG_SEED_SEED_Msk (0xfffffffful << CRPT_PRNG_SEED_SEED_Pos) /*!< CRPT_T::PRNG_SEED: SEED Mask */ + +#define CRPT_PRNG_KEY0_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY0: KEY Position */ +#define CRPT_PRNG_KEY0_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY0_KEY_Pos) /*!< CRPT_T::PRNG_KEY0: KEY Mask */ + +#define CRPT_PRNG_KEY1_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY1: KEY Position */ +#define CRPT_PRNG_KEY1_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY1_KEY_Pos) /*!< CRPT_T::PRNG_KEY1: KEY Mask */ + +#define CRPT_PRNG_KEY2_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY2: KEY Position */ +#define CRPT_PRNG_KEY2_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY2_KEY_Pos) /*!< CRPT_T::PRNG_KEY2: KEY Mask */ + +#define CRPT_PRNG_KEY3_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY3: KEY Position */ +#define CRPT_PRNG_KEY3_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY3_KEY_Pos) /*!< CRPT_T::PRNG_KEY3: KEY Mask */ + +#define CRPT_PRNG_KEY4_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY4: KEY Position */ +#define CRPT_PRNG_KEY4_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY4_KEY_Pos) /*!< CRPT_T::PRNG_KEY4: KEY Mask */ + +#define CRPT_PRNG_KEY5_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY5: KEY Position */ +#define CRPT_PRNG_KEY5_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY5_KEY_Pos) /*!< CRPT_T::PRNG_KEY5: KEY Mask */ + +#define CRPT_PRNG_KEY6_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY6: KEY Position */ +#define CRPT_PRNG_KEY6_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY6_KEY_Pos) /*!< CRPT_T::PRNG_KEY6: KEY Mask */ + +#define CRPT_PRNG_KEY7_KEY_Pos (0) /*!< CRPT_T::PRNG_KEY7: KEY Position */ +#define CRPT_PRNG_KEY7_KEY_Msk (0xfffffffful << CRPT_PRNG_KEY7_KEY_Pos) /*!< CRPT_T::PRNG_KEY7: KEY Mask */ + +#define CRPT_AES_FDBCK0_FDBCK_Pos (0) /*!< CRPT_T::AES_FDBCK0: FDBCK Position */ +#define CRPT_AES_FDBCK0_FDBCK_Msk (0xfffffffful << CRPT_AES_FDBCK0_FDBCK_Pos) /*!< CRPT_T::AES_FDBCK0: FDBCK Mask */ + +#define CRPT_AES_FDBCK1_FDBCK_Pos (0) /*!< CRPT_T::AES_FDBCK1: FDBCK Position */ +#define CRPT_AES_FDBCK1_FDBCK_Msk (0xfffffffful << CRPT_AES_FDBCK1_FDBCK_Pos) /*!< CRPT_T::AES_FDBCK1: FDBCK Mask */ + +#define CRPT_AES_FDBCK2_FDBCK_Pos (0) /*!< CRPT_T::AES_FDBCK2: FDBCK Position */ +#define CRPT_AES_FDBCK2_FDBCK_Msk (0xfffffffful << CRPT_AES_FDBCK2_FDBCK_Pos) /*!< CRPT_T::AES_FDBCK2: FDBCK Mask */ + +#define CRPT_AES_FDBCK3_FDBCK_Pos (0) /*!< CRPT_T::AES_FDBCK3: FDBCK Position */ +#define CRPT_AES_FDBCK3_FDBCK_Msk (0xfffffffful << CRPT_AES_FDBCK3_FDBCK_Pos) /*!< CRPT_T::AES_FDBCK3: FDBCK Mask */ + +#define CRPT_TDES_FDBCKH_FDBCK_Pos (0) /*!< CRPT_T::TDES_FDBCKH: FDBCK Position */ +#define CRPT_TDES_FDBCKH_FDBCK_Msk (0xfffffffful << CRPT_TDES_FDBCKH_FDBCK_Pos) /*!< CRPT_T::TDES_FDBCKH: FDBCK Mask */ + +#define CRPT_TDES_FDBCKL_FDBCK_Pos (0) /*!< CRPT_T::TDES_FDBCKL: FDBCK Position */ +#define CRPT_TDES_FDBCKL_FDBCK_Msk (0xfffffffful << CRPT_TDES_FDBCKL_FDBCK_Pos) /*!< CRPT_T::TDES_FDBCKL: FDBCK Mask */ + +#define CRPT_AES_CTL_START_Pos (0) /*!< CRPT_T::AES_CTL: START Position */ +#define CRPT_AES_CTL_START_Msk (0x1ul << CRPT_AES_CTL_START_Pos) /*!< CRPT_T::AES_CTL: START Mask */ + +#define CRPT_AES_CTL_STOP_Pos (1) /*!< CRPT_T::AES_CTL: STOP Position */ +#define CRPT_AES_CTL_STOP_Msk (0x1ul << CRPT_AES_CTL_STOP_Pos) /*!< CRPT_T::AES_CTL: STOP Mask */ + +#define CRPT_AES_CTL_KEYSZ_Pos (2) /*!< CRPT_T::AES_CTL: KEYSZ Position */ +#define CRPT_AES_CTL_KEYSZ_Msk (0x3ul << CRPT_AES_CTL_KEYSZ_Pos) /*!< CRPT_T::AES_CTL: KEYSZ Mask */ + +#define CRPT_AES_CTL_DMALAST_Pos (5) /*!< CRPT_T::AES_CTL: DMALAST Position */ +#define CRPT_AES_CTL_DMALAST_Msk (0x1ul << CRPT_AES_CTL_DMALAST_Pos) /*!< CRPT_T::AES_CTL: DMALAST Mask */ + +#define CRPT_AES_CTL_DMACSCAD_Pos (6) /*!< CRPT_T::AES_CTL: DMACSCAD Position */ +#define CRPT_AES_CTL_DMACSCAD_Msk (0x1ul << CRPT_AES_CTL_DMACSCAD_Pos) /*!< CRPT_T::AES_CTL: DMACSCAD Mask */ + +#define CRPT_AES_CTL_DMAEN_Pos (7) /*!< CRPT_T::AES_CTL: DMAEN Position */ +#define CRPT_AES_CTL_DMAEN_Msk (0x1ul << CRPT_AES_CTL_DMAEN_Pos) /*!< CRPT_T::AES_CTL: DMAEN Mask */ + +#define CRPT_AES_CTL_OPMODE_Pos (8) /*!< CRPT_T::AES_CTL: OPMODE Position */ +#define CRPT_AES_CTL_OPMODE_Msk (0xfful << CRPT_AES_CTL_OPMODE_Pos) /*!< CRPT_T::AES_CTL: OPMODE Mask */ + +#define CRPT_AES_CTL_ENCRPT_Pos (16) /*!< CRPT_T::AES_CTL: ENCRPT Position */ +#define CRPT_AES_CTL_ENCRPT_Msk (0x1ul << CRPT_AES_CTL_ENCRPT_Pos) /*!< CRPT_T::AES_CTL: ENCRPT Mask */ + +#define CRPT_AES_CTL_OUTSWAP_Pos (22) /*!< CRPT_T::AES_CTL: OUTSWAP Position */ +#define CRPT_AES_CTL_OUTSWAP_Msk (0x1ul << CRPT_AES_CTL_OUTSWAP_Pos) /*!< CRPT_T::AES_CTL: OUTSWAP Mask */ + +#define CRPT_AES_CTL_INSWAP_Pos (23) /*!< CRPT_T::AES_CTL: INSWAP Position */ +#define CRPT_AES_CTL_INSWAP_Msk (0x1ul << CRPT_AES_CTL_INSWAP_Pos) /*!< CRPT_T::AES_CTL: INSWAP Mask */ + +#define CRPT_AES_CTL_CHANNEL_Pos (24) /*!< CRPT_T::AES_CTL: CHANNEL Position */ +#define CRPT_AES_CTL_CHANNEL_Msk (0x3ul << CRPT_AES_CTL_CHANNEL_Pos) /*!< CRPT_T::AES_CTL: CHANNEL Mask */ + +#define CRPT_AES_CTL_KEYUNPRT_Pos (26) /*!< CRPT_T::AES_CTL: KEYUNPRT Position */ +#define CRPT_AES_CTL_KEYUNPRT_Msk (0x1ful << CRPT_AES_CTL_KEYUNPRT_Pos) /*!< CRPT_T::AES_CTL: KEYUNPRT Mask */ + +#define CRPT_AES_CTL_KEYPRT_Pos (31) /*!< CRPT_T::AES_CTL: KEYPRT Position */ +#define CRPT_AES_CTL_KEYPRT_Msk (0x1ul << CRPT_AES_CTL_KEYPRT_Pos) /*!< CRPT_T::AES_CTL: KEYPRT Mask */ + +#define CRPT_AES_STS_BUSY_Pos (0) /*!< CRPT_T::AES_STS: BUSY Position */ +#define CRPT_AES_STS_BUSY_Msk (0x1ul << CRPT_AES_STS_BUSY_Pos) /*!< CRPT_T::AES_STS: BUSY Mask */ + +#define CRPT_AES_STS_INBUFEMPTY_Pos (8) /*!< CRPT_T::AES_STS: INBUFEMPTY Position */ +#define CRPT_AES_STS_INBUFEMPTY_Msk (0x1ul << CRPT_AES_STS_INBUFEMPTY_Pos) /*!< CRPT_T::AES_STS: INBUFEMPTY Mask */ + +#define CRPT_AES_STS_INBUFFULL_Pos (9) /*!< CRPT_T::AES_STS: INBUFFULL Position */ +#define CRPT_AES_STS_INBUFFULL_Msk (0x1ul << CRPT_AES_STS_INBUFFULL_Pos) /*!< CRPT_T::AES_STS: INBUFFULL Mask */ + +#define CRPT_AES_STS_INBUFERR_Pos (10) /*!< CRPT_T::AES_STS: INBUFERR Position */ +#define CRPT_AES_STS_INBUFERR_Msk (0x1ul << CRPT_AES_STS_INBUFERR_Pos) /*!< CRPT_T::AES_STS: INBUFERR Mask */ + +#define CRPT_AES_STS_CNTERR_Pos (12) /*!< CRPT_T::AES_STS: CNTERR Position */ +#define CRPT_AES_STS_CNTERR_Msk (0x1ul << CRPT_AES_STS_CNTERR_Pos) /*!< CRPT_T::AES_STS: CNTERR Mask */ + +#define CRPT_AES_STS_OUTBUFEMPTY_Pos (16) /*!< CRPT_T::AES_STS: OUTBUFEMPTY Position */ +#define CRPT_AES_STS_OUTBUFEMPTY_Msk (0x1ul << CRPT_AES_STS_OUTBUFEMPTY_Pos) /*!< CRPT_T::AES_STS: OUTBUFEMPTY Mask */ + +#define CRPT_AES_STS_OUTBUFFULL_Pos (17) /*!< CRPT_T::AES_STS: OUTBUFFULL Position */ +#define CRPT_AES_STS_OUTBUFFULL_Msk (0x1ul << CRPT_AES_STS_OUTBUFFULL_Pos) /*!< CRPT_T::AES_STS: OUTBUFFULL Mask */ + +#define CRPT_AES_STS_OUTBUFERR_Pos (18) /*!< CRPT_T::AES_STS: OUTBUFERR Position */ +#define CRPT_AES_STS_OUTBUFERR_Msk (0x1ul << CRPT_AES_STS_OUTBUFERR_Pos) /*!< CRPT_T::AES_STS: OUTBUFERR Mask */ + +#define CRPT_AES_STS_BUSERR_Pos (20) /*!< CRPT_T::AES_STS: BUSERR Position */ +#define CRPT_AES_STS_BUSERR_Msk (0x1ul << CRPT_AES_STS_BUSERR_Pos) /*!< CRPT_T::AES_STS: BUSERR Mask */ + +#define CRPT_AES_DATIN_DATIN_Pos (0) /*!< CRPT_T::AES_DATIN: DATIN Position */ +#define CRPT_AES_DATIN_DATIN_Msk (0xfffffffful << CRPT_AES_DATIN_DATIN_Pos) /*!< CRPT_T::AES_DATIN: DATIN Mask */ + +#define CRPT_AES_DATOUT_DATOUT_Pos (0) /*!< CRPT_T::AES_DATOUT: DATOUT Position */ +#define CRPT_AES_DATOUT_DATOUT_Msk (0xfffffffful << CRPT_AES_DATOUT_DATOUT_Pos) /*!< CRPT_T::AES_DATOUT: DATOUT Mask */ + +#define CRPT_AES0_KEY0_KEY_Pos (0) /*!< CRPT_T::AES0_KEY0: KEY Position */ +#define CRPT_AES0_KEY0_KEY_Msk (0xfffffffful << CRPT_AES0_KEY0_KEY_Pos) /*!< CRPT_T::AES0_KEY0: KEY Mask */ + +#define CRPT_AES0_KEY1_KEY_Pos (0) /*!< CRPT_T::AES0_KEY1: KEY Position */ +#define CRPT_AES0_KEY1_KEY_Msk (0xfffffffful << CRPT_AES0_KEY1_KEY_Pos) /*!< CRPT_T::AES0_KEY1: KEY Mask */ + +#define CRPT_AES0_KEY2_KEY_Pos (0) /*!< CRPT_T::AES0_KEY2: KEY Position */ +#define CRPT_AES0_KEY2_KEY_Msk (0xfffffffful << CRPT_AES0_KEY2_KEY_Pos) /*!< CRPT_T::AES0_KEY2: KEY Mask */ + +#define CRPT_AES0_KEY3_KEY_Pos (0) /*!< CRPT_T::AES0_KEY3: KEY Position */ +#define CRPT_AES0_KEY3_KEY_Msk (0xfffffffful << CRPT_AES0_KEY3_KEY_Pos) /*!< CRPT_T::AES0_KEY3: KEY Mask */ + +#define CRPT_AES0_KEY4_KEY_Pos (0) /*!< CRPT_T::AES0_KEY4: KEY Position */ +#define CRPT_AES0_KEY4_KEY_Msk (0xfffffffful << CRPT_AES0_KEY4_KEY_Pos) /*!< CRPT_T::AES0_KEY4: KEY Mask */ + +#define CRPT_AES0_KEY5_KEY_Pos (0) /*!< CRPT_T::AES0_KEY5: KEY Position */ +#define CRPT_AES0_KEY5_KEY_Msk (0xfffffffful << CRPT_AES0_KEY5_KEY_Pos) /*!< CRPT_T::AES0_KEY5: KEY Mask */ + +#define CRPT_AES0_KEY6_KEY_Pos (0) /*!< CRPT_T::AES0_KEY6: KEY Position */ +#define CRPT_AES0_KEY6_KEY_Msk (0xfffffffful << CRPT_AES0_KEY6_KEY_Pos) /*!< CRPT_T::AES0_KEY6: KEY Mask */ + +#define CRPT_AES0_KEY7_KEY_Pos (0) /*!< CRPT_T::AES0_KEY7: KEY Position */ +#define CRPT_AES0_KEY7_KEY_Msk (0xfffffffful << CRPT_AES0_KEY7_KEY_Pos) /*!< CRPT_T::AES0_KEY7: KEY Mask */ + +#define CRPT_AES0_IV0_IV_Pos (0) /*!< CRPT_T::AES0_IV0: IV Position */ +#define CRPT_AES0_IV0_IV_Msk (0xfffffffful << CRPT_AES0_IV0_IV_Pos) /*!< CRPT_T::AES0_IV0: IV Mask */ + +#define CRPT_AES0_IV1_IV_Pos (0) /*!< CRPT_T::AES0_IV1: IV Position */ +#define CRPT_AES0_IV1_IV_Msk (0xfffffffful << CRPT_AES0_IV1_IV_Pos) /*!< CRPT_T::AES0_IV1: IV Mask */ + +#define CRPT_AES0_IV2_IV_Pos (0) /*!< CRPT_T::AES0_IV2: IV Position */ +#define CRPT_AES0_IV2_IV_Msk (0xfffffffful << CRPT_AES0_IV2_IV_Pos) /*!< CRPT_T::AES0_IV2: IV Mask */ + +#define CRPT_AES0_IV3_IV_Pos (0) /*!< CRPT_T::AES0_IV3: IV Position */ +#define CRPT_AES0_IV3_IV_Msk (0xfffffffful << CRPT_AES0_IV3_IV_Pos) /*!< CRPT_T::AES0_IV3: IV Mask */ + +#define CRPT_AES0_SADDR_SADDR_Pos (0) /*!< CRPT_T::AES0_SADDR: SADDR Position */ +#define CRPT_AES0_SADDR_SADDR_Msk (0xfffffffful << CRPT_AES0_SADDR_SADDR_Pos) /*!< CRPT_T::AES0_SADDR: SADDR Mask */ + +#define CRPT_AES0_DADDR_DADDR_Pos (0) /*!< CRPT_T::AES0_DADDR: DADDR Position */ +#define CRPT_AES0_DADDR_DADDR_Msk (0xfffffffful << CRPT_AES0_DADDR_DADDR_Pos) /*!< CRPT_T::AES0_DADDR: DADDR Mask */ + +#define CRPT_AES0_CNT_CNT_Pos (0) /*!< CRPT_T::AES0_CNT: CNT Position */ +#define CRPT_AES0_CNT_CNT_Msk (0xfffffffful << CRPT_AES0_CNT_CNT_Pos) /*!< CRPT_T::AES0_CNT: CNT Mask */ + +#define CRPT_AES1_KEY0_KEY_Pos (0) /*!< CRPT_T::AES1_KEY0: KEY Position */ +#define CRPT_AES1_KEY0_KEY_Msk (0xfffffffful << CRPT_AES1_KEY0_KEY_Pos) /*!< CRPT_T::AES1_KEY0: KEY Mask */ + +#define CRPT_AES1_KEY1_KEY_Pos (0) /*!< CRPT_T::AES1_KEY1: KEY Position */ +#define CRPT_AES1_KEY1_KEY_Msk (0xfffffffful << CRPT_AES1_KEY1_KEY_Pos) /*!< CRPT_T::AES1_KEY1: KEY Mask */ + +#define CRPT_AES1_KEY2_KEY_Pos (0) /*!< CRPT_T::AES1_KEY2: KEY Position */ +#define CRPT_AES1_KEY2_KEY_Msk (0xfffffffful << CRPT_AES1_KEY2_KEY_Pos) /*!< CRPT_T::AES1_KEY2: KEY Mask */ + +#define CRPT_AES1_KEY3_KEY_Pos (0) /*!< CRPT_T::AES1_KEY3: KEY Position */ +#define CRPT_AES1_KEY3_KEY_Msk (0xfffffffful << CRPT_AES1_KEY3_KEY_Pos) /*!< CRPT_T::AES1_KEY3: KEY Mask */ + +#define CRPT_AES1_KEY4_KEY_Pos (0) /*!< CRPT_T::AES1_KEY4: KEY Position */ +#define CRPT_AES1_KEY4_KEY_Msk (0xfffffffful << CRPT_AES1_KEY4_KEY_Pos) /*!< CRPT_T::AES1_KEY4: KEY Mask */ + +#define CRPT_AES1_KEY5_KEY_Pos (0) /*!< CRPT_T::AES1_KEY5: KEY Position */ +#define CRPT_AES1_KEY5_KEY_Msk (0xfffffffful << CRPT_AES1_KEY5_KEY_Pos) /*!< CRPT_T::AES1_KEY5: KEY Mask */ + +#define CRPT_AES1_KEY6_KEY_Pos (0) /*!< CRPT_T::AES1_KEY6: KEY Position */ +#define CRPT_AES1_KEY6_KEY_Msk (0xfffffffful << CRPT_AES1_KEY6_KEY_Pos) /*!< CRPT_T::AES1_KEY6: KEY Mask */ + +#define CRPT_AES1_KEY7_KEY_Pos (0) /*!< CRPT_T::AES1_KEY7: KEY Position */ +#define CRPT_AES1_KEY7_KEY_Msk (0xfffffffful << CRPT_AES1_KEY7_KEY_Pos) /*!< CRPT_T::AES1_KEY7: KEY Mask */ + +#define CRPT_AES1_IV0_IV_Pos (0) /*!< CRPT_T::AES1_IV0: IV Position */ +#define CRPT_AES1_IV0_IV_Msk (0xfffffffful << CRPT_AES1_IV0_IV_Pos) /*!< CRPT_T::AES1_IV0: IV Mask */ + +#define CRPT_AES1_IV1_IV_Pos (0) /*!< CRPT_T::AES1_IV1: IV Position */ +#define CRPT_AES1_IV1_IV_Msk (0xfffffffful << CRPT_AES1_IV1_IV_Pos) /*!< CRPT_T::AES1_IV1: IV Mask */ + +#define CRPT_AES1_IV2_IV_Pos (0) /*!< CRPT_T::AES1_IV2: IV Position */ +#define CRPT_AES1_IV2_IV_Msk (0xfffffffful << CRPT_AES1_IV2_IV_Pos) /*!< CRPT_T::AES1_IV2: IV Mask */ + +#define CRPT_AES1_IV3_IV_Pos (0) /*!< CRPT_T::AES1_IV3: IV Position */ +#define CRPT_AES1_IV3_IV_Msk (0xfffffffful << CRPT_AES1_IV3_IV_Pos) /*!< CRPT_T::AES1_IV3: IV Mask */ + +#define CRPT_AES1_SADDR_SADDR_Pos (0) /*!< CRPT_T::AES1_SADDR: SADDR Position */ +#define CRPT_AES1_SADDR_SADDR_Msk (0xfffffffful << CRPT_AES1_SADDR_SADDR_Pos) /*!< CRPT_T::AES1_SADDR: SADDR Mask */ + +#define CRPT_AES1_DADDR_DADDR_Pos (0) /*!< CRPT_T::AES1_DADDR: DADDR Position */ +#define CRPT_AES1_DADDR_DADDR_Msk (0xfffffffful << CRPT_AES1_DADDR_DADDR_Pos) /*!< CRPT_T::AES1_DADDR: DADDR Mask */ + +#define CRPT_AES1_CNT_CNT_Pos (0) /*!< CRPT_T::AES1_CNT: CNT Position */ +#define CRPT_AES1_CNT_CNT_Msk (0xfffffffful << CRPT_AES1_CNT_CNT_Pos) /*!< CRPT_T::AES1_CNT: CNT Mask */ + +#define CRPT_AES2_KEY0_KEY_Pos (0) /*!< CRPT_T::AES2_KEY0: KEY Position */ +#define CRPT_AES2_KEY0_KEY_Msk (0xfffffffful << CRPT_AES2_KEY0_KEY_Pos) /*!< CRPT_T::AES2_KEY0: KEY Mask */ + +#define CRPT_AES2_KEY1_KEY_Pos (0) /*!< CRPT_T::AES2_KEY1: KEY Position */ +#define CRPT_AES2_KEY1_KEY_Msk (0xfffffffful << CRPT_AES2_KEY1_KEY_Pos) /*!< CRPT_T::AES2_KEY1: KEY Mask */ + +#define CRPT_AES2_KEY2_KEY_Pos (0) /*!< CRPT_T::AES2_KEY2: KEY Position */ +#define CRPT_AES2_KEY2_KEY_Msk (0xfffffffful << CRPT_AES2_KEY2_KEY_Pos) /*!< CRPT_T::AES2_KEY2: KEY Mask */ + +#define CRPT_AES2_KEY3_KEY_Pos (0) /*!< CRPT_T::AES2_KEY3: KEY Position */ +#define CRPT_AES2_KEY3_KEY_Msk (0xfffffffful << CRPT_AES2_KEY3_KEY_Pos) /*!< CRPT_T::AES2_KEY3: KEY Mask */ + +#define CRPT_AES2_KEY4_KEY_Pos (0) /*!< CRPT_T::AES2_KEY4: KEY Position */ +#define CRPT_AES2_KEY4_KEY_Msk (0xfffffffful << CRPT_AES2_KEY4_KEY_Pos) /*!< CRPT_T::AES2_KEY4: KEY Mask */ + +#define CRPT_AES2_KEY5_KEY_Pos (0) /*!< CRPT_T::AES2_KEY5: KEY Position */ +#define CRPT_AES2_KEY5_KEY_Msk (0xfffffffful << CRPT_AES2_KEY5_KEY_Pos) /*!< CRPT_T::AES2_KEY5: KEY Mask */ + +#define CRPT_AES2_KEY6_KEY_Pos (0) /*!< CRPT_T::AES2_KEY6: KEY Position */ +#define CRPT_AES2_KEY6_KEY_Msk (0xfffffffful << CRPT_AES2_KEY6_KEY_Pos) /*!< CRPT_T::AES2_KEY6: KEY Mask */ + +#define CRPT_AES2_KEY7_KEY_Pos (0) /*!< CRPT_T::AES2_KEY7: KEY Position */ +#define CRPT_AES2_KEY7_KEY_Msk (0xfffffffful << CRPT_AES2_KEY7_KEY_Pos) /*!< CRPT_T::AES2_KEY7: KEY Mask */ + +#define CRPT_AES2_IV0_IV_Pos (0) /*!< CRPT_T::AES2_IV0: IV Position */ +#define CRPT_AES2_IV0_IV_Msk (0xfffffffful << CRPT_AES2_IV0_IV_Pos) /*!< CRPT_T::AES2_IV0: IV Mask */ + +#define CRPT_AES2_IV1_IV_Pos (0) /*!< CRPT_T::AES2_IV1: IV Position */ +#define CRPT_AES2_IV1_IV_Msk (0xfffffffful << CRPT_AES2_IV1_IV_Pos) /*!< CRPT_T::AES2_IV1: IV Mask */ + +#define CRPT_AES2_IV2_IV_Pos (0) /*!< CRPT_T::AES2_IV2: IV Position */ +#define CRPT_AES2_IV2_IV_Msk (0xfffffffful << CRPT_AES2_IV2_IV_Pos) /*!< CRPT_T::AES2_IV2: IV Mask */ + +#define CRPT_AES2_IV3_IV_Pos (0) /*!< CRPT_T::AES2_IV3: IV Position */ +#define CRPT_AES2_IV3_IV_Msk (0xfffffffful << CRPT_AES2_IV3_IV_Pos) /*!< CRPT_T::AES2_IV3: IV Mask */ + +#define CRPT_AES2_SADDR_SADDR_Pos (0) /*!< CRPT_T::AES2_SADDR: SADDR Position */ +#define CRPT_AES2_SADDR_SADDR_Msk (0xfffffffful << CRPT_AES2_SADDR_SADDR_Pos) /*!< CRPT_T::AES2_SADDR: SADDR Mask */ + +#define CRPT_AES2_DADDR_DADDR_Pos (0) /*!< CRPT_T::AES2_DADDR: DADDR Position */ +#define CRPT_AES2_DADDR_DADDR_Msk (0xfffffffful << CRPT_AES2_DADDR_DADDR_Pos) /*!< CRPT_T::AES2_DADDR: DADDR Mask */ + +#define CRPT_AES2_CNT_CNT_Pos (0) /*!< CRPT_T::AES2_CNT: CNT Position */ +#define CRPT_AES2_CNT_CNT_Msk (0xfffffffful << CRPT_AES2_CNT_CNT_Pos) /*!< CRPT_T::AES2_CNT: CNT Mask */ + +#define CRPT_AES3_KEY0_KEY_Pos (0) /*!< CRPT_T::AES3_KEY0: KEY Position */ +#define CRPT_AES3_KEY0_KEY_Msk (0xfffffffful << CRPT_AES3_KEY0_KEY_Pos) /*!< CRPT_T::AES3_KEY0: KEY Mask */ + +#define CRPT_AES3_KEY1_KEY_Pos (0) /*!< CRPT_T::AES3_KEY1: KEY Position */ +#define CRPT_AES3_KEY1_KEY_Msk (0xfffffffful << CRPT_AES3_KEY1_KEY_Pos) /*!< CRPT_T::AES3_KEY1: KEY Mask */ + +#define CRPT_AES3_KEY2_KEY_Pos (0) /*!< CRPT_T::AES3_KEY2: KEY Position */ +#define CRPT_AES3_KEY2_KEY_Msk (0xfffffffful << CRPT_AES3_KEY2_KEY_Pos) /*!< CRPT_T::AES3_KEY2: KEY Mask */ + +#define CRPT_AES3_KEY3_KEY_Pos (0) /*!< CRPT_T::AES3_KEY3: KEY Position */ +#define CRPT_AES3_KEY3_KEY_Msk (0xfffffffful << CRPT_AES3_KEY3_KEY_Pos) /*!< CRPT_T::AES3_KEY3: KEY Mask */ + +#define CRPT_AES3_KEY4_KEY_Pos (0) /*!< CRPT_T::AES3_KEY4: KEY Position */ +#define CRPT_AES3_KEY4_KEY_Msk (0xfffffffful << CRPT_AES3_KEY4_KEY_Pos) /*!< CRPT_T::AES3_KEY4: KEY Mask */ + +#define CRPT_AES3_KEY5_KEY_Pos (0) /*!< CRPT_T::AES3_KEY5: KEY Position */ +#define CRPT_AES3_KEY5_KEY_Msk (0xfffffffful << CRPT_AES3_KEY5_KEY_Pos) /*!< CRPT_T::AES3_KEY5: KEY Mask */ + +#define CRPT_AES3_KEY6_KEY_Pos (0) /*!< CRPT_T::AES3_KEY6: KEY Position */ +#define CRPT_AES3_KEY6_KEY_Msk (0xfffffffful << CRPT_AES3_KEY6_KEY_Pos) /*!< CRPT_T::AES3_KEY6: KEY Mask */ + +#define CRPT_AES3_KEY7_KEY_Pos (0) /*!< CRPT_T::AES3_KEY7: KEY Position */ +#define CRPT_AES3_KEY7_KEY_Msk (0xfffffffful << CRPT_AES3_KEY7_KEY_Pos) /*!< CRPT_T::AES3_KEY7: KEY Mask */ + +#define CRPT_AES3_IV0_IV_Pos (0) /*!< CRPT_T::AES3_IV0: IV Position */ +#define CRPT_AES3_IV0_IV_Msk (0xfffffffful << CRPT_AES3_IV0_IV_Pos) /*!< CRPT_T::AES3_IV0: IV Mask */ + +#define CRPT_AES3_IV1_IV_Pos (0) /*!< CRPT_T::AES3_IV1: IV Position */ +#define CRPT_AES3_IV1_IV_Msk (0xfffffffful << CRPT_AES3_IV1_IV_Pos) /*!< CRPT_T::AES3_IV1: IV Mask */ + +#define CRPT_AES3_IV2_IV_Pos (0) /*!< CRPT_T::AES3_IV2: IV Position */ +#define CRPT_AES3_IV2_IV_Msk (0xfffffffful << CRPT_AES3_IV2_IV_Pos) /*!< CRPT_T::AES3_IV2: IV Mask */ + +#define CRPT_AES3_IV3_IV_Pos (0) /*!< CRPT_T::AES3_IV3: IV Position */ +#define CRPT_AES3_IV3_IV_Msk (0xfffffffful << CRPT_AES3_IV3_IV_Pos) /*!< CRPT_T::AES3_IV3: IV Mask */ + +#define CRPT_AES3_SADDR_SADDR_Pos (0) /*!< CRPT_T::AES3_SADDR: SADDR Position */ +#define CRPT_AES3_SADDR_SADDR_Msk (0xfffffffful << CRPT_AES3_SADDR_SADDR_Pos) /*!< CRPT_T::AES3_SADDR: SADDR Mask */ + +#define CRPT_AES3_DADDR_DADDR_Pos (0) /*!< CRPT_T::AES3_DADDR: DADDR Position */ +#define CRPT_AES3_DADDR_DADDR_Msk (0xfffffffful << CRPT_AES3_DADDR_DADDR_Pos) /*!< CRPT_T::AES3_DADDR: DADDR Mask */ + +#define CRPT_AES3_CNT_CNT_Pos (0) /*!< CRPT_T::AES3_CNT: CNT Position */ +#define CRPT_AES3_CNT_CNT_Msk (0xfffffffful << CRPT_AES3_CNT_CNT_Pos) /*!< CRPT_T::AES3_CNT: CNT Mask */ + +#define CRPT_TDES_CTL_START_Pos (0) /*!< CRPT_T::TDES_CTL: START Position */ +#define CRPT_TDES_CTL_START_Msk (0x1ul << CRPT_TDES_CTL_START_Pos) /*!< CRPT_T::TDES_CTL: START Mask */ + +#define CRPT_TDES_CTL_STOP_Pos (1) /*!< CRPT_T::TDES_CTL: STOP Position */ +#define CRPT_TDES_CTL_STOP_Msk (0x1ul << CRPT_TDES_CTL_STOP_Pos) /*!< CRPT_T::TDES_CTL: STOP Mask */ + +#define CRPT_TDES_CTL_TMODE_Pos (2) /*!< CRPT_T::TDES_CTL: TMODE Position */ +#define CRPT_TDES_CTL_TMODE_Msk (0x1ul << CRPT_TDES_CTL_TMODE_Pos) /*!< CRPT_T::TDES_CTL: TMODE Mask */ + +#define CRPT_TDES_CTL_3KEYS_Pos (3) /*!< CRPT_T::TDES_CTL: 3KEYS Position */ +#define CRPT_TDES_CTL_3KEYS_Msk (0x1ul << CRPT_TDES_CTL_3KEYS_Pos) /*!< CRPT_T::TDES_CTL: 3KEYS Mask */ + +#define CRPT_TDES_CTL_DMALAST_Pos (5) /*!< CRPT_T::TDES_CTL: DMALAST Position */ +#define CRPT_TDES_CTL_DMALAST_Msk (0x1ul << CRPT_TDES_CTL_DMALAST_Pos) /*!< CRPT_T::TDES_CTL: DMALAST Mask */ + +#define CRPT_TDES_CTL_DMACSCAD_Pos (6) /*!< CRPT_T::TDES_CTL: DMACSCAD Position */ +#define CRPT_TDES_CTL_DMACSCAD_Msk (0x1ul << CRPT_TDES_CTL_DMACSCAD_Pos) /*!< CRPT_T::TDES_CTL: DMACSCAD Mask */ + +#define CRPT_TDES_CTL_DMAEN_Pos (7) /*!< CRPT_T::TDES_CTL: DMAEN Position */ +#define CRPT_TDES_CTL_DMAEN_Msk (0x1ul << CRPT_TDES_CTL_DMAEN_Pos) /*!< CRPT_T::TDES_CTL: DMAEN Mask */ + +#define CRPT_TDES_CTL_OPMODE_Pos (8) /*!< CRPT_T::TDES_CTL: OPMODE Position */ +#define CRPT_TDES_CTL_OPMODE_Msk (0x7ul << CRPT_TDES_CTL_OPMODE_Pos) /*!< CRPT_T::TDES_CTL: OPMODE Mask */ + +#define CRPT_TDES_CTL_ENCRPT_Pos (16) /*!< CRPT_T::TDES_CTL: ENCRPT Position */ +#define CRPT_TDES_CTL_ENCRPT_Msk (0x1ul << CRPT_TDES_CTL_ENCRPT_Pos) /*!< CRPT_T::TDES_CTL: ENCRPT Mask */ + +#define CRPT_TDES_CTL_BLKSWAP_Pos (21) /*!< CRPT_T::TDES_CTL: BLKSWAP Position */ +#define CRPT_TDES_CTL_BLKSWAP_Msk (0x1ul << CRPT_TDES_CTL_BLKSWAP_Pos) /*!< CRPT_T::TDES_CTL: BLKSWAP Mask */ + +#define CRPT_TDES_CTL_OUTSWAP_Pos (22) /*!< CRPT_T::TDES_CTL: OUTSWAP Position */ +#define CRPT_TDES_CTL_OUTSWAP_Msk (0x1ul << CRPT_TDES_CTL_OUTSWAP_Pos) /*!< CRPT_T::TDES_CTL: OUTSWAP Mask */ + +#define CRPT_TDES_CTL_INSWAP_Pos (23) /*!< CRPT_T::TDES_CTL: INSWAP Position */ +#define CRPT_TDES_CTL_INSWAP_Msk (0x1ul << CRPT_TDES_CTL_INSWAP_Pos) /*!< CRPT_T::TDES_CTL: INSWAP Mask */ + +#define CRPT_TDES_CTL_CHANNEL_Pos (24) /*!< CRPT_T::TDES_CTL: CHANNEL Position */ +#define CRPT_TDES_CTL_CHANNEL_Msk (0x3ul << CRPT_TDES_CTL_CHANNEL_Pos) /*!< CRPT_T::TDES_CTL: CHANNEL Mask */ + +#define CRPT_TDES_CTL_KEYUNPRT_Pos (26) /*!< CRPT_T::TDES_CTL: KEYUNPRT Position */ +#define CRPT_TDES_CTL_KEYUNPRT_Msk (0x1ful << CRPT_TDES_CTL_KEYUNPRT_Pos) /*!< CRPT_T::TDES_CTL: KEYUNPRT Mask */ + +#define CRPT_TDES_CTL_KEYPRT_Pos (31) /*!< CRPT_T::TDES_CTL: KEYPRT Position */ +#define CRPT_TDES_CTL_KEYPRT_Msk (0x1ul << CRPT_TDES_CTL_KEYPRT_Pos) /*!< CRPT_T::TDES_CTL: KEYPRT Mask */ + +#define CRPT_TDES_STS_BUSY_Pos (0) /*!< CRPT_T::TDES_STS: BUSY Position */ +#define CRPT_TDES_STS_BUSY_Msk (0x1ul << CRPT_TDES_STS_BUSY_Pos) /*!< CRPT_T::TDES_STS: BUSY Mask */ + +#define CRPT_TDES_STS_INBUFEMPTY_Pos (8) /*!< CRPT_T::TDES_STS: INBUFEMPTY Position */ +#define CRPT_TDES_STS_INBUFEMPTY_Msk (0x1ul << CRPT_TDES_STS_INBUFEMPTY_Pos) /*!< CRPT_T::TDES_STS: INBUFEMPTY Mask */ + +#define CRPT_TDES_STS_INBUFFULL_Pos (9) /*!< CRPT_T::TDES_STS: INBUFFULL Position */ +#define CRPT_TDES_STS_INBUFFULL_Msk (0x1ul << CRPT_TDES_STS_INBUFFULL_Pos) /*!< CRPT_T::TDES_STS: INBUFFULL Mask */ + +#define CRPT_TDES_STS_INBUFERR_Pos (10) /*!< CRPT_T::TDES_STS: INBUFERR Position */ +#define CRPT_TDES_STS_INBUFERR_Msk (0x1ul << CRPT_TDES_STS_INBUFERR_Pos) /*!< CRPT_T::TDES_STS: INBUFERR Mask */ + +#define CRPT_TDES_STS_OUTBUFEMPTY_Pos (16) /*!< CRPT_T::TDES_STS: OUTBUFEMPTY Position */ +#define CRPT_TDES_STS_OUTBUFEMPTY_Msk (0x1ul << CRPT_TDES_STS_OUTBUFEMPTY_Pos) /*!< CRPT_T::TDES_STS: OUTBUFEMPTY Mask */ + +#define CRPT_TDES_STS_OUTBUFFULL_Pos (17) /*!< CRPT_T::TDES_STS: OUTBUFFULL Position */ +#define CRPT_TDES_STS_OUTBUFFULL_Msk (0x1ul << CRPT_TDES_STS_OUTBUFFULL_Pos) /*!< CRPT_T::TDES_STS: OUTBUFFULL Mask */ + +#define CRPT_TDES_STS_OUTBUFERR_Pos (18) /*!< CRPT_T::TDES_STS: OUTBUFERR Position */ +#define CRPT_TDES_STS_OUTBUFERR_Msk (0x1ul << CRPT_TDES_STS_OUTBUFERR_Pos) /*!< CRPT_T::TDES_STS: OUTBUFERR Mask */ + +#define CRPT_TDES_STS_BUSERR_Pos (20) /*!< CRPT_T::TDES_STS: BUSERR Position */ +#define CRPT_TDES_STS_BUSERR_Msk (0x1ul << CRPT_TDES_STS_BUSERR_Pos) /*!< CRPT_T::TDES_STS: BUSERR Mask */ + +#define CRPT_TDES0_KEY1H_KEY_Pos (0) /*!< CRPT_T::TDES0_KEY1H: KEY Position */ +#define CRPT_TDES0_KEY1H_KEY_Msk (0xfffffffful << CRPT_TDES0_KEY1H_KEY_Pos) /*!< CRPT_T::TDES0_KEY1H: KEY Mask */ + +#define CRPT_TDES0_KEY1L_KEY_Pos (0) /*!< CRPT_T::TDES0_KEY1L: KEY Position */ +#define CRPT_TDES0_KEY1L_KEY_Msk (0xfffffffful << CRPT_TDES0_KEY1L_KEY_Pos) /*!< CRPT_T::TDES0_KEY1L: KEY Mask */ + +#define CRPT_TDES0_KEY2H_KEY_Pos (0) /*!< CRPT_T::TDES0_KEY2H: KEY Position */ +#define CRPT_TDES0_KEY2H_KEY_Msk (0xfffffffful << CRPT_TDES0_KEY2H_KEY_Pos) /*!< CRPT_T::TDES0_KEY2H: KEY Mask */ + +#define CRPT_TDES0_KEY2L_KEY_Pos (0) /*!< CRPT_T::TDES0_KEY2L: KEY Position */ +#define CRPT_TDES0_KEY2L_KEY_Msk (0xfffffffful << CRPT_TDES0_KEY2L_KEY_Pos) /*!< CRPT_T::TDES0_KEY2L: KEY Mask */ + +#define CRPT_TDES0_KEY3H_KEY_Pos (0) /*!< CRPT_T::TDES0_KEY3H: KEY Position */ +#define CRPT_TDES0_KEY3H_KEY_Msk (0xfffffffful << CRPT_TDES0_KEY3H_KEY_Pos) /*!< CRPT_T::TDES0_KEY3H: KEY Mask */ + +#define CRPT_TDES0_KEY3L_KEY_Pos (0) /*!< CRPT_T::TDES0_KEY3L: KEY Position */ +#define CRPT_TDES0_KEY3L_KEY_Msk (0xfffffffful << CRPT_TDES0_KEY3L_KEY_Pos) /*!< CRPT_T::TDES0_KEY3L: KEY Mask */ + +#define CRPT_TDES0_IVH_IV_Pos (0) /*!< CRPT_T::TDES0_IVH: IV Position */ +#define CRPT_TDES0_IVH_IV_Msk (0xfffffffful << CRPT_TDES0_IVH_IV_Pos) /*!< CRPT_T::TDES0_IVH: IV Mask */ + +#define CRPT_TDES0_IVL_IV_Pos (0) /*!< CRPT_T::TDES0_IVL: IV Position */ +#define CRPT_TDES0_IVL_IV_Msk (0xfffffffful << CRPT_TDES0_IVL_IV_Pos) /*!< CRPT_T::TDES0_IVL: IV Mask */ + +#define CRPT_TDES0_SADDR_SADDR_Pos (0) /*!< CRPT_T::TDES0_SADDR: SADDR Position */ +#define CRPT_TDES0_SADDR_SADDR_Msk (0xfffffffful << CRPT_TDES0_SADDR_SADDR_Pos) /*!< CRPT_T::TDES0_SADDR: SADDR Mask */ + +#define CRPT_TDES0_DADDR_DADDR_Pos (0) /*!< CRPT_T::TDES0_DADDR: DADDR Position */ +#define CRPT_TDES0_DADDR_DADDR_Msk (0xfffffffful << CRPT_TDES0_DADDR_DADDR_Pos) /*!< CRPT_T::TDES0_DADDR: DADDR Mask */ + +#define CRPT_TDES0_CNT_CNT_Pos (0) /*!< CRPT_T::TDES0_CNT: CNT Position */ +#define CRPT_TDES0_CNT_CNT_Msk (0xfffffffful << CRPT_TDES0_CNT_CNT_Pos) /*!< CRPT_T::TDES0_CNT: CNT Mask */ + +#define CRPT_TDES_DATIN_DATIN_Pos (0) /*!< CRPT_T::TDES_DATIN: DATIN Position */ +#define CRPT_TDES_DATIN_DATIN_Msk (0xfffffffful << CRPT_TDES_DATIN_DATIN_Pos) /*!< CRPT_T::TDES_DATIN: DATIN Mask */ + +#define CRPT_TDES_DATOUT_DATOUT_Pos (0) /*!< CRPT_T::TDES_DATOUT: DATOUT Position */ +#define CRPT_TDES_DATOUT_DATOUT_Msk (0xfffffffful << CRPT_TDES_DATOUT_DATOUT_Pos) /*!< CRPT_T::TDES_DATOUT: DATOUT Mask */ + +#define CRPT_TDES1_KEY1H_KEY_Pos (0) /*!< CRPT_T::TDES1_KEY1H: KEY Position */ +#define CRPT_TDES1_KEY1H_KEY_Msk (0xfffffffful << CRPT_TDES1_KEY1H_KEY_Pos) /*!< CRPT_T::TDES1_KEY1H: KEY Mask */ + +#define CRPT_TDES1_KEY1L_KEYL_Pos (0) /*!< CRPT_T::TDES1_KEY1L: KEY Position */ +#define CRPT_TDES1_KEY1L_KEY_Msk (0xfffffffful << CRPT_TDES1_KEY1L_KEY_Pos) /*!< CRPT_T::TDES1_KEY1L: KEY Mask */ + +#define CRPT_TDES1_KEY2H_KEY_Pos (0) /*!< CRPT_T::TDES1_KEY2H: KEY Position */ +#define CRPT_TDES1_KEY2H_KEY_Msk (0xfffffffful << CRPT_TDES1_KEY2H_KEY_Pos) /*!< CRPT_T::TDES1_KEY2H: KEY Mask */ + +#define CRPT_TDES1_KEY2L_KEY_Pos (0) /*!< CRPT_T::TDES1_KEY2L: KEY Position */ +#define CRPT_TDES1_KEY2L_KEY_Msk (0xfffffffful << CRPT_TDES1_KEY2L_KEY_Pos) /*!< CRPT_T::TDES1_KEY2L: KEY Mask */ + +#define CRPT_TDES1_KEY3H_KEY_Pos (0) /*!< CRPT_T::TDES1_KEY3H: KEY Position */ +#define CRPT_TDES1_KEY3H_KEY_Msk (0xfffffffful << CRPT_TDES1_KEY3H_KEY_Pos) /*!< CRPT_T::TDES1_KEY3H: KEY Mask */ + +#define CRPT_TDES1_KEY3L_KEY_Pos (0) /*!< CRPT_T::TDES1_KEY3L: KEY Position */ +#define CRPT_TDES1_KEY3L_KEY_Msk (0xfffffffful << CRPT_TDES1_KEY3L_KEY_Pos) /*!< CRPT_T::TDES1_KEY3L: KEY Mask */ + +#define CRPT_TDES1_IVH_IV_Pos (0) /*!< CRPT_T::TDES1_IVH: IV Position */ +#define CRPT_TDES1_IVH_IV_Msk (0xfffffffful << CRPT_TDES1_IVH_IV_Pos) /*!< CRPT_T::TDES1_IVH: IV Mask */ + +#define CRPT_TDES1_IVL_IV_Pos (0) /*!< CRPT_T::TDES1_IVL: IV Position */ +#define CRPT_TDES1_IVL_IV_Msk (0xfffffffful << CRPT_TDES1_IVL_IV_Pos) /*!< CRPT_T::TDES1_IVL: IV Mask */ + +#define CRPT_TDES1_SADDR_SADDR_Pos (0) /*!< CRPT_T::TDES1_SADDR: SADDR Position */ +#define CRPT_TDES1_SADDR_SADDR_Msk (0xfffffffful << CRPT_TDES1_SADDR_SADDR_Pos) /*!< CRPT_T::TDES1_SADDR: SADDR Mask */ + +#define CRPT_TDES1_DADDR_DADDR_Pos (0) /*!< CRPT_T::TDES1_DADDR: DADDR Position */ +#define CRPT_TDES1_DADDR_DADDR_Msk (0xfffffffful << CRPT_TDES1_DADDR_DADDR_Pos) /*!< CRPT_T::TDES1_DADDR: DADDR Mask */ + +#define CRPT_TDES1_CNT_CNT_Pos (0) /*!< CRPT_T::TDES1_CNT: CNT Position */ +#define CRPT_TDES1_CNT_CNT_Msk (0xfffffffful << CRPT_TDES1_CNT_CNT_Pos) /*!< CRPT_T::TDES1_CNT: CNT Mask */ + +#define CRPT_TDES2_KEY1H_KEY_Pos (0) /*!< CRPT_T::TDES2_KEY1H: KEY Position */ +#define CRPT_TDES2_KEY1H_KEY_Msk (0xfffffffful << CRPT_TDES2_KEY1H_KEY_Pos) /*!< CRPT_T::TDES2_KEY1H: KEY Mask */ + +#define CRPT_TDES2_KEY1L_KEY_Pos (0) /*!< CRPT_T::TDES2_KEY1L: KEY Position */ +#define CRPT_TDES2_KEY1L_KEY_Msk (0xfffffffful << CRPT_TDES2_KEY1L_KEY_Pos) /*!< CRPT_T::TDES2_KEY1L: KEY Mask */ + +#define CRPT_TDES2_KEY2H_KEY_Pos (0) /*!< CRPT_T::TDES2_KEY2H: KEY Position */ +#define CRPT_TDES2_KEY2H_KEY_Msk (0xfffffffful << CRPT_TDES2_KEY2H_KEY_Pos) /*!< CRPT_T::TDES2_KEY2H: KEY Mask */ + +#define CRPT_TDES2_KEY2L_KEY_Pos (0) /*!< CRPT_T::TDES2_KEY2L: KEY Position */ +#define CRPT_TDES2_KEY2L_KEY_Msk (0xfffffffful << CRPT_TDES2_KEY2L_KEY_Pos) /*!< CRPT_T::TDES2_KEY2L: KEY Mask */ + +#define CRPT_TDES2_KEY3H_KEY_Pos (0) /*!< CRPT_T::TDES2_KEY3H: KEY Position */ +#define CRPT_TDES2_KEY3H_KEY_Msk (0xfffffffful << CRPT_TDES2_KEY3H_KEY_Pos) /*!< CRPT_T::TDES2_KEY3H: KEY Mask */ + +#define CRPT_TDES2_KEY3L_KEY_Pos (0) /*!< CRPT_T::TDES2_KEY3L: KEY Position */ +#define CRPT_TDES2_KEY3L_KEY_Msk (0xfffffffful << CRPT_TDES2_KEY3L_KEY_Pos) /*!< CRPT_T::TDES2_KEY3L: KEY Mask */ + +#define CRPT_TDES2_IVH_IV_Pos (0) /*!< CRPT_T::TDES2_IVH: IV Position */ +#define CRPT_TDES2_IVH_IV_Msk (0xfffffffful << CRPT_TDES2_IVH_IV_Pos) /*!< CRPT_T::TDES2_IVH: IV Mask */ + +#define CRPT_TDES2_IVL_IV_Pos (0) /*!< CRPT_T::TDES2_IVL: IV Position */ +#define CRPT_TDES2_IVL_IV_Msk (0xfffffffful << CRPT_TDES2_IVL_IV_Pos) /*!< CRPT_T::TDES2_IVL: IV Mask */ + +#define CRPT_TDES2_SADDR_SADDR_Pos (0) /*!< CRPT_T::TDES2_SADDR: SADDR Position */ +#define CRPT_TDES2_SADDR_SADDR_Msk (0xfffffffful << CRPT_TDES2_SADDR_SADDR_Pos) /*!< CRPT_T::TDES2_SADDR: SADDR Mask */ + +#define CRPT_TDES2_DADDR_DADDR_Pos (0) /*!< CRPT_T::TDES2_DADDR: DADDR Position */ +#define CRPT_TDES2_DADDR_DADDR_Msk (0xfffffffful << CRPT_TDES2_DADDR_DADDR_Pos) /*!< CRPT_T::TDES2_DADDR: DADDR Mask */ + +#define CRPT_TDES2_CNT_CNT_Pos (0) /*!< CRPT_T::TDES2_CNT: CNT Position */ +#define CRPT_TDES2_CNT_CNT_Msk (0xfffffffful << CRPT_TDES2_CNT_CNT_Pos) /*!< CRPT_T::TDES2_CNT: CNT Mask */ + +#define CRPT_TDES3_KEY1H_KEY_Pos (0) /*!< CRPT_T::TDES3_KEY1H: KEY Position */ +#define CRPT_TDES3_KEY1H_KEY_Msk (0xfffffffful << CRPT_TDES3_KEY1H_KEY_Pos) /*!< CRPT_T::TDES3_KEY1H: KEY Mask */ + +#define CRPT_TDES3_KEY1L_KEY_Pos (0) /*!< CRPT_T::TDES3_KEY1L: KEY Position */ +#define CRPT_TDES3_KEY1L_KEY_Msk (0xfffffffful << CRPT_TDES3_KEY1L_KEY_Pos) /*!< CRPT_T::TDES3_KEY1L: KEY Mask */ + +#define CRPT_TDES3_KEY2H_KEY_Pos (0) /*!< CRPT_T::TDES3_KEY2H: KEY Position */ +#define CRPT_TDES3_KEY2H_KEY_Msk (0xfffffffful << CRPT_TDES3_KEY2H_KEY_Pos) /*!< CRPT_T::TDES3_KEY2H: KEY Mask */ + +#define CRPT_TDES3_KEY2L_KEY_Pos (0) /*!< CRPT_T::TDES3_KEY2L: KEY Position */ +#define CRPT_TDES3_KEY2L_KEY_Msk (0xfffffffful << CRPT_TDES3_KEY2L_KEY_Pos) /*!< CRPT_T::TDES3_KEY2L: KEY Mask */ + +#define CRPT_TDES3_KEY3H_KEY_Pos (0) /*!< CRPT_T::TDES3_KEY3H: KEY Position */ +#define CRPT_TDES3_KEY3H_KEY_Msk (0xfffffffful << CRPT_TDES3_KEY3H_KEY_Pos) /*!< CRPT_T::TDES3_KEY3H: KEY Mask */ + +#define CRPT_TDES3_KEY3L_KEY_Pos (0) /*!< CRPT_T::TDES3_KEY3L: KEY Position */ +#define CRPT_TDES3_KEY3L_KEY_Msk (0xfffffffful << CRPT_TDES3_KEY3L_KEY_Pos) /*!< CRPT_T::TDES3_KEY3L: KEY Mask */ + +#define CRPT_TDES3_IVH_IV_Pos (0) /*!< CRPT_T::TDES3_IVH: IV Position */ +#define CRPT_TDES3_IVH_IV_Msk (0xfffffffful << CRPT_TDES3_IVH_IV_Pos) /*!< CRPT_T::TDES3_IVH: IV Mask */ + +#define CRPT_TDES3_IVL_IV_Pos (0) /*!< CRPT_T::TDES3_IVL: IV Position */ +#define CRPT_TDES3_IVL_IV_Msk (0xfffffffful << CRPT_TDES3_IVL_IV_Pos) /*!< CRPT_T::TDES3_IVL: IV Mask */ + +#define CRPT_TDES3_SADDR_SADDR_Pos (0) /*!< CRPT_T::TDES3_SADDR: SADDR Position */ +#define CRPT_TDES3_SADDR_SADDR_Msk (0xfffffffful << CRPT_TDES3_SADDR_SADDR_Pos) /*!< CRPT_T::TDES3_SADDR: SADDR Mask */ + +#define CRPT_TDES3_DADDR_DADDR_Pos (0) /*!< CRPT_T::TDES3_DADDR: DADDR Position */ +#define CRPT_TDES3_DADDR_DADDR_Msk (0xfffffffful << CRPT_TDES3_DADDR_DADDR_Pos) /*!< CRPT_T::TDES3_DADDR: DADDR Mask */ + +#define CRPT_TDES3_CNT_CNT_Pos (0) /*!< CRPT_T::TDES3_CNT: CNT Position */ +#define CRPT_TDES3_CNT_CNT_Msk (0xfffffffful << CRPT_TDES3_CNT_CNT_Pos) /*!< CRPT_T::TDES3_CNT: CNT Mask */ + +#define CRPT_SHA_CTL_START_Pos (0) /*!< CRPT_T::SHA_CTL: START Position */ +#define CRPT_SHA_CTL_START_Msk (0x1ul << CRPT_SHA_CTL_START_Pos) /*!< CRPT_T::SHA_CTL: START Mask */ + +#define CRPT_SHA_CTL_STOP_Pos (1) /*!< CRPT_T::SHA_CTL: STOP Position */ +#define CRPT_SHA_CTL_STOP_Msk (0x1ul << CRPT_SHA_CTL_STOP_Pos) /*!< CRPT_T::SHA_CTL: STOP Mask */ + +#define CRPT_SHA_CTL_DMALAST_Pos (5) /*!< CRPT_T::SHA_CTL: DMALAST Position */ +#define CRPT_SHA_CTL_DMALAST_Msk (0x1ul << CRPT_SHA_CTL_DMALAST_Pos) /*!< CRPT_T::SHA_CTL: DMALAST Mask */ + +#define CRPT_SHA_CTL_DMAEN_Pos (7) /*!< CRPT_T::SHA_CTL: DMAEN Position */ +#define CRPT_SHA_CTL_DMAEN_Msk (0x1ul << CRPT_SHA_CTL_DMAEN_Pos) /*!< CRPT_T::SHA_CTL: DMAEN Mask */ + +#define CRPT_SHA_CTL_OPMODE_Pos (8) /*!< CRPT_T::SHA_CTL: OPMODE Position */ +#define CRPT_SHA_CTL_OPMODE_Msk (0x7ul << CRPT_SHA_CTL_OPMODE_Pos) /*!< CRPT_T::SHA_CTL: OPMODE Mask */ + +#define CRPT_SHA_CTL_OUTSWAP_Pos (22) /*!< CRPT_T::SHA_CTL: OUTSWAP Position */ +#define CRPT_SHA_CTL_OUTSWAP_Msk (0x1ul << CRPT_SHA_CTL_OUTSWAP_Pos) /*!< CRPT_T::SHA_CTL: OUTSWAP Mask */ + +#define CRPT_SHA_CTL_INSWAP_Pos (23) /*!< CRPT_T::SHA_CTL: INSWAP Position */ +#define CRPT_SHA_CTL_INSWAP_Msk (0x1ul << CRPT_SHA_CTL_INSWAP_Pos) /*!< CRPT_T::SHA_CTL: INSWAP Mask */ + +#define CRPT_SHA_STS_BUSY_Pos (0) /*!< CRPT_T::SHA_STS: BUSY Position */ +#define CRPT_SHA_STS_BUSY_Msk (0x1ul << CRPT_SHA_STS_BUSY_Pos) /*!< CRPT_T::SHA_STS: BUSY Mask */ + +#define CRPT_SHA_STS_DMABUSY_Pos (1) /*!< CRPT_T::SHA_STS: DMABUSY Position */ +#define CRPT_SHA_STS_DMABUSY_Msk (0x1ul << CRPT_SHA_STS_DMABUSY_Pos) /*!< CRPT_T::SHA_STS: DMABUSY Mask */ + +#define CRPT_SHA_STS_DMAERR_Pos (8) /*!< CRPT_T::SHA_STS: DMAERR Position */ +#define CRPT_SHA_STS_DMAERR_Msk (0x1ul << CRPT_SHA_STS_DMAERR_Pos) /*!< CRPT_T::SHA_STS: DMAERR Mask */ + +#define CRPT_SHA_STS_DATINREQ_Pos (16) /*!< CRPT_T::SHA_STS: DATINREQ Position */ +#define CRPT_SHA_STS_DATINREQ_Msk (0x1ul << CRPT_SHA_STS_DATINREQ_Pos) /*!< CRPT_T::SHA_STS: DATINREQ Mask */ + +#define CRPT_SHA_DGST0_DGST_Pos (0) /*!< CRPT_T::SHA_DGST0: DGST Position */ +#define CRPT_SHA_DGST0_DGST_Msk (0xfffffffful << CRPT_SHA_DGST0_DGST_Pos) /*!< CRPT_T::SHA_DGST0: DGST Mask */ + +#define CRPT_SHA_DGST1_DGST_Pos (0) /*!< CRPT_T::SHA_DGST1: DGST Position */ +#define CRPT_SHA_DGST1_DGST_Msk (0xfffffffful << CRPT_SHA_DGST1_DGST_Pos) /*!< CRPT_T::SHA_DGST1: DGST Mask */ + +#define CRPT_SHA_DGST2_DGST_Pos (0) /*!< CRPT_T::SHA_DGST2: DGST Position */ +#define CRPT_SHA_DGST2_DGST_Msk (0xfffffffful << CRPT_SHA_DGST2_DGST_Pos) /*!< CRPT_T::SHA_DGST2: DGST Mask */ + +#define CRPT_SHA_DGST3_DGST_Pos (0) /*!< CRPT_T::SHA_DGST3: DGST Position */ +#define CRPT_SHA_DGST3_DGST_Msk (0xfffffffful << CRPT_SHA_DGST3_DGST_Pos) /*!< CRPT_T::SHA_DGST3: DGST Mask */ + +#define CRPT_SHA_DGST4_DGST_Pos (0) /*!< CRPT_T::SHA_DGST4: DGST Position */ +#define CRPT_SHA_DGST4_DGST_Msk (0xfffffffful << CRPT_SHA_DGST4_DGST_Pos) /*!< CRPT_T::SHA_DGST4: DGST Mask */ + +#define CRPT_SHA_DGST5_DGST_Pos (0) /*!< CRPT_T::SHA_DGST5: DGST Position */ +#define CRPT_SHA_DGST5_DGST_Msk (0xfffffffful << CRPT_SHA_DGST5_DGST_Pos) /*!< CRPT_T::SHA_DGST5: DGST Mask */ + +#define CRPT_SHA_DGST6_DGST_Pos (0) /*!< CRPT_T::SHA_DGST6: DGST Position */ +#define CRPT_SHA_DGST6_DGST_Msk (0xfffffffful << CRPT_SHA_DGST6_DGST_Pos) /*!< CRPT_T::SHA_DGST6: DGST Mask */ + +#define CRPT_SHA_DGST7_DGST_Pos (0) /*!< CRPT_T::SHA_DGST7: DGST Position */ +#define CRPT_SHA_DGST7_DGST_Msk (0xfffffffful << CRPT_SHA_DGST7_DGST_Pos) /*!< CRPT_T::SHA_DGST7: DGST Mask */ + +#define CRPT_SHA_KEYCNT_KEYCNT_Pos (0) /*!< CRPT_T::SHA_KEYCNT: KEYCNT Position */ +#define CRPT_SHA_KEYCNT_KEYCNT_Msk (0xfffffffful << CRPT_SHA_KEYCNT_KEYCNT_Pos) /*!< CRPT_T::SHA_KEYCNT: KEYCNT Mask */ + +#define CRPT_SHA_SADDR_SADDR_Pos (0) /*!< CRPT_T::SHA_SADDR: SADDR Position */ +#define CRPT_SHA_SADDR_SADDR_Msk (0xfffffffful << CRPT_SHA_SADDR_SADDR_Pos) /*!< CRPT_T::SHA_SADDR: SADDR Mask */ + +#define CRPT_SHA_DMACNT_DMACNT_Pos (0) /*!< CRPT_T::SHA_DMACNT: DMACNT Position */ +#define CRPT_SHA_DMACNT_DMACNT_Msk (0xfffffffful << CRPT_SHA_DMACNT_DMACNT_Pos) /*!< CRPT_T::SHA_DMACNT: DMACNT Mask */ + +#define CRPT_SHA_DATIN_DATIN_Pos (0) /*!< CRPT_T::SHA_DATIN: DATIN Position */ +#define CRPT_SHA_DATIN_DATIN_Msk (0xfffffffful << CRPT_SHA_DATIN_DATIN_Pos) /*!< CRPT_T::SHA_DATIN: DATIN Mask */ + +/**@}*/ /* CRPT_CONST */ +/**@}*/ /* end of CRPT register group */ + + +/*---------------------- Enhanced Analog to Digital Converter -------------------------*/ +/** + @addtogroup EADC Enhanced Analog to Digital Converter(EADC) + Memory Mapped Structure for EADC Controller +@{ */ + +typedef struct { + + + /** + * AD0DAT0 + * =================================================================================================== + * Offset: 0x00 A/D Data Register 0 for SAMPLE00 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT0; + + /** + * AD0DAT1 + * =================================================================================================== + * Offset: 0x04 A/D Data Register 1 for SAMPLE01 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT1; + + /** + * AD0DAT2 + * =================================================================================================== + * Offset: 0x08 A/D Data Register 2 for SAMPLE02 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT2; + + /** + * AD0DAT3 + * =================================================================================================== + * Offset: 0x0C A/D Data Register 3 for SAMPLE03 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT3; + + /** + * AD0DAT4 + * =================================================================================================== + * Offset: 0x10 A/D Data Register 4 for SAMPLE04 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT4; + + /** + * AD0DAT5 + * =================================================================================================== + * Offset: 0x14 A/D Data Register 5 for SAMPLE05 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT5; + + /** + * AD0DAT6 + * =================================================================================================== + * Offset: 0x18 A/D Data Register 6 for SAMPLE06 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT6; + + /** + * AD0DAT7 + * =================================================================================================== + * Offset: 0x1C A/D Data Register 7 for SAMPLE07 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DAT7; + + /** + * AD1DAT0 + * =================================================================================================== + * Offset: 0x20 A/D Data Register 8 for SAMPLE10 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT0; + + /** + * AD1DAT1 + * =================================================================================================== + * Offset: 0x24 A/D Data Register 9 for SAMPLE11 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT1; + + /** + * AD1DAT2 + * =================================================================================================== + * Offset: 0x28 A/D Data Register 10 for SAMPLE12 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT2; + + /** + * AD1DAT3 + * =================================================================================================== + * Offset: 0x2C A/D Data Register 11 for SAMPLE13 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT3; + + /** + * AD1DAT4 + * =================================================================================================== + * Offset: 0x30 A/D Data Register 12 for SAMPLE14 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT4; + + /** + * AD1DAT5 + * =================================================================================================== + * Offset: 0x34 A/D Data Register 13 for SAMPLE15 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT5; + + /** + * AD1DAT6 + * =================================================================================================== + * Offset: 0x38 A/D Data Register 14 for SAMPLE16 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT6; + + /** + * AD1DAT7 + * =================================================================================================== + * Offset: 0x3C A/D Data Register 15 for SAMPLE17 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |OV |Overrun Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is recent conversion result. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is overwrite. + * | | |If converted data in RESULT (EADC_ADnDATx[11:0]) has not been read before new conversion result is loaded to this register, OV (EADC_ADnDATx[16]) is set to 1. + * | | |It is cleared by hardware after EADC_ADnDATx register is read. + * |[17] |VALID |Valid Flag + * | | |0 = Data in RESULT (EADC_ADnDATx[11:0]) is not valid. + * | | |1 = Data in RESULT (EADC_ADnDATx[11:0]) is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DAT7; + + /** + * CTL + * =================================================================================================== + * Offset: 0x40 A/D Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ADCEN |A/D Converter Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |Before starting A/D conversion function, this bit should be set to 1. + * | | |Clear it to 0 to disable A/D converter analog circuit power consumption. + * |[1] |ADCRST |ADC0, ADC1 A/D Converter Control Circuits Reset + * | | |0 = No effect. + * | | |1 = Cause ADC control circuits reset to initial state, but not change the ADC registers value. + * | | |The ADCRST (EADC_CTL [1]) bit remains 1 during ADC reset, when ADC reset end, the ADCRST (EADC_CTL [1]) bit is automatically cleared to 0. + * |[2] |ADCIEN0 |Specific SAMPLE A/D ADINT0 Interrupt Enable Control + * | | |0 = Specific SAMPLE A/D ADINT0 interrupt function Disabled. + * | | |1 = Specific SAMPLE A/D ADINT0 interrupt function Enabled. + * | | |The A/D converter generates a conversion end ADIF0 (EADC_STATUS1 [0]) flag upon the end of specific SAMPLE A/D conversion. + * | | |If ADCIEN0 (EADC_CTL [2]) bit is set then conversion end interrupt request ADINT0 is generated. + * |[3] |ADCIEN1 |Specific SAMPLE A/D ADINT1 Interrupt Enable Control + * | | |0 = Specific SAMPLE A/D ADINT1 interrupt function Disabled. + * | | |1 = Specific SAMPLE A/D ADINT1 interrupt function Enabled. + * | | |The A/D converter generates a conversion end ADIF0 (EADC_STATUS1 [1]) flag upon the end of specific SAMPLE A/D conversion. + * | | |If ADCIEN1 EADC_CTL [3]) bit is set then conversion end interrupt request ADINT1 is generated. + * |[4] |ADCIEN2 |Specific SAMPLE A/D ADINT2 Interrupt Enable Control + * | | |0 = Specific SAMPLE A/D ADINT2 interrupt function Disabled. + * | | |1 = Specific SAMPLE A/D ADINT2 interrupt function Enabled. + * | | |The A/D converter generates a conversion end ADIF2 (EADC_STATUS1 [2]) flag upon the end of specific SAMPLE A/D conversion. + * | | |If ADCIEN2 (EADC_CTL [4]) bit is set then conversion end interrupt request ADINT2 is generated. + * |[5] |ADCIEN3 |Specific SAMPLE A/D ADINT3 Interrupt Enable Control + * | | |0 = Specific SAMPLE A/D ADINT3 interrupt function Disabled. + * | | |1 = Specific SAMPLE A/D ADINT3 interrupt function Enabled. + * | | |The A/D converter generates a conversion end ADIF3 (EADC_STATUS1 [3]) flag upon the end of specific SAMPLE A/D conversion. + * | | |If ADCIEN3 (EADC_CTL [5]) bit is set then conversion end interrupt request ADINT3 is generated. + */ + __IO uint32_t CTL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SWTRG + * =================================================================================================== + * Offset: 0x48 A/D SAMPLE Software Start Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SWTRG7_0 |A/D SAMPLE07~SAMPLE00 Software Force To Start ADC Conversion + * | | |0 = No effect. + * | | |1 = Start an ADC conversion when the priority is given to SAMPLE0x. + * | | |Note: x = 0~7. + * |[8:15] |SWTRG15_8 |A/D SAMPLE17~SAMPLE10 Software Force To Start ADC Conversion + * | | |0 = No effect. + * | | |1 = Start an ADC conversion when the priority is given to SAMPLE1x. + * | | |Note: x = 0~7. + */ + __O uint32_t SWTRG; + + /** + * PENDSTS + * =================================================================================================== + * Offset: 0x4C A/D Start of Conversion Pending Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |STPF7_0 |A/D SAMPLE07~SAMPLE00 Start Of Conversion Pending Flag + * | | |0 = There is no pending conversion for SAMPLE0x. + * | | |1 = SAMPLE0x ADC start of conversion is pending. + * | | |Note: This bit remains 1 during pending state, when the respective ADC conversion is started, the STPF bit is automatically cleared to 0. + * | | |Note: x = 0~7. + * |[8:15] |STPF15_8 |A/D SAMPLE17~SAMPLE10 Start Of Conversion Pending Flag + * | | |0 = There is no pending conversion for SAMPLE1x. + * | | |1 = SAMPLE1x ADC start of conversion is pending. + * | | |Note: This bit remains 1 during pending state, when the respective ADC conversion is started, the STPF bit is automatically cleared to 0. + * | | |Note: x = 0~7. + */ + __I uint32_t PENDSTS; + + /** + * ADIFOV + * =================================================================================================== + * Offset: 0x50 A/D ADINT3~0 Interrupt Flag Overrun Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ADFOV0 |A/D ADINT0 Interrupt Flag Overrun + * | | |0 = ADINT0 interrupt flag is not overwritten to 1. + * | | |1 = ADINT0 interrupt flag is overwritten to 1. + * | | |Note: This bit is cleared by writing 1 to it. + * |[1] |ADFOV1 |A/D ADINT1 Interrupt Flag Overrun + * | | |0 = ADINT1 interrupt flag is not overwritten to 1. + * | | |1 = ADINT1 interrupt flag is overwritten to 1. + * | | |Note: This bit is cleared by writing 1 to it. + * |[2] |ADFOV2 |A/D ADINT2 Interrupt Flag Overrun + * | | |0 = ADINT2 interrupt flag is not overwritten to 1. + * | | |1 = ADINT2 interrupt flag is overwritten to 1. + * | | |Note: This bit is cleared by writing 1 to it. + * |[3] |ADFOV3 |A/D ADINT3 Interrupt Flag Overrun + * | | |0 = ADINT3 interrupt flag is not overwritten to 1. + * | | |1 = ADINT3 interrupt flag is overwritten to 1. + * | | |Note: This bit is cleared by writing 1 to it. + */ + __IO uint32_t ADIFOV; + + /** + * OVSTS + * =================================================================================================== + * Offset: 0x54 A/D SAMPLE Start of Conversion Overrun Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SPOVF7_0 |A/D SAMPLE07~SAMPLE00 Start Of Conversion Overrun Flag + * | | |0 = No SAMPLE0x event overrun. + * | | |1 = Indicates a new SAMPLE0x event is generated while an old one event is pending. + * | | |If there is a new trigger event comes when the SAMPLE is pending for the last trigger event, the overrun is happened and the SPOVF bit will be set as 1. + * | | |Note: This bit is cleared by writing 1 to it. + * | | |Note: x = 0~7. + * |[8:15] |SPOVF15_8 |A/D SAMPLE17~SAMPLE10 Start Of Conversion Overrun Flag + * | | |0 = No SAMPLE1x event overrun. + * | | |1 = Indicates a new SAMPLE1x event is generated while an old one event is pending. + * | | |If there is a new trigger event comes when the SAMPLE is pending for the last trigger event, the overrun is happened and the SPOVF bit will be set as 1. + * | | |Note: This bit is cleared by writing 1 to it. + * | | |Note: x = 0~7. + */ + __IO uint32_t OVSTS; + + /** + * AD0SPCTL0 + * =================================================================================================== + * Offset: 0x58 A/D SAMPLE00 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL0; + + /** + * AD0SPCTL1 + * =================================================================================================== + * Offset: 0x5C A/D SAMPLE01 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL1; + + /** + * AD0SPCTL2 + * =================================================================================================== + * Offset: 0x60 A/D SAMPLE02 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL2; + + /** + * AD0SPCTL3 + * =================================================================================================== + * Offset: 0x64 A/D SAMPLE03 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL3; + + /** + * AD0SPCTL4 + * =================================================================================================== + * Offset: 0x68 A/D SAMPLE04 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL4; + + /** + * AD0SPCTL5 + * =================================================================================================== + * Offset: 0x6C A/D SAMPLE05 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL5; + + /** + * AD0SPCTL6 + * =================================================================================================== + * Offset: 0x70 A/D SAMPLE06 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL6; + + /** + * AD0SPCTL7 + * =================================================================================================== + * Offset: 0x74 A/D SAMPLE07 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD0SPCTL7; + + /** + * AD1SPCTL0 + * =================================================================================================== + * Offset: 0x78 A/D SAMPLE10 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL0; + + /** + * AD1SPCTL1 + * =================================================================================================== + * Offset: 0x7C A/D SAMPLE11 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL1; + + /** + * AD1SPCTL2 + * =================================================================================================== + * Offset: 0x80 A/D SAMPLE12 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL2; + + /** + * AD1SPCTL3 + * =================================================================================================== + * Offset: 0x84 A/D SAMPLE13 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:7] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |0000 = Disable hardware trigger. + * | | |0001 = External pin (STADC) trigger. + * | | |0010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |0011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |0100 = Timer0 overflow pulse trigger. + * | | |0101 = Timer1 overflow pulse trigger. + * | | |0110 = Timer2 overflow pulse trigger. + * | | |0111 = Timer3 overflow pulse trigger. + * | | |1000 = EPWM0_CH0 trigger. + * | | |1001 = EPWM0_CH2 trigger. + * | | |1010 = EPWM0_CH4 trigger. + * | | |1011 = EPWM1_CH0 trigger. + * | | |1100 = EPWM1_CH2 trigger. + * | | |1101 = EPWM1_CH4 trigger. + * | | |1110 = PWM0_CH0 trigger. + * | | |1111 = PWM0_CH1 trigger. + * |[8:15] |TRGDLYCNT |A/D SAMPLE Start Of Conversion Trigger Delay Time + * | | |Trigger delay time = (TRGDLYCNT + 4) x Trigger delay clock period. + * |[16:17] |TRGDLYDIV |A/D SAMPLE Start Of Conversion Trigger Delay Clock Divider Selection + * | | |Trigger delay clock frequency: + * | | |00 = ADC_CLK/1. + * | | |01 = ADC_CLK/2. + * | | |10 = ADC_CLK/4. + * | | |11 = ADC_CLK/16. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL3; + + /** + * AD1SPCTL4 + * =================================================================================================== + * Offset: 0x88 A/D SAMPLE14 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL4; + + /** + * AD1SPCTL5 + * =================================================================================================== + * Offset: 0x8C A/D SAMPLE15 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL5; + + /** + * AD1SPCTL6 + * =================================================================================================== + * Offset: 0x90 A/D SAMPLE16 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL6; + + /** + * AD1SPCTL7 + * =================================================================================================== + * Offset: 0x94 A/D SAMPLE17 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |CHSEL |A/D SAMPLE0,1 Channel Selection + * | | |0000 = ADCn_CH0. + * | | |0001 = ADCn_CH1. + * | | |0010 = ADCn_CH2. + * | | |0011 = ADCn_CH3. + * | | |0100 = ADCn_CH4. + * | | |0101 = ADCn_CH5. + * | | |0110 = ADCn_CH6. + * | | |0111 = ADCn_CH7. + * | | |For SAMPLE0 + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OP0. + * | | |For SAMPLE1 + * | | |1000= OP1. + * |[4:6] |TRGSEL |A/D SAMPLE Start Of Conversion Trigger Source Selection + * | | |000 = Disable hardware trigger. + * | | |001 = External pin (STADC) trigger. + * | | |010 = ADC ADINT0 interrupt EOC pulse trigger. + * | | |011 = ADC ADINT1 interrupt EOC pulse trigger. + * | | |100 = Timer0 overflow pulse trigger. + * | | |101 = Timer1 overflow pulse trigger. + * | | |110 = Timer2 overflow pulse trigger. + * | | |111 = Timer3 overflow pulse trigger. + * |[20] |EXTREN |A/D External Pin Rising Edge Trigger Enable Control + * | | |0 = A/D external pin rising edge trigger Disabled. + * | | |1 = A/D external pin rising edge trigger Enabled. + * |[21] |EXTFEN |A/D External Pin Falling Edge Trigger Enable Control + * | | |0 = A/D external pin falling edge trigger Disabled. + * | | |1 = A/D external pin falling edge trigger Enabled. + */ + __IO uint32_t AD1SPCTL7; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SIMUSEL + * =================================================================================================== + * Offset: 0xA4 A/D SAMPLE Simultaneous Sampling Mode Select Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SIMUSEL0 |A/D SAMPLE00, SAMPLE10 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE00, SAMPLE10 are in single sampling mode, both SAMPLE00 and SAMPLE10's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE00, SAMPLE10 are in simultaneous sampling mode, Only SAMPLE00 can trigger the both ADC conversions of SAMPLE00 and SAMPLE10, SAMPLE10 trigger select TRGSEL is ignored. + * | | |If SAMPLE00's CHSEL = 1, and SAMPLE10's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + * |[1] |SIMUSEL1 |A/D SAMPLE01, SAMPLE11 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE01, SAMPLE11 are in single sampling mode, both SAMPLE01 and SAMPLE11's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE01, SAMPLE11 are in simultaneous sampling mode, Only SAMPLE01 can trigger the both ADC conversions of SAMPLE01 and SAMPLE11, SAMPLE11 trigger select TRGSEL is ignored. + * | | |If SAMPLE01's CHSEL = 1, and SAMPLE11's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + * |[2] |SIMUSEL2 |A/D SAMPLE02, SAMPLE12 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE02, SAMPLE12 are in single sampling mode, both SAMPLE02 and SAMPLE12's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE02, SAMPLE12 are in simultaneous sampling mode, Only SAMPLE02 can trigger the both ADC conversions of SAMPLE02 and SAMPLE12, SAMPLE12 trigger select TRGSEL is ignored. + * | | |If SAMPLE02's CHSEL = 1, and SAMPLE12's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + * |[3] |SIMUSEL3 |A/D SAMPLE03, SAMPLE13 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE03, SAMPLE13 are in single sampling mode, both SAMPLE03 and SAMPLE13's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE03, SAMPLE13 are in simultaneous sampling mode, Only SAMPLE03 can trigger the both ADC conversions of SAMPLE03 and SAMPLE13, SAMPLE13 trigger select TRGSEL is ignored. + * | | |If SAMPLE03's CHSEL = 1, and SAMPLE13's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + * |[4] |SIMUSEL4 |A/D SAMPLE04, SAMPLE14 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE04, SAMPLE14 are in single sampling mode, both SAMPLE04 and SAMPLE14's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE04, SAMPLE14 are in simultaneous sampling mode, Only SAMPLE04 can trigger the both ADC conversions of SAMPLE04 and SAMPLE14, SAMPLE14 trigger select TRGSEL is ignored. + * | | |If SAMPLE04's CHSEL = 1, and SAMPLE14's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + * |[5] |SIMUSEL5 |A/D SAMPLE05, SAMPLE15 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE05, SAMPLE15 are in single sampling mode, both SAMPLE05 and SAMPLE15's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE05, SAMPLE15 are in simultaneous sampling mode, Only SAMPLE05 can trigger the both ADC conversions of SAMPLE05 and SAMPLE15, SAMPLE15 trigger select TRGSEL is ignored. + * | | |if SAMPLE05's CHSEL = 1, and SAMPLE15's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + * |[6] |SIMUSEL6 |A/D SAMPLE06, SAMPLE16 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE06, SAMPLE16 are in single sampling mode, both SAMPLE06 and SAMPLE16's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE06, SAMPLE16 are in simultaneous sampling mode, Only SAMPLE06 can trigger the both ADC conversions of SAMPLE06 and SAMPLE16, SAMPLE16 trigger select TRGSEL is ignored. + * | | |If SAMPLE06's CHSEL = 1, and SAMPLE16's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + * |[7] |SIMUSEL7 |A/D SAMPLE07, SAMPLE17 Simultaneous Sampling Mode Selection + * | | |0 = SAMPLE07, SAMPLE17 are in single sampling mode, both SAMPLE07 and SAMPLE17's 3 bits of CHSEL define the ADC channels to be converted. + * | | |1 = SAMPLE07, SAMPLE17 are in simultaneous sampling mode, Only SAMPLE07 can trigger the both ADC conversions of SAMPLE07 and SAMPLE17, SAMPLE17 trigger select TRGSEL is ignored. + * | | |If SAMPLE07's CHSEL = 1, SAMPLE17's CHSEL = 3, the pair of channels are ADC0_CH1, ADC1_CH3, they will do the ADC conversion at the same time to reach the simulataneous sampling goal. + */ + __IO uint32_t SIMUSEL; + + /** + * CMP0/1 + * =================================================================================================== + * Offset: 0xA8 A/D Result Compare Register 0 + * Offset: 0xAC A/D Result Compare Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ADCMPEN |A/D Result Compare Enable Control + * | | |0 = Compare Disabled. + * | | |1 = Compare Enabled. + * | | |Set this bit to 1 to enable compare CMPDAT (EADC_CMPx[27:16]) with specified SAMPLE conversion result when converted data is loaded into ADDR register. + * |[1] |ADCMPIE |A/D Result Compare Interrupt Enable Control + * | | |0 = Compare function interrupt Disabled. + * | | |1 = Compare function interrupt Enabled. + * | | |If the compare function is enabled and the compare condition matches the setting of CMPCOND (EADC_CMPx[2]) and CMPMCNT (EADC_CMPx[11:8]), ADCMPF (EADC_STATUS1 [7:6]) bit will be asserted, in the meanwhile, if ADCMPIE (EADC_CMPx[1]) is set to 1, a compare interrupt request is generated. + * |[2] |CMPCOND |Compare Condition + * | | |0= Set the compare condition as that when a 12-bit A/D conversion result is less than the 12-bit CMPDAT (EADC_CMPx[27:16]), the internal match counter will increase one. + * | | |1= Set the compare condition as that when a 12-bit A/D conversion result is greater or equal to the 12-bit CMPDAT (EADC_CMPx[27:16]), the internal match counter will increase one. + * | | |Note: When the internal counter reaches the value to CMPMCNT (EADC_CMPx[11:8]) + 1, the CMPF bit will be set. + * |[3:5] |CMPSPL |Compare SAMPLE Selection + * | | |000 = SAMPLE00 conversion result EADC_AD0DAT0 is selected to be compared. + * | | |001 = SAMPLE01 conversion result EADC_AD0DAT1 is selected to be compared. + * | | |010 = SAMPLE02 conversion result EADC_AD0DAT2 is selected to be compared. + * | | |011 = SAMPLE03 conversion result EADC_AD0DAT3 is selected to be compared. + * | | |100 = SAMPLE10 conversion result EADC_AD1DAT0 is selected to be compared. + * | | |101 = SAMPLE11 conversion result EADC_AD1DAT1 is selected to be compared. + * | | |110 = SAMPLE12 conversion result EADC_AD1DAT2 is selected to be compared. + * | | |111 = SAMPLE13 conversion result EADC_AD1DAT3 is selected to be compared. + * |[8:11] |CMPMCNT |Compare Match Count + * | | |When the specified A/D SAMPLE analog conversion result matches the compare condition defined by CMPCOND (EADC_CMPx[2]), the internal match counter will increase 1. + * | | |When the internal counter reaches the value to CMPMCNT (EADC_CMPx[11:8] + 1, the ADCMPF (EADC_STATUS1 [7:6]) bit will be set. + * |[16:27] |CMPDAT |Compared Data + * | | |The 12 bits data is used to compare with conversion result of specified SAMPLE. + * | | |Software can use it to monitor the external analog input pin voltage transition without imposing a load on software. + */ + __IO uint32_t CMP[2]; + + /** + * STATUS0 + * =================================================================================================== + * Offset: 0xB0 A/D Status Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |VALID7_0 |ADDR07~ ADDR00 Data Valid Flag (Read Only) + * | | |It is a mirror of VALID bit in SAMPLE0 A/D result data register EADC_AD0DAT0x. + * | | |Note: x = 0~7. + * |[8:15] |VALID15_8 |ADDR17~ ADDR10 Data Valid Flag (Read Only) + * | | |It is a mirror of VALID bit in SAMPLE1 A/D result data register EADC_AD0DAT1x. + * | | |Note: x = 0~7. + * |[16:23] |OV7_0 |ADDR07~ ADDR00 Overrun Flag (Read Only) + * | | |It is a mirror to OV bit in SAMPLE0 A/D result data register EADC_AD0DAT0x. + * | | |Note: x = 0~7. + * |[24:31] |OV15_8 |ADDR17~ADDR10 Overrun Flag (Read Only) + * | | |It is a mirror to OV bit in SAMPLE1 A/D result data register EADC_AD0DAT1x. + * | | |Note: x = 0~7. + */ + __I uint32_t STATUS0; + + /** + * STATUS1 + * =================================================================================================== + * Offset: 0xB4 A/D Status Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ADIF0 |A/D ADINT0 Interrupt Flag + * | | |0 = No ADINT0 interrupt pulse received. + * | | |1 = ADINT0 interrupt pulse has been received. + * | | |Note1: This bit is cleared by writing 1 to it. + * | | |Note2:This bit indicates whether an A/D conversion of specific SAMPLE has been completed + * |[1] |ADIF1 |A/D ADINT1 Interrupt Flag + * | | |0 = No ADINT1 interrupt pulse received. + * | | |1 = ADINT1 interrupt pulse has been received. + * | | |Note1: This bit is cleared by writing 1 to it. + * | | |Note2:This bit indicates whether an A/D conversion of specific SAMPLE has been completed + * |[2] |ADIF2 |A/D ADINT2 Interrupt Flag + * | | |0 = no ADINT2 interrupt pulse received. + * | | |1 = ADINT2 interrupt pulse has been received. + * | | |Note1: This bit is cleared by writing 1 to it. + * | | |Note2:This bit indicates whether an A/D conversion of specific SAMPLE has been completed + * |[3] |ADIF3 |A/D ADINT3 Interrupt Flag + * | | |0 = No ADINT3 interrupt pulse received. + * | | |1 = ADINT3 interrupt pulse has been received. + * | | |Note1: This bit is cleared by writing 1 to it. + * | | |Note2:This bit indicates whether an A/D conversion of specific SAMPLE has been completed + * |[4] |ADCMPO0 |ADC Compare 0 Output Status + * | | |The 12 bits compare0 data CMPDAT EADC_CMP0 [27:16]) is used to compare with conversion result of specified SAMPLE. + * | | |Software can use it to monitor the external analog input pin voltage status. + * | | |0 = Conversion result in ADDR less than CMPDAT (EADC_CMP0 [27:16]) setting. + * | | |1 = Conversion result in ADDR great than or equal CMPDAT (EADC_CMP0 [27:16]) setting. + * |[5] |ADCMPO1 |ADC Compare 1 Output Status + * | | |The 12 bits compare1 data CMPDAT (EADC_CMP1 [27:16]) is used to compare with conversion result of specified SAMPLE. + * | | |Software can use it to monitor the external analog input pin voltage status. + * | | |0 = Conversion result in ADDR less than CMPDAT EADC_CMP1 [27:16]) setting. + * | | |1 = Conversion result in ADDR great than or equal CMPDAT (EADC_CMP1 [27:16]) setting. + * |[6] |ADCMPF0 |ADC Compare 0 Flag + * | | |When the specific SAMPLE A/D conversion result meets setting condition in EADC_CMP0 then this bit is set to 1. + * | | |0 = Conversion result in ADDR does not meet EADC_CMP0 setting. + * | | |1 = Conversion result in ADDR meets EADC_CMP0 setting. + * | | |Note: This bit is cleared by writing 1 to it. + * |[7] |ADCMPF1 |ADC Compare 1 Flag + * | | |When the specific SAMPLE A/D conversion result meets setting condition in EADC_CMP1 then this bit is set to 1. + * | | |0 = Conversion result in ADDR does not meet EADC_CMP1 setting. + * | | |1 = Conversion result in ADDR meets EADC_CMP1 setting. + * | | |Note: This bit is cleared by writing 1 to it. + * |[8] |BUSY0 |Busy/Idle (Read Only) + * | | |0 = A/D converter 0 (ADC0) is in idle state. + * | | |1 = A/D converter 0 (ADC0) is doing conversion. + * |[12:15] |CHANNEL0 |Current Conversion Channel (Read Only) + * | | |This filed reflects ADC0 current conversion channel when BUSY0 (EADC_STATUS1 [8]) = 1. + * | | |When BUSY0 (EADC_STATUS1 [8]) = 0, it shows the last converted channel. + * | | |0000 = ADC0_CH0. + * | | |0001 = ADC0_CH1. + * | | |0010 = ADC0_CH2. + * | | |0011 = ADC0_CH3. + * | | |0100 = ADC0_CH4. + * | | |0100 = ADC0_CH5. + * | | |0110 = ADC0_CH6. + * | | |0111 = ADC0_CH7. + * | | |1000 = VBG. + * | | |1001 = VTEMP. + * | | |1010 = AVSS. + * | | |1011 = OPA0_O. + * | | |Other = reserved. + * |[16] |BUSY1 |Busy/Idle + * | | |0 = A/D converter 1 (ADC1) is in idle state. + * | | |1 = A/D converter 1 (ADC1) is doing conversion. + * |[20:23] |CHANNEL1 |Current Conversion Channel (Read Only) + * | | |This filed reflects ADC1 current conversion channel when BUSY1 (EADC_STATUS1 [16]) = 1. + * | | |When BUSY1 (EADC_STATUS1 [16]) = 0, it shows the last converted channel. + * | | |0000 = ADC1_CH0. + * | | |0001 = ADC1_CH1. + * | | |0010 = ADC1_CH2. + * | | |0011 = ADC1_CH3. + * | | |0100 = ADC1_CH4. + * | | |0101 = ADC1_CH5. + * | | |0110 = ADC1_CH6. + * | | |0111 = ADC1_CH7. + * | | |1000 = OPA1_O. + * | | |Other = reversed. + * |[24] |ADOVIF |All A/D Interrupt Flag Overrun Bits Check + * | | |0 = None of ADINT interrupt flag ADFOVx (ADIFOVR [15:0]) is overwritten to 1. + * | | |1 = Any one of ADINT interrupt flag ADFOVx (ADIFOVR [15:0]) is overwritten to 1. + * | | |Note: This bit will keep 1 when any ADFOVx (ADIFOVR [15:0]) Flag is equal to 1. + * |[25] |STOVF |For All A/D SAMPLE Start Of Conversion Overrun Flags Check + * | | |0 = None of SAMPLE event overrun flag SPOVFx (ADSPOVFR [15:0]) is set to 1. + * | | |1 = Any one of SAMPLE event overrun flag SPOVFx (ADSPOVFR [15:0]) is set to 1. + * | | |Note: This bit will keep 1 when any SPOVFx (ADSPOVFR [15:0]) Flag is equal to 1. + * |[26] |AVALID |For All SAMPLE A/D Result Data Register ADDR Data Valid Flag Check + * | | |0 = None of SAMPLE data register valid flag VALIDx (EADC_ADnDATx[17]) is set to 1. + * | | |1 = Any one of SAMPLE data register valid flag VALIDx (EADC_ADnDATx[17]) is set to 1. + * | | |Note: This bit will keep 1 when any VALIDx (EADC_ADnDATx[17]) Flag is equal to 1. + * |[27] |AOV |For All SAMPLE A/D Result Data Register Overrun Flags Check + * | | |0 = None of SAMPLE data register overrun flag OVx (EADC_ADnDATx[16]) is set to 1. + * | | |1 = Any one of SAMPLE data register overrun flag OVx (EADC_ADnDATx[16]) is set to 1. + * | | |Note: This bit will keep 1 when any OVx (EADC_ADnDATx[16]) Flag is equal to 1. + */ + __IO uint32_t STATUS1; + + /** + * EXTSMPT + * =================================================================================================== + * Offset: 0xB8 A/D Timing Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |EXTSMPT0 |ADC0 Extend Sampling Time + * | | |When A/D converting at high conversion rate, the sampling time of analog input voltage may not enough if input channel loading is heavy, SW can extend A/D sampling time after trigger source is coming to get enough sampling time. + * | | |The range of start delay time is from 0~255 ADC clock. + * |[16:23] |EXTSMPT1 |ADC1 Extend Sampling Time + * | | |When A/D converting at high conversion rate, the sampling time of analog input voltage may not enough if input channel loading is heavy, SW can extend A/D sampling time after trigger source is coming to get enough sampling time. + * | | |The range of start delay time is from 0~255 ADC clock. + */ + __IO uint32_t EXTSMPT; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[17]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * AD0DDAT0 + * =================================================================================================== + * Offset: 0x100 A/D double Data Register 0 for SAMPLE00 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DDAT0; + + /** + * AD0DDAT1 + * =================================================================================================== + * Offset: 0x104 A/D double Data Register 1 for SAMPLE01 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DDAT1; + + /** + * AD0DDAT2 + * =================================================================================================== + * Offset: 0x108 A/D double Data Register 2 for SAMPLE02 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DDAT2; + + /** + * AD0DDAT3 + * =================================================================================================== + * Offset: 0x10C A/D double Data Register 3 for SAMPLE03 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD0DDAT3; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE3[4]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * AD1DDAT0 + * =================================================================================================== + * Offset: 0x120 A/D double Data Register 0 for SAMPLE10 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DDAT0; + + /** + * AD1DDAT1 + * =================================================================================================== + * Offset: 0x124 A/D double Data Register 1 for SAMPLE11 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DDAT1; + + /** + * AD1DDAT2 + * =================================================================================================== + * Offset: 0x128 A/D double Data Register 2 for SAMPLE12 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DDAT2; + + /** + * AD1DDAT3 + * =================================================================================================== + * Offset: 0x12C A/D double Data Register 3 for SAMPLE13 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |RESULT |A/D Conversion Result + * | | |This field contains 12 bits conversion result. + * |[16] |VALID |Valid Flag + * | | |0 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is not valid. + * | | |1 = Double buffer data in RESULT (EADC_ADnDATx[11:0]) bits is valid. + * | | |This bit is set to 1 when corresponding SAMPLE channel analog input conversion is completed and cleared by hardware after EADC_ADnDATx register is read. + */ + __I uint32_t AD1DDAT3; + + /** + * DBMEN + * =================================================================================================== + * Offset: 0x130 A/D Double Buffer Mode select + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |AD0DBM0 |Double Buffer Mode For SAMPLE00 + * | | |0 = SAMPLE00 has one sample result register. (default). + * | | |1 =SAMPLE00 has two sample result registers. + * |[1] |AD0DBM1 |Double Buffer Mode For SAMPLE01 + * | | |0 = SAMPLE01 has one sample result register. (default). + * | | |1 = SAMPLE01 has two sample result registers. + * |[2] |AD0DBM2 |Double Buffer Mode For SAMPLE02 + * | | |0 = SAMPLE02 has one sample result register. (default). + * | | |1 =SAMPLE02 has two sample result registers. + * |[3] |AD0DBM3 |Double Buffer Mode For SAMPLE03 + * | | |0 = SAMPLE03 has one sample result register. (default). + * | | |1 =SAMPLE03 has two sample result registers. + * |[8] |AD1DBM0 |Double Buffer Mode For SAMPLE10 + * | | |0 = SAMPLE10 has one sample result register. (default) + * | | |1 =SAMPLE10 has two sample result registers. + * |[9] |AD1DBM1 |Double Buffer Mode For SAMPLE11 + * | | |0 = SAMPLE11 has one sample result register. (default). + * | | |1 =SAMPLE11 has two sample result registers. + * |[10] |AD1DBM2 |Double Buffer Mode For SAMPLE12 + * | | |0 = SAMPLE12 has one sample result register. (default). + * | | |1 =SAMPLE12 has two sample result registers. + * |[11] |AD1DBM3 |Double Buffer Mode For SAMPLE13 + * | | |0 = SAMPLE13 has one sample result register. (default) + * | | |1 =SAMPLE13 has two sample result registers. + */ + __IO uint32_t DBMEN; + + /** + * INTSRC0 + * =================================================================================================== + * Offset: 0x134 A/D Interrupt 0 Source Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |AD0SPIE0 |SAMPLE00 Interrupt Mask Enable Control + * | | |0 = SAMPLE00 interrupt mask Disabled. + * | | |1 = SAMPLE00 interrupt mask Enabled. + * |[1] |AD0SPIE1 |SAMPLE01 Interrupt Mask Enable Control + * | | |0 = SAMPLE01 interrupt mask Disabled. + * | | |1 = SAMPLE01 interrupt mask Enabled. + * |[2] |AD0SPIE2 |SAMPLE02 Interrupt Mask Enable Control + * | | |0 = SAMPLE02 interrupt mask Disabled. + * | | |1 = SAMPLE02 interrupt mask Enabled. + * |[3] |AD0SPIE3 |SAMPLE03 Interrupt Mask Enable Control + * | | |0 = SAMPLE03 interrupt mask Disabled. + * | | |1 = SAMPLE03 interrupt mask Enabled. + * |[4] |AD0SPIE4 |SAMPLE04 Interrupt Mask Enable Control + * | | |0 = SAMPLE04 interrupt mask Disabled. + * | | |1 = SAMPLE04 interrupt mask Enabled. + * |[5] |AD0SPIE5 |SAMPLE05 Interrupt Mask Enable Control + * | | |0 = SAMPLE05 interrupt mask Disabled. + * | | |1 = SAMPLE05 interrupt mask Enabled. + * |[6] |AD0SPIE6 |SAMPLE06 Interrupt Mask Enable Control + * | | |0 = SAMPLE06 interrupt mask Disabled. + * | | |1 = SAMPLE06 interrupt mask Enabled. + * |[7] |AD0SPIE7 |SAMPLE07 Interrupt Mask Enable Control + * | | |0 = SAMPLE07 interrupt mask Disabled. + * | | |1 = SAMPLE07 interrupt mask Enabled. + * |[8] |AD1SPIE0 |SAMPLE10 Interrupt Mask Enable Control + * | | |0 = SAMPLE10 interrupt mask Disabled. + * | | |1 = SAMPLE10 interrupt mask Enabled. + * |[9] |AD1SPIE1 |SAMPLE11 Interrupt Mask Enable Control + * | | |0 = SAMPLE11 interrupt mask Disabled. + * | | |1 = SAMPLE11 interrupt mask Enabled. + * |[10] |AD1SPIE2 |SAMPLE12 Interrupt Mask Enable Control + * | | |0 = SAMPLE12 interrupt mask Disabled. + * | | |1 = SAMPLE12 interrupt mask Enabled. + * |[11] |AD1SPIE3 |SAMPLE13 Interrupt Mask Enable Control + * | | |0 = SAMPLE13 interrupt mask Disabled. + * | | |1 = SAMPLE13 interrupt mask Enabled. + * |[12] |AD1SPIE4 |SAMPLE14 Interrupt Mask Enable Control + * | | |0 = SAMPLE14 interrupt mask Disabled. + * | | |1 = SAMPLE14 interrupt mask Enabled. + * |[13] |AD1SPIE5 |SAMPLE15 Interrupt Mask Enable Control + * | | |0 = SAMPLE15 interrupt mask Disabled. + * | | |1 = SAMPLE15 interrupt mask Enabled. + * |[14] |AD1SPIE6 |SAMPLE16 Interrupt Mask Enable Control + * | | |0 = SAMPLE16 interrupt mask Disabled. + * | | |1 = SAMPLE16 interrupt mask Enabled. + * |[15] |AD1SPIE7 |SAMPLE17 Interrupt Mask Enable Control + * | | |0 = SAMPLE17 interrupt mask Disabled. + * | | |1 = SAMPLE17 interrupt mask Enabled. + */ + __IO uint32_t INTSRC[4]; + + /** + * AD0TRGEN0 + * =================================================================================================== + * Offset: 0x144 A/D trigger condition for SAMPLE00 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD0TRGEN0; + + /** + * AD0TRGEN1 + * =================================================================================================== + * Offset: 0x148 A/D trigger condition for SAMPLE01 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD0TRGEN1; + + /** + * AD0TRGEN2 + * =================================================================================================== + * Offset: 0x14C A/D trigger condition for SAMPLE02 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD0TRGEN2; + + /** + * AD0TRGEN3 + * =================================================================================================== + * Offset: 0x150 A/D trigger condition for SAMPLE03 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD0TRGEN3; + + /** + * AD1TRGEN0 + * =================================================================================================== + * Offset: 0x154 A/D trigger condition for SAMPLE10 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD1TRGEN0; + + /** + * AD1TRGEN1 + * =================================================================================================== + * Offset: 0x158 A/D trigger condition for SAMPLE11 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD1TRGEN1; + + /** + * AD1TRGEN2 + * =================================================================================================== + * Offset: 0x15C A/D trigger condition for SAMPLE12 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD1TRGEN2; + + /** + * AD1TRGEN3 + * =================================================================================================== + * Offset: 0x160 A/D trigger condition for SAMPLE13 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPWM00REN |EPWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |EPWM00FEN |EPWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |EPWM00PEN |EPWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |EPWM00CEN |EPWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |EPWM02REN |EPWM0_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |EPWM02FEN |EPWM0_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |EPWM02PEN |EPWM0_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[7] |EPWM02CEN |EPWM0_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |EPWM04REN |EPWM0_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[9] |EPWM04FEN |EPWM0_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[10] |EPWM04PEN |EPWM0_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[11] |EPWM04CEN |EPWM0_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[12] |EPWM10REN |EPWM1_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |EPWM10FEN |EPWM1_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |EPWM10PEN |EPWM1_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[15] |EPWM10CEN |EPWM1_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[16] |EPWM12REN |EPWM1_CH2 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[17] |EPWM120FEN|EPWM1_CH2 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[18] |EPWM12PEN |EPWM1_CH2 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[19] |EPWM12CEN |EPWM1_CH2 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[20] |EPWM14REN |EPWM1_CH4 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[21] |EPWM14FEN |EPWM1_CH4 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[22] |EPWM14PEN |EPWM1_CH4 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[23] |EPWM14CEN |EPWM1_CH4 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[24] |PWM00REN |PWM0_CH0 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[25] |PWM00FEN |PWM0_CH0 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[26] |PWM00PEN |PWM0_CH0 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[27] |PWM00CEN |PWM0_CH0 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[28] |PWM01REN |PWM0_CH1 Rising Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[29] |PWM01FEN |PWM0_CH1 Falling Edge Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |PWM01PEN |PWM0_CH1 Period Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[31] |PWM01CEN |PWM0_CH1 Center Trigger Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + */ + __IO uint32_t AD1TRGEN3; + +} EADC_T; + +/** + @addtogroup EADC_CONST EADC Bit Field Definition + Constant Definitions for EADC Controller +@{ */ + +#define EADC_AD0DAT0_RESULT_Pos (0) /*!< EADC_T::AD0DAT0: RESULT Position */ +#define EADC_AD0DAT0_RESULT_Msk (0xffful << EADC_AD0DAT0_RESULT_Pos) /*!< EADC_T::AD0DAT0: RESULT Mask */ + +#define EADC_AD0DAT0_OV_Pos (16) /*!< EADC_T::AD0DAT0: OV Position */ +#define EADC_AD0DAT0_OV_Msk (0x1ul << EADC_AD0DAT0_OV_Pos) /*!< EADC_T::AD0DAT0: OV Mask */ + +#define EADC_AD0DAT0_VALID_Pos (17) /*!< EADC_T::AD0DAT0: VALID Position */ +#define EADC_AD0DAT0_VALID_Msk (0x1ul << EADC_AD0DAT0_VALID_Pos) /*!< EADC_T::AD0DAT0: VALID Mask */ + +#define EADC_AD0DAT1_RESULT_Pos (0) /*!< EADC_T::AD0DAT1: RESULT Position */ +#define EADC_AD0DAT1_RESULT_Msk (0xffful << EADC_AD0DAT1_RESULT_Pos) /*!< EADC_T::AD0DAT1: RESULT Mask */ + +#define EADC_AD0DAT1_OV_Pos (16) /*!< EADC_T::AD0DAT1: OV Position */ +#define EADC_AD0DAT1_OV_Msk (0x1ul << EADC_AD0DAT1_OV_Pos) /*!< EADC_T::AD0DAT1: OV Mask */ + +#define EADC_AD0DAT1_VALID_Pos (17) /*!< EADC_T::AD0DAT1: VALID Position */ +#define EADC_AD0DAT1_VALID_Msk (0x1ul << EADC_AD0DAT1_VALID_Pos) /*!< EADC_T::AD0DAT1: VALID Mask */ + +#define EADC_AD0DAT2_RESULT_Pos (0) /*!< EADC_T::AD0DAT2: RESULT Position */ +#define EADC_AD0DAT2_RESULT_Msk (0xffful << EADC_AD0DAT2_RESULT_Pos) /*!< EADC_T::AD0DAT2: RESULT Mask */ + +#define EADC_AD0DAT2_OV_Pos (16) /*!< EADC_T::AD0DAT2: OV Position */ +#define EADC_AD0DAT2_OV_Msk (0x1ul << EADC_AD0DAT2_OV_Pos) /*!< EADC_T::AD0DAT2: OV Mask */ + +#define EADC_AD0DAT2_VALID_Pos (17) /*!< EADC_T::AD0DAT2: VALID Position */ +#define EADC_AD0DAT2_VALID_Msk (0x1ul << EADC_AD0DAT2_VALID_Pos) /*!< EADC_T::AD0DAT2: VALID Mask */ + +#define EADC_AD0DAT3_RESULT_Pos (0) /*!< EADC_T::AD0DAT3: RESULT Position */ +#define EADC_AD0DAT3_RESULT_Msk (0xffful << EADC_AD0DAT3_RESULT_Pos) /*!< EADC_T::AD0DAT3: RESULT Mask */ + +#define EADC_AD0DAT3_OV_Pos (16) /*!< EADC_T::AD0DAT3: OV Position */ +#define EADC_AD0DAT3_OV_Msk (0x1ul << EADC_AD0DAT3_OV_Pos) /*!< EADC_T::AD0DAT3: OV Mask */ + +#define EADC_AD0DAT3_VALID_Pos (17) /*!< EADC_T::AD0DAT3: VALID Position */ +#define EADC_AD0DAT3_VALID_Msk (0x1ul << EADC_AD0DAT3_VALID_Pos) /*!< EADC_T::AD0DAT3: VALID Mask */ + +#define EADC_AD0DAT4_RESULT_Pos (0) /*!< EADC_T::AD0DAT4: RESULT Position */ +#define EADC_AD0DAT4_RESULT_Msk (0xffful << EADC_AD0DAT4_RESULT_Pos) /*!< EADC_T::AD0DAT4: RESULT Mask */ + +#define EADC_AD0DAT4_OV_Pos (16) /*!< EADC_T::AD0DAT4: OV Position */ +#define EADC_AD0DAT4_OV_Msk (0x1ul << EADC_AD0DAT4_OV_Pos) /*!< EADC_T::AD0DAT4: OV Mask */ + +#define EADC_AD0DAT4_VALID_Pos (17) /*!< EADC_T::AD0DAT4: VALID Position */ +#define EADC_AD0DAT4_VALID_Msk (0x1ul << EADC_AD0DAT4_VALID_Pos) /*!< EADC_T::AD0DAT4: VALID Mask */ + +#define EADC_AD0DAT5_RESULT_Pos (0) /*!< EADC_T::AD0DAT5: RESULT Position */ +#define EADC_AD0DAT5_RESULT_Msk (0xffful << EADC_AD0DAT5_RESULT_Pos) /*!< EADC_T::AD0DAT5: RESULT Mask */ + +#define EADC_AD0DAT5_OV_Pos (16) /*!< EADC_T::AD0DAT5: OV Position */ +#define EADC_AD0DAT5_OV_Msk (0x1ul << EADC_AD0DAT5_OV_Pos) /*!< EADC_T::AD0DAT5: OV Mask */ + +#define EADC_AD0DAT5_VALID_Pos (17) /*!< EADC_T::AD0DAT5: VALID Position */ +#define EADC_AD0DAT5_VALID_Msk (0x1ul << EADC_AD0DAT5_VALID_Pos) /*!< EADC_T::AD0DAT5: VALID Mask */ + +#define EADC_AD0DAT6_RESULT_Pos (0) /*!< EADC_T::AD0DAT6: RESULT Position */ +#define EADC_AD0DAT6_RESULT_Msk (0xffful << EADC_AD0DAT6_RESULT_Pos) /*!< EADC_T::AD0DAT6: RESULT Mask */ + +#define EADC_AD0DAT6_OV_Pos (16) /*!< EADC_T::AD0DAT6: OV Position */ +#define EADC_AD0DAT6_OV_Msk (0x1ul << EADC_AD0DAT6_OV_Pos) /*!< EADC_T::AD0DAT6: OV Mask */ + +#define EADC_AD0DAT6_VALID_Pos (17) /*!< EADC_T::AD0DAT6: VALID Position */ +#define EADC_AD0DAT6_VALID_Msk (0x1ul << EADC_AD0DAT6_VALID_Pos) /*!< EADC_T::AD0DAT6: VALID Mask */ + +#define EADC_AD0DAT7_RESULT_Pos (0) /*!< EADC_T::AD0DAT7: RESULT Position */ +#define EADC_AD0DAT7_RESULT_Msk (0xffful << EADC_AD0DAT7_RESULT_Pos) /*!< EADC_T::AD0DAT7: RESULT Mask */ + +#define EADC_AD0DAT7_OV_Pos (16) /*!< EADC_T::AD0DAT7: OV Position */ +#define EADC_AD0DAT7_OV_Msk (0x1ul << EADC_AD0DAT7_OV_Pos) /*!< EADC_T::AD0DAT7: OV Mask */ + +#define EADC_AD0DAT7_VALID_Pos (17) /*!< EADC_T::AD0DAT7: VALID Position */ +#define EADC_AD0DAT7_VALID_Msk (0x1ul << EADC_AD0DAT7_VALID_Pos) /*!< EADC_T::AD0DAT7: VALID Mask */ + +#define EADC_AD1DAT0_RESULT_Pos (0) /*!< EADC_T::AD1DAT0: RESULT Position */ +#define EADC_AD1DAT0_RESULT_Msk (0xffful << EADC_AD1DAT0_RESULT_Pos) /*!< EADC_T::AD1DAT0: RESULT Mask */ + +#define EADC_AD1DAT0_OV_Pos (16) /*!< EADC_T::AD1DAT0: OV Position */ +#define EADC_AD1DAT0_OV_Msk (0x1ul << EADC_AD1DAT0_OV_Pos) /*!< EADC_T::AD1DAT0: OV Mask */ + +#define EADC_AD1DAT0_VALID_Pos (17) /*!< EADC_T::AD1DAT0: VALID Position */ +#define EADC_AD1DAT0_VALID_Msk (0x1ul << EADC_AD1DAT0_VALID_Pos) /*!< EADC_T::AD1DAT0: VALID Mask */ + +#define EADC_AD1DAT1_RESULT_Pos (0) /*!< EADC_T::AD1DAT1: RESULT Position */ +#define EADC_AD1DAT1_RESULT_Msk (0xffful << EADC_AD1DAT1_RESULT_Pos) /*!< EADC_T::AD1DAT1: RESULT Mask */ + +#define EADC_AD1DAT1_OV_Pos (16) /*!< EADC_T::AD1DAT1: OV Position */ +#define EADC_AD1DAT1_OV_Msk (0x1ul << EADC_AD1DAT1_OV_Pos) /*!< EADC_T::AD1DAT1: OV Mask */ + +#define EADC_AD1DAT1_VALID_Pos (17) /*!< EADC_T::AD1DAT1: VALID Position */ +#define EADC_AD1DAT1_VALID_Msk (0x1ul << EADC_AD1DAT1_VALID_Pos) /*!< EADC_T::AD1DAT1: VALID Mask */ + +#define EADC_AD1DAT2_RESULT_Pos (0) /*!< EADC_T::AD1DAT2: RESULT Position */ +#define EADC_AD1DAT2_RESULT_Msk (0xffful << EADC_AD1DAT2_RESULT_Pos) /*!< EADC_T::AD1DAT2: RESULT Mask */ + +#define EADC_AD1DAT2_OV_Pos (16) /*!< EADC_T::AD1DAT2: OV Position */ +#define EADC_AD1DAT2_OV_Msk (0x1ul << EADC_AD1DAT2_OV_Pos) /*!< EADC_T::AD1DAT2: OV Mask */ + +#define EADC_AD1DAT2_VALID_Pos (17) /*!< EADC_T::AD1DAT2: VALID Position */ +#define EADC_AD1DAT2_VALID_Msk (0x1ul << EADC_AD1DAT2_VALID_Pos) /*!< EADC_T::AD1DAT2: VALID Mask */ + +#define EADC_AD1DAT3_RESULT_Pos (0) /*!< EADC_T::AD1DAT3: RESULT Position */ +#define EADC_AD1DAT3_RESULT_Msk (0xffful << EADC_AD1DAT3_RESULT_Pos) /*!< EADC_T::AD1DAT3: RESULT Mask */ + +#define EADC_AD1DAT3_OV_Pos (16) /*!< EADC_T::AD1DAT3: OV Position */ +#define EADC_AD1DAT3_OV_Msk (0x1ul << EADC_AD1DAT3_OV_Pos) /*!< EADC_T::AD1DAT3: OV Mask */ + +#define EADC_AD1DAT3_VALID_Pos (17) /*!< EADC_T::AD1DAT3: VALID Position */ +#define EADC_AD1DAT3_VALID_Msk (0x1ul << EADC_AD1DAT3_VALID_Pos) /*!< EADC_T::AD1DAT3: VALID Mask */ + +#define EADC_AD1DAT4_RESULT_Pos (0) /*!< EADC_T::AD1DAT4: RESULT Position */ +#define EADC_AD1DAT4_RESULT_Msk (0xffful << EADC_AD1DAT4_RESULT_Pos) /*!< EADC_T::AD1DAT4: RESULT Mask */ + +#define EADC_AD1DAT4_OV_Pos (16) /*!< EADC_T::AD1DAT4: OV Position */ +#define EADC_AD1DAT4_OV_Msk (0x1ul << EADC_AD1DAT4_OV_Pos) /*!< EADC_T::AD1DAT4: OV Mask */ + +#define EADC_AD1DAT4_VALID_Pos (17) /*!< EADC_T::AD1DAT4: VALID Position */ +#define EADC_AD1DAT4_VALID_Msk (0x1ul << EADC_AD1DAT4_VALID_Pos) /*!< EADC_T::AD1DAT4: VALID Mask */ + +#define EADC_AD1DAT5_RESULT_Pos (0) /*!< EADC_T::AD1DAT5: RESULT Position */ +#define EADC_AD1DAT5_RESULT_Msk (0xffful << EADC_AD1DAT5_RESULT_Pos) /*!< EADC_T::AD1DAT5: RESULT Mask */ + +#define EADC_AD1DAT5_OV_Pos (16) /*!< EADC_T::AD1DAT5: OV Position */ +#define EADC_AD1DAT5_OV_Msk (0x1ul << EADC_AD1DAT5_OV_Pos) /*!< EADC_T::AD1DAT5: OV Mask */ + +#define EADC_AD1DAT5_VALID_Pos (17) /*!< EADC_T::AD1DAT5: VALID Position */ +#define EADC_AD1DAT5_VALID_Msk (0x1ul << EADC_AD1DAT5_VALID_Pos) /*!< EADC_T::AD1DAT5: VALID Mask */ + +#define EADC_AD1DAT6_RESULT_Pos (0) /*!< EADC_T::AD1DAT6: RESULT Position */ +#define EADC_AD1DAT6_RESULT_Msk (0xffful << EADC_AD1DAT6_RESULT_Pos) /*!< EADC_T::AD1DAT6: RESULT Mask */ + +#define EADC_AD1DAT6_OV_Pos (16) /*!< EADC_T::AD1DAT6: OV Position */ +#define EADC_AD1DAT6_OV_Msk (0x1ul << EADC_AD1DAT6_OV_Pos) /*!< EADC_T::AD1DAT6: OV Mask */ + +#define EADC_AD1DAT6_VALID_Pos (17) /*!< EADC_T::AD1DAT6: VALID Position */ +#define EADC_AD1DAT6_VALID_Msk (0x1ul << EADC_AD1DAT6_VALID_Pos) /*!< EADC_T::AD1DAT6: VALID Mask */ + +#define EADC_AD1DAT7_RESULT_Pos (0) /*!< EADC_T::AD1DAT7: RESULT Position */ +#define EADC_AD1DAT7_RESULT_Msk (0xffful << EADC_AD1DAT7_RESULT_Pos) /*!< EADC_T::AD1DAT7: RESULT Mask */ + +#define EADC_AD1DAT7_OV_Pos (16) /*!< EADC_T::AD1DAT7: OV Position */ +#define EADC_AD1DAT7_OV_Msk (0x1ul << EADC_AD1DAT7_OV_Pos) /*!< EADC_T::AD1DAT7: OV Mask */ + +#define EADC_AD1DAT7_VALID_Pos (17) /*!< EADC_T::AD1DAT7: VALID Position */ +#define EADC_AD1DAT7_VALID_Msk (0x1ul << EADC_AD1DAT7_VALID_Pos) /*!< EADC_T::AD1DAT7: VALID Mask */ + +#define EADC_CTL_ADCEN_Pos (0) /*!< EADC_T::CTL: ADCEN Position */ +#define EADC_CTL_ADCEN_Msk (0x1ul << EADC_CTL_ADCEN_Pos) /*!< EADC_T::CTL: ADCEN Mask */ + +#define EADC_CTL_ADCRST_Pos (1) /*!< EADC_T::CTL: ADCRST Position */ +#define EADC_CTL_ADCRST_Msk (0x1ul << EADC_CTL_ADCRST_Pos) /*!< EADC_T::CTL: ADCRST Mask */ + +#define EADC_CTL_ADCIEN0_Pos (2) /*!< EADC_T::CTL: ADCIEN0 Position */ +#define EADC_CTL_ADCIEN0_Msk (0x1ul << EADC_CTL_ADCIEN0_Pos) /*!< EADC_T::CTL: ADCIEN0 Mask */ + +#define EADC_CTL_ADCIEN1_Pos (3) /*!< EADC_T::CTL: ADCIEN1 Position */ +#define EADC_CTL_ADCIEN1_Msk (0x1ul << EADC_CTL_ADCIEN1_Pos) /*!< EADC_T::CTL: ADCIEN1 Mask */ + +#define EADC_CTL_ADCIEN2_Pos (4) /*!< EADC_T::CTL: ADCIEN2 Position */ +#define EADC_CTL_ADCIEN2_Msk (0x1ul << EADC_CTL_ADCIEN2_Pos) /*!< EADC_T::CTL: ADCIEN2 Mask */ + +#define EADC_CTL_ADCIEN3_Pos (5) /*!< EADC_T::CTL: ADCIEN3 Position */ +#define EADC_CTL_ADCIEN3_Msk (0x1ul << EADC_CTL_ADCIEN3_Pos) /*!< EADC_T::CTL: ADCIEN3 Mask */ + +#define EADC_SWTRG_SWTRG7_0_Pos (0) /*!< EADC_T::SWTRG: SWTRG7_0 Position */ +#define EADC_SWTRG_SWTRG7_0_Msk (0xfful << EADC_SWTRG_SWTRG7_0_Pos) /*!< EADC_T::SWTRG: SWTRG7_0 Mask */ + +#define EADC_SWTRG_SWTRG15_8_Pos (8) /*!< EADC_T::SWTRG: SWTRG15_8 Position */ +#define EADC_SWTRG_SWTRG15_8_Msk (0xfful << EADC_SWTRG_SWTRG15_8_Pos) /*!< EADC_T::SWTRG: SWTRG15_8 Mask */ + +#define EADC_PENDSTS_STPF7_0_Pos (0) /*!< EADC_T::PENDSTS: STPF7_0 Position */ +#define EADC_PENDSTS_STPF7_0_Msk (0xfful << EADC_PENDSTS_STPF7_0_Pos) /*!< EADC_T::PENDSTS: STPF7_0 Mask */ + +#define EADC_PENDSTS_STPF15_8_Pos (8) /*!< EADC_T::PENDSTS: STPF15_8 Position */ +#define EADC_PENDSTS_STPF15_8_Msk (0xfful << EADC_PENDSTS_STPF15_8_Pos) /*!< EADC_T::PENDSTS: STPF15_8 Mask */ + +#define EADC_ADIFOV_ADFOV0_Pos (0) /*!< EADC_T::ADIFOV: ADFOV0 Position */ +#define EADC_ADIFOV_ADFOV0_Msk (0x1ul << EADC_ADIFOV_ADFOV0_Pos) /*!< EADC_T::ADIFOV: ADFOV0 Mask */ + +#define EADC_ADIFOV_ADFOV1_Pos (1) /*!< EADC_T::ADIFOV: ADFOV1 Position */ +#define EADC_ADIFOV_ADFOV1_Msk (0x1ul << EADC_ADIFOV_ADFOV1_Pos) /*!< EADC_T::ADIFOV: ADFOV1 Mask */ + +#define EADC_ADIFOV_ADFOV2_Pos (2) /*!< EADC_T::ADIFOV: ADFOV2 Position */ +#define EADC_ADIFOV_ADFOV2_Msk (0x1ul << EADC_ADIFOV_ADFOV2_Pos) /*!< EADC_T::ADIFOV: ADFOV2 Mask */ + +#define EADC_ADIFOV_ADFOV3_Pos (3) /*!< EADC_T::ADIFOV: ADFOV3 Position */ +#define EADC_ADIFOV_ADFOV3_Msk (0x1ul << EADC_ADIFOV_ADFOV3_Pos) /*!< EADC_T::ADIFOV: ADFOV3 Mask */ + +#define EADC_OVSTS_SPOVF7_0_Pos (0) /*!< EADC_T::OVSTS: SPOVF7_0 Position */ +#define EADC_OVSTS_SPOVF7_0_Msk (0xfful << EADC_OVSTS_SPOVF7_0_Pos) /*!< EADC_T::OVSTS: SPOVF7_0 Mask */ + +#define EADC_OVSTS_SPOVF15_8_Pos (8) /*!< EADC_T::OVSTS: SPOVF15_8 Position */ +#define EADC_OVSTS_SPOVF15_8_Msk (0xfful << EADC_OVSTS_SPOVF15_8_Pos) /*!< EADC_T::OVSTS: SPOVF15_8 Mask */ + +#define EADC_AD0SPCTL0_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL0: CHSEL Position */ +#define EADC_AD0SPCTL0_CHSEL_Msk (0xful << EADC_AD0SPCTL0_CHSEL_Pos) /*!< EADC_T::AD0SPCTL0: CHSEL Mask */ + +#define EADC_AD0SPCTL0_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL0: TRGSEL Position */ +#define EADC_AD0SPCTL0_TRGSEL_Msk (0xful << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL0: TRGSEL Mask */ + +#define EADC_AD0SPCTL0_TRGDLYCNT_Pos (8) /*!< EADC_T::AD0SPCTL0: TRGDLYCNT Position */ +#define EADC_AD0SPCTL0_TRGDLYCNT_Msk (0xfful << EADC_AD0SPCTL0_TRGDLYCNT_Pos) /*!< EADC_T::AD0SPCTL0: TRGDLYCNT Mask */ + +#define EADC_AD0SPCTL0_TRGDLYDIV_Pos (16) /*!< EADC_T::AD0SPCTL0: TRGDLYDIV Position */ +#define EADC_AD0SPCTL0_TRGDLYDIV_Msk (0x3ul << EADC_AD0SPCTL0_TRGDLYDIV_Pos) /*!< EADC_T::AD0SPCTL0: TRGDLYDIV Mask */ + +#define EADC_AD0SPCTL0_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL0: EXTREN Position */ +#define EADC_AD0SPCTL0_EXTREN_Msk (0x1ul << EADC_AD0SPCTL0_EXTREN_Pos) /*!< EADC_T::AD0SPCTL0: EXTREN Mask */ + +#define EADC_AD0SPCTL0_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL0: EXTFEN Position */ +#define EADC_AD0SPCTL0_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL0_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL0: EXTFEN Mask */ + +#define EADC_AD0SPCTL1_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL1: CHSEL Position */ +#define EADC_AD0SPCTL1_CHSEL_Msk (0xful << EADC_AD0SPCTL1_CHSEL_Pos) /*!< EADC_T::AD0SPCTL1: CHSEL Mask */ + +#define EADC_AD0SPCTL1_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL1: TRGSEL Position */ +#define EADC_AD0SPCTL1_TRGSEL_Msk (0xful << EADC_AD0SPCTL1_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL1: TRGSEL Mask */ + +#define EADC_AD0SPCTL1_TRGDLYCNT_Pos (8) /*!< EADC_T::AD0SPCTL1: TRGDLYCNT Position */ +#define EADC_AD0SPCTL1_TRGDLYCNT_Msk (0xfful << EADC_AD0SPCTL1_TRGDLYCNT_Pos) /*!< EADC_T::AD0SPCTL1: TRGDLYCNT Mask */ + +#define EADC_AD0SPCTL1_TRGDLYDIV_Pos (16) /*!< EADC_T::AD0SPCTL1: TRGDLYDIV Position */ +#define EADC_AD0SPCTL1_TRGDLYDIV_Msk (0x3ul << EADC_AD0SPCTL1_TRGDLYDIV_Pos) /*!< EADC_T::AD0SPCTL1: TRGDLYDIV Mask */ + +#define EADC_AD0SPCTL1_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL1: EXTREN Position */ +#define EADC_AD0SPCTL1_EXTREN_Msk (0x1ul << EADC_AD0SPCTL1_EXTREN_Pos) /*!< EADC_T::AD0SPCTL1: EXTREN Mask */ + +#define EADC_AD0SPCTL1_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL1: EXTFEN Position */ +#define EADC_AD0SPCTL1_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL1_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL1: EXTFEN Mask */ + +#define EADC_AD0SPCTL2_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL2: CHSEL Position */ +#define EADC_AD0SPCTL2_CHSEL_Msk (0xful << EADC_AD0SPCTL2_CHSEL_Pos) /*!< EADC_T::AD0SPCTL2: CHSEL Mask */ + +#define EADC_AD0SPCTL2_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL2: TRGSEL Position */ +#define EADC_AD0SPCTL2_TRGSEL_Msk (0xful << EADC_AD0SPCTL2_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL2: TRGSEL Mask */ + +#define EADC_AD0SPCTL2_TRGDLYCNT_Pos (8) /*!< EADC_T::AD0SPCTL2: TRGDLYCNT Position */ +#define EADC_AD0SPCTL2_TRGDLYCNT_Msk (0xfful << EADC_AD0SPCTL2_TRGDLYCNT_Pos) /*!< EADC_T::AD0SPCTL2: TRGDLYCNT Mask */ + +#define EADC_AD0SPCTL2_TRGDLYDIV_Pos (16) /*!< EADC_T::AD0SPCTL2: TRGDLYDIV Position */ +#define EADC_AD0SPCTL2_TRGDLYDIV_Msk (0x3ul << EADC_AD0SPCTL2_TRGDLYDIV_Pos) /*!< EADC_T::AD0SPCTL2: TRGDLYDIV Mask */ + +#define EADC_AD0SPCTL2_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL2: EXTREN Position */ +#define EADC_AD0SPCTL2_EXTREN_Msk (0x1ul << EADC_AD0SPCTL2_EXTREN_Pos) /*!< EADC_T::AD0SPCTL2: EXTREN Mask */ + +#define EADC_AD0SPCTL2_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL2: EXTFEN Position */ +#define EADC_AD0SPCTL2_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL2_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL2: EXTFEN Mask */ + +#define EADC_AD0SPCTL3_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL3: CHSEL Position */ +#define EADC_AD0SPCTL3_CHSEL_Msk (0xful << EADC_AD0SPCTL3_CHSEL_Pos) /*!< EADC_T::AD0SPCTL3: CHSEL Mask */ + +#define EADC_AD0SPCTL3_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL3: TRGSEL Position */ +#define EADC_AD0SPCTL3_TRGSEL_Msk (0xful << EADC_AD0SPCTL3_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL3: TRGSEL Mask */ + +#define EADC_AD0SPCTL3_TRGDLYCNT_Pos (8) /*!< EADC_T::AD0SPCTL3: TRGDLYCNT Position */ +#define EADC_AD0SPCTL3_TRGDLYCNT_Msk (0xfful << EADC_AD0SPCTL3_TRGDLYCNT_Pos) /*!< EADC_T::AD0SPCTL3: TRGDLYCNT Mask */ + +#define EADC_AD0SPCTL3_TRGDLYDIV_Pos (16) /*!< EADC_T::AD0SPCTL3: TRGDLYDIV Position */ +#define EADC_AD0SPCTL3_TRGDLYDIV_Msk (0x3ul << EADC_AD0SPCTL3_TRGDLYDIV_Pos) /*!< EADC_T::AD0SPCTL3: TRGDLYDIV Mask */ + +#define EADC_AD0SPCTL3_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL3: EXTREN Position */ +#define EADC_AD0SPCTL3_EXTREN_Msk (0x1ul << EADC_AD0SPCTL3_EXTREN_Pos) /*!< EADC_T::AD0SPCTL3: EXTREN Mask */ + +#define EADC_AD0SPCTL3_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL3: EXTFEN Position */ +#define EADC_AD0SPCTL3_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL3_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL3: EXTFEN Mask */ + +#define EADC_AD0SPCTL4_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL4: CHSEL Position */ +#define EADC_AD0SPCTL4_CHSEL_Msk (0xful << EADC_AD0SPCTL4_CHSEL_Pos) /*!< EADC_T::AD0SPCTL4: CHSEL Mask */ + +#define EADC_AD0SPCTL4_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL4: TRGSEL Position */ +#define EADC_AD0SPCTL4_TRGSEL_Msk (0x7ul << EADC_AD0SPCTL4_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL4: TRGSEL Mask */ + +#define EADC_AD0SPCTL4_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL4: EXTREN Position */ +#define EADC_AD0SPCTL4_EXTREN_Msk (0x1ul << EADC_AD0SPCTL4_EXTREN_Pos) /*!< EADC_T::AD0SPCTL4: EXTREN Mask */ + +#define EADC_AD0SPCTL4_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL4: EXTFEN Position */ +#define EADC_AD0SPCTL4_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL4_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL4: EXTFEN Mask */ + +#define EADC_AD0SPCTL5_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL5: CHSEL Position */ +#define EADC_AD0SPCTL5_CHSEL_Msk (0xful << EADC_AD0SPCTL5_CHSEL_Pos) /*!< EADC_T::AD0SPCTL5: CHSEL Mask */ + +#define EADC_AD0SPCTL5_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL5: TRGSEL Position */ +#define EADC_AD0SPCTL5_TRGSEL_Msk (0x7ul << EADC_AD0SPCTL5_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL5: TRGSEL Mask */ + +#define EADC_AD0SPCTL5_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL5: EXTREN Position */ +#define EADC_AD0SPCTL5_EXTREN_Msk (0x1ul << EADC_AD0SPCTL5_EXTREN_Pos) /*!< EADC_T::AD0SPCTL5: EXTREN Mask */ + +#define EADC_AD0SPCTL5_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL5: EXTFEN Position */ +#define EADC_AD0SPCTL5_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL5_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL5: EXTFEN Mask */ + +#define EADC_AD0SPCTL6_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL6: CHSEL Position */ +#define EADC_AD0SPCTL6_CHSEL_Msk (0xful << EADC_AD0SPCTL6_CHSEL_Pos) /*!< EADC_T::AD0SPCTL6: CHSEL Mask */ + +#define EADC_AD0SPCTL6_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL6: TRGSEL Position */ +#define EADC_AD0SPCTL6_TRGSEL_Msk (0x7ul << EADC_AD0SPCTL6_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL6: TRGSEL Mask */ + +#define EADC_AD0SPCTL6_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL6: EXTREN Position */ +#define EADC_AD0SPCTL6_EXTREN_Msk (0x1ul << EADC_AD0SPCTL6_EXTREN_Pos) /*!< EADC_T::AD0SPCTL6: EXTREN Mask */ + +#define EADC_AD0SPCTL6_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL6: EXTFEN Position */ +#define EADC_AD0SPCTL6_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL6_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL6: EXTFEN Mask */ + +#define EADC_AD0SPCTL7_CHSEL_Pos (0) /*!< EADC_T::AD0SPCTL7: CHSEL Position */ +#define EADC_AD0SPCTL7_CHSEL_Msk (0xful << EADC_AD0SPCTL7_CHSEL_Pos) /*!< EADC_T::AD0SPCTL7: CHSEL Mask */ + +#define EADC_AD0SPCTL7_TRGSEL_Pos (4) /*!< EADC_T::AD0SPCTL7: TRGSEL Position */ +#define EADC_AD0SPCTL7_TRGSEL_Msk (0x7ul << EADC_AD0SPCTL7_TRGSEL_Pos) /*!< EADC_T::AD0SPCTL7: TRGSEL Mask */ + +#define EADC_AD0SPCTL7_EXTREN_Pos (20) /*!< EADC_T::AD0SPCTL7: EXTREN Position */ +#define EADC_AD0SPCTL7_EXTREN_Msk (0x1ul << EADC_AD0SPCTL7_EXTREN_Pos) /*!< EADC_T::AD0SPCTL7: EXTREN Mask */ + +#define EADC_AD0SPCTL7_EXTFEN_Pos (21) /*!< EADC_T::AD0SPCTL7: EXTFEN Position */ +#define EADC_AD0SPCTL7_EXTFEN_Msk (0x1ul << EADC_AD0SPCTL7_EXTFEN_Pos) /*!< EADC_T::AD0SPCTL7: EXTFEN Mask */ + +#define EADC_AD1SPCTL0_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL0: CHSEL Position */ +#define EADC_AD1SPCTL0_CHSEL_Msk (0xful << EADC_AD1SPCTL0_CHSEL_Pos) /*!< EADC_T::AD1SPCTL0: CHSEL Mask */ + +#define EADC_AD1SPCTL0_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL0: TRGSEL Position */ +#define EADC_AD1SPCTL0_TRGSEL_Msk (0xful << EADC_AD1SPCTL0_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL0: TRGSEL Mask */ + +#define EADC_AD1SPCTL0_TRGDLYCNT_Pos (8) /*!< EADC_T::AD1SPCTL0: TRGDLYCNT Position */ +#define EADC_AD1SPCTL0_TRGDLYCNT_Msk (0xfful << EADC_AD1SPCTL0_TRGDLYCNT_Pos) /*!< EADC_T::AD1SPCTL0: TRGDLYCNT Mask */ + +#define EADC_AD1SPCTL0_TRGDLYDIV_Pos (16) /*!< EADC_T::AD1SPCTL0: TRGDLYDIV Position */ +#define EADC_AD1SPCTL0_TRGDLYDIV_Msk (0x3ul << EADC_AD1SPCTL0_TRGDLYDIV_Pos) /*!< EADC_T::AD1SPCTL0: TRGDLYDIV Mask */ + +#define EADC_AD1SPCTL0_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL0: EXTREN Position */ +#define EADC_AD1SPCTL0_EXTREN_Msk (0x1ul << EADC_AD1SPCTL0_EXTREN_Pos) /*!< EADC_T::AD1SPCTL0: EXTREN Mask */ + +#define EADC_AD1SPCTL0_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL0: EXTFEN Position */ +#define EADC_AD1SPCTL0_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL0_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL0: EXTFEN Mask */ + +#define EADC_AD1SPCTL1_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL1: CHSEL Position */ +#define EADC_AD1SPCTL1_CHSEL_Msk (0xful << EADC_AD1SPCTL1_CHSEL_Pos) /*!< EADC_T::AD1SPCTL1: CHSEL Mask */ + +#define EADC_AD1SPCTL1_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL1: TRGSEL Position */ +#define EADC_AD1SPCTL1_TRGSEL_Msk (0xful << EADC_AD1SPCTL1_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL1: TRGSEL Mask */ + +#define EADC_AD1SPCTL1_TRGDLYCNT_Pos (8) /*!< EADC_T::AD1SPCTL1: TRGDLYCNT Position */ +#define EADC_AD1SPCTL1_TRGDLYCNT_Msk (0xfful << EADC_AD1SPCTL1_TRGDLYCNT_Pos) /*!< EADC_T::AD1SPCTL1: TRGDLYCNT Mask */ + +#define EADC_AD1SPCTL1_TRGDLYDIV_Pos (16) /*!< EADC_T::AD1SPCTL1: TRGDLYDIV Position */ +#define EADC_AD1SPCTL1_TRGDLYDIV_Msk (0x3ul << EADC_AD1SPCTL1_TRGDLYDIV_Pos) /*!< EADC_T::AD1SPCTL1: TRGDLYDIV Mask */ + +#define EADC_AD1SPCTL1_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL1: EXTREN Position */ +#define EADC_AD1SPCTL1_EXTREN_Msk (0x1ul << EADC_AD1SPCTL1_EXTREN_Pos) /*!< EADC_T::AD1SPCTL1: EXTREN Mask */ + +#define EADC_AD1SPCTL1_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL1: EXTFEN Position */ +#define EADC_AD1SPCTL1_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL1_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL1: EXTFEN Mask */ + +#define EADC_AD1SPCTL2_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL2: CHSEL Position */ +#define EADC_AD1SPCTL2_CHSEL_Msk (0xful << EADC_AD1SPCTL2_CHSEL_Pos) /*!< EADC_T::AD1SPCTL2: CHSEL Mask */ + +#define EADC_AD1SPCTL2_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL2: TRGSEL Position */ +#define EADC_AD1SPCTL2_TRGSEL_Msk (0xful << EADC_AD1SPCTL2_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL2: TRGSEL Mask */ + +#define EADC_AD1SPCTL2_TRGDLYCNT_Pos (8) /*!< EADC_T::AD1SPCTL2: TRGDLYCNT Position */ +#define EADC_AD1SPCTL2_TRGDLYCNT_Msk (0xfful << EADC_AD1SPCTL2_TRGDLYCNT_Pos) /*!< EADC_T::AD1SPCTL2: TRGDLYCNT Mask */ + +#define EADC_AD1SPCTL2_TRGDLYDIV_Pos (16) /*!< EADC_T::AD1SPCTL2: TRGDLYDIV Position */ +#define EADC_AD1SPCTL2_TRGDLYDIV_Msk (0x3ul << EADC_AD1SPCTL2_TRGDLYDIV_Pos) /*!< EADC_T::AD1SPCTL2: TRGDLYDIV Mask */ + +#define EADC_AD1SPCTL2_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL2: EXTREN Position */ +#define EADC_AD1SPCTL2_EXTREN_Msk (0x1ul << EADC_AD1SPCTL2_EXTREN_Pos) /*!< EADC_T::AD1SPCTL2: EXTREN Mask */ + +#define EADC_AD1SPCTL2_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL2: EXTFEN Position */ +#define EADC_AD1SPCTL2_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL2_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL2: EXTFEN Mask */ + +#define EADC_AD1SPCTL3_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL3: CHSEL Position */ +#define EADC_AD1SPCTL3_CHSEL_Msk (0xful << EADC_AD1SPCTL3_CHSEL_Pos) /*!< EADC_T::AD1SPCTL3: CHSEL Mask */ + +#define EADC_AD1SPCTL3_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL3: TRGSEL Position */ +#define EADC_AD1SPCTL3_TRGSEL_Msk (0xful << EADC_AD1SPCTL3_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL3: TRGSEL Mask */ + +#define EADC_AD1SPCTL3_TRGDLYCNT_Pos (8) /*!< EADC_T::AD1SPCTL3: TRGDLYCNT Position */ +#define EADC_AD1SPCTL3_TRGDLYCNT_Msk (0xfful << EADC_AD1SPCTL3_TRGDLYCNT_Pos) /*!< EADC_T::AD1SPCTL3: TRGDLYCNT Mask */ + +#define EADC_AD1SPCTL3_TRGDLYDIV_Pos (16) /*!< EADC_T::AD1SPCTL3: TRGDLYDIV Position */ +#define EADC_AD1SPCTL3_TRGDLYDIV_Msk (0x3ul << EADC_AD1SPCTL3_TRGDLYDIV_Pos) /*!< EADC_T::AD1SPCTL3: TRGDLYDIV Mask */ + +#define EADC_AD1SPCTL3_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL3: EXTREN Position */ +#define EADC_AD1SPCTL3_EXTREN_Msk (0x1ul << EADC_AD1SPCTL3_EXTREN_Pos) /*!< EADC_T::AD1SPCTL3: EXTREN Mask */ + +#define EADC_AD1SPCTL3_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL3: EXTFEN Position */ +#define EADC_AD1SPCTL3_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL3_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL3: EXTFEN Mask */ + +#define EADC_AD1SPCTL4_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL4: CHSEL Position */ +#define EADC_AD1SPCTL4_CHSEL_Msk (0xful << EADC_AD1SPCTL4_CHSEL_Pos) /*!< EADC_T::AD1SPCTL4: CHSEL Mask */ + +#define EADC_AD1SPCTL4_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL4: TRGSEL Position */ +#define EADC_AD1SPCTL4_TRGSEL_Msk (0x7ul << EADC_AD1SPCTL4_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL4: TRGSEL Mask */ + +#define EADC_AD1SPCTL4_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL4: EXTREN Position */ +#define EADC_AD1SPCTL4_EXTREN_Msk (0x1ul << EADC_AD1SPCTL4_EXTREN_Pos) /*!< EADC_T::AD1SPCTL4: EXTREN Mask */ + +#define EADC_AD1SPCTL4_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL4: EXTFEN Position */ +#define EADC_AD1SPCTL4_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL4_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL4: EXTFEN Mask */ + +#define EADC_AD1SPCTL5_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL5: CHSEL Position */ +#define EADC_AD1SPCTL5_CHSEL_Msk (0xful << EADC_AD1SPCTL5_CHSEL_Pos) /*!< EADC_T::AD1SPCTL5: CHSEL Mask */ + +#define EADC_AD1SPCTL5_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL5: TRGSEL Position */ +#define EADC_AD1SPCTL5_TRGSEL_Msk (0x7ul << EADC_AD1SPCTL5_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL5: TRGSEL Mask */ + +#define EADC_AD1SPCTL5_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL5: EXTREN Position */ +#define EADC_AD1SPCTL5_EXTREN_Msk (0x1ul << EADC_AD1SPCTL5_EXTREN_Pos) /*!< EADC_T::AD1SPCTL5: EXTREN Mask */ + +#define EADC_AD1SPCTL5_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL5: EXTFEN Position */ +#define EADC_AD1SPCTL5_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL5_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL5: EXTFEN Mask */ + +#define EADC_AD1SPCTL6_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL6: CHSEL Position */ +#define EADC_AD1SPCTL6_CHSEL_Msk (0xful << EADC_AD1SPCTL6_CHSEL_Pos) /*!< EADC_T::AD1SPCTL6: CHSEL Mask */ + +#define EADC_AD1SPCTL6_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL6: TRGSEL Position */ +#define EADC_AD1SPCTL6_TRGSEL_Msk (0x7ul << EADC_AD1SPCTL6_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL6: TRGSEL Mask */ + +#define EADC_AD1SPCTL6_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL6: EXTREN Position */ +#define EADC_AD1SPCTL6_EXTREN_Msk (0x1ul << EADC_AD1SPCTL6_EXTREN_Pos) /*!< EADC_T::AD1SPCTL6: EXTREN Mask */ + +#define EADC_AD1SPCTL6_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL6: EXTFEN Position */ +#define EADC_AD1SPCTL6_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL6_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL6: EXTFEN Mask */ + +#define EADC_AD1SPCTL7_CHSEL_Pos (0) /*!< EADC_T::AD1SPCTL7: CHSEL Position */ +#define EADC_AD1SPCTL7_CHSEL_Msk (0xful << EADC_AD1SPCTL7_CHSEL_Pos) /*!< EADC_T::AD1SPCTL7: CHSEL Mask */ + +#define EADC_AD1SPCTL7_TRGSEL_Pos (4) /*!< EADC_T::AD1SPCTL7: TRGSEL Position */ +#define EADC_AD1SPCTL7_TRGSEL_Msk (0x7ul << EADC_AD1SPCTL7_TRGSEL_Pos) /*!< EADC_T::AD1SPCTL7: TRGSEL Mask */ + +#define EADC_AD1SPCTL7_EXTREN_Pos (20) /*!< EADC_T::AD1SPCTL7: EXTREN Position */ +#define EADC_AD1SPCTL7_EXTREN_Msk (0x1ul << EADC_AD1SPCTL7_EXTREN_Pos) /*!< EADC_T::AD1SPCTL7: EXTREN Mask */ + +#define EADC_AD1SPCTL7_EXTFEN_Pos (21) /*!< EADC_T::AD1SPCTL7: EXTFEN Position */ +#define EADC_AD1SPCTL7_EXTFEN_Msk (0x1ul << EADC_AD1SPCTL7_EXTFEN_Pos) /*!< EADC_T::AD1SPCTL7: EXTFEN Mask */ + +#define EADC_SIMUSEL_SIMUSEL0_Pos (0) /*!< EADC_T::SIMUSEL: SIMUSEL0 Position */ +#define EADC_SIMUSEL_SIMUSEL0_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL0_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL0 Mask */ + +#define EADC_SIMUSEL_SIMUSEL1_Pos (1) /*!< EADC_T::SIMUSEL: SIMUSEL1 Position */ +#define EADC_SIMUSEL_SIMUSEL1_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL1_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL1 Mask */ + +#define EADC_SIMUSEL_SIMUSEL2_Pos (2) /*!< EADC_T::SIMUSEL: SIMUSEL2 Position */ +#define EADC_SIMUSEL_SIMUSEL2_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL2_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL2 Mask */ + +#define EADC_SIMUSEL_SIMUSEL3_Pos (3) /*!< EADC_T::SIMUSEL: SIMUSEL3 Position */ +#define EADC_SIMUSEL_SIMUSEL3_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL3_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL3 Mask */ + +#define EADC_SIMUSEL_SIMUSEL4_Pos (4) /*!< EADC_T::SIMUSEL: SIMUSEL4 Position */ +#define EADC_SIMUSEL_SIMUSEL4_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL4_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL4 Mask */ + +#define EADC_SIMUSEL_SIMUSEL5_Pos (5) /*!< EADC_T::SIMUSEL: SIMUSEL5 Position */ +#define EADC_SIMUSEL_SIMUSEL5_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL5_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL5 Mask */ + +#define EADC_SIMUSEL_SIMUSEL6_Pos (6) /*!< EADC_T::SIMUSEL: SIMUSEL6 Position */ +#define EADC_SIMUSEL_SIMUSEL6_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL6_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL6 Mask */ + +#define EADC_SIMUSEL_SIMUSEL7_Pos (7) /*!< EADC_T::SIMUSEL: SIMUSEL7 Position */ +#define EADC_SIMUSEL_SIMUSEL7_Msk (0x1ul << EADC_SIMUSEL_SIMUSEL7_Pos) /*!< EADC_T::SIMUSEL: SIMUSEL7 Mask */ + +#define EADC_CMP0_ADCMPEN_Pos (0) /*!< EADC_T::CMP: ADCMPEN Position */ +#define EADC_CMP0_ADCMPEN_Msk (0x1ul << EADC_CMP0_ADCMPEN_Pos) /*!< EADC_T::CMP: ADCMPEN Mask */ + +#define EADC_CMP0_ADCMPIE_Pos (1) /*!< EADC_T::CMP: ADCMPIE Position */ +#define EADC_CMP0_ADCMPIE_Msk (0x1ul << EADC_CMP0_ADCMPIE_Pos) /*!< EADC_T::CMP: ADCMPIE Mask */ + +#define EADC_CMP0_CMPCOND_Pos (2) /*!< EADC_T::CMP: CMPCOND Position */ +#define EADC_CMP0_CMPCOND_Msk (0x1ul << EADC_CMP0_CMPCOND_Pos) /*!< EADC_T::CMP: CMPCOND Mask */ + +#define EADC_CMP0_CMPSPL_Pos (3) /*!< EADC_T::CMP: CMPSPL Position */ +#define EADC_CMP0_CMPSPL_Msk (0x7ul << EADC_CMP0_CMPSPL_Pos) /*!< EADC_T::CMP: CMPSPL Mask */ + +#define EADC_CMP0_CMPMCNT_Pos (8) /*!< EADC_T::CMP: CMPMCNT Position */ +#define EADC_CMP0_CMPMCNT_Msk (0xful << EADC_CMP0_CMPMCNT_Pos) /*!< EADC_T::CMP: CMPMCNT Mask */ + +#define EADC_CMP0_CMPDAT_Pos (16) /*!< EADC_T::CMP: CMPDAT Position */ +#define EADC_CMP0_CMPDAT_Msk (0xffful << EADC_CMP0_CMPDAT_Pos) /*!< EADC_T::CMP: CMPDAT Mask */ + +#define EADC_CMP1_ADCMPEN_Pos (0) /*!< EADC_T::CMP: ADCMPEN Position */ +#define EADC_CMP1_ADCMPEN_Msk (0x1ul << EADC_CMP1_ADCMPEN_Pos) /*!< EADC_T::CMP: ADCMPEN Mask */ + +#define EADC_CMP1_ADCMPIE_Pos (1) /*!< EADC_T::CMP: ADCMPIE Position */ +#define EADC_CMP1_ADCMPIE_Msk (0x1ul << EADC_CMP1_ADCMPIE_Pos) /*!< EADC_T::CMP: ADCMPIE Mask */ + +#define EADC_CMP1_CMPCOND_Pos (2) /*!< EADC_T::CMP: CMPCOND Position */ +#define EADC_CMP1_CMPCOND_Msk (0x1ul << EADC_CMP1_CMPCOND_Pos) /*!< EADC_T::CMP: CMPCOND Mask */ + +#define EADC_CMP1_CMPSPL_Pos (3) /*!< EADC_T::CMP: CMPSPL Position */ +#define EADC_CMP1_CMPSPL_Msk (0x7ul << EADC_CMP1_CMPSPL_Pos) /*!< EADC_T::CMP: CMPSPL Mask */ + +#define EADC_CMP1_CMPMCNT_Pos (8) /*!< EADC_T::CMP: CMPMCNT Position */ +#define EADC_CMP1_CMPMCNT_Msk (0xful << EADC_CMP1_CMPMCNT_Pos) /*!< EADC_T::CMP: CMPMCNT Mask */ + +#define EADC_CMP1_CMPDAT_Pos (16) /*!< EADC_T::CMP: CMPDAT Position */ +#define EADC_CMP1_CMPDAT_Msk (0xffful << EADC_CMP1_CMPDAT_Pos) /*!< EADC_T::CMP: CMPDAT Mask */ + +#define EADC_STATUS0_VALID_Pos (0) /*!< EADC_T::STATUS0: VALID Position */ +#define EADC_STATUS0_VALID_Msk (0xfffful << EADC_STATUS0_VALID_Pos) /*!< EADC_T::STATUS0: VALID Mask */ + +#define EADC_STATUS0_OV_Pos (16) /*!< EADC_T::STATUS0: OV Position */ +#define EADC_STATUS0_OV_Msk (0xfffful << EADC_STATUS0_OV_Pos) /*!< EADC_T::STATUS0: OV Mask */ + +#define EADC_STATUS1_ADIF0_Pos (0) /*!< EADC_T::STATUS1: ADIF0 Position */ +#define EADC_STATUS1_ADIF0_Msk (0x1ul << EADC_STATUS1_ADIF0_Pos) /*!< EADC_T::STATUS1: ADIF0 Mask */ + +#define EADC_STATUS1_ADIF1_Pos (1) /*!< EADC_T::STATUS1: ADIF1 Position */ +#define EADC_STATUS1_ADIF1_Msk (0x1ul << EADC_STATUS1_ADIF1_Pos) /*!< EADC_T::STATUS1: ADIF1 Mask */ + +#define EADC_STATUS1_ADIF2_Pos (2) /*!< EADC_T::STATUS1: ADIF2 Position */ +#define EADC_STATUS1_ADIF2_Msk (0x1ul << EADC_STATUS1_ADIF2_Pos) /*!< EADC_T::STATUS1: ADIF2 Mask */ + +#define EADC_STATUS1_ADIF3_Pos (3) /*!< EADC_T::STATUS1: ADIF3 Position */ +#define EADC_STATUS1_ADIF3_Msk (0x1ul << EADC_STATUS1_ADIF3_Pos) /*!< EADC_T::STATUS1: ADIF3 Mask */ + +#define EADC_STATUS1_ADCMPO0_Pos (4) /*!< EADC_T::STATUS1: ADCMPO0 Position */ +#define EADC_STATUS1_ADCMPO0_Msk (0x1ul << EADC_STATUS1_ADCMPO0_Pos) /*!< EADC_T::STATUS1: ADCMPO0 Mask */ + +#define EADC_STATUS1_ADCMPO1_Pos (5) /*!< EADC_T::STATUS1: ADCMPO1 Position */ +#define EADC_STATUS1_ADCMPO1_Msk (0x1ul << EADC_STATUS1_ADCMPO1_Pos) /*!< EADC_T::STATUS1: ADCMPO1 Mask */ + +#define EADC_STATUS1_ADCMPF0_Pos (6) /*!< EADC_T::STATUS1: ADCMPF0 Position */ +#define EADC_STATUS1_ADCMPF0_Msk (0x1ul << EADC_STATUS1_ADCMPF0_Pos) /*!< EADC_T::STATUS1: ADCMPF0 Mask */ + +#define EADC_STATUS1_ADCMPF1_Pos (7) /*!< EADC_T::STATUS1: ADCMPF1 Position */ +#define EADC_STATUS1_ADCMPF1_Msk (0x1ul << EADC_STATUS1_ADCMPF1_Pos) /*!< EADC_T::STATUS1: ADCMPF1 Mask */ + +#define EADC_STATUS1_BUSY0_Pos (8) /*!< EADC_T::STATUS1: BUSY0 Position */ +#define EADC_STATUS1_BUSY0_Msk (0x1ul << EADC_STATUS1_BUSY0_Pos) /*!< EADC_T::STATUS1: BUSY0 Mask */ + +#define EADC_STATUS1_CHANNEL0_Pos (12) /*!< EADC_T::STATUS1: CHANNEL0 Position */ +#define EADC_STATUS1_CHANNEL0_Msk (0xful << EADC_STATUS1_CHANNEL0_Pos) /*!< EADC_T::STATUS1: CHANNEL0 Mask */ + +#define EADC_STATUS1_BUSY1_Pos (16) /*!< EADC_T::STATUS1: BUSY1 Position */ +#define EADC_STATUS1_BUSY1_Msk (0x1ul << EADC_STATUS1_BUSY1_Pos) /*!< EADC_T::STATUS1: BUSY1 Mask */ + +#define EADC_STATUS1_CHANNEL1_Pos (20) /*!< EADC_T::STATUS1: CHANNEL1 Position */ +#define EADC_STATUS1_CHANNEL1_Msk (0xful << EADC_STATUS1_CHANNEL1_Pos) /*!< EADC_T::STATUS1: CHANNEL1 Mask */ + +#define EADC_STATUS1_ADOVIF_Pos (24) /*!< EADC_T::STATUS1: ADOVIF Position */ +#define EADC_STATUS1_ADOVIF_Msk (0x1ul << EADC_STATUS1_ADOVIF_Pos) /*!< EADC_T::STATUS1: ADOVIF Mask */ + +#define EADC_STATUS1_STOVF_Pos (25) /*!< EADC_T::STATUS1: STOVF Position */ +#define EADC_STATUS1_STOVF_Msk (0x1ul << EADC_STATUS1_STOVF_Pos) /*!< EADC_T::STATUS1: STOVF Mask */ + +#define EADC_STATUS1_AVALID_Pos (26) /*!< EADC_T::STATUS1: AVALID Position */ +#define EADC_STATUS1_AVALID_Msk (0x1ul << EADC_STATUS1_AVALID_Pos) /*!< EADC_T::STATUS1: AVALID Mask */ + +#define EADC_STATUS1_AOV_Pos (27) /*!< EADC_T::STATUS1: AOV Position */ +#define EADC_STATUS1_AOV_Msk (0x1ul << EADC_STATUS1_AOV_Pos) /*!< EADC_T::STATUS1: AOV Mask */ + +#define EADC_EXTSMPT_EXTSMPT0_Pos (0) /*!< EADC_T::EXTSMPT: EXTSMPT0 Position */ +#define EADC_EXTSMPT_EXTSMPT0_Msk (0xfful << EADC_EXTSMPT_EXTSMPT0_Pos) /*!< EADC_T::EXTSMPT: EXTSMPT0 Mask */ + +#define EADC_EXTSMPT_EXTSMPT1_Pos (16) /*!< EADC_T::EXTSMPT: EXTSMPT1 Position */ +#define EADC_EXTSMPT_EXTSMPT1_Msk (0xfful << EADC_EXTSMPT_EXTSMPT1_Pos) /*!< EADC_T::EXTSMPT: EXTSMPT1 Mask */ + +#define EADC_AD0DDAT0_RESULT_Pos (0) /*!< EADC_T::AD0DDAT0: RESULT Position */ +#define EADC_AD0DDAT0_RESULT_Msk (0xffful << EADC_AD0DDAT0_RESULT_Pos) /*!< EADC_T::AD0DDAT0: RESULT Mask */ + +#define EADC_AD0DDAT0_VALID_Pos (16) /*!< EADC_T::AD0DDAT0: VALID Position */ +#define EADC_AD0DDAT0_VALID_Msk (0x1ul << EADC_AD0DDAT0_VALID_Pos) /*!< EADC_T::AD0DDAT0: VALID Mask */ + +#define EADC_AD0DDAT1_RESULT_Pos (0) /*!< EADC_T::AD0DDAT1: RESULT Position */ +#define EADC_AD0DDAT1_RESULT_Msk (0xffful << EADC_AD0DDAT1_RESULT_Pos) /*!< EADC_T::AD0DDAT1: RESULT Mask */ + +#define EADC_AD0DDAT1_VALID_Pos (16) /*!< EADC_T::AD0DDAT1: VALID Position */ +#define EADC_AD0DDAT1_VALID_Msk (0x1ul << EADC_AD0DDAT1_VALID_Pos) /*!< EADC_T::AD0DDAT1: VALID Mask */ + +#define EADC_AD0DDAT2_RESULT_Pos (0) /*!< EADC_T::AD0DDAT2: RESULT Position */ +#define EADC_AD0DDAT2_RESULT_Msk (0xffful << EADC_AD0DDAT2_RESULT_Pos) /*!< EADC_T::AD0DDAT2: RESULT Mask */ + +#define EADC_AD0DDAT2_VALID_Pos (16) /*!< EADC_T::AD0DDAT2: VALID Position */ +#define EADC_AD0DDAT2_VALID_Msk (0x1ul << EADC_AD0DDAT2_VALID_Pos) /*!< EADC_T::AD0DDAT2: VALID Mask */ + +#define EADC_AD0DDAT3_RESULT_Pos (0) /*!< EADC_T::AD0DDAT3: RESULT Position */ +#define EADC_AD0DDAT3_RESULT_Msk (0xffful << EADC_AD0DDAT3_RESULT_Pos) /*!< EADC_T::AD0DDAT3: RESULT Mask */ + +#define EADC_AD0DDAT3_VALID_Pos (16) /*!< EADC_T::AD0DDAT3: VALID Position */ +#define EADC_AD0DDAT3_VALID_Msk (0x1ul << EADC_AD0DDAT3_VALID_Pos) /*!< EADC_T::AD0DDAT3: VALID Mask */ + +#define EADC_AD1DDAT0_RESULT_Pos (0) /*!< EADC_T::AD1DDAT0: RESULT Position */ +#define EADC_AD1DDAT0_RESULT_Msk (0xffful << EADC_AD1DDAT0_RESULT_Pos) /*!< EADC_T::AD1DDAT0: RESULT Mask */ + +#define EADC_AD1DDAT0_VALID_Pos (16) /*!< EADC_T::AD1DDAT0: VALID Position */ +#define EADC_AD1DDAT0_VALID_Msk (0x1ul << EADC_AD1DDAT0_VALID_Pos) /*!< EADC_T::AD1DDAT0: VALID Mask */ + +#define EADC_AD1DDAT1_RESULT_Pos (0) /*!< EADC_T::AD1DDAT1: RESULT Position */ +#define EADC_AD1DDAT1_RESULT_Msk (0xffful << EADC_AD1DDAT1_RESULT_Pos) /*!< EADC_T::AD1DDAT1: RESULT Mask */ + +#define EADC_AD1DDAT1_VALID_Pos (16) /*!< EADC_T::AD1DDAT1: VALID Position */ +#define EADC_AD1DDAT1_VALID_Msk (0x1ul << EADC_AD1DDAT1_VALID_Pos) /*!< EADC_T::AD1DDAT1: VALID Mask */ + +#define EADC_AD1DDAT2_RESULT_Pos (0) /*!< EADC_T::AD1DDAT2: RESULT Position */ +#define EADC_AD1DDAT2_RESULT_Msk (0xffful << EADC_AD1DDAT2_RESULT_Pos) /*!< EADC_T::AD1DDAT2: RESULT Mask */ + +#define EADC_AD1DDAT2_VALID_Pos (16) /*!< EADC_T::AD1DDAT2: VALID Position */ +#define EADC_AD1DDAT2_VALID_Msk (0x1ul << EADC_AD1DDAT2_VALID_Pos) /*!< EADC_T::AD1DDAT2: VALID Mask */ + +#define EADC_AD1DDAT3_RESULT_Pos (0) /*!< EADC_T::AD1DDAT3: RESULT Position */ +#define EADC_AD1DDAT3_RESULT_Msk (0xffful << EADC_AD1DDAT3_RESULT_Pos) /*!< EADC_T::AD1DDAT3: RESULT Mask */ + +#define EADC_AD1DDAT3_VALID_Pos (16) /*!< EADC_T::AD1DDAT3: VALID Position */ +#define EADC_AD1DDAT3_VALID_Msk (0x1ul << EADC_AD1DDAT3_VALID_Pos) /*!< EADC_T::AD1DDAT3: VALID Mask */ + +#define EADC_DBMEN_AD0DBM0_Pos (0) /*!< EADC_T::DBMEN: AD0DBM0 Position */ +#define EADC_DBMEN_AD0DBM0_Msk (0x1ul << EADC_DBMEN_AD0DBM0_Pos) /*!< EADC_T::DBMEN: AD0DBM0 Mask */ + +#define EADC_DBMEN_AD0DBM1_Pos (1) /*!< EADC_T::DBMEN: AD0DBM1 Position */ +#define EADC_DBMEN_AD0DBM1_Msk (0x1ul << EADC_DBMEN_AD0DBM1_Pos) /*!< EADC_T::DBMEN: AD0DBM1 Mask */ + +#define EADC_DBMEN_AD0DBM2_Pos (2) /*!< EADC_T::DBMEN: AD0DBM2 Position */ +#define EADC_DBMEN_AD0DBM2_Msk (0x1ul << EADC_DBMEN_AD0DBM2_Pos) /*!< EADC_T::DBMEN: AD0DBM2 Mask */ + +#define EADC_DBMEN_AD0DBM3_Pos (3) /*!< EADC_T::DBMEN: AD0DBM3 Position */ +#define EADC_DBMEN_AD0DBM3_Msk (0x1ul << EADC_DBMEN_AD0DBM3_Pos) /*!< EADC_T::DBMEN: AD0DBM3 Mask */ + +#define EADC_DBMEN_AD1DBM0_Pos (8) /*!< EADC_T::DBMEN: AD1DBM0 Position */ +#define EADC_DBMEN_AD1DBM0_Msk (0x1ul << EADC_DBMEN_AD1DBM0_Pos) /*!< EADC_T::DBMEN: AD1DBM0 Mask */ + +#define EADC_DBMEN_AD1DBM1_Pos (9) /*!< EADC_T::DBMEN: AD1DBM1 Position */ +#define EADC_DBMEN_AD1DBM1_Msk (0x1ul << EADC_DBMEN_AD1DBM1_Pos) /*!< EADC_T::DBMEN: AD1DBM1 Mask */ + +#define EADC_DBMEN_AD1DBM2_Pos (10) /*!< EADC_T::DBMEN: AD1DBM2 Position */ +#define EADC_DBMEN_AD1DBM2_Msk (0x1ul << EADC_DBMEN_AD1DBM2_Pos) /*!< EADC_T::DBMEN: AD1DBM2 Mask */ + +#define EADC_DBMEN_AD1DBM3_Pos (11) /*!< EADC_T::DBMEN: AD1DBM3 Position */ +#define EADC_DBMEN_AD1DBM3_Msk (0x1ul << EADC_DBMEN_AD1DBM3_Pos) /*!< EADC_T::DBMEN: AD1DBM3 Mask */ + +#define EADC_INTSRC0_AD0SPIE0_Pos (0) /*!< EADC_T::INTSRC: AD0SPIE0 Position */ +#define EADC_INTSRC0_AD0SPIE0_Msk (0x1ul << EADC_INTSRC0_AD0SPIE0_Pos) /*!< EADC_T::INTSRC: AD0SPIE0 Mask */ + +#define EADC_INTSRC0_AD0SPIE1_Pos (1) /*!< EADC_T::INTSRC: AD0SPIE1 Position */ +#define EADC_INTSRC0_AD0SPIE1_Msk (0x1ul << EADC_INTSRC0_AD0SPIE1_Pos) /*!< EADC_T::INTSRC: AD0SPIE1 Mask */ + +#define EADC_INTSRC0_AD0SPIE2_Pos (2) /*!< EADC_T::INTSRC: AD0SPIE2 Position */ +#define EADC_INTSRC0_AD0SPIE2_Msk (0x1ul << EADC_INTSRC0_AD0SPIE2_Pos) /*!< EADC_T::INTSRC: AD0SPIE2 Mask */ + +#define EADC_INTSRC0_AD0SPIE3_Pos (3) /*!< EADC_T::INTSRC: AD0SPIE3 Position */ +#define EADC_INTSRC0_AD0SPIE3_Msk (0x1ul << EADC_INTSRC0_AD0SPIE3_Pos) /*!< EADC_T::INTSRC: AD0SPIE3 Mask */ + +#define EADC_INTSRC0_AD0SPIE4_Pos (4) /*!< EADC_T::INTSRC: AD0SPIE4 Position */ +#define EADC_INTSRC0_AD0SPIE4_Msk (0x1ul << EADC_INTSRC0_AD0SPIE4_Pos) /*!< EADC_T::INTSRC: AD0SPIE4 Mask */ + +#define EADC_INTSRC0_AD0SPIE5_Pos (5) /*!< EADC_T::INTSRC: AD0SPIE5 Position */ +#define EADC_INTSRC0_AD0SPIE5_Msk (0x1ul << EADC_INTSRC0_AD0SPIE5_Pos) /*!< EADC_T::INTSRC: AD0SPIE5 Mask */ + +#define EADC_INTSRC0_AD0SPIE6_Pos (6) /*!< EADC_T::INTSRC: AD0SPIE6 Position */ +#define EADC_INTSRC0_AD0SPIE6_Msk (0x1ul << EADC_INTSRC0_AD0SPIE6_Pos) /*!< EADC_T::INTSRC: AD0SPIE6 Mask */ + +#define EADC_INTSRC0_AD0SPIE7_Pos (7) /*!< EADC_T::INTSRC: AD0SPIE7 Position */ +#define EADC_INTSRC0_AD0SPIE7_Msk (0x1ul << EADC_INTSRC0_AD0SPIE7_Pos) /*!< EADC_T::INTSRC: AD0SPIE7 Mask */ + +#define EADC_INTSRC0_AD1SPIE0_Pos (8) /*!< EADC_T::INTSRC: AD1SPIE0 Position */ +#define EADC_INTSRC0_AD1SPIE0_Msk (0x1ul << EADC_INTSRC0_AD1SPIE0_Pos) /*!< EADC_T::INTSRC: AD1SPIE0 Mask */ + +#define EADC_INTSRC0_AD1SPIE1_Pos (9) /*!< EADC_T::INTSRC: AD1SPIE1 Position */ +#define EADC_INTSRC0_AD1SPIE1_Msk (0x1ul << EADC_INTSRC0_AD1SPIE1_Pos) /*!< EADC_T::INTSRC: AD1SPIE1 Mask */ + +#define EADC_INTSRC0_AD1SPIE2_Pos (10) /*!< EADC_T::INTSRC: AD1SPIE2 Position */ +#define EADC_INTSRC0_AD1SPIE2_Msk (0x1ul << EADC_INTSRC0_AD1SPIE2_Pos) /*!< EADC_T::INTSRC: AD1SPIE2 Mask */ + +#define EADC_INTSRC0_AD1SPIE3_Pos (11) /*!< EADC_T::INTSRC: AD1SPIE3 Position */ +#define EADC_INTSRC0_AD1SPIE3_Msk (0x1ul << EADC_INTSRC0_AD1SPIE3_Pos) /*!< EADC_T::INTSRC: AD1SPIE3 Mask */ + +#define EADC_INTSRC0_AD1SPIE4_Pos (12) /*!< EADC_T::INTSRC: AD1SPIE4 Position */ +#define EADC_INTSRC0_AD1SPIE4_Msk (0x1ul << EADC_INTSRC0_AD1SPIE4_Pos) /*!< EADC_T::INTSRC: AD1SPIE4 Mask */ + +#define EADC_INTSRC0_AD1SPIE5_Pos (13) /*!< EADC_T::INTSRC: AD1SPIE5 Position */ +#define EADC_INTSRC0_AD1SPIE5_Msk (0x1ul << EADC_INTSRC0_AD1SPIE5_Pos) /*!< EADC_T::INTSRC: AD1SPIE5 Mask */ + +#define EADC_INTSRC0_AD1SPIE6_Pos (14) /*!< EADC_T::INTSRC: AD1SPIE6 Position */ +#define EADC_INTSRC0_AD1SPIE6_Msk (0x1ul << EADC_INTSRC0_AD1SPIE6_Pos) /*!< EADC_T::INTSRC: AD1SPIE6 Mask */ + +#define EADC_INTSRC0_AD1SPIE7_Pos (15) /*!< EADC_T::INTSRC: AD1SPIE7 Position */ +#define EADC_INTSRC0_AD1SPIE7_Msk (0x1ul << EADC_INTSRC0_AD1SPIE7_Pos) /*!< EADC_T::INTSRC: AD1SPIE7 Mask */ + +#define EADC_INTSRC1_AD0SPIE0_Pos (0) /*!< EADC_T::INTSRC: AD0SPIE0 Position */ +#define EADC_INTSRC1_AD0SPIE0_Msk (0x1ul << EADC_INTSRC1_AD0SPIE0_Pos) /*!< EADC_T::INTSRC: AD0SPIE0 Mask */ + +#define EADC_INTSRC1_AD0SPIE1_Pos (1) /*!< EADC_T::INTSRC: AD0SPIE1 Position */ +#define EADC_INTSRC1_AD0SPIE1_Msk (0x1ul << EADC_INTSRC1_AD0SPIE1_Pos) /*!< EADC_T::INTSRC: AD0SPIE1 Mask */ + +#define EADC_INTSRC1_AD0SPIE2_Pos (2) /*!< EADC_T::INTSRC: AD0SPIE2 Position */ +#define EADC_INTSRC1_AD0SPIE2_Msk (0x1ul << EADC_INTSRC1_AD0SPIE2_Pos) /*!< EADC_T::INTSRC: AD0SPIE2 Mask */ + +#define EADC_INTSRC1_AD0SPIE3_Pos (3) /*!< EADC_T::INTSRC: AD0SPIE3 Position */ +#define EADC_INTSRC1_AD0SPIE3_Msk (0x1ul << EADC_INTSRC1_AD0SPIE3_Pos) /*!< EADC_T::INTSRC: AD0SPIE3 Mask */ + +#define EADC_INTSRC1_AD0SPIE4_Pos (4) /*!< EADC_T::INTSRC: AD0SPIE4 Position */ +#define EADC_INTSRC1_AD0SPIE4_Msk (0x1ul << EADC_INTSRC1_AD0SPIE4_Pos) /*!< EADC_T::INTSRC: AD0SPIE4 Mask */ + +#define EADC_INTSRC1_AD0SPIE5_Pos (5) /*!< EADC_T::INTSRC: AD0SPIE5 Position */ +#define EADC_INTSRC1_AD0SPIE5_Msk (0x1ul << EADC_INTSRC1_AD0SPIE5_Pos) /*!< EADC_T::INTSRC: AD0SPIE5 Mask */ + +#define EADC_INTSRC1_AD0SPIE6_Pos (6) /*!< EADC_T::INTSRC: AD0SPIE6 Position */ +#define EADC_INTSRC1_AD0SPIE6_Msk (0x1ul << EADC_INTSRC1_AD0SPIE6_Pos) /*!< EADC_T::INTSRC: AD0SPIE6 Mask */ + +#define EADC_INTSRC1_AD0SPIE7_Pos (7) /*!< EADC_T::INTSRC: AD0SPIE7 Position */ +#define EADC_INTSRC1_AD0SPIE7_Msk (0x1ul << EADC_INTSRC1_AD0SPIE7_Pos) /*!< EADC_T::INTSRC: AD0SPIE7 Mask */ + +#define EADC_INTSRC1_AD1SPIE0_Pos (8) /*!< EADC_T::INTSRC: AD1SPIE0 Position */ +#define EADC_INTSRC1_AD1SPIE0_Msk (0x1ul << EADC_INTSRC1_AD1SPIE0_Pos) /*!< EADC_T::INTSRC: AD1SPIE0 Mask */ + +#define EADC_INTSRC1_AD1SPIE1_Pos (9) /*!< EADC_T::INTSRC: AD1SPIE1 Position */ +#define EADC_INTSRC1_AD1SPIE1_Msk (0x1ul << EADC_INTSRC1_AD1SPIE1_Pos) /*!< EADC_T::INTSRC: AD1SPIE1 Mask */ + +#define EADC_INTSRC1_AD1SPIE2_Pos (10) /*!< EADC_T::INTSRC: AD1SPIE2 Position */ +#define EADC_INTSRC1_AD1SPIE2_Msk (0x1ul << EADC_INTSRC1_AD1SPIE2_Pos) /*!< EADC_T::INTSRC: AD1SPIE2 Mask */ + +#define EADC_INTSRC1_AD1SPIE3_Pos (11) /*!< EADC_T::INTSRC: AD1SPIE3 Position */ +#define EADC_INTSRC1_AD1SPIE3_Msk (0x1ul << EADC_INTSRC1_AD1SPIE3_Pos) /*!< EADC_T::INTSRC: AD1SPIE3 Mask */ + +#define EADC_INTSRC1_AD1SPIE4_Pos (12) /*!< EADC_T::INTSRC: AD1SPIE4 Position */ +#define EADC_INTSRC1_AD1SPIE4_Msk (0x1ul << EADC_INTSRC1_AD1SPIE4_Pos) /*!< EADC_T::INTSRC: AD1SPIE4 Mask */ + +#define EADC_INTSRC1_AD1SPIE5_Pos (13) /*!< EADC_T::INTSRC: AD1SPIE5 Position */ +#define EADC_INTSRC1_AD1SPIE5_Msk (0x1ul << EADC_INTSRC1_AD1SPIE5_Pos) /*!< EADC_T::INTSRC: AD1SPIE5 Mask */ + +#define EADC_INTSRC1_AD1SPIE6_Pos (14) /*!< EADC_T::INTSRC: AD1SPIE6 Position */ +#define EADC_INTSRC1_AD1SPIE6_Msk (0x1ul << EADC_INTSRC1_AD1SPIE6_Pos) /*!< EADC_T::INTSRC: AD1SPIE6 Mask */ + +#define EADC_INTSRC1_AD1SPIE7_Pos (15) /*!< EADC_T::INTSRC: AD1SPIE7 Position */ +#define EADC_INTSRC1_AD1SPIE7_Msk (0x1ul << EADC_INTSRC1_AD1SPIE7_Pos) /*!< EADC_T::INTSRC: AD1SPIE7 Mask */ + +#define EADC_INTSRC2_AD0SPIE0_Pos (0) /*!< EADC_T::INTSRC: AD0SPIE0 Position */ +#define EADC_INTSRC2_AD0SPIE0_Msk (0x1ul << EADC_INTSRC2_AD0SPIE0_Pos) /*!< EADC_T::INTSRC: AD0SPIE0 Mask */ + +#define EADC_INTSRC2_AD0SPIE1_Pos (1) /*!< EADC_T::INTSRC: AD0SPIE1 Position */ +#define EADC_INTSRC2_AD0SPIE1_Msk (0x1ul << EADC_INTSRC2_AD0SPIE1_Pos) /*!< EADC_T::INTSRC: AD0SPIE1 Mask */ + +#define EADC_INTSRC2_AD0SPIE2_Pos (2) /*!< EADC_T::INTSRC: AD0SPIE2 Position */ +#define EADC_INTSRC2_AD0SPIE2_Msk (0x1ul << EADC_INTSRC2_AD0SPIE2_Pos) /*!< EADC_T::INTSRC: AD0SPIE2 Mask */ + +#define EADC_INTSRC2_AD0SPIE3_Pos (3) /*!< EADC_T::INTSRC: AD0SPIE3 Position */ +#define EADC_INTSRC2_AD0SPIE3_Msk (0x1ul << EADC_INTSRC2_AD0SPIE3_Pos) /*!< EADC_T::INTSRC: AD0SPIE3 Mask */ + +#define EADC_INTSRC2_AD0SPIE4_Pos (4) /*!< EADC_T::INTSRC: AD0SPIE4 Position */ +#define EADC_INTSRC2_AD0SPIE4_Msk (0x1ul << EADC_INTSRC2_AD0SPIE4_Pos) /*!< EADC_T::INTSRC: AD0SPIE4 Mask */ + +#define EADC_INTSRC2_AD0SPIE5_Pos (5) /*!< EADC_T::INTSRC: AD0SPIE5 Position */ +#define EADC_INTSRC2_AD0SPIE5_Msk (0x1ul << EADC_INTSRC2_AD0SPIE5_Pos) /*!< EADC_T::INTSRC: AD0SPIE5 Mask */ + +#define EADC_INTSRC2_AD0SPIE6_Pos (6) /*!< EADC_T::INTSRC: AD0SPIE6 Position */ +#define EADC_INTSRC2_AD0SPIE6_Msk (0x1ul << EADC_INTSRC2_AD0SPIE6_Pos) /*!< EADC_T::INTSRC: AD0SPIE6 Mask */ + +#define EADC_INTSRC2_AD0SPIE7_Pos (7) /*!< EADC_T::INTSRC: AD0SPIE7 Position */ +#define EADC_INTSRC2_AD0SPIE7_Msk (0x1ul << EADC_INTSRC2_AD0SPIE7_Pos) /*!< EADC_T::INTSRC: AD0SPIE7 Mask */ + +#define EADC_INTSRC2_AD1SPIE0_Pos (8) /*!< EADC_T::INTSRC: AD1SPIE0 Position */ +#define EADC_INTSRC2_AD1SPIE0_Msk (0x1ul << EADC_INTSRC2_AD1SPIE0_Pos) /*!< EADC_T::INTSRC: AD1SPIE0 Mask */ + +#define EADC_INTSRC2_AD1SPIE1_Pos (9) /*!< EADC_T::INTSRC: AD1SPIE1 Position */ +#define EADC_INTSRC2_AD1SPIE1_Msk (0x1ul << EADC_INTSRC2_AD1SPIE1_Pos) /*!< EADC_T::INTSRC: AD1SPIE1 Mask */ + +#define EADC_INTSRC2_AD1SPIE2_Pos (10) /*!< EADC_T::INTSRC: AD1SPIE2 Position */ +#define EADC_INTSRC2_AD1SPIE2_Msk (0x1ul << EADC_INTSRC2_AD1SPIE2_Pos) /*!< EADC_T::INTSRC: AD1SPIE2 Mask */ + +#define EADC_INTSRC2_AD1SPIE3_Pos (11) /*!< EADC_T::INTSRC: AD1SPIE3 Position */ +#define EADC_INTSRC2_AD1SPIE3_Msk (0x1ul << EADC_INTSRC2_AD1SPIE3_Pos) /*!< EADC_T::INTSRC: AD1SPIE3 Mask */ + +#define EADC_INTSRC2_AD1SPIE4_Pos (12) /*!< EADC_T::INTSRC: AD1SPIE4 Position */ +#define EADC_INTSRC2_AD1SPIE4_Msk (0x1ul << EADC_INTSRC2_AD1SPIE4_Pos) /*!< EADC_T::INTSRC: AD1SPIE4 Mask */ + +#define EADC_INTSRC2_AD1SPIE5_Pos (13) /*!< EADC_T::INTSRC: AD1SPIE5 Position */ +#define EADC_INTSRC2_AD1SPIE5_Msk (0x1ul << EADC_INTSRC2_AD1SPIE5_Pos) /*!< EADC_T::INTSRC: AD1SPIE5 Mask */ + +#define EADC_INTSRC2_AD1SPIE6_Pos (14) /*!< EADC_T::INTSRC: AD1SPIE6 Position */ +#define EADC_INTSRC2_AD1SPIE6_Msk (0x1ul << EADC_INTSRC2_AD1SPIE6_Pos) /*!< EADC_T::INTSRC: AD1SPIE6 Mask */ + +#define EADC_INTSRC2_AD1SPIE7_Pos (15) /*!< EADC_T::INTSRC: AD1SPIE7 Position */ +#define EADC_INTSRC2_AD1SPIE7_Msk (0x1ul << EADC_INTSRC2_AD1SPIE7_Pos) /*!< EADC_T::INTSRC: AD1SPIE7 Mask */ + +#define EADC_INTSRC3_AD0SPIE0_Pos (0) /*!< EADC_T::INTSRC: AD0SPIE0 Position */ +#define EADC_INTSRC3_AD0SPIE0_Msk (0x1ul << EADC_INTSRC3_AD0SPIE0_Pos) /*!< EADC_T::INTSRC: AD0SPIE0 Mask */ + +#define EADC_INTSRC3_AD0SPIE1_Pos (1) /*!< EADC_T::INTSRC: AD0SPIE1 Position */ +#define EADC_INTSRC3_AD0SPIE1_Msk (0x1ul << EADC_INTSRC3_AD0SPIE1_Pos) /*!< EADC_T::INTSRC: AD0SPIE1 Mask */ + +#define EADC_INTSRC3_AD0SPIE2_Pos (2) /*!< EADC_T::INTSRC: AD0SPIE2 Position */ +#define EADC_INTSRC3_AD0SPIE2_Msk (0x1ul << EADC_INTSRC3_AD0SPIE2_Pos) /*!< EADC_T::INTSRC: AD0SPIE2 Mask */ + +#define EADC_INTSRC3_AD0SPIE3_Pos (3) /*!< EADC_T::INTSRC: AD0SPIE3 Position */ +#define EADC_INTSRC3_AD0SPIE3_Msk (0x1ul << EADC_INTSRC3_AD0SPIE3_Pos) /*!< EADC_T::INTSRC: AD0SPIE3 Mask */ + +#define EADC_INTSRC3_AD0SPIE4_Pos (4) /*!< EADC_T::INTSRC: AD0SPIE4 Position */ +#define EADC_INTSRC3_AD0SPIE4_Msk (0x1ul << EADC_INTSRC3_AD0SPIE4_Pos) /*!< EADC_T::INTSRC: AD0SPIE4 Mask */ + +#define EADC_INTSRC3_AD0SPIE5_Pos (5) /*!< EADC_T::INTSRC: AD0SPIE5 Position */ +#define EADC_INTSRC3_AD0SPIE5_Msk (0x1ul << EADC_INTSRC3_AD0SPIE5_Pos) /*!< EADC_T::INTSRC: AD0SPIE5 Mask */ + +#define EADC_INTSRC3_AD0SPIE6_Pos (6) /*!< EADC_T::INTSRC: AD0SPIE6 Position */ +#define EADC_INTSRC3_AD0SPIE6_Msk (0x1ul << EADC_INTSRC3_AD0SPIE6_Pos) /*!< EADC_T::INTSRC: AD0SPIE6 Mask */ + +#define EADC_INTSRC3_AD0SPIE7_Pos (7) /*!< EADC_T::INTSRC: AD0SPIE7 Position */ +#define EADC_INTSRC3_AD0SPIE7_Msk (0x1ul << EADC_INTSRC3_AD0SPIE7_Pos) /*!< EADC_T::INTSRC: AD0SPIE7 Mask */ + +#define EADC_INTSRC3_AD1SPIE0_Pos (8) /*!< EADC_T::INTSRC: AD1SPIE0 Position */ +#define EADC_INTSRC3_AD1SPIE0_Msk (0x1ul << EADC_INTSRC3_AD1SPIE0_Pos) /*!< EADC_T::INTSRC: AD1SPIE0 Mask */ + +#define EADC_INTSRC3_AD1SPIE1_Pos (9) /*!< EADC_T::INTSRC: AD1SPIE1 Position */ +#define EADC_INTSRC3_AD1SPIE1_Msk (0x1ul << EADC_INTSRC3_AD1SPIE1_Pos) /*!< EADC_T::INTSRC: AD1SPIE1 Mask */ + +#define EADC_INTSRC3_AD1SPIE2_Pos (10) /*!< EADC_T::INTSRC: AD1SPIE2 Position */ +#define EADC_INTSRC3_AD1SPIE2_Msk (0x1ul << EADC_INTSRC3_AD1SPIE2_Pos) /*!< EADC_T::INTSRC: AD1SPIE2 Mask */ + +#define EADC_INTSRC3_AD1SPIE3_Pos (11) /*!< EADC_T::INTSRC: AD1SPIE3 Position */ +#define EADC_INTSRC3_AD1SPIE3_Msk (0x1ul << EADC_INTSRC3_AD1SPIE3_Pos) /*!< EADC_T::INTSRC: AD1SPIE3 Mask */ + +#define EADC_INTSRC3_AD1SPIE4_Pos (12) /*!< EADC_T::INTSRC: AD1SPIE4 Position */ +#define EADC_INTSRC3_AD1SPIE4_Msk (0x1ul << EADC_INTSRC3_AD1SPIE4_Pos) /*!< EADC_T::INTSRC: AD1SPIE4 Mask */ + +#define EADC_INTSRC3_AD1SPIE5_Pos (13) /*!< EADC_T::INTSRC: AD1SPIE5 Position */ +#define EADC_INTSRC3_AD1SPIE5_Msk (0x1ul << EADC_INTSRC3_AD1SPIE5_Pos) /*!< EADC_T::INTSRC: AD1SPIE5 Mask */ + +#define EADC_INTSRC3_AD1SPIE6_Pos (14) /*!< EADC_T::INTSRC: AD1SPIE6 Position */ +#define EADC_INTSRC3_AD1SPIE6_Msk (0x1ul << EADC_INTSRC3_AD1SPIE6_Pos) /*!< EADC_T::INTSRC: AD1SPIE6 Mask */ + +#define EADC_INTSRC3_AD1SPIE7_Pos (15) /*!< EADC_T::INTSRC: AD1SPIE7 Position */ +#define EADC_INTSRC3_AD1SPIE7_Msk (0x1ul << EADC_INTSRC3_AD1SPIE7_Pos) /*!< EADC_T::INTSRC: AD1SPIE7 Mask */ + +#define EADC_AD0TRGEN0_EPWM00REN_Pos (0) /*!< EADC_T::AD0TRGEN0: EPWM00REN Position */ +#define EADC_AD0TRGEN0_EPWM00REN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM00REN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM00REN Mask */ + +#define EADC_AD0TRGEN0_EPWM00FEN_Pos (1) /*!< EADC_T::AD0TRGEN0: EPWM00FEN Position */ +#define EADC_AD0TRGEN0_EPWM00FEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM00FEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM00FEN Mask */ + +#define EADC_AD0TRGEN0_EPWM00PEN_Pos (2) /*!< EADC_T::AD0TRGEN0: EPWM00PEN Position */ +#define EADC_AD0TRGEN0_EPWM00PEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM00PEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM00PEN Mask */ + +#define EADC_AD0TRGEN0_EPWM00CEN_Pos (3) /*!< EADC_T::AD0TRGEN0: EPWM00CEN Position */ +#define EADC_AD0TRGEN0_EPWM00CEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM00CEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM00CEN Mask */ + +#define EADC_AD0TRGEN0_EPWM02REN_Pos (4) /*!< EADC_T::AD0TRGEN0: EPWM02REN Position */ +#define EADC_AD0TRGEN0_EPWM02REN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM02REN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM02REN Mask */ + +#define EADC_AD0TRGEN0_EPWM02FEN_Pos (5) /*!< EADC_T::AD0TRGEN0: EPWM02FEN Position */ +#define EADC_AD0TRGEN0_EPWM02FEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM02FEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM02FEN Mask */ + +#define EADC_AD0TRGEN0_EPWM02PEN_Pos (6) /*!< EADC_T::AD0TRGEN0: EPWM02PEN Position */ +#define EADC_AD0TRGEN0_EPWM02PEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM02PEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM02PEN Mask */ + +#define EADC_AD0TRGEN0_EPWM02CEN_Pos (7) /*!< EADC_T::AD0TRGEN0: EPWM02CEN Position */ +#define EADC_AD0TRGEN0_EPWM02CEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM02CEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM02CEN Mask */ + +#define EADC_AD0TRGEN0_EPWM04REN_Pos (8) /*!< EADC_T::AD0TRGEN0: EPWM04REN Position */ +#define EADC_AD0TRGEN0_EPWM04REN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM04REN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM04REN Mask */ + +#define EADC_AD0TRGEN0_EPWM04FEN_Pos (9) /*!< EADC_T::AD0TRGEN0: EPWM04FEN Position */ +#define EADC_AD0TRGEN0_EPWM04FEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM04FEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM04FEN Mask */ + +#define EADC_AD0TRGEN0_EPWM04PEN_Pos (10) /*!< EADC_T::AD0TRGEN0: EPWM04PEN Position */ +#define EADC_AD0TRGEN0_EPWM04PEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM04PEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM04PEN Mask */ + +#define EADC_AD0TRGEN0_EPWM04CEN_Pos (11) /*!< EADC_T::AD0TRGEN0: EPWM04CEN Position */ +#define EADC_AD0TRGEN0_EPWM04CEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM04CEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM04CEN Mask */ + +#define EADC_AD0TRGEN0_EPWM10REN_Pos (12) /*!< EADC_T::AD0TRGEN0: EPWM10REN Position */ +#define EADC_AD0TRGEN0_EPWM10REN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM10REN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM10REN Mask */ + +#define EADC_AD0TRGEN0_EPWM10FEN_Pos (13) /*!< EADC_T::AD0TRGEN0: EPWM10FEN Position */ +#define EADC_AD0TRGEN0_EPWM10FEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM10FEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM10FEN Mask */ + +#define EADC_AD0TRGEN0_EPWM10PEN_Pos (14) /*!< EADC_T::AD0TRGEN0: EPWM10PEN Position */ +#define EADC_AD0TRGEN0_EPWM10PEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM10PEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM10PEN Mask */ + +#define EADC_AD0TRGEN0_EPWM10CEN_Pos (15) /*!< EADC_T::AD0TRGEN0: EPWM10CEN Position */ +#define EADC_AD0TRGEN0_EPWM10CEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM10CEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM10CEN Mask */ + +#define EADC_AD0TRGEN0_EPWM12REN_Pos (16) /*!< EADC_T::AD0TRGEN0: EPWM12REN Position */ +#define EADC_AD0TRGEN0_EPWM12REN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM12REN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM12REN Mask */ + +#define EADC_AD0TRGEN0_EPWM120FEN_Pos (17) /*!< EADC_T::AD0TRGEN0: EPWM120FEN Position */ +#define EADC_AD0TRGEN0_EPWM120FEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM120FEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM120FEN Mask */ + +#define EADC_AD0TRGEN0_EPWM12PEN_Pos (18) /*!< EADC_T::AD0TRGEN0: EPWM12PEN Position */ +#define EADC_AD0TRGEN0_EPWM12PEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM12PEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM12PEN Mask */ + +#define EADC_AD0TRGEN0_EPWM12CEN_Pos (19) /*!< EADC_T::AD0TRGEN0: EPWM12CEN Position */ +#define EADC_AD0TRGEN0_EPWM12CEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM12CEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM12CEN Mask */ + +#define EADC_AD0TRGEN0_EPWM14REN_Pos (20) /*!< EADC_T::AD0TRGEN0: EPWM14REN Position */ +#define EADC_AD0TRGEN0_EPWM14REN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM14REN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM14REN Mask */ + +#define EADC_AD0TRGEN0_EPWM14FEN_Pos (21) /*!< EADC_T::AD0TRGEN0: EPWM14FEN Position */ +#define EADC_AD0TRGEN0_EPWM14FEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM14FEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM14FEN Mask */ + +#define EADC_AD0TRGEN0_EPWM14PEN_Pos (22) /*!< EADC_T::AD0TRGEN0: EPWM14PEN Position */ +#define EADC_AD0TRGEN0_EPWM14PEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM14PEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM14PEN Mask */ + +#define EADC_AD0TRGEN0_EPWM14CEN_Pos (23) /*!< EADC_T::AD0TRGEN0: EPWM14CEN Position */ +#define EADC_AD0TRGEN0_EPWM14CEN_Msk (0x1ul << EADC_AD0TRGEN0_EPWM14CEN_Pos) /*!< EADC_T::AD0TRGEN0: EPWM14CEN Mask */ + +#define EADC_AD0TRGEN0_PWM00REN_Pos (24) /*!< EADC_T::AD0TRGEN0: PWM00REN Position */ +#define EADC_AD0TRGEN0_PWM00REN_Msk (0x1ul << EADC_AD0TRGEN0_PWM00REN_Pos) /*!< EADC_T::AD0TRGEN0: PWM00REN Mask */ + +#define EADC_AD0TRGEN0_PWM00FEN_Pos (25) /*!< EADC_T::AD0TRGEN0: PWM00FEN Position */ +#define EADC_AD0TRGEN0_PWM00FEN_Msk (0x1ul << EADC_AD0TRGEN0_PWM00FEN_Pos) /*!< EADC_T::AD0TRGEN0: PWM00FEN Mask */ + +#define EADC_AD0TRGEN0_PWM00PEN_Pos (26) /*!< EADC_T::AD0TRGEN0: PWM00PEN Position */ +#define EADC_AD0TRGEN0_PWM00PEN_Msk (0x1ul << EADC_AD0TRGEN0_PWM00PEN_Pos) /*!< EADC_T::AD0TRGEN0: PWM00PEN Mask */ + +#define EADC_AD0TRGEN0_PWM00CEN_Pos (27) /*!< EADC_T::AD0TRGEN0: PWM00CEN Position */ +#define EADC_AD0TRGEN0_PWM00CEN_Msk (0x1ul << EADC_AD0TRGEN0_PWM00CEN_Pos) /*!< EADC_T::AD0TRGEN0: PWM00CEN Mask */ + +#define EADC_AD0TRGEN0_PWM01REN_Pos (28) /*!< EADC_T::AD0TRGEN0: PWM01REN Position */ +#define EADC_AD0TRGEN0_PWM01REN_Msk (0x1ul << EADC_AD0TRGEN0_PWM01REN_Pos) /*!< EADC_T::AD0TRGEN0: PWM01REN Mask */ + +#define EADC_AD0TRGEN0_PWM01FEN_Pos (29) /*!< EADC_T::AD0TRGEN0: PWM01FEN Position */ +#define EADC_AD0TRGEN0_PWM01FEN_Msk (0x1ul << EADC_AD0TRGEN0_PWM01FEN_Pos) /*!< EADC_T::AD0TRGEN0: PWM01FEN Mask */ + +#define EADC_AD0TRGEN0_PWM01PEN_Pos (30) /*!< EADC_T::AD0TRGEN0: PWM01PEN Position */ +#define EADC_AD0TRGEN0_PWM01PEN_Msk (0x1ul << EADC_AD0TRGEN0_PWM01PEN_Pos) /*!< EADC_T::AD0TRGEN0: PWM01PEN Mask */ + +#define EADC_AD0TRGEN0_PWM01CEN_Pos (31) /*!< EADC_T::AD0TRGEN0: PWM01CEN Position */ +#define EADC_AD0TRGEN0_PWM01CEN_Msk (0x1ul << EADC_AD0TRGEN0_PWM01CEN_Pos) /*!< EADC_T::AD0TRGEN0: PWM01CEN Mask */ + +#define EADC_AD0TRGEN1_EPWM00REN_Pos (0) /*!< EADC_T::AD0TRGEN1: EPWM00REN Position */ +#define EADC_AD0TRGEN1_EPWM00REN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM00REN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM00REN Mask */ + +#define EADC_AD0TRGEN1_EPWM00FEN_Pos (1) /*!< EADC_T::AD0TRGEN1: EPWM00FEN Position */ +#define EADC_AD0TRGEN1_EPWM00FEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM00FEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM00FEN Mask */ + +#define EADC_AD0TRGEN1_EPWM00PEN_Pos (2) /*!< EADC_T::AD0TRGEN1: EPWM00PEN Position */ +#define EADC_AD0TRGEN1_EPWM00PEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM00PEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM00PEN Mask */ + +#define EADC_AD0TRGEN1_EPWM00CEN_Pos (3) /*!< EADC_T::AD0TRGEN1: EPWM00CEN Position */ +#define EADC_AD0TRGEN1_EPWM00CEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM00CEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM00CEN Mask */ + +#define EADC_AD0TRGEN1_EPWM02REN_Pos (4) /*!< EADC_T::AD0TRGEN1: EPWM02REN Position */ +#define EADC_AD0TRGEN1_EPWM02REN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM02REN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM02REN Mask */ + +#define EADC_AD0TRGEN1_EPWM02FEN_Pos (5) /*!< EADC_T::AD0TRGEN1: EPWM02FEN Position */ +#define EADC_AD0TRGEN1_EPWM02FEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM02FEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM02FEN Mask */ + +#define EADC_AD0TRGEN1_EPWM02PEN_Pos (6) /*!< EADC_T::AD0TRGEN1: EPWM02PEN Position */ +#define EADC_AD0TRGEN1_EPWM02PEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM02PEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM02PEN Mask */ + +#define EADC_AD0TRGEN1_EPWM02CEN_Pos (7) /*!< EADC_T::AD0TRGEN1: EPWM02CEN Position */ +#define EADC_AD0TRGEN1_EPWM02CEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM02CEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM02CEN Mask */ + +#define EADC_AD0TRGEN1_EPWM04REN_Pos (8) /*!< EADC_T::AD0TRGEN1: EPWM04REN Position */ +#define EADC_AD0TRGEN1_EPWM04REN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM04REN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM04REN Mask */ + +#define EADC_AD0TRGEN1_EPWM04FEN_Pos (9) /*!< EADC_T::AD0TRGEN1: EPWM04FEN Position */ +#define EADC_AD0TRGEN1_EPWM04FEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM04FEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM04FEN Mask */ + +#define EADC_AD0TRGEN1_EPWM04PEN_Pos (10) /*!< EADC_T::AD0TRGEN1: EPWM04PEN Position */ +#define EADC_AD0TRGEN1_EPWM04PEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM04PEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM04PEN Mask */ + +#define EADC_AD0TRGEN1_EPWM04CEN_Pos (11) /*!< EADC_T::AD0TRGEN1: EPWM04CEN Position */ +#define EADC_AD0TRGEN1_EPWM04CEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM04CEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM04CEN Mask */ + +#define EADC_AD0TRGEN1_EPWM10REN_Pos (12) /*!< EADC_T::AD0TRGEN1: EPWM10REN Position */ +#define EADC_AD0TRGEN1_EPWM10REN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM10REN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM10REN Mask */ + +#define EADC_AD0TRGEN1_EPWM10FEN_Pos (13) /*!< EADC_T::AD0TRGEN1: EPWM10FEN Position */ +#define EADC_AD0TRGEN1_EPWM10FEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM10FEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM10FEN Mask */ + +#define EADC_AD0TRGEN1_EPWM10PEN_Pos (14) /*!< EADC_T::AD0TRGEN1: EPWM10PEN Position */ +#define EADC_AD0TRGEN1_EPWM10PEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM10PEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM10PEN Mask */ + +#define EADC_AD0TRGEN1_EPWM10CEN_Pos (15) /*!< EADC_T::AD0TRGEN1: EPWM10CEN Position */ +#define EADC_AD0TRGEN1_EPWM10CEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM10CEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM10CEN Mask */ + +#define EADC_AD0TRGEN1_EPWM12REN_Pos (16) /*!< EADC_T::AD0TRGEN1: EPWM12REN Position */ +#define EADC_AD0TRGEN1_EPWM12REN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM12REN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM12REN Mask */ + +#define EADC_AD0TRGEN1_EPWM120FEN_Pos (17) /*!< EADC_T::AD0TRGEN1: EPWM120FEN Position */ +#define EADC_AD0TRGEN1_EPWM120FEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM120FEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM120FEN Mask */ + +#define EADC_AD0TRGEN1_EPWM12PEN_Pos (18) /*!< EADC_T::AD0TRGEN1: EPWM12PEN Position */ +#define EADC_AD0TRGEN1_EPWM12PEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM12PEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM12PEN Mask */ + +#define EADC_AD0TRGEN1_EPWM12CEN_Pos (19) /*!< EADC_T::AD0TRGEN1: EPWM12CEN Position */ +#define EADC_AD0TRGEN1_EPWM12CEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM12CEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM12CEN Mask */ + +#define EADC_AD0TRGEN1_EPWM14REN_Pos (20) /*!< EADC_T::AD0TRGEN1: EPWM14REN Position */ +#define EADC_AD0TRGEN1_EPWM14REN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM14REN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM14REN Mask */ + +#define EADC_AD0TRGEN1_EPWM14FEN_Pos (21) /*!< EADC_T::AD0TRGEN1: EPWM14FEN Position */ +#define EADC_AD0TRGEN1_EPWM14FEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM14FEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM14FEN Mask */ + +#define EADC_AD0TRGEN1_EPWM14PEN_Pos (22) /*!< EADC_T::AD0TRGEN1: EPWM14PEN Position */ +#define EADC_AD0TRGEN1_EPWM14PEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM14PEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM14PEN Mask */ + +#define EADC_AD0TRGEN1_EPWM14CEN_Pos (23) /*!< EADC_T::AD0TRGEN1: EPWM14CEN Position */ +#define EADC_AD0TRGEN1_EPWM14CEN_Msk (0x1ul << EADC_AD0TRGEN1_EPWM14CEN_Pos) /*!< EADC_T::AD0TRGEN1: EPWM14CEN Mask */ + +#define EADC_AD0TRGEN1_PWM00REN_Pos (24) /*!< EADC_T::AD0TRGEN1: PWM00REN Position */ +#define EADC_AD0TRGEN1_PWM00REN_Msk (0x1ul << EADC_AD0TRGEN1_PWM00REN_Pos) /*!< EADC_T::AD0TRGEN1: PWM00REN Mask */ + +#define EADC_AD0TRGEN1_PWM00FEN_Pos (25) /*!< EADC_T::AD0TRGEN1: PWM00FEN Position */ +#define EADC_AD0TRGEN1_PWM00FEN_Msk (0x1ul << EADC_AD0TRGEN1_PWM00FEN_Pos) /*!< EADC_T::AD0TRGEN1: PWM00FEN Mask */ + +#define EADC_AD0TRGEN1_PWM00PEN_Pos (26) /*!< EADC_T::AD0TRGEN1: PWM00PEN Position */ +#define EADC_AD0TRGEN1_PWM00PEN_Msk (0x1ul << EADC_AD0TRGEN1_PWM00PEN_Pos) /*!< EADC_T::AD0TRGEN1: PWM00PEN Mask */ + +#define EADC_AD0TRGEN1_PWM00CEN_Pos (27) /*!< EADC_T::AD0TRGEN1: PWM00CEN Position */ +#define EADC_AD0TRGEN1_PWM00CEN_Msk (0x1ul << EADC_AD0TRGEN1_PWM00CEN_Pos) /*!< EADC_T::AD0TRGEN1: PWM00CEN Mask */ + +#define EADC_AD0TRGEN1_PWM01REN_Pos (28) /*!< EADC_T::AD0TRGEN1: PWM01REN Position */ +#define EADC_AD0TRGEN1_PWM01REN_Msk (0x1ul << EADC_AD0TRGEN1_PWM01REN_Pos) /*!< EADC_T::AD0TRGEN1: PWM01REN Mask */ + +#define EADC_AD0TRGEN1_PWM01FEN_Pos (29) /*!< EADC_T::AD0TRGEN1: PWM01FEN Position */ +#define EADC_AD0TRGEN1_PWM01FEN_Msk (0x1ul << EADC_AD0TRGEN1_PWM01FEN_Pos) /*!< EADC_T::AD0TRGEN1: PWM01FEN Mask */ + +#define EADC_AD0TRGEN1_PWM01PEN_Pos (30) /*!< EADC_T::AD0TRGEN1: PWM01PEN Position */ +#define EADC_AD0TRGEN1_PWM01PEN_Msk (0x1ul << EADC_AD0TRGEN1_PWM01PEN_Pos) /*!< EADC_T::AD0TRGEN1: PWM01PEN Mask */ + +#define EADC_AD0TRGEN1_PWM01CEN_Pos (31) /*!< EADC_T::AD0TRGEN1: PWM01CEN Position */ +#define EADC_AD0TRGEN1_PWM01CEN_Msk (0x1ul << EADC_AD0TRGEN1_PWM01CEN_Pos) /*!< EADC_T::AD0TRGEN1: PWM01CEN Mask */ + +#define EADC_AD0TRGEN2_EPWM00REN_Pos (0) /*!< EADC_T::AD0TRGEN2: EPWM00REN Position */ +#define EADC_AD0TRGEN2_EPWM00REN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM00REN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM00REN Mask */ + +#define EADC_AD0TRGEN2_EPWM00FEN_Pos (1) /*!< EADC_T::AD0TRGEN2: EPWM00FEN Position */ +#define EADC_AD0TRGEN2_EPWM00FEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM00FEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM00FEN Mask */ + +#define EADC_AD0TRGEN2_EPWM00PEN_Pos (2) /*!< EADC_T::AD0TRGEN2: EPWM00PEN Position */ +#define EADC_AD0TRGEN2_EPWM00PEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM00PEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM00PEN Mask */ + +#define EADC_AD0TRGEN2_EPWM00CEN_Pos (3) /*!< EADC_T::AD0TRGEN2: EPWM00CEN Position */ +#define EADC_AD0TRGEN2_EPWM00CEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM00CEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM00CEN Mask */ + +#define EADC_AD0TRGEN2_EPWM02REN_Pos (4) /*!< EADC_T::AD0TRGEN2: EPWM02REN Position */ +#define EADC_AD0TRGEN2_EPWM02REN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM02REN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM02REN Mask */ + +#define EADC_AD0TRGEN2_EPWM02FEN_Pos (5) /*!< EADC_T::AD0TRGEN2: EPWM02FEN Position */ +#define EADC_AD0TRGEN2_EPWM02FEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM02FEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM02FEN Mask */ + +#define EADC_AD0TRGEN2_EPWM02PEN_Pos (6) /*!< EADC_T::AD0TRGEN2: EPWM02PEN Position */ +#define EADC_AD0TRGEN2_EPWM02PEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM02PEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM02PEN Mask */ + +#define EADC_AD0TRGEN2_EPWM02CEN_Pos (7) /*!< EADC_T::AD0TRGEN2: EPWM02CEN Position */ +#define EADC_AD0TRGEN2_EPWM02CEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM02CEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM02CEN Mask */ + +#define EADC_AD0TRGEN2_EPWM04REN_Pos (8) /*!< EADC_T::AD0TRGEN2: EPWM04REN Position */ +#define EADC_AD0TRGEN2_EPWM04REN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM04REN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM04REN Mask */ + +#define EADC_AD0TRGEN2_EPWM04FEN_Pos (9) /*!< EADC_T::AD0TRGEN2: EPWM04FEN Position */ +#define EADC_AD0TRGEN2_EPWM04FEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM04FEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM04FEN Mask */ + +#define EADC_AD0TRGEN2_EPWM04PEN_Pos (10) /*!< EADC_T::AD0TRGEN2: EPWM04PEN Position */ +#define EADC_AD0TRGEN2_EPWM04PEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM04PEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM04PEN Mask */ + +#define EADC_AD0TRGEN2_EPWM04CEN_Pos (11) /*!< EADC_T::AD0TRGEN2: EPWM04CEN Position */ +#define EADC_AD0TRGEN2_EPWM04CEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM04CEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM04CEN Mask */ + +#define EADC_AD0TRGEN2_EPWM10REN_Pos (12) /*!< EADC_T::AD0TRGEN2: EPWM10REN Position */ +#define EADC_AD0TRGEN2_EPWM10REN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM10REN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM10REN Mask */ + +#define EADC_AD0TRGEN2_EPWM10FEN_Pos (13) /*!< EADC_T::AD0TRGEN2: EPWM10FEN Position */ +#define EADC_AD0TRGEN2_EPWM10FEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM10FEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM10FEN Mask */ + +#define EADC_AD0TRGEN2_EPWM10PEN_Pos (14) /*!< EADC_T::AD0TRGEN2: EPWM10PEN Position */ +#define EADC_AD0TRGEN2_EPWM10PEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM10PEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM10PEN Mask */ + +#define EADC_AD0TRGEN2_EPWM10CEN_Pos (15) /*!< EADC_T::AD0TRGEN2: EPWM10CEN Position */ +#define EADC_AD0TRGEN2_EPWM10CEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM10CEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM10CEN Mask */ + +#define EADC_AD0TRGEN2_EPWM12REN_Pos (16) /*!< EADC_T::AD0TRGEN2: EPWM12REN Position */ +#define EADC_AD0TRGEN2_EPWM12REN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM12REN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM12REN Mask */ + +#define EADC_AD0TRGEN2_EPWM120FEN_Pos (17) /*!< EADC_T::AD0TRGEN2: EPWM120FEN Position */ +#define EADC_AD0TRGEN2_EPWM120FEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM120FEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM120FEN Mask */ + +#define EADC_AD0TRGEN2_EPWM12PEN_Pos (18) /*!< EADC_T::AD0TRGEN2: EPWM12PEN Position */ +#define EADC_AD0TRGEN2_EPWM12PEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM12PEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM12PEN Mask */ + +#define EADC_AD0TRGEN2_EPWM12CEN_Pos (19) /*!< EADC_T::AD0TRGEN2: EPWM12CEN Position */ +#define EADC_AD0TRGEN2_EPWM12CEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM12CEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM12CEN Mask */ + +#define EADC_AD0TRGEN2_EPWM14REN_Pos (20) /*!< EADC_T::AD0TRGEN2: EPWM14REN Position */ +#define EADC_AD0TRGEN2_EPWM14REN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM14REN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM14REN Mask */ + +#define EADC_AD0TRGEN2_EPWM14FEN_Pos (21) /*!< EADC_T::AD0TRGEN2: EPWM14FEN Position */ +#define EADC_AD0TRGEN2_EPWM14FEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM14FEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM14FEN Mask */ + +#define EADC_AD0TRGEN2_EPWM14PEN_Pos (22) /*!< EADC_T::AD0TRGEN2: EPWM14PEN Position */ +#define EADC_AD0TRGEN2_EPWM14PEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM14PEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM14PEN Mask */ + +#define EADC_AD0TRGEN2_EPWM14CEN_Pos (23) /*!< EADC_T::AD0TRGEN2: EPWM14CEN Position */ +#define EADC_AD0TRGEN2_EPWM14CEN_Msk (0x1ul << EADC_AD0TRGEN2_EPWM14CEN_Pos) /*!< EADC_T::AD0TRGEN2: EPWM14CEN Mask */ + +#define EADC_AD0TRGEN2_PWM00REN_Pos (24) /*!< EADC_T::AD0TRGEN2: PWM00REN Position */ +#define EADC_AD0TRGEN2_PWM00REN_Msk (0x1ul << EADC_AD0TRGEN2_PWM00REN_Pos) /*!< EADC_T::AD0TRGEN2: PWM00REN Mask */ + +#define EADC_AD0TRGEN2_PWM00FEN_Pos (25) /*!< EADC_T::AD0TRGEN2: PWM00FEN Position */ +#define EADC_AD0TRGEN2_PWM00FEN_Msk (0x1ul << EADC_AD0TRGEN2_PWM00FEN_Pos) /*!< EADC_T::AD0TRGEN2: PWM00FEN Mask */ + +#define EADC_AD0TRGEN2_PWM00PEN_Pos (26) /*!< EADC_T::AD0TRGEN2: PWM00PEN Position */ +#define EADC_AD0TRGEN2_PWM00PEN_Msk (0x1ul << EADC_AD0TRGEN2_PWM00PEN_Pos) /*!< EADC_T::AD0TRGEN2: PWM00PEN Mask */ + +#define EADC_AD0TRGEN2_PWM00CEN_Pos (27) /*!< EADC_T::AD0TRGEN2: PWM00CEN Position */ +#define EADC_AD0TRGEN2_PWM00CEN_Msk (0x1ul << EADC_AD0TRGEN2_PWM00CEN_Pos) /*!< EADC_T::AD0TRGEN2: PWM00CEN Mask */ + +#define EADC_AD0TRGEN2_PWM01REN_Pos (28) /*!< EADC_T::AD0TRGEN2: PWM01REN Position */ +#define EADC_AD0TRGEN2_PWM01REN_Msk (0x1ul << EADC_AD0TRGEN2_PWM01REN_Pos) /*!< EADC_T::AD0TRGEN2: PWM01REN Mask */ + +#define EADC_AD0TRGEN2_PWM01FEN_Pos (29) /*!< EADC_T::AD0TRGEN2: PWM01FEN Position */ +#define EADC_AD0TRGEN2_PWM01FEN_Msk (0x1ul << EADC_AD0TRGEN2_PWM01FEN_Pos) /*!< EADC_T::AD0TRGEN2: PWM01FEN Mask */ + +#define EADC_AD0TRGEN2_PWM01PEN_Pos (30) /*!< EADC_T::AD0TRGEN2: PWM01PEN Position */ +#define EADC_AD0TRGEN2_PWM01PEN_Msk (0x1ul << EADC_AD0TRGEN2_PWM01PEN_Pos) /*!< EADC_T::AD0TRGEN2: PWM01PEN Mask */ + +#define EADC_AD0TRGEN2_PWM01CEN_Pos (31) /*!< EADC_T::AD0TRGEN2: PWM01CEN Position */ +#define EADC_AD0TRGEN2_PWM01CEN_Msk (0x1ul << EADC_AD0TRGEN2_PWM01CEN_Pos) /*!< EADC_T::AD0TRGEN2: PWM01CEN Mask */ + +#define EADC_AD0TRGEN3_EPWM00REN_Pos (0) /*!< EADC_T::AD0TRGEN3: EPWM00REN Position */ +#define EADC_AD0TRGEN3_EPWM00REN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM00REN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM00REN Mask */ + +#define EADC_AD0TRGEN3_EPWM00FEN_Pos (1) /*!< EADC_T::AD0TRGEN3: EPWM00FEN Position */ +#define EADC_AD0TRGEN3_EPWM00FEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM00FEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM00FEN Mask */ + +#define EADC_AD0TRGEN3_EPWM00PEN_Pos (2) /*!< EADC_T::AD0TRGEN3: EPWM00PEN Position */ +#define EADC_AD0TRGEN3_EPWM00PEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM00PEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM00PEN Mask */ + +#define EADC_AD0TRGEN3_EPWM00CEN_Pos (3) /*!< EADC_T::AD0TRGEN3: EPWM00CEN Position */ +#define EADC_AD0TRGEN3_EPWM00CEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM00CEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM00CEN Mask */ + +#define EADC_AD0TRGEN3_EPWM02REN_Pos (4) /*!< EADC_T::AD0TRGEN3: EPWM02REN Position */ +#define EADC_AD0TRGEN3_EPWM02REN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM02REN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM02REN Mask */ + +#define EADC_AD0TRGEN3_EPWM02FEN_Pos (5) /*!< EADC_T::AD0TRGEN3: EPWM02FEN Position */ +#define EADC_AD0TRGEN3_EPWM02FEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM02FEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM02FEN Mask */ + +#define EADC_AD0TRGEN3_EPWM02PEN_Pos (6) /*!< EADC_T::AD0TRGEN3: EPWM02PEN Position */ +#define EADC_AD0TRGEN3_EPWM02PEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM02PEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM02PEN Mask */ + +#define EADC_AD0TRGEN3_EPWM02CEN_Pos (7) /*!< EADC_T::AD0TRGEN3: EPWM02CEN Position */ +#define EADC_AD0TRGEN3_EPWM02CEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM02CEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM02CEN Mask */ + +#define EADC_AD0TRGEN3_EPWM04REN_Pos (8) /*!< EADC_T::AD0TRGEN3: EPWM04REN Position */ +#define EADC_AD0TRGEN3_EPWM04REN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM04REN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM04REN Mask */ + +#define EADC_AD0TRGEN3_EPWM04FEN_Pos (9) /*!< EADC_T::AD0TRGEN3: EPWM04FEN Position */ +#define EADC_AD0TRGEN3_EPWM04FEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM04FEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM04FEN Mask */ + +#define EADC_AD0TRGEN3_EPWM04PEN_Pos (10) /*!< EADC_T::AD0TRGEN3: EPWM04PEN Position */ +#define EADC_AD0TRGEN3_EPWM04PEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM04PEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM04PEN Mask */ + +#define EADC_AD0TRGEN3_EPWM04CEN_Pos (11) /*!< EADC_T::AD0TRGEN3: EPWM04CEN Position */ +#define EADC_AD0TRGEN3_EPWM04CEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM04CEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM04CEN Mask */ + +#define EADC_AD0TRGEN3_EPWM10REN_Pos (12) /*!< EADC_T::AD0TRGEN3: EPWM10REN Position */ +#define EADC_AD0TRGEN3_EPWM10REN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM10REN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM10REN Mask */ + +#define EADC_AD0TRGEN3_EPWM10FEN_Pos (13) /*!< EADC_T::AD0TRGEN3: EPWM10FEN Position */ +#define EADC_AD0TRGEN3_EPWM10FEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM10FEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM10FEN Mask */ + +#define EADC_AD0TRGEN3_EPWM10PEN_Pos (14) /*!< EADC_T::AD0TRGEN3: EPWM10PEN Position */ +#define EADC_AD0TRGEN3_EPWM10PEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM10PEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM10PEN Mask */ + +#define EADC_AD0TRGEN3_EPWM10CEN_Pos (15) /*!< EADC_T::AD0TRGEN3: EPWM10CEN Position */ +#define EADC_AD0TRGEN3_EPWM10CEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM10CEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM10CEN Mask */ + +#define EADC_AD0TRGEN3_EPWM12REN_Pos (16) /*!< EADC_T::AD0TRGEN3: EPWM12REN Position */ +#define EADC_AD0TRGEN3_EPWM12REN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM12REN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM12REN Mask */ + +#define EADC_AD0TRGEN3_EPWM120FEN_Pos (17) /*!< EADC_T::AD0TRGEN3: EPWM120FEN Position */ +#define EADC_AD0TRGEN3_EPWM120FEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM120FEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM120FEN Mask */ + +#define EADC_AD0TRGEN3_EPWM12PEN_Pos (18) /*!< EADC_T::AD0TRGEN3: EPWM12PEN Position */ +#define EADC_AD0TRGEN3_EPWM12PEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM12PEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM12PEN Mask */ + +#define EADC_AD0TRGEN3_EPWM12CEN_Pos (19) /*!< EADC_T::AD0TRGEN3: EPWM12CEN Position */ +#define EADC_AD0TRGEN3_EPWM12CEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM12CEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM12CEN Mask */ + +#define EADC_AD0TRGEN3_EPWM14REN_Pos (20) /*!< EADC_T::AD0TRGEN3: EPWM14REN Position */ +#define EADC_AD0TRGEN3_EPWM14REN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM14REN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM14REN Mask */ + +#define EADC_AD0TRGEN3_EPWM14FEN_Pos (21) /*!< EADC_T::AD0TRGEN3: EPWM14FEN Position */ +#define EADC_AD0TRGEN3_EPWM14FEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM14FEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM14FEN Mask */ + +#define EADC_AD0TRGEN3_EPWM14PEN_Pos (22) /*!< EADC_T::AD0TRGEN3: EPWM14PEN Position */ +#define EADC_AD0TRGEN3_EPWM14PEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM14PEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM14PEN Mask */ + +#define EADC_AD0TRGEN3_EPWM14CEN_Pos (23) /*!< EADC_T::AD0TRGEN3: EPWM14CEN Position */ +#define EADC_AD0TRGEN3_EPWM14CEN_Msk (0x1ul << EADC_AD0TRGEN3_EPWM14CEN_Pos) /*!< EADC_T::AD0TRGEN3: EPWM14CEN Mask */ + +#define EADC_AD0TRGEN3_PWM00REN_Pos (24) /*!< EADC_T::AD0TRGEN3: PWM00REN Position */ +#define EADC_AD0TRGEN3_PWM00REN_Msk (0x1ul << EADC_AD0TRGEN3_PWM00REN_Pos) /*!< EADC_T::AD0TRGEN3: PWM00REN Mask */ + +#define EADC_AD0TRGEN3_PWM00FEN_Pos (25) /*!< EADC_T::AD0TRGEN3: PWM00FEN Position */ +#define EADC_AD0TRGEN3_PWM00FEN_Msk (0x1ul << EADC_AD0TRGEN3_PWM00FEN_Pos) /*!< EADC_T::AD0TRGEN3: PWM00FEN Mask */ + +#define EADC_AD0TRGEN3_PWM00PEN_Pos (26) /*!< EADC_T::AD0TRGEN3: PWM00PEN Position */ +#define EADC_AD0TRGEN3_PWM00PEN_Msk (0x1ul << EADC_AD0TRGEN3_PWM00PEN_Pos) /*!< EADC_T::AD0TRGEN3: PWM00PEN Mask */ + +#define EADC_AD0TRGEN3_PWM00CEN_Pos (27) /*!< EADC_T::AD0TRGEN3: PWM00CEN Position */ +#define EADC_AD0TRGEN3_PWM00CEN_Msk (0x1ul << EADC_AD0TRGEN3_PWM00CEN_Pos) /*!< EADC_T::AD0TRGEN3: PWM00CEN Mask */ + +#define EADC_AD0TRGEN3_PWM01REN_Pos (28) /*!< EADC_T::AD0TRGEN3: PWM01REN Position */ +#define EADC_AD0TRGEN3_PWM01REN_Msk (0x1ul << EADC_AD0TRGEN3_PWM01REN_Pos) /*!< EADC_T::AD0TRGEN3: PWM01REN Mask */ + +#define EADC_AD0TRGEN3_PWM01FEN_Pos (29) /*!< EADC_T::AD0TRGEN3: PWM01FEN Position */ +#define EADC_AD0TRGEN3_PWM01FEN_Msk (0x1ul << EADC_AD0TRGEN3_PWM01FEN_Pos) /*!< EADC_T::AD0TRGEN3: PWM01FEN Mask */ + +#define EADC_AD0TRGEN3_PWM01PEN_Pos (30) /*!< EADC_T::AD0TRGEN3: PWM01PEN Position */ +#define EADC_AD0TRGEN3_PWM01PEN_Msk (0x1ul << EADC_AD0TRGEN3_PWM01PEN_Pos) /*!< EADC_T::AD0TRGEN3: PWM01PEN Mask */ + +#define EADC_AD0TRGEN3_PWM01CEN_Pos (31) /*!< EADC_T::AD0TRGEN3: PWM01CEN Position */ +#define EADC_AD0TRGEN3_PWM01CEN_Msk (0x1ul << EADC_AD0TRGEN3_PWM01CEN_Pos) /*!< EADC_T::AD0TRGEN3: PWM01CEN Mask */ + +#define EADC_AD1TRGEN0_EPWM00REN_Pos (0) /*!< EADC_T::AD1TRGEN0: EPWM00REN Position */ +#define EADC_AD1TRGEN0_EPWM00REN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM00REN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM00REN Mask */ + +#define EADC_AD1TRGEN0_EPWM00FEN_Pos (1) /*!< EADC_T::AD1TRGEN0: EPWM00FEN Position */ +#define EADC_AD1TRGEN0_EPWM00FEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM00FEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM00FEN Mask */ + +#define EADC_AD1TRGEN0_EPWM00PEN_Pos (2) /*!< EADC_T::AD1TRGEN0: EPWM00PEN Position */ +#define EADC_AD1TRGEN0_EPWM00PEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM00PEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM00PEN Mask */ + +#define EADC_AD1TRGEN0_EPWM00CEN_Pos (3) /*!< EADC_T::AD1TRGEN0: EPWM00CEN Position */ +#define EADC_AD1TRGEN0_EPWM00CEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM00CEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM00CEN Mask */ + +#define EADC_AD1TRGEN0_EPWM02REN_Pos (4) /*!< EADC_T::AD1TRGEN0: EPWM02REN Position */ +#define EADC_AD1TRGEN0_EPWM02REN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM02REN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM02REN Mask */ + +#define EADC_AD1TRGEN0_EPWM02FEN_Pos (5) /*!< EADC_T::AD1TRGEN0: EPWM02FEN Position */ +#define EADC_AD1TRGEN0_EPWM02FEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM02FEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM02FEN Mask */ + +#define EADC_AD1TRGEN0_EPWM02PEN_Pos (6) /*!< EADC_T::AD1TRGEN0: EPWM02PEN Position */ +#define EADC_AD1TRGEN0_EPWM02PEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM02PEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM02PEN Mask */ + +#define EADC_AD1TRGEN0_EPWM02CEN_Pos (7) /*!< EADC_T::AD1TRGEN0: EPWM02CEN Position */ +#define EADC_AD1TRGEN0_EPWM02CEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM02CEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM02CEN Mask */ + +#define EADC_AD1TRGEN0_EPWM04REN_Pos (8) /*!< EADC_T::AD1TRGEN0: EPWM04REN Position */ +#define EADC_AD1TRGEN0_EPWM04REN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM04REN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM04REN Mask */ + +#define EADC_AD1TRGEN0_EPWM04FEN_Pos (9) /*!< EADC_T::AD1TRGEN0: EPWM04FEN Position */ +#define EADC_AD1TRGEN0_EPWM04FEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM04FEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM04FEN Mask */ + +#define EADC_AD1TRGEN0_EPWM04PEN_Pos (10) /*!< EADC_T::AD1TRGEN0: EPWM04PEN Position */ +#define EADC_AD1TRGEN0_EPWM04PEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM04PEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM04PEN Mask */ + +#define EADC_AD1TRGEN0_EPWM04CEN_Pos (11) /*!< EADC_T::AD1TRGEN0: EPWM04CEN Position */ +#define EADC_AD1TRGEN0_EPWM04CEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM04CEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM04CEN Mask */ + +#define EADC_AD1TRGEN0_EPWM10REN_Pos (12) /*!< EADC_T::AD1TRGEN0: EPWM10REN Position */ +#define EADC_AD1TRGEN0_EPWM10REN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM10REN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM10REN Mask */ + +#define EADC_AD1TRGEN0_EPWM10FEN_Pos (13) /*!< EADC_T::AD1TRGEN0: EPWM10FEN Position */ +#define EADC_AD1TRGEN0_EPWM10FEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM10FEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM10FEN Mask */ + +#define EADC_AD1TRGEN0_EPWM10PEN_Pos (14) /*!< EADC_T::AD1TRGEN0: EPWM10PEN Position */ +#define EADC_AD1TRGEN0_EPWM10PEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM10PEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM10PEN Mask */ + +#define EADC_AD1TRGEN0_EPWM10CEN_Pos (15) /*!< EADC_T::AD1TRGEN0: EPWM10CEN Position */ +#define EADC_AD1TRGEN0_EPWM10CEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM10CEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM10CEN Mask */ + +#define EADC_AD1TRGEN0_EPWM12REN_Pos (16) /*!< EADC_T::AD1TRGEN0: EPWM12REN Position */ +#define EADC_AD1TRGEN0_EPWM12REN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM12REN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM12REN Mask */ + +#define EADC_AD1TRGEN0_EPWM120FEN_Pos (17) /*!< EADC_T::AD1TRGEN0: EPWM120FEN Position */ +#define EADC_AD1TRGEN0_EPWM120FEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM120FEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM120FEN Mask */ + +#define EADC_AD1TRGEN0_EPWM12PEN_Pos (18) /*!< EADC_T::AD1TRGEN0: EPWM12PEN Position */ +#define EADC_AD1TRGEN0_EPWM12PEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM12PEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM12PEN Mask */ + +#define EADC_AD1TRGEN0_EPWM12CEN_Pos (19) /*!< EADC_T::AD1TRGEN0: EPWM12CEN Position */ +#define EADC_AD1TRGEN0_EPWM12CEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM12CEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM12CEN Mask */ + +#define EADC_AD1TRGEN0_EPWM14REN_Pos (20) /*!< EADC_T::AD1TRGEN0: EPWM14REN Position */ +#define EADC_AD1TRGEN0_EPWM14REN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM14REN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM14REN Mask */ + +#define EADC_AD1TRGEN0_EPWM14FEN_Pos (21) /*!< EADC_T::AD1TRGEN0: EPWM14FEN Position */ +#define EADC_AD1TRGEN0_EPWM14FEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM14FEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM14FEN Mask */ + +#define EADC_AD1TRGEN0_EPWM14PEN_Pos (22) /*!< EADC_T::AD1TRGEN0: EPWM14PEN Position */ +#define EADC_AD1TRGEN0_EPWM14PEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM14PEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM14PEN Mask */ + +#define EADC_AD1TRGEN0_EPWM14CEN_Pos (23) /*!< EADC_T::AD1TRGEN0: EPWM14CEN Position */ +#define EADC_AD1TRGEN0_EPWM14CEN_Msk (0x1ul << EADC_AD1TRGEN0_EPWM14CEN_Pos) /*!< EADC_T::AD1TRGEN0: EPWM14CEN Mask */ + +#define EADC_AD1TRGEN0_PWM00REN_Pos (24) /*!< EADC_T::AD1TRGEN0: PWM00REN Position */ +#define EADC_AD1TRGEN0_PWM00REN_Msk (0x1ul << EADC_AD1TRGEN0_PWM00REN_Pos) /*!< EADC_T::AD1TRGEN0: PWM00REN Mask */ + +#define EADC_AD1TRGEN0_PWM00FEN_Pos (25) /*!< EADC_T::AD1TRGEN0: PWM00FEN Position */ +#define EADC_AD1TRGEN0_PWM00FEN_Msk (0x1ul << EADC_AD1TRGEN0_PWM00FEN_Pos) /*!< EADC_T::AD1TRGEN0: PWM00FEN Mask */ + +#define EADC_AD1TRGEN0_PWM00PEN_Pos (26) /*!< EADC_T::AD1TRGEN0: PWM00PEN Position */ +#define EADC_AD1TRGEN0_PWM00PEN_Msk (0x1ul << EADC_AD1TRGEN0_PWM00PEN_Pos) /*!< EADC_T::AD1TRGEN0: PWM00PEN Mask */ + +#define EADC_AD1TRGEN0_PWM00CEN_Pos (27) /*!< EADC_T::AD1TRGEN0: PWM00CEN Position */ +#define EADC_AD1TRGEN0_PWM00CEN_Msk (0x1ul << EADC_AD1TRGEN0_PWM00CEN_Pos) /*!< EADC_T::AD1TRGEN0: PWM00CEN Mask */ + +#define EADC_AD1TRGEN0_PWM01REN_Pos (28) /*!< EADC_T::AD1TRGEN0: PWM01REN Position */ +#define EADC_AD1TRGEN0_PWM01REN_Msk (0x1ul << EADC_AD1TRGEN0_PWM01REN_Pos) /*!< EADC_T::AD1TRGEN0: PWM01REN Mask */ + +#define EADC_AD1TRGEN0_PWM01FEN_Pos (29) /*!< EADC_T::AD1TRGEN0: PWM01FEN Position */ +#define EADC_AD1TRGEN0_PWM01FEN_Msk (0x1ul << EADC_AD1TRGEN0_PWM01FEN_Pos) /*!< EADC_T::AD1TRGEN0: PWM01FEN Mask */ + +#define EADC_AD1TRGEN0_PWM01PEN_Pos (30) /*!< EADC_T::AD1TRGEN0: PWM01PEN Position */ +#define EADC_AD1TRGEN0_PWM01PEN_Msk (0x1ul << EADC_AD1TRGEN0_PWM01PEN_Pos) /*!< EADC_T::AD1TRGEN0: PWM01PEN Mask */ + +#define EADC_AD1TRGEN0_PWM01CEN_Pos (31) /*!< EADC_T::AD1TRGEN0: PWM01CEN Position */ +#define EADC_AD1TRGEN0_PWM01CEN_Msk (0x1ul << EADC_AD1TRGEN0_PWM01CEN_Pos) /*!< EADC_T::AD1TRGEN0: PWM01CEN Mask */ + +#define EADC_AD1TRGEN1_EPWM00REN_Pos (0) /*!< EADC_T::AD1TRGEN1: EPWM00REN Position */ +#define EADC_AD1TRGEN1_EPWM00REN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM00REN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM00REN Mask */ + +#define EADC_AD1TRGEN1_EPWM00FEN_Pos (1) /*!< EADC_T::AD1TRGEN1: EPWM00FEN Position */ +#define EADC_AD1TRGEN1_EPWM00FEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM00FEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM00FEN Mask */ + +#define EADC_AD1TRGEN1_EPWM00PEN_Pos (2) /*!< EADC_T::AD1TRGEN1: EPWM00PEN Position */ +#define EADC_AD1TRGEN1_EPWM00PEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM00PEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM00PEN Mask */ + +#define EADC_AD1TRGEN1_EPWM00CEN_Pos (3) /*!< EADC_T::AD1TRGEN1: EPWM00CEN Position */ +#define EADC_AD1TRGEN1_EPWM00CEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM00CEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM00CEN Mask */ + +#define EADC_AD1TRGEN1_EPWM02REN_Pos (4) /*!< EADC_T::AD1TRGEN1: EPWM02REN Position */ +#define EADC_AD1TRGEN1_EPWM02REN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM02REN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM02REN Mask */ + +#define EADC_AD1TRGEN1_EPWM02FEN_Pos (5) /*!< EADC_T::AD1TRGEN1: EPWM02FEN Position */ +#define EADC_AD1TRGEN1_EPWM02FEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM02FEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM02FEN Mask */ + +#define EADC_AD1TRGEN1_EPWM02PEN_Pos (6) /*!< EADC_T::AD1TRGEN1: EPWM02PEN Position */ +#define EADC_AD1TRGEN1_EPWM02PEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM02PEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM02PEN Mask */ + +#define EADC_AD1TRGEN1_EPWM02CEN_Pos (7) /*!< EADC_T::AD1TRGEN1: EPWM02CEN Position */ +#define EADC_AD1TRGEN1_EPWM02CEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM02CEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM02CEN Mask */ + +#define EADC_AD1TRGEN1_EPWM04REN_Pos (8) /*!< EADC_T::AD1TRGEN1: EPWM04REN Position */ +#define EADC_AD1TRGEN1_EPWM04REN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM04REN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM04REN Mask */ + +#define EADC_AD1TRGEN1_EPWM04FEN_Pos (9) /*!< EADC_T::AD1TRGEN1: EPWM04FEN Position */ +#define EADC_AD1TRGEN1_EPWM04FEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM04FEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM04FEN Mask */ + +#define EADC_AD1TRGEN1_EPWM04PEN_Pos (10) /*!< EADC_T::AD1TRGEN1: EPWM04PEN Position */ +#define EADC_AD1TRGEN1_EPWM04PEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM04PEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM04PEN Mask */ + +#define EADC_AD1TRGEN1_EPWM04CEN_Pos (11) /*!< EADC_T::AD1TRGEN1: EPWM04CEN Position */ +#define EADC_AD1TRGEN1_EPWM04CEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM04CEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM04CEN Mask */ + +#define EADC_AD1TRGEN1_EPWM10REN_Pos (12) /*!< EADC_T::AD1TRGEN1: EPWM10REN Position */ +#define EADC_AD1TRGEN1_EPWM10REN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM10REN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM10REN Mask */ + +#define EADC_AD1TRGEN1_EPWM10FEN_Pos (13) /*!< EADC_T::AD1TRGEN1: EPWM10FEN Position */ +#define EADC_AD1TRGEN1_EPWM10FEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM10FEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM10FEN Mask */ + +#define EADC_AD1TRGEN1_EPWM10PEN_Pos (14) /*!< EADC_T::AD1TRGEN1: EPWM10PEN Position */ +#define EADC_AD1TRGEN1_EPWM10PEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM10PEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM10PEN Mask */ + +#define EADC_AD1TRGEN1_EPWM10CEN_Pos (15) /*!< EADC_T::AD1TRGEN1: EPWM10CEN Position */ +#define EADC_AD1TRGEN1_EPWM10CEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM10CEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM10CEN Mask */ + +#define EADC_AD1TRGEN1_EPWM12REN_Pos (16) /*!< EADC_T::AD1TRGEN1: EPWM12REN Position */ +#define EADC_AD1TRGEN1_EPWM12REN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM12REN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM12REN Mask */ + +#define EADC_AD1TRGEN1_EPWM120FEN_Pos (17) /*!< EADC_T::AD1TRGEN1: EPWM120FEN Position */ +#define EADC_AD1TRGEN1_EPWM120FEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM120FEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM120FEN Mask */ + +#define EADC_AD1TRGEN1_EPWM12PEN_Pos (18) /*!< EADC_T::AD1TRGEN1: EPWM12PEN Position */ +#define EADC_AD1TRGEN1_EPWM12PEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM12PEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM12PEN Mask */ + +#define EADC_AD1TRGEN1_EPWM12CEN_Pos (19) /*!< EADC_T::AD1TRGEN1: EPWM12CEN Position */ +#define EADC_AD1TRGEN1_EPWM12CEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM12CEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM12CEN Mask */ + +#define EADC_AD1TRGEN1_EPWM14REN_Pos (20) /*!< EADC_T::AD1TRGEN1: EPWM14REN Position */ +#define EADC_AD1TRGEN1_EPWM14REN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM14REN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM14REN Mask */ + +#define EADC_AD1TRGEN1_EPWM14FEN_Pos (21) /*!< EADC_T::AD1TRGEN1: EPWM14FEN Position */ +#define EADC_AD1TRGEN1_EPWM14FEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM14FEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM14FEN Mask */ + +#define EADC_AD1TRGEN1_EPWM14PEN_Pos (22) /*!< EADC_T::AD1TRGEN1: EPWM14PEN Position */ +#define EADC_AD1TRGEN1_EPWM14PEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM14PEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM14PEN Mask */ + +#define EADC_AD1TRGEN1_EPWM14CEN_Pos (23) /*!< EADC_T::AD1TRGEN1: EPWM14CEN Position */ +#define EADC_AD1TRGEN1_EPWM14CEN_Msk (0x1ul << EADC_AD1TRGEN1_EPWM14CEN_Pos) /*!< EADC_T::AD1TRGEN1: EPWM14CEN Mask */ + +#define EADC_AD1TRGEN1_PWM00REN_Pos (24) /*!< EADC_T::AD1TRGEN1: PWM00REN Position */ +#define EADC_AD1TRGEN1_PWM00REN_Msk (0x1ul << EADC_AD1TRGEN1_PWM00REN_Pos) /*!< EADC_T::AD1TRGEN1: PWM00REN Mask */ + +#define EADC_AD1TRGEN1_PWM00FEN_Pos (25) /*!< EADC_T::AD1TRGEN1: PWM00FEN Position */ +#define EADC_AD1TRGEN1_PWM00FEN_Msk (0x1ul << EADC_AD1TRGEN1_PWM00FEN_Pos) /*!< EADC_T::AD1TRGEN1: PWM00FEN Mask */ + +#define EADC_AD1TRGEN1_PWM00PEN_Pos (26) /*!< EADC_T::AD1TRGEN1: PWM00PEN Position */ +#define EADC_AD1TRGEN1_PWM00PEN_Msk (0x1ul << EADC_AD1TRGEN1_PWM00PEN_Pos) /*!< EADC_T::AD1TRGEN1: PWM00PEN Mask */ + +#define EADC_AD1TRGEN1_PWM00CEN_Pos (27) /*!< EADC_T::AD1TRGEN1: PWM00CEN Position */ +#define EADC_AD1TRGEN1_PWM00CEN_Msk (0x1ul << EADC_AD1TRGEN1_PWM00CEN_Pos) /*!< EADC_T::AD1TRGEN1: PWM00CEN Mask */ + +#define EADC_AD1TRGEN1_PWM01REN_Pos (28) /*!< EADC_T::AD1TRGEN1: PWM01REN Position */ +#define EADC_AD1TRGEN1_PWM01REN_Msk (0x1ul << EADC_AD1TRGEN1_PWM01REN_Pos) /*!< EADC_T::AD1TRGEN1: PWM01REN Mask */ + +#define EADC_AD1TRGEN1_PWM01FEN_Pos (29) /*!< EADC_T::AD1TRGEN1: PWM01FEN Position */ +#define EADC_AD1TRGEN1_PWM01FEN_Msk (0x1ul << EADC_AD1TRGEN1_PWM01FEN_Pos) /*!< EADC_T::AD1TRGEN1: PWM01FEN Mask */ + +#define EADC_AD1TRGEN1_PWM01PEN_Pos (30) /*!< EADC_T::AD1TRGEN1: PWM01PEN Position */ +#define EADC_AD1TRGEN1_PWM01PEN_Msk (0x1ul << EADC_AD1TRGEN1_PWM01PEN_Pos) /*!< EADC_T::AD1TRGEN1: PWM01PEN Mask */ + +#define EADC_AD1TRGEN1_PWM01CEN_Pos (31) /*!< EADC_T::AD1TRGEN1: PWM01CEN Position */ +#define EADC_AD1TRGEN1_PWM01CEN_Msk (0x1ul << EADC_AD1TRGEN1_PWM01CEN_Pos) /*!< EADC_T::AD1TRGEN1: PWM01CEN Mask */ + +#define EADC_AD1TRGEN2_EPWM00REN_Pos (0) /*!< EADC_T::AD1TRGEN2: EPWM00REN Position */ +#define EADC_AD1TRGEN2_EPWM00REN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM00REN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM00REN Mask */ + +#define EADC_AD1TRGEN2_EPWM00FEN_Pos (1) /*!< EADC_T::AD1TRGEN2: EPWM00FEN Position */ +#define EADC_AD1TRGEN2_EPWM00FEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM00FEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM00FEN Mask */ + +#define EADC_AD1TRGEN2_EPWM00PEN_Pos (2) /*!< EADC_T::AD1TRGEN2: EPWM00PEN Position */ +#define EADC_AD1TRGEN2_EPWM00PEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM00PEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM00PEN Mask */ + +#define EADC_AD1TRGEN2_EPWM00CEN_Pos (3) /*!< EADC_T::AD1TRGEN2: EPWM00CEN Position */ +#define EADC_AD1TRGEN2_EPWM00CEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM00CEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM00CEN Mask */ + +#define EADC_AD1TRGEN2_EPWM02REN_Pos (4) /*!< EADC_T::AD1TRGEN2: EPWM02REN Position */ +#define EADC_AD1TRGEN2_EPWM02REN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM02REN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM02REN Mask */ + +#define EADC_AD1TRGEN2_EPWM02FEN_Pos (5) /*!< EADC_T::AD1TRGEN2: EPWM02FEN Position */ +#define EADC_AD1TRGEN2_EPWM02FEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM02FEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM02FEN Mask */ + +#define EADC_AD1TRGEN2_EPWM02PEN_Pos (6) /*!< EADC_T::AD1TRGEN2: EPWM02PEN Position */ +#define EADC_AD1TRGEN2_EPWM02PEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM02PEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM02PEN Mask */ + +#define EADC_AD1TRGEN2_EPWM02CEN_Pos (7) /*!< EADC_T::AD1TRGEN2: EPWM02CEN Position */ +#define EADC_AD1TRGEN2_EPWM02CEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM02CEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM02CEN Mask */ + +#define EADC_AD1TRGEN2_EPWM04REN_Pos (8) /*!< EADC_T::AD1TRGEN2: EPWM04REN Position */ +#define EADC_AD1TRGEN2_EPWM04REN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM04REN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM04REN Mask */ + +#define EADC_AD1TRGEN2_EPWM04FEN_Pos (9) /*!< EADC_T::AD1TRGEN2: EPWM04FEN Position */ +#define EADC_AD1TRGEN2_EPWM04FEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM04FEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM04FEN Mask */ + +#define EADC_AD1TRGEN2_EPWM04PEN_Pos (10) /*!< EADC_T::AD1TRGEN2: EPWM04PEN Position */ +#define EADC_AD1TRGEN2_EPWM04PEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM04PEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM04PEN Mask */ + +#define EADC_AD1TRGEN2_EPWM04CEN_Pos (11) /*!< EADC_T::AD1TRGEN2: EPWM04CEN Position */ +#define EADC_AD1TRGEN2_EPWM04CEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM04CEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM04CEN Mask */ + +#define EADC_AD1TRGEN2_EPWM10REN_Pos (12) /*!< EADC_T::AD1TRGEN2: EPWM10REN Position */ +#define EADC_AD1TRGEN2_EPWM10REN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM10REN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM10REN Mask */ + +#define EADC_AD1TRGEN2_EPWM10FEN_Pos (13) /*!< EADC_T::AD1TRGEN2: EPWM10FEN Position */ +#define EADC_AD1TRGEN2_EPWM10FEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM10FEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM10FEN Mask */ + +#define EADC_AD1TRGEN2_EPWM10PEN_Pos (14) /*!< EADC_T::AD1TRGEN2: EPWM10PEN Position */ +#define EADC_AD1TRGEN2_EPWM10PEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM10PEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM10PEN Mask */ + +#define EADC_AD1TRGEN2_EPWM10CEN_Pos (15) /*!< EADC_T::AD1TRGEN2: EPWM10CEN Position */ +#define EADC_AD1TRGEN2_EPWM10CEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM10CEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM10CEN Mask */ + +#define EADC_AD1TRGEN2_EPWM12REN_Pos (16) /*!< EADC_T::AD1TRGEN2: EPWM12REN Position */ +#define EADC_AD1TRGEN2_EPWM12REN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM12REN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM12REN Mask */ + +#define EADC_AD1TRGEN2_EPWM120FEN_Pos (17) /*!< EADC_T::AD1TRGEN2: EPWM120FEN Position */ +#define EADC_AD1TRGEN2_EPWM120FEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM120FEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM120FEN Mask */ + +#define EADC_AD1TRGEN2_EPWM12PEN_Pos (18) /*!< EADC_T::AD1TRGEN2: EPWM12PEN Position */ +#define EADC_AD1TRGEN2_EPWM12PEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM12PEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM12PEN Mask */ + +#define EADC_AD1TRGEN2_EPWM12CEN_Pos (19) /*!< EADC_T::AD1TRGEN2: EPWM12CEN Position */ +#define EADC_AD1TRGEN2_EPWM12CEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM12CEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM12CEN Mask */ + +#define EADC_AD1TRGEN2_EPWM14REN_Pos (20) /*!< EADC_T::AD1TRGEN2: EPWM14REN Position */ +#define EADC_AD1TRGEN2_EPWM14REN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM14REN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM14REN Mask */ + +#define EADC_AD1TRGEN2_EPWM14FEN_Pos (21) /*!< EADC_T::AD1TRGEN2: EPWM14FEN Position */ +#define EADC_AD1TRGEN2_EPWM14FEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM14FEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM14FEN Mask */ + +#define EADC_AD1TRGEN2_EPWM14PEN_Pos (22) /*!< EADC_T::AD1TRGEN2: EPWM14PEN Position */ +#define EADC_AD1TRGEN2_EPWM14PEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM14PEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM14PEN Mask */ + +#define EADC_AD1TRGEN2_EPWM14CEN_Pos (23) /*!< EADC_T::AD1TRGEN2: EPWM14CEN Position */ +#define EADC_AD1TRGEN2_EPWM14CEN_Msk (0x1ul << EADC_AD1TRGEN2_EPWM14CEN_Pos) /*!< EADC_T::AD1TRGEN2: EPWM14CEN Mask */ + +#define EADC_AD1TRGEN2_PWM00REN_Pos (24) /*!< EADC_T::AD1TRGEN2: PWM00REN Position */ +#define EADC_AD1TRGEN2_PWM00REN_Msk (0x1ul << EADC_AD1TRGEN2_PWM00REN_Pos) /*!< EADC_T::AD1TRGEN2: PWM00REN Mask */ + +#define EADC_AD1TRGEN2_PWM00FEN_Pos (25) /*!< EADC_T::AD1TRGEN2: PWM00FEN Position */ +#define EADC_AD1TRGEN2_PWM00FEN_Msk (0x1ul << EADC_AD1TRGEN2_PWM00FEN_Pos) /*!< EADC_T::AD1TRGEN2: PWM00FEN Mask */ + +#define EADC_AD1TRGEN2_PWM00PEN_Pos (26) /*!< EADC_T::AD1TRGEN2: PWM00PEN Position */ +#define EADC_AD1TRGEN2_PWM00PEN_Msk (0x1ul << EADC_AD1TRGEN2_PWM00PEN_Pos) /*!< EADC_T::AD1TRGEN2: PWM00PEN Mask */ + +#define EADC_AD1TRGEN2_PWM00CEN_Pos (27) /*!< EADC_T::AD1TRGEN2: PWM00CEN Position */ +#define EADC_AD1TRGEN2_PWM00CEN_Msk (0x1ul << EADC_AD1TRGEN2_PWM00CEN_Pos) /*!< EADC_T::AD1TRGEN2: PWM00CEN Mask */ + +#define EADC_AD1TRGEN2_PWM01REN_Pos (28) /*!< EADC_T::AD1TRGEN2: PWM01REN Position */ +#define EADC_AD1TRGEN2_PWM01REN_Msk (0x1ul << EADC_AD1TRGEN2_PWM01REN_Pos) /*!< EADC_T::AD1TRGEN2: PWM01REN Mask */ + +#define EADC_AD1TRGEN2_PWM01FEN_Pos (29) /*!< EADC_T::AD1TRGEN2: PWM01FEN Position */ +#define EADC_AD1TRGEN2_PWM01FEN_Msk (0x1ul << EADC_AD1TRGEN2_PWM01FEN_Pos) /*!< EADC_T::AD1TRGEN2: PWM01FEN Mask */ + +#define EADC_AD1TRGEN2_PWM01PEN_Pos (30) /*!< EADC_T::AD1TRGEN2: PWM01PEN Position */ +#define EADC_AD1TRGEN2_PWM01PEN_Msk (0x1ul << EADC_AD1TRGEN2_PWM01PEN_Pos) /*!< EADC_T::AD1TRGEN2: PWM01PEN Mask */ + +#define EADC_AD1TRGEN2_PWM01CEN_Pos (31) /*!< EADC_T::AD1TRGEN2: PWM01CEN Position */ +#define EADC_AD1TRGEN2_PWM01CEN_Msk (0x1ul << EADC_AD1TRGEN2_PWM01CEN_Pos) /*!< EADC_T::AD1TRGEN2: PWM01CEN Mask */ + +#define EADC_AD1TRGEN3_EPWM00REN_Pos (0) /*!< EADC_T::AD1TRGEN3: EPWM00REN Position */ +#define EADC_AD1TRGEN3_EPWM00REN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM00REN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM00REN Mask */ + +#define EADC_AD1TRGEN3_EPWM00FEN_Pos (1) /*!< EADC_T::AD1TRGEN3: EPWM00FEN Position */ +#define EADC_AD1TRGEN3_EPWM00FEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM00FEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM00FEN Mask */ + +#define EADC_AD1TRGEN3_EPWM00PEN_Pos (2) /*!< EADC_T::AD1TRGEN3: EPWM00PEN Position */ +#define EADC_AD1TRGEN3_EPWM00PEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM00PEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM00PEN Mask */ + +#define EADC_AD1TRGEN3_EPWM00CEN_Pos (3) /*!< EADC_T::AD1TRGEN3: EPWM00CEN Position */ +#define EADC_AD1TRGEN3_EPWM00CEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM00CEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM00CEN Mask */ + +#define EADC_AD1TRGEN3_EPWM02REN_Pos (4) /*!< EADC_T::AD1TRGEN3: EPWM02REN Position */ +#define EADC_AD1TRGEN3_EPWM02REN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM02REN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM02REN Mask */ + +#define EADC_AD1TRGEN3_EPWM02FEN_Pos (5) /*!< EADC_T::AD1TRGEN3: EPWM02FEN Position */ +#define EADC_AD1TRGEN3_EPWM02FEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM02FEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM02FEN Mask */ + +#define EADC_AD1TRGEN3_EPWM02PEN_Pos (6) /*!< EADC_T::AD1TRGEN3: EPWM02PEN Position */ +#define EADC_AD1TRGEN3_EPWM02PEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM02PEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM02PEN Mask */ + +#define EADC_AD1TRGEN3_EPWM02CEN_Pos (7) /*!< EADC_T::AD1TRGEN3: EPWM02CEN Position */ +#define EADC_AD1TRGEN3_EPWM02CEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM02CEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM02CEN Mask */ + +#define EADC_AD1TRGEN3_EPWM04REN_Pos (8) /*!< EADC_T::AD1TRGEN3: EPWM04REN Position */ +#define EADC_AD1TRGEN3_EPWM04REN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM04REN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM04REN Mask */ + +#define EADC_AD1TRGEN3_EPWM04FEN_Pos (9) /*!< EADC_T::AD1TRGEN3: EPWM04FEN Position */ +#define EADC_AD1TRGEN3_EPWM04FEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM04FEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM04FEN Mask */ + +#define EADC_AD1TRGEN3_EPWM04PEN_Pos (10) /*!< EADC_T::AD1TRGEN3: EPWM04PEN Position */ +#define EADC_AD1TRGEN3_EPWM04PEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM04PEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM04PEN Mask */ + +#define EADC_AD1TRGEN3_EPWM04CEN_Pos (11) /*!< EADC_T::AD1TRGEN3: EPWM04CEN Position */ +#define EADC_AD1TRGEN3_EPWM04CEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM04CEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM04CEN Mask */ + +#define EADC_AD1TRGEN3_EPWM10REN_Pos (12) /*!< EADC_T::AD1TRGEN3: EPWM10REN Position */ +#define EADC_AD1TRGEN3_EPWM10REN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM10REN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM10REN Mask */ + +#define EADC_AD1TRGEN3_EPWM10FEN_Pos (13) /*!< EADC_T::AD1TRGEN3: EPWM10FEN Position */ +#define EADC_AD1TRGEN3_EPWM10FEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM10FEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM10FEN Mask */ + +#define EADC_AD1TRGEN3_EPWM10PEN_Pos (14) /*!< EADC_T::AD1TRGEN3: EPWM10PEN Position */ +#define EADC_AD1TRGEN3_EPWM10PEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM10PEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM10PEN Mask */ + +#define EADC_AD1TRGEN3_EPWM10CEN_Pos (15) /*!< EADC_T::AD1TRGEN3: EPWM10CEN Position */ +#define EADC_AD1TRGEN3_EPWM10CEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM10CEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM10CEN Mask */ + +#define EADC_AD1TRGEN3_EPWM12REN_Pos (16) /*!< EADC_T::AD1TRGEN3: EPWM12REN Position */ +#define EADC_AD1TRGEN3_EPWM12REN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM12REN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM12REN Mask */ + +#define EADC_AD1TRGEN3_EPWM120FEN_Pos (17) /*!< EADC_T::AD1TRGEN3: EPWM120FEN Position */ +#define EADC_AD1TRGEN3_EPWM120FEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM120FEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM120FEN Mask */ + +#define EADC_AD1TRGEN3_EPWM12PEN_Pos (18) /*!< EADC_T::AD1TRGEN3: EPWM12PEN Position */ +#define EADC_AD1TRGEN3_EPWM12PEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM12PEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM12PEN Mask */ + +#define EADC_AD1TRGEN3_EPWM12CEN_Pos (19) /*!< EADC_T::AD1TRGEN3: EPWM12CEN Position */ +#define EADC_AD1TRGEN3_EPWM12CEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM12CEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM12CEN Mask */ + +#define EADC_AD1TRGEN3_EPWM14REN_Pos (20) /*!< EADC_T::AD1TRGEN3: EPWM14REN Position */ +#define EADC_AD1TRGEN3_EPWM14REN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM14REN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM14REN Mask */ + +#define EADC_AD1TRGEN3_EPWM14FEN_Pos (21) /*!< EADC_T::AD1TRGEN3: EPWM14FEN Position */ +#define EADC_AD1TRGEN3_EPWM14FEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM14FEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM14FEN Mask */ + +#define EADC_AD1TRGEN3_EPWM14PEN_Pos (22) /*!< EADC_T::AD1TRGEN3: EPWM14PEN Position */ +#define EADC_AD1TRGEN3_EPWM14PEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM14PEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM14PEN Mask */ + +#define EADC_AD1TRGEN3_EPWM14CEN_Pos (23) /*!< EADC_T::AD1TRGEN3: EPWM14CEN Position */ +#define EADC_AD1TRGEN3_EPWM14CEN_Msk (0x1ul << EADC_AD1TRGEN3_EPWM14CEN_Pos) /*!< EADC_T::AD1TRGEN3: EPWM14CEN Mask */ + +#define EADC_AD1TRGEN3_PWM00REN_Pos (24) /*!< EADC_T::AD1TRGEN3: PWM00REN Position */ +#define EADC_AD1TRGEN3_PWM00REN_Msk (0x1ul << EADC_AD1TRGEN3_PWM00REN_Pos) /*!< EADC_T::AD1TRGEN3: PWM00REN Mask */ + +#define EADC_AD1TRGEN3_PWM00FEN_Pos (25) /*!< EADC_T::AD1TRGEN3: PWM00FEN Position */ +#define EADC_AD1TRGEN3_PWM00FEN_Msk (0x1ul << EADC_AD1TRGEN3_PWM00FEN_Pos) /*!< EADC_T::AD1TRGEN3: PWM00FEN Mask */ + +#define EADC_AD1TRGEN3_PWM00PEN_Pos (26) /*!< EADC_T::AD1TRGEN3: PWM00PEN Position */ +#define EADC_AD1TRGEN3_PWM00PEN_Msk (0x1ul << EADC_AD1TRGEN3_PWM00PEN_Pos) /*!< EADC_T::AD1TRGEN3: PWM00PEN Mask */ + +#define EADC_AD1TRGEN3_PWM00CEN_Pos (27) /*!< EADC_T::AD1TRGEN3: PWM00CEN Position */ +#define EADC_AD1TRGEN3_PWM00CEN_Msk (0x1ul << EADC_AD1TRGEN3_PWM00CEN_Pos) /*!< EADC_T::AD1TRGEN3: PWM00CEN Mask */ + +#define EADC_AD1TRGEN3_PWM01REN_Pos (28) /*!< EADC_T::AD1TRGEN3: PWM01REN Position */ +#define EADC_AD1TRGEN3_PWM01REN_Msk (0x1ul << EADC_AD1TRGEN3_PWM01REN_Pos) /*!< EADC_T::AD1TRGEN3: PWM01REN Mask */ + +#define EADC_AD1TRGEN3_PWM01FEN_Pos (29) /*!< EADC_T::AD1TRGEN3: PWM01FEN Position */ +#define EADC_AD1TRGEN3_PWM01FEN_Msk (0x1ul << EADC_AD1TRGEN3_PWM01FEN_Pos) /*!< EADC_T::AD1TRGEN3: PWM01FEN Mask */ + +#define EADC_AD1TRGEN3_PWM01PEN_Pos (30) /*!< EADC_T::AD1TRGEN3: PWM01PEN Position */ +#define EADC_AD1TRGEN3_PWM01PEN_Msk (0x1ul << EADC_AD1TRGEN3_PWM01PEN_Pos) /*!< EADC_T::AD1TRGEN3: PWM01PEN Mask */ + +#define EADC_AD1TRGEN3_PWM01CEN_Pos (31) /*!< EADC_T::AD1TRGEN3: PWM01CEN Position */ +#define EADC_AD1TRGEN3_PWM01CEN_Msk (0x1ul << EADC_AD1TRGEN3_PWM01CEN_Pos) /*!< EADC_T::AD1TRGEN3: PWM01CEN Mask */ + +/**@}*/ /* EADC_CONST */ +/**@}*/ /* end of EADC register group */ + + +/*---------------------- External Bus Interface Controller -------------------------*/ +/** + @addtogroup EBI External Bus Interface Controller(EBI) + Memory Mapped Structure for EBI Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 External Bus Interface General Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[8:10] |MCLKDIV |External Output Clock Divider + * | | |The frequency of EBI output clock is controlled by MCLKDIV as below: + * | | |000 = HCLK/1. + * | | |001 = HCLK/2. + * | | |010 = HCLK/4. + * | | |011 = HCLK/8. + * | | |100 = HCLK/16. + * | | |101 = HCLK/32. + * | | |11x = Default. + * | | |Note: Default value of output clock is HCLK/1 + * |[24:27] |CRYPTOEN |Encrypt/Decrypt Function Enable Control (For 4 Individual Chip Select) + * | | |0 = Encrypt/Decrypt function Disabled. + * | | |1 = Encrypt/Decrypt function Enabled. + * |[28:31] |CSPOLINV |Reverse Chip Select + * | | |The original design Chip Select is active low nCS. + * | | |"Chip Select Active High" can be specified by customers-Bit[28+n] is for nCS[n], where n=0~3. + * | | |0 = nCS (chip select active low). + * | | |1 = CS (chip select active high). + */ + __IO uint32_t CTL; + + /** + * TCTL + * =================================================================================================== + * Offset: 0x04 - 0x10 External Bus Interface Bank0~3 Timing Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |TALE |Bank Expand Time Of ALE + * | | |The ALE width (tALE) to latch the address can be controlled by TALE. + * | | |tALE = (TALE+1)*MCLK. + * |[3:7] |TACC |EBI Bank Data Access Time + * | | |TACC define data access time (tACC). + * | | |tACC = (TACC +1) * MCLK. + * |[8:10] |TAHD |EBI Bank Data Access Hold Time + * | | |TAHD define data access hold time (tAHD). + * | | |tAHD = (TAHD +1) * MCLK. + * |[12:15] |W2X |Bank Idle State Cycle After Write + * | | |When write action is finish, idle state is inserted and nCS[0] return to high if W2X is not zero. + * | | |Idle state cycle = (W2X*MCLK). + * | | |0 = reserved. + * |[16:19] |R2W |Bank Idle State Cycle Between Read-Write + * | | |When read action is finish and next action is going to write, idle state is inserted and nCS[0] return to high if R2W is not zero. + * | | |Idle state cycle = (R2W*MCLK). + * | | |0 = reserved. + * |[24:27] |R2R |Bank Idle State Cycle Between Read-Read + * | | |When read action is finish and next action is going to read, idle state is inserted and nCS[0] return to high if R2R is not zero. + * | | |Idle state cycle = (R2R*MCLK). + * | | |0 = reserved. + * |[28] |CSEN |EBI Bank Enable Control + * | | |This bit is the functional enable bit for EBI. + * | | |0 = EBI function Disabled. + * | | |1 = EBI function Enabled. + * |[29] |DW16 |EBI Bank Data Width 16-Bit + * | | |This bit defines if the data bus is 8-bit or 16-bit. + * | | |0 = EBI data width is 8-bit. + * | | |1 = EBI data width is 16-bit. + * |[30] |SEPEN |EBI Bank Address/Data Bus Separating Enable Control + * | | |0 = Address/Data Bus Separating Disabled. + * | | |1 = Address/Data Bus Separating Enabled. + */ + __IO uint32_t TCTL[4]; + + /** + * KEY0 + * =================================================================================================== + * Offset: 0x14 External Bus Interface Crypto Key Word 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY0 |Crypto Key Word 0 (key[31:0]). + */ + __IO uint32_t KEY0; + + /** + * KEY1 + * =================================================================================================== + * Offset: 0x18 External Bus Interface Crypto Key Word 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |Crypto Key Word 1 (key[63:32]). + */ + __IO uint32_t KEY1; + + /** + * KEY2 + * =================================================================================================== + * Offset: 0x1C External Bus Interface Crypto Key Word 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |Crypto Key Word 2 (key[95:64]). + */ + __IO uint32_t KEY2; + + /** + * KEY3 + * =================================================================================================== + * Offset: 0x20 External Bus Interface Crypto Key Word 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |KEY |Crypto Key Word 3 (key[127:96]). + */ + __IO uint32_t KEY3; + +} EBI_T; + +/** + @addtogroup EBI_CONST EBI Bit Field Definition + Constant Definitions for EBI Controller +@{ */ + +#define EBI_CTL_MCLKDIV_Pos (8) /*!< EBI_T::CTL: MCLKDIV Position */ +#define EBI_CTL_MCLKDIV_Msk (0x7ul << EBI_CTL_MCLKDIV_Pos) /*!< EBI_T::CTL: MCLKDIV Mask */ + +#define EBI_CTL_CRYPTOEN_Pos (24) /*!< EBI_T::CTL: CRYPTOEN Position */ +#define EBI_CTL_CRYPTOEN_Msk (0xful << EBI_CTL_CRYPTOEN_Pos) /*!< EBI_T::CTL: CRYPTOEN Mask */ + +#define EBI_CTL_CSPOLINV_Pos (28) /*!< EBI_T::CTL: CSPOLINV Position */ +#define EBI_CTL_CSPOLINV_Msk (0xful << EBI_CTL_CSPOLINV_Pos) /*!< EBI_T::CTL: CSPOLINV Mask */ + +#define EBI_TCTL_TALE_Pos (0) /*!< EBI_T::TCTL: TALE Position */ +#define EBI_TCTL_TALE_Msk (0x7ul << EBI_TCTL_TALE_Pos) /*!< EBI_T::TCTL: TALE Mask */ + +#define EBI_TCTL_TACC_Pos (3) /*!< EBI_T::TCTL: TACC Position */ +#define EBI_TCTL_TACC_Msk (0x1ful << EBI_TCTL_TACC_Pos) /*!< EBI_T::TCTL: TACC Mask */ + +#define EBI_TCTL_TAHD_Pos (8) /*!< EBI_T::TCTL: TAHD Position */ +#define EBI_TCTL_TAHD_Msk (0x7ul << EBI_TCTL_TAHD_Pos) /*!< EBI_T::TCTL: TAHD Mask */ + +#define EBI_TCTL_W2X_Pos (12) /*!< EBI_T::TCTL: W2X Position */ +#define EBI_TCTL_W2X_Msk (0xful << EBI_TCTL_W2X_Pos) /*!< EBI_T::TCTL: W2X Mask */ + +#define EBI_TCTL_R2W_Pos (16) /*!< EBI_T::TCTL: R2W Position */ +#define EBI_TCTL_R2W_Msk (0xful << EBI_TCTL_R2W_Pos) /*!< EBI_T::TCTL: R2W Mask */ + +#define EBI_TCTL_R2R_Pos (24) /*!< EBI_T::TCTL: R2R Position */ +#define EBI_TCTL_R2R_Msk (0xful << EBI_TCTL_R2R_Pos) /*!< EBI_T::TCTL: R2R Mask */ + +#define EBI_TCTL_CSEN_Pos (28) /*!< EBI_T::TCTL: CSEN Position */ +#define EBI_TCTL_CSEN_Msk (0x1ul << EBI_TCTL_CSEN_Pos) /*!< EBI_T::TCTL: CSEN Mask */ + +#define EBI_TCTL_DW16_Pos (29) /*!< EBI_T::TCTL: DW16 Position */ +#define EBI_TCTL_DW16_Msk (0x1ul << EBI_TCTL_DW16_Pos) /*!< EBI_T::TCTL: DW16 Mask */ + +#define EBI_TCTL_SEPEN_Pos (30) /*!< EBI_T::TCTL: SEPEN Position */ +#define EBI_TCTL_SEPEN_Msk (0x1ul << EBI_TCTL_SEPEN_Pos) /*!< EBI_T::TCTL: SEPEN Mask */ + +#define EBI_KEY0_KEY_Pos (0) /*!< EBI_T::KEY0: KEY Position */ +#define EBI_KEY0_KEY_Msk (0xfffffffful << EBI_KEY0_KEY_Pos) /*!< EBI_T::KEY0: KEY Mask */ + +#define EBI_KEY1_KEY_Pos (0) /*!< EBI_T::KEY1: KEY Position */ +#define EBI_KEY1_KEY_Msk (0xfffffffful << EBI_KEY1_KEY_Pos) /*!< EBI_T::KEY1: KEY Mask */ + +#define EBI_KEY2_KEY_Pos (0) /*!< EBI_T::KEY2: KEY Position */ +#define EBI_KEY2_KEY_Msk (0xfffffffful << EBI_KEY2_KEY_Pos) /*!< EBI_T::KEY2: KEY Mask */ + +#define EBI_KEY3_KEY_Pos (0) /*!< EBI_T::KEY3: KEY Position */ +#define EBI_KEY3_KEY_Msk (0xfffffffful << EBI_KEY3_KEY_Pos) /*!< EBI_T::KEY3: KEY Mask */ + +/**@}*/ /* EBI_CONST */ +/**@}*/ /* end of EBI register group */ + + +/*---------------------- Ethernet MAC Controller -------------------------*/ +/** + @addtogroup EMAC Ethernet MAC Controller(EMAC) + Memory Mapped Structure for EMAC Controller +@{ */ + +typedef struct { + + + /** + * CAMCTL + * =================================================================================================== + * Offset: 0x00 CAM Comparison Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |AUP |Accept Unicast Packet + * | | |The AUP controls the unicast packet reception. + * | | |If AUP is enabled, EMAC receives all incoming packet its destination MAC address is a unicast address. + * | | |0 = EMAC receives packet depends on the CAM comparison result. + * | | |1 = EMAC receives all unicast packets. + * |[1] |AMP |Accept Multicast Packet + * | | |The AMP controls the multicast packet reception. + * | | |If AMP is enabled, EMAC receives all incoming packet its destination MAC address is a multicast address. + * | | |0 = EMAC receives packet depends on the CAM comparison result. + * | | |1 = EMAC receives all multicast packets. + * |[2] |ABP |Accept Broadcast Packet + * | | |The ABP controls the broadcast packet reception. + * | | |If ABP is enabled, EMAC receives all incoming packet its destination MAC address is a broadcast address. + * | | |0 = EMAC receives packet depends on the CAM comparison result. + * | | |1 = EMAC receives all broadcast packets. + * |[3] |COMPEN |Complement CAM Comparison Enable + * | | |The COMPEN controls the complement of the CAM comparison result. + * | | |If the CMPEN and COMPEN are both enabled, the incoming packet with specific destination MAC address configured in CAM entry will be dropped. + * | | |And the incoming packet with destination MAC address does not configured in any CAM entry will be received. + * | | |0 = The CAM comparison result does not complement. + * | | |1 = The CAM comparison result complemented. + * |[4] |CMPEN |CAM Compare Enable + * | | |The CMPEN controls the enable of CAM comparison function for destination MAC address recognition. + * | | |If software wants to receive a packet with specific destination MAC address, configures the MAC address into CAM 12~0, then enables that CAM entry and set CMPEN to 1. + * | | |0 = CAM comparison function for destination MAC address recognition disabled. + * | | |1 = CAM comparison function for destination MAC address recognition enabled. + */ + __IO uint32_t CAMCTL; + + /** + * CAMEN + * =================================================================================================== + * Offset: 0x04 CAM Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CAMxEN |CAM Entry X Enable Control + * | | |The CAMxEN controls the validation of CAM entry x. + * | | |The CAM entry 13, 14 and 15 are for PAUSE control frame transmission. + * | | |If software wants to transmit a PAUSE control frame out to network, the enable bits of these three CAM entries all must be enabled first. + * | | |0 = CAM entry x Disabled. + * | | |1 = CAM entry x Enabled. + */ + __IO uint32_t CAMEN; + + /** + * CAM0M + * =================================================================================================== + * Offset: 0x08 CAM0 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM0M; + + /** + * CAM0L + * =================================================================================================== + * Offset: 0x0C CAM0 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM0L; + + /** + * CAM1M + * =================================================================================================== + * Offset: 0x10 CAM1 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM1M; + + /** + * CAM1L + * =================================================================================================== + * Offset: 0x14 CAM1 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM1L; + + /** + * CAM2M + * =================================================================================================== + * Offset: 0x18 CAM2 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM2M; + + /** + * CAM2L + * =================================================================================================== + * Offset: 0x1C CAM2 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM2L; + + /** + * CAM3M + * =================================================================================================== + * Offset: 0x20 CAM3 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM3M; + + /** + * CAM3L + * =================================================================================================== + * Offset: 0x24 CAM3 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM3L; + + /** + * CAM4M + * =================================================================================================== + * Offset: 0x28 CAM4 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM4M; + + /** + * CAM4L + * =================================================================================================== + * Offset: 0x2C CAM4 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM4L; + + /** + * CAM5M + * =================================================================================================== + * Offset: 0x30 CAM5 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM5M; + + /** + * CAM5L + * =================================================================================================== + * Offset: 0x34 CAM5 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM5L; + + /** + * CAM6M + * =================================================================================================== + * Offset: 0x38 CAM6 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM6M; + + /** + * CAM6L + * =================================================================================================== + * Offset: 0x3C CAM6 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM6L; + + /** + * CAM7M + * =================================================================================================== + * Offset: 0x40 CAM7 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM7M; + + /** + * CAM7L + * =================================================================================================== + * Offset: 0x44 CAM7 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM7L; + + /** + * CAM8M + * =================================================================================================== + * Offset: 0x48 CAM8 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM8M; + + /** + * CAM8L + * =================================================================================================== + * Offset: 0x4C CAM8 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM8L; + + /** + * CAM9M + * =================================================================================================== + * Offset: 0x50 CAM9 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM9M; + + /** + * CAM9L + * =================================================================================================== + * Offset: 0x54 CAM9 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM9L; + + /** + * CAM10M + * =================================================================================================== + * Offset: 0x58 CAM10 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM10M; + + /** + * CAM10L + * =================================================================================================== + * Offset: 0x5C CAM10 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM10L; + + /** + * CAM11M + * =================================================================================================== + * Offset: 0x60 CAM11 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM11M; + + /** + * CAM11L + * =================================================================================================== + * Offset: 0x64 CAM11 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM11L; + + /** + * CAM12M + * =================================================================================================== + * Offset: 0x68 CAM12 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM12M; + + /** + * CAM12L + * =================================================================================================== + * Offset: 0x6C CAM12 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM12L; + + /** + * CAM13M + * =================================================================================================== + * Offset: 0x70 CAM13 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM13M; + + /** + * CAM13L + * =================================================================================================== + * Offset: 0x74 CAM13 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM13L; + + /** + * CAM14M + * =================================================================================================== + * Offset: 0x78 CAM14 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |MACADDR2 |MAC Address Byte 2 + * |[8:15] |MACADDR3 |MAC Address Byte 3 + * |[16:23] |MACADDR4 |MAC Address Byte 4 + * |[24:31] |MACADDR5 |MAC Address Byte 5 + * | | |The CAMxM keeps the bit 47~16 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM14M; + + /** + * CAM14L + * =================================================================================================== + * Offset: 0x7C CAM14 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:23] |MACADDR0 |MAC Address Byte 0 + * |[24:31] |MACADDR1 |MAC Address Byte 1 + * | | |The CAMxL keeps the bit 15~0 of MAC address. + * | | |The x can be the 0~14. + * | | |The register pair {EMAC_CAMxMSB, EMAC_CAMxLSB} represents a CAM entry and keeps a MAC address. + * | | |For example, if the MAC address 00-50-BA-33-BA-44 kept in CAM entry 1, the register EMAC_CAM1M is 0x0050_BA33 and EMAC_CAM1L is 0xBA44_0000. + */ + __IO uint32_t CAM14L; + + /** + * CAM15MSB + * =================================================================================================== + * Offset: 0x80 CAM15 Most Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |OPCODE |OP Code Field of PAUSE Control Frame + * | | |In the PAUSE control frame, an op code field defined and is 0x0001. + * |[16:31] |LENGTH |LENGTH Field of PAUSE Control Frame + * | | |In the PAUSE control frame, a LENGTH field defined and is 0x8808. + */ + __IO uint32_t CAM15MSB; + + /** + * CAM15LSB + * =================================================================================================== + * Offset: 0x84 CAM15 Least Significant Word Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[24:31] |OPERAND |Pause Parameter + * | | |In the PAUSE control frame, an OPERAND field defined and controls how much time the destination Ethernet MAC Controller paused. + * | | |The unit of the OPERAND is a slot time, the 512 bits time. + */ + __IO uint32_t CAM15LSB; + + /** + * TXDSA + * =================================================================================================== + * Offset: 0x88 Transmit Descriptor Link List Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |TXDSA |Transmit Descriptor Link-List Start Address + * | | |The TXDSA keeps the start address of transmit descriptor link-list. + * | | |If the software enables the bit TXON (EMAC_CTL[8]), the content of TXDSA will be loaded into the current transmit descriptor start address register (EMAC_CTXDSA). + * | | |The TXDSA does not be updated by EMAC. + * | | |During the operation, EMAC will ignore the bits [1:0] of TXDSA. + * | | |This means that each TX descriptor always must locate at word boundary memory address. + */ + __IO uint32_t TXDSA; + + /** + * RXDSA + * =================================================================================================== + * Offset: 0x8C Receive Descriptor Link List Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |RXDSA |Receive Descriptor Link-List Start Address + * | | |The RXDSA keeps the start address of receive descriptor link-list. + * | | |If the S/W enables the bit RXON (EMAC_CTL[0]), the content of RXDSA will be loaded into the current receive descriptor start address register (EMAC_CRXDSA). + * | | |The RXDSA does not be updated by EMAC. + * | | |During the operation, EMAC will ignore the bits [1:0] of RXDSA. + * | | |This means that each RX descriptor always must locate at word boundary memory address. + */ + __IO uint32_t RXDSA; + + /** + * CTL + * =================================================================================================== + * Offset: 0x90 MAC Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXON |Frame Reception ON + * | | |The RXON controls the normal packet reception of EMAC. + * | | |If the RXON is set to high, the EMAC starts the packet reception process, including the RX descriptor fetching, packet reception and RX descriptor modification. + * | | |It is necessary to finish EMAC initial sequence before enable RXON. + * | | |Otherwise, the EMAC operation is undefined. + * | | |If the RXON is disabled during EMAC is receiving an incoming packet, the EMAC stops the packet reception process after the current packet reception finished. + * | | |0 = Packet reception process stopped. + * | | |1 = Packet reception process started. + * |[1] |ALP |Accept Long Packet + * | | |The ALP controls the long packet, which packet length is greater than 1518 bytes, reception. + * | | |If the ALP is set to high, the EMAC will accept the long packet. + * | | |Otherwise, the long packet will be dropped. + * | | |0 = Ethernet MAC controller dropped the long packet. + * | | |1 = Ethernet MAC controller received the long packet. + * |[2] |ARP |Accept Runt Packet + * | | |The ARP controls the runt packet, which length is less than 64 bytes, reception. + * | | |If the ARP is set to high, the EMAC will accept the runt packet. + * | | |Otherwise, the runt packet will be dropped. + * | | |0 = Ethernet MAC controller dropped the runt packet. + * | | |1 = Ethernet MAC controller received the runt packet. + * |[3] |ACP |Accept Control Packet + * | | |The ACP controls the control frame reception. + * | | |If the ACP is set to high, the EMAC will accept the control frame. + * | | |Otherwise, the control frame will be dropped. + * | | |It is recommended that S/W only enable ACP while EMAC is operating on full duplex mode. + * | | |0 = Ethernet MAC controller dropped the control frame. + * | | |1 = Ethernet MAC controller received the control frame. + * |[4] |AEP |Accept CRC Error Packet + * | | |The AEP controls the EMAC accepts or drops the CRC error packet. + * | | |If the AEP is set to high, the incoming packet with CRC error will be received by EMAC as a good packet. + * | | |0 = Ethernet MAC controller dropped the CRC error packet. + * | | |1 = Ethernet MAC controller received the CRC error packet. + * |[5] |STRIPCRC |Strip CRC Checksum + * | | |The STRIPCRC controls if the length of incoming packet is calculated with 4 bytes CRC checksum. + * | | |If the STRIPCRC is set to high, 4 bytes CRC checksum is excluded from length calculation of incoming packet. + * | | |0 = The 4 bytes CRC checksum is included in packet length calculation. + * | | |1 = The 4 bytes CRC checksum is excluded in packet length calculation. + * |[6] |WOLEN |Wake On LAN Enable + * | | |The WOLEN high enables the functionality that Ethernet MAC controller checked if the incoming packet is Magic Packet and wakeup system from Power-down mode. + * | | |If incoming packet was a Magic Packet and the system was in Power-down, the Ethernet MAC controller would generate a wakeup event to wake system up from Power-down mode. + * | | |0 = Wake-up by Magic Packet function Disabled. + * | | |1 = Wake-up by Magic Packet function Enabled. + * |[8] |TXON |Frame Transmission ON + * | | |The TXON controls the normal packet transmission of EMAC. + * | | |If the TXON is set to high, the EMAC starts the packet transmission process, including the TX descriptor fetching, packet transmission and TX descriptor modification. + * | | |It is must to finish EMAC initial sequence before enable TXON. + * | | |Otherwise, the EMAC operation is undefined. + * | | |If the TXON is disabled during EMAC is transmitting a packet out, the EMAC stops the packet transmission process after the current packet transmission finished. + * | | |0 = Packet transmission process stopped. + * | | |1 = Packet transmission process started. + * |[9] |NODEF |No Deferral + * | | |The NODEF controls the enable of deferral exceed counter. + * | | |If NODEF is set to high, the deferral exceed counter is disabled. + * | | |The NODEF is only useful while EMAC is operating on half duplex mode. + * | | |0 = The deferral exceed counter Enabled. + * | | |1 = The deferral exceed counter Disabled. + * |[16] |SDPZ |Send PAUSE Frame + * | | |The SDPZ controls the PAUSE control frame transmission. + * | | |If S/W wants to send a PAUSE control frame out, the CAM entry 13, 14 and 15 must be configured first and the corresponding CAM enable bit of CAMEN register also must be set. + * | | |Then, set SDPZ to 1 enables the PAUSE control frame transmission. + * | | |The SDPZ is a self-clear bit. + * | | |This means after the PAUSE control frame transmission has completed, the SDPZ will be cleared automatically. + * | | |It is recommended that only enabling SNDPAUSE while EMAC is operating in Full Duplex mode. + * | | |0 = PAUSE control frame transmission completed. + * | | |1 = PAUSE control frame transmission Enabled. + * |[17] |SQECHKEN |SQE Checking Enable + * | | |The SQECHKEN controls the enable of SQE checking. + * | | |The SQE checking is only available while EMAC is operating on 10M bps and half duplex mode. + * | | |In other words, the SQECHKEN cannot affect EMAC operation, if the EMAC is operating on 100M bps or full duplex mode. + * | | |0 = SQE checking Disabled while EMAC is operating in 10Mbps and Half Duplex mode. + * | | |1 = SQE checking Enabled while EMAC is operating in 10Mbps and Half Duplex mode. + * |[18] |FUDUP |Full Duplex Mode Selection + * | | |The FUDUP controls that if EMAC is operating on full or half duplex mode. + * | | |0 = EMAC operates in half duplex mode. + * | | |1 = EMAC operates in full duplex mode. + * |[19] |RMIIRXCTL |RMII RX Control + * | | |The RMIIRXCTL control the receive data sample in RMII mode. + * | | |It's necessary to set this bit high when RMIIEN (EMAC_CTL[ [22]) is high. + * | | |0 = RMII RX control disabled. + * | | |1 = RMII RX control enabled. + * |[20] |OPMODE |Operation Mode Selection + * | | |The OPMODE defines that if the EMAC is operating on 10M or 100M bps mode. + * | | |The RST (EMAC_CTL[24]) would not affect OPMODE value. + * | | |0 = EMAC operates in 10Mbps mode. + * | | |1 = EMAC operates in 100Mbps mode. + * |[22] |RMIIEN |RMII Mode Enable + * | | |This bit controls if Ethernet MAC controller connected with off-chip Ethernet PHY by MII interface or RMII interface. + * | | |The RST (EMAC_CTL[24]) would not affect RMIIEN value. + * | | |0 = Ethernet MAC controller MII mode Enabled. + * | | |1 = Ethernet MAC controller RMII mode Enabled. + * |[24] |RST |Software Reset + * | | |The RST implements a reset function to make the EMAC return default state. + * | | |The RST is a self-clear bit. + * | | |This means after the software reset finished, the RST will be cleared automatically. + * | | |Enable RST can also reset all control and status registers, exclusive of the control bits RMIIEN (EMAC_CTL[22]), LOOPBK (EMAC_CTL[21]) and OPMODE (EMAC_CTL[20]). + * | | |The EMAC re-initial is necessary after the software reset completed. + * | | |0 = Software reset completed. + * | | |1 = Software reset Enabled. + */ + __IO uint32_t CTL; + + /** + * MIIMDAT + * =================================================================================================== + * Offset: 0x94 MII Management Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |DATA |MII Management Data + * | | |The DATA is the 16 bits data that will be written into the registers of external PHY for MII Management write command or the data from the registers of external PHY for MII Management read command. + */ + __IO uint32_t MIIMDAT; + + /** + * MIIMCTL + * =================================================================================================== + * Offset: 0x98 MII Management Control and Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:4] |PHYREG |PHY Register Address + * | | |The PHYREG keeps the address to indicate which register of external PHY is the target of the MII management command. + * |[8:12] |PHYADDR |PHY Address + * | | |The PHYADDR keeps the address to differentiate which external PHY is the target of the MII management command. + * |[16] |WRITE |Write Command + * | | |The Write defines the MII management command is a read or write. + * | | |0 = MII management command is a read command. + * | | |1 = MII management command is a write command. + * |[17] |BUSY |Busy Bit + * | | |The BUSY controls the enable of the MII management frame generation. + * | | |If S/W wants to access registers of external PHY, it set BUSY to high and EMAC generates the MII management frame to external PHY through MII Management I/F. + * | | |The BUSY is a self-clear bit. + * | | |This means the BUSY will be cleared automatically after the MII management command finished. + * | | |0 = MII management command generation finished. + * | | |1 = MII management command generation Enabled. + * |[18] |PREAMSP |Preamble Suppress + * | | |The PREAMSP controls the preamble field generation of MII management frame. + * | | |If the PREAMSP is set to high, the preamble field generation of MII management frame is skipped. + * | | |0 = Preamble field generation of MII management frame not skipped. + * | | |1 = Preamble field generation of MII management frame skipped. + * |[19] |MDCON |MDC Clock ON Always + * | | |The MDC controls the MDC clock generation. + * | | |If the MDCON is set to high, the MDC clock actives always. + * | | |Otherwise, the MDC will only active while S/W issues a MII management command. + * | | |0 = MDC clock only actives while S/W issues a MII management command. + * | | |1 = MDC clock actives always. + */ + __IO uint32_t MIIMCTL; + + /** + * FIFOCTL + * =================================================================================================== + * Offset: 0x9C FIFO Threshold Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |RXFIFOTH |RXFIFO Low Threshold + * | | |The RXFIFOTH controls when RXDMA requests internal arbiter for data transfer between RXFIFO and system memory. + * | | |The RXFIFOTH defines not only the high threshold of RXFIFO, but also the low threshold. + * | | |The low threshold is the half of high threshold always. + * | | |During the packet reception, if the RXFIFO reaches the high threshold, the RXDMA starts to transfer frame data from RXFIFO to system memory. + * | | |If the frame data in RXFIFO is less than low threshold, RXDMA stops to transfer the frame data to system memory. + * | | |00 = Depend on the burst length setting. + * | | |If the burst length is 8 words, high threshold is 8 words, too. + * | | |01 = RXFIFO high threshold is 64B and low threshold is 32B. + * | | |10 = RXFIFO high threshold is 128B and low threshold is 64B. + * | | |11 = RXFIFO high threshold is 192B and low threshold is 96B. + * |[8:9] |TXFIFOTH |TXFIFO Low Threshold + * | | |The TXFIFOTH controls when TXDMA requests internal arbiter for data transfer between system memory and TXFIFO. + * | | |The TXFIFOTH defines not only the low threshold of TXFIFO, but also the high threshold. + * | | |The high threshold is the twice of low threshold always.During the packet transmission, if the TXFIFO reaches the high threshold, the TXDMA stops generate request to transfer frame data from system memory to TXFIFO. + * | | |If the frame data in TXFIFO is less than low threshold, TXDMA starts to transfer frame data from system memory to TXFIFO. + * | | |The TXFIFOTH also defines when the TXMAC starts to transmit frame out to network. + * | | |The TXMAC starts to transmit the frame out while the TXFIFO first time reaches the high threshold during the transmission of the frame. + * | | |If the frame data length is less than TXFIFO high threshold, the TXMAC starts to transmit the frame out after the frame data are all inside the TXFIFO. + * | | |00 = Undefined. + * | | |01 = TXFIFO low threshold is 64B and high threshold is 128B. + * | | |10 = TXFIFO low threshold is 80B and high threshold is 160B. + * | | |11 = TXFIFO low threshold is 96B and high threshold is 192B. + * |[20:21] |BURSTLEN |DMA Burst Length + * | | |This defines the burst length of AHB bus cycle while EMAC accesses system memory. + * | | |00 = 16 words. + * | | |01 = 16 words. + * | | |10 = 8 words. + * | | |11 = 4 words. + */ + __IO uint32_t FIFOCTL; + + /** + * TXST + * =================================================================================================== + * Offset: 0xA0 Transmit Start Demand Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |TXST |Transmit Start Demand + * | | |If the TX descriptor is not available for use of TXDMA after the TXON (EMAC_CTL[8]) is enabled, the FSM (Finite State Machine) of TXDMA enters the Halt state and the frame transmission is halted. + * | | |After the S/W has prepared the new TX descriptor for frame transmission, it must issue a write command to EMAC_TXST register to make TXDMA to leave Halt state and continue the frame transmission. + * | | |The EMAC_TXST is a write only register and read from this register is undefined. + * | | |The write to EMAC_TXST register takes effect only when TXDMA stayed at Halt state. + */ + __O uint32_t TXST; + + /** + * RXST + * =================================================================================================== + * Offset: 0xA4 Receive Start Demand Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |RXST |Receive Start Demand + * | | |If the RX descriptor is not available for use of RXDMA after the RXON (EMAC_CTL[0]) is enabled, the FSM (Finite State Machine) of RXDMA enters the Halt state and the frame reception is halted. + * | | |After the S/W has prepared the new RX descriptor for frame reception, it must issue a write command to EMAC_RXST register to make RXDMA to leave Halt state and continue the frame reception. + * | | |The EMAC_RXST is a write only register and read from this register is undefined. + * | | |The write to EMAC_RXST register take effect only when RXDMA stayed at Halt state. + */ + __O uint32_t RXST; + + /** + * MRFL + * =================================================================================================== + * Offset: 0xA8 Maximum Receive Frame Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |MRFL |Maximum Receive Frame Length + * | | |The MRFL defines the maximum frame length for received frame. + * | | |If the frame length of received frame is greater than MRFL, and bit MFLEIEN (EMAC_INTEN[8]) is also enabled, the bit MFLEIF (EMAC_INTSTS[8]) is set and the RX interrupt is triggered. + * | | |It is recommended that only use MRFL to qualify the length of received frame while S/W wants to receive a frame which length is greater than 1518 bytes. + */ + __IO uint32_t MRFL; + + /** + * INTEN + * =================================================================================================== + * Offset: 0xAC MAC Interrupt Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXIEN |Receive Interrupt Enable Control + * | | |The RXIEN controls the RX interrupt generation. + * | | |If RXIEN is enabled and RXIF (EMAC_INTSTS[0]) is high, EMAC generates the RX interrupt to CPU. + * | | |If RXIEN is disabled, no RX interrupt is generated to CPU even any status bit EMAC_INTSTS[15:1] is set and the corresponding bit of EMAC_INTEN is enabled. + * | | |In other words, if S/W wants to receive RX interrupt from EMAC, this bit must be enabled. + * | | |And, if S/W doesn't want to receive any RX interrupt from EMAC, disables this bit. + * | | |0 = RXIF (EMAC_INTSTS[0]) is masked and RX interrupt generation Disabled. + * | | |1 = RXIF (EMAC_INTSTS[0]) is not masked and RX interrupt generation Enabled. + * |[1] |CRCEIEN |CRC Error Interrupt Enable Control + * | | |The CRCEIEN controls the CRCEIF (EMAC_INTSTS[1]) interrupt generation. + * | | |If CRCEIF (EMAC_INTSTS[1]) is set, and both CRCEIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If CRCEIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the CRCEIF (EMAC_INTSTS[1]) is set. + * | | |0 = CRCEIF (EMAC_INTSTS[1]) trigger RX interrupt Disabled. + * | | |1 = CRCEIF (EMAC_INTSTS[1]) trigger RX interrupt Enabled. + * |[2] |RXOVIEN |Receive FIFO Overflow Interrupt Enable Control + * | | |The RXOVIEN controls the RXOVIF (EMAC_INTSTS[2]) interrupt generation. + * | | |If RXOVIF (EMAC_INTSTS[2]) is set, and both RXOVIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If RXOVIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the RXOVIF (EMAC_INTSTS[2]) is set. + * | | |0 = RXOVIF (EMAC_INTSTS[2]) trigger RX interrupt Disabled. + * | | |1 = RXOVIF (EMAC_INTSTS[2]) trigger RX interrupt Enabled. + * |[3] |LPIEN |Long Packet Interrupt Enable + * | | |The LPIEN controls the LPIF (EMAC_INTSTS[3]) interrupt generation. + * | | |If LPIF (EMAC_INTSTS[3]) is set, and both LPIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If LPIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the LPIF (EMAC_INTSTS[3]) is set. + * | | |0 = LPIF (EMAC_INTSTS[3]) trigger RX interrupt Disabled. + * | | |1 = LPIF (EMAC_INTSTS[3]) trigger RX interrupt Enabled. + * |[4] |RXGDIEN |Receive Good Interrupt Enable Control + * | | |The RXGDIEN controls the RXGDIF (EMAC_INTSTS[4]) interrupt generation. + * | | |If RXGDIF (EMAC_INTSTS[4]) is set, and both RXGDIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If RXGDIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the RXGDIF (EMAC_INTSTS[4]) is set. + * | | |0 = RXGDIF (EMAC_INTSTS[4]) trigger RX interrupt Disabled. + * | | |1 = RXGDIF (EMAC_INTSTS[4]) trigger RX interrupt Enabled. + * |[5] |ALIEIEN |Alignment Error Interrupt Enable Control + * | | |The ALIEIEN controls the ALIEIF (EMAC_INTSTS[5]) interrupt generation. + * | | |If ALIEIF (EMAC_INTSTS[5]) is set, and both ALIEIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If ALIEIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the ALIEIF (EMAC_INTSTS[5]) is set. + * | | |0 = ALIEIF (EMAC_INTSTS[5]) trigger RX interrupt Disabled. + * | | |1 = ALIEIF (EMAC_INTSTS[5]) trigger RX interrupt Enabled. + * |[6] |RPIEN |Runt Packet Interrupt Enable Control + * | | |The RPIEN controls the RPIF (EMAC_INTSTS[6]) interrupt generation. + * | | |If RPIF (EMAC_INTSTS[6]) is set, and both RPIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If RPIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the RPIF (EMAC_INTSTS[6]) is set. + * | | |0 = RPIF (EMAC_INTSTS[6]) trigger RX interrupt Disabled. + * | | |1 = RPIF (EMAC_INTSTS[6]) trigger RX interrupt Enabled. + * |[7] |MPCOVIEN |Miss Packet Counter Overrun Interrupt Enable + * | | |The MPCOVIEN controls the MPCOVIF (EMAC_INTSTS[7]) interrupt generation. + * | | |If MPCOVIF (EMAC_INTSTS[7]) is set, and both MPCOVIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If MPCOVIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the MPCOVIF (EMAC_INTSTS[7]) is set. + * | | |0 = MPCOVIF (EMAC_INTSTS[7]) trigger RX interrupt Disabled. + * | | |1 = MPCOVIF (EMAC_INTSTS[7]) trigger RX interrupt Enabled. + * |[8] |MFLEIEN |Maximum Frame Length Exceed Interrupt Enable + * | | |The MFLEIEN controls the MFLEIF (EMAC_INTSTS[8]) interrupt generation. + * | | |If MFLEIF (EMAC_INTSTS[8]) is set, and both MFLEIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If MFLEIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the MFLEIF (EMAC_INTSTS[8]) is set. + * | | |0 = MFLEIF (EMAC_INTSTS[8]) trigger RX interrupt Disabled. + * | | |1 = MFLEIF (EMAC_INTSTS[8]) trigger RX interrupt Enabled. + * |[9] |DENIEN |DMA Early Notification Interrupt Enable Control + * | | |The DENIEN controls the DENIF (EMAC_INTSTS[9]) interrupt generation. + * | | |If DENIF (EMAC_INTSTS[9]) is set, and both DENIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If DENIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the DENIF (EMAC_INTSTS[9]) is set. + * | | |0 = TDENIF (EMAC_INTSTS[9]) trigger RX interrupt Disabled. + * | | |1 = TDENIF (EMAC_INTSTS[9]) trigger RX interrupt Enabled. + * |[10] |RDUIEN |Receive Descriptor Unavailable Interrupt Enable Control + * | | |The RDUIEN controls the RDUIF (EMAC_INTSTS[10]) interrupt generation. + * | | |If RDUIF (EMAC_INTSTS[10]) is set, and both RDUIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If RDUIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the RDUIF (EMAC_MIOSTA[10]) register is set. + * | | |0 = RDUIF (EMAC_INTSTS[10]) trigger RX interrupt Disabled. + * | | |1 = RDUIF (EMAC_INTSTS[10]) trigger RX interrupt Enabled. + * |[11] |RXBEIEN |Receive Bus Error Interrupt Enable Control + * | | |The RXBEIEN controls the RXBEIF (EMAC_INTSTS[11]) interrupt generation. + * | | |If RXBEIF (EMAC_INTSTS[11]) is set, and both RXBEIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If RXBEIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the RXBEIF (EMAC_INTSTS[11]) is set. + * | | |0 = RXBEIF (EMAC_INTSTS[11]) trigger RX interrupt Disabled. + * | | |1 = RXBEIF (EMAC_INTSTS[11]) trigger RX interrupt Enabled. + * |[14] |CFRIEN |Control Frame Receive Interrupt Enable Control + * | | |The CFRIEN controls the CFRIF (EMAC_INTSTS[14]) interrupt generation. + * | | |If CFRIF (EMAC_INTSTS[14]) is set, and both CFRIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If CFRIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the CFRIF (EMAC_INTSTS[14]) register is set. + * | | |0 = CFRIF (EMAC_INTSTS[14]) trigger RX interrupt Disabled. + * | | |1 = CFRIF (EMAC_INTSTS[14]) trigger RX interrupt Enabled. + * |[15] |WOLIEN |Wake On LAN Interrupt Enable + * | | |The WOLIEN controls the WOLIF (EMAC_INTSTS[15]) interrupt generation. + * | | |If WOLIF (EMAC_INTSTS[15]) is set, and both WOLIEN and RXIEN (EMAC_INTEN[0]) are enabled, the EMAC generates the RX interrupt to CPU. + * | | |If WOLIEN or RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated to CPU even the WOLIF (EMAC_INTSTS[15]) is set. + * | | |0 = WOLIF (EMAC_INTSTS[15]) trigger RX interrupt Disabled. + * | | |1 = WOLIF (EMAC_INTSTS[15]) trigger RX interrupt Enabled. + * |[16] |TXIEN |Transmit Interrupt Enable Control + * | | |The TXIEN controls the TX interrupt generation. + * | | |If TXIEN is enabled and TXIF (EMAC_INTSTS[16]) is high, EMAC generates the TX interrupt to CPU. + * | | |If TXIEN is disabled, no TX interrupt is generated to CPU even any status bit of EMAC_INTSTS[24:17] set and the corresponding bit of EMAC_INTEN is enabled. + * | | |In other words, if S/W wants to receive TX interrupt from EMAC, this bit must be enabled. + * | | |And, if S/W doesn't want to receive any TX interrupt from EMAC, disables this bit. + * | | |0 = TXIF (EMAC_INTSTS[16]) is masked and TX interrupt generation Disabled. + * | | |1 = TXIF (EMAC_INTSTS[16]) is not masked and TX interrupt generation Enabled. + * |[17] |TXUDIEN |Transmit FIFO Underflow Interrupt Enable Control + * | | |The TXUDIEN controls the TXUDIF (EMAC_INTSTS[17]) interrupt generation. + * | | |If TXUDIF (EMAC_INTSTS[17]) is set, and both TXUDIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If TXUDIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the TXUDIF (EMAC_INTSTS[17]) is set. + * | | |0 = TXUDIF (EMAC_INTSTS[17]) TX interrupt Disabled. + * | | |1 = TXUDIF (EMAC_INTSTS[17]) TX interrupt Enabled. + * |[18] |TXCPIEN |Transmit Completion Interrupt Enable Control + * | | |The TXCPIEN controls the TXCPIF (EMAC_INTSTS[18]) interrupt generation. + * | | |If TXCPIF (EMAC_INTSTS[18]) is set, and both TXCPIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If TXCPIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the TXCPIF (EMAC_INTSTS[18]) is set. + * | | |0 = TXCPIF (EMAC_INTSTS[18]) trigger TX interrupt Disabled. + * | | |1 = TXCPIF (EMAC_INTSTS[18]) trigger TX interrupt Enabled. + * |[19] |EXDEFIEN |Defer Exceed Interrupt Enable Control + * | | |The EXDEFIEN controls the EXDEFIF (EMAC_INTSTS[19]) interrupt generation. + * | | |If EXDEFIF (EMAC_INTSTS[19]) is set, and both EXDEFIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If EXDEFIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the EXDEFIF (EMAC_INTSTS[19]) is set. + * | | |0 = EXDEFIF (EMAC_INTSTS[19]) trigger TX interrupt Disabled. + * | | |1 = EXDEFIF (EMAC_INTSTS[19]) trigger TX interrupt Enabled. + * |[20] |NCSIEN |No Carrier Sense Interrupt Enable Control + * | | |The NCSIEN controls the NCSIF (EMAC_INTSTS[20]) interrupt generation. + * | | |If NCSIF (EMAC_INTSTS[20]) is set, and both NCSIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If NCSIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the NCSIF (EMAC_INTSTS[20]) is set. + * | | |0 = NCSIF (EMAC_INTSTS[20]) trigger TX interrupt Disabled. + * | | |1 = NCSIF (EMAC_INTSTS[20]) trigger TX interrupt Enabled. + * |[21] |TXABTIEN |Transmit Abort Interrupt Enable Control + * | | |The TXABTIEN controls the TXABTIF (EMAC_INTSTS[21]) interrupt generation. + * | | |If TXABTIF (EMAC_INTSTS[21]) is set, and both TXABTIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If TXABTIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the TXABTIF (EMAC_INTSTS[21]) is set. + * | | |0 = TXABTIF (EMAC_INTSTS[21]) trigger TX interrupt Disabled. + * | | |1 = TXABTIF (EMAC_INTSTS[21]) trigger TX interrupt Enabled. + * |[22] |LCIEN |Late Collision Interrupt Enable Control + * | | |The LCIEN controls the LCIF (EMAC_INTSTS[22]) interrupt generation. + * | | |If LCIF (EMAC_INTSTS[22]) is set, and both LCIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If LCIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the LCIF (EMAC_INTSTS[22]) is set. + * | | |0 = LCIF (EMAC_INTSTS[22]) trigger TX interrupt Disabled. + * | | |1 = LCIF (EMAC_INTSTS[22]) trigger TX interrupt Enabled. + * |[23] |TDUIEN |Transmit Descriptor Unavailable Interrupt Enable Control + * | | |The TDUIEN controls the TDUIF (EMAC_INTSTS[23]) interrupt generation. + * | | |If TDUIF (EMAC_INTSTS[23]) is set, and both TDUIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If TDUIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the TDUIF (EMAC_INTSTS[23]) is set. + * | | |0 = TDUIF (EMAC_INTSTS[23]) trigger TX interrupt Disabled. + * | | |1 = TDUIF (EMAC_INTSTS[23]) trigger TX interrupt Enabled. + * |[24] |TXBEIEN |Transmit Bus Error Interrupt Enable Control + * | | |The TXBEIEN controls the TXBEIF (EMAC_INTSTS[24]) interrupt generation. + * | | |If TXBEIF (EMAC_INTSTS[24]) is set, and both TXBEIEN and TXIEN (EMAC_INTEN[16]) are enabled, the EMAC generates the TX interrupt to CPU. + * | | |If TXBEIEN or TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated to CPU even the TXBEIF (EMAC_INTSTS[24]) is set. + * | | |0 = TXBEIF (EMAC_INTSTS[24]) trigger TX interrupt Disabled. + * | | |1 = TXBEIF (EMAC_INTSTS[24]) trigger TX interrupt Enabled. + * |[28] |TSALMIEN |Time Stamp Alarm Interrupt Enable Control + * | | |The TSALMIEN controls the TSALMIF (EMAC_INTSTS[28]) interrupt generation. + * | | |If TSALMIF (EMAC_INTSTS[28]) is set, and both TSALMIEN and TXIEN (EMAC_INTEN[16]) enabled, the EMAC generates the TX interrupt to CPU. + * | | |If TSALMIEN or TXIEN (EMAC_INTEN[16]) disabled, no TX interrupt generated to CPU even the TXTSALMIF (EMAC_INTEN[28]) is set. + * | | |0 = TXTSALMIF (EMAC_INTSTS[28]) trigger TX interrupt Disabled. + * | | |1 = TXTSALMIF (EMAC_INTSTS[28]) trigger TX interrupt Enabled. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0xB0 MAC Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXIF |Receive Interrupt + * | | |The RXIF indicates the RX interrupt status. + * | | |If RXIF high and its corresponding enable bit, RXIEN (EMAC_INTEN[0]), is also high indicates the EMAC generates RX interrupt to CPU. + * | | |If RXIF is high but RXIEN (EMAC_INTEN[0]) is disabled, no RX interrupt is generated. + * | | |The RXIF is logic OR result of bit logic AND result of EMAC_INTSTS[15:1] and EMAC_INTEN[15:1]. + * | | |In other words, if any bit of EMAC_INTSTS[15:1] is high and its corresponding enable bit in EMAC_INTEN[15:1] is also enabled, the RXIF will be high. + * | | |Because the RXIF is a logic OR result, clears EMAC_INTSTS[15:1] makes RXIF be cleared, too. + * | | |0 = No status bit in EMAC_INTSTS[15:1] is set or no enable bit in EMAC_INTEN[15:1] is enabled. + * | | |1 = At least one status in EMAC_INTSTS[15:1] is set and its corresponding enable bit in EMAC_INTEN[15:1] is enabled, too. + * |[1] |CRCEIF |CRC Error Interrupt + * | | |The CRCEIF high indicates the incoming packet incurred the CRC error and the packet is dropped. + * | | |If the AEP (EMAC_CTL[4]) is set, the CRC error packet will be regarded as a good packet and CRCEIF will not be set. + * | | |If the CRCEIF is high and CRCEIEN (EMAC_INTEN[1]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the CRCEIF status. + * | | |0 = The frame does not incur CRC error. + * | | |1 = The frame incurred CRC error. + * |[2] |RXOVIF |Receive FIFO Overflow Interrupt + * | | |The RXOVIF high indicates the RXFIFO overflow occurred during packet reception. + * | | |While the RXFIFO overflow occurred, the EMAC drops the current receiving packer. + * | | |If the RXFIFO overflow occurred often, it is recommended that modify RXFIFO threshold control, the RXFIFOTH of FFTCR register, to higher level. + * | | |If the RXOVIF is high and RXOVIEN (EMAC_INTEN[2]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the RXOVIF status. + * | | |0 = No RXFIFO overflow occurred during packet reception. + * | | |1 = RXFIFO overflow occurred during packet reception. + * |[3] |LPIF |Long Packet Interrupt Flag + * | | |The LPIF high indicates the length of the incoming packet is greater than 1518 bytes and the incoming packet is dropped. + * | | |If the ALP (EMAC_CTL[1]) is set, the long packet will be regarded as a good packet and LPIF will not be set. + * | | |If the LPIF is high and LPIEN (EMAC_INTEN[3]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the LPIF status. + * | | |0 = The incoming frame is not a long frame or S/W wants to receive a long frame. + * | | |1 = The incoming frame is a long frame and dropped. + * |[4] |RXGDIF |Receive Good Interrupt + * | | |The RXGDIF high indicates the frame reception has completed. + * | | |If the RXGDIF is high and RXGDIEN (EAMC_MIEN[4]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the RXGDIF status. + * | | |0 = The frame reception has not complete yet. + * | | |1 = The frame reception has completed. + * |[5] |ALIEIF |Alignment Error Interrupt + * | | |The ALIEIF high indicates the length of the incoming frame is not a multiple of byte. + * | | |If the ALIEIF is high and ALIEIEN (EMAC_INTEN[5]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the ALIEIF status. + * | | |0 = The frame length is a multiple of byte. + * | | |1 = The frame length is not a multiple of byte. + * |[6] |RPIF |Runt Packet Interrupt + * | | |The RPIF high indicates the length of the incoming packet is less than 64 bytes and the packet is dropped. + * | | |If the ARP (EMAC_CTL[2]) is set, the short packet is regarded as a good packet and RPIF will not be set. + * | | |If the RPIF is high and RPIEN (EMAC_INTEN[6]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the RPIF status. + * | | |0 = The incoming frame is not a short frame or S/W wants to receive a short frame. + * | | |1 = The incoming frame is a short frame and dropped. + * |[7] |MPCOVIF |Missed Packet Counter Overrun Interrupt Flag + * | | |The MPCOVIF high indicates the MPCNT, Missed Packet Count, has overflow. + * | | |If the MPCOVIF is high and MPCOVIEN (EMAC_INTEN[7]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the MPCOVIF status. + * | | |0 = The MPCNT has not rolled over yet. + * | | |1 = The MPCNT has rolled over yet. + * |[8] |MFLEIF |Maximum Frame Length Exceed Interrupt Flag + * | | |The MFLEIF high indicates the length of the incoming packet has exceeded the length limitation configured in DMARFC register and the incoming packet is dropped. + * | | |If the MFLEIF is high and MFLEIEN (EMAC_INTEN[8]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the MFLEIF status. + * | | |0 = The length of the incoming packet does not exceed the length limitation configured in DMARFC. + * | | |1 = The length of the incoming packet has exceeded the length limitation configured in DMARFC. + * |[9] |DENIF |DMA Early Notification Interrupt + * | | |The DENIF high indicates the EMAC has received the LENGTH field of the incoming packet. + * | | |If the DENIF is high and DENIENI (EMAC_INTEN[9]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the DENIF status. + * | | |0 = The LENGTH field of incoming packet has not received yet. + * | | |1 = The LENGTH field of incoming packet has received. + * |[10] |RDUIF |Receive Descriptor Unavailable Interrupt + * | | |The RDUIF high indicates that there is no available RX descriptor for packet reception and RXDMA will stay at Halt state. + * | | |Once, the RXDMA enters the Halt state, S/W must issues a write command to RSDR register to make RXDMA leave Halt state while new RX descriptor is available. + * | | |If the RDUIF is high and RDUIEN (EMAC_INTEN[10]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the RDUIF status. + * | | |0 = RX descriptor is available. + * | | |1 = RX descriptor is unavailable. + * |[11] |RXBEIF |Receive Bus Error Interrupt + * | | |The RXBEIF high indicates the memory controller replies ERROR response while EMAC access system memory through RXDMA during packet reception process. + * | | |Reset EMAC is recommended while RXBEIF status is high. + * | | |If the RXBEIF is high and RXBEIEN (EMAC_INTEN[11]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the RXBEIF status. + * | | |0 = No ERROR response is received. + * | | |1 = ERROR response is received. + * |[14] |CFRIF |Control Frame Receive Interrupt + * | | |The CFRIF high indicates EMAC receives a flow control frame. + * | | |The CFRIF only available while EMAC is operating on full duplex mode. + * | | |If the CFRIF is high and CFRIEN (EMAC_INTEN[14]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the CFRIF status. + * | | |0 = The EMAC does not receive the flow control frame. + * | | |1 = The EMAC receives a flow control frame. + * |[15] |WOLIF |Wake On LAN Interrupt Flag + * | | |The WOLIF high indicates EMAC receives a Magic Packet. + * | | |The CFRIF only available while system is in power down mode and WOLEN is set high. + * | | |If the WOLIF is high and WOLIEN (EMAC_INTEN[15]) is enabled, the RXIF will be high. + * | | |Write 1 to this bit clears the WOLIF status. + * | | |0 = The EMAC does not receive the Magic Packet. + * | | |1 = The EMAC receives a Magic Packet. + * |[16] |TXIF |Transmit Interrupt + * | | |The TXIF indicates the TX interrupt status. + * | | |If TXIF high and its corresponding enable bit, TXIEN (EMAC_INTEN[16]), is also high indicates the EMAC generates TX interrupt to CPU. + * | | |If TXIF is high but TXIEN (EMAC_INTEN[16]) is disabled, no TX interrupt is generated. + * | | |The TXIF is logic OR result of bit logic AND result of EMAC_INTSTS[28:17] and EMAC_INTEN[28:17]. + * | | |In other words, if any bit of EMAC_INTSTS[28:17] is high and its corresponding enable bit in EMAC_INTEN[28:17] is also enabled, the TXIF will be high. + * | | |Because the TXIF is a logic OR result, clears EMAC_INTSTS[28:17] makes TXIF be cleared, too. + * | | |0 = No status bit in EMAC_INTSTS[28:17] is set or no enable bit in EMAC_INTEN[28:17] is enabled. + * | | |1 = At least one status in EMAC_INTSTS[28:17] is set and its corresponding enable bit in EMAC_INTEN[28:17] is enabled, too. + * |[17] |TXUDIF |Transmit FIFO Underflow Interrupt + * | | |The TXUDIF high indicates the TXFIFO underflow occurred during packet transmission. + * | | |While the TXFIFO underflow occurred, the EMAC will retransmit the packet automatically without S/W intervention. + * | | |If the TXFIFO underflow occurred often, it is recommended that modify TXFIFO threshold control, the TXFIFOTH of FFTCR register, to higher level. + * | | |If the TXUDIF is high and TXUDIEN (EMAC_INTEN[17]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the TXUDIF status. + * | | |0 = No TXFIFO underflow occurred during packet transmission. + * | | |1 = TXFIFO underflow occurred during packet transmission. + * |[18] |TXCPIF |Transmit Completion Interrupt + * | | |The TXCPIF indicates the packet transmission has completed correctly. + * | | |If the TXCPIF is high and TXCPIEN (EMAC_INTEN[18]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the TXCPIF status. + * | | |0 = The packet transmission not completed. + * | | |1 = The packet transmission has completed. + * |[19] |EXDEFIF |Defer Exceed Interrupt + * | | |The EXDEFIF high indicates the frame waiting for transmission has deferred over 0.32768ms on 100Mbps mode, or 3.2768ms on 10Mbps mode. + * | | |The deferral exceed check will only be done while bit NODEF of MCMDR is disabled, and EMAC is operating on half-duplex mode. + * | | |If the EXDEFIF is high and EXDEFIEN (EMAC_INTEN[19]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the EXDEFIF status. + * | | |0 = Frame waiting for transmission has not deferred over 0.32768ms (100Mbps) or 3.2768ms (10Mbps). + * | | |1 = Frame waiting for transmission has deferred over 0.32768ms (100Mbps) or 3.2768ms (10Mbps). + * |[20] |NCSIF |No Carrier Sense Interrupt + * | | |The NCSIF high indicates the MII I/F signal CRS does not active at the start of or during the packet transmission. + * | | |The NCSIF is only available while EMAC is operating on half-duplex mode. + * | | |If the NCSIF is high and NCSIEN (EMAC_INTEN[20]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the NCSIF status. + * | | |0 = CRS signal actives correctly. + * | | |1 = CRS signal does not active at the start of or during the packet transmission. + * |[21] |TXABTIF |Transmit Abort Interrupt + * | | |The TXABTIF high indicates the packet incurred 16 consecutive collisions during transmission, and then the transmission process for this packet is aborted. + * | | |The transmission abort is only available while EMAC is operating on half-duplex mode. + * | | |If the TXABTIF is high and TXABTIEN (EMAC_INTEN[21]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the TXABTIF status. + * | | |0 = Packet does not incur 16 consecutive collisions during transmission. + * | | |1 = Packet incurred 16 consecutive collisions during transmission. + * |[22] |LCIF |Late Collision Interrupt + * | | |The LCIF high indicates the collision occurred in the outside of 64 bytes collision window. + * | | |This means after the 64 bytes of a frame has been transmitted out to the network, the collision still occurred. + * | | |The late collision check will only be done while EMAC is operating on half-duplex mode. + * | | |If the LCIF is high and LCIEN (EMAC_INTEN[22]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the LCIF status. + * | | |0 = No collision occurred in the outside of 64 bytes collision window. + * | | |1 = Collision occurred in the outside of 64 bytes collision window. + * |[23] |TDUIF |Transmit Descriptor Unavailable Interrupt + * | | |The TDUIF high indicates that there is no available TX descriptor for packet transmission and TXDMA will stay at Halt state. + * | | |Once, the TXDMA enters the Halt state, S/W must issues a write command to TSDR register to make TXDMA leave Halt state while new TX descriptor is available. + * | | |If the TDUIF is high and TDUIEN (EMAC_INTEN[23]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the TDUIF status. + * | | |0 = TX descriptor is available. + * | | |1 = TX descriptor is unavailable. + * |[24] |TXBEIF |Transmit Bus Error Interrupt + * | | |The TXBEIF high indicates the memory controller replies ERROR response while EMAC access system memory through TXDMA during packet transmission process. + * | | |Reset EMAC is recommended while TXBEIF status is high. + * | | |If the TXBEIF is high and TXBEIEN (EMAC_INTEN[24]) is enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the TXBEIF status. + * | | |0 = No ERROR response is received. + * | | |1 = ERROR response is received. + * |[28] |TSALMIF |Time Stamp Alarm Interrupt + * | | |The TSALMIF high indicates the EMAC_TSSEC register value equals to EMAC_ALMSEC register and EMAC_TSSUBSEC register value equals to register EMAC_TSMLSR. + * | | |If TSALMIF is high and TSALMIEN (EMAC_INTEN[28]) enabled, the TXIF will be high. + * | | |Write 1 to this bit clears the TSALMIF status. + * | | |0 = EMAC_TSSEC did not equal EMAC_ALMSEC or EMAC_TSSUBSEC did not equal EMAC_ALMSUBSEC. + * | | |1 = EMAC_TSSEC equals EMAC_ALMSEC and EMAC_TSSUBSEC equals EMAC_ALMSUBSEC. + */ + __IO uint32_t INTSTS; + + /** + * GENSTS + * =================================================================================================== + * Offset: 0xB4 MAC General Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CFRIF |Control Frame Received + * | | |The CFRIF high indicates EMAC receives a flow control frame. + * | | |The CFRIF only available while EMAC is operating on full duplex mode. + * | | |0 = The EMAC does not receive the flow control frame. + * | | |1 = The EMAC receives a flow control frame. + * |[1] |RXHALT |Receive Halted + * | | |The RXHALT high indicates the next normal packet reception process will be halted because the bit RXON of MCMDR is disabled be S/W. + * | | |0 = Next normal packet reception process will go on. + * | | |1 = Next normal packet reception process will be halted. + * |[2] |RXFFULL |RXFIFO Full + * | | |The RXFFULL indicates the RXFIFO is full due to four 64-byte packets are kept in RXFIFO and the following incoming packet will be dropped. + * | | |0 = The RXFIFO is not full. + * | | |1 = The RXFIFO is full and the following incoming packet will be dropped. + * |[4:7] |COLCNT |Collision Count + * | | |The COLCNT indicates that how many collisions occurred consecutively during a packet transmission. + * | | |If the packet incurred 16 consecutive collisions during transmission, the COLCNT will be 0 and bit TXABTIF will be set to 1. + * |[8] |DEF |Deferred Transmission + * | | |The DEF high indicates the packet transmission has deferred once. + * | | |The DEF is only available while EMAC is operating on half-duplex mode. + * | | |0 = Packet transmission does not defer. + * | | |1 = Packet transmission has deferred once. + * |[9] |TXPAUSED |Transmission Paused + * | | |The TXPAUSED high indicates the next normal packet transmission process will be paused temporally because EMAC received a PAUSE control frame. + * | | |0 = Next normal packet transmission process will go on. + * | | |1 = Next normal packet transmission process will be paused. + * |[10] |SQE |Signal Quality Error + * | | |The SQE high indicates the SQE error found at end of packet transmission on 10Mbps half-duplex mode. + * | | |The SQE error check will only be done while both bit SQECHKEN (EMAC_CTL[17]) is enabled and EMAC is operating on 10Mbps half-duplex mode. + * | | |0 = No SQE error found at end of packet transmission. + * | | |1 = SQE error found at end of packet transmission. + * |[11] |TXHALT |Transmission Halted + * | | |The TXHALT high indicates the next normal packet transmission process will be halted because the bit TXON (EMAC_CTL[8]) is disabled be S/W. + * | | |0 = Next normal packet transmission process will go on. + * | | |1 = Next normal packet transmission process will be halted. + * |[12] |RPSTS |Remote Pause Status + * | | |The RPSTS indicates that remote pause counter down counting actives. + * | | |After Ethernet MAC controller sent PAUSE frame out successfully, it starts the remote pause counter down counting. + * | | |When this bit high, it's predictable that remote Ethernet MAC controller wouldn't start the packet transmission until the down counting done. + * | | |0 = Remote pause counter down counting done. + * | | |1 = Remote pause counter down counting actives. + */ + __IO uint32_t GENSTS; + + /** + * MPCNT + * =================================================================================================== + * Offset: 0xB8 Missed Packet Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |MPCNT |Miss Packet Count + * | | |The MPCNT indicates the number of packets that were dropped due to various types of receive errors. + * | | |The following type of receiving error makes missed packet counter increase:. + * | | |1. Incoming packet is incurred RXFIFO overflow. + * | | |2. Incoming packet is dropped due to RXON is disabled. + * | | |3. Incoming packet is incurred CRC error. + */ + __IO uint32_t MPCNT; + + /** + * RPCNT + * =================================================================================================== + * Offset: 0xBC MAC Receive Pause Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RPCNT |MAC Receive Pause Count + * | | |The RPCNT keeps the OPERAND field of the PAUSE control frame. + * | | |It indicates how many slot time (512 bit time) the TX of EMAC will be paused. + */ + __I uint32_t RPCNT; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[2]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * FRSTS + * =================================================================================================== + * Offset: 0xC8 DMA Receive Frame Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RXFLT |Receive Frame LENGTH + * | | |The RXFLT keeps the LENGTH field of each incoming Ethernet packet. + * | | |If the bit DENIEN (EMAC_INTEN[9]) is enabled and the LENGTH field of incoming packet has received, the bit DENIF (EMAC_INTSTS[9]) will be set and trigger interrupt. + * | | |And, the content of LENGTH field will be stored in RXFLT. + */ + __IO uint32_t FRSTS; + + /** + * CTXDSA + * =================================================================================================== + * Offset: 0xCC Current Transmit Descriptor Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CTXDSA |Current Transmit Descriptor Start Address + * | | |The CTXDSA keeps the start address of TX descriptor that is used by TXDMA currently. + * | | |The CTXDSA is read only and write to this register has no effect. + */ + __I uint32_t CTXDSA; + + /** + * CTXBSA + * =================================================================================================== + * Offset: 0xD0 Current Transmit Buffer Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CTXBSA |Current Transmit Buffer Start Address + * | | |The CTXDSA keeps the start address of TX frame buffer that is used by TXDMA currently. + * | | |The CTXBSA is read only and write to this register has no effect. + */ + __I uint32_t CTXBSA; + + /** + * CRXDSA + * =================================================================================================== + * Offset: 0xD4 Current Receive Descriptor Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CRXDSA |Current Receive Descriptor Start Address + * | | |The CRXDSA keeps the start address of RX descriptor that is used by RXDMA currently. + * | | |The CRXDSA is read only and write to this register has no effect. + */ + __I uint32_t CRXDSA; + + /** + * CRXBSA + * =================================================================================================== + * Offset: 0xD8 Current Receive Buffer Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |CRXBSA |Current Receive Buffer Start Address + * | | |The CRXBSA keeps the start address of RX frame buffer that is used by RXDMA currently. + * | | |The CRXBSA is read only and write to this register has no effect. + */ + __I uint32_t CRXBSA; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[9]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TSCTL + * =================================================================================================== + * Offset: 0x100 Time Stamp Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TSEN |Time Stamp Function Enable Control + * | | |This bit controls if the IEEE 1588 PTP time stamp function is enabled or not. + * | | |Set this bit high to enable IEEE 1588 PTP time stamp function while set this bit low to disable IEEE 1588 PTP time stamp function. + * | | |0 = I EEE 1588 PTP time stamp function Disabled. + * | | |1 = IEEE 1588 PTP time stamp function Enabled. + * |[1] |TSIEN |Time Stamp Counter Initialization Enable Control + * | | |Set this bit high enables Ethernet MAC controller to load value of register EMAC_UPDSEC and EMAC_UPDSUBSEC to PTP time stamp counter. + * | | |After the load operation finished, Ethernet MAC controller clear this bit to low automatically. + * | | |0 = Time stamp counter initialization done. + * | | |1 = Time stamp counter initialization Enabled. + * |[2] |TSMODE |Time Stamp Fine Update Enable Control + * | | |This bit chooses the time stamp counter update mode. + * | | |0 = Time stamp counter is in coarse update mode. + * | | |1 = Time stamp counter is in fine update mode. + * |[3] |TSUPDATE |Time Stamp Counter Time Update Enable Control + * | | |Set this bit high enables Ethernet MAC controller to add value of register EMAC_UPDSEC and EMAC_UPDSUBSEC to PTP time stamp counter. + * | | |After the add operation finished, Ethernet MAC controller clear this bit to low automatically. + * | | |0 = No action. + * | | |1 = EMAC_UPDSEC updated to EMAC_TSSEC and EMAC_UPDSUBSEC updated to EMAC_TSSUBSEC. + * |[5] |TSALMEN |Time Stamp Alarm Enable Control + * | | |Set this bit high enable Ethernet MAC controller to set TSALMIF (EMAC_INTSTS[28]) high when EMAC_TSSEC equals to EMAC_ALMSEC and EMAC_TSSUBSEC equals to EMAC_ALMSUBSEC. + * | | |0 = Alarm disabled when EMAC_TSSEC equals to EMAC_ALMSEC and EMAC_TSSUBSEC equals to EMAC_ALMSUBSEC. + * | | |1 = Alarm enabled when EMAC_TSSEC equals to EMAC_ALMSEC and EMAC_TSSUBSEC equals to EMAC_ALMSUBSEC. + */ + __IO uint32_t TSCTL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TSSEC + * =================================================================================================== + * Offset: 0x110 Time Stamp Most Significant Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SEC |Time Stamp Counter Second + * | | |This register reflects the bit [63:32] value of 64-bit reference timing counter. + * | | |This 32-bit value is used as the second part of time stamp when TSEN (EMAC_TSCTL[0]) is high. + */ + __I uint32_t TSSEC; + + /** + * TSSUBSEC + * =================================================================================================== + * Offset: 0x114 Time Stamp Least Significant Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SUBSEC |Time Stamp Counter Sub-Second + * | | |This register reflects the bit [31:0] value of 64-bit reference timing counter. + * | | |This 32-bit value is used as the sub-second part of time stamp when TSEN (EMAC_TSCTL[0]) is high. + */ + __I uint32_t TSSUBSEC; + + /** + * TSINC + * =================================================================================================== + * Offset: 0x118 Time Stamp Increment Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |CNTINC |Time Stamp Counter Increment + * | | |Time stamp counter increment value. + * | | |If TSEN (EMAC_TSCTL[0]) is high, EMAC adds EMAC_TSSUBSEC with this 8-bit value every time when it wants to increase the EMAC_TSSUBSEC value. + */ + __IO uint32_t TSINC; + + /** + * TSADDEND + * =================================================================================================== + * Offset: 0x11C Time Stamp Addend Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ADDEND |Time Stamp Counter Addend + * | | |This register keeps a 32-bit value for accumulator to enable increment of EMAC_TSSUBSEC. + * | | |If TSEN (EMAC_TSCTL[0]) and TSMODE (EMAC_TSCTL[2]) are both high, EMAC increases accumulator with this 32-bit value in each HCLK. + * | | |Once the accumulator is overflow, it generates a enable to increase EMAC_TSSUBSEC with an 8-bit value kept in register EMAC_TSINC. + */ + __IO uint32_t TSADDEND; + + /** + * UPDSEC + * =================================================================================================== + * Offset: 0x120 Time Stamp Most Significant Update Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SEC |Time Stamp Counter Second Update + * | | |When TSIEN (EMAC_TSCTL[1]) is high. + * | | |EMAC loads this 32-bit value to EMAC_TSSEC directly. + * | | |When TSUPDATE (EMAC_TSCTL[3]) is high, EMAC increases EMAC_TSSEC with this 32-bit value. + */ + __IO uint32_t UPDSEC; + + /** + * UPDSUBSEC + * =================================================================================================== + * Offset: 0x124 Time Stamp Least Significant Update Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SUBSEC |Time Stamp Counter Sub-Second Update + * | | |When TSIEN (EMAC_TSCTL[1]) is high. + * | | |EMAC loads this 32-bit value to EMAC_TSSUBSEC directly. + * | | |When TSUPDATE (EMAC_TSCTL[3]) is high, EMAC increases EMAC_TSSUBSEC with this 32-bit value. + */ + __IO uint32_t UPDSUBSEC; + + /** + * ALMSEC + * =================================================================================================== + * Offset: 0x128 Time Stamp Most Significant Alarm Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SEC |Time Stamp Counter Second Alarm + * | | |Time stamp counter second part alarm value. + * | | |This value is only useful when ALMEN (EMAC_TSCTL[5]) high. + * | | |If ALMEN (EMAC_TSCTL[5]) is high, EMAC_TSSEC equals to EMAC_ALMSEC and EMAC_TSSUBSEC equals to EMAC_ALMSUBSEC, Ethernet MAC controller set TSALMIF (EMAC_INTSTS[28]) high. + */ + __IO uint32_t ALMSEC; + + /** + * ALMSUBSEC + * =================================================================================================== + * Offset: 0x12C Time Stamp Least Significant Alarm Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SUBSEC |Time Stamp Counter Sub-Second Alarm + * | | |Time stamp counter sub-second part alarm value. + * | | |This value is only useful when ALMEN (EMAC_TSCTL[5]) high. + * | | |If ALMEN (EMAC_TSCTL[5]) is high, EMAC_TSSEC equals to EMAC_ALMSEC and EMAC_TSSUBSEC equals to EMAC_ALMSUBSEC, Ethernet MAC controller set TSALMIF (EMAC_INTSTS[28]) high. + */ + __IO uint32_t ALMSUBSEC; + +} EMAC_T; + +/** + @addtogroup EMAC_CONST EMAC Bit Field Definition + Constant Definitions for EMAC Controller +@{ */ + +#define EMAC_CAMCTL_AUP_Pos (0) /*!< EMAC_T::CAMCTL: AUP Position */ +#define EMAC_CAMCTL_AUP_Msk (0x1ul << EMAC_CAMCTL_AUP_Pos) /*!< EMAC_T::CAMCTL: AUP Mask */ + +#define EMAC_CAMCTL_AMP_Pos (1) /*!< EMAC_T::CAMCTL: AMP Position */ +#define EMAC_CAMCTL_AMP_Msk (0x1ul << EMAC_CAMCTL_AMP_Pos) /*!< EMAC_T::CAMCTL: AMP Mask */ + +#define EMAC_CAMCTL_ABP_Pos (2) /*!< EMAC_T::CAMCTL: ABP Position */ +#define EMAC_CAMCTL_ABP_Msk (0x1ul << EMAC_CAMCTL_ABP_Pos) /*!< EMAC_T::CAMCTL: ABP Mask */ + +#define EMAC_CAMCTL_COMPEN_Pos (3) /*!< EMAC_T::CAMCTL: COMPEN Position */ +#define EMAC_CAMCTL_COMPEN_Msk (0x1ul << EMAC_CAMCTL_COMPEN_Pos) /*!< EMAC_T::CAMCTL: COMPEN Mask */ + +#define EMAC_CAMCTL_CMPEN_Pos (4) /*!< EMAC_T::CAMCTL: CMPEN Position */ +#define EMAC_CAMCTL_CMPEN_Msk (0x1ul << EMAC_CAMCTL_CMPEN_Pos) /*!< EMAC_T::CAMCTL: CMPEN Mask */ + +#define EMAC_CAMEN_CAMxEN_Pos (0) /*!< EMAC_T::CAMEN: CAMxEN Position */ +#define EMAC_CAMEN_CAMxEN_Msk (0x1ul << EMAC_CAMEN_CAMxEN_Pos) /*!< EMAC_T::CAMEN: CAMxEN Mask */ + +#define EMAC_CAM0M_MACADDR2_Pos (0) /*!< EMAC_T::CAM0M: MACADDR2 Position */ +#define EMAC_CAM0M_MACADDR2_Msk (0xfful << EMAC_CAM0M_MACADDR2_Pos) /*!< EMAC_T::CAM0M: MACADDR2 Mask */ + +#define EMAC_CAM0M_MACADDR3_Pos (8) /*!< EMAC_T::CAM0M: MACADDR3 Position */ +#define EMAC_CAM0M_MACADDR3_Msk (0xfful << EMAC_CAM0M_MACADDR3_Pos) /*!< EMAC_T::CAM0M: MACADDR3 Mask */ + +#define EMAC_CAM0M_MACADDR4_Pos (16) /*!< EMAC_T::CAM0M: MACADDR4 Position */ +#define EMAC_CAM0M_MACADDR4_Msk (0xfful << EMAC_CAM0M_MACADDR4_Pos) /*!< EMAC_T::CAM0M: MACADDR4 Mask */ + +#define EMAC_CAM0M_MACADDR5_Pos (24) /*!< EMAC_T::CAM0M: MACADDR5 Position */ +#define EMAC_CAM0M_MACADDR5_Msk (0xfful << EMAC_CAM0M_MACADDR5_Pos) /*!< EMAC_T::CAM0M: MACADDR5 Mask */ + +#define EMAC_CAM0L_Rserved_Pos (0) /*!< EMAC_T::CAM0L: Rserved Position */ +#define EMAC_CAM0L_Rserved_Msk (0xfffful << EMAC_CAM0L_Rserved_Pos) /*!< EMAC_T::CAM0L: Rserved Mask */ + +#define EMAC_CAM0L_MACADDR0_Pos (16) /*!< EMAC_T::CAM0L: MACADDR0 Position */ +#define EMAC_CAM0L_MACADDR0_Msk (0xfful << EMAC_CAM0L_MACADDR0_Pos) /*!< EMAC_T::CAM0L: MACADDR0 Mask */ + +#define EMAC_CAM0L_MACADDR1_Pos (24) /*!< EMAC_T::CAM0L: MACADDR1 Position */ +#define EMAC_CAM0L_MACADDR1_Msk (0xfful << EMAC_CAM0L_MACADDR1_Pos) /*!< EMAC_T::CAM0L: MACADDR1 Mask */ + +#define EMAC_CAM1M_MACADDR2_Pos (0) /*!< EMAC_T::CAM1M: MACADDR2 Position */ +#define EMAC_CAM1M_MACADDR2_Msk (0xfful << EMAC_CAM1M_MACADDR2_Pos) /*!< EMAC_T::CAM1M: MACADDR2 Mask */ + +#define EMAC_CAM1M_MACADDR3_Pos (8) /*!< EMAC_T::CAM1M: MACADDR3 Position */ +#define EMAC_CAM1M_MACADDR3_Msk (0xfful << EMAC_CAM1M_MACADDR3_Pos) /*!< EMAC_T::CAM1M: MACADDR3 Mask */ + +#define EMAC_CAM1M_MACADDR4_Pos (16) /*!< EMAC_T::CAM1M: MACADDR4 Position */ +#define EMAC_CAM1M_MACADDR4_Msk (0xfful << EMAC_CAM1M_MACADDR4_Pos) /*!< EMAC_T::CAM1M: MACADDR4 Mask */ + +#define EMAC_CAM1M_MACADDR5_Pos (24) /*!< EMAC_T::CAM1M: MACADDR5 Position */ +#define EMAC_CAM1M_MACADDR5_Msk (0xfful << EMAC_CAM1M_MACADDR5_Pos) /*!< EMAC_T::CAM1M: MACADDR5 Mask */ + +#define EMAC_CAM1L_Rserved_Pos (0) /*!< EMAC_T::CAM1L: Rserved Position */ +#define EMAC_CAM1L_Rserved_Msk (0xfffful << EMAC_CAM1L_Rserved_Pos) /*!< EMAC_T::CAM1L: Rserved Mask */ + +#define EMAC_CAM1L_MACADDR0_Pos (16) /*!< EMAC_T::CAM1L: MACADDR0 Position */ +#define EMAC_CAM1L_MACADDR0_Msk (0xfful << EMAC_CAM1L_MACADDR0_Pos) /*!< EMAC_T::CAM1L: MACADDR0 Mask */ + +#define EMAC_CAM1L_MACADDR1_Pos (24) /*!< EMAC_T::CAM1L: MACADDR1 Position */ +#define EMAC_CAM1L_MACADDR1_Msk (0xfful << EMAC_CAM1L_MACADDR1_Pos) /*!< EMAC_T::CAM1L: MACADDR1 Mask */ + +#define EMAC_CAM2M_MACADDR2_Pos (0) /*!< EMAC_T::CAM2M: MACADDR2 Position */ +#define EMAC_CAM2M_MACADDR2_Msk (0xfful << EMAC_CAM2M_MACADDR2_Pos) /*!< EMAC_T::CAM2M: MACADDR2 Mask */ + +#define EMAC_CAM2M_MACADDR3_Pos (8) /*!< EMAC_T::CAM2M: MACADDR3 Position */ +#define EMAC_CAM2M_MACADDR3_Msk (0xfful << EMAC_CAM2M_MACADDR3_Pos) /*!< EMAC_T::CAM2M: MACADDR3 Mask */ + +#define EMAC_CAM2M_MACADDR4_Pos (16) /*!< EMAC_T::CAM2M: MACADDR4 Position */ +#define EMAC_CAM2M_MACADDR4_Msk (0xfful << EMAC_CAM2M_MACADDR4_Pos) /*!< EMAC_T::CAM2M: MACADDR4 Mask */ + +#define EMAC_CAM2M_MACADDR5_Pos (24) /*!< EMAC_T::CAM2M: MACADDR5 Position */ +#define EMAC_CAM2M_MACADDR5_Msk (0xfful << EMAC_CAM2M_MACADDR5_Pos) /*!< EMAC_T::CAM2M: MACADDR5 Mask */ + +#define EMAC_CAM2L_Rserved_Pos (0) /*!< EMAC_T::CAM2L: Rserved Position */ +#define EMAC_CAM2L_Rserved_Msk (0xfffful << EMAC_CAM2L_Rserved_Pos) /*!< EMAC_T::CAM2L: Rserved Mask */ + +#define EMAC_CAM2L_MACADDR0_Pos (16) /*!< EMAC_T::CAM2L: MACADDR0 Position */ +#define EMAC_CAM2L_MACADDR0_Msk (0xfful << EMAC_CAM2L_MACADDR0_Pos) /*!< EMAC_T::CAM2L: MACADDR0 Mask */ + +#define EMAC_CAM2L_MACADDR1_Pos (24) /*!< EMAC_T::CAM2L: MACADDR1 Position */ +#define EMAC_CAM2L_MACADDR1_Msk (0xfful << EMAC_CAM2L_MACADDR1_Pos) /*!< EMAC_T::CAM2L: MACADDR1 Mask */ + +#define EMAC_CAM3M_MACADDR2_Pos (0) /*!< EMAC_T::CAM3M: MACADDR2 Position */ +#define EMAC_CAM3M_MACADDR2_Msk (0xfful << EMAC_CAM3M_MACADDR2_Pos) /*!< EMAC_T::CAM3M: MACADDR2 Mask */ + +#define EMAC_CAM3M_MACADDR3_Pos (8) /*!< EMAC_T::CAM3M: MACADDR3 Position */ +#define EMAC_CAM3M_MACADDR3_Msk (0xfful << EMAC_CAM3M_MACADDR3_Pos) /*!< EMAC_T::CAM3M: MACADDR3 Mask */ + +#define EMAC_CAM3M_MACADDR4_Pos (16) /*!< EMAC_T::CAM3M: MACADDR4 Position */ +#define EMAC_CAM3M_MACADDR4_Msk (0xfful << EMAC_CAM3M_MACADDR4_Pos) /*!< EMAC_T::CAM3M: MACADDR4 Mask */ + +#define EMAC_CAM3M_MACADDR5_Pos (24) /*!< EMAC_T::CAM3M: MACADDR5 Position */ +#define EMAC_CAM3M_MACADDR5_Msk (0xfful << EMAC_CAM3M_MACADDR5_Pos) /*!< EMAC_T::CAM3M: MACADDR5 Mask */ + +#define EMAC_CAM3L_Rserved_Pos (0) /*!< EMAC_T::CAM3L: Rserved Position */ +#define EMAC_CAM3L_Rserved_Msk (0xfffful << EMAC_CAM3L_Rserved_Pos) /*!< EMAC_T::CAM3L: Rserved Mask */ + +#define EMAC_CAM3L_MACADDR0_Pos (16) /*!< EMAC_T::CAM3L: MACADDR0 Position */ +#define EMAC_CAM3L_MACADDR0_Msk (0xfful << EMAC_CAM3L_MACADDR0_Pos) /*!< EMAC_T::CAM3L: MACADDR0 Mask */ + +#define EMAC_CAM3L_MACADDR1_Pos (24) /*!< EMAC_T::CAM3L: MACADDR1 Position */ +#define EMAC_CAM3L_MACADDR1_Msk (0xfful << EMAC_CAM3L_MACADDR1_Pos) /*!< EMAC_T::CAM3L: MACADDR1 Mask */ + +#define EMAC_CAM4M_MACADDR2_Pos (0) /*!< EMAC_T::CAM4M: MACADDR2 Position */ +#define EMAC_CAM4M_MACADDR2_Msk (0xfful << EMAC_CAM4M_MACADDR2_Pos) /*!< EMAC_T::CAM4M: MACADDR2 Mask */ + +#define EMAC_CAM4M_MACADDR3_Pos (8) /*!< EMAC_T::CAM4M: MACADDR3 Position */ +#define EMAC_CAM4M_MACADDR3_Msk (0xfful << EMAC_CAM4M_MACADDR3_Pos) /*!< EMAC_T::CAM4M: MACADDR3 Mask */ + +#define EMAC_CAM4M_MACADDR4_Pos (16) /*!< EMAC_T::CAM4M: MACADDR4 Position */ +#define EMAC_CAM4M_MACADDR4_Msk (0xfful << EMAC_CAM4M_MACADDR4_Pos) /*!< EMAC_T::CAM4M: MACADDR4 Mask */ + +#define EMAC_CAM4M_MACADDR5_Pos (24) /*!< EMAC_T::CAM4M: MACADDR5 Position */ +#define EMAC_CAM4M_MACADDR5_Msk (0xfful << EMAC_CAM4M_MACADDR5_Pos) /*!< EMAC_T::CAM4M: MACADDR5 Mask */ + +#define EMAC_CAM4L_Rserved_Pos (0) /*!< EMAC_T::CAM4L: Rserved Position */ +#define EMAC_CAM4L_Rserved_Msk (0xfffful << EMAC_CAM4L_Rserved_Pos) /*!< EMAC_T::CAM4L: Rserved Mask */ + +#define EMAC_CAM4L_MACADDR0_Pos (16) /*!< EMAC_T::CAM4L: MACADDR0 Position */ +#define EMAC_CAM4L_MACADDR0_Msk (0xfful << EMAC_CAM4L_MACADDR0_Pos) /*!< EMAC_T::CAM4L: MACADDR0 Mask */ + +#define EMAC_CAM4L_MACADDR1_Pos (24) /*!< EMAC_T::CAM4L: MACADDR1 Position */ +#define EMAC_CAM4L_MACADDR1_Msk (0xfful << EMAC_CAM4L_MACADDR1_Pos) /*!< EMAC_T::CAM4L: MACADDR1 Mask */ + +#define EMAC_CAM5M_MACADDR2_Pos (0) /*!< EMAC_T::CAM5M: MACADDR2 Position */ +#define EMAC_CAM5M_MACADDR2_Msk (0xfful << EMAC_CAM5M_MACADDR2_Pos) /*!< EMAC_T::CAM5M: MACADDR2 Mask */ + +#define EMAC_CAM5M_MACADDR3_Pos (8) /*!< EMAC_T::CAM5M: MACADDR3 Position */ +#define EMAC_CAM5M_MACADDR3_Msk (0xfful << EMAC_CAM5M_MACADDR3_Pos) /*!< EMAC_T::CAM5M: MACADDR3 Mask */ + +#define EMAC_CAM5M_MACADDR4_Pos (16) /*!< EMAC_T::CAM5M: MACADDR4 Position */ +#define EMAC_CAM5M_MACADDR4_Msk (0xfful << EMAC_CAM5M_MACADDR4_Pos) /*!< EMAC_T::CAM5M: MACADDR4 Mask */ + +#define EMAC_CAM5M_MACADDR5_Pos (24) /*!< EMAC_T::CAM5M: MACADDR5 Position */ +#define EMAC_CAM5M_MACADDR5_Msk (0xfful << EMAC_CAM5M_MACADDR5_Pos) /*!< EMAC_T::CAM5M: MACADDR5 Mask */ + +#define EMAC_CAM5L_Rserved_Pos (0) /*!< EMAC_T::CAM5L: Rserved Position */ +#define EMAC_CAM5L_Rserved_Msk (0xfffful << EMAC_CAM5L_Rserved_Pos) /*!< EMAC_T::CAM5L: Rserved Mask */ + +#define EMAC_CAM5L_MACADDR0_Pos (16) /*!< EMAC_T::CAM5L: MACADDR0 Position */ +#define EMAC_CAM5L_MACADDR0_Msk (0xfful << EMAC_CAM5L_MACADDR0_Pos) /*!< EMAC_T::CAM5L: MACADDR0 Mask */ + +#define EMAC_CAM5L_MACADDR1_Pos (24) /*!< EMAC_T::CAM5L: MACADDR1 Position */ +#define EMAC_CAM5L_MACADDR1_Msk (0xfful << EMAC_CAM5L_MACADDR1_Pos) /*!< EMAC_T::CAM5L: MACADDR1 Mask */ + +#define EMAC_CAM6M_MACADDR2_Pos (0) /*!< EMAC_T::CAM6M: MACADDR2 Position */ +#define EMAC_CAM6M_MACADDR2_Msk (0xfful << EMAC_CAM6M_MACADDR2_Pos) /*!< EMAC_T::CAM6M: MACADDR2 Mask */ + +#define EMAC_CAM6M_MACADDR3_Pos (8) /*!< EMAC_T::CAM6M: MACADDR3 Position */ +#define EMAC_CAM6M_MACADDR3_Msk (0xfful << EMAC_CAM6M_MACADDR3_Pos) /*!< EMAC_T::CAM6M: MACADDR3 Mask */ + +#define EMAC_CAM6M_MACADDR4_Pos (16) /*!< EMAC_T::CAM6M: MACADDR4 Position */ +#define EMAC_CAM6M_MACADDR4_Msk (0xfful << EMAC_CAM6M_MACADDR4_Pos) /*!< EMAC_T::CAM6M: MACADDR4 Mask */ + +#define EMAC_CAM6M_MACADDR5_Pos (24) /*!< EMAC_T::CAM6M: MACADDR5 Position */ +#define EMAC_CAM6M_MACADDR5_Msk (0xfful << EMAC_CAM6M_MACADDR5_Pos) /*!< EMAC_T::CAM6M: MACADDR5 Mask */ + +#define EMAC_CAM6L_Rserved_Pos (0) /*!< EMAC_T::CAM6L: Rserved Position */ +#define EMAC_CAM6L_Rserved_Msk (0xfffful << EMAC_CAM6L_Rserved_Pos) /*!< EMAC_T::CAM6L: Rserved Mask */ + +#define EMAC_CAM6L_MACADDR0_Pos (16) /*!< EMAC_T::CAM6L: MACADDR0 Position */ +#define EMAC_CAM6L_MACADDR0_Msk (0xfful << EMAC_CAM6L_MACADDR0_Pos) /*!< EMAC_T::CAM6L: MACADDR0 Mask */ + +#define EMAC_CAM6L_MACADDR1_Pos (24) /*!< EMAC_T::CAM6L: MACADDR1 Position */ +#define EMAC_CAM6L_MACADDR1_Msk (0xfful << EMAC_CAM6L_MACADDR1_Pos) /*!< EMAC_T::CAM6L: MACADDR1 Mask */ + +#define EMAC_CAM7M_MACADDR2_Pos (0) /*!< EMAC_T::CAM7M: MACADDR2 Position */ +#define EMAC_CAM7M_MACADDR2_Msk (0xfful << EMAC_CAM7M_MACADDR2_Pos) /*!< EMAC_T::CAM7M: MACADDR2 Mask */ + +#define EMAC_CAM7M_MACADDR3_Pos (8) /*!< EMAC_T::CAM7M: MACADDR3 Position */ +#define EMAC_CAM7M_MACADDR3_Msk (0xfful << EMAC_CAM7M_MACADDR3_Pos) /*!< EMAC_T::CAM7M: MACADDR3 Mask */ + +#define EMAC_CAM7M_MACADDR4_Pos (16) /*!< EMAC_T::CAM7M: MACADDR4 Position */ +#define EMAC_CAM7M_MACADDR4_Msk (0xfful << EMAC_CAM7M_MACADDR4_Pos) /*!< EMAC_T::CAM7M: MACADDR4 Mask */ + +#define EMAC_CAM7M_MACADDR5_Pos (24) /*!< EMAC_T::CAM7M: MACADDR5 Position */ +#define EMAC_CAM7M_MACADDR5_Msk (0xfful << EMAC_CAM7M_MACADDR5_Pos) /*!< EMAC_T::CAM7M: MACADDR5 Mask */ + +#define EMAC_CAM7L_Rserved_Pos (0) /*!< EMAC_T::CAM7L: Rserved Position */ +#define EMAC_CAM7L_Rserved_Msk (0xfffful << EMAC_CAM7L_Rserved_Pos) /*!< EMAC_T::CAM7L: Rserved Mask */ + +#define EMAC_CAM7L_MACADDR0_Pos (16) /*!< EMAC_T::CAM7L: MACADDR0 Position */ +#define EMAC_CAM7L_MACADDR0_Msk (0xfful << EMAC_CAM7L_MACADDR0_Pos) /*!< EMAC_T::CAM7L: MACADDR0 Mask */ + +#define EMAC_CAM7L_MACADDR1_Pos (24) /*!< EMAC_T::CAM7L: MACADDR1 Position */ +#define EMAC_CAM7L_MACADDR1_Msk (0xfful << EMAC_CAM7L_MACADDR1_Pos) /*!< EMAC_T::CAM7L: MACADDR1 Mask */ + +#define EMAC_CAM8M_MACADDR2_Pos (0) /*!< EMAC_T::CAM8M: MACADDR2 Position */ +#define EMAC_CAM8M_MACADDR2_Msk (0xfful << EMAC_CAM8M_MACADDR2_Pos) /*!< EMAC_T::CAM8M: MACADDR2 Mask */ + +#define EMAC_CAM8M_MACADDR3_Pos (8) /*!< EMAC_T::CAM8M: MACADDR3 Position */ +#define EMAC_CAM8M_MACADDR3_Msk (0xfful << EMAC_CAM8M_MACADDR3_Pos) /*!< EMAC_T::CAM8M: MACADDR3 Mask */ + +#define EMAC_CAM8M_MACADDR4_Pos (16) /*!< EMAC_T::CAM8M: MACADDR4 Position */ +#define EMAC_CAM8M_MACADDR4_Msk (0xfful << EMAC_CAM8M_MACADDR4_Pos) /*!< EMAC_T::CAM8M: MACADDR4 Mask */ + +#define EMAC_CAM8M_MACADDR5_Pos (24) /*!< EMAC_T::CAM8M: MACADDR5 Position */ +#define EMAC_CAM8M_MACADDR5_Msk (0xfful << EMAC_CAM8M_MACADDR5_Pos) /*!< EMAC_T::CAM8M: MACADDR5 Mask */ + +#define EMAC_CAM8L_Rserved_Pos (0) /*!< EMAC_T::CAM8L: Rserved Position */ +#define EMAC_CAM8L_Rserved_Msk (0xfffful << EMAC_CAM8L_Rserved_Pos) /*!< EMAC_T::CAM8L: Rserved Mask */ + +#define EMAC_CAM8L_MACADDR0_Pos (16) /*!< EMAC_T::CAM8L: MACADDR0 Position */ +#define EMAC_CAM8L_MACADDR0_Msk (0xfful << EMAC_CAM8L_MACADDR0_Pos) /*!< EMAC_T::CAM8L: MACADDR0 Mask */ + +#define EMAC_CAM8L_MACADDR1_Pos (24) /*!< EMAC_T::CAM8L: MACADDR1 Position */ +#define EMAC_CAM8L_MACADDR1_Msk (0xfful << EMAC_CAM8L_MACADDR1_Pos) /*!< EMAC_T::CAM8L: MACADDR1 Mask */ + +#define EMAC_CAM9M_MACADDR2_Pos (0) /*!< EMAC_T::CAM9M: MACADDR2 Position */ +#define EMAC_CAM9M_MACADDR2_Msk (0xfful << EMAC_CAM9M_MACADDR2_Pos) /*!< EMAC_T::CAM9M: MACADDR2 Mask */ + +#define EMAC_CAM9M_MACADDR3_Pos (8) /*!< EMAC_T::CAM9M: MACADDR3 Position */ +#define EMAC_CAM9M_MACADDR3_Msk (0xfful << EMAC_CAM9M_MACADDR3_Pos) /*!< EMAC_T::CAM9M: MACADDR3 Mask */ + +#define EMAC_CAM9M_MACADDR4_Pos (16) /*!< EMAC_T::CAM9M: MACADDR4 Position */ +#define EMAC_CAM9M_MACADDR4_Msk (0xfful << EMAC_CAM9M_MACADDR4_Pos) /*!< EMAC_T::CAM9M: MACADDR4 Mask */ + +#define EMAC_CAM9M_MACADDR5_Pos (24) /*!< EMAC_T::CAM9M: MACADDR5 Position */ +#define EMAC_CAM9M_MACADDR5_Msk (0xfful << EMAC_CAM9M_MACADDR5_Pos) /*!< EMAC_T::CAM9M: MACADDR5 Mask */ + +#define EMAC_CAM9L_Rserved_Pos (0) /*!< EMAC_T::CAM9L: Rserved Position */ +#define EMAC_CAM9L_Rserved_Msk (0xfffful << EMAC_CAM9L_Rserved_Pos) /*!< EMAC_T::CAM9L: Rserved Mask */ + +#define EMAC_CAM9L_MACADDR0_Pos (16) /*!< EMAC_T::CAM9L: MACADDR0 Position */ +#define EMAC_CAM9L_MACADDR0_Msk (0xfful << EMAC_CAM9L_MACADDR0_Pos) /*!< EMAC_T::CAM9L: MACADDR0 Mask */ + +#define EMAC_CAM9L_MACADDR1_Pos (24) /*!< EMAC_T::CAM9L: MACADDR1 Position */ +#define EMAC_CAM9L_MACADDR1_Msk (0xfful << EMAC_CAM9L_MACADDR1_Pos) /*!< EMAC_T::CAM9L: MACADDR1 Mask */ + +#define EMAC_CAM10M_MACADDR2_Pos (0) /*!< EMAC_T::CAM10M: MACADDR2 Position */ +#define EMAC_CAM10M_MACADDR2_Msk (0xfful << EMAC_CAM10M_MACADDR2_Pos) /*!< EMAC_T::CAM10M: MACADDR2 Mask */ + +#define EMAC_CAM10M_MACADDR3_Pos (8) /*!< EMAC_T::CAM10M: MACADDR3 Position */ +#define EMAC_CAM10M_MACADDR3_Msk (0xfful << EMAC_CAM10M_MACADDR3_Pos) /*!< EMAC_T::CAM10M: MACADDR3 Mask */ + +#define EMAC_CAM10M_MACADDR4_Pos (16) /*!< EMAC_T::CAM10M: MACADDR4 Position */ +#define EMAC_CAM10M_MACADDR4_Msk (0xfful << EMAC_CAM10M_MACADDR4_Pos) /*!< EMAC_T::CAM10M: MACADDR4 Mask */ + +#define EMAC_CAM10M_MACADDR5_Pos (24) /*!< EMAC_T::CAM10M: MACADDR5 Position */ +#define EMAC_CAM10M_MACADDR5_Msk (0xfful << EMAC_CAM10M_MACADDR5_Pos) /*!< EMAC_T::CAM10M: MACADDR5 Mask */ + +#define EMAC_CAM10L_Rserved_Pos (0) /*!< EMAC_T::CAM10L: Rserved Position */ +#define EMAC_CAM10L_Rserved_Msk (0xfffful << EMAC_CAM10L_Rserved_Pos) /*!< EMAC_T::CAM10L: Rserved Mask */ + +#define EMAC_CAM10L_MACADDR0_Pos (16) /*!< EMAC_T::CAM10L: MACADDR0 Position */ +#define EMAC_CAM10L_MACADDR0_Msk (0xfful << EMAC_CAM10L_MACADDR0_Pos) /*!< EMAC_T::CAM10L: MACADDR0 Mask */ + +#define EMAC_CAM10L_MACADDR1_Pos (24) /*!< EMAC_T::CAM10L: MACADDR1 Position */ +#define EMAC_CAM10L_MACADDR1_Msk (0xfful << EMAC_CAM10L_MACADDR1_Pos) /*!< EMAC_T::CAM10L: MACADDR1 Mask */ + +#define EMAC_CAM11M_MACADDR2_Pos (0) /*!< EMAC_T::CAM11M: MACADDR2 Position */ +#define EMAC_CAM11M_MACADDR2_Msk (0xfful << EMAC_CAM11M_MACADDR2_Pos) /*!< EMAC_T::CAM11M: MACADDR2 Mask */ + +#define EMAC_CAM11M_MACADDR3_Pos (8) /*!< EMAC_T::CAM11M: MACADDR3 Position */ +#define EMAC_CAM11M_MACADDR3_Msk (0xfful << EMAC_CAM11M_MACADDR3_Pos) /*!< EMAC_T::CAM11M: MACADDR3 Mask */ + +#define EMAC_CAM11M_MACADDR4_Pos (16) /*!< EMAC_T::CAM11M: MACADDR4 Position */ +#define EMAC_CAM11M_MACADDR4_Msk (0xfful << EMAC_CAM11M_MACADDR4_Pos) /*!< EMAC_T::CAM11M: MACADDR4 Mask */ + +#define EMAC_CAM11M_MACADDR5_Pos (24) /*!< EMAC_T::CAM11M: MACADDR5 Position */ +#define EMAC_CAM11M_MACADDR5_Msk (0xfful << EMAC_CAM11M_MACADDR5_Pos) /*!< EMAC_T::CAM11M: MACADDR5 Mask */ + +#define EMAC_CAM11L_Rserved_Pos (0) /*!< EMAC_T::CAM11L: Rserved Position */ +#define EMAC_CAM11L_Rserved_Msk (0xfffful << EMAC_CAM11L_Rserved_Pos) /*!< EMAC_T::CAM11L: Rserved Mask */ + +#define EMAC_CAM11L_MACADDR0_Pos (16) /*!< EMAC_T::CAM11L: MACADDR0 Position */ +#define EMAC_CAM11L_MACADDR0_Msk (0xfful << EMAC_CAM11L_MACADDR0_Pos) /*!< EMAC_T::CAM11L: MACADDR0 Mask */ + +#define EMAC_CAM11L_MACADDR1_Pos (24) /*!< EMAC_T::CAM11L: MACADDR1 Position */ +#define EMAC_CAM11L_MACADDR1_Msk (0xfful << EMAC_CAM11L_MACADDR1_Pos) /*!< EMAC_T::CAM11L: MACADDR1 Mask */ + +#define EMAC_CAM12M_MACADDR2_Pos (0) /*!< EMAC_T::CAM12M: MACADDR2 Position */ +#define EMAC_CAM12M_MACADDR2_Msk (0xfful << EMAC_CAM12M_MACADDR2_Pos) /*!< EMAC_T::CAM12M: MACADDR2 Mask */ + +#define EMAC_CAM12M_MACADDR3_Pos (8) /*!< EMAC_T::CAM12M: MACADDR3 Position */ +#define EMAC_CAM12M_MACADDR3_Msk (0xfful << EMAC_CAM12M_MACADDR3_Pos) /*!< EMAC_T::CAM12M: MACADDR3 Mask */ + +#define EMAC_CAM12M_MACADDR4_Pos (16) /*!< EMAC_T::CAM12M: MACADDR4 Position */ +#define EMAC_CAM12M_MACADDR4_Msk (0xfful << EMAC_CAM12M_MACADDR4_Pos) /*!< EMAC_T::CAM12M: MACADDR4 Mask */ + +#define EMAC_CAM12M_MACADDR5_Pos (24) /*!< EMAC_T::CAM12M: MACADDR5 Position */ +#define EMAC_CAM12M_MACADDR5_Msk (0xfful << EMAC_CAM12M_MACADDR5_Pos) /*!< EMAC_T::CAM12M: MACADDR5 Mask */ + +#define EMAC_CAM12L_Rserved_Pos (0) /*!< EMAC_T::CAM12L: Rserved Position */ +#define EMAC_CAM12L_Rserved_Msk (0xfffful << EMAC_CAM12L_Rserved_Pos) /*!< EMAC_T::CAM12L: Rserved Mask */ + +#define EMAC_CAM12L_MACADDR0_Pos (16) /*!< EMAC_T::CAM12L: MACADDR0 Position */ +#define EMAC_CAM12L_MACADDR0_Msk (0xfful << EMAC_CAM12L_MACADDR0_Pos) /*!< EMAC_T::CAM12L: MACADDR0 Mask */ + +#define EMAC_CAM12L_MACADDR1_Pos (24) /*!< EMAC_T::CAM12L: MACADDR1 Position */ +#define EMAC_CAM12L_MACADDR1_Msk (0xfful << EMAC_CAM12L_MACADDR1_Pos) /*!< EMAC_T::CAM12L: MACADDR1 Mask */ + +#define EMAC_CAM13M_MACADDR2_Pos (0) /*!< EMAC_T::CAM13M: MACADDR2 Position */ +#define EMAC_CAM13M_MACADDR2_Msk (0xfful << EMAC_CAM13M_MACADDR2_Pos) /*!< EMAC_T::CAM13M: MACADDR2 Mask */ + +#define EMAC_CAM13M_MACADDR3_Pos (8) /*!< EMAC_T::CAM13M: MACADDR3 Position */ +#define EMAC_CAM13M_MACADDR3_Msk (0xfful << EMAC_CAM13M_MACADDR3_Pos) /*!< EMAC_T::CAM13M: MACADDR3 Mask */ + +#define EMAC_CAM13M_MACADDR4_Pos (16) /*!< EMAC_T::CAM13M: MACADDR4 Position */ +#define EMAC_CAM13M_MACADDR4_Msk (0xfful << EMAC_CAM13M_MACADDR4_Pos) /*!< EMAC_T::CAM13M: MACADDR4 Mask */ + +#define EMAC_CAM13M_MACADDR5_Pos (24) /*!< EMAC_T::CAM13M: MACADDR5 Position */ +#define EMAC_CAM13M_MACADDR5_Msk (0xfful << EMAC_CAM13M_MACADDR5_Pos) /*!< EMAC_T::CAM13M: MACADDR5 Mask */ + +#define EMAC_CAM13L_Rserved_Pos (0) /*!< EMAC_T::CAM13L: Rserved Position */ +#define EMAC_CAM13L_Rserved_Msk (0xfffful << EMAC_CAM13L_Rserved_Pos) /*!< EMAC_T::CAM13L: Rserved Mask */ + +#define EMAC_CAM13L_MACADDR0_Pos (16) /*!< EMAC_T::CAM13L: MACADDR0 Position */ +#define EMAC_CAM13L_MACADDR0_Msk (0xfful << EMAC_CAM13L_MACADDR0_Pos) /*!< EMAC_T::CAM13L: MACADDR0 Mask */ + +#define EMAC_CAM13L_MACADDR1_Pos (24) /*!< EMAC_T::CAM13L: MACADDR1 Position */ +#define EMAC_CAM13L_MACADDR1_Msk (0xfful << EMAC_CAM13L_MACADDR1_Pos) /*!< EMAC_T::CAM13L: MACADDR1 Mask */ + +#define EMAC_CAM14M_MACADDR2_Pos (0) /*!< EMAC_T::CAM14M: MACADDR2 Position */ +#define EMAC_CAM14M_MACADDR2_Msk (0xfful << EMAC_CAM14M_MACADDR2_Pos) /*!< EMAC_T::CAM14M: MACADDR2 Mask */ + +#define EMAC_CAM14M_MACADDR3_Pos (8) /*!< EMAC_T::CAM14M: MACADDR3 Position */ +#define EMAC_CAM14M_MACADDR3_Msk (0xfful << EMAC_CAM14M_MACADDR3_Pos) /*!< EMAC_T::CAM14M: MACADDR3 Mask */ + +#define EMAC_CAM14M_MACADDR4_Pos (16) /*!< EMAC_T::CAM14M: MACADDR4 Position */ +#define EMAC_CAM14M_MACADDR4_Msk (0xfful << EMAC_CAM14M_MACADDR4_Pos) /*!< EMAC_T::CAM14M: MACADDR4 Mask */ + +#define EMAC_CAM14M_MACADDR5_Pos (24) /*!< EMAC_T::CAM14M: MACADDR5 Position */ +#define EMAC_CAM14M_MACADDR5_Msk (0xfful << EMAC_CAM14M_MACADDR5_Pos) /*!< EMAC_T::CAM14M: MACADDR5 Mask */ + +#define EMAC_CAM14L_Rserved_Pos (0) /*!< EMAC_T::CAM14L: Rserved Position */ +#define EMAC_CAM14L_Rserved_Msk (0xfffful << EMAC_CAM14L_Rserved_Pos) /*!< EMAC_T::CAM14L: Rserved Mask */ + +#define EMAC_CAM14L_MACADDR0_Pos (16) /*!< EMAC_T::CAM14L: MACADDR0 Position */ +#define EMAC_CAM14L_MACADDR0_Msk (0xfful << EMAC_CAM14L_MACADDR0_Pos) /*!< EMAC_T::CAM14L: MACADDR0 Mask */ + +#define EMAC_CAM14L_MACADDR1_Pos (24) /*!< EMAC_T::CAM14L: MACADDR1 Position */ +#define EMAC_CAM14L_MACADDR1_Msk (0xfful << EMAC_CAM14L_MACADDR1_Pos) /*!< EMAC_T::CAM14L: MACADDR1 Mask */ + +#define EMAC_CAM15MSB_OPCODE_Pos (0) /*!< EMAC_T::CAM15MSB: OPCODE Position */ +#define EMAC_CAM15MSB_OPCODE_Msk (0xfffful << EMAC_CAM15MSB_OPCODE_Pos) /*!< EMAC_T::CAM15MSB: OPCODE Mask */ + +#define EMAC_CAM15MSB_LENGTH_Pos (16) /*!< EMAC_T::CAM15MSB: LENGTH Position */ +#define EMAC_CAM15MSB_LENGTH_Msk (0xfffful << EMAC_CAM15MSB_LENGTH_Pos) /*!< EMAC_T::CAM15MSB: LENGTH Mask */ + +#define EMAC_CAM15LSB_OPERAND_Pos (24) /*!< EMAC_T::CAM15LSB: OPERAND Position */ +#define EMAC_CAM15LSB_OPERAND_Msk (0xfful << EMAC_CAM15LSB_OPERAND_Pos) /*!< EMAC_T::CAM15LSB: OPERAND Mask */ + +#define EMAC_TXDSA_TXDSA_Pos (0) /*!< EMAC_T::TXDSA: TXDSA Position */ +#define EMAC_TXDSA_TXDSA_Msk (0xfffffffful << EMAC_TXDSA_TXDSA_Pos) /*!< EMAC_T::TXDSA: TXDSA Mask */ + +#define EMAC_RXDSA_RXDSA_Pos (0) /*!< EMAC_T::RXDSA: RXDSA Position */ +#define EMAC_RXDSA_RXDSA_Msk (0xfffffffful << EMAC_RXDSA_RXDSA_Pos) /*!< EMAC_T::RXDSA: RXDSA Mask */ + +#define EMAC_CTL_RXON_Pos (0) /*!< EMAC_T::CTL: RXON Position */ +#define EMAC_CTL_RXON_Msk (0x1ul << EMAC_CTL_RXON_Pos) /*!< EMAC_T::CTL: RXON Mask */ + +#define EMAC_CTL_ALP_Pos (1) /*!< EMAC_T::CTL: ALP Position */ +#define EMAC_CTL_ALP_Msk (0x1ul << EMAC_CTL_ALP_Pos) /*!< EMAC_T::CTL: ALP Mask */ + +#define EMAC_CTL_ARP_Pos (2) /*!< EMAC_T::CTL: ARP Position */ +#define EMAC_CTL_ARP_Msk (0x1ul << EMAC_CTL_ARP_Pos) /*!< EMAC_T::CTL: ARP Mask */ + +#define EMAC_CTL_ACP_Pos (3) /*!< EMAC_T::CTL: ACP Position */ +#define EMAC_CTL_ACP_Msk (0x1ul << EMAC_CTL_ACP_Pos) /*!< EMAC_T::CTL: ACP Mask */ + +#define EMAC_CTL_AEP_Pos (4) /*!< EMAC_T::CTL: AEP Position */ +#define EMAC_CTL_AEP_Msk (0x1ul << EMAC_CTL_AEP_Pos) /*!< EMAC_T::CTL: AEP Mask */ + +#define EMAC_CTL_STRIPCRC_Pos (5) /*!< EMAC_T::CTL: STRIPCRC Position */ +#define EMAC_CTL_STRIPCRC_Msk (0x1ul << EMAC_CTL_STRIPCRC_Pos) /*!< EMAC_T::CTL: STRIPCRC Mask */ + +#define EMAC_CTL_WOLEN_Pos (6) /*!< EMAC_T::CTL: WOLEN Position */ +#define EMAC_CTL_WOLEN_Msk (0x1ul << EMAC_CTL_WOLEN_Pos) /*!< EMAC_T::CTL: WOLEN Mask */ + +#define EMAC_CTL_TXON_Pos (8) /*!< EMAC_T::CTL: TXON Position */ +#define EMAC_CTL_TXON_Msk (0x1ul << EMAC_CTL_TXON_Pos) /*!< EMAC_T::CTL: TXON Mask */ + +#define EMAC_CTL_NODEF_Pos (9) /*!< EMAC_T::CTL: NODEF Position */ +#define EMAC_CTL_NODEF_Msk (0x1ul << EMAC_CTL_NODEF_Pos) /*!< EMAC_T::CTL: NODEF Mask */ + +#define EMAC_CTL_SDPZ_Pos (16) /*!< EMAC_T::CTL: SDPZ Position */ +#define EMAC_CTL_SDPZ_Msk (0x1ul << EMAC_CTL_SDPZ_Pos) /*!< EMAC_T::CTL: SDPZ Mask */ + +#define EMAC_CTL_SQECHKEN_Pos (17) /*!< EMAC_T::CTL: SQECHKEN Position */ +#define EMAC_CTL_SQECHKEN_Msk (0x1ul << EMAC_CTL_SQECHKEN_Pos) /*!< EMAC_T::CTL: SQECHKEN Mask */ + +#define EMAC_CTL_FUDUP_Pos (18) /*!< EMAC_T::CTL: FUDUP Position */ +#define EMAC_CTL_FUDUP_Msk (0x1ul << EMAC_CTL_FUDUP_Pos) /*!< EMAC_T::CTL: FUDUP Mask */ + +#define EMAC_CTL_RMIIRXCTL_Pos (19) /*!< EMAC_T::CTL: RMIIRXCTL Position */ +#define EMAC_CTL_RMIIRXCTL_Msk (0x1ul << EMAC_CTL_RMIIRXCTL_Pos) /*!< EMAC_T::CTL: RMIIRXCTL Mask */ + +#define EMAC_CTL_OPMODE_Pos (20) /*!< EMAC_T::CTL: OPMODE Position */ +#define EMAC_CTL_OPMODE_Msk (0x1ul << EMAC_CTL_OPMODE_Pos) /*!< EMAC_T::CTL: OPMODE Mask */ + +#define EMAC_CTL_RMIIEN_Pos (22) /*!< EMAC_T::CTL: RMIIEN Position */ +#define EMAC_CTL_RMIIEN_Msk (0x1ul << EMAC_CTL_RMIIEN_Pos) /*!< EMAC_T::CTL: RMIIEN Mask */ + +#define EMAC_CTL_RST_Pos (24) /*!< EMAC_T::CTL: RST Position */ +#define EMAC_CTL_RST_Msk (0x1ul << EMAC_CTL_RST_Pos) /*!< EMAC_T::CTL: RST Mask */ + +#define EMAC_MIIMDAT_DATA_Pos (0) /*!< EMAC_T::MIIMDAT: DATA Position */ +#define EMAC_MIIMDAT_DATA_Msk (0xfffful << EMAC_MIIMDAT_DATA_Pos) /*!< EMAC_T::MIIMDAT: DATA Mask */ + +#define EMAC_MIIMCTL_PHYREG_Pos (0) /*!< EMAC_T::MIIMCTL: PHYREG Position */ +#define EMAC_MIIMCTL_PHYREG_Msk (0x1ful << EMAC_MIIMCTL_PHYREG_Pos) /*!< EMAC_T::MIIMCTL: PHYREG Mask */ + +#define EMAC_MIIMCTL_PHYADDR_Pos (8) /*!< EMAC_T::MIIMCTL: PHYADDR Position */ +#define EMAC_MIIMCTL_PHYADDR_Msk (0x1ful << EMAC_MIIMCTL_PHYADDR_Pos) /*!< EMAC_T::MIIMCTL: PHYADDR Mask */ + +#define EMAC_MIIMCTL_WRITE_Pos (16) /*!< EMAC_T::MIIMCTL: WRITE Position */ +#define EMAC_MIIMCTL_WRITE_Msk (0x1ul << EMAC_MIIMCTL_WRITE_Pos) /*!< EMAC_T::MIIMCTL: WRITE Mask */ + +#define EMAC_MIIMCTL_BUSY_Pos (17) /*!< EMAC_T::MIIMCTL: BUSY Position */ +#define EMAC_MIIMCTL_BUSY_Msk (0x1ul << EMAC_MIIMCTL_BUSY_Pos) /*!< EMAC_T::MIIMCTL: BUSY Mask */ + +#define EMAC_MIIMCTL_PREAMSP_Pos (18) /*!< EMAC_T::MIIMCTL: PREAMSP Position */ +#define EMAC_MIIMCTL_PREAMSP_Msk (0x1ul << EMAC_MIIMCTL_PREAMSP_Pos) /*!< EMAC_T::MIIMCTL: PREAMSP Mask */ + +#define EMAC_MIIMCTL_MDCON_Pos (19) /*!< EMAC_T::MIIMCTL: MDCON Position */ +#define EMAC_MIIMCTL_MDCON_Msk (0x1ul << EMAC_MIIMCTL_MDCON_Pos) /*!< EMAC_T::MIIMCTL: MDCON Mask */ + +#define EMAC_FIFOCTL_RXFIFOTH_Pos (0) /*!< EMAC_T::FIFOCTL: RXFIFOTH Position */ +#define EMAC_FIFOCTL_RXFIFOTH_Msk (0x3ul << EMAC_FIFOCTL_RXFIFOTH_Pos) /*!< EMAC_T::FIFOCTL: RXFIFOTH Mask */ + +#define EMAC_FIFOCTL_TXFIFOTH_Pos (8) /*!< EMAC_T::FIFOCTL: TXFIFOTH Position */ +#define EMAC_FIFOCTL_TXFIFOTH_Msk (0x3ul << EMAC_FIFOCTL_TXFIFOTH_Pos) /*!< EMAC_T::FIFOCTL: TXFIFOTH Mask */ + +#define EMAC_FIFOCTL_BURSTLEN_Pos (20) /*!< EMAC_T::FIFOCTL: BURSTLEN Position */ +#define EMAC_FIFOCTL_BURSTLEN_Msk (0x3ul << EMAC_FIFOCTL_BURSTLEN_Pos) /*!< EMAC_T::FIFOCTL: BURSTLEN Mask */ + +#define EMAC_TXST_TXST_Pos (0) /*!< EMAC_T::TXST: TXST Position */ +#define EMAC_TXST_TXST_Msk (0xfffffffful << EMAC_TXST_TXST_Pos) /*!< EMAC_T::TXST: TXST Mask */ + +#define EMAC_RXST_RXST_Pos (0) /*!< EMAC_T::RXST: RXST Position */ +#define EMAC_RXST_RXST_Msk (0xfffffffful << EMAC_RXST_RXST_Pos) /*!< EMAC_T::RXST: RXST Mask */ + +#define EMAC_MRFL_MRFL_Pos (0) /*!< EMAC_T::MRFL: MRFL Position */ +#define EMAC_MRFL_MRFL_Msk (0xfffful << EMAC_MRFL_MRFL_Pos) /*!< EMAC_T::MRFL: MRFL Mask */ + +#define EMAC_INTEN_RXIEN_Pos (0) /*!< EMAC_T::INTEN: RXIEN Position */ +#define EMAC_INTEN_RXIEN_Msk (0x1ul << EMAC_INTEN_RXIEN_Pos) /*!< EMAC_T::INTEN: RXIEN Mask */ + +#define EMAC_INTEN_CRCEIEN_Pos (1) /*!< EMAC_T::INTEN: CRCEIEN Position */ +#define EMAC_INTEN_CRCEIEN_Msk (0x1ul << EMAC_INTEN_CRCEIEN_Pos) /*!< EMAC_T::INTEN: CRCEIEN Mask */ + +#define EMAC_INTEN_RXOVIEN_Pos (2) /*!< EMAC_T::INTEN: RXOVIEN Position */ +#define EMAC_INTEN_RXOVIEN_Msk (0x1ul << EMAC_INTEN_RXOVIEN_Pos) /*!< EMAC_T::INTEN: RXOVIEN Mask */ + +#define EMAC_INTEN_LPIEN_Pos (3) /*!< EMAC_T::INTEN: LPIEN Position */ +#define EMAC_INTEN_LPIEN_Msk (0x1ul << EMAC_INTEN_LPIEN_Pos) /*!< EMAC_T::INTEN: LPIEN Mask */ + +#define EMAC_INTEN_RXGDIEN_Pos (4) /*!< EMAC_T::INTEN: RXGDIEN Position */ +#define EMAC_INTEN_RXGDIEN_Msk (0x1ul << EMAC_INTEN_RXGDIEN_Pos) /*!< EMAC_T::INTEN: RXGDIEN Mask */ + +#define EMAC_INTEN_ALIEIEN_Pos (5) /*!< EMAC_T::INTEN: ALIEIEN Position */ +#define EMAC_INTEN_ALIEIEN_Msk (0x1ul << EMAC_INTEN_ALIEIEN_Pos) /*!< EMAC_T::INTEN: ALIEIEN Mask */ + +#define EMAC_INTEN_RPIEN_Pos (6) /*!< EMAC_T::INTEN: RPIEN Position */ +#define EMAC_INTEN_RPIEN_Msk (0x1ul << EMAC_INTEN_RPIEN_Pos) /*!< EMAC_T::INTEN: RPIEN Mask */ + +#define EMAC_INTEN_MPCOVIEN_Pos (7) /*!< EMAC_T::INTEN: MPCOVIEN Position */ +#define EMAC_INTEN_MPCOVIEN_Msk (0x1ul << EMAC_INTEN_MPCOVIEN_Pos) /*!< EMAC_T::INTEN: MPCOVIEN Mask */ + +#define EMAC_INTEN_MFLEIEN_Pos (8) /*!< EMAC_T::INTEN: MFLEIEN Position */ +#define EMAC_INTEN_MFLEIEN_Msk (0x1ul << EMAC_INTEN_MFLEIEN_Pos) /*!< EMAC_T::INTEN: MFLEIEN Mask */ + +#define EMAC_INTEN_DENIEN_Pos (9) /*!< EMAC_T::INTEN: DENIEN Position */ +#define EMAC_INTEN_DENIEN_Msk (0x1ul << EMAC_INTEN_DENIEN_Pos) /*!< EMAC_T::INTEN: DENIEN Mask */ + +#define EMAC_INTEN_RDUIEN_Pos (10) /*!< EMAC_T::INTEN: RDUIEN Position */ +#define EMAC_INTEN_RDUIEN_Msk (0x1ul << EMAC_INTEN_RDUIEN_Pos) /*!< EMAC_T::INTEN: RDUIEN Mask */ + +#define EMAC_INTEN_RXBEIEN_Pos (11) /*!< EMAC_T::INTEN: RXBEIEN Position */ +#define EMAC_INTEN_RXBEIEN_Msk (0x1ul << EMAC_INTEN_RXBEIEN_Pos) /*!< EMAC_T::INTEN: RXBEIEN Mask */ + +#define EMAC_INTEN_CFRIEN_Pos (14) /*!< EMAC_T::INTEN: CFRIEN Position */ +#define EMAC_INTEN_CFRIEN_Msk (0x1ul << EMAC_INTEN_CFRIEN_Pos) /*!< EMAC_T::INTEN: CFRIEN Mask */ + +#define EMAC_INTEN_WOLIEN_Pos (15) /*!< EMAC_T::INTEN: WOLIEN Position */ +#define EMAC_INTEN_WOLIEN_Msk (0x1ul << EMAC_INTEN_WOLIEN_Pos) /*!< EMAC_T::INTEN: WOLIEN Mask */ + +#define EMAC_INTEN_TXIEN_Pos (16) /*!< EMAC_T::INTEN: TXIEN Position */ +#define EMAC_INTEN_TXIEN_Msk (0x1ul << EMAC_INTEN_TXIEN_Pos) /*!< EMAC_T::INTEN: TXIEN Mask */ + +#define EMAC_INTEN_TXUDIEN_Pos (17) /*!< EMAC_T::INTEN: TXUDIEN Position */ +#define EMAC_INTEN_TXUDIEN_Msk (0x1ul << EMAC_INTEN_TXUDIEN_Pos) /*!< EMAC_T::INTEN: TXUDIEN Mask */ + +#define EMAC_INTEN_TXCPIEN_Pos (18) /*!< EMAC_T::INTEN: TXCPIEN Position */ +#define EMAC_INTEN_TXCPIEN_Msk (0x1ul << EMAC_INTEN_TXCPIEN_Pos) /*!< EMAC_T::INTEN: TXCPIEN Mask */ + +#define EMAC_INTEN_EXDEFIEN_Pos (19) /*!< EMAC_T::INTEN: EXDEFIEN Position */ +#define EMAC_INTEN_EXDEFIEN_Msk (0x1ul << EMAC_INTEN_EXDEFIEN_Pos) /*!< EMAC_T::INTEN: EXDEFIEN Mask */ + +#define EMAC_INTEN_NCSIEN_Pos (20) /*!< EMAC_T::INTEN: NCSIEN Position */ +#define EMAC_INTEN_NCSIEN_Msk (0x1ul << EMAC_INTEN_NCSIEN_Pos) /*!< EMAC_T::INTEN: NCSIEN Mask */ + +#define EMAC_INTEN_TXABTIEN_Pos (21) /*!< EMAC_T::INTEN: TXABTIEN Position */ +#define EMAC_INTEN_TXABTIEN_Msk (0x1ul << EMAC_INTEN_TXABTIEN_Pos) /*!< EMAC_T::INTEN: TXABTIEN Mask */ + +#define EMAC_INTEN_LCIEN_Pos (22) /*!< EMAC_T::INTEN: LCIEN Position */ +#define EMAC_INTEN_LCIEN_Msk (0x1ul << EMAC_INTEN_LCIEN_Pos) /*!< EMAC_T::INTEN: LCIEN Mask */ + +#define EMAC_INTEN_TDUIEN_Pos (23) /*!< EMAC_T::INTEN: TDUIEN Position */ +#define EMAC_INTEN_TDUIEN_Msk (0x1ul << EMAC_INTEN_TDUIEN_Pos) /*!< EMAC_T::INTEN: TDUIEN Mask */ + +#define EMAC_INTEN_TXBEIEN_Pos (24) /*!< EMAC_T::INTEN: TXBEIEN Position */ +#define EMAC_INTEN_TXBEIEN_Msk (0x1ul << EMAC_INTEN_TXBEIEN_Pos) /*!< EMAC_T::INTEN: TXBEIEN Mask */ + +#define EMAC_INTEN_TSALMIEN_Pos (28) /*!< EMAC_T::INTEN: TSALMIEN Position */ +#define EMAC_INTEN_TSALMIEN_Msk (0x1ul << EMAC_INTEN_TSALMIEN_Pos) /*!< EMAC_T::INTEN: TSALMIEN Mask */ + +#define EMAC_INTSTS_RXIF_Pos (0) /*!< EMAC_T::INTSTS: RXIF Position */ +#define EMAC_INTSTS_RXIF_Msk (0x1ul << EMAC_INTSTS_RXIF_Pos) /*!< EMAC_T::INTSTS: RXIF Mask */ + +#define EMAC_INTSTS_CRCEIF_Pos (1) /*!< EMAC_T::INTSTS: CRCEIF Position */ +#define EMAC_INTSTS_CRCEIF_Msk (0x1ul << EMAC_INTSTS_CRCEIF_Pos) /*!< EMAC_T::INTSTS: CRCEIF Mask */ + +#define EMAC_INTSTS_RXOVIF_Pos (2) /*!< EMAC_T::INTSTS: RXOVIF Position */ +#define EMAC_INTSTS_RXOVIF_Msk (0x1ul << EMAC_INTSTS_RXOVIF_Pos) /*!< EMAC_T::INTSTS: RXOVIF Mask */ + +#define EMAC_INTSTS_LPIF_Pos (3) /*!< EMAC_T::INTSTS: LPIF Position */ +#define EMAC_INTSTS_LPIF_Msk (0x1ul << EMAC_INTSTS_LPIF_Pos) /*!< EMAC_T::INTSTS: LPIF Mask */ + +#define EMAC_INTSTS_RXGDIF_Pos (4) /*!< EMAC_T::INTSTS: RXGDIF Position */ +#define EMAC_INTSTS_RXGDIF_Msk (0x1ul << EMAC_INTSTS_RXGDIF_Pos) /*!< EMAC_T::INTSTS: RXGDIF Mask */ + +#define EMAC_INTSTS_ALIEIF_Pos (5) /*!< EMAC_T::INTSTS: ALIEIF Position */ +#define EMAC_INTSTS_ALIEIF_Msk (0x1ul << EMAC_INTSTS_ALIEIF_Pos) /*!< EMAC_T::INTSTS: ALIEIF Mask */ + +#define EMAC_INTSTS_RPIF_Pos (6) /*!< EMAC_T::INTSTS: RPIF Position */ +#define EMAC_INTSTS_RPIF_Msk (0x1ul << EMAC_INTSTS_RPIF_Pos) /*!< EMAC_T::INTSTS: RPIF Mask */ + +#define EMAC_INTSTS_MPCOVIF_Pos (7) /*!< EMAC_T::INTSTS: MPCOVIF Position */ +#define EMAC_INTSTS_MPCOVIF_Msk (0x1ul << EMAC_INTSTS_MPCOVIF_Pos) /*!< EMAC_T::INTSTS: MPCOVIF Mask */ + +#define EMAC_INTSTS_MFLEIF_Pos (8) /*!< EMAC_T::INTSTS: MFLEIF Position */ +#define EMAC_INTSTS_MFLEIF_Msk (0x1ul << EMAC_INTSTS_MFLEIF_Pos) /*!< EMAC_T::INTSTS: MFLEIF Mask */ + +#define EMAC_INTSTS_DENIF_Pos (9) /*!< EMAC_T::INTSTS: DENIF Position */ +#define EMAC_INTSTS_DENIF_Msk (0x1ul << EMAC_INTSTS_DENIF_Pos) /*!< EMAC_T::INTSTS: DENIF Mask */ + +#define EMAC_INTSTS_RDUIF_Pos (10) /*!< EMAC_T::INTSTS: RDUIF Position */ +#define EMAC_INTSTS_RDUIF_Msk (0x1ul << EMAC_INTSTS_RDUIF_Pos) /*!< EMAC_T::INTSTS: RDUIF Mask */ + +#define EMAC_INTSTS_RXBEIF_Pos (11) /*!< EMAC_T::INTSTS: RXBEIF Position */ +#define EMAC_INTSTS_RXBEIF_Msk (0x1ul << EMAC_INTSTS_RXBEIF_Pos) /*!< EMAC_T::INTSTS: RXBEIF Mask */ + +#define EMAC_INTSTS_CFRIF_Pos (14) /*!< EMAC_T::INTSTS: CFRIF Position */ +#define EMAC_INTSTS_CFRIF_Msk (0x1ul << EMAC_INTSTS_CFRIF_Pos) /*!< EMAC_T::INTSTS: CFRIF Mask */ + +#define EMAC_INTSTS_WOLIF_Pos (15) /*!< EMAC_T::INTSTS: WOLIF Position */ +#define EMAC_INTSTS_WOLIF_Msk (0x1ul << EMAC_INTSTS_WOLIF_Pos) /*!< EMAC_T::INTSTS: WOLIF Mask */ + +#define EMAC_INTSTS_TXIF_Pos (16) /*!< EMAC_T::INTSTS: TXIF Position */ +#define EMAC_INTSTS_TXIF_Msk (0x1ul << EMAC_INTSTS_TXIF_Pos) /*!< EMAC_T::INTSTS: TXIF Mask */ + +#define EMAC_INTSTS_TXUDIF_Pos (17) /*!< EMAC_T::INTSTS: TXUDIF Position */ +#define EMAC_INTSTS_TXUDIF_Msk (0x1ul << EMAC_INTSTS_TXUDIF_Pos) /*!< EMAC_T::INTSTS: TXUDIF Mask */ + +#define EMAC_INTSTS_TXCPIF_Pos (18) /*!< EMAC_T::INTSTS: TXCPIF Position */ +#define EMAC_INTSTS_TXCPIF_Msk (0x1ul << EMAC_INTSTS_TXCPIF_Pos) /*!< EMAC_T::INTSTS: TXCPIF Mask */ + +#define EMAC_INTSTS_EXDEFIF_Pos (19) /*!< EMAC_T::INTSTS: EXDEFIF Position */ +#define EMAC_INTSTS_EXDEFIF_Msk (0x1ul << EMAC_INTSTS_EXDEFIF_Pos) /*!< EMAC_T::INTSTS: EXDEFIF Mask */ + +#define EMAC_INTSTS_NCSIF_Pos (20) /*!< EMAC_T::INTSTS: NCSIF Position */ +#define EMAC_INTSTS_NCSIF_Msk (0x1ul << EMAC_INTSTS_NCSIF_Pos) /*!< EMAC_T::INTSTS: NCSIF Mask */ + +#define EMAC_INTSTS_TXABTIF_Pos (21) /*!< EMAC_T::INTSTS: TXABTIF Position */ +#define EMAC_INTSTS_TXABTIF_Msk (0x1ul << EMAC_INTSTS_TXABTIF_Pos) /*!< EMAC_T::INTSTS: TXABTIF Mask */ + +#define EMAC_INTSTS_LCIF_Pos (22) /*!< EMAC_T::INTSTS: LCIF Position */ +#define EMAC_INTSTS_LCIF_Msk (0x1ul << EMAC_INTSTS_LCIF_Pos) /*!< EMAC_T::INTSTS: LCIF Mask */ + +#define EMAC_INTSTS_TDUIF_Pos (23) /*!< EMAC_T::INTSTS: TDUIF Position */ +#define EMAC_INTSTS_TDUIF_Msk (0x1ul << EMAC_INTSTS_TDUIF_Pos) /*!< EMAC_T::INTSTS: TDUIF Mask */ + +#define EMAC_INTSTS_TXBEIF_Pos (24) /*!< EMAC_T::INTSTS: TXBEIF Position */ +#define EMAC_INTSTS_TXBEIF_Msk (0x1ul << EMAC_INTSTS_TXBEIF_Pos) /*!< EMAC_T::INTSTS: TXBEIF Mask */ + +#define EMAC_INTSTS_TSALMIF_Pos (28) /*!< EMAC_T::INTSTS: TSALMIF Position */ +#define EMAC_INTSTS_TSALMIF_Msk (0x1ul << EMAC_INTSTS_TSALMIF_Pos) /*!< EMAC_T::INTSTS: TSALMIF Mask */ + +#define EMAC_GENSTS_CFRIF_Pos (0) /*!< EMAC_T::GENSTS: CFRIF Position */ +#define EMAC_GENSTS_CFRIF_Msk (0x1ul << EMAC_GENSTS_CFRIF_Pos) /*!< EMAC_T::GENSTS: CFRIF Mask */ + +#define EMAC_GENSTS_RXHALT_Pos (1) /*!< EMAC_T::GENSTS: RXHALT Position */ +#define EMAC_GENSTS_RXHALT_Msk (0x1ul << EMAC_GENSTS_RXHALT_Pos) /*!< EMAC_T::GENSTS: RXHALT Mask */ + +#define EMAC_GENSTS_RXFFULL_Pos (2) /*!< EMAC_T::GENSTS: RXFFULL Position */ +#define EMAC_GENSTS_RXFFULL_Msk (0x1ul << EMAC_GENSTS_RXFFULL_Pos) /*!< EMAC_T::GENSTS: RXFFULL Mask */ + +#define EMAC_GENSTS_COLCNT_Pos (4) /*!< EMAC_T::GENSTS: COLCNT Position */ +#define EMAC_GENSTS_COLCNT_Msk (0xful << EMAC_GENSTS_COLCNT_Pos) /*!< EMAC_T::GENSTS: COLCNT Mask */ + +#define EMAC_GENSTS_DEF_Pos (8) /*!< EMAC_T::GENSTS: DEF Position */ +#define EMAC_GENSTS_DEF_Msk (0x1ul << EMAC_GENSTS_DEF_Pos) /*!< EMAC_T::GENSTS: DEF Mask */ + +#define EMAC_GENSTS_TXPAUSED_Pos (9) /*!< EMAC_T::GENSTS: TXPAUSED Position */ +#define EMAC_GENSTS_TXPAUSED_Msk (0x1ul << EMAC_GENSTS_TXPAUSED_Pos) /*!< EMAC_T::GENSTS: TXPAUSED Mask */ + +#define EMAC_GENSTS_SQE_Pos (10) /*!< EMAC_T::GENSTS: SQE Position */ +#define EMAC_GENSTS_SQE_Msk (0x1ul << EMAC_GENSTS_SQE_Pos) /*!< EMAC_T::GENSTS: SQE Mask */ + +#define EMAC_GENSTS_TXHALT_Pos (11) /*!< EMAC_T::GENSTS: TXHALT Position */ +#define EMAC_GENSTS_TXHALT_Msk (0x1ul << EMAC_GENSTS_TXHALT_Pos) /*!< EMAC_T::GENSTS: TXHALT Mask */ + +#define EMAC_GENSTS_RPSTS_Pos (12) /*!< EMAC_T::GENSTS: RPSTS Position */ +#define EMAC_GENSTS_RPSTS_Msk (0x1ul << EMAC_GENSTS_RPSTS_Pos) /*!< EMAC_T::GENSTS: RPSTS Mask */ + +#define EMAC_MPCNT_MPCNT_Pos (0) /*!< EMAC_T::MPCNT: MPCNT Position */ +#define EMAC_MPCNT_MPCNT_Msk (0xfffful << EMAC_MPCNT_MPCNT_Pos) /*!< EMAC_T::MPCNT: MPCNT Mask */ + +#define EMAC_RPCNT_RPCNT_Pos (0) /*!< EMAC_T::RPCNT: RPCNT Position */ +#define EMAC_RPCNT_RPCNT_Msk (0xfffful << EMAC_RPCNT_RPCNT_Pos) /*!< EMAC_T::RPCNT: RPCNT Mask */ + +#define EMAC_FRSTS_RXFLT_Pos (0) /*!< EMAC_T::FRSTS: RXFLT Position */ +#define EMAC_FRSTS_RXFLT_Msk (0xfffful << EMAC_FRSTS_RXFLT_Pos) /*!< EMAC_T::FRSTS: RXFLT Mask */ + +#define EMAC_CTXDSA_CTXDSA_Pos (0) /*!< EMAC_T::CTXDSA: CTXDSA Position */ +#define EMAC_CTXDSA_CTXDSA_Msk (0xfffffffful << EMAC_CTXDSA_CTXDSA_Pos) /*!< EMAC_T::CTXDSA: CTXDSA Mask */ + +#define EMAC_CTXBSA_CTXBSA_Pos (0) /*!< EMAC_T::CTXBSA: CTXBSA Position */ +#define EMAC_CTXBSA_CTXBSA_Msk (0xfffffffful << EMAC_CTXBSA_CTXBSA_Pos) /*!< EMAC_T::CTXBSA: CTXBSA Mask */ + +#define EMAC_CRXDSA_CRXDSA_Pos (0) /*!< EMAC_T::CRXDSA: CRXDSA Position */ +#define EMAC_CRXDSA_CRXDSA_Msk (0xfffffffful << EMAC_CRXDSA_CRXDSA_Pos) /*!< EMAC_T::CRXDSA: CRXDSA Mask */ + +#define EMAC_CRXBSA_CRXBSA_Pos (0) /*!< EMAC_T::CRXBSA: CRXBSA Position */ +#define EMAC_CRXBSA_CRXBSA_Msk (0xfffffffful << EMAC_CRXBSA_CRXBSA_Pos) /*!< EMAC_T::CRXBSA: CRXBSA Mask */ + +#define EMAC_TSCTL_TSEN_Pos (0) /*!< EMAC_T::TSCTL: TSEN Position */ +#define EMAC_TSCTL_TSEN_Msk (0x1ul << EMAC_TSCTL_TSEN_Pos) /*!< EMAC_T::TSCTL: TSEN Mask */ + +#define EMAC_TSCTL_TSIEN_Pos (1) /*!< EMAC_T::TSCTL: TSIEN Position */ +#define EMAC_TSCTL_TSIEN_Msk (0x1ul << EMAC_TSCTL_TSIEN_Pos) /*!< EMAC_T::TSCTL: TSIEN Mask */ + +#define EMAC_TSCTL_TSMODE_Pos (2) /*!< EMAC_T::TSCTL: TSMODE Position */ +#define EMAC_TSCTL_TSMODE_Msk (0x1ul << EMAC_TSCTL_TSMODE_Pos) /*!< EMAC_T::TSCTL: TSMODE Mask */ + +#define EMAC_TSCTL_TSUPDATE_Pos (3) /*!< EMAC_T::TSCTL: TSUPDATE Position */ +#define EMAC_TSCTL_TSUPDATE_Msk (0x1ul << EMAC_TSCTL_TSUPDATE_Pos) /*!< EMAC_T::TSCTL: TSUPDATE Mask */ + +#define EMAC_TSCTL_TSALMEN_Pos (5) /*!< EMAC_T::TSCTL: TSALMEN Position */ +#define EMAC_TSCTL_TSALMEN_Msk (0x1ul << EMAC_TSCTL_TSALMEN_Pos) /*!< EMAC_T::TSCTL: TSALMEN Mask */ + +#define EMAC_TSSEC_SEC_Pos (0) /*!< EMAC_T::TSSEC: SEC Position */ +#define EMAC_TSSEC_SEC_Msk (0xfffffffful << EMAC_TSSEC_SEC_Pos) /*!< EMAC_T::TSSEC: SEC Mask */ + +#define EMAC_TSSUBSEC_SUBSEC_Pos (0) /*!< EMAC_T::TSSUBSEC: SUBSEC Position */ +#define EMAC_TSSUBSEC_SUBSEC_Msk (0xfffffffful << EMAC_TSSUBSEC_SUBSEC_Pos) /*!< EMAC_T::TSSUBSEC: SUBSEC Mask */ + +#define EMAC_TSINC_CNTINC_Pos (0) /*!< EMAC_T::TSINC: CNTINC Position */ +#define EMAC_TSINC_CNTINC_Msk (0xfful << EMAC_TSINC_CNTINC_Pos) /*!< EMAC_T::TSINC: CNTINC Mask */ + +#define EMAC_TSADDEND_ADDEND_Pos (0) /*!< EMAC_T::TSADDEND: ADDEND Position */ +#define EMAC_TSADDEND_ADDEND_Msk (0xfffffffful << EMAC_TSADDEND_ADDEND_Pos) /*!< EMAC_T::TSADDEND: ADDEND Mask */ + +#define EMAC_UPDSEC_SEC_Pos (0) /*!< EMAC_T::UPDSEC: SEC Position */ +#define EMAC_UPDSEC_SEC_Msk (0xfffffffful << EMAC_UPDSEC_SEC_Pos) /*!< EMAC_T::UPDSEC: SEC Mask */ + +#define EMAC_UPDSUBSEC_SUBSEC_Pos (0) /*!< EMAC_T::UPDSUBSEC: SUBSEC Position */ +#define EMAC_UPDSUBSEC_SUBSEC_Msk (0xfffffffful << EMAC_UPDSUBSEC_SUBSEC_Pos) /*!< EMAC_T::UPDSUBSEC: SUBSEC Mask */ + +#define EMAC_ALMSEC_SEC_Pos (0) /*!< EMAC_T::ALMSEC: SEC Position */ +#define EMAC_ALMSEC_SEC_Msk (0xfffffffful << EMAC_ALMSEC_SEC_Pos) /*!< EMAC_T::ALMSEC: SEC Mask */ + +#define EMAC_ALMSUBSEC_SUBSEC_Pos (0) /*!< EMAC_T::ALMSUBSEC: SUBSEC Position */ +#define EMAC_ALMSUBSEC_SUBSEC_Msk (0xfffffffful << EMAC_ALMSUBSEC_SUBSEC_Pos) /*!< EMAC_T::ALMSUBSEC: SUBSEC Mask */ + +/**@}*/ /* EMAC_CONST */ +/**@}*/ /* end of EMAC register group */ + + +/*---------------------- Enhanced PWM Generator -------------------------*/ +/** + @addtogroup EPWM Enhanced PWM Generator(EPWM) + Memory Mapped Structure for EPWM Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 PWM Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |MODE |PWM Mode Selection + * | | |00 = Independent mode. + * | | |01 = Pair/Complementary mode. + * | | |10 = Synchronized mode. + * | | |11 = Reserved. + * |[2:3] |CLKDIV |PWM Clock Pre-Divider Selection + * | | |00 = PWM clock = EPWMx_CLK. + * | | |01 = PWM clock = EPWMx_CLK/2. + * | | |10 = PWM clock = EPWMx_CLK/4. + * | | |11 = PWM clock = EPWMx_CLK/16. + * |[4] |PWMIEN |PWM Interrupt Enable Control + * | | |0 = Disabling flag PIF to trigger PWM interrupt. + * | | |1 = Enabling flag PIF can trigger PWM interrupt. + * |[5] |BRKIEN |Brake0 And Brak1 Interrupt Enable Control + * | | |0 = Disabling flags BFK0 and BFK1 to trigger PWM interrupt. + * | | |1 = Enabling flags BRKIF0 and BRKIF1 can trigger PWM interrupt. + * |[6] |LOAD |Re-Load PWM Period Registers (EPWM_PERIOD) And PWM Duty Registers (PWM0~3) Control + * | | |0 = No action if written with 0. + * | | |The value of PWM period register (EPWM_PERIOD) and PWM duty registers (PWMn_CH0~PWMn_CH3) are not loaded to PWM counter and Comparator registers. + * | | |1 = Hardware will update the value of PWM period register (EPWM_PERIOD) and PWM duty registers (PWMn_CH0~PWMn_CH3) to PWM Counter and Comparator register at the time of PWM Counter matches PERIOD in edge and central aligned modes or at the time of PWM Counter down counts with underflow in central aligned mode. + * | | |Note1: n=0-1 for PWM unit0-1. + * | | |Note2: This bit is software write, hardware clear and always read zero. + * |[7] |CNTEN |Start CNTEN Control + * | | |0 = The PWM stops running. + * | | |1 = The PWM counter starts running. + * |[8] |INTTYPE |PWM Interrupt Type Selection + * | | |0 = PIF will be set if PWM counter underflow. + * | | |1 = PIF will be set if PWM counter matches EPWM_PERIOD register. + * | | |Note: This bit is effective when PWM in central align mode only. + * |[9] |PINV |Inverse PWM Comparator Output + * | | |When PINV is set to high the PWM comparator output signals will be inversed, therefore the PWM Duty (in percentage) is changed to (1-Duty) before PINV is set to high. + * | | |0 = Not inverse PWM comparator output. + * | | |1 = Inverse PWM comparator output. + * |[11] |CNTCLR |Clear PWM Counter Control + * | | |1 = Clear 16-bit PWM counter to 000H. + * | | |Note: It is automatically cleared by hardware. + * |[12] |CNTTYPE |PWM Aligned Type Selection + * | | |0 = Edge-aligned type. + * | | |1 = Centre-aligned type. + * |[13] |GROUPEN |Group Bit + * | | |0 = The signals timing of EPWM_CMPDAT0, EPWM_CMPDAT2 and EPWM_CMPDAT4 are independent. + * | | |1 = Unify the signals timing of EPWM_CMPDAT0, EPWM_CMPDAT2 and EPWM_CMPDAT4 in the same phase which is controlled by EPWM_CMPDAT0. + * |[14] |BRKP0INV |Inverse BKP0 State + * | | |0 = The state of pin BKPx0 is passed to the negative edge detector. + * | | |1 = The inversed state of pin BKPx0 is passed to the negative edge detector. + * |[15] |BRKP1INV |Inverse BKP1 State + * | | |0 = The state of pin BKPx1 is passed to the negative edge detector. + * | | |1 = The inversed state of pin BKPx1 is passed to the negative edge detector. + * |[16] |BRKP0EN |BKPx0 Pin Trigger Brake Function0 Enable Control + * | | |0 = PWMx Brake Function 0 Disabled. + * | | |1 = PWMx Brake Function 0 Enabled. + * | | |Note: x=0~1 for PWM unit0~1. + * |[17] |BRKP1EN |BKPx1 Pin Trigger Brake Function Enable Control + * | | |0 = PWMx Brake Function 1 Disabled. + * | | |1 = PWMx Brake Function 1 Enabled. + * | | |Note: x=0~1 for PWM unit0~1. + * |[18:19] |BRK1SEL |Brake Function 1 Source Selection + * | | |00 = From external pin BKPx1 (x=0~1 for unit0~1). + * | | |01 = From analog comparator 0 output (CPO0). + * | | |10 = From analog comparator 1 output (CPO1). + * | | |11 = From analog comparator 2 output (CPO2). + * |[20:21] |BRK0NFSEL |Brake 0 (BKPx0 Pin) Edge Detector Filter Clock Selection + * | | |00 = Filter clock = HCLK. + * | | |01 = Filter clock = HCLK/2. + * | | |10 = Filter clock = HCLK/4. + * | | |11 = Filter clock = HCLK/16. + * |[22:23] |BRK1NFSEL |Brake 1 (BKPx1 Pin) Edge Detector Filter Clock Selection + * | | |00 = Filter clock = HCLK. + * | | |01 =Filter clock = HCLK/2. + * | | |10 = Filter clock = HCLK/4. + * | | |11 = Filter clock = HCLK/16. + * |[24] |CPO0BKEN |CPO0 Digital Output As Brake0 Source Enable Control + * | | |1 = CPO0 as one brake source in Brake 0 Enabled. + * | | |0 = CPO0 as one brake source in Brake 0 Disabled. + * |[25] |CPO1BKEN |CPO1 Digital Output As Brake 0 Source Enable Control + * | | |0 = CPO1 as one brake source in Brake 0 Disabled. + * | | |1 = CPO1 as one brake source in Brake 0 Enabled. + * |[26] |CPO2BKEN |CPO2 Digital Output As Brake 0 Source Enable Control + * | | |0 = CPO2 as one brake source in Brake 0 Disabled. + * | | |1 = CPO2 as one brake source in Brake 0 Enabled. + * |[27] |LVDBKEN |Low-Level Detection Trigger PWM Brake Function 1 Enable Control + * | | |0 = Brake Function 1 triggered by Low-level detection Disabled. + * | | |1 = Brake Function 1 triggered by Low-level detection Enabled. + * |[28] |BRK0NFDIS |PWM Brake 0 Noise Filter Disable Control + * | | |0 = Noise filter of PWM Brake 0 Enabled. + * | | |1 = Noise filter of PWM Brake 0 Disabled. + * |[29] |BRK1NFDIS |PWM Brake 1 Noise Filter Disable Control + * | | |0 = Noise filter of PWM Brake 1 Enabled. + * | | |1 = Noise filter of PWM Brake 1 Disabled. + * |[31] |CTRLD |Center Reload Mode Enable Control + * | | |0 = EPWM reload duty register at the period point of PWM counter. + * | | |1 = EPWM reload duty register at the center point of PWM counter. + * | | |This bit only work when EPWM operation at center aligned mode. + */ + __IO uint32_t CTL; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x04 PWM Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BRKIF0 |PWM Brake0 Flag + * | | |0 = PWM Brake 0 is able to poll falling signal at BKP0 and has not recognized any one. + * | | |1 = When PWM Brake 0 detects a falling signal at BKP0, this flag will be set to high. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[1] |BRKIF1 |PWM Brake1 Flag + * | | |0 = PWM Brake 1 is able to poll falling signal at BKP1 and has not recognized any one. + * | | |1 = When PWM Brake 1 detects a falling signal at pin BKP1, this flag will be set to high. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[2] |PIF |PWM Period Flag + * | | |0 = PWM Counter has not up counted to the value of PERIOD or down counted with underflow. + * | | |1 = Hardware will set this flag to high at the time of PWM Counter matches PERIOD in edge and Centre aligned modes or at the time of PWM Counter down counts with underflow in Centre aligned mode. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[4] |EIF0 |PWMx0 Edge Flag + * | | |0 = The PWMx0 doesn't toggle. + * | | |1 = Hardware will set this flag to high at the time of PWMx0 rising or falling. + * | | |If EINTTYPE0 = 0, this bit is set when PWMx0 falling is detected. + * | | |If EINTTYPE0 = 1, this bit is set when PWMx0 rising is detected. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[5] |EIF2 |PWMx2 Edge Flag + * | | |0 = The PWMx2 doesn't toggle. + * | | |1 = Hardware will set this flag to high at the time of PWMx2 rising or falling. + * | | |If EINTTYPE2 = 0, this bit is set when PWMx2 falling is detected. + * | | |If EINTTYPE2 = 1, this bit is set when PWMx2 rising is detected. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[6] |EIF4 |PWMx4 Edge Flag + * | | |0 = The PWMx4 doesn't toggle. + * | | |1 = Hardware will set this flag to high at the time of PWMx4 rising or falling. + * | | |If EINTTYPE4 = 0, this bit is set when PWMx4 falling is detected. + * | | |If EINTTYPE4 = 1, this bit is set when PWMx4 rising is detected. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[8] |BRK0LOCK |PWM Brake0 Locked + * | | |0 = Brake 0 state is released. + * | | |1 = When PWM Brake detects a falling signal at BKP0, this flag will be set to high to indicate the Brake0 state is locked. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[24] |BRK0STS |Brake 0 Status (Read Only) + * | | |0 = PWM had been out of Brake 0 state. + * | | |1 = PWM is in Brake 0 state. + * |[25] |BRK1STS |Brake 1 Status (Read Only) + * | | |0 = PWM had been out of Brake 1 state. + * | | |1 = PWM is in Brake 1 state. + */ + __IO uint32_t STATUS; + + /** + * PERIOD + * =================================================================================================== + * Offset: 0x08 PWM Period Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |PERIOD |PWM Period Register + * | | |Edge aligned: + * | | |Period = (PERIOD + 1)* EPWMx_CLK period * pre-scalar. + * | | |Duty = (Duty +1 )* EPWMx_CLK period * pre-scalar. + * | | |Centre aligned: + * | | |Period = (PERIOD * 2)* EPWMx_CLK period * pre-scalar. + * | | |Duty = (Duty *2 + 1) * EPWMx_CLK period * pre-scalar. + */ + __IO uint32_t PERIOD; + + /** + * CMPDAT0 + * =================================================================================================== + * Offset: 0x0C EPWM_CMPDAT0 Duty Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |CMP |PWM Duty Register + * | | |Edge aligned: + * | | |Period = (PERIOD + 1)* EPWMx_CLK period * pre-scalar. + * | | |Duty = (Duty +1 )* EPWMx_CLK period * pre-scalar. + * | | |Centre aligned: + * | | |Period = (PERIOD * 2)* EPWMx_CLK period * pre-scalar. + * | | |Duty = (Duty *2 + 1) * EPWMx_CLK period * pre-scalar. + */ + __IO uint32_t CMPDAT[3]; + + /** + * MSKEN + * =================================================================================================== + * Offset: 0x18 PWM Mask Mode Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |MSKEN |PWM Mask Enable Control + * | | |The PWM generator signal will be masked when this bit is enabled. + * | | |The corresponding PWMn channel will be output with PMD.n data. + * | | |0 = PWM generator signal is output to next stage. + * | | |1 = PWM generator signal is masked and PMD.n is output to next stage. + * | | |Note: n = 0~5. + */ + __IO uint32_t MSKEN; + + /** + * MSK + * =================================================================================================== + * Offset: 0x1C PWM Mask Mode Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |MSKDAT |PWM Mask Data Bit + * | | |This data bit control the state of PWMn output pin, if the corresponding PME.n = 1. + * | | |0 = Output logic low to PWMn. + * | | |1 = Output logic high to PWMn. + * | | |Note: n = 0~5. + */ + __IO uint32_t MSK; + + /** + * ASYMCMP0 + * =================================================================================================== + * Offset: 0x20 Asymmetric EPWM_CMPDAT0 Duty Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |CMP |Asymmetric PWM Duty Register + * | | |When the asymmetric PWM function is enabled, this 16-bit field determines the second time compared value after PWM counter has matched with PWM_Duty in the first half PWM cycle. + */ + __IO uint32_t ASYMCMP0; + + /** + * ASYMCMP2 + * =================================================================================================== + * Offset: 0x24 Asymmetric EPWM_CMPDAT2 Duty Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |CMP |Asymmetric PWM Duty Register + * | | |When the asymmetric PWM function is enabled, this 16-bit field determines the second time compared value after PWM counter has matched with PWM_Duty in the first half PWM cycle. + */ + __IO uint32_t ASYMCMP2; + + /** + * ASYMCMP4 + * =================================================================================================== + * Offset: 0x28 Asymmetric EPWM_CMPDAT4 Duty Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |CMP |Asymmetric PWM Duty Register + * | | |When the asymmetric PWM function is enabled, this 16-bit field determines the second time compared value after PWM counter has matched with PWM_Duty in the first half PWM cycle. + */ + __IO uint32_t ASYMCMP4; + + /** + * DTCTL + * =================================================================================================== + * Offset: 0x2C PWM Dead-time Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:10] |DTCNT |Dead-Time Counter + * | | |The dead-time can be calculated from the following formula: + * | | |Dead-time = EPWMx_CLK period * (DTCNT.[10:0]+1). + * |[16] |DTEN0 |Dead-Time Insertion Enable Control For PWMx Pair (PWM0, PWM1) + * | | |Dead-time insertion is only active when this pair of complementary PWM is enabled. + * | | |If dead-time insertion is inactive, the outputs of pin pair are complementary without any delay. + * | | |0 = Dead-time insertion Disabled on the pin pair (PWM0, PWM1). + * | | |1 = Dead-time insertion Enabled on the pin pair (PWM0, PWM1). + * | | |Note: x=0~1 for PWM unit0~1. + * |[17] |DTEN2 |Dead-Time Insertion Enable Control For PWMx Pair (PWM2, PWM3) + * | | |Dead-time insertion is only active when this pair of complementary PWM is enabled. + * | | |If dead-time insertion is inactive, the outputs of pin pair are complementary without any delay. + * | | |0 = Dead-time insertion Disabled on the pin pair (PWM2, PWM3). + * | | |1 = Dead-time insertion Enabled on the pin pair (PWM2, PWM3). + * | | |Note: x=0~1 for PWM unit0~1. + * |[18] |DTEN4 |Dead-Time Insertion Enable Control For PWMx Pair (PWM4, PWM5) + * | | |Dead-time insertion is only active when this pair of complementary PWM is enabled. + * | | |If dead-time insertion is inactive, the outputs of pin pair are complementary without any delay. + * | | |0 = Dead-time insertion Disabled on the pin pair (PWM4, PWM5). + * | | |1 = Dead-time insertion Enabled on the pin pair (PWM4, PWM5). + * | | |Note: x=0~1 for PWM unit0~1. + */ + __IO uint32_t DTCTL; + + /** + * BRKOUT + * =================================================================================================== + * Offset: 0x30 PWM Brake Output + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |BRKOUT |PWM Brake Output + * | | |When PWM Brake is asserted, the PWM0~5 output state before polarity control will follow PWM1 bit0~5 setting, respectively. + * | | |0 = The PWMn output before polarity control is low when Brake is asserted. + * | | |1 = The PWMn output before polarity control is high when Brake is asserted. + * | | |Note: n = 0~5. + */ + __IO uint32_t BRKOUT; + + /** + * NPCTL + * =================================================================================================== + * Offset: 0x34 PWM Negative Polarity Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |NEGPOLAR |PWM Negative Polarity Control + * | | |The register bit controls polarity/active state of real PWM output. + * | | |0 = PWMn output is active high. + * | | |1 = PWMn output is active low. + * | | |Note: n = 0~5. + */ + __IO uint32_t NPCTL; + + /** + * ASYMCTL + * =================================================================================================== + * Offset: 0x38 Asymmetric PWM Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ASYMEN |Asymmetric PWM Enable Control + * | | |0 = Asymmetric PWM function Disabled. + * | | |1 = Asymmetric PWM function Enabled. + * | | |Note: This control bit is only valid when PWM module is set in Centre-aligned mode. + * |[8:9] |ASYMMODE0 |Asymmetric PWMx0 Reload Mode Setting + * | | |00 = 1. PWM compare register 0 is reload PWM_Duty (PWMx0[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 0 in up-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 0 is reloaded with CMP (ASPWMx0[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 0 in down-counting cycle. + * | | |01 = 1. PWM compare register 0 is reload PWM_Duty (PWMx0[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 0 in up-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 0 is reloaded with CMP (ASPWMx0[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 0 in up-counting cycle. + * | | | 5. PWMx0 must be less than ASPWMx0 + * | | |10 = 1. PWM compare register 0 is reload PWM_Duty (PWMx0[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 0 in down-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 0 is reloaded with CMP (ASPWMx0[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 0 in down-counting cycle. + * | | | 5. PWMx0 must be greater than ASPWMx0. + * | | |11 = Reserved. + * | | |Note1: x=0~1 for PWM unit 0~1. + * | | |Note2: This bit field is available only when ASYMEN=1. + * | | |Note3: The setting will be effected at the condition of LOAD=1 and from the start of next PWM cycle. + * |[16:17] |ASYMMODE2 |Asymmetric PWMx2 Reload Mode Setting + * | | |00 = 1. PWM compare register 2 is reload PWM_Duty (PWMx2[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 2 in up-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 2 is reloaded with CMP (ASPWMx2[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 2 in down-counting cycle. + * | | |01 = 1. PWM compare register 2 is reload PWM_Duty (PWMx2[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 2 in up-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register2 is reloaded with CMP (ASPWMx2[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 2 in up-counting cycle. + * | | | 5. PWMx2 must be less than ASPWMx2 + * | | |10 = 1. PWM compare register 2 is reload PWM_Duty (PWMx2[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 2 in down-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 2 is reloaded with CMP (ASPWMx2[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 2 in down-counting cycle. + * | | | 5. PWMx2 must be greater than ASPWMx2. + * | | |11 = Reserved. + * | | |Note1: x=0~1 for PWM unit 0~1. + * | | |Note2: This bit field is available only when ASYMEN=1. + * | | |Note3: The setting will be effected at the condition of LOAD=1 and from the start of next PWM cycle. + * |[24:25] |ASYMMODE4 |Asymmetric PWMx4 Reload Mode Setting + * | | |00 = 1. PWM compare register 4 is reload PWM_Duty (PWMx4[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 4 in up-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 4 is reloaded with CMP (ASPWMx4[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 4 in down-counting cycle. + * | | |01 = 1. PWM compare register 4 is reload PWM_Duty (PWMx4[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 4 in up-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 0 is reloaded with CMP (ASPWMx4[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 4 in up-counting cycle. + * | | | 5. PWMx4 must be less than ASPWMx4. + * | | |10 = 1. PWM compare register 4 is reload PWM_Duty (PWMx4[15:0]) at PWM cycle start. + * | | | 2. PWM module compares the PWM counter (PWMCNT) with PWM compare register 4 in down-counting cycle + * | | |3. + * | | |PWM compare output toggles at compare match, in the meanwhile, PWM compare register 4 is reloaded with CMP (ASPWMx4[15:00]). + * | | | 4. PWM module compares the PWM counter (PWMCNT) with PWM compare register 4 in down-counting cycle. + * | | | 5. PWMx4 must be greater than ASPWMx4. + * | | |11= Reserved. + * | | |Note1: x=0~1 for PWM unit 0~1. + * | | |Note2: This bit field is available only when ASYMEN=1. + * | | |Note3: The setting will be effected at the condition of LOAD=1 and from the start of next PWM cycle. + */ + __IO uint32_t ASYMCTL; + + /** + * PERIODCNT + * =================================================================================================== + * Offset: 0x3C PIF Compared Counter + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PERIODCNT |PIF Compared Counter + * | | |The register sets the count number which defines how many times of PWM period occurs to set bit PIF to request the PWM period interrupt. + * | | |PIF will be set in every (1 + PERIODCNT[3:0]) times of PWM period or center point defined by INTTYPE when EPWM_CTL [8] occurred. + */ + __IO uint32_t PERIODCNT; + + /** + * EINTCTL + * =================================================================================================== + * Offset: 0x40 PWM Edge Interrupt Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EDGEIEN0 |PWMx0 Edge Interrupt Enable Control + * | | |0 = Disabling flag EIF0 to trigger PWM interrupt. + * | | |1 = Enabling flag EIF0 can trigger PWM interrupt. + * |[1] |EDGEIEN2 |PWMx2 Edge Interrupt Enable Control + * | | |0 = Disabling flag EIF2 can trigger PWM interrupt. + * | | |1 = Enabling flag EIF2 can trigger PWM interrupt. + * |[2] |EDGEIEN4 |PWMx4 Edge Interrupt Enable Control + * | | |0 = Disable flag EIF4 to trigger PWM interrupt. + * | | |1 = Enabling flag EIF4 can trigger PWM interrupt. + * |[8] |EINTTYPE0 |PWMx0 Edge Interrupt Type + * | | |0 = EIF0 will be set if falling edge is detected at PWMx0. + * | | |1 = EIF0 will be set if rising edge is detected at PWMx0. + * |[9] |EINTTYPE2 |PWMx2 Edge Interrupt Type + * | | |0 = EIF2 will be set if falling edge is detected at PWMx2. + * | | |1 = EIF2 will be set if rising edge is detected at PWMx2. + * |[10] |EINTTYPE4 |PWMx4 Edge Interrupt Type + * | | |0 = EIF4 will be set if falling edge is detected at PWMx4. + * | | |1 = EIF4 will be set if rising edge is detected at PWMx4. + */ + __IO uint32_t EINTCTL; + + /** + * OUTEN0 + * =================================================================================================== + * Offset: 0x44 PWM Output Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EVENOUTEN |PWM Even Ports Output Enable Control + * | | |0 = PWM even ports output Disabled (PWM even ports at tri-state). + * | | |1 = PWM even ports output Enabled. + * |[1] |ODDOUTEN |PWM Odd Ports Output Enable Control + * | | |0 = PWM odd ports output Disabled (PWM even ports at tri-state). + * | | |1 = PWM odd ports output Enabled. + */ + __IO uint32_t OUTEN0; + +} EPWM_T; + +/** + @addtogroup EPWM_CONST EPWM Bit Field Definition + Constant Definitions for EPWM Controller +@{ */ + +#define EPWM_CTL_MODE_Pos (0) /*!< EPWM_T::CTL: MODE Position */ +#define EPWM_CTL_MODE_Msk (0x3ul << EPWM_CTL_MODE_Pos) /*!< EPWM_T::CTL: MODE Mask */ + +#define EPWM_CTL_CLKDIV_Pos (2) /*!< EPWM_T::CTL: CLKDIV Position */ +#define EPWM_CTL_CLKDIV_Msk (0x3ul << EPWM_CTL_CLKDIV_Pos) /*!< EPWM_T::CTL: CLKDIV Mask */ + +#define EPWM_CTL_PWMIEN_Pos (4) /*!< EPWM_T::CTL: PWMIEN Position */ +#define EPWM_CTL_PWMIEN_Msk (0x1ul << EPWM_CTL_PWMIEN_Pos) /*!< EPWM_T::CTL: PWMIEN Mask */ + +#define EPWM_CTL_BRKIEN_Pos (5) /*!< EPWM_T::CTL: BRKIEN Position */ +#define EPWM_CTL_BRKIEN_Msk (0x1ul << EPWM_CTL_BRKIEN_Pos) /*!< EPWM_T::CTL: BRKIEN Mask */ + +#define EPWM_CTL_LOAD_Pos (6) /*!< EPWM_T::CTL: LOAD Position */ +#define EPWM_CTL_LOAD_Msk (0x1ul << EPWM_CTL_LOAD_Pos) /*!< EPWM_T::CTL: LOAD Mask */ + +#define EPWM_CTL_CNTEN_Pos (7) /*!< EPWM_T::CTL: CNTEN Position */ +#define EPWM_CTL_CNTEN_Msk (0x1ul << EPWM_CTL_CNTEN_Pos) /*!< EPWM_T::CTL: CNTEN Mask */ + +#define EPWM_CTL_INTTYPE_Pos (8) /*!< EPWM_T::CTL: INTTYPE Position */ +#define EPWM_CTL_INTTYPE_Msk (0x1ul << EPWM_CTL_INTTYPE_Pos) /*!< EPWM_T::CTL: INTTYPE Mask */ + +#define EPWM_CTL_PINV_Pos (9) /*!< EPWM_T::CTL: PINV Position */ +#define EPWM_CTL_PINV_Msk (0x1ul << EPWM_CTL_PINV_Pos) /*!< EPWM_T::CTL: PINV Mask */ + +#define EPWM_CTL_CNTCLR_Pos (11) /*!< EPWM_T::CTL: CNTCLR Position */ +#define EPWM_CTL_CNTCLR_Msk (0x1ul << EPWM_CTL_CNTCLR_Pos) /*!< EPWM_T::CTL: CNTCLR Mask */ + +#define EPWM_CTL_CNTTYPE_Pos (12) /*!< EPWM_T::CTL: CNTTYPE Position */ +#define EPWM_CTL_CNTTYPE_Msk (0x1ul << EPWM_CTL_CNTTYPE_Pos) /*!< EPWM_T::CTL: CNTTYPE Mask */ + +#define EPWM_CTL_GROUPEN_Pos (13) /*!< EPWM_T::CTL: GROUPEN Position */ +#define EPWM_CTL_GROUPEN_Msk (0x1ul << EPWM_CTL_GROUPEN_Pos) /*!< EPWM_T::CTL: GROUPEN Mask */ + +#define EPWM_CTL_BRKP0INV_Pos (14) /*!< EPWM_T::CTL: BRKP0INV Position */ +#define EPWM_CTL_BRKP0INV_Msk (0x1ul << EPWM_CTL_BRKP0INV_Pos) /*!< EPWM_T::CTL: BRKP0INV Mask */ + +#define EPWM_CTL_BRKP1INV_Pos (15) /*!< EPWM_T::CTL: BRKP1INV Position */ +#define EPWM_CTL_BRKP1INV_Msk (0x1ul << EPWM_CTL_BRKP1INV_Pos) /*!< EPWM_T::CTL: BRKP1INV Mask */ + +#define EPWM_CTL_BRKP0EN_Pos (16) /*!< EPWM_T::CTL: BRKP0EN Position */ +#define EPWM_CTL_BRKP0EN_Msk (0x1ul << EPWM_CTL_BRKP0EN_Pos) /*!< EPWM_T::CTL: BRKP0EN Mask */ + +#define EPWM_CTL_BRKP1EN_Pos (17) /*!< EPWM_T::CTL: BRKP1EN Position */ +#define EPWM_CTL_BRKP1EN_Msk (0x1ul << EPWM_CTL_BRKP1EN_Pos) /*!< EPWM_T::CTL: BRKP1EN Mask */ + +#define EPWM_CTL_BRK1SEL_Pos (18) /*!< EPWM_T::CTL: BRK1SEL Position */ +#define EPWM_CTL_BRK1SEL_Msk (0x3ul << EPWM_CTL_BRK1SEL_Pos) /*!< EPWM_T::CTL: BRK1SEL Mask */ + +#define EPWM_CTL_BRK0NFSEL_Pos (20) /*!< EPWM_T::CTL: BRK0NFSEL Position */ +#define EPWM_CTL_BRK0NFSEL_Msk (0x3ul << EPWM_CTL_BRK0NFSEL_Pos) /*!< EPWM_T::CTL: BRK0NFSEL Mask */ + +#define EPWM_CTL_BRK1NFSEL_Pos (22) /*!< EPWM_T::CTL: BRK1NFSEL Position */ +#define EPWM_CTL_BRK1NFSEL_Msk (0x3ul << EPWM_CTL_BRK1NFSEL_Pos) /*!< EPWM_T::CTL: BRK1NFSEL Mask */ + +#define EPWM_CTL_CPO0BKEN_Pos (24) /*!< EPWM_T::CTL: CPO0BKEN Position */ +#define EPWM_CTL_CPO0BKEN_Msk (0x1ul << EPWM_CTL_CPO0BKEN_Pos) /*!< EPWM_T::CTL: CPO0BKEN Mask */ + +#define EPWM_CTL_CPO1BKEN_Pos (25) /*!< EPWM_T::CTL: CPO1BKEN Position */ +#define EPWM_CTL_CPO1BKEN_Msk (0x1ul << EPWM_CTL_CPO1BKEN_Pos) /*!< EPWM_T::CTL: CPO1BKEN Mask */ + +#define EPWM_CTL_CPO2BKEN_Pos (26) /*!< EPWM_T::CTL: CPO2BKEN Position */ +#define EPWM_CTL_CPO2BKEN_Msk (0x1ul << EPWM_CTL_CPO2BKEN_Pos) /*!< EPWM_T::CTL: CPO2BKEN Mask */ + +#define EPWM_CTL_LVDBKEN_Pos (27) /*!< EPWM_T::CTL: LVDBKEN Position */ +#define EPWM_CTL_LVDBKEN_Msk (0x1ul << EPWM_CTL_LVDBKEN_Pos) /*!< EPWM_T::CTL: LVDBKEN Mask */ + +#define EPWM_CTL_BRK0NFDIS_Pos (28) /*!< EPWM_T::CTL: BRK0NFDIS Position */ +#define EPWM_CTL_BRK0NFDIS_Msk (0x1ul << EPWM_CTL_BRK0NFDIS_Pos) /*!< EPWM_T::CTL: BRK0NFDIS Mask */ + +#define EPWM_CTL_BRK1NFDIS_Pos (29) /*!< EPWM_T::CTL: BRK1NFDIS Position */ +#define EPWM_CTL_BRK1NFDIS_Msk (0x1ul << EPWM_CTL_BRK1NFDIS_Pos) /*!< EPWM_T::CTL: BRK1NFDIS Mask */ + +#define EPWM_CTL_CTRLD_Pos (31) /*!< EPWM_T::CTL: CTRLD Position */ +#define EPWM_CTL_CTRLD_Msk (0x1ul << EPWM_CTL_CTRLD_Pos) /*!< EPWM_T::CTL: CTRLD Mask */ + +#define EPWM_STATUS_BRKIF0_Pos (0) /*!< EPWM_T::STATUS: BRKIF0 Position */ +#define EPWM_STATUS_BRKIF0_Msk (0x1ul << EPWM_STATUS_BRKIF0_Pos) /*!< EPWM_T::STATUS: BRKIF0 Mask */ + +#define EPWM_STATUS_BRKIF1_Pos (1) /*!< EPWM_T::STATUS: BRKIF1 Position */ +#define EPWM_STATUS_BRKIF1_Msk (0x1ul << EPWM_STATUS_BRKIF1_Pos) /*!< EPWM_T::STATUS: BRKIF1 Mask */ + +#define EPWM_STATUS_PIF_Pos (2) /*!< EPWM_T::STATUS: PIF Position */ +#define EPWM_STATUS_PIF_Msk (0x1ul << EPWM_STATUS_PIF_Pos) /*!< EPWM_T::STATUS: PIF Mask */ + +#define EPWM_STATUS_EIF0_Pos (4) /*!< EPWM_T::STATUS: EIF0 Position */ +#define EPWM_STATUS_EIF0_Msk (0x1ul << EPWM_STATUS_EIF0_Pos) /*!< EPWM_T::STATUS: EIF0 Mask */ + +#define EPWM_STATUS_EIF2_Pos (5) /*!< EPWM_T::STATUS: EIF2 Position */ +#define EPWM_STATUS_EIF2_Msk (0x1ul << EPWM_STATUS_EIF2_Pos) /*!< EPWM_T::STATUS: EIF2 Mask */ + +#define EPWM_STATUS_EIF4_Pos (6) /*!< EPWM_T::STATUS: EIF4 Position */ +#define EPWM_STATUS_EIF4_Msk (0x1ul << EPWM_STATUS_EIF4_Pos) /*!< EPWM_T::STATUS: EIF4 Mask */ + +#define EPWM_STATUS_BRK0LOCK_Pos (8) /*!< EPWM_T::STATUS: BRK0LOCK Position */ +#define EPWM_STATUS_BRK0LOCK_Msk (0x1ul << EPWM_STATUS_BRK0LOCK_Pos) /*!< EPWM_T::STATUS: BRK0LOCK Mask */ + +#define EPWM_STATUS_BRK0STS_Pos (24) /*!< EPWM_T::STATUS: BRK0STS Position */ +#define EPWM_STATUS_BRK0STS_Msk (0x1ul << EPWM_STATUS_BRK0STS_Pos) /*!< EPWM_T::STATUS: BRK0STS Mask */ + +#define EPWM_STATUS_BRK1STS_Pos (25) /*!< EPWM_T::STATUS: BRK1STS Position */ +#define EPWM_STATUS_BRK1STS_Msk (0x1ul << EPWM_STATUS_BRK1STS_Pos) /*!< EPWM_T::STATUS: BRK1STS Mask */ + +#define EPWM_PERIOD_PERIOD_Pos (0) /*!< EPWM_T::PERIOD: PERIOD Position */ +#define EPWM_PERIOD_PERIOD_Msk (0xfffful << EPWM_PERIOD_PERIOD_Pos) /*!< EPWM_T::PERIOD: PERIOD Mask */ + +#define EPWM_CMPDAT0_CMP_Pos (0) /*!< EPWM_T::CMPDAT0: CMP Position */ +#define EPWM_CMPDAT0_CMP_Msk (0xfffful << EPWM_CMPDAT0_CMP_Pos) /*!< EPWM_T::CMPDAT0: CMP Mask */ + +#define EPWM_CMPDAT2_CMP_Pos (0) /*!< EPWM_T::CMPDAT2: CMP Position */ +#define EPWM_CMPDAT2_CMP_Msk (0xfffful << EPWM_CMPDAT2_CMP_Pos) /*!< EPWM_T::CMPDAT2: CMP Mask */ + +#define EPWM_CMPDAT4_CMP_Pos (0) /*!< EPWM_T::CMPDAT4: CMP Position */ +#define EPWM_CMPDAT4_CMP_Msk (0xfffful << EPWM_CMPDAT4_CMP_Pos) /*!< EPWM_T::CMPDAT4: CMP Mask */ + +#define EPWM_MSKEN_MSKEN_Pos (0) /*!< EPWM_T::MSKEN: MSKEN Position */ +#define EPWM_MSKEN_MSKEN_Msk (0x3ful << EPWM_MSKEN_MSKEN_Pos) /*!< EPWM_T::MSKEN: MSKEN Mask */ + +#define EPWM_MSK_MSKDAT_Pos (0) /*!< EPWM_T::MSK: MSKDAT Position */ +#define EPWM_MSK_MSKDAT_Msk (0x3ful << EPWM_MSK_MSKDAT_Pos) /*!< EPWM_T::MSK: MSKDAT Mask */ + +#define EPWM_ASYMCMP0_CMP_Pos (0) /*!< EPWM_T::ASYMCMP0: CMP Position */ +#define EPWM_ASYMCMP0_CMP_Msk (0xfffful << EPWM_ASYMCMP0_CMP_Pos) /*!< EPWM_T::ASYMCMP0: CMP Mask */ + +#define EPWM_ASYMCMP2_CMP_Pos (0) /*!< EPWM_T::ASYMCMP2: CMP Position */ +#define EPWM_ASYMCMP2_CMP_Msk (0xfffful << EPWM_ASYMCMP2_CMP_Pos) /*!< EPWM_T::ASYMCMP2: CMP Mask */ + +#define EPWM_ASYMCMP4_CMP_Pos (0) /*!< EPWM_T::ASYMCMP4: CMP Position */ +#define EPWM_ASYMCMP4_CMP_Msk (0xfffful << EPWM_ASYMCMP4_CMP_Pos) /*!< EPWM_T::ASYMCMP4: CMP Mask */ + +#define EPWM_DTCTL_DTCNT_Pos (0) /*!< EPWM_T::DTCTL: DTCNT Position */ +#define EPWM_DTCTL_DTCNT_Msk (0x7fful << EPWM_DTCTL_DTCNT_Pos) /*!< EPWM_T::DTCTL: DTCNT Mask */ + +#define EPWM_DTCTL_DTEN0_Pos (16) /*!< EPWM_T::DTCTL: DTEN0 Position */ +#define EPWM_DTCTL_DTEN0_Msk (0x1ul << EPWM_DTCTL_DTEN0_Pos) /*!< EPWM_T::DTCTL: DTEN0 Mask */ + +#define EPWM_DTCTL_DTEN2_Pos (17) /*!< EPWM_T::DTCTL: DTEN2 Position */ +#define EPWM_DTCTL_DTEN2_Msk (0x1ul << EPWM_DTCTL_DTEN2_Pos) /*!< EPWM_T::DTCTL: DTEN2 Mask */ + +#define EPWM_DTCTL_DTEN4_Pos (18) /*!< EPWM_T::DTCTL: DTEN4 Position */ +#define EPWM_DTCTL_DTEN4_Msk (0x1ul << EPWM_DTCTL_DTEN4_Pos) /*!< EPWM_T::DTCTL: DTEN4 Mask */ + +#define EPWM_BRKOUT_BRKOUT_Pos (0) /*!< EPWM_T::BRKOUT: BRKOUT Position */ +#define EPWM_BRKOUT_BRKOUT_Msk (0x3ful << EPWM_BRKOUT_BRKOUT_Pos) /*!< EPWM_T::BRKOUT: BRKOUT Mask */ + +#define EPWM_NPCTL_NEGPOLAR_Pos (0) /*!< EPWM_T::NPCTL: NEGPOLAR Position */ +#define EPWM_NPCTL_NEGPOLAR_Msk (0x3ful << EPWM_NPCTL_NEGPOLAR_Pos) /*!< EPWM_T::NPCTL: NEGPOLAR Mask */ + +#define EPWM_ASYMCTL_ASYMEN_Pos (0) /*!< EPWM_T::ASYMCTL: ASYMEN Position */ +#define EPWM_ASYMCTL_ASYMEN_Msk (0x1ul << EPWM_ASYMCTL_ASYMEN_Pos) /*!< EPWM_T::ASYMCTL: ASYMEN Mask */ + +#define EPWM_ASYMCTL_ASYMMODE0_Pos (8) /*!< EPWM_T::ASYMCTL: ASYMMODE0 Position */ +#define EPWM_ASYMCTL_ASYMMODE0_Msk (0x3ul << EPWM_ASYMCTL_ASYMMODE0_Pos) /*!< EPWM_T::ASYMCTL: ASYMMODE0 Mask */ + +#define EPWM_ASYMCTL_ASYMMODE2_Pos (16) /*!< EPWM_T::ASYMCTL: ASYMMODE2 Position */ +#define EPWM_ASYMCTL_ASYMMODE2_Msk (0x3ul << EPWM_ASYMCTL_ASYMMODE2_Pos) /*!< EPWM_T::ASYMCTL: ASYMMODE2 Mask */ + +#define EPWM_ASYMCTL_ASYMMODE4_Pos (24) /*!< EPWM_T::ASYMCTL: ASYMMODE4 Position */ +#define EPWM_ASYMCTL_ASYMMODE4_Msk (0x3ul << EPWM_ASYMCTL_ASYMMODE4_Pos) /*!< EPWM_T::ASYMCTL: ASYMMODE4 Mask */ + +#define EPWM_PERIODCNT_PERIODCNT_Pos (0) /*!< EPWM_T::PERIODCNT: PERIODCNT Position */ +#define EPWM_PERIODCNT_PERIODCNT_Msk (0xful << EPWM_PERIODCNT_PERIODCNT_Pos) /*!< EPWM_T::PERIODCNT: PERIODCNT Mask */ + +#define EPWM_EINTCTL_EDGEIEN0_Pos (0) /*!< EPWM_T::EINTCTL: EDGEIEN0 Position */ +#define EPWM_EINTCTL_EDGEIEN0_Msk (0x1ul << EPWM_EINTCTL_EDGEIEN0_Pos) /*!< EPWM_T::EINTCTL: EDGEIEN0 Mask */ + +#define EPWM_EINTCTL_EDGEIEN2_Pos (1) /*!< EPWM_T::EINTCTL: EDGEIEN2 Position */ +#define EPWM_EINTCTL_EDGEIEN2_Msk (0x1ul << EPWM_EINTCTL_EDGEIEN2_Pos) /*!< EPWM_T::EINTCTL: EDGEIEN2 Mask */ + +#define EPWM_EINTCTL_EDGEIEN4_Pos (2) /*!< EPWM_T::EINTCTL: EDGEIEN4 Position */ +#define EPWM_EINTCTL_EDGEIEN4_Msk (0x1ul << EPWM_EINTCTL_EDGEIEN4_Pos) /*!< EPWM_T::EINTCTL: EDGEIEN4 Mask */ + +#define EPWM_EINTCTL_EINTTYPE0_Pos (8) /*!< EPWM_T::EINTCTL: EINTTYPE0 Position */ +#define EPWM_EINTCTL_EINTTYPE0_Msk (0x1ul << EPWM_EINTCTL_EINTTYPE0_Pos) /*!< EPWM_T::EINTCTL: EINTTYPE0 Mask */ + +#define EPWM_EINTCTL_EINTTYPE2_Pos (9) /*!< EPWM_T::EINTCTL: EINTTYPE2 Position */ +#define EPWM_EINTCTL_EINTTYPE2_Msk (0x1ul << EPWM_EINTCTL_EINTTYPE2_Pos) /*!< EPWM_T::EINTCTL: EINTTYPE2 Mask */ + +#define EPWM_EINTCTL_EINTTYPE4_Pos (10) /*!< EPWM_T::EINTCTL: EINTTYPE4 Position */ +#define EPWM_EINTCTL_EINTTYPE4_Msk (0x1ul << EPWM_EINTCTL_EINTTYPE4_Pos) /*!< EPWM_T::EINTCTL: EINTTYPE4 Mask */ + +#define EPWM_OUTEN0_EVENOUTEN_Pos (0) /*!< EPWM_T::OUTEN0: EVENOUTEN Position */ +#define EPWM_OUTEN0_EVENOUTEN_Msk (0x1ul << EPWM_OUTEN0_EVENOUTEN_Pos) /*!< EPWM_T::OUTEN0: EVENOUTEN Mask */ + +#define EPWM_OUTEN0_ODDOUTEN_Pos (1) /*!< EPWM_T::OUTEN0: ODDOUTEN Position */ +#define EPWM_OUTEN0_ODDOUTEN_Msk (0x1ul << EPWM_OUTEN0_ODDOUTEN_Pos) /*!< EPWM_T::OUTEN0: ODDOUTEN Mask */ + +/**@}*/ /* EPWM_CONST */ +/**@}*/ /* end of EPWM register group */ + + +/*---------------------- Flash Memory Controller -------------------------*/ +/** + @addtogroup FMC Flash Memory Controller(FMC) + Memory Mapped Structure for FMC Controller +@{ */ + +typedef struct { + /** + * ISPCTL + * =================================================================================================== + * Offset: 0x00 ISP Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ISPEN |ISP Enable Control (Write Protect) + * | | |ISP function enable bit. Set this bit to enable ISP function. + * | | |0 = ISP function Disabled. + * | | |1 = ISP function Enabled. + * |[1] |BS |Boot Select (Write Protect) + * | | |Set/clear this bit to select next booting from LDROM/APROM, respectively. + * | | |This bit also functions as chip booting status flag, which can be used to check where chip booted from. + * | | |This bit is initiated with the inversed value of CBS in Config0 after any reset is happened except CPU reset (RSTS_CPU is 1) or system reset (RSTS_SYS) is happened. + * | | |0 = Boot from APROM. + * | | |1 = Boot from LDROM. + * |[3] |APUEN |APROM Update Enable Control (Write Protect) + * | | |0 = APROM cannot be updated when the chip runs in APROM. + * | | |1 = APROM can be updated when the chip runs in APROM. + * |[4] |CFGUEN |Config-Bits Update By ISP (Write Protect) Enable Control + * | | |0 = ISP Disabled to update config-bits. + * | | |1 = ISP Enabled to update config-bits at KEYMATCH flag active (bit7 of ISPSTS). + * | | |Note: This bit is fixed to 0 in Secure mode. + * |[5] |LDUEN |LDROM Update Enable Control (Write Protect) + * | | |LDROM update enable bit. + * | | |0 = LDROM cannot be updated. + * | | |1 = LDROM can be updated at KEYMATCH flag active (bit7 of ISPSTS). + * | | |Note: This bit is fixed to 0 in Secure mode. + * |[6] |ISPFF |ISP Fail Flag (Write Protect) + * | | |This bit is set by hardware when a triggered ISP meets any of the following conditions: + * | | |(1) APROM writes to itself if APUEN is set to 0. + * | | |(2) LDROM writes to itself if LDUEN is set to 0. + * | | |(3) CONFIG is erased/programmed if CFGUEN is set to 0. + * | | |(4) Destination address is illegal, such as over an available range. + * | | |Note: This bit needs to be cleared by writing 1 to it. + */ + __IO uint32_t ISPCTL; + + /** + * ISPADDR + * =================================================================================================== + * Offset: 0x04 ISP Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ISPADR |ISP Address + * | | |The NUC442/NUC472 series is equipped with an embedded flash and supports word program only. + * | | |ISPADR[1:0] must be kept 00b for ISP operation. + */ + __IO uint32_t ISPADDR; + + /** + * ISPDAT + * =================================================================================================== + * Offset: 0x08 ISP Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ISPDAT |ISP Data + * | | |Write data to this register before ISP program operation. + * | | |Read data from this register after ISP read operation. + */ + __IO uint32_t ISPDAT; + + /** + * ISPCMD + * =================================================================================================== + * Offset: 0x0C ISP Command Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |CMD |ISP Command + * | | |Please check the table below for ISP commands. + */ + __IO uint32_t ISPCMD; + + /** + * ISPTRG + * =================================================================================================== + * Offset: 0x10 ISP Trigger Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ISPGO |ISP Start Trigger + * | | |Write 1 to start ISP operation and this bit will be cleared to 0 by hardware automatically when ISP operation is finished. + * | | |0 = ISP operation is finished. + * | | |1 = ISP is progressed. + * | | |This bit is the protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + */ + __IO uint32_t ISPTRG; + + /** + * DFBA + * =================================================================================================== + * Offset: 0x14 Data Flash Base Address + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DFBA |Data Flash Base Address + * | | |This register indicates data flash start address. It is a read only register. + * | | |The data flash is shared with APROM and data flash size is defined by user configuration and the content of this register is loaded from Config1. + */ + __I uint32_t DFBA; + + /** + * FTCTL + * =================================================================================================== + * Offset: 0x18 Flash Access Time Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[4:6] |FOM |Frequency Optimization Mode (Write Protect) + * | | |When chip operation frequency is lower, chip can work more efficiently by setting FOM bits + * | | |FOM[2:0] + * | | |Optimized Frequency (OF) + * | | |001 + * | | |0 MHz < OF <= 24 MHz + * | | |010 + * | | |24 MHz < OF <= 48 MHz + * | | |011 + * | | |48 MHz < OF <= 72 MHz + * | | |others + * | | |Reserved + */ + __IO uint32_t FTCTL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[9]; + /// @endcond //HIDDEN_SYMBOLS + + /** + * ISPSTS + * =================================================================================================== + * Offset: 0x40 Flash Access Time Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ISPBUSY |ISP busy flag + * | | |0 = ISP operation is finished. + * | | |1 = ISP is progressed. + * |[2:1] |CBS |Chip boot selection mode + * | | |This CBS field is just a copy of User-Configuration Config0 CBS[7:6]. + * |[6] |ISPFF |ISP Fail Flag (Write Protect) + * | | |This bit is set by hardware when a triggered ISP meets any of the following conditions: + * | | |(1) APROM writes to itself if APUEN is set to 0. + * | | |(2) LDROM writes to itself if LDUEN is set to 0. + * | | |(3) CONFIG is erased/programmed if CFGUEN is set to 0. + * | | |(4) Destination address is illegal, such as over an available range. + * | | |Note: This bit needs to be cleared by writing 1 to it. + * |[20:9] |VECMAP |Vector Page Mapping Address (Read Only) + * | | |The current flash address space 0x0000_0000~0x0000_07FF is mapping to + * | | |address {VECMAP[11:2], 11¡¦h000} ~ {VECMAP[11:2], 11¡¦h7FF} + * | | |VECMAP[1:0] is needed to set 0. + * |[26] |CFGCRCF |User-Configuration CRC Check Flag (Read Only) + * | | |This bit is set by hardware when detecting CONFIG CRC checksum is error + * | | |0 = CONFIG CRC checksum is OK. + * | | |1 = CONFIG CRC checksum error and force chip into LOCK mode. + */ + __IO uint32_t ISPSTS; + + /** + * FBWP + * =================================================================================================== + * Offset: 0x44 Flash Block Write Protect Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |BWP |Flash Block Write Protect Control + * | | |If BWP.N bit is set to 0, the APROM memory relative region cannot program and erase by ISP. (N=0~31). + * | | |Bit Block Protect Region + * | | |BWP0 0x00_0000 ~ 0x00_3FFF + * | | |BWP1 0x00_4000 ~ 0x00_7FFF + * | | |BWP2 0x00_8000 ~ 0x00_BFFF + * | | |BWP3 0x00_C000 ~ 0x00_FFFF + * | | |BWP4 0x01_0000 ~ 0x01_3FFF + * | | |BWP5 0x01_4000 ~ 0x01_7FFF + * | | |BWP6 0x01_8000 ~ 0x01_BFFF + * | | |BWP7 0x01_C000 ~ 0x01_FFFF + * | | |BWP8 0x02_0000 ~ 0x02_3FFF + * | | |BWP9 0x02_4000 ~ 0x02_7FFF + * | | |BWP10 0x02_8000 ~ 0x02_BFFF + * | | |BWP11 0x02_C000 ~ 0x02_FFFF + * | | |BWP12 0x03_0000 ~ 0x03_3FFF + * | | |BWP13 0x03_4000 ~ 0x03_7FFF + * | | |BWP14 0x03_8000 ~ 0x03_BFFF + * | | |BWP15 0x03_C000 ~ 0x03_FFFF + * | | |BWP16 0x04_0000 ~ 0x04_3FFF + * | | |BWP17 0x04_4000 ~ 0x04_7FFF + * | | |BWP18 0x04_8000 ~ 0x04_BFFF + * | | |BWP19 0x04_C000 ~ 0x04_FFFF + * | | |BWP20 0x05_0000 ~ 0x05_3FFF + * | | |BWP21 0x05_4000 ~ 0x05_7FFF + * | | |BWP22 0x05_8000 ~ 0x05_BFFF + * | | |BWP23 0x05_C000 ~ 0x05_FFFF + * | | |BWP24 0x06_0000 ~ 0x06_3FFF + * | | |BWP25 0x06_4000 ~ 0x06_7FFF + * | | |BWP26 0x06_8000 ~ 0x06_BFFF + * | | |BWP27 0x06_C000 ~ 0x06_FFFF + * | | |BWP28 0x07_0000 ~ 0x07_3FFF + * | | |BWP29 0x07_4000 ~ 0x07_7FFF + * | | |BWP30 0x07_8000 ~ 0x07_BFFF + * | | |BWP31 0x07_C000 ~ 0x07_FFFF + * | | |This register is loaded from Config2 when chip is power on. + * | | |It is read only, except the correct Super Key is matched. + * | | |This register is also a protected bit which means programming this bit needs to write "59h", "16h", "88h" to address GCR_BA+0x100 to disable register protection. + * | | |Refer to the register REGWRPROT at address GCR_BA+0x100. + */ + __IO uint32_t FBWP; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[14]; + /// @endcond //HIDDEN_SYMBOLS + + /** + * MPDAT0 + * =================================================================================================== + * Offset: 0x80 ISP Data 0 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ISPDAT0 |ISP Data 0 + * | | |This register is the first 32-bit data for 32b/64b/multi-word program, + * | | |and it is also the mirror of FMC_ISPDAT register, both registers keep the same data. + */ + __IO uint32_t MPDAT0; + + /** + * MPDAT1 + * =================================================================================================== + * Offset: 0x84 ISP Data 1 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ISPDAT1 |ISP Data 1 + * | | |This register is the second 32-bit data for 32b/64b/multi-word program. + */ + __IO uint32_t MPDAT1; + + /** + * MPDAT2 + * =================================================================================================== + * Offset: 0x88 ISP Data 2 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ISPDAT2 |ISP Data 2 + * | | |This register is the third 32-bit data for 32b/64b/multi-word program. + */ + __IO uint32_t MPDAT2; + + /** + * MPDAT3 + * =================================================================================================== + * Offset: 0x8C ISP Data 1 Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ISPDAT3 |ISP Data 3 + * | | |This register is the fourth 32-bit data for 32b/64b/multi-word program. + */ + __IO uint32_t MPDAT3; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[12]; + /// @endcond //HIDDEN_SYMBOLS + + /** + * MPSTS + * =================================================================================================== + * Offset: 0xC0 ISP Multi-Word Program Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |MPBUSY |ISP Multi-Word Program Busy Flag (Read Only) + * | | |0 = ISP Multi-Word Program operation is aborted or finished. + * | | |1 = ISP Multi-Word Program operation is progressed. + * |[2] |ISPFF |ISP Fail Flag (Read Only) + * | | |This CBS field is just a copy of User-Configuration Config0 CBS[7:6]. + * |[4] |D0 |ISP DATA 0 Flag (Read Only) + * | | |This bit is set when FMC_MPDAT0 is written and auto-clear to 0 + * | | |when the FMC_MPDAT0 is programmed to flash complete. + * | | |0 = FMC_MPDAT0 register is empty, or program to flash complete. + * | | |1 = FMC_MPDAT0 register has been written, and not programmed to flash yet. + * |[5] |D1 |ISP DATA 1 Flag (Read Only) + * | | |This bit is set when FMC_MPDAT1 is written and auto-clear to 0 + * | | |when the FMC_MPDAT1 is programmed to flash complete. + * | | |0 = FMC_MPDAT1 register is empty, or program to flash complete. + * | | |1 = FMC_MPDAT1 register has been written, and not programmed to flash yet. + * |[6] |D2 |ISP DATA 2 Flag (Read Only) + * | | |This bit is set when FMC_MPDAT2 is written and auto-clear to 0 + * | | |when the FMC_MPDAT2 is programmed to flash complete. + * | | |0 = FMC_MPDAT2 register is empty, or program to flash complete. + * | | |1 = FMC_MPDAT2 register has been written, and not programmed to flash yet. + * |[7] |D3 |ISP DATA 3 Flag (Read Only) + * | | |This bit is set when FMC_MPDAT3 is written and auto-clear to 0 + * | | |when the FMC_MPDAT3 is programmed to flash complete. + * | | |0 = FMC_MPDAT3 register is empty, or program to flash complete. + * | | |1 = FMC_MPDAT3 register has been written, and not programmed to flash yet. + */ + __IO uint32_t MPSTS; + + /** + * MPADDR + * =================================================================================================== + * Offset: 0xC4 ISP Multi-Word Program Address Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |MPADDR |ISP Multi-Word Program Address Status + * | | |MPADDR is the address of ISP Multi-Word Program operation when + * | | |MPBUSY flag is 1. MPADDR will keep the final address when + * | | |Multi-Word Program is aborted or finished. + */ + __IO uint32_t MPADDR; + +} FMC_T; + + +/** + @addtogroup FMC_CONST FMC Bit Field Definition + Constant Definitions for FMC Controller +@{ */ + +#define FMC_ISPCTL_ISPEN_Pos (0) /*!< FMC_T::ISPCTL: ISPEN Position */ +#define FMC_ISPCTL_ISPEN_Msk (0x1ul << FMC_ISPCTL_ISPEN_Pos) /*!< FMC_T::ISPCTL: ISPEN Mask */ + +#define FMC_ISPCTL_BS_Pos (1) /*!< FMC_T::ISPCTL: BS Position */ +#define FMC_ISPCTL_BS_Msk (0x1ul << FMC_ISPCTL_BS_Pos) /*!< FMC_T::ISPCTL: BS Mask */ + +#define FMC_ISPCTL_APUEN_Pos (3) /*!< FMC_T::ISPCTL: APUEN Position */ +#define FMC_ISPCTL_APUEN_Msk (0x1ul << FMC_ISPCTL_APUEN_Pos) /*!< FMC_T::ISPCTL: APUEN Mask */ + +#define FMC_ISPCTL_CFGUEN_Pos (4) /*!< FMC_T::ISPCTL: CFGUEN Position */ +#define FMC_ISPCTL_CFGUEN_Msk (0x1ul << FMC_ISPCTL_CFGUEN_Pos) /*!< FMC_T::ISPCTL: CFGUEN Mask */ + +#define FMC_ISPCTL_LDUEN_Pos (5) /*!< FMC_T::ISPCTL: LDUEN Position */ +#define FMC_ISPCTL_LDUEN_Msk (0x1ul << FMC_ISPCTL_LDUEN_Pos) /*!< FMC_T::ISPCTL: LDUEN Mask */ + +#define FMC_ISPCTL_ISPFF_Pos (6) /*!< FMC_T::ISPCTL: ISPFF Position */ +#define FMC_ISPCTL_ISPFF_Msk (0x1ul << FMC_ISPCTL_ISPFF_Pos) /*!< FMC_T::ISPCTL: ISPFF Mask */ + +#define FMC_ISPADDR_ISPADDR_Pos (0) /*!< FMC_T::ISPADDR: ISPADDR Position */ +#define FMC_ISPADDR_ISPADDR_Msk (0xfffffffful << FMC_ISPADDR_ISPADDR_Pos) /*!< FMC_T::ISPADDR: ISPADDR Mask */ + +#define FMC_ISPDAT_ISPDAT_Pos (0) /*!< FMC_T::ISPDAT: ISPDAT Position */ +#define FMC_ISPDAT_ISPDAT_Msk (0xfffffffful << FMC_ISPDAT_ISPDAT_Pos) /*!< FMC_T::ISPDAT: ISPDAT Mask */ + +#define FMC_ISPCMD_CMD_Pos (0) /*!< FMC_T::ISPCMD: CMD Position */ +#define FMC_ISPCMD_CMD_Msk (0x3ful << FMC_ISPCMD_CMD_Pos) /*!< FMC_T::ISPCMD: CMD Mask */ + +#define FMC_ISPTRG_ISPGO_Pos (0) /*!< FMC_T::ISPTRG: ISPGO Position */ +#define FMC_ISPTRG_ISPGO_Msk (0x1ul << FMC_ISPTRG_ISPGO_Pos) /*!< FMC_T::ISPTRG: ISPGO Mask */ + +#define FMC_DFBA_DFBA_Pos (0) /*!< FMC_T::DFBA: DFBA Position */ +#define FMC_DFBA_DFBA_Msk (0xfffffffful << FMC_DFBA_DFBA_Pos) /*!< FMC_T::DFBA: DFBA Mask */ + +#define FMC_FTCTL_FOM_Pos (4) /*!< FMC_T::FTCTL: FOM Position */ +#define FMC_FTCTL_FOM_Msk (0x7ul << FMC_FTCTL_FOM_Pos) /*!< FMC_T::FTCTL: FOM Mask */ + +#define FMC_ISPSTS_ISPBUSY_Pos (0) /*!< FMC_T::ISPSTS: ISPBUSY Position */ +#define FMC_ISPSTS_ISPBUSY_Msk (0x1ul << FMC_ISPSTS_ISPBUSY_Pos) /*!< FMC_T::ISPSTS: ISPBUSY Mask */ + +#define FMC_ISPSTS_CBS_Pos (1) /*!< FMC_T::ISPSTS: CBS Position */ +#define FMC_ISPSTS_CBS_Msk (0x3ul << FMC_ISPSTS_CBS_Pos) /*!< FMC_T::ISPSTS: CBS Mask */ + +#define FMC_ISPSTS_ISPFF_Pos (6) /*!< FMC_T::ISPSTS: ISPFF Position */ +#define FMC_ISPSTS_ISPFF_Msk (0x1ul << FMC_ISPSTS_ISPFF_Pos) /*!< FMC_T::ISPSTS: ISPFF Mask */ + +#define FMC_ISPSTS_VECMAP_Pos (9) /*!< FMC_T::ISPSTS: VECMAP Position */ +#define FMC_ISPSTS_VECMAP_Msk (0xffful << FMC_ISPSTS_VECMAP_Pos) /*!< FMC_T::ISPSTS: VECMAP Mask */ + +#define FMC_ISPSTS_CFGCRCF_Pos (26) /*!< FMC_T::ISPSTS: CFGCRCF Position */ +#define FMC_ISPSTS_CFGCRCF_Msk (0x1ul << FMC_ISPSTS_CFGCRCF_Pos) /*!< FMC_T::ISPSTS: CFGCRCF Mask */ + +#define FMC_FBWP_BWP_Pos (0) /*!< FMC_T::FBWP: BWP Position */ +#define FMC_FBWP_BWP_Msk (0xfffffffful << FMC_FBWP_BWP_Pos) /*!< FMC_T::FBWP: BWP Mask */ + +#define FMC_MPDAT0_ISPDAT0_Pos (0) /*!< FMC_T::MPDAT0: ISPDAT0 Position */ +#define FMC_MPDAT0_ISPDAT0_Msk (0xfffffffful << FMC_MPDAT0_ISPDAT0_Pos) /*!< FMC_T::MPDAT0: ISPDAT0 Mask */ + +#define FMC_MPDAT1_ISPDAT1_Pos (0) /*!< FMC_T::MPDAT1: ISPDAT1 Position */ +#define FMC_MPDAT1_ISPDAT1_Msk (0xfffffffful << FMC_MPDAT1_ISPDAT1_Pos) /*!< FMC_T::MPDAT1: ISPDAT1 Mask */ + +#define FMC_MPDAT2_ISPDAT2_Pos (0) /*!< FMC_T::MPDAT2: ISPDAT2 Position */ +#define FMC_MPDAT2_ISPDAT2_Msk (0xfffffffful << FMC_MPDAT2_ISPDAT2_Pos) /*!< FMC_T::MPDAT2: ISPDAT2 Mask */ + +#define FMC_MPDAT3_ISPDAT3_Pos (0) /*!< FMC_T::MPDAT3: ISPDAT3 Position */ +#define FMC_MPDAT3_ISPDAT3_Msk (0xfffffffful << FMC_MPDAT3_ISPDAT3_Pos) /*!< FMC_T::MPDAT3: ISPDAT3 Mask */ + +#define FMC_MPSTS_MPBUSY_Pos (0) /*!< FMC_T::MPSTS: WMPBUSY Position */ +#define FMC_MPSTS_MPBUSY_Msk (0x1ul << FMC_MPSTS_MPBUSY_Pos) /*!< FMC_T::MPSTS: MPBUSY Mask */ + +#define FMC_MPSTS_ISPFF_Pos (2) /*!< FMC_T::MPSTS: ISPFF Position */ +#define FMC_MPSTS_ISPFF_Msk (0x1ul << FMC_MPSTS_ISPFF_Pos) /*!< FMC_T::MPSTS: ISPFF Mask */ + +#define FMC_MPSTS_D0_Pos (4) /*!< FMC_T::MPSTS: D0 Position */ +#define FMC_MPSTS_D0_Msk (0x1ul << FMC_MPSTS_D0_Pos) /*!< FMC_T::MPSTS: D0 Mask */ + +#define FMC_MPSTS_D1_Pos (5) /*!< FMC_T::MPSTS: D1 Position */ +#define FMC_MPSTS_D1_Msk (0x1ul << FMC_MPSTS_D1_Pos) /*!< FMC_T::MPSTS: D1 Mask */ + +#define FMC_MPSTS_D2_Pos (6) /*!< FMC_T::MPSTS: D2 Position */ +#define FMC_MPSTS_D2_Msk (0x1ul << FMC_MPSTS_D2_Pos) /*!< FMC_T::MPSTS: D2 Mask */ + +#define FMC_MPSTS_D3_Pos (7) /*!< FMC_T::MPSTS: D3 Position */ +#define FMC_MPSTS_D3_Msk (0x1ul << FMC_MPSTS_D3_Pos) /*!< FMC_T::MPSTS: D3 Mask */ + +#define FMC_MPADDR_MPADDR_Pos (0) /*!< FMC_T::MPADDR: MPADDR Position */ +#define FMC_MPADDR_MPADDR_Msk (0xfffffffful << FMC_MPADDR_MPADDR_Pos) /*!< FMC_T::MPADDR: MPADDR Mask */ + +/**@}*/ /* FMC_CONST */ +/**@}*/ /* end of FMC register group */ + + +/*---------------------- General Purpose Input/Output Controller -------------------------*/ +/** + @addtogroup GPIO General Purpose Input/Output Controller(GPIO) + Memory Mapped Structure for GPIO Controller +@{ */ + +typedef struct { + + + /** + * Px_MODE + * =================================================================================================== + * Offset: 0x00 Px I/O Mode Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |MODE0 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[2:3] |MODE1 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[4:5] |MODE2 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[6:7] |MODE3 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[8:9] |MODE4 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[10:11] |MODE5 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[12:13] |MODE6 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[14:15] |MODE7 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[16:17] |MODE8 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[18:19] |MODE9 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[20:21] |MODE10 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[22:23] |MODE11 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[24:25] |MODE12 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[26:27] |MODE13 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[28:29] |MODE14 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + * |[30:31] |MODE15 |Port N Bit M I/O Mode Control + * | | |Determine the I/O mode of port n bit m. + * | | |00 = INPUT only mode. + * | | |01 = OUTPUT mode. + * | | |10 = Open-drain mode. + * | | |11 = Quasi-bidirectional mode. + * | | |Reset value: + * | | |0xFFFF_FFFF when ( cfg_io =1'b0). + * | | |0x0000_00000 when ( cfg_io =1'b1). + */ + __IO uint32_t MODE; + + /** + * Px_DINOFF + * =================================================================================================== + * Offset: 0x04 Px Digital Input Path Disable Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16] |DINOFF0 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[17] |DINOFF1 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[18] |DINOFF2 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[19] |DINOFF3 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[20] |DINOFF4 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[21] |DINOFF5 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[22] |DINOFF6 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[23] |DINOFF7 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[24] |DINOFF8 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[25] |DINOFF9 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[26] |DINOFF10 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[27] |DINOFF11 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[28] |DINOFF12 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[29] |DINOFF13 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[30] |DINOFF14 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + * |[31] |DINOFF15 |Port N Bit M Off Digital Input Path + * | | |Each of these bits is used to turn off the digital input path of port n bit m pin. + * | | |If input is analog signal, users can turn off digital input path to avoid input current leakage. + * | | |0 = Digital input path Enabled. + * | | |1 = Digital input path Disabled (Digital input is tied to low). + */ + __IO uint32_t DINOFF; + + /** + * Px_DOUT + * =================================================================================================== + * Offset: 0x08 Px Data Output Value + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DOUT0 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[1] |DOUT1 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[2] |DOUT2 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[3] |DOUT3 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[4] |DOUT4 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[5] |DOUT5 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[6] |DOUT6 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[7] |DOUT7 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[8] |DOUT8 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[9] |DOUT9 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[10] |DOUT10 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[11] |DOUT11 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[12] |DOUT12 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[13] |DOUT13 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[14] |DOUT14 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + * |[15] |DOUT15 |Port N Bit M Output + * | | |Each of these bits control the status of port n bit m when this pin is configures as output, open-drain, or Quasi-bidirectional mode. + * | | |0 = Drive port n bit m high low. + * | | |1 = Drive port n bit m high level. + */ + __IO uint32_t DOUT; + + /** + * Px_DATMSK + * =================================================================================================== + * Offset: 0x0C Px Data Output Write Mask + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DATMSK0 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[1] |DATMSK1 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[2] |DATMSK2 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[3] |DATMSK3 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[4] |DATMSK4 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[5] |DATMSK5 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[6] |DATMSK6 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[7] |DATMSK7 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[8] |DATMSK8 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[9] |DATMSK9 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[10] |DATMSK10 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[11] |DATMSK11 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[12] |DATMSK12 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[13] |DATMSK13 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[14] |DATMSK14 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + * |[15] |DATMSK15 |Port N Bit M Data Output Write Mask + * | | |These bits are used to protect the corresponding register of Px_DOUT[m]. + * | | |When set the DATMSK [m] to 1, the writing to Px_DOUT[m] bit is ignored. + * | | |The write to port pin latch is masked. + * | | |0 = Px_DOUT[m] bit writing is valid. + * | | |1 = Px_DOUT[m] bit writing is ignored. + */ + __IO uint32_t DATMSK; + + /** + * Px_PIN + * =================================================================================================== + * Offset: 0x10 Px Pin Value + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |PIN0 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[1] |PIN1 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[2] |PIN2 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[3] |PIN3 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[4] |PIN4 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[5] |PIN5 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[6] |PIN6 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[7] |PIN7 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[8] |PIN8 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[9] |PIN9 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[10] |PIN10 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[11] |PIN11 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[12] |PIN12 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[13] |PIN13 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[14] |PIN14 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + * |[15] |PIN15 |Port N Bit M Pin Value + * | | |Each bit of the register reflects the actual status of the respective port pin. + * | | |If bit is 1, it indicates the corresponding pin status is high, else the pin status is low. + */ + __I uint32_t PIN; + + /** + * Px_DBEN + * =================================================================================================== + * Offset: 0x14 Px De-Bounce Enable Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DBEN0 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[1] |DBEN1 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[2] |DBEN2 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[3] |DBEN3 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[4] |DBEN4 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[5] |DBEN5 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[6] |DBEN6 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[7] |DBEN7 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[8] |DBEN8 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[9] |DBEN9 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[10] |DBEN10 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[11] |DBEN11 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[12] |DBEN12 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[13] |DBEN13 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[14] |DBEN14 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + * |[15] |DBEN15 |Port N Bit M Input De-Bounce Enable + * | | |DBEN[m] is used to enable the de-bounce function for each corresponding bit. + * | | |DBEN[m] is valid for "edge-triggered" interrupt only and is ignored for "level triggered" interrupt. + * | | |If the input signal pulse width can't be sampled by continuous two de-bounce sample cycle The input signal transition is seen as the signal bounce and will not trigger the interrupt. + * | | |The de-bounce clock is controlled by GPIO_DBCTL register. + * | | |0 = Port n bit m input de-bounce Disabled. + * | | |1 = Port n bit m input de-bounce Enabled. + */ + __IO uint32_t DBEN; + + /** + * Px_INTTYPE + * =================================================================================================== + * Offset: 0x18 Px Interrupt Trigger Type Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TYPE0 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[1] |TYPE1 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[2] |TYPE2 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[3] |TYPE3 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[4] |TYPE4 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[5] |TYPE5 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[6] |TYPE6 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[7] |TYPE7 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[8] |TYPE8 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[9] |TYPE9 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[10] |TYPE10 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[11] |TYPE11 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[12] |TYPE12 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[13] |TYPE13 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[14] |TYPE14 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + * |[15] |TYPE15 |Port N Bit M Edge Or Level Triggered Interrupt Control + * | | |TYPE[m] decides the pin interrupt triggered by level or edge. + * | | |If the interrupt is by edge trigger, the trigger source can be controlled by de-bounce. + * | | |If the interrupt is by level trigger, the input source is sampled by one HCLK. + * | | |clock and generates the interrupt. + * | | |0 = Edge triggered interrupt. + * | | |1 = Level triggered interrupt. + * | | |Note1: If pin is set as the level trigger interrupt, only one level can be set on the registers Px_INTEN. + * | | |If set both the level to trigger interrupt, the setting is ignored and no interrupt will occur. + * | | |Note2: The de-bounce function is valid for edge triggered interrupt. + * | | |If the interrupt mode is level triggered, the de-bounce enable bit is ignored. + */ + __IO uint32_t INTTYPE; + + /** + * Px_INTEN + * =================================================================================================== + * Offset: 0x1C Px Interrupt Enable + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |FLIEN0 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[1] |FLIEN1 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[2] |FLIEN2 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[3] |FLIEN3 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[4] |FLIEN4 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[5] |FLIEN5 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[6] |FLIEN6 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[7] |FLIEN7 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[8] |FLIEN8 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[9] |FLIEN9 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[10] |FLIEN10 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[11] |FLIEN11 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[12] |FLIEN12 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[13] |FLIEN13 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[14] |FLIEN14 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[15] |FLIEN15 |Port N Bit M Interrupt Enable For Falling Edge Or Low Level Input + * | | |FLIEN[n] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m low-level or falling edge interrupt Disabled. + * | | |1 = Port n bit m low-level or falling edge interrupt Enabled. + * |[16] |RHIEN0 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[17] |RHIEN1 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[18] |RHIEN2 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[19] |RHIEN3 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[20] |RHIEN4 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[21] |RHIEN5 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[22] |RHIEN6 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[23] |RHIEN7 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[24] |RHIEN8 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[25] |RHIEN9 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[26] |RHIEN10 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[27] |RHIEN11 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[28] |RHIEN12 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[29] |RHIEN13 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[30] |RHIEN14 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + * |[31] |RHIEN15 |Port N Bit M Interrupt Enable For Rising Edge Or High Level Input + * | | |RHIEN[m] enables the interrupt for each of the corresponding input of Port n. + * | | |Setting this bit to 1 also enables the pin wake-up function. + * | | |0 = Port n bit m high-level or rising edge interrupt Disabled. + * | | |1 = Port n bit m high-level or rising edge interrupt Enabled. + */ + __IO uint32_t INTEN; + + /** + * Px_INTSRC + * =================================================================================================== + * Offset: 0x20 Px Interrupt Source Flag + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |INTSRC0 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[1] |INTSRC1 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[2] |INTSRC2 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[3] |INTSRC3 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[4] |INTSRC4 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[5] |INTSRC5 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[6] |INTSRC6 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[7] |INTSRC7 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[8] |INTSRC8 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[9] |INTSRC9 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[10] |INTSRC10 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[11] |INTSRC11 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[12] |INTSRC12 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[13] |INTSRC13 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[14] |INTSRC14 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + * |[15] |INTSRC15 |Port N Bit M Interrupt Trigger Source Indicator + * | | |Read: + * | | |0 = No interrupt at Port n. + * | | |1 = Port n bit m generate an interrupt. + * | | |Write: + * | | |0= No effect. + * | | |1= Clear the correspond pending interrupt. + */ + __IO uint32_t INTSRC; + + /** + * Px_SMTEN + * =================================================================================================== + * Offset: 0x24 Px Input Schmitt Trigger Enable + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SMTEN0 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[1] |SMTEN1 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[2] |SMTEN2 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[3] |SMTEN3 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[4] |SMTEN4 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[5] |SMTEN5 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[6] |SMTEN6 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[7] |SMTEN7 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[8] |SMTEN8 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[9] |SMTEN9 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[10] |SMTEN10 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[11] |SMTEN11 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[12] |SMTEN12 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[13] |SMTEN13 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[14] |SMTEN14 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + * |[15] |SMTEN15 |0 = P I/O input Schmitt Trigger function Disabled. + * | | |1 = P I/O input Schmitt Trigger function Enabled. + */ + __IO uint32_t SMTEN; + + /** + * Px_SLEWCTL + * =================================================================================================== + * Offset: 0x28 Px High Slew Rate Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |HSREN0 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[1] |HSREN1 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[2] |HSREN2 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[3] |HSREN3 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[4] |HSREN4 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[5] |HSREN5 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[6] |HSREN6 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[7] |HSREN7 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[8] |HSREN8 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[9] |HSREN9 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[10] |HSREN10 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[11] |HSREN11 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[12] |HSREN12 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[13] |HSREN13 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[14] |HSREN14 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + * |[15] |HSREN15 |0 = P I/O output with basic slew rate. + * | | |1 = P I/O output with higher slew rate. + */ + __IO uint32_t SLEWCTL; + +} GPIO_T; + + +typedef struct { + + /** + * GPIO_DBCTL + * =================================================================================================== + * Offset: 0x000 Interrupt De-bounce Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |DBCLKSEL |De-Bounce Sampling Cycle Selection + * | | |0000 = Sample interrupt input once per 1 clocks. + * | | |0001 = Sample interrupt input once per 2 clocks. + * | | |0010 = Sample interrupt input once per 4 clocks. + * | | |0011 = Sample interrupt input once per 8 clocks. + * | | |0100 = Sample interrupt input once per 16 clocks. + * | | |0101 = Sample interrupt input once per 32 clocks. + * | | |0110 = Sample interrupt input once per 64 clocks. + * | | |0111 = Sample interrupt input once per 128 clocks. + * | | |1000 = Sample interrupt input once per 256 clocks. + * | | |1001 = Sample interrupt input once per 2*256 clocks. + * | | |1010 = Sample interrupt input once per 4*256 clocks. + * | | |1011 = Sample interrupt input once per 8*256 clocks. + * | | |1100 = Sample interrupt input once per 16*256 clocks. + * | | |1101 = Sample interrupt input once per 32*256 clocks. + * | | |1110 = Sample interrupt input once per 64*256 clocks. + * | | |1111 = Sample interrupt input once per 128*256 clocks. + * |[4] |DBCLKSRC |De-Bounce Counter Clock Source Selection + * | | |0 = De-bounce counter clock source is the HCLK. + * | | |1 = De-bounce counter clock source is the internal 10 kHz clock. + * |[5] |ICLKON |Interrupt Clock On Mode + * | | |Setting this bit to 0 will disable the interrupt generate circuit clock if the pin[n] interrupt is disabled. + * | | |0 = Disable the clock if the all port interrupts are disabled. + * | | |1 = Interrupt generated circuit clock always Enabled. + */ + __IO uint32_t DBCTL; + +} GPIO_DB_T; + +/** + @addtogroup GPIO_CONST GPIO Bit Field Definition + Constant Definitions for GPIO Controller +@{ */ + +#define GPIO_MODE_MODE0_Pos (0) /*!< GPIO_T::MODE: MODE0 Position */ +#define GPIO_MODE_MODE0_Msk (0x3ul << GPIO_MODE_MODE0_Pos) /*!< GPIO_T::MODE: MODE0 Mask */ + +#define GPIO_MODE_MODE1_Pos (2) /*!< GPIO_T::MODE: MODE1 Position */ +#define GPIO_MODE_MODE1_Msk (0x3ul << GPIO_MODE_MODE1_Pos) /*!< GPIO_T::MODE: MODE1 Mask */ + +#define GPIO_MODE_MODE2_Pos (4) /*!< GPIO_T::MODE: MODE2 Position */ +#define GPIO_MODE_MODE2_Msk (0x3ul << GPIO_MODE_MODE2_Pos) /*!< GPIO_T::MODE: MODE2 Mask */ + +#define GPIO_MODE_MODE3_Pos (6) /*!< GPIO_T::MODE: MODE3 Position */ +#define GPIO_MODE_MODE3_Msk (0x3ul << GPIO_MODE_MODE3_Pos) /*!< GPIO_T::MODE: MODE3 Mask */ + +#define GPIO_MODE_MODE4_Pos (8) /*!< GPIO_T::MODE: MODE4 Position */ +#define GPIO_MODE_MODE4_Msk (0x3ul << GPIO_MODE_MODE4_Pos) /*!< GPIO_T::MODE: MODE4 Mask */ + +#define GPIO_MODE_MODE5_Pos (10) /*!< GPIO_T::MODE: MODE5 Position */ +#define GPIO_MODE_MODE5_Msk (0x3ul << GPIO_MODE_MODE5_Pos) /*!< GPIO_T::MODE: MODE5 Mask */ + +#define GPIO_MODE_MODE6_Pos (12) /*!< GPIO_T::MODE: MODE6 Position */ +#define GPIO_MODE_MODE6_Msk (0x3ul << GPIO_MODE_MODE6_Pos) /*!< GPIO_T::MODE: MODE6 Mask */ + +#define GPIO_MODE_MODE7_Pos (14) /*!< GPIO_T::MODE: MODE7 Position */ +#define GPIO_MODE_MODE7_Msk (0x3ul << GPIO_MODE_MODE7_Pos) /*!< GPIO_T::MODE: MODE7 Mask */ + +#define GPIO_MODE_MODE8_Pos (16) /*!< GPIO_T::MODE: MODE8 Position */ +#define GPIO_MODE_MODE8_Msk (0x3ul << GPIO_MODE_MODE8_Pos) /*!< GPIO_T::MODE: MODE8 Mask */ + +#define GPIO_MODE_MODE9_Pos (18) /*!< GPIO_T::MODE: MODE9 Position */ +#define GPIO_MODE_MODE9_Msk (0x3ul << GPIO_MODE_MODE9_Pos) /*!< GPIO_T::MODE: MODE9 Mask */ + +#define GPIO_MODE_MODE10_Pos (20) /*!< GPIO_T::MODE: MODE10 Position */ +#define GPIO_MODE_MODE10_Msk (0x3ul << GPIO_MODE_MODE10_Pos) /*!< GPIO_T::MODE: MODE10 Mask */ + +#define GPIO_MODE_MODE11_Pos (22) /*!< GPIO_T::MODE: MODE11 Position */ +#define GPIO_MODE_MODE11_Msk (0x3ul << GPIO_MODE_MODE11_Pos) /*!< GPIO_T::MODE: MODE11 Mask */ + +#define GPIO_MODE_MODE12_Pos (24) /*!< GPIO_T::MODE: MODE12 Position */ +#define GPIO_MODE_MODE12_Msk (0x3ul << GPIO_MODE_MODE12_Pos) /*!< GPIO_T::MODE: MODE12 Mask */ + +#define GPIO_MODE_MODE13_Pos (26) /*!< GPIO_T::MODE: MODE13 Position */ +#define GPIO_MODE_MODE13_Msk (0x3ul << GPIO_MODE_MODE13_Pos) /*!< GPIO_T::MODE: MODE13 Mask */ + +#define GPIO_MODE_MODE14_Pos (28) /*!< GPIO_T::MODE: MODE14 Position */ +#define GPIO_MODE_MODE14_Msk (0x3ul << GPIO_MODE_MODE14_Pos) /*!< GPIO_T::MODE: MODE14 Mask */ + +#define GPIO_MODE_MODE15_Pos (30) /*!< GPIO_T::MODE: MODE15 Position */ +#define GPIO_MODE_MODE15_Msk (0x3ul << GPIO_MODE_MODE15_Pos) /*!< GPIO_T::MODE: MODE15 Mask */ + +#define GPIO_DINOFF_DINOFF0_Pos (16) /*!< GPIO_T::DINOFF: DINOFF0 Position */ +#define GPIO_DINOFF_DINOFF0_Msk (0x1ul << GPIO_DINOFF_DINOFF0_Pos) /*!< GPIO_T::DINOFF: DINOFF0 Mask */ + +#define GPIO_DINOFF_DINOFF1_Pos (17) /*!< GPIO_T::DINOFF: DINOFF1 Position */ +#define GPIO_DINOFF_DINOFF1_Msk (0x1ul << GPIO_DINOFF_DINOFF1_Pos) /*!< GPIO_T::DINOFF: DINOFF1 Mask */ + +#define GPIO_DINOFF_DINOFF2_Pos (18) /*!< GPIO_T::DINOFF: DINOFF2 Position */ +#define GPIO_DINOFF_DINOFF2_Msk (0x1ul << GPIO_DINOFF_DINOFF2_Pos) /*!< GPIO_T::DINOFF: DINOFF2 Mask */ + +#define GPIO_DINOFF_DINOFF3_Pos (19) /*!< GPIO_T::DINOFF: DINOFF3 Position */ +#define GPIO_DINOFF_DINOFF3_Msk (0x1ul << GPIO_DINOFF_DINOFF3_Pos) /*!< GPIO_T::DINOFF: DINOFF3 Mask */ + +#define GPIO_DINOFF_DINOFF4_Pos (20) /*!< GPIO_T::DINOFF: DINOFF4 Position */ +#define GPIO_DINOFF_DINOFF4_Msk (0x1ul << GPIO_DINOFF_DINOFF4_Pos) /*!< GPIO_T::DINOFF: DINOFF4 Mask */ + +#define GPIO_DINOFF_DINOFF5_Pos (21) /*!< GPIO_T::DINOFF: DINOFF5 Position */ +#define GPIO_DINOFF_DINOFF5_Msk (0x1ul << GPIO_DINOFF_DINOFF5_Pos) /*!< GPIO_T::DINOFF: DINOFF5 Mask */ + +#define GPIO_DINOFF_DINOFF6_Pos (22) /*!< GPIO_T::DINOFF: DINOFF6 Position */ +#define GPIO_DINOFF_DINOFF6_Msk (0x1ul << GPIO_DINOFF_DINOFF6_Pos) /*!< GPIO_T::DINOFF: DINOFF6 Mask */ + +#define GPIO_DINOFF_DINOFF7_Pos (23) /*!< GPIO_T::DINOFF: DINOFF7 Position */ +#define GPIO_DINOFF_DINOFF7_Msk (0x1ul << GPIO_DINOFF_DINOFF7_Pos) /*!< GPIO_T::DINOFF: DINOFF7 Mask */ + +#define GPIO_DINOFF_DINOFF8_Pos (24) /*!< GPIO_T::DINOFF: DINOFF8 Position */ +#define GPIO_DINOFF_DINOFF8_Msk (0x1ul << GPIO_DINOFF_DINOFF8_Pos) /*!< GPIO_T::DINOFF: DINOFF8 Mask */ + +#define GPIO_DINOFF_DINOFF9_Pos (25) /*!< GPIO_T::DINOFF: DINOFF9 Position */ +#define GPIO_DINOFF_DINOFF9_Msk (0x1ul << GPIO_DINOFF_DINOFF9_Pos) /*!< GPIO_T::DINOFF: DINOFF9 Mask */ + +#define GPIO_DINOFF_DINOFF10_Pos (26) /*!< GPIO_T::DINOFF: DINOFF10 Position */ +#define GPIO_DINOFF_DINOFF10_Msk (0x1ul << GPIO_DINOFF_DINOFF10_Pos) /*!< GPIO_T::DINOFF: DINOFF10 Mask */ + +#define GPIO_DINOFF_DINOFF11_Pos (27) /*!< GPIO_T::DINOFF: DINOFF11 Position */ +#define GPIO_DINOFF_DINOFF11_Msk (0x1ul << GPIO_DINOFF_DINOFF11_Pos) /*!< GPIO_T::DINOFF: DINOFF11 Mask */ + +#define GPIO_DINOFF_DINOFF12_Pos (28) /*!< GPIO_T::DINOFF: DINOFF12 Position */ +#define GPIO_DINOFF_DINOFF12_Msk (0x1ul << GPIO_DINOFF_DINOFF12_Pos) /*!< GPIO_T::DINOFF: DINOFF12 Mask */ + +#define GPIO_DINOFF_DINOFF13_Pos (29) /*!< GPIO_T::DINOFF: DINOFF13 Position */ +#define GPIO_DINOFF_DINOFF13_Msk (0x1ul << GPIO_DINOFF_DINOFF13_Pos) /*!< GPIO_T::DINOFF: DINOFF13 Mask */ + +#define GPIO_DINOFF_DINOFF14_Pos (30) /*!< GPIO_T::DINOFF: DINOFF14 Position */ +#define GPIO_DINOFF_DINOFF14_Msk (0x1ul << GPIO_DINOFF_DINOFF14_Pos) /*!< GPIO_T::DINOFF: DINOFF14 Mask */ + +#define GPIO_DINOFF_DINOFF15_Pos (31) /*!< GPIO_T::DINOFF: DINOFF15 Position */ +#define GPIO_DINOFF_DINOFF15_Msk (0x1ul << GPIO_DINOFF_DINOFF15_Pos) /*!< GPIO_T::DINOFF: DINOFF15 Mask */ + +#define GPIO_DOUT_DOUT0_Pos (0) /*!< GPIO_T::DOUT: DOUT0 Position */ +#define GPIO_DOUT_DOUT0_Msk (0x1ul << GPIO_DOUT_DOUT0_Pos) /*!< GPIO_T::DOUT: DOUT0 Mask */ + +#define GPIO_DOUT_DOUT1_Pos (1) /*!< GPIO_T::DOUT: DOUT1 Position */ +#define GPIO_DOUT_DOUT1_Msk (0x1ul << GPIO_DOUT_DOUT1_Pos) /*!< GPIO_T::DOUT: DOUT1 Mask */ + +#define GPIO_DOUT_DOUT2_Pos (2) /*!< GPIO_T::DOUT: DOUT2 Position */ +#define GPIO_DOUT_DOUT2_Msk (0x1ul << GPIO_DOUT_DOUT2_Pos) /*!< GPIO_T::DOUT: DOUT2 Mask */ + +#define GPIO_DOUT_DOUT3_Pos (3) /*!< GPIO_T::DOUT: DOUT3 Position */ +#define GPIO_DOUT_DOUT3_Msk (0x1ul << GPIO_DOUT_DOUT3_Pos) /*!< GPIO_T::DOUT: DOUT3 Mask */ + +#define GPIO_DOUT_DOUT4_Pos (4) /*!< GPIO_T::DOUT: DOUT4 Position */ +#define GPIO_DOUT_DOUT4_Msk (0x1ul << GPIO_DOUT_DOUT4_Pos) /*!< GPIO_T::DOUT: DOUT4 Mask */ + +#define GPIO_DOUT_DOUT5_Pos (5) /*!< GPIO_T::DOUT: DOUT5 Position */ +#define GPIO_DOUT_DOUT5_Msk (0x1ul << GPIO_DOUT_DOUT5_Pos) /*!< GPIO_T::DOUT: DOUT5 Mask */ + +#define GPIO_DOUT_DOUT6_Pos (6) /*!< GPIO_T::DOUT: DOUT6 Position */ +#define GPIO_DOUT_DOUT6_Msk (0x1ul << GPIO_DOUT_DOUT6_Pos) /*!< GPIO_T::DOUT: DOUT6 Mask */ + +#define GPIO_DOUT_DOUT7_Pos (7) /*!< GPIO_T::DOUT: DOUT7 Position */ +#define GPIO_DOUT_DOUT7_Msk (0x1ul << GPIO_DOUT_DOUT7_Pos) /*!< GPIO_T::DOUT: DOUT7 Mask */ + +#define GPIO_DOUT_DOUT8_Pos (8) /*!< GPIO_T::DOUT: DOUT8 Position */ +#define GPIO_DOUT_DOUT8_Msk (0x1ul << GPIO_DOUT_DOUT8_Pos) /*!< GPIO_T::DOUT: DOUT8 Mask */ + +#define GPIO_DOUT_DOUT9_Pos (9) /*!< GPIO_T::DOUT: DOUT9 Position */ +#define GPIO_DOUT_DOUT9_Msk (0x1ul << GPIO_DOUT_DOUT9_Pos) /*!< GPIO_T::DOUT: DOUT9 Mask */ + +#define GPIO_DOUT_DOUT10_Pos (10) /*!< GPIO_T::DOUT: DOUT10 Position */ +#define GPIO_DOUT_DOUT10_Msk (0x1ul << GPIO_DOUT_DOUT10_Pos) /*!< GPIO_T::DOUT: DOUT10 Mask */ + +#define GPIO_DOUT_DOUT11_Pos (11) /*!< GPIO_T::DOUT: DOUT11 Position */ +#define GPIO_DOUT_DOUT11_Msk (0x1ul << GPIO_DOUT_DOUT11_Pos) /*!< GPIO_T::DOUT: DOUT11 Mask */ + +#define GPIO_DOUT_DOUT12_Pos (12) /*!< GPIO_T::DOUT: DOUT12 Position */ +#define GPIO_DOUT_DOUT12_Msk (0x1ul << GPIO_DOUT_DOUT12_Pos) /*!< GPIO_T::DOUT: DOUT12 Mask */ + +#define GPIO_DOUT_DOUT13_Pos (13) /*!< GPIO_T::DOUT: DOUT13 Position */ +#define GPIO_DOUT_DOUT13_Msk (0x1ul << GPIO_DOUT_DOUT13_Pos) /*!< GPIO_T::DOUT: DOUT13 Mask */ + +#define GPIO_DOUT_DOUT14_Pos (14) /*!< GPIO_T::DOUT: DOUT14 Position */ +#define GPIO_DOUT_DOUT14_Msk (0x1ul << GPIO_DOUT_DOUT14_Pos) /*!< GPIO_T::DOUT: DOUT14 Mask */ + +#define GPIO_DOUT_DOUT15_Pos (15) /*!< GPIO_T::DOUT: DOUT15 Position */ +#define GPIO_DOUT_DOUT15_Msk (0x1ul << GPIO_DOUT_DOUT15_Pos) /*!< GPIO_T::DOUT: DOUT15 Mask */ + +#define GPIO_DATMSK_DATMSK0_Pos (0) /*!< GPIO_T::DATMSK: DATMSK0 Position */ +#define GPIO_DATMSK_DATMSK0_Msk (0x1ul << GPIO_DATMSK_DATMSK0_Pos) /*!< GPIO_T::DATMSK: DATMSK0 Mask */ + +#define GPIO_DATMSK_DATMSK1_Pos (1) /*!< GPIO_T::DATMSK: DATMSK1 Position */ +#define GPIO_DATMSK_DATMSK1_Msk (0x1ul << GPIO_DATMSK_DATMSK1_Pos) /*!< GPIO_T::DATMSK: DATMSK1 Mask */ + +#define GPIO_DATMSK_DATMSK2_Pos (2) /*!< GPIO_T::DATMSK: DATMSK2 Position */ +#define GPIO_DATMSK_DATMSK2_Msk (0x1ul << GPIO_DATMSK_DATMSK2_Pos) /*!< GPIO_T::DATMSK: DATMSK2 Mask */ + +#define GPIO_DATMSK_DATMSK3_Pos (3) /*!< GPIO_T::DATMSK: DATMSK3 Position */ +#define GPIO_DATMSK_DATMSK3_Msk (0x1ul << GPIO_DATMSK_DATMSK3_Pos) /*!< GPIO_T::DATMSK: DATMSK3 Mask */ + +#define GPIO_DATMSK_DATMSK4_Pos (4) /*!< GPIO_T::DATMSK: DATMSK4 Position */ +#define GPIO_DATMSK_DATMSK4_Msk (0x1ul << GPIO_DATMSK_DATMSK4_Pos) /*!< GPIO_T::DATMSK: DATMSK4 Mask */ + +#define GPIO_DATMSK_DATMSK5_Pos (5) /*!< GPIO_T::DATMSK: DATMSK5 Position */ +#define GPIO_DATMSK_DATMSK5_Msk (0x1ul << GPIO_DATMSK_DATMSK5_Pos) /*!< GPIO_T::DATMSK: DATMSK5 Mask */ + +#define GPIO_DATMSK_DATMSK6_Pos (6) /*!< GPIO_T::DATMSK: DATMSK6 Position */ +#define GPIO_DATMSK_DATMSK6_Msk (0x1ul << GPIO_DATMSK_DATMSK6_Pos) /*!< GPIO_T::DATMSK: DATMSK6 Mask */ + +#define GPIO_DATMSK_DATMSK7_Pos (7) /*!< GPIO_T::DATMSK: DATMSK7 Position */ +#define GPIO_DATMSK_DATMSK7_Msk (0x1ul << GPIO_DATMSK_DATMSK7_Pos) /*!< GPIO_T::DATMSK: DATMSK7 Mask */ + +#define GPIO_DATMSK_DATMSK8_Pos (8) /*!< GPIO_T::DATMSK: DATMSK8 Position */ +#define GPIO_DATMSK_DATMSK8_Msk (0x1ul << GPIO_DATMSK_DATMSK8_Pos) /*!< GPIO_T::DATMSK: DATMSK8 Mask */ + +#define GPIO_DATMSK_DATMSK9_Pos (9) /*!< GPIO_T::DATMSK: DATMSK9 Position */ +#define GPIO_DATMSK_DATMSK9_Msk (0x1ul << GPIO_DATMSK_DATMSK9_Pos) /*!< GPIO_T::DATMSK: DATMSK9 Mask */ + +#define GPIO_DATMSK_DATMSK10_Pos (10) /*!< GPIO_T::DATMSK: DATMSK10 Position */ +#define GPIO_DATMSK_DATMSK10_Msk (0x1ul << GPIO_DATMSK_DATMSK10_Pos) /*!< GPIO_T::DATMSK: DATMSK10 Mask */ + +#define GPIO_DATMSK_DATMSK11_Pos (11) /*!< GPIO_T::DATMSK: DATMSK11 Position */ +#define GPIO_DATMSK_DATMSK11_Msk (0x1ul << GPIO_DATMSK_DATMSK11_Pos) /*!< GPIO_T::DATMSK: DATMSK11 Mask */ + +#define GPIO_DATMSK_DATMSK12_Pos (12) /*!< GPIO_T::DATMSK: DATMSK12 Position */ +#define GPIO_DATMSK_DATMSK12_Msk (0x1ul << GPIO_DATMSK_DATMSK12_Pos) /*!< GPIO_T::DATMSK: DATMSK12 Mask */ + +#define GPIO_DATMSK_DATMSK13_Pos (13) /*!< GPIO_T::DATMSK: DATMSK13 Position */ +#define GPIO_DATMSK_DATMSK13_Msk (0x1ul << GPIO_DATMSK_DATMSK13_Pos) /*!< GPIO_T::DATMSK: DATMSK13 Mask */ + +#define GPIO_DATMSK_DATMSK14_Pos (14) /*!< GPIO_T::DATMSK: DATMSK14 Position */ +#define GPIO_DATMSK_DATMSK14_Msk (0x1ul << GPIO_DATMSK_DATMSK14_Pos) /*!< GPIO_T::DATMSK: DATMSK14 Mask */ + +#define GPIO_DATMSK_DATMSK15_Pos (15) /*!< GPIO_T::DATMSK: DATMSK15 Position */ +#define GPIO_DATMSK_DATMSK15_Msk (0x1ul << GPIO_DATMSK_DATMSK15_Pos) /*!< GPIO_T::DATMSK: DATMSK15 Mask */ + +#define GPIO_PIN_PIN0_Pos (0) /*!< GPIO_T::PIN: PIN0 Position */ +#define GPIO_PIN_PIN0_Msk (0x1ul << GPIO_PIN_PIN0_Pos) /*!< GPIO_T::PIN: PIN0 Mask */ + +#define GPIO_PIN_PIN1_Pos (1) /*!< GPIO_T::PIN: PIN1 Position */ +#define GPIO_PIN_PIN1_Msk (0x1ul << GPIO_PIN_PIN1_Pos) /*!< GPIO_T::PIN: PIN1 Mask */ + +#define GPIO_PIN_PIN2_Pos (2) /*!< GPIO_T::PIN: PIN2 Position */ +#define GPIO_PIN_PIN2_Msk (0x1ul << GPIO_PIN_PIN2_Pos) /*!< GPIO_T::PIN: PIN2 Mask */ + +#define GPIO_PIN_PIN3_Pos (3) /*!< GPIO_T::PIN: PIN3 Position */ +#define GPIO_PIN_PIN3_Msk (0x1ul << GPIO_PIN_PIN3_Pos) /*!< GPIO_T::PIN: PIN3 Mask */ + +#define GPIO_PIN_PIN4_Pos (4) /*!< GPIO_T::PIN: PIN4 Position */ +#define GPIO_PIN_PIN4_Msk (0x1ul << GPIO_PIN_PIN4_Pos) /*!< GPIO_T::PIN: PIN4 Mask */ + +#define GPIO_PIN_PIN5_Pos (5) /*!< GPIO_T::PIN: PIN5 Position */ +#define GPIO_PIN_PIN5_Msk (0x1ul << GPIO_PIN_PIN5_Pos) /*!< GPIO_T::PIN: PIN5 Mask */ + +#define GPIO_PIN_PIN6_Pos (6) /*!< GPIO_T::PIN: PIN6 Position */ +#define GPIO_PIN_PIN6_Msk (0x1ul << GPIO_PIN_PIN6_Pos) /*!< GPIO_T::PIN: PIN6 Mask */ + +#define GPIO_PIN_PIN7_Pos (7) /*!< GPIO_T::PIN: PIN7 Position */ +#define GPIO_PIN_PIN7_Msk (0x1ul << GPIO_PIN_PIN7_Pos) /*!< GPIO_T::PIN: PIN7 Mask */ + +#define GPIO_PIN_PIN8_Pos (8) /*!< GPIO_T::PIN: PIN8 Position */ +#define GPIO_PIN_PIN8_Msk (0x1ul << GPIO_PIN_PIN8_Pos) /*!< GPIO_T::PIN: PIN8 Mask */ + +#define GPIO_PIN_PIN9_Pos (9) /*!< GPIO_T::PIN: PIN9 Position */ +#define GPIO_PIN_PIN9_Msk (0x1ul << GPIO_PIN_PIN9_Pos) /*!< GPIO_T::PIN: PIN9 Mask */ + +#define GPIO_PIN_PIN10_Pos (10) /*!< GPIO_T::PIN: PIN10 Position */ +#define GPIO_PIN_PIN10_Msk (0x1ul << GPIO_PIN_PIN10_Pos) /*!< GPIO_T::PIN: PIN10 Mask */ + +#define GPIO_PIN_PIN11_Pos (11) /*!< GPIO_T::PIN: PIN11 Position */ +#define GPIO_PIN_PIN11_Msk (0x1ul << GPIO_PIN_PIN11_Pos) /*!< GPIO_T::PIN: PIN11 Mask */ + +#define GPIO_PIN_PIN12_Pos (12) /*!< GPIO_T::PIN: PIN12 Position */ +#define GPIO_PIN_PIN12_Msk (0x1ul << GPIO_PIN_PIN12_Pos) /*!< GPIO_T::PIN: PIN12 Mask */ + +#define GPIO_PIN_PIN13_Pos (13) /*!< GPIO_T::PIN: PIN13 Position */ +#define GPIO_PIN_PIN13_Msk (0x1ul << GPIO_PIN_PIN13_Pos) /*!< GPIO_T::PIN: PIN13 Mask */ + +#define GPIO_PIN_PIN14_Pos (14) /*!< GPIO_T::PIN: PIN14 Position */ +#define GPIO_PIN_PIN14_Msk (0x1ul << GPIO_PIN_PIN14_Pos) /*!< GPIO_T::PIN: PIN14 Mask */ + +#define GPIO_PIN_PIN15_Pos (15) /*!< GPIO_T::PIN: PIN15 Position */ +#define GPIO_PIN_PIN15_Msk (0x1ul << GPIO_PIN_PIN15_Pos) /*!< GPIO_T::PIN: PIN15 Mask */ + +#define GPIO_DBEN_DBEN0_Pos (0) /*!< GPIO_T::DBEN: DBEN0 Position */ +#define GPIO_DBEN_DBEN0_Msk (0x1ul << GPIO_DBEN_DBEN0_Pos) /*!< GPIO_T::DBEN: DBEN0 Mask */ + +#define GPIO_DBEN_DBEN1_Pos (1) /*!< GPIO_T::DBEN: DBEN1 Position */ +#define GPIO_DBEN_DBEN1_Msk (0x1ul << GPIO_DBEN_DBEN1_Pos) /*!< GPIO_T::DBEN: DBEN1 Mask */ + +#define GPIO_DBEN_DBEN2_Pos (2) /*!< GPIO_T::DBEN: DBEN2 Position */ +#define GPIO_DBEN_DBEN2_Msk (0x1ul << GPIO_DBEN_DBEN2_Pos) /*!< GPIO_T::DBEN: DBEN2 Mask */ + +#define GPIO_DBEN_DBEN3_Pos (3) /*!< GPIO_T::DBEN: DBEN3 Position */ +#define GPIO_DBEN_DBEN3_Msk (0x1ul << GPIO_DBEN_DBEN3_Pos) /*!< GPIO_T::DBEN: DBEN3 Mask */ + +#define GPIO_DBEN_DBEN4_Pos (4) /*!< GPIO_T::DBEN: DBEN4 Position */ +#define GPIO_DBEN_DBEN4_Msk (0x1ul << GPIO_DBEN_DBEN4_Pos) /*!< GPIO_T::DBEN: DBEN4 Mask */ + +#define GPIO_DBEN_DBEN5_Pos (5) /*!< GPIO_T::DBEN: DBEN5 Position */ +#define GPIO_DBEN_DBEN5_Msk (0x1ul << GPIO_DBEN_DBEN5_Pos) /*!< GPIO_T::DBEN: DBEN5 Mask */ + +#define GPIO_DBEN_DBEN6_Pos (6) /*!< GPIO_T::DBEN: DBEN6 Position */ +#define GPIO_DBEN_DBEN6_Msk (0x1ul << GPIO_DBEN_DBEN6_Pos) /*!< GPIO_T::DBEN: DBEN6 Mask */ + +#define GPIO_DBEN_DBEN7_Pos (7) /*!< GPIO_T::DBEN: DBEN7 Position */ +#define GPIO_DBEN_DBEN7_Msk (0x1ul << GPIO_DBEN_DBEN7_Pos) /*!< GPIO_T::DBEN: DBEN7 Mask */ + +#define GPIO_DBEN_DBEN8_Pos (8) /*!< GPIO_T::DBEN: DBEN8 Position */ +#define GPIO_DBEN_DBEN8_Msk (0x1ul << GPIO_DBEN_DBEN8_Pos) /*!< GPIO_T::DBEN: DBEN8 Mask */ + +#define GPIO_DBEN_DBEN9_Pos (9) /*!< GPIO_T::DBEN: DBEN9 Position */ +#define GPIO_DBEN_DBEN9_Msk (0x1ul << GPIO_DBEN_DBEN9_Pos) /*!< GPIO_T::DBEN: DBEN9 Mask */ + +#define GPIO_DBEN_DBEN10_Pos (10) /*!< GPIO_T::DBEN: DBEN10 Position */ +#define GPIO_DBEN_DBEN10_Msk (0x1ul << GPIO_DBEN_DBEN10_Pos) /*!< GPIO_T::DBEN: DBEN10 Mask */ + +#define GPIO_DBEN_DBEN11_Pos (11) /*!< GPIO_T::DBEN: DBEN11 Position */ +#define GPIO_DBEN_DBEN11_Msk (0x1ul << GPIO_DBEN_DBEN11_Pos) /*!< GPIO_T::DBEN: DBEN11 Mask */ + +#define GPIO_DBEN_DBEN12_Pos (12) /*!< GPIO_T::DBEN: DBEN12 Position */ +#define GPIO_DBEN_DBEN12_Msk (0x1ul << GPIO_DBEN_DBEN12_Pos) /*!< GPIO_T::DBEN: DBEN12 Mask */ + +#define GPIO_DBEN_DBEN13_Pos (13) /*!< GPIO_T::DBEN: DBEN13 Position */ +#define GPIO_DBEN_DBEN13_Msk (0x1ul << GPIO_DBEN_DBEN13_Pos) /*!< GPIO_T::DBEN: DBEN13 Mask */ + +#define GPIO_DBEN_DBEN14_Pos (14) /*!< GPIO_T::DBEN: DBEN14 Position */ +#define GPIO_DBEN_DBEN14_Msk (0x1ul << GPIO_DBEN_DBEN14_Pos) /*!< GPIO_T::DBEN: DBEN14 Mask */ + +#define GPIO_DBEN_DBEN15_Pos (15) /*!< GPIO_T::DBEN: DBEN15 Position */ +#define GPIO_DBEN_DBEN15_Msk (0x1ul << GPIO_DBEN_DBEN15_Pos) /*!< GPIO_T::DBEN: DBEN15 Mask */ + +#define GPIO_INTTYPE_TYPE0_Pos (0) /*!< GPIO_T::INTTYPE: TYPE0 Position */ +#define GPIO_INTTYPE_TYPE0_Msk (0x1ul << GPIO_INTTYPE_TYPE0_Pos) /*!< GPIO_T::INTTYPE: TYPE0 Mask */ + +#define GPIO_INTTYPE_TYPE1_Pos (1) /*!< GPIO_T::INTTYPE: TYPE1 Position */ +#define GPIO_INTTYPE_TYPE1_Msk (0x1ul << GPIO_INTTYPE_TYPE1_Pos) /*!< GPIO_T::INTTYPE: TYPE1 Mask */ + +#define GPIO_INTTYPE_TYPE2_Pos (2) /*!< GPIO_T::INTTYPE: TYPE2 Position */ +#define GPIO_INTTYPE_TYPE2_Msk (0x1ul << GPIO_INTTYPE_TYPE2_Pos) /*!< GPIO_T::INTTYPE: TYPE2 Mask */ + +#define GPIO_INTTYPE_TYPE3_Pos (3) /*!< GPIO_T::INTTYPE: TYPE3 Position */ +#define GPIO_INTTYPE_TYPE3_Msk (0x1ul << GPIO_INTTYPE_TYPE3_Pos) /*!< GPIO_T::INTTYPE: TYPE3 Mask */ + +#define GPIO_INTTYPE_TYPE4_Pos (4) /*!< GPIO_T::INTTYPE: TYPE4 Position */ +#define GPIO_INTTYPE_TYPE4_Msk (0x1ul << GPIO_INTTYPE_TYPE4_Pos) /*!< GPIO_T::INTTYPE: TYPE4 Mask */ + +#define GPIO_INTTYPE_TYPE5_Pos (5) /*!< GPIO_T::INTTYPE: TYPE5 Position */ +#define GPIO_INTTYPE_TYPE5_Msk (0x1ul << GPIO_INTTYPE_TYPE5_Pos) /*!< GPIO_T::INTTYPE: TYPE5 Mask */ + +#define GPIO_INTTYPE_TYPE6_Pos (6) /*!< GPIO_T::INTTYPE: TYPE6 Position */ +#define GPIO_INTTYPE_TYPE6_Msk (0x1ul << GPIO_INTTYPE_TYPE6_Pos) /*!< GPIO_T::INTTYPE: TYPE6 Mask */ + +#define GPIO_INTTYPE_TYPE7_Pos (7) /*!< GPIO_T::INTTYPE: TYPE7 Position */ +#define GPIO_INTTYPE_TYPE7_Msk (0x1ul << GPIO_INTTYPE_TYPE7_Pos) /*!< GPIO_T::INTTYPE: TYPE7 Mask */ + +#define GPIO_INTTYPE_TYPE8_Pos (8) /*!< GPIO_T::INTTYPE: TYPE8 Position */ +#define GPIO_INTTYPE_TYPE8_Msk (0x1ul << GPIO_INTTYPE_TYPE8_Pos) /*!< GPIO_T::INTTYPE: TYPE8 Mask */ + +#define GPIO_INTTYPE_TYPE9_Pos (9) /*!< GPIO_T::INTTYPE: TYPE9 Position */ +#define GPIO_INTTYPE_TYPE9_Msk (0x1ul << GPIO_INTTYPE_TYPE9_Pos) /*!< GPIO_T::INTTYPE: TYPE9 Mask */ + +#define GPIO_INTTYPE_TYPE10_Pos (10) /*!< GPIO_T::INTTYPE: TYPE10 Position */ +#define GPIO_INTTYPE_TYPE10_Msk (0x1ul << GPIO_INTTYPE_TYPE10_Pos) /*!< GPIO_T::INTTYPE: TYPE10 Mask */ + +#define GPIO_INTTYPE_TYPE11_Pos (11) /*!< GPIO_T::INTTYPE: TYPE11 Position */ +#define GPIO_INTTYPE_TYPE11_Msk (0x1ul << GPIO_INTTYPE_TYPE11_Pos) /*!< GPIO_T::INTTYPE: TYPE11 Mask */ + +#define GPIO_INTTYPE_TYPE12_Pos (12) /*!< GPIO_T::INTTYPE: TYPE12 Position */ +#define GPIO_INTTYPE_TYPE12_Msk (0x1ul << GPIO_INTTYPE_TYPE12_Pos) /*!< GPIO_T::INTTYPE: TYPE12 Mask */ + +#define GPIO_INTTYPE_TYPE13_Pos (13) /*!< GPIO_T::INTTYPE: TYPE13 Position */ +#define GPIO_INTTYPE_TYPE13_Msk (0x1ul << GPIO_INTTYPE_TYPE13_Pos) /*!< GPIO_T::INTTYPE: TYPE13 Mask */ + +#define GPIO_INTTYPE_TYPE14_Pos (14) /*!< GPIO_T::INTTYPE: TYPE14 Position */ +#define GPIO_INTTYPE_TYPE14_Msk (0x1ul << GPIO_INTTYPE_TYPE14_Pos) /*!< GPIO_T::INTTYPE: TYPE14 Mask */ + +#define GPIO_INTTYPE_TYPE15_Pos (15) /*!< GPIO_T::INTTYPE: TYPE15 Position */ +#define GPIO_INTTYPE_TYPE15_Msk (0x1ul << GPIO_INTTYPE_TYPE15_Pos) /*!< GPIO_T::INTTYPE: TYPE15 Mask */ + +#define GPIO_INTEN_FLIEN0_Pos (0) /*!< GPIO_T::INTEN: FLIEN0 Position */ +#define GPIO_INTEN_FLIEN0_Msk (0x1ul << GPIO_INTEN_FLIEN0_Pos) /*!< GPIO_T::INTEN: FLIEN0 Mask */ + +#define GPIO_INTEN_FLIEN1_Pos (1) /*!< GPIO_T::INTEN: FLIEN1 Position */ +#define GPIO_INTEN_FLIEN1_Msk (0x1ul << GPIO_INTEN_FLIEN1_Pos) /*!< GPIO_T::INTEN: FLIEN1 Mask */ + +#define GPIO_INTEN_FLIEN2_Pos (2) /*!< GPIO_T::INTEN: FLIEN2 Position */ +#define GPIO_INTEN_FLIEN2_Msk (0x1ul << GPIO_INTEN_FLIEN2_Pos) /*!< GPIO_T::INTEN: FLIEN2 Mask */ + +#define GPIO_INTEN_FLIEN3_Pos (3) /*!< GPIO_T::INTEN: FLIEN3 Position */ +#define GPIO_INTEN_FLIEN3_Msk (0x1ul << GPIO_INTEN_FLIEN3_Pos) /*!< GPIO_T::INTEN: FLIEN3 Mask */ + +#define GPIO_INTEN_FLIEN4_Pos (4) /*!< GPIO_T::INTEN: FLIEN4 Position */ +#define GPIO_INTEN_FLIEN4_Msk (0x1ul << GPIO_INTEN_FLIEN4_Pos) /*!< GPIO_T::INTEN: FLIEN4 Mask */ + +#define GPIO_INTEN_FLIEN5_Pos (5) /*!< GPIO_T::INTEN: FLIEN5 Position */ +#define GPIO_INTEN_FLIEN5_Msk (0x1ul << GPIO_INTEN_FLIEN5_Pos) /*!< GPIO_T::INTEN: FLIEN5 Mask */ + +#define GPIO_INTEN_FLIEN6_Pos (6) /*!< GPIO_T::INTEN: FLIEN6 Position */ +#define GPIO_INTEN_FLIEN6_Msk (0x1ul << GPIO_INTEN_FLIEN6_Pos) /*!< GPIO_T::INTEN: FLIEN6 Mask */ + +#define GPIO_INTEN_FLIEN7_Pos (7) /*!< GPIO_T::INTEN: FLIEN7 Position */ +#define GPIO_INTEN_FLIEN7_Msk (0x1ul << GPIO_INTEN_FLIEN7_Pos) /*!< GPIO_T::INTEN: FLIEN7 Mask */ + +#define GPIO_INTEN_FLIEN8_Pos (8) /*!< GPIO_T::INTEN: FLIEN8 Position */ +#define GPIO_INTEN_FLIEN8_Msk (0x1ul << GPIO_INTEN_FLIEN8_Pos) /*!< GPIO_T::INTEN: FLIEN8 Mask */ + +#define GPIO_INTEN_FLIEN9_Pos (9) /*!< GPIO_T::INTEN: FLIEN9 Position */ +#define GPIO_INTEN_FLIEN9_Msk (0x1ul << GPIO_INTEN_FLIEN9_Pos) /*!< GPIO_T::INTEN: FLIEN9 Mask */ + +#define GPIO_INTEN_FLIEN10_Pos (10) /*!< GPIO_T::INTEN: FLIEN10 Position */ +#define GPIO_INTEN_FLIEN10_Msk (0x1ul << GPIO_INTEN_FLIEN10_Pos) /*!< GPIO_T::INTEN: FLIEN10 Mask */ + +#define GPIO_INTEN_FLIEN11_Pos (11) /*!< GPIO_T::INTEN: FLIEN11 Position */ +#define GPIO_INTEN_FLIEN11_Msk (0x1ul << GPIO_INTEN_FLIEN11_Pos) /*!< GPIO_T::INTEN: FLIEN11 Mask */ + +#define GPIO_INTEN_FLIEN12_Pos (12) /*!< GPIO_T::INTEN: FLIEN12 Position */ +#define GPIO_INTEN_FLIEN12_Msk (0x1ul << GPIO_INTEN_FLIEN12_Pos) /*!< GPIO_T::INTEN: FLIEN12 Mask */ + +#define GPIO_INTEN_FLIEN13_Pos (13) /*!< GPIO_T::INTEN: FLIEN13 Position */ +#define GPIO_INTEN_FLIEN13_Msk (0x1ul << GPIO_INTEN_FLIEN13_Pos) /*!< GPIO_T::INTEN: FLIEN13 Mask */ + +#define GPIO_INTEN_FLIEN14_Pos (14) /*!< GPIO_T::INTEN: FLIEN14 Position */ +#define GPIO_INTEN_FLIEN14_Msk (0x1ul << GPIO_INTEN_FLIEN14_Pos) /*!< GPIO_T::INTEN: FLIEN14 Mask */ + +#define GPIO_INTEN_FLIEN15_Pos (15) /*!< GPIO_T::INTEN: FLIEN15 Position */ +#define GPIO_INTEN_FLIEN15_Msk (0x1ul << GPIO_INTEN_FLIEN15_Pos) /*!< GPIO_T::INTEN: FLIEN15 Mask */ + +#define GPIO_INTEN_RHIEN0_Pos (16) /*!< GPIO_T::INTEN: RHIEN0 Position */ +#define GPIO_INTEN_RHIEN0_Msk (0x1ul << GPIO_INTEN_RHIEN0_Pos) /*!< GPIO_T::INTEN: RHIEN0 Mask */ + +#define GPIO_INTEN_RHIEN1_Pos (17) /*!< GPIO_T::INTEN: RHIEN1 Position */ +#define GPIO_INTEN_RHIEN1_Msk (0x1ul << GPIO_INTEN_RHIEN1_Pos) /*!< GPIO_T::INTEN: RHIEN1 Mask */ + +#define GPIO_INTEN_RHIEN2_Pos (18) /*!< GPIO_T::INTEN: RHIEN2 Position */ +#define GPIO_INTEN_RHIEN2_Msk (0x1ul << GPIO_INTEN_RHIEN2_Pos) /*!< GPIO_T::INTEN: RHIEN2 Mask */ + +#define GPIO_INTEN_RHIEN3_Pos (19) /*!< GPIO_T::INTEN: RHIEN3 Position */ +#define GPIO_INTEN_RHIEN3_Msk (0x1ul << GPIO_INTEN_RHIEN3_Pos) /*!< GPIO_T::INTEN: RHIEN3 Mask */ + +#define GPIO_INTEN_RHIEN4_Pos (20) /*!< GPIO_T::INTEN: RHIEN4 Position */ +#define GPIO_INTEN_RHIEN4_Msk (0x1ul << GPIO_INTEN_RHIEN4_Pos) /*!< GPIO_T::INTEN: RHIEN4 Mask */ + +#define GPIO_INTEN_RHIEN5_Pos (21) /*!< GPIO_T::INTEN: RHIEN5 Position */ +#define GPIO_INTEN_RHIEN5_Msk (0x1ul << GPIO_INTEN_RHIEN5_Pos) /*!< GPIO_T::INTEN: RHIEN5 Mask */ + +#define GPIO_INTEN_RHIEN6_Pos (22) /*!< GPIO_T::INTEN: RHIEN6 Position */ +#define GPIO_INTEN_RHIEN6_Msk (0x1ul << GPIO_INTEN_RHIEN6_Pos) /*!< GPIO_T::INTEN: RHIEN6 Mask */ + +#define GPIO_INTEN_RHIEN7_Pos (23) /*!< GPIO_T::INTEN: RHIEN7 Position */ +#define GPIO_INTEN_RHIEN7_Msk (0x1ul << GPIO_INTEN_RHIEN7_Pos) /*!< GPIO_T::INTEN: RHIEN7 Mask */ + +#define GPIO_INTEN_RHIEN8_Pos (24) /*!< GPIO_T::INTEN: RHIEN8 Position */ +#define GPIO_INTEN_RHIEN8_Msk (0x1ul << GPIO_INTEN_RHIEN8_Pos) /*!< GPIO_T::INTEN: RHIEN8 Mask */ + +#define GPIO_INTEN_RHIEN9_Pos (25) /*!< GPIO_T::INTEN: RHIEN9 Position */ +#define GPIO_INTEN_RHIEN9_Msk (0x1ul << GPIO_INTEN_RHIEN9_Pos) /*!< GPIO_T::INTEN: RHIEN9 Mask */ + +#define GPIO_INTEN_RHIEN10_Pos (26) /*!< GPIO_T::INTEN: RHIEN10 Position */ +#define GPIO_INTEN_RHIEN10_Msk (0x1ul << GPIO_INTEN_RHIEN10_Pos) /*!< GPIO_T::INTEN: RHIEN10 Mask */ + +#define GPIO_INTEN_RHIEN11_Pos (27) /*!< GPIO_T::INTEN: RHIEN11 Position */ +#define GPIO_INTEN_RHIEN11_Msk (0x1ul << GPIO_INTEN_RHIEN11_Pos) /*!< GPIO_T::INTEN: RHIEN11 Mask */ + +#define GPIO_INTEN_RHIEN12_Pos (28) /*!< GPIO_T::INTEN: RHIEN12 Position */ +#define GPIO_INTEN_RHIEN12_Msk (0x1ul << GPIO_INTEN_RHIEN12_Pos) /*!< GPIO_T::INTEN: RHIEN12 Mask */ + +#define GPIO_INTEN_RHIEN13_Pos (29) /*!< GPIO_T::INTEN: RHIEN13 Position */ +#define GPIO_INTEN_RHIEN13_Msk (0x1ul << GPIO_INTEN_RHIEN13_Pos) /*!< GPIO_T::INTEN: RHIEN13 Mask */ + +#define GPIO_INTEN_RHIEN14_Pos (30) /*!< GPIO_T::INTEN: RHIEN14 Position */ +#define GPIO_INTEN_RHIEN14_Msk (0x1ul << GPIO_INTEN_RHIEN14_Pos) /*!< GPIO_T::INTEN: RHIEN14 Mask */ + +#define GPIO_INTEN_RHIEN15_Pos (31) /*!< GPIO_T::INTEN: RHIEN15 Position */ +#define GPIO_INTEN_RHIEN15_Msk (0x1ul << GPIO_INTEN_RHIEN15_Pos) /*!< GPIO_T::INTEN: RHIEN15 Mask */ + +#define GPIO_INTSRC_INTSRC0_Pos (0) /*!< GPIO_T::INTSRC: INTSRC0 Position */ +#define GPIO_INTSRC_INTSRC0_Msk (0x1ul << GPIO_INTSRC_INTSRC0_Pos) /*!< GPIO_T::INTSRC: INTSRC0 Mask */ + +#define GPIO_INTSRC_INTSRC1_Pos (1) /*!< GPIO_T::INTSRC: INTSRC1 Position */ +#define GPIO_INTSRC_INTSRC1_Msk (0x1ul << GPIO_INTSRC_INTSRC1_Pos) /*!< GPIO_T::INTSRC: INTSRC1 Mask */ + +#define GPIO_INTSRC_INTSRC2_Pos (2) /*!< GPIO_T::INTSRC: INTSRC2 Position */ +#define GPIO_INTSRC_INTSRC2_Msk (0x1ul << GPIO_INTSRC_INTSRC2_Pos) /*!< GPIO_T::INTSRC: INTSRC2 Mask */ + +#define GPIO_INTSRC_INTSRC3_Pos (3) /*!< GPIO_T::INTSRC: INTSRC3 Position */ +#define GPIO_INTSRC_INTSRC3_Msk (0x1ul << GPIO_INTSRC_INTSRC3_Pos) /*!< GPIO_T::INTSRC: INTSRC3 Mask */ + +#define GPIO_INTSRC_INTSRC4_Pos (4) /*!< GPIO_T::INTSRC: INTSRC4 Position */ +#define GPIO_INTSRC_INTSRC4_Msk (0x1ul << GPIO_INTSRC_INTSRC4_Pos) /*!< GPIO_T::INTSRC: INTSRC4 Mask */ + +#define GPIO_INTSRC_INTSRC5_Pos (5) /*!< GPIO_T::INTSRC: INTSRC5 Position */ +#define GPIO_INTSRC_INTSRC5_Msk (0x1ul << GPIO_INTSRC_INTSRC5_Pos) /*!< GPIO_T::INTSRC: INTSRC5 Mask */ + +#define GPIO_INTSRC_INTSRC6_Pos (6) /*!< GPIO_T::INTSRC: INTSRC6 Position */ +#define GPIO_INTSRC_INTSRC6_Msk (0x1ul << GPIO_INTSRC_INTSRC6_Pos) /*!< GPIO_T::INTSRC: INTSRC6 Mask */ + +#define GPIO_INTSRC_INTSRC7_Pos (7) /*!< GPIO_T::INTSRC: INTSRC7 Position */ +#define GPIO_INTSRC_INTSRC7_Msk (0x1ul << GPIO_INTSRC_INTSRC7_Pos) /*!< GPIO_T::INTSRC: INTSRC7 Mask */ + +#define GPIO_INTSRC_INTSRC8_Pos (8) /*!< GPIO_T::INTSRC: INTSRC8 Position */ +#define GPIO_INTSRC_INTSRC8_Msk (0x1ul << GPIO_INTSRC_INTSRC8_Pos) /*!< GPIO_T::INTSRC: INTSRC8 Mask */ + +#define GPIO_INTSRC_INTSRC9_Pos (9) /*!< GPIO_T::INTSRC: INTSRC9 Position */ +#define GPIO_INTSRC_INTSRC9_Msk (0x1ul << GPIO_INTSRC_INTSRC9_Pos) /*!< GPIO_T::INTSRC: INTSRC9 Mask */ + +#define GPIO_INTSRC_INTSRC10_Pos (10) /*!< GPIO_T::INTSRC: INTSRC10 Position */ +#define GPIO_INTSRC_INTSRC10_Msk (0x1ul << GPIO_INTSRC_INTSRC10_Pos) /*!< GPIO_T::INTSRC: INTSRC10 Mask */ + +#define GPIO_INTSRC_INTSRC11_Pos (11) /*!< GPIO_T::INTSRC: INTSRC11 Position */ +#define GPIO_INTSRC_INTSRC11_Msk (0x1ul << GPIO_INTSRC_INTSRC11_Pos) /*!< GPIO_T::INTSRC: INTSRC11 Mask */ + +#define GPIO_INTSRC_INTSRC12_Pos (12) /*!< GPIO_T::INTSRC: INTSRC12 Position */ +#define GPIO_INTSRC_INTSRC12_Msk (0x1ul << GPIO_INTSRC_INTSRC12_Pos) /*!< GPIO_T::INTSRC: INTSRC12 Mask */ + +#define GPIO_INTSRC_INTSRC13_Pos (13) /*!< GPIO_T::INTSRC: INTSRC13 Position */ +#define GPIO_INTSRC_INTSRC13_Msk (0x1ul << GPIO_INTSRC_INTSRC13_Pos) /*!< GPIO_T::INTSRC: INTSRC13 Mask */ + +#define GPIO_INTSRC_INTSRC14_Pos (14) /*!< GPIO_T::INTSRC: INTSRC14 Position */ +#define GPIO_INTSRC_INTSRC14_Msk (0x1ul << GPIO_INTSRC_INTSRC14_Pos) /*!< GPIO_T::INTSRC: INTSRC14 Mask */ + +#define GPIO_INTSRC_INTSRC15_Pos (15) /*!< GPIO_T::INTSRC: INTSRC15 Position */ +#define GPIO_INTSRC_INTSRC15_Msk (0x1ul << GPIO_INTSRC_INTSRC15_Pos) /*!< GPIO_T::INTSRC: INTSRC15 Mask */ + +#define GPIO_SMTEN_SMTEN0_Pos (0) /*!< GPIO_T::SMTEN: SMTEN0 Position */ +#define GPIO_SMTEN_SMTEN0_Msk (0x1ul << GPIO_SMTEN_SMTEN0_Pos) /*!< GPIO_T::SMTEN: SMTEN0 Mask */ + +#define GPIO_SMTEN_SMTEN1_Pos (1) /*!< GPIO_T::SMTEN: SMTEN1 Position */ +#define GPIO_SMTEN_SMTEN1_Msk (0x1ul << GPIO_SMTEN_SMTEN1_Pos) /*!< GPIO_T::SMTEN: SMTEN1 Mask */ + +#define GPIO_SMTEN_SMTEN2_Pos (2) /*!< GPIO_T::SMTEN: SMTEN2 Position */ +#define GPIO_SMTEN_SMTEN2_Msk (0x1ul << GPIO_SMTEN_SMTEN2_Pos) /*!< GPIO_T::SMTEN: SMTEN2 Mask */ + +#define GPIO_SMTEN_SMTEN3_Pos (3) /*!< GPIO_T::SMTEN: SMTEN3 Position */ +#define GPIO_SMTEN_SMTEN3_Msk (0x1ul << GPIO_SMTEN_SMTEN3_Pos) /*!< GPIO_T::SMTEN: SMTEN3 Mask */ + +#define GPIO_SMTEN_SMTEN4_Pos (4) /*!< GPIO_T::SMTEN: SMTEN4 Position */ +#define GPIO_SMTEN_SMTEN4_Msk (0x1ul << GPIO_SMTEN_SMTEN4_Pos) /*!< GPIO_T::SMTEN: SMTEN4 Mask */ + +#define GPIO_SMTEN_SMTEN5_Pos (5) /*!< GPIO_T::SMTEN: SMTEN5 Position */ +#define GPIO_SMTEN_SMTEN5_Msk (0x1ul << GPIO_SMTEN_SMTEN5_Pos) /*!< GPIO_T::SMTEN: SMTEN5 Mask */ + +#define GPIO_SMTEN_SMTEN6_Pos (6) /*!< GPIO_T::SMTEN: SMTEN6 Position */ +#define GPIO_SMTEN_SMTEN6_Msk (0x1ul << GPIO_SMTEN_SMTEN6_Pos) /*!< GPIO_T::SMTEN: SMTEN6 Mask */ + +#define GPIO_SMTEN_SMTEN7_Pos (7) /*!< GPIO_T::SMTEN: SMTEN7 Position */ +#define GPIO_SMTEN_SMTEN7_Msk (0x1ul << GPIO_SMTEN_SMTEN7_Pos) /*!< GPIO_T::SMTEN: SMTEN7 Mask */ + +#define GPIO_SMTEN_SMTEN8_Pos (8) /*!< GPIO_T::SMTEN: SMTEN8 Position */ +#define GPIO_SMTEN_SMTEN8_Msk (0x1ul << GPIO_SMTEN_SMTEN8_Pos) /*!< GPIO_T::SMTEN: SMTEN8 Mask */ + +#define GPIO_SMTEN_SMTEN9_Pos (9) /*!< GPIO_T::SMTEN: SMTEN9 Position */ +#define GPIO_SMTEN_SMTEN9_Msk (0x1ul << GPIO_SMTEN_SMTEN9_Pos) /*!< GPIO_T::SMTEN: SMTEN9 Mask */ + +#define GPIO_SMTEN_SMTEN10_Pos (10) /*!< GPIO_T::SMTEN: SMTEN10 Position */ +#define GPIO_SMTEN_SMTEN10_Msk (0x1ul << GPIO_SMTEN_SMTEN10_Pos) /*!< GPIO_T::SMTEN: SMTEN10 Mask */ + +#define GPIO_SMTEN_SMTEN11_Pos (11) /*!< GPIO_T::SMTEN: SMTEN11 Position */ +#define GPIO_SMTEN_SMTEN11_Msk (0x1ul << GPIO_SMTEN_SMTEN11_Pos) /*!< GPIO_T::SMTEN: SMTEN11 Mask */ + +#define GPIO_SMTEN_SMTEN12_Pos (12) /*!< GPIO_T::SMTEN: SMTEN12 Position */ +#define GPIO_SMTEN_SMTEN12_Msk (0x1ul << GPIO_SMTEN_SMTEN12_Pos) /*!< GPIO_T::SMTEN: SMTEN12 Mask */ + +#define GPIO_SMTEN_SMTEN13_Pos (13) /*!< GPIO_T::SMTEN: SMTEN13 Position */ +#define GPIO_SMTEN_SMTEN13_Msk (0x1ul << GPIO_SMTEN_SMTEN13_Pos) /*!< GPIO_T::SMTEN: SMTEN13 Mask */ + +#define GPIO_SMTEN_SMTEN14_Pos (14) /*!< GPIO_T::SMTEN: SMTEN14 Position */ +#define GPIO_SMTEN_SMTEN14_Msk (0x1ul << GPIO_SMTEN_SMTEN14_Pos) /*!< GPIO_T::SMTEN: SMTEN14 Mask */ + +#define GPIO_SMTEN_SMTEN15_Pos (15) /*!< GPIO_T::SMTEN: SMTEN15 Position */ +#define GPIO_SMTEN_SMTEN15_Msk (0x1ul << GPIO_SMTEN_SMTEN15_Pos) /*!< GPIO_T::SMTEN: SMTEN15 Mask */ + +#define GPIO_SLEWCTL_HSREN0_Pos (0) /*!< GPIO_T::SLEWCTL: HSREN0 Position */ +#define GPIO_SLEWCTL_HSREN0_Msk (0x1ul << GPIO_SLEWCTL_HSREN0_Pos) /*!< GPIO_T::SLEWCTL: HSREN0 Mask */ + +#define GPIO_SLEWCTL_HSREN1_Pos (1) /*!< GPIO_T::SLEWCTL: HSREN1 Position */ +#define GPIO_SLEWCTL_HSREN1_Msk (0x1ul << GPIO_SLEWCTL_HSREN1_Pos) /*!< GPIO_T::SLEWCTL: HSREN1 Mask */ + +#define GPIO_SLEWCTL_HSREN2_Pos (2) /*!< GPIO_T::SLEWCTL: HSREN2 Position */ +#define GPIO_SLEWCTL_HSREN2_Msk (0x1ul << GPIO_SLEWCTL_HSREN2_Pos) /*!< GPIO_T::SLEWCTL: HSREN2 Mask */ + +#define GPIO_SLEWCTL_HSREN3_Pos (3) /*!< GPIO_T::SLEWCTL: HSREN3 Position */ +#define GPIO_SLEWCTL_HSREN3_Msk (0x1ul << GPIO_SLEWCTL_HSREN3_Pos) /*!< GPIO_T::SLEWCTL: HSREN3 Mask */ + +#define GPIO_SLEWCTL_HSREN4_Pos (4) /*!< GPIO_T::SLEWCTL: HSREN4 Position */ +#define GPIO_SLEWCTL_HSREN4_Msk (0x1ul << GPIO_SLEWCTL_HSREN4_Pos) /*!< GPIO_T::SLEWCTL: HSREN4 Mask */ + +#define GPIO_SLEWCTL_HSREN5_Pos (5) /*!< GPIO_T::SLEWCTL: HSREN5 Position */ +#define GPIO_SLEWCTL_HSREN5_Msk (0x1ul << GPIO_SLEWCTL_HSREN5_Pos) /*!< GPIO_T::SLEWCTL: HSREN5 Mask */ + +#define GPIO_SLEWCTL_HSREN6_Pos (6) /*!< GPIO_T::SLEWCTL: HSREN6 Position */ +#define GPIO_SLEWCTL_HSREN6_Msk (0x1ul << GPIO_SLEWCTL_HSREN6_Pos) /*!< GPIO_T::SLEWCTL: HSREN6 Mask */ + +#define GPIO_SLEWCTL_HSREN7_Pos (7) /*!< GPIO_T::SLEWCTL: HSREN7 Position */ +#define GPIO_SLEWCTL_HSREN7_Msk (0x1ul << GPIO_SLEWCTL_HSREN7_Pos) /*!< GPIO_T::SLEWCTL: HSREN7 Mask */ + +#define GPIO_SLEWCTL_HSREN8_Pos (8) /*!< GPIO_T::SLEWCTL: HSREN8 Position */ +#define GPIO_SLEWCTL_HSREN8_Msk (0x1ul << GPIO_SLEWCTL_HSREN8_Pos) /*!< GPIO_T::SLEWCTL: HSREN8 Mask */ + +#define GPIO_SLEWCTL_HSREN9_Pos (9) /*!< GPIO_T::SLEWCTL: HSREN9 Position */ +#define GPIO_SLEWCTL_HSREN9_Msk (0x1ul << GPIO_SLEWCTL_HSREN9_Pos) /*!< GPIO_T::SLEWCTL: HSREN9 Mask */ + +#define GPIO_SLEWCTL_HSREN10_Pos (10) /*!< GPIO_T::SLEWCTL: HSREN10 Position */ +#define GPIO_SLEWCTL_HSREN10_Msk (0x1ul << GPIO_SLEWCTL_HSREN10_Pos) /*!< GPIO_T::SLEWCTL: HSREN10 Mask */ + +#define GPIO_SLEWCTL_HSREN11_Pos (11) /*!< GPIO_T::SLEWCTL: HSREN11 Position */ +#define GPIO_SLEWCTL_HSREN11_Msk (0x1ul << GPIO_SLEWCTL_HSREN11_Pos) /*!< GPIO_T::SLEWCTL: HSREN11 Mask */ + +#define GPIO_SLEWCTL_HSREN12_Pos (12) /*!< GPIO_T::SLEWCTL: HSREN12 Position */ +#define GPIO_SLEWCTL_HSREN12_Msk (0x1ul << GPIO_SLEWCTL_HSREN12_Pos) /*!< GPIO_T::SLEWCTL: HSREN12 Mask */ + +#define GPIO_SLEWCTL_HSREN13_Pos (13) /*!< GPIO_T::SLEWCTL: HSREN13 Position */ +#define GPIO_SLEWCTL_HSREN13_Msk (0x1ul << GPIO_SLEWCTL_HSREN13_Pos) /*!< GPIO_T::SLEWCTL: HSREN13 Mask */ + +#define GPIO_SLEWCTL_HSREN14_Pos (14) /*!< GPIO_T::SLEWCTL: HSREN14 Position */ +#define GPIO_SLEWCTL_HSREN14_Msk (0x1ul << GPIO_SLEWCTL_HSREN14_Pos) /*!< GPIO_T::SLEWCTL: HSREN14 Mask */ + +#define GPIO_SLEWCTL_HSREN15_Pos (15) /*!< GPIO_T::SLEWCTL: HSREN15 Position */ +#define GPIO_SLEWCTL_HSREN15_Msk (0x1ul << GPIO_SLEWCTL_HSREN15_Pos) /*!< GPIO_T::SLEWCTL: HSREN15 Mask */ + +#define GPIO_DBCTL_DBCLKSEL_Pos (0) /*!< GPIO_DB_T::DBCTL: DBCLKSEL Position */ +#define GPIO_DBCTL_DBCLKSEL_Msk (0xful << GPIO_DBCTL_DBCLKSEL_Pos) /*!< GPIO_DB_T::DBCTL: DBCLKSEL Mask */ + +#define GPIO_DBCTL_DBCLKSRC_Pos (4) /*!< GPIO_DB_T::DBCTL: DBCLKSRC Position */ +#define GPIO_DBCTL_DBCLKSRC_Msk (0x1ul << GPIO_DBCTL_DBCLKSRC_Pos) /*!< GPIO_DB_T::DBCTL: DBCLKSRC Mask */ + +#define GPIO_DBCTL_ICLKON_Pos (5) /*!< GPIO_DB_T::DBCTL: ICLKON Position */ +#define GPIO_DBCTL_ICLKON_Msk (0x1ul << GPIO_DBCTL_ICLKON_Pos) /*!< GPIO_DB_T::DBCTL: ICLKON Mask */ + +/**@}*/ /* GPIO_CONST */ +/**@}*/ /* end of GPIO register group */ + + +/*---------------------- Inter-IC Bus Controller -------------------------*/ +/** + @addtogroup I2C Inter-IC Bus Controller(I2C) + Memory Mapped Structure for I2C Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 I2C Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[2] |AA |Assert Acknowledge Control + * | | |When AA =1 prior to address or data received, an acknowledged (low level to SDA) will be returned during the acknowledge clock pulse on the SCL line when 1.) A slave is acknowledging the address sent from master, 2.) The receiver devices are acknowledging the data sent by transmitter. + * | | |When AA=0 prior to address or data received, a Not acknowledged (high level to SDA) will be returned during the acknowledge clock pulse on the SCL line. + * |[3] |SI |I2C Interrupt Flag + * | | |When a new I2C state is present in the I2C_STATUS register, the SI flag is set by hardware, and if bit EI (I2CON [7]) is set, the I2C interrupt is requested. + * | | |SI must be cleared by software. + * | | |Clear SI by writing 1 to this bit. + * |[4] |STO |I2C STOP Control + * | | |In Master mode, setting STO to transmit a STOP condition to bus then I2C hardware will check the bus condition if a STOP condition is detected this bit will be cleared by hardware automatically. + * | | |In a slave mode, setting STO resets I2C hardware to the defined "not addressed" slave mode. + * | | |This means it is NO LONGER in the slave receiver mode to receive data from the master transmit device. + * |[5] |STA |I2C START Control + * | | |Setting STA to logic 1 to enter Master mode, the I2C hardware sends a START or repeat START condition to bus when the bus is free. + * |[6] |I2CEN |I2C Controller Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |Set to enable I2C serial function controller. + * | | |When ENS1=1 the I2C serial function enables. + * | | |The multi-function pin function of SDA and SCL must set to I2C function first. + * |[7] |INTEN |I2C Interrupt Enable Control + * | | |0 = I2C interrupt Disabled. + * | | |1 = I2C interrupt Enabled. + */ + __IO uint32_t CTL; + + /** + * ADDR0 + * =================================================================================================== + * Offset: 0x04 I2C Slave Address Register0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |GC |General Call Function + * | | |0 = General Call Function Disabled. + * | | |1 = General Call Function Enabled. + * |[1:7] |ADDR |I2C Address Bits + * | | |The content of this register is irrelevant when I2C is in Master mode. + * | | |In the slave mode, the seven most significant bits must be loaded with the chip's own address. + * | | |The I2C hardware will react if either of the address is matched. + */ + __IO uint32_t ADDR0; + + /** + * DAT + * =================================================================================================== + * Offset: 0x08 I2C Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DAT |I2C Data Bits + * | | |Bit [7:0] is located with the 8-bit transferred data of I2C serial port. + */ + __IO uint32_t DAT; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x0C I2C Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |STATUS |I2C Status Bits + * | | |The status register of I2C: + * | | |The three least significant bits are always 0. + * | | |The five most significant bits contain the status code. + * | | |Refer to section 6.15.5.4 for detail description. + */ + __I uint32_t STATUS; + + /** + * CLKDIV + * =================================================================================================== + * Offset: 0x10 I2C Clock Divided Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DIVIDER |I2C Clock Divided Bits + * | | |The I2C clock rate bits: Data Baud Rate of I2C = (system clock) / (4x (I2CLK+1)). + * | | |Note: The minimum value of I2CLK is 4. + */ + __IO uint32_t CLKDIV; + + /** + * TOCTL + * =================================================================================================== + * Offset: 0x14 I2C Time-out Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TOIF |Time-Out Flag + * | | |This bit is set by H/W when I2C time-out happened and it can interrupt CPU if I2C interrupt enable bit (EI (I2CON[7])) is set to 1. + * | | |Note: Write 1 to clear this bit. + * |[1] |TOCDIV4 |Time-Out Counter Input Clock Divided By 4 + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |When Enabled, The time-out period is extend 4 times. + * |[2] |TOCEN |Time-Out Counter Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |When Enabled, the 14-bit time-out counter will start counting when SI (I2CON[3]) is clear. + * | | |Setting flag SI to high will reset counter and re-start up counting after SI is cleared. + */ + __IO uint32_t TOCTL; + + /** + * ADDR1 + * =================================================================================================== + * Offset: 0x18 I2C Slave Address Register1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |GC |General Call Function + * | | |0 = General Call Function Disabled. + * | | |1 = General Call Function Enabled. + * |[1:7] |ADDR |I2C Address Bits + * | | |The content of this register is irrelevant when I2C is in Master mode. + * | | |In the slave mode, the seven most significant bits must be loaded with the chip's own address. + * | | |The I2C hardware will react if either of the address is matched. + */ + __IO uint32_t ADDR1; + + /** + * ADDR2 + * =================================================================================================== + * Offset: 0x1C I2C Slave Address Register2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |GC |General Call Function + * | | |0 = General Call Function Disabled. + * | | |1 = General Call Function Enabled. + * |[1:7] |ADDR |I2C Address Bits + * | | |The content of this register is irrelevant when I2C is in Master mode. + * | | |In the slave mode, the seven most significant bits must be loaded with the chip's own address. + * | | |The I2C hardware will react if either of the address is matched. + */ + __IO uint32_t ADDR2; + + /** + * ADDR3 + * =================================================================================================== + * Offset: 0x20 I2C Slave Address Register3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |GC |General Call Function + * | | |0 = General Call Function Disabled. + * | | |1 = General Call Function Enabled. + * |[1:7] |ADDR |I2C Address Bits + * | | |The content of this register is irrelevant when I2C is in Master mode. + * | | |In the slave mode, the seven most significant bits must be loaded with the chip's own address. + * | | |The I2C hardware will react if either of the address is matched. + */ + __IO uint32_t ADDR3; + + /** + * ADDRMSK0 + * =================================================================================================== + * Offset: 0x24 I2C Slave Address Mask Register0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1:7] |ADDRMSK |I2C Address Mask Bits + * | | |0 = Mask Disabled (the received corresponding register bit should be exact the same as address register.). + * | | |1 = Mask Enabled (the received corresponding address bit is don't care.). + * | | |I2C bus controllers support multiple address recognition with four address mask register. + * | | |When the bit in the address mask register is set to one, it means the received corresponding address bit is don't-care. + * | | |If the bit is set to zero, that means the received corresponding register bit should be exact the same as address register. + */ + __IO uint32_t ADDRMSK0; + + /** + * ADDRMSK1 + * =================================================================================================== + * Offset: 0x28 I2C Slave Address Mask Register1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1:7] |ADDRMSK |I2C Address Mask Bits + * | | |0 = Mask Disabled (the received corresponding register bit should be exact the same as address register.). + * | | |1 = Mask Enabled (the received corresponding address bit is don't care.). + * | | |I2C bus controllers support multiple address recognition with four address mask register. + * | | |When the bit in the address mask register is set to one, it means the received corresponding address bit is don't-care. + * | | |If the bit is set to zero, that means the received corresponding register bit should be exact the same as address register. + */ + __IO uint32_t ADDRMSK1; + + /** + * ADDRMSK2 + * =================================================================================================== + * Offset: 0x2C I2C Slave Address Mask Register2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1:7] |ADDRMSK |I2C Address Mask Bits + * | | |0 = Mask Disabled (the received corresponding register bit should be exact the same as address register.). + * | | |1 = Mask Enabled (the received corresponding address bit is don't care.). + * | | |I2C bus controllers support multiple address recognition with four address mask register. + * | | |When the bit in the address mask register is set to one, it means the received corresponding address bit is don't-care. + * | | |If the bit is set to zero, that means the received corresponding register bit should be exact the same as address register. + */ + __IO uint32_t ADDRMSK2; + + /** + * ADDRMSK3 + * =================================================================================================== + * Offset: 0x30 I2C Slave Address Mask Register3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1:7] |ADDRMSK |I2C Address Mask Bits + * | | |0 = Mask Disabled (the received corresponding register bit should be exact the same as address register.). + * | | |1 = Mask Enabled (the received corresponding address bit is don't care.). + * | | |I2C bus controllers support multiple address recognition with four address mask register. + * | | |When the bit in the address mask register is set to one, it means the received corresponding address bit is don't-care. + * | | |If the bit is set to zero, that means the received corresponding register bit should be exact the same as address register. + */ + __IO uint32_t ADDRMSK3; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[2]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * WKCTL + * =================================================================================================== + * Offset: 0x3C I2C Wake-up Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |WKEN |I2C Wake-Up Enable Control + * | | |0 = I2C wake-up function Disabled. + * | | |1 = I2C wake-up function Enabled. + */ + __IO uint32_t WKCTL; + + /** + * WKSTS + * =================================================================================================== + * Offset: 0x40 I2C Wake-up Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |WKIF |I2C Wake-Up Flag + * | | |0 = No wake up occurred. + * | | |1 = Wake up from Power-down mode. + * | | |Note: Software can write 1 to clear this bit. + */ + __IO uint32_t WKSTS; + +} I2C_T; + +/** + @addtogroup I2C_CONST I2C Bit Field Definition + Constant Definitions for I2C Controller +@{ */ + +#define I2C_CTL_AA_Pos (2) /*!< I2C_T::CTL: AA Position */ +#define I2C_CTL_AA_Msk (0x1ul << I2C_CTL_AA_Pos) /*!< I2C_T::CTL: AA Mask */ + +#define I2C_CTL_SI_Pos (3) /*!< I2C_T::CTL: SI Position */ +#define I2C_CTL_SI_Msk (0x1ul << I2C_CTL_SI_Pos) /*!< I2C_T::CTL: SI Mask */ + +#define I2C_CTL_STO_Pos (4) /*!< I2C_T::CTL: STO Position */ +#define I2C_CTL_STO_Msk (0x1ul << I2C_CTL_STO_Pos) /*!< I2C_T::CTL: STO Mask */ + +#define I2C_CTL_STA_Pos (5) /*!< I2C_T::CTL: STA Position */ +#define I2C_CTL_STA_Msk (0x1ul << I2C_CTL_STA_Pos) /*!< I2C_T::CTL: STA Mask */ + +#define I2C_CTL_I2CEN_Pos (6) /*!< I2C_T::CTL: I2CEN Position */ +#define I2C_CTL_I2CEN_Msk (0x1ul << I2C_CTL_I2CEN_Pos) /*!< I2C_T::CTL: I2CEN Mask */ + +#define I2C_CTL_INTEN_Pos (7) /*!< I2C_T::CTL: INTEN Position */ +#define I2C_CTL_INTEN_Msk (0x1ul << I2C_CTL_INTEN_Pos) /*!< I2C_T::CTL: INTEN Mask */ + +#define I2C_ADDR0_GC_Pos (0) /*!< I2C_T::ADDR0: GC Position */ +#define I2C_ADDR0_GC_Msk (0x1ul << I2C_ADDR0_GC_Pos) /*!< I2C_T::ADDR0: GC Mask */ + +#define I2C_ADDR0_ADDR_Pos (1) /*!< I2C_T::ADDR0: ADDR Position */ +#define I2C_ADDR0_ADDR_Msk (0x7ful << I2C_ADDR0_ADDR_Pos) /*!< I2C_T::ADDR0: ADDR Mask */ + +#define I2C_DAT_DAT_Pos (0) /*!< I2C_T::DAT: DAT Position */ +#define I2C_DAT_DAT_Msk (0xfful << I2C_DAT_DAT_Pos) /*!< I2C_T::DAT: DAT Mask */ + +#define I2C_STATUS_STATUS_Pos (0) /*!< I2C_T::STATUS: STATUS Position */ +#define I2C_STATUS_STATUS_Msk (0xfful << I2C_STATUS_STATUS_Pos) /*!< I2C_T::STATUS: STATUS Mask */ + +#define I2C_CLKDIV_DIVIDER_Pos (0) /*!< I2C_T::CLKDIV: DIVIDER Position */ +#define I2C_CLKDIV_DIVIDER_Msk (0xfful << I2C_CLKDIV_DIVIDER_Pos) /*!< I2C_T::CLKDIV: DIVIDER Mask */ + +#define I2C_TOCTL_TOIF_Pos (0) /*!< I2C_T::TOCTL: TOIF Position */ +#define I2C_TOCTL_TOIF_Msk (0x1ul << I2C_TOCTL_TOIF_Pos) /*!< I2C_T::TOCTL: TOIF Mask */ + +#define I2C_TOCTL_TOCDIV4_Pos (1) /*!< I2C_T::TOCTL: TOCDIV4 Position */ +#define I2C_TOCTL_TOCDIV4_Msk (0x1ul << I2C_TOCTL_TOCDIV4_Pos) /*!< I2C_T::TOCTL: TOCDIV4 Mask */ + +#define I2C_TOCTL_TOCEN_Pos (2) /*!< I2C_T::TOCTL: TOCEN Position */ +#define I2C_TOCTL_TOCEN_Msk (0x1ul << I2C_TOCTL_TOCEN_Pos) /*!< I2C_T::TOCTL: TOCEN Mask */ + +#define I2C_ADDR1_GC_Pos (0) /*!< I2C_T::ADDR1: GC Position */ +#define I2C_ADDR1_GC_Msk (0x1ul << I2C_ADDR1_GC_Pos) /*!< I2C_T::ADDR1: GC Mask */ + +#define I2C_ADDR1_ADDR_Pos (1) /*!< I2C_T::ADDR1: ADDR Position */ +#define I2C_ADDR1_ADDR_Msk (0x7ful << I2C_ADDR1_ADDR_Pos) /*!< I2C_T::ADDR1: ADDR Mask */ + +#define I2C_ADDR2_GC_Pos (0) /*!< I2C_T::ADDR2: GC Position */ +#define I2C_ADDR2_GC_Msk (0x1ul << I2C_ADDR2_GC_Pos) /*!< I2C_T::ADDR2: GC Mask */ + +#define I2C_ADDR2_ADDR_Pos (1) /*!< I2C_T::ADDR2: ADDR Position */ +#define I2C_ADDR2_ADDR_Msk (0x7ful << I2C_ADDR2_ADDR_Pos) /*!< I2C_T::ADDR2: ADDR Mask */ + +#define I2C_ADDR3_GC_Pos (0) /*!< I2C_T::ADDR3: GC Position */ +#define I2C_ADDR3_GC_Msk (0x1ul << I2C_ADDR3_GC_Pos) /*!< I2C_T::ADDR3: GC Mask */ + +#define I2C_ADDR3_ADDR_Pos (1) /*!< I2C_T::ADDR3: ADDR Position */ +#define I2C_ADDR3_ADDR_Msk (0x7ful << I2C_ADDR3_ADDR_Pos) /*!< I2C_T::ADDR3: ADDR Mask */ + +#define I2C_ADDRMSK0_ADDRMSK_Pos (1) /*!< I2C_T::ADDRMSK0: ADDRMSK Position */ +#define I2C_ADDRMSK0_ADDRMSK_Msk (0x7ful << I2C_ADDRMSK0_ADDRMSK_Pos) /*!< I2C_T::ADDRMSK0: ADDRMSK Mask */ + +#define I2C_ADDRMSK1_ADDRMSK_Pos (1) /*!< I2C_T::ADDRMSK1: ADDRMSK Position */ +#define I2C_ADDRMSK1_ADDRMSK_Msk (0x7ful << I2C_ADDRMSK1_ADDRMSK_Pos) /*!< I2C_T::ADDRMSK1: ADDRMSK Mask */ + +#define I2C_ADDRMSK2_ADDRMSK_Pos (1) /*!< I2C_T::ADDRMSK2: ADDRMSK Position */ +#define I2C_ADDRMSK2_ADDRMSK_Msk (0x7ful << I2C_ADDRMSK2_ADDRMSK_Pos) /*!< I2C_T::ADDRMSK2: ADDRMSK Mask */ + +#define I2C_ADDRMSK3_ADDRMSK_Pos (1) /*!< I2C_T::ADDRMSK3: ADDRMSK Position */ +#define I2C_ADDRMSK3_ADDRMSK_Msk (0x7ful << I2C_ADDRMSK3_ADDRMSK_Pos) /*!< I2C_T::ADDRMSK3: ADDRMSK Mask */ + +#define I2C_WKCTL_WKEN_Pos (0) /*!< I2C_T::WKCTL: WKEN Position */ +#define I2C_WKCTL_WKEN_Msk (0x1ul << I2C_WKCTL_WKEN_Pos) /*!< I2C_T::WKCTL: WKEN Mask */ + +#define I2C_WKSTS_WKIF_Pos (0) /*!< I2C_T::WKSTS: WKIF Position */ +#define I2C_WKSTS_WKIF_Msk (0x1ul << I2C_WKSTS_WKIF_Pos) /*!< I2C_T::WKSTS: WKIF Mask */ + +/**@}*/ /* I2C_CONST */ +/**@}*/ /* end of I2C register group */ + + +/*---------------------- I2S Interface Controller -------------------------*/ +/** + @addtogroup I2S I2S Interface Controller(I2S) + Memory Mapped Structure for I2S Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 I2S Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |I2SEN |I2S Controller Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |TXEN |Transmit Enable Control + * | | |0 = Data transmission Disabled. + * | | |1 = Data transmission Enabled. + * |[2] |RXEN |Receive Enable Control + * | | |0 = Data receiving Disabled. + * | | |1 = Data receiving Enabled. + * |[3] |MUTE |Transmit Mute Enable Control + * | | |0 = Transmit data is shifted from buffer. + * | | |1 = Transmit zero data. + * |[4:5] |WDWIDTH |Word Width + * | | |00 = data is 8-bit. + * | | |01 = data is 16-bit. + * | | |10 = data is 24-bit. + * | | |11 = data is 32-bit. + * |[6] |MONO |Monaural Data Control + * | | |0 = Data is stereo format. + * | | |1 = Data is monaural format. + * | | |Note: when chip records data, only right channel data will be saved if monaural format is select. + * |[7] |FORMAT |Data Format Selection + * | | |If PCM=0, + * | | |0 = I2S data format. + * | | |1 = MSB justified data format. + * | | |If PCM=1, + * | | |0 = PCM mode A. + * | | |1 = PCM mode B. + * |[8] |SLAVE |Slave Mode Enable Control + * | | |0 = Master mode. + * | | |1 = Slave mode. + * | | |Note: I2S can operate as master or slave. + * | | |For Master mode, I2S_BCLK and I2S_LRCLK pins are output mode and send bit clock from NuMicro(TM) + * | | |NUC442/NUC472 series to Audio CODEC chip. + * | | |In Slave mode, I2S_BCLK and I2S_LRCLK pins are input mode and I2S_BCLK and I2S_LRCLK signals are received from outer Audio CODEC chip. + * |[9:11] |TXTH |Transmit FIFO Threshold Level + * | | |000 = 0 word data in transmit FIFO. + * | | |001 = 1 word data in transmit FIFO. + * | | |010 = 2 words data in transmit FIFO. + * | | |011 = 3 words data in transmit FIFO. + * | | |100 = 4 words data in transmit FIFO. + * | | |101 = 5 words data in transmit FIFO. + * | | |110 = 6 words data in transmit FIFO. + * | | |111 = 7 words data in transmit FIFO. + * | | |Note: If remain data word(s) in transmit FIFO is the same or less than threshold level then TXTHF flag is set. + * |[12:14] |RXTH |Receive FIFO Threshold Level + * | | |000 = 1 word data in receive FIFO. + * | | |001 = 2 word data in receive FIFO. + * | | |010 = 3 word data in receive FIFO. + * | | |011 = 4 word data in receive FIFO. + * | | |100 = 5 word data in receive FIFO. + * | | |101 = 6 word data in receive FIFO. + * | | |110 = 7 word data in receive FIFO. + * | | |111 = 8 word data in receive FIFO. + * | | |Note: When received data word(s) in buffer is equal to or higher than threshold level then RXTHF flag is set. + * |[15] |MCLKEN |Master Clock Enable Control + * | | |0 = Master clock Disabled. + * | | |1 = Master clock Enabled. + * | | |Note: If the external crystal clock in NuMicro(TM) NUC442/NUC472 series is frequency 2*N*256fs, software can program MCLK_DIV(I2S_CLK[5:0]) to get 256fs clock to audio codec chip. + * |[16] |RZCEN |Right Channel Zero-Cross Detection Enable Control + * | | |0 = Right channel zero-cross detect Disabled. + * | | |1 = Right channel zero-cross detect Enabled. + * | | |Note1: If this bit is set to 1, when right channel data sign bit change or next shift data bits are all zero then RZCF(I2S_STATUS[22]) flag is set to 1. + * | | |Note2: If RZCF Flag is set to 1, the right channel will be mute. + * |[17] |LZCEN |Left Channel Zero-Cross Detect Enable Control + * | | |0 = Left channel zero-cross detect Disabled. + * | | |1 = Left channel zero-cross detect Enabled. + * | | |Note1: If this bit is set to 1, when left channel data sign bit change or next shift data bits are all zero then LZCF(I2S_STATUS[23]) flag is set to 1. + * | | |Note2: If LZCF Flag is set to 1, the left channel will be mute. + * |[18] |TXCLR |Clear Transmit FIFO + * | | |0 = No Effect. + * | | |1 = Clear TX FIFO. + * | | |Note1: Write 1 to clear transmit FIFO, internal pointer is reset to FIFO start point, and TXCNT(I2S_STATUS[31:28]) returns 0 and transmit FIFO becomes empty but data in transmit FIFO is not changed. + * | | |Note2: This bit is clear by hardware automatically, read it return zero. + * |[19] |RXCLR |Clear Receive FIFO + * | | |0 = No Effect. + * | | |1 = Clear RX FIFO. + * | | |Note1: Write 1 to clear receive FIFO, internal pointer is reset to FIFO start point, and RXCNT (I2S_STATUS[27:24]) returns 0 and receive FIFO becomes empty. + * | | |Note2: This bit is cleared by hardware automatically, read it return zero. + * |[20] |TXPDMAEN |Transmit DMA Enable Control + * | | |0 = TX DMA Disabled. + * | | |1 = TX DMA Enabled. + * | | |Note: When TX DMA is enables, I2S request DMA to transfer data from SRAM to transmit FIFO if FIFO is not full. + * |[21] |RXPDMAEN |Receive DMA Enable Control + * | | |0 = RX DMA Disabled. + * | | |1 = RX DMA Enabled. + * | | |Note: When RX DMA is enabled, I2S requests DMA to transfer data from receive FIFO to SRAM if FIFO is not empty. + * |[23] |RXLCH |Receive Left Channel Enable Control + * | | |0 = Receives right channel data when monaural format is selected. + * | | |1 = Receives left channel data when monaural format is selected. + * | | |Note: When monaural format is selected (MONO = 1), I2S will receive right channel data if RXLCH is set to 0, and receive left channel data if RXLCH is set to 1. + * |[24] |PCMEN |PCM Interface Enable Control + * | | |0 = I2S Interface. + * | | |1 = PCM Interface. + */ + __IO uint32_t CTL; + + /** + * CLKDIV + * =================================================================================================== + * Offset: 0x04 I2S Clock Divider Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |MCLKDIV |Master Clock Divider + * | | |If chip external crystal frequency is (2xMCLKDIV)*256fs then software can program these bits to generate 256fs clock frequency to audio codec chip. + * | | |If MCLKDIV is set to 0, MCLK is the same as external clock input. + * | | |For example, sampling rate is 24 kHz and chip external crystal clock is 12.288 MHz, set MCLKDIV = 1. + * | | |F_MCLK = F_I2SCLK/(2x(MCLKDIV)) (When MCLKDIV is >= 1 ). + * | | |F_MCLK = F_I2SCLK (When MCLKDIV is set to 0 ). + * | | |Note: F_MCLK is the frequency of MCLK, and F_i2SCLK is the frequency of the I2S_CLK + * |[8:16] |BCLKDIV |Bit Clock Divider + * | | |If I2S operates in Master mode, bit clock is provided by the NuMicro(TM) NUC442/NUC472 series. + * | | |Software can program these bits to generate sampling rate clock frequency. + * | | |F_BCLK= F_I2SCLK / (2*(BCLKDIV + 1)). + * | | |Note: F_BCLK is the frequency of BCLK and F_I2SCLK is the frequency of I2S_CLK + */ + __IO uint32_t CLKDIV; + + /** + * IEN + * =================================================================================================== + * Offset: 0x08 I2S Interrupt Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXUDIEN |Receive FIFO Underflow Interrupt E Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: If software reads receive FIFO when it is empty then RXUDIF(I2S_STATUS[8]) flag is set to 1. + * |[1] |RXOVIEN |Receive FIFO Overflow Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: Interrupt occurs if this bit is set to 1 and RXOVIEN(I2S_STATUS[9]) flag is set to 1 + * |[2] |RXTHIEN |Receive FIFO Threshold Level Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: When data word in receive FIFO is equal or higher than RXTH(I2S_CTL[14:12]) and the RXTHF bit is set to 1. + * | | |If RXTHIEN bit is enabled, interrupt occur. + * |[8] |TXUDIEN |Transmit FIFO Underflow Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: Interrupt occur if this bit is set to 1 and TXUDIEN(I2S_STATUS[16]) flag is set to 1. + * |[9] |TXOVIEN |Transmit FIFO Overflow Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: Interrupt occurs if this bit is set to 1 and TXOVIEN(I2S_STATUS[17]) flag is set to 1 + * |[10] |TXTHIEN |Transmit FIFO Threshold Level Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: Interrupt occurs if this bit is set to 1 and data words in transmit FIFO is less than TXTH(I2S_CTL[11:9]). + * |[11] |RZCIEN |Right Channel Zero-Cross Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: Interrupt occurs if this bit is set to 1 and right channel zero-cross + * |[12] |LZCIEN |Left Channel Zero-Cross Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: Interrupt occurs if this bit is set to 1 and left channel zero-cross + */ + __IO uint32_t IEN; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x0C I2S Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |I2SIF |I2S Interrupt Flag (Read Only) + * | | |0 = No I2S interrupt. + * | | |1 = I2S interrupt. + * | | |Note: It is wire-OR of TXIF and RXIF bits. + * |[1] |RXIF |I2S Receive Interrupt (Read Only) + * | | |0 = No receive interrupt. + * | | |1 = Receive interrupt. + * |[2] |TXIF |I2S Transmit Interrupt (Read Only) + * | | |0 = No transmit interrupt. + * | | |1 = Transmit interrupt. + * |[3] |RIGHT |Right Channel (Read Only) + * | | |0 = Left channel. + * | | |1 = Right channel. + * | | |Note: This bit indicate current transmit data is belong to right channel + * |[8] |RXUDIF |Receive FIFO Underflow Flag + * | | |0 = No underflow occur. + * | | |1 = Underflow occur. + * | | |Note1: When receive FIFO is empty, and software reads the receive FIFO again. + * | | |This bit will be set to 1, and it indicates underflow situation occurs. + * | | |Note2: Write 1 to clear this bit to zero + * |[9] |RXOVIF |Receive FIFO Overflow Flag + * | | |0 = No overflow occur. + * | | |1 = Overflow occur. + * | | |Note1: When receive FIFO is full and receive hardware attempt write to data into receive FIFO then this bit is set to 1, data in 1st buffer is overwrote. + * | | |Note2: Write 1 to clear this bit to 0. + * |[10] |RXTHIF |Receive FIFO Threshold Flag (Read Only) + * | | |0 = Data word(s) in FIFO is lower than threshold level. + * | | |1 = Data word(s) in FIFO is equal or higher than threshold level. + * | | |Note: When data word(s) in receive FIFO is equal or higher than threshold value set in RXTH(I2S_CTL[14:12]) the RXTHIF bit becomes to 1. + * | | |It keeps at 1 till RXCNT less than RXTH after software read RXFIFO register. + * |[11] |RXFULL |Receive FIFO Full (Read Only) + * | | |0 = Not full. + * | | |1 = Full. + * | | |Note: This bit reflects data words number in receive FIFO is 8. + * |[12] |RXEMPTY |Receive FIFO Empty (Read Only) + * | | |0 = Not empty. + * | | |1 = Empty. + * | | |Note: This bit reflects data words number in receive FIFO is zero + * |[16] |TXUDIF |Transmit FIFO Underflow Flag + * | | |0 = No underflow. + * | | |1 = Underflow. + * | | |Note1: When transmit FIFO is empty and shift logic hardware read data from data FIFO causes this set to 1. + * | | |Note2: Write 1 to clear this bit to 0. + * |[17] |TXOVIF |Transmit FIFO Overflow Flag + * | | |0 = No overflow. + * | | |1 = Overflow. + * | | |Note1: Write data to transmit FIFO when it is full and this bit set to 1 + * | | |Note2: Write 1 to clear this bit to 0. + * |[18] |TXTHIF |Transmit FIFO Threshold Flag (Read Only) + * | | |0 = Data word(s) in FIFO is higher than threshold level. + * | | |1 = Data word(s) in FIFO is equal or lower than threshold level. + * | | |Note: When data word(s) in transmit FIFO is equal or lower than threshold value set in TXTH(I2S_CTL[11:9]) the TXTHIF bit becomes to 1. + * | | |It keeps at 1 till TXCNT is higher than TXTH after software write TXFIFO register. + * |[19] |TXFULL |Transmit FIFO Full (Read Only) + * | | |This bit reflect data word number in transmit FIFO is 8 + * | | |0 = Not full. + * | | |1 = Full. + * |[20] |TXEMPTY |Transmit FIFO Empty (Read Only) + * | | |This bit reflect data word number in transmit FIFO is zero + * | | |0 = Not empty. + * | | |1 = Empty. + * |[21] |TXBUSY |Transmit Busy (Read Only) + * | | |0 = Transmit shift buffer is empty. + * | | |1 = Transmit shift buffer is busy. + * | | |Note: This bit is cleared to 0 when all data in transmit FIFO and shift buffer is shifted out. + * | | |And set to 1 when 1st data is load to shift buffer. + * |[22] |RZCIF |Right Channel Zero-Cross Flag + * | | |It indicates right channel next sample data sign bit is changed or all data bits are zero. + * | | |0 = No zero-cross. + * | | |1 = Right channel zero-cross is detected. + * | | |Note: Write 1 to clear this bit to 0. + * |[23] |LZCIF |Left Channel Zero-Cross Flag + * | | |It indicates left channel next sample data sign bit is changed or all data bits are zero. + * | | |0 = No zero-cross. + * | | |1 = Left channel zero-cross is detected. + * | | |Note: Write 1 to clear this bit to 0. + * |[24:27] |RXCNT |Receive FIFO Level (Read Only) + * | | |These bits indicate word number in receive FIFO + * | | |0000 = No data. + * | | |0001 = 1 word in receive FIFO. + * | | |.... + * | | |1000 = 8 words in receive FIFO. + * |[28:31] |TXCNT |Transmit FIFO Level (Read Only) + * | | |These bits indicate word number in transmit FIFO + * | | |0000 = No data. + * | | |0001 = 1 word in transmit FIFO. + * | | |.... + * | | |1000 = 8 words in transmit FIFO. + */ + __IO uint32_t STATUS; + + /** + * TX + * =================================================================================================== + * Offset: 0x10 I2S Transmit FIFO Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |TX |Transmit FIFO Bits + * | | |I2S contains 8 words (8x32 bit) data buffer for data transmit. + * | | |Write data to this register to prepare data for transmit. + * | | |The remaining word number is indicated by TXCNT(I2S_STATUS[31:28]). + */ + __O uint32_t TX; + + /** + * RX + * =================================================================================================== + * Offset: 0x14 I2S Receive FIFO Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |RX |Receive FIFO Bits + * | | |I2S contains 8 words (8x32 bit) data buffer for data receive. + * | | |Read this register to get data in FIFO. + * | | |The remaining data word number is indicated by RXCNT(I2S_STATUS[27:24]). + */ + __I uint32_t RX; + +} I2S_T; + +/** + @addtogroup I2S_CONST I2S Bit Field Definition + Constant Definitions for I2S Controller +@{ */ + +#define I2S_CTL_I2SEN_Pos (0) /*!< I2S_T::CTL: I2SEN Position */ +#define I2S_CTL_I2SEN_Msk (0x1ul << I2S_CTL_I2SEN_Pos) /*!< I2S_T::CTL: I2SEN Mask */ + +#define I2S_CTL_TXEN_Pos (1) /*!< I2S_T::CTL: TXEN Position */ +#define I2S_CTL_TXEN_Msk (0x1ul << I2S_CTL_TXEN_Pos) /*!< I2S_T::CTL: TXEN Mask */ + +#define I2S_CTL_RXEN_Pos (2) /*!< I2S_T::CTL: RXEN Position */ +#define I2S_CTL_RXEN_Msk (0x1ul << I2S_CTL_RXEN_Pos) /*!< I2S_T::CTL: RXEN Mask */ + +#define I2S_CTL_MUTE_Pos (3) /*!< I2S_T::CTL: MUTE Position */ +#define I2S_CTL_MUTE_Msk (0x1ul << I2S_CTL_MUTE_Pos) /*!< I2S_T::CTL: MUTE Mask */ + +#define I2S_CTL_WDWIDTH_Pos (4) /*!< I2S_T::CTL: WDWIDTH Position */ +#define I2S_CTL_WDWIDTH_Msk (0x3ul << I2S_CTL_WDWIDTH_Pos) /*!< I2S_T::CTL: WDWIDTH Mask */ + +#define I2S_CTL_MONO_Pos (6) /*!< I2S_T::CTL: MONO Position */ +#define I2S_CTL_MONO_Msk (0x1ul << I2S_CTL_MONO_Pos) /*!< I2S_T::CTL: MONO Mask */ + +#define I2S_CTL_FORMAT_Pos (7) /*!< I2S_T::CTL: FORMAT Position */ +#define I2S_CTL_FORMAT_Msk (0x1ul << I2S_CTL_FORMAT_Pos) /*!< I2S_T::CTL: FORMAT Mask */ + +#define I2S_CTL_SLAVE_Pos (8) /*!< I2S_T::CTL: SLAVE Position */ +#define I2S_CTL_SLAVE_Msk (0x1ul << I2S_CTL_SLAVE_Pos) /*!< I2S_T::CTL: SLAVE Mask */ + +#define I2S_CTL_TXTH_Pos (9) /*!< I2S_T::CTL: TXTH Position */ +#define I2S_CTL_TXTH_Msk (0x7ul << I2S_CTL_TXTH_Pos) /*!< I2S_T::CTL: TXTH Mask */ + +#define I2S_CTL_RXTH_Pos (12) /*!< I2S_T::CTL: RXTH Position */ +#define I2S_CTL_RXTH_Msk (0x7ul << I2S_CTL_RXTH_Pos) /*!< I2S_T::CTL: RXTH Mask */ + +#define I2S_CTL_MCLKEN_Pos (15) /*!< I2S_T::CTL: MCLKEN Position */ +#define I2S_CTL_MCLKEN_Msk (0x1ul << I2S_CTL_MCLKEN_Pos) /*!< I2S_T::CTL: MCLKEN Mask */ + +#define I2S_CTL_RZCEN_Pos (16) /*!< I2S_T::CTL: RZCEN Position */ +#define I2S_CTL_RZCEN_Msk (0x1ul << I2S_CTL_RZCEN_Pos) /*!< I2S_T::CTL: RZCEN Mask */ + +#define I2S_CTL_LZCEN_Pos (17) /*!< I2S_T::CTL: LZCEN Position */ +#define I2S_CTL_LZCEN_Msk (0x1ul << I2S_CTL_LZCEN_Pos) /*!< I2S_T::CTL: LZCEN Mask */ + +#define I2S_CTL_TXCLR_Pos (18) /*!< I2S_T::CTL: TXCLR Position */ +#define I2S_CTL_TXCLR_Msk (0x1ul << I2S_CTL_TXCLR_Pos) /*!< I2S_T::CTL: TXCLR Mask */ + +#define I2S_CTL_RXCLR_Pos (19) /*!< I2S_T::CTL: RXCLR Position */ +#define I2S_CTL_RXCLR_Msk (0x1ul << I2S_CTL_RXCLR_Pos) /*!< I2S_T::CTL: RXCLR Mask */ + +#define I2S_CTL_TXPDMAEN_Pos (20) /*!< I2S_T::CTL: TXPDMAEN Position */ +#define I2S_CTL_TXPDMAEN_Msk (0x1ul << I2S_CTL_TXPDMAEN_Pos) /*!< I2S_T::CTL: TXPDMAEN Mask */ + +#define I2S_CTL_RXPDMAEN_Pos (21) /*!< I2S_T::CTL: RXPDMAEN Position */ +#define I2S_CTL_RXPDMAEN_Msk (0x1ul << I2S_CTL_RXPDMAEN_Pos) /*!< I2S_T::CTL: RXPDMAEN Mask */ + +#define I2S_CTL_RXLCH_Pos (23) /*!< I2S_T::CTL: RXLCH Position */ +#define I2S_CTL_RXLCH_Msk (0x1ul << I2S_CTL_RXLCH_Pos) /*!< I2S_T::CTL: RXLCH Mask */ + +#define I2S_CTL_PCMEN_Pos (24) /*!< I2S_T::CTL: PCMEN Position */ +#define I2S_CTL_PCMEN_Msk (0x1ul << I2S_CTL_PCMEN_Pos) /*!< I2S_T::CTL: PCMEN Mask */ + +#define I2S_CLKDIV_MCLKDIV_Pos (0) /*!< I2S_T::CLKDIV: MCLKDIV Position */ +#define I2S_CLKDIV_MCLKDIV_Msk (0x3ful << I2S_CLKDIV_MCLKDIV_Pos) /*!< I2S_T::CLKDIV: MCLKDIV Mask */ + +#define I2S_CLKDIV_BCLKDIV_Pos (8) /*!< I2S_T::CLKDIV: BCLKDIV Position */ +#define I2S_CLKDIV_BCLKDIV_Msk (0x1fful << I2S_CLKDIV_BCLKDIV_Pos) /*!< I2S_T::CLKDIV: BCLKDIV Mask */ + +#define I2S_IEN_RXUDIEN_Pos (0) /*!< I2S_T::IEN: RXUDIEN Position */ +#define I2S_IEN_RXUDIEN_Msk (0x1ul << I2S_IEN_RXUDIEN_Pos) /*!< I2S_T::IEN: RXUDIEN Mask */ + +#define I2S_IEN_RXOVIEN_Pos (1) /*!< I2S_T::IEN: RXOVIEN Position */ +#define I2S_IEN_RXOVIEN_Msk (0x1ul << I2S_IEN_RXOVIEN_Pos) /*!< I2S_T::IEN: RXOVIEN Mask */ + +#define I2S_IEN_RXTHIEN_Pos (2) /*!< I2S_T::IEN: RXTHIEN Position */ +#define I2S_IEN_RXTHIEN_Msk (0x1ul << I2S_IEN_RXTHIEN_Pos) /*!< I2S_T::IEN: RXTHIEN Mask */ + +#define I2S_IEN_TXUDIEN_Pos (8) /*!< I2S_T::IEN: TXUDIEN Position */ +#define I2S_IEN_TXUDIEN_Msk (0x1ul << I2S_IEN_TXUDIEN_Pos) /*!< I2S_T::IEN: TXUDIEN Mask */ + +#define I2S_IEN_TXOVIEN_Pos (9) /*!< I2S_T::IEN: TXOVIEN Position */ +#define I2S_IEN_TXOVIEN_Msk (0x1ul << I2S_IEN_TXOVIEN_Pos) /*!< I2S_T::IEN: TXOVIEN Mask */ + +#define I2S_IEN_TXTHIEN_Pos (10) /*!< I2S_T::IEN: TXTHIEN Position */ +#define I2S_IEN_TXTHIEN_Msk (0x1ul << I2S_IEN_TXTHIEN_Pos) /*!< I2S_T::IEN: TXTHIEN Mask */ + +#define I2S_IEN_RZCIEN_Pos (11) /*!< I2S_T::IEN: RZCIEN Position */ +#define I2S_IEN_RZCIEN_Msk (0x1ul << I2S_IEN_RZCIEN_Pos) /*!< I2S_T::IEN: RZCIEN Mask */ + +#define I2S_IEN_LZCIEN_Pos (12) /*!< I2S_T::IEN: LZCIEN Position */ +#define I2S_IEN_LZCIEN_Msk (0x1ul << I2S_IEN_LZCIEN_Pos) /*!< I2S_T::IEN: LZCIEN Mask */ + +#define I2S_STATUS_I2SIF_Pos (0) /*!< I2S_T::STATUS: I2SIF Position */ +#define I2S_STATUS_I2SIF_Msk (0x1ul << I2S_STATUS_I2SIF_Pos) /*!< I2S_T::STATUS: I2SIF Mask */ + +#define I2S_STATUS_RXIF_Pos (1) /*!< I2S_T::STATUS: RXIF Position */ +#define I2S_STATUS_RXIF_Msk (0x1ul << I2S_STATUS_RXIF_Pos) /*!< I2S_T::STATUS: RXIF Mask */ + +#define I2S_STATUS_TXIF_Pos (2) /*!< I2S_T::STATUS: TXIF Position */ +#define I2S_STATUS_TXIF_Msk (0x1ul << I2S_STATUS_TXIF_Pos) /*!< I2S_T::STATUS: TXIF Mask */ + +#define I2S_STATUS_RIGHT_Pos (3) /*!< I2S_T::STATUS: RIGHT Position */ +#define I2S_STATUS_RIGHT_Msk (0x1ul << I2S_STATUS_RIGHT_Pos) /*!< I2S_T::STATUS: RIGHT Mask */ + +#define I2S_STATUS_RXUDIF_Pos (8) /*!< I2S_T::STATUS: RXUDIF Position */ +#define I2S_STATUS_RXUDIF_Msk (0x1ul << I2S_STATUS_RXUDIF_Pos) /*!< I2S_T::STATUS: RXUDIF Mask */ + +#define I2S_STATUS_RXOVIF_Pos (9) /*!< I2S_T::STATUS: RXOVIF Position */ +#define I2S_STATUS_RXOVIF_Msk (0x1ul << I2S_STATUS_RXOVIF_Pos) /*!< I2S_T::STATUS: RXOVIF Mask */ + +#define I2S_STATUS_RXTHIF_Pos (10) /*!< I2S_T::STATUS: RXTHIF Position */ +#define I2S_STATUS_RXTHIF_Msk (0x1ul << I2S_STATUS_RXTHIF_Pos) /*!< I2S_T::STATUS: RXTHIF Mask */ + +#define I2S_STATUS_RXFULL_Pos (11) /*!< I2S_T::STATUS: RXFULL Position */ +#define I2S_STATUS_RXFULL_Msk (0x1ul << I2S_STATUS_RXFULL_Pos) /*!< I2S_T::STATUS: RXFULL Mask */ + +#define I2S_STATUS_RXEMPTY_Pos (12) /*!< I2S_T::STATUS: RXEMPTY Position */ +#define I2S_STATUS_RXEMPTY_Msk (0x1ul << I2S_STATUS_RXEMPTY_Pos) /*!< I2S_T::STATUS: RXEMPTY Mask */ + +#define I2S_STATUS_TXUDIF_Pos (16) /*!< I2S_T::STATUS: TXUDIF Position */ +#define I2S_STATUS_TXUDIF_Msk (0x1ul << I2S_STATUS_TXUDIF_Pos) /*!< I2S_T::STATUS: TXUDIF Mask */ + +#define I2S_STATUS_TXOVIF_Pos (17) /*!< I2S_T::STATUS: TXOVIF Position */ +#define I2S_STATUS_TXOVIF_Msk (0x1ul << I2S_STATUS_TXOVIF_Pos) /*!< I2S_T::STATUS: TXOVIF Mask */ + +#define I2S_STATUS_TXTHIF_Pos (18) /*!< I2S_T::STATUS: TXTHIF Position */ +#define I2S_STATUS_TXTHIF_Msk (0x1ul << I2S_STATUS_TXTHIF_Pos) /*!< I2S_T::STATUS: TXTHIF Mask */ + +#define I2S_STATUS_TXFULL_Pos (19) /*!< I2S_T::STATUS: TXFULL Position */ +#define I2S_STATUS_TXFULL_Msk (0x1ul << I2S_STATUS_TXFULL_Pos) /*!< I2S_T::STATUS: TXFULL Mask */ + +#define I2S_STATUS_TXEMPTY_Pos (20) /*!< I2S_T::STATUS: TXEMPTY Position */ +#define I2S_STATUS_TXEMPTY_Msk (0x1ul << I2S_STATUS_TXEMPTY_Pos) /*!< I2S_T::STATUS: TXEMPTY Mask */ + +#define I2S_STATUS_TXBUSY_Pos (21) /*!< I2S_T::STATUS: TXBUSY Position */ +#define I2S_STATUS_TXBUSY_Msk (0x1ul << I2S_STATUS_TXBUSY_Pos) /*!< I2S_T::STATUS: TXBUSY Mask */ + +#define I2S_STATUS_RZCIF_Pos (22) /*!< I2S_T::STATUS: RZCIF Position */ +#define I2S_STATUS_RZCIF_Msk (0x1ul << I2S_STATUS_RZCIF_Pos) /*!< I2S_T::STATUS: RZCIF Mask */ + +#define I2S_STATUS_LZCIF_Pos (23) /*!< I2S_T::STATUS: LZCIF Position */ +#define I2S_STATUS_LZCIF_Msk (0x1ul << I2S_STATUS_LZCIF_Pos) /*!< I2S_T::STATUS: LZCIF Mask */ + +#define I2S_STATUS_RXCNT_Pos (24) /*!< I2S_T::STATUS: RXCNT Position */ +#define I2S_STATUS_RXCNT_Msk (0xful << I2S_STATUS_RXCNT_Pos) /*!< I2S_T::STATUS: RXCNT Mask */ + +#define I2S_STATUS_TXCNT_Pos (28) /*!< I2S_T::STATUS: TXCNT Position */ +#define I2S_STATUS_TXCNT_Msk (0xful << I2S_STATUS_TXCNT_Pos) /*!< I2S_T::STATUS: TXCNT Mask */ + +#define I2S_TX_TX_Pos (0) /*!< I2S_T::TX: TX Position */ +#define I2S_TX_TX_Msk (0xfffffffful << I2S_TX_TX_Pos) /*!< I2S_T::TX: TX Mask */ + +#define I2S_RX_RX_Pos (0) /*!< I2S_T::RX: RX Position */ +#define I2S_RX_RX_Msk (0xfffffffful << I2S_RX_RX_Pos) /*!< I2S_T::RX: RX Mask */ + +/**@}*/ /* I2S_CONST */ +/**@}*/ /* end of I2S register group */ + + +/*---------------------- OP Amplifier -------------------------*/ +/** + @addtogroup OPA OP Amplifier(OPA) + Memory Mapped Structure for OPA Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 OP Amplifier Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |OPEN0 |OP Amplifier 0 Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |Note: OP Amplifier 0 output needs wait stable 20us[MS1] after OPEN0 is first set. + * | | |[MS1]alpha test + * |[1] |OPEN1 |OP Amplifier 1 Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |Note: OP Amplifier 1 output needs wait stable 20us[MS1] after OPEN1 is first set. + * | | |[MS1]alpha test + * |[4] |OPSMTEN0 |OP Amplifier 0 Schmitt Trigger Non-Inverting Buffer Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |OPSMTEN1 |OP Amplifier 1 Schmitt Trigger Non-Inverting Buffer Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[8] |OPAIE0 |OP Amplifier 0 Schmitt Trigger Digital Output Interrupt Enable Control + * | | |0 = OP Amplifier 0 digital output interrupt function Disabled. + * | | |1 = OP Amplifier 0 digital output interrupt function Enabled. + * | | |The OPDF0 interrupt flag is set by hardware whenever the OP amplifier 0 Schmitt trigger non-inverting buffer digital output changes state, in the meanwhile, if OPAIE0 is set to 1, a comparator interrupt request is generated. + * |[9] |OPAIE1 |OP Amplifier 1 Schmitt Trigger Digital Output Interrupt Enable Control + * | | |0 = OP Amplifier 1 digital output interrupt function Disabled. + * | | |1 = OP Amplifier 1 digital output interrupt function Enabled. + * | | |OPDF1 interrupt flag is set by hardware whenever the OP amplifier 1 Schmitt trigger non-inverting buffer digital output changes state, in the meanwhile, if OPAIE1 is set to 1, a comparator interrupt request is generated. + */ + __IO uint32_t CTL; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x04 OP Amplifier Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |OPDO0 |OP Amplifier 0 Digital Output + * | | |Synchronized to the APB clock to allow reading by software. + * | | |Cleared when the Schmitt trigger buffer is disabled (OPSMTEN0 = 0). + * |[1] |OPDO1 |OP Amplifier 1 Digital Output + * | | |Synchronized to the APB clock to allow reading by software. + * | | |Cleared when the Schmitt trigger buffer is disabled (OPSMTEN1 = 0). + * |[4] |OPDF0 |OP Amplifier 0 Schmitt Trigger Digital Output Interrupt Flag + * | | |OPDF0 interrupt flag is set by hardware whenever the OP amplifier 0 Schmitt trigger non-inverting buffer digital output changes state. + * | | |This bit is cleared by writing 1 to it. + * |[5] |OPDF1 |OP Amplifier 1 Schmitt Trigger Digital Output Interrupt Flag + * | | |OPDF1 interrupt flag is set by hardware whenever the OP amplifier 1 Schmitt trigger non-inverting buffer digital output changes state. + * | | |This bit is cleared by writing 1 to it. + */ + __IO uint32_t STATUS; + +} OPA_T; + +/** + @addtogroup OPA_CONST OPA Bit Field Definition + Constant Definitions for OPA Controller +@{ */ + +#define OPA_CTL_OPEN0_Pos (0) /*!< OPA_T::CTL: OPEN0 Position */ +#define OPA_CTL_OPEN0_Msk (0x1ul << OPA_CTL_OPEN0_Pos) /*!< OPA_T::CTL: OPEN0 Mask */ + +#define OPA_CTL_OPEN1_Pos (1) /*!< OPA_T::CTL: OPEN1 Position */ +#define OPA_CTL_OPEN1_Msk (0x1ul << OPA_CTL_OPEN1_Pos) /*!< OPA_T::CTL: OPEN1 Mask */ + +#define OPA_CTL_OPSMTEN0_Pos (4) /*!< OPA_T::CTL: OPSMTEN0 Position */ +#define OPA_CTL_OPSMTEN0_Msk (0x1ul << OPA_CTL_OPSMTEN0_Pos) /*!< OPA_T::CTL: OPSMTEN0 Mask */ + +#define OPA_CTL_OPSMTEN1_Pos (5) /*!< OPA_T::CTL: OPSMTEN1 Position */ +#define OPA_CTL_OPSMTEN1_Msk (0x1ul << OPA_CTL_OPSMTEN1_Pos) /*!< OPA_T::CTL: OPSMTEN1 Mask */ + +#define OPA_CTL_OPAIE0_Pos (8) /*!< OPA_T::CTL: OPAIE0 Position */ +#define OPA_CTL_OPAIE0_Msk (0x1ul << OPA_CTL_OPAIE0_Pos) /*!< OPA_T::CTL: OPAIE0 Mask */ + +#define OPA_CTL_OPAIE1_Pos (9) /*!< OPA_T::CTL: OPAIE1 Position */ +#define OPA_CTL_OPAIE1_Msk (0x1ul << OPA_CTL_OPAIE1_Pos) /*!< OPA_T::CTL: OPAIE1 Mask */ + +#define OPA_STATUS_OPDO0_Pos (0) /*!< OPA_T::STATUS: OPDO0 Position */ +#define OPA_STATUS_OPDO0_Msk (0x1ul << OPA_STATUS_OPDO0_Pos) /*!< OPA_T::STATUS: OPDO0 Mask */ + +#define OPA_STATUS_OPDO1_Pos (1) /*!< OPA_T::STATUS: OPDO1 Position */ +#define OPA_STATUS_OPDO1_Msk (0x1ul << OPA_STATUS_OPDO1_Pos) /*!< OPA_T::STATUS: OPDO1 Mask */ + +#define OPA_STATUS_OPDF0_Pos (4) /*!< OPA_T::STATUS: OPDF0 Position */ +#define OPA_STATUS_OPDF0_Msk (0x1ul << OPA_STATUS_OPDF0_Pos) /*!< OPA_T::STATUS: OPDF0 Mask */ + +#define OPA_STATUS_OPDF1_Pos (5) /*!< OPA_T::STATUS: OPDF1 Position */ +#define OPA_STATUS_OPDF1_Msk (0x1ul << OPA_STATUS_OPDF1_Pos) /*!< OPA_T::STATUS: OPDF1 Mask */ + +/**@}*/ /* OPA_CONST */ +/**@}*/ /* end of OPA register group */ + + +/*---------------------- USB On-The-Go Controller -------------------------*/ +/** + @addtogroup OTG USB On-The-Go Controller(OTG) + Memory Mapped Structure for OTG Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 OTG Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |VBUSDROP |Drop The VUSB Bus + * | | |If user application running on this OTG A-device wants to conserve power consumption, set this bit to high When set this bit to TRUE, BUSREQ shall be cleared as well. + * | | |0 = Did Not drop the VBUS and keep going on USB data transfers. + * | | |1 = Drop the VBUS to conserve power consumption. + * |[1] |BUSREQ |OTG A-Device Bus Request + * | | |If user application of an OTG A-device wants to do data transfers via USB bus, set this bit to high Otherwise if user application won't use the bus any more, set this bit to low. + * | | |This bit will be automatically cleared if VBUSDROP bit is set to TRUE. + * |[2] |HNPREQEN |OTG B-Device HNP Enable/Request + * | | |Set this bit to TRUE after the OTG A-device successfully sends a SetFeature(b_hnp_enable) command to the OTG B-device This bit will be cleared automatically when a bus reset or SESS_VLD goes from TRUE to FALSE. + * |[4] |OTGEN |OTG Function Enable Control + * | | |If USB is configured as OTG device, this bit must set high. + * | | |0= OTG function Disabled. + * | | |1 = OTG function Enabled. + * |[7] |PDEVCKON |Force OTG PHY Output Clock To USB Device + * | | |If software configures OTG controller as OTG device and OTG device as A-device, OTG controller will output OTG PHY clock (30 MHz) to USB device only when OTG device as A-peripheral. + * | | |If software needs to configure USB device before role change (from A-Host to A-Peripheral), software can set this bit high to output OTG PHY clock to USB device. + * | | |0= USB device clock is available only when OTG device as a peripheral. + * | | |1 = Force output OTG PHY clock to USB device. + * |[8] |WKEN |OTG Wake-Up Enable Control + * | | |0= OTG ID pin status change wake-up Disabled. + * | | |1 = OTG ID pin status change wake-up Enabled. + */ + __IO uint32_t CTL; + + /** + * PHYCTL + * =================================================================================================== + * Offset: 0x04 OTG PHY Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SWPDEN |Software Control Pull-Down On Data Lines Enable Control + * | | |0 = Pull-down resistors on data lines is controlled by OTG control logic. + * | | |1 = Pull-down resistors on data lines is controlled by software. + * | | |Note: Software must set this bit high before controlling DPPDEN and DMPDEN. + * |[1] |DPPDEN |D+ Pull-Down Enable Control Set SWPDEN to TRUE before using this function + * | | |0 = 15 kOhm resistor pull-down on D+ pin Disabled. + * | | |1 = 15 kOhm resistor pull-down on D+ pin Enabled. + * |[2] |DMPDEN |D- Pull-Down Enable Control Set SWPDEN to TRUE before using this function + * | | |0 = 15 kOhm resistor pull-down on D- pin Disabled. + * | | |1 = 15 kOhm resistor pull-down on D- pin Enabled. + * |[5] |VBSTSPOL |Off-Chip USB VBUS Power Status Polarity + * | | |The polarity of off-chip USB VBUS LDO valid depends on the selected component. + * | | |This bit provides the inversed option of off-chip USB VBUS LDO valid. + * | | |0 = The polarity of off-chip USB VBUS LDO valid not inversed. + * | | |1 = The polarity of off-chip USB VBUS LDO valid inversed. + * |[6] |VBENPOL |Off-Chip USB VBUS Power Enable Polarity + * | | |The OTG controller will enable off-chip USB VBUS LDO to provide VBUS power when need. + * | | |The polarity of enabling off-chip BSU VBUS LDO (high active or low active) depends on the selected component. + * | | |This bit provides the inverse option of off-chip USB VBUS LDO enable. + * | | |0 = The polarity of enabling off-chip USB VBUS LDO from the OTG controller not inversed. + * | | |1 = The polarity of enabling off-chip USB VBUS LDO from the OTG controller inversed. + * |[7] |IDDETEN |ID Detection Enable + * | | |0 = Sampling on ID pin Enabled. + * | | |1 = Sampling on ID pin Disabled. + * |[8] |PHYCLK |PHY Input Clock Selection + * | | |0 = PHY input clock is12 MHz. + * | | |1 = PHY input clock is 24 MHz. + * |[9] |OTGPHYEN |OTG PHY Enable Control When Device Configured As OTG-Device + * | | |When device is configured as OTG-device, hardware will not enable OTG PHY automatically. + * | | |Software can set OTG_EN to enable OTG PHY. + * | | |0 = OTG PHY Disabled. + * | | |1 = OTG PHY Enabled. + */ + __IO uint32_t PHYCTL; + + /** + * INTEN + * =================================================================================================== + * Offset: 0x08 OTG Interrupt Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ROLECHGIEN|Role(Host Or Peripheral) Changed Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[1] |VBEIEN |VBUS Error Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: VBUS error means going to a_vbus_err state. Please refer to A-device state diagram in OTG spec. + * |[2] |SRPFIEN |SRP Fail Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[3] |HNPFIEN |HNP Fail Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[4] |GOIDLEIEN |OTG Device Goes IDLE State Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * | | |Note: Going to idle state means going to a_idle or b_idle state. + * | | |Please refer to A-device state diagram and B-device state diagram in OTG spec. + * |[5] |IDCHGIEN |IDSTS Changed Interrupt Enable + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[6] |PDEVIEN |Act As Peripheral Interrupt Enable Control + * | | |0 = This device as a peripheral interrupt Disabled. + * | | |1 = This device as a peripheral interrupt Enabled. + * |[7] |HOSTIEN |Act As Host Interrupt Enable Control + * | | |0= This device as a host interrupt Disabled. + * | | |1 = This device as a host interrupt Enabled. + * |[8] |BVLDCHGIEN|B-Device Session Valid Status Change (From High To Low Or From Low To High) Interrupt Enable Control + * | | |0 =Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[9] |AVLDCHGIEN|A-Device Session Valid Status Change (From High To Low Or From Low To High) Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[10] |VBCHGIEN |VBVALID Status Changed Interrupt Enable + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[11] |SECHGIEN |SESSEND Status Changed Interrupt Enable Control 0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + * |[13] |SRPDETIEN |SRP Detected Interrupt Enable Control + * | | |0 = Interrupt Disabled. + * | | |1 = Interrupt Enabled. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x0C OTG Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ROLECHGIF |OTG Role Change Interrupt Status + * | | |This flag is set when the role of an OTG device changed from a host to a peripheral, or changed from a peripheral to a host + * | | |Note: Write 1 to clear this flag. + * |[1] |VBEIF |VBUS Error Interrupt Status + * | | |This flag will be set in one of two conditions + * | | |l One case is that voltage on VBUS cannot reach a minimum valid threshold 4.4V within a maximum time of 100ms after OTG A device starting to drive. + * | | |l The other case is that the supplied VBUS drops below a minimum valid threshold due to the overcurrent condition. + * | | |Note: Write 1 to clear this flag and recover from the VBUS error state. + * |[2] |SRPFIF |SRP Fail Interrupt Status + * | | |After initiating SRP, an OTG B-device will wait at least TB_SRP_FAIL min, defined in OTG specification, for the OTG A-device respond This flag is set when the OTG B-device didn't get the response from the remote A-device to turn VBUS on and generate a bus reset. + * | | |Note: Write 1 to clear this flag. + * |[3] |HNPFIF |HNP Fail Interrupt Status + * | | |When A-device has granted B-device to be host and USB bus in SE0 state, this bit will be set in specified interval (b_ase0_brst_tmr, defined in OTG spec. + * | | |specification), A-device does not signal connect signal. + * | | |Note: Write 1 to clear this flag. + * |[4] |GOIDLEIF |OTG Device Goes IDLE Interrupt Status + * | | |Flag is set if the OTG device transfers from non-idle state to idle state. + * | | |The OTG device will be neither a host nor a peripheral. + * | | |0 = OTG device does not go back to idle state(a_idle or b_idle). + * | | |1 = OTG device go back to idle state(a_idle or b_idle). + * | | |Note: Write 1 to clear this flag. + * |[5] |IDCHGIF |ID State Change Interrupt Status + * | | |0 = IDSTS not toggled. + * | | |1 = IDSTS from high to low or from low to high. + * | | |Note1: OTG_CTL[BUSREQ] will be cleared when IDDIG is high. + * | | |Note2: Write 1 to clear this flag. + * |[6] |PDEVIF |Act As Peripheral Interrupt Status + * | | |0= This device does not act as a peripheral. + * | | |1 = This device acts as a peripheral. + * | | |Note: Write 1 to clear this flag. + * |[7] |HOSTIF |Act As Host Interrupt Status + * | | |0= This device does not act as a host. + * | | |1 = This device acts as a host. + * | | |Note: Write 1 to clear this flag. + * |[8] |BVLDCHGIF |B-Device Session Valid State Change Interrupt Status + * | | |0 = BVLD not toggled. + * | | |1 = BVLD from high to low or low to high. + * | | |Note: Write 1 to clear this status. + * |[9] |AVLDCHGIF |A-Device Session Valid State Change Interrupt Status + * | | |0 = AVLD not toggled. + * | | |1 = AVLD from high to low or low to high. + * | | |Note: Write 1 to clear this flag. + * |[10] |VBCHGIF |VBVALID State Change Interrupt Status + * | | |0 = VBUS_VLD not toggled. + * | | |1 = VBUSVLD from high to low or from low to high. + * | | |Note: Write 1 to clear this flag. + * |[11] |SECHGIF |SESSEND State Change Interrupt Status + * | | |0 = Session end not toggled. + * | | |1 = SESSEND from high to low or from low to high. + * | | |Note: Write 1 to clear this flag. + * |[13] |SRPDETIF |SRP Detected Interrupt Status + * | | |0 = SRP not detected. + * | | |1 = SRP detected. + * | | |Note: Write 1 to clear this status. + */ + __IO uint32_t INTSTS; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x10 Functional Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |OVERCUR |Over current Condition + * | | |The voltage on VBUS cannot reach a minimum VBUS valid threshold, 4.4V minimum, within a maximum time of 100ms after OTG A device starting to drive + * | | |0 = OTG A-device drives VBUS successfully. + * | | |1 = Over current condition occurred. + * |[1] |IDSTS |ID Pin State Of Mini-B/Micro-Plug + * | | |0 = Mini-A/Micro-A plug is attached. + * | | |1 = Mini-B/Micro-B plug is attached. + * |[2] |SESSEND |Session End Status + * | | |0 = VBUS > 0.8V. + * | | |1 = VBUS < 0.2V. + * |[3] |BVLID |B-Device Session Valid Status + * | | |0 = VBUS < 0.8V. + * | | |1 = VBUS > 4V. + * |[4] |AVLD |A-Device Session Valid Status + * | | |0 = VBUS < 0.8V. + * | | |1 = VBUS > 2V. + * |[5] |VBUSVLD |VBUS Valid Status + * | | |0 = VBUS < 4.4V. + * | | |1 = VBUS > 4.75V. + */ + __I uint32_t STATUS; + +} OTG_T; + +/** + @addtogroup OTG_CONST OTG Bit Field Definition + Constant Definitions for OTG Controller +@{ */ + +#define OTG_CTL_VBUSDROP_Pos (0) /*!< OTG_T::CTL: VBUSDROP Position */ +#define OTG_CTL_VBUSDROP_Msk (0x1ul << OTG_CTL_VBUSDROP_Pos) /*!< OTG_T::CTL: VBUSDROP Mask */ + +#define OTG_CTL_BUSREQ_Pos (1) /*!< OTG_T::CTL: BUSREQ Position */ +#define OTG_CTL_BUSREQ_Msk (0x1ul << OTG_CTL_BUSREQ_Pos) /*!< OTG_T::CTL: BUSREQ Mask */ + +#define OTG_CTL_HNPREQEN_Pos (2) /*!< OTG_T::CTL: HNPREQEN Position */ +#define OTG_CTL_HNPREQEN_Msk (0x1ul << OTG_CTL_HNPREQEN_Pos) /*!< OTG_T::CTL: HNPREQEN Mask */ + +#define OTG_CTL_OTGEN_Pos (4) /*!< OTG_T::CTL: OTGEN Position */ +#define OTG_CTL_OTGEN_Msk (0x1ul << OTG_CTL_OTGEN_Pos) /*!< OTG_T::CTL: OTGEN Mask */ + +#define OTG_CTL_PDEVCKON_Pos (7) /*!< OTG_T::CTL: PDEVCKON Position */ +#define OTG_CTL_PDEVCKON_Msk (0x1ul << OTG_CTL_PDEVCKON_Pos) /*!< OTG_T::CTL: PDEVCKON Mask */ + +#define OTG_CTL_WKEN_Pos (8) /*!< OTG_T::CTL: WKEN Position */ +#define OTG_CTL_WKEN_Msk (0x1ul << OTG_CTL_WKEN_Pos) /*!< OTG_T::CTL: WKEN Mask */ + +#define OTG_PHYCTL_SWPDEN_Pos (0) /*!< OTG_T::PHYCTL: SWPDEN Position */ +#define OTG_PHYCTL_SWPDEN_Msk (0x1ul << OTG_PHYCTL_SWPDEN_Pos) /*!< OTG_T::PHYCTL: SWPDEN Mask */ + +#define OTG_PHYCTL_DPPDEN_Pos (1) /*!< OTG_T::PHYCTL: DPPDEN Position */ +#define OTG_PHYCTL_DPPDEN_Msk (0x1ul << OTG_PHYCTL_DPPDEN_Pos) /*!< OTG_T::PHYCTL: DPPDEN Mask */ + +#define OTG_PHYCTL_DMPDEN_Pos (2) /*!< OTG_T::PHYCTL: DMPDEN Position */ +#define OTG_PHYCTL_DMPDEN_Msk (0x1ul << OTG_PHYCTL_DMPDEN_Pos) /*!< OTG_T::PHYCTL: DMPDEN Mask */ + +#define OTG_PHYCTL_VBSTSPOL_Pos (5) /*!< OTG_T::PHYCTL: VBSTSPOL Position */ +#define OTG_PHYCTL_VBSTSPOL_Msk (0x1ul << OTG_PHYCTL_VBSTSPOL_Pos) /*!< OTG_T::PHYCTL: VBSTSPOL Mask */ + +#define OTG_PHYCTL_VBENPOL_Pos (6) /*!< OTG_T::PHYCTL: VBUSPOL Position */ +#define OTG_PHYCTL_VBENPOL_Msk (0x1ul << OTG_PHYCTL_VBENPOL_Pos) /*!< OTG_T::PHYCTL: VBUSPOL Mask */ + +#define OTG_PHYCTL_IDDETEN_Pos (7) /*!< OTG_T::PHYCTL: IDDETEN Position */ +#define OTG_PHYCTL_IDDETEN_Msk (0x1ul << OTG_PHYCTL_IDDETEN_Pos) /*!< OTG_T::PHYCTL: IDDETEN Mask */ + +#define OTG_PHYCTL_PHYCLK_Pos (8) /*!< OTG_T::PHYCTL: PHYCLK Position */ +#define OTG_PHYCTL_PHYCLK_Msk (0x1ul << OTG_PHYCTL_PHYCLK_Pos) /*!< OTG_T::PHYCTL: PHYCLK Mask */ + +#define OTG_PHYCTL_OTGPHYEN_Pos (9) /*!< OTG_T::PHYCTL: OTGPHYEN Position */ +#define OTG_PHYCTL_OTGPHYEN_Msk (0x1ul << OTG_PHYCTL_OTGPHYEN_Pos) /*!< OTG_T::PHYCTL: OTGPHYEN Mask */ + +#define OTG_INTEN_ROLECHGIEN_Pos (0) /*!< OTG_T::INTEN: ROLECHGIEN Position */ +#define OTG_INTEN_ROLECHGIEN_Msk (0x1ul << OTG_INTEN_ROLECHGIEN_Pos) /*!< OTG_T::INTEN: ROLECHGIEN Mask */ + +#define OTG_INTEN_VBEIEN_Pos (1) /*!< OTG_T::INTEN: VBEIEN Position */ +#define OTG_INTEN_VBEIEN_Msk (0x1ul << OTG_INTEN_VBEIEN_Pos) /*!< OTG_T::INTEN: VBEIEN Mask */ + +#define OTG_INTEN_SRPFIEN_Pos (2) /*!< OTG_T::INTEN: SRPFIEN Position */ +#define OTG_INTEN_SRPFIEN_Msk (0x1ul << OTG_INTEN_SRPFIEN_Pos) /*!< OTG_T::INTEN: SRPFIEN Mask */ + +#define OTG_INTEN_HNPFIEN_Pos (3) /*!< OTG_T::INTEN: HNPFIEN Position */ +#define OTG_INTEN_HNPFIEN_Msk (0x1ul << OTG_INTEN_HNPFIEN_Pos) /*!< OTG_T::INTEN: HNPFIEN Mask */ + +#define OTG_INTEN_GOIDLEIEN_Pos (4) /*!< OTG_T::INTEN: GOIDLEIEN Position */ +#define OTG_INTEN_GOIDLEIEN_Msk (0x1ul << OTG_INTEN_GOIDLEIEN_Pos) /*!< OTG_T::INTEN: GOIDLEIEN Mask */ + +#define OTG_INTEN_IDCHGIEN_Pos (5) /*!< OTG_T::INTEN: IDCHGIEN Position */ +#define OTG_INTEN_IDCHGIEN_Msk (0x1ul << OTG_INTEN_IDCHGIEN_Pos) /*!< OTG_T::INTEN: IDCHGIEN Mask */ + +#define OTG_INTEN_PDEVIEN_Pos (6) /*!< OTG_T::INTEN: PDEVIEN Position */ +#define OTG_INTEN_PDEVIEN_Msk (0x1ul << OTG_INTEN_PDEVIEN_Pos) /*!< OTG_T::INTEN: PDEVIEN Mask */ + +#define OTG_INTEN_HOSTIEN_Pos (7) /*!< OTG_T::INTEN: HOSTIEN Position */ +#define OTG_INTEN_HOSTIEN_Msk (0x1ul << OTG_INTEN_HOSTIEN_Pos) /*!< OTG_T::INTEN: HOSTIEN Mask */ + +#define OTG_INTEN_BVLDCHGIEN_Pos (8) /*!< OTG_T::INTEN: BVLDCHGIEN Position */ +#define OTG_INTEN_BVLDCHGIEN_Msk (0x1ul << OTG_INTEN_BVLDCHGIEN_Pos) /*!< OTG_T::INTEN: BVLDCHGIEN Mask */ + +#define OTG_INTEN_AVLDCHGIEN_Pos (9) /*!< OTG_T::INTEN: AVLDCHGIEN Position */ +#define OTG_INTEN_AVLDCHGIEN_Msk (0x1ul << OTG_INTEN_AVLDCHGIEN_Pos) /*!< OTG_T::INTEN: AVLDCHGIEN Mask */ + +#define OTG_INTEN_VBCHGIEN_Pos (10) /*!< OTG_T::INTEN: VBCHGIEN Position */ +#define OTG_INTEN_VBCHGIEN_Msk (0x1ul << OTG_INTEN_VBCHGIEN_Pos) /*!< OTG_T::INTEN: VBCHGIEN Mask */ + +#define OTG_INTEN_SECHGIEN_Pos (11) /*!< OTG_T::INTEN: SECHGIEN Position */ +#define OTG_INTEN_SECHGIEN_Msk (0x1ul << OTG_INTEN_SECHGIEN_Pos) /*!< OTG_T::INTEN: SECHGIEN Mask */ + +#define OTG_INTEN_SRPDETIEN_Pos (13) /*!< OTG_T::INTEN: SRPDETIEN Position */ +#define OTG_INTEN_SRPDETIEN_Msk (0x1ul << OTG_INTEN_SRPDETIEN_Pos) /*!< OTG_T::INTEN: SRPDETIEN Mask */ + +#define OTG_INTSTS_ROLECHGIF_Pos (0) /*!< OTG_T::INTSTS: ROLECHGIF Position */ +#define OTG_INTSTS_ROLECHGIF_Msk (0x1ul << OTG_INTSTS_ROLECHGIF_Pos) /*!< OTG_T::INTSTS: ROLECHGIF Mask */ + +#define OTG_INTSTS_VBEIF_Pos (1) /*!< OTG_T::INTSTS: VBEIF Position */ +#define OTG_INTSTS_VBEIF_Msk (0x1ul << OTG_INTSTS_VBEIF_Pos) /*!< OTG_T::INTSTS: VBEIF Mask */ + +#define OTG_INTSTS_SRPFIF_Pos (2) /*!< OTG_T::INTSTS: SRPFIF Position */ +#define OTG_INTSTS_SRPFIF_Msk (0x1ul << OTG_INTSTS_SRPFIF_Pos) /*!< OTG_T::INTSTS: SRPFIF Mask */ + +#define OTG_INTSTS_HNPFIF_Pos (3) /*!< OTG_T::INTSTS: HNPFIF Position */ +#define OTG_INTSTS_HNPFIF_Msk (0x1ul << OTG_INTSTS_HNPFIF_Pos) /*!< OTG_T::INTSTS: HNPFIF Mask */ + +#define OTG_INTSTS_GOIDLEIF_Pos (4) /*!< OTG_T::INTSTS: GOIDLEIF Position */ +#define OTG_INTSTS_GOIDLEIF_Msk (0x1ul << OTG_INTSTS_GOIDLEIF_Pos) /*!< OTG_T::INTSTS: GOIDLEIF Mask */ + +#define OTG_INTSTS_IDCHGIF_Pos (5) /*!< OTG_T::INTSTS: IDCHGIF Position */ +#define OTG_INTSTS_IDCHGIF_Msk (0x1ul << OTG_INTSTS_IDCHGIF_Pos) /*!< OTG_T::INTSTS: IDCHGIF Mask */ + +#define OTG_INTSTS_PDEVIF_Pos (6) /*!< OTG_T::INTSTS: PDEVIF Position */ +#define OTG_INTSTS_PDEVIF_Msk (0x1ul << OTG_INTSTS_PDEVIF_Pos) /*!< OTG_T::INTSTS: PDEVIF Mask */ + +#define OTG_INTSTS_HOSTIF_Pos (7) /*!< OTG_T::INTSTS: HOSTIF Position */ +#define OTG_INTSTS_HOSTIF_Msk (0x1ul << OTG_INTSTS_HOSTIF_Pos) /*!< OTG_T::INTSTS: HOSTIF Mask */ + +#define OTG_INTSTS_BVLDCHGIF_Pos (8) /*!< OTG_T::INTSTS: BVLDCHGIF Position */ +#define OTG_INTSTS_BVLDCHGIF_Msk (0x1ul << OTG_INTSTS_BVLDCHGIF_Pos) /*!< OTG_T::INTSTS: BVLDCHGIF Mask */ + +#define OTG_INTSTS_AVLDCHGIF_Pos (9) /*!< OTG_T::INTSTS: AVLDCHGIF Position */ +#define OTG_INTSTS_AVLDCHGIF_Msk (0x1ul << OTG_INTSTS_AVLDCHGIF_Pos) /*!< OTG_T::INTSTS: AVLDCHGIF Mask */ + +#define OTG_INTSTS_VBCHGIF_Pos (10) /*!< OTG_T::INTSTS: VBCHGIF Position */ +#define OTG_INTSTS_VBCHGIF_Msk (0x1ul << OTG_INTSTS_VBCHGIF_Pos) /*!< OTG_T::INTSTS: VBCHGIF Mask */ + +#define OTG_INTSTS_SECHGIF_Pos (11) /*!< OTG_T::INTSTS: SECHGIF Position */ +#define OTG_INTSTS_SECHGIF_Msk (0x1ul << OTG_INTSTS_SECHGIF_Pos) /*!< OTG_T::INTSTS: SECHGIF Mask */ + +#define OTG_INTSTS_SRPDETIF_Pos (13) /*!< OTG_T::INTSTS: SRPDETIF Position */ +#define OTG_INTSTS_SRPDETIF_Msk (0x1ul << OTG_INTSTS_SRPDETIF_Pos) /*!< OTG_T::INTSTS: SRPDETIF Mask */ + +#define OTG_STATUS_OVERCUR_Pos (0) /*!< OTG_T::STATUS: OVERCUR Position */ +#define OTG_STATUS_OVERCUR_Msk (0x1ul << OTG_STATUS_OVERCUR_Pos) /*!< OTG_T::STATUS: OVERCUR Mask */ + +#define OTG_STATUS_IDSTS_Pos (1) /*!< OTG_T::STATUS: IDSTS Position */ +#define OTG_STATUS_IDSTS_Msk (0x1ul << OTG_STATUS_IDSTS_Pos) /*!< OTG_T::STATUS: IDSTS Mask */ + +#define OTG_STATUS_SESSEND_Pos (2) /*!< OTG_T::STATUS: SESSEND Position */ +#define OTG_STATUS_SESSEND_Msk (0x1ul << OTG_STATUS_SESSEND_Pos) /*!< OTG_T::STATUS: SESSEND Mask */ + +#define OTG_STATUS_BVLD_Pos (3) /*!< OTG_T::STATUS: BVLD Position */ +#define OTG_STATUS_BVLD_Msk (0x1ul << OTG_STATUS_BVLD_Pos) /*!< OTG_T::STATUS: BVLD Mask */ + +#define OTG_STATUS_AVLD_Pos (4) /*!< OTG_T::STATUS: AVLD Position */ +#define OTG_STATUS_AVLD_Msk (0x1ul << OTG_STATUS_AVLD_Pos) /*!< OTG_T::STATUS: AVLD Mask */ + +#define OTG_STATUS_VBUSVLD_Pos (5) /*!< OTG_T::STATUS: VBUSVLD Position */ +#define OTG_STATUS_VBUSVLD_Msk (0x1ul << OTG_STATUS_VBUSVLD_Pos) /*!< OTG_T::STATUS: VBUSVLD Mask */ + +/**@}*/ /* OTG_CONST */ +/**@}*/ /* end of OTG register group */ + + +/*---------------------- Peripheral Direct Memory Access Controller -------------------------*/ +/** + @addtogroup PDMA Peripheral Direct Memory Access Controller(PDMA) + Memory Mapped Structure for PDMA Controller +@{ */ + +typedef struct { + + /** + * DSCTx_CTL + * =================================================================================================== + * Offset: 0x00 Descriptor Table Control Register of PDMA Channel x + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |OPMODE |PDMA Operation Mode Selection + * | | |00 = Stop Mode. + * | | |Channel is stopped or this table is complete, when PDMA finish channel table task, OPMODE will be cleared to stop mode automatically. + * | | |01 = Basic Mode. + * | | |The descriptor table only has one task. + * | | |When this task is finished, the PDMA_INTSTS[x] will be asserted. + * | | |10 = Scatter-Gather Mode. + * | | |When operating in this mode, user must give the next descriptor table address in EMBTA_NTAAR register; PDMA will ignore this task, and then load the next task to execute. + * | | |Note: Before filling transfer task in the descriptor table, user must check if the descriptor table is complete. + * |[2] |TXTYPE |Request Type + * | | |0 = Burst request type. + * | | |1 = Single request type. + * |[4:6] |BURSIZE |Burst Size + * | | |This field is used for peripheral to determine the burst size or used for determine the re-arbitration size. + * | | |But if in Single Request Type, this field is not useful and only 1 transfer item been transmitted for each transfer. + * | | |000 = 128 transfers. + * | | |001 = 64 transfers. + * | | |010 = 32 transfers. + * | | |011 = 16 transfers. + * | | |100 = 8 transfers. + * | | |101 = 4 transfers. + * | | |110 = 2 transfers. + * | | |111 = 1 transfers. + * |[7] |TBINTDIS |Table Interrupt Disable Control + * | | |This field can be used to decide whether to enable table interrupt or not. + * | | |When with transfer done flag, this bit is only used for scatter-gather mode. + * | | |If the TBINTDIS bit is enabled when PDMA finishes this task, there will no any interrupt generated. + * | | |However, with the table empty flag, this bit is also useful. + * | | |If it is set to '1', the TEMPTYF will not be set when this situation has happened. + * | | |0 = Table interrupt Enabled. + * | | |1 = Table interrupt Disabled. + * |[8:9] |SAINC |Source Address Increment + * | | |This field is used to set the source address increment size + * | | |11 = No Increment (Fixed Address.). + * | | |Other = Increment and size is depended on TXWIDTH selection. + * |[10:11] |DAINC |Destination Address Increment + * | | |This field is used to set the destination address increment size + * | | |11 = No Increment (Fixed Address.). + * | | |Other = Increment and size is depended on TXWIDTH selection. + * |[12:13] |TXWIDTH |Transfer Width Selection + * | | |This field is used for transfer width. + * | | |00 = 8 bits for every transfer item. + * | | |01 = 16 bits for every transfer item. + * | | |10 = 32 bits for every transfer item. + * | | |11 = Reserved. + * | | |Note: The PDMA transfer source address (EMBTA_ENDSAR) and PDMA transfer destination address (EMBTA_ENDDAR) should be alignment under the TXWIDTH selection + * |[16:29] |TXCNT |Transfer Count + * | | |The TXCNT represents the required number of PDMA transfer, the real transfer count is (TXCNT + 1); The maximum transfer count is 16384 , every transfer may be byte, half-word or word that is dependent on TXWIDTH field. + * | | |Note: When PDMA finish each transfer item, this field will be decrease imminently + */ + __IO uint32_t CTL; + + /** + * DSCTx_ENDSA + * =================================================================================================== + * Offset: 0x04 End Source Address Register of PDMA Channel x + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ENDSA |PDMA Transfer Ending Source Address Bits + * | | |This field indicates a 32-bit ending source address of PDMA. + * | | |Note: If the source start address is 0x2000_0000, the transfer count is 0x100 and the source address increment is word, this field must be filled 0x2000_0400. + * | | |The equation is "0x2000_0400 = 0x2000_0000 + 0x100*4(word)". + */ + __IO uint32_t ENDSA; + + /** + * DSCTx_ENDDA + * =================================================================================================== + * Offset: 0x08 End Destination Address Register of PDMA Channel x + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ENDDA |PDMA Transfer Ending Destination Address Bits + * | | |This field indicates a 32-bit ending destination address of PDMA. + * | | |Note: If the destination start address is 0x2000_0000, the transfer count is 0x100 and the destination address increment is word, this field must be filled 0x2000_0400. + * | | |The equation is "0x2000_0400 = 0x2000_0000 + 0x100*4(word)". + */ + __IO uint32_t ENDDA; + + /** + * DSCTx_NEXT + * =================================================================================================== + * Offset: 0x0C Scatter-Gather Descriptor Table Offset Address of PDMA Channel x + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[2:15] |NEXT |PDMA Next Description Table Offset Address Bits + * | | |This field indicates the offset of next descriptor table address in system memory. + * | | |Note1: The next descriptor table address must be word boundary. + * | | |Note2: The system memory based address is 0x2000_0000 (PDMA_ETADDR), if the next descriptor table is 0x2000_0100, that this field must fill 0x0100. + * | | |Note3: Before filled transfer task in the description table, user must check if the descriptor table is complete. + */ + __IO uint32_t NEXT; + +} DSCT_T; + +typedef struct { + DSCT_T DSCT[16]; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[192]; + /// @endcond //HIDDEN_SYMBOLS + + /** + * CHCTL + * =================================================================================================== + * Offset: 0x400 PDMA Channel Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |CHEN |PDMA Channel Enable Control Bit[X] + * | | |Set this bit to 1 to enable PDMA[x] operation. + * | | |0 = PDMA channel [x] Disabled. + * | | |1 = PDMA channel [x] Enabled. + * | | |Note1: If software stops each PDMA transfer by setting PDMA_STOP register, this bit will be cleared automatically after finishing current transfer. + * | | |Note2: Software reset (writing 0xFFFF_FFF to PDMA_STOP register) will clear this bit. + * | | |Note3: If each channel is not set as enabled, each channel cannot be active. + */ + __IO uint32_t CHCTL; + + /** + * STOP + * =================================================================================================== + * Offset: 0x404 PDMA Stop Transfer Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |STOP |PDMA Stop Transfer Bit [X] + * | | |User can stop the PDMA transfer by software reset (writing all '1' to PDMA_STOP register) or by PDMA_STOP register. + * | | |The difference between software reset and PDMA_STOP register is when software set software reset, the operation will be stopped imminently that include the on-going transfer and the channel enable bit and request active flag will be cleared to '0'. + * | | |When software set PDMA_STOP bit, the operation will finish the on-going transfer channel and then clear the channel enable bit and request active flag. + * | | |Software can poll channel enable bit to know if the on-going transfer is finished. + * | | |0 = No effect. + * | | |1 = Stop PDMA transfer[x]. + * | | |Note1: This field is Write-Only + * | | |Note2: Setting all PDMA_STOP bit to "1" will generate software reset to reset internal state machine (the embedded table will not be reset). + */ + __O uint32_t STOP; + + /** + * SWREQ + * =================================================================================================== + * Offset: 0x408 PDMA Software Request Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |SWREQ |PDMA Software Request Bit [X] + * | | |Set this bit to 1 to generate a software request to PDMA [x]. + * | | |0 = No effect. + * | | |1 = Generate a software request. + * | | |Note1: This field is Write-Only. + * | | |Software can indicate which channel is on active by reading PDMA_TRGSTS register. + * | | |Active flag may be triggered by software request or peripheral request. + * | | |Note2: If user does not enable each PDMA channel, the software request will be ignored. + */ + __O uint32_t SWREQ; + + /** + * TRGSTS + * =================================================================================================== + * Offset: 0x40C PDMA Request Active Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |REQSTS |PDMA Request Active Flag [X] + * | | |This flag indicates whether channel[x] have a request or not. + * | | |0 = Have no requests. + * | | |1 = Have a request. + * | | |Note1: The request may come from software request (SWREQ) or peripheral request. + * | | |Note2: When PDMA finishes channel transfer, this bit will be cleared automatically + * | | |Note3: Software reset (setting PDMA_STOP to 0xFFFF_FFFF) will clear this bit. + */ + __I uint32_t TRGSTS; + + /** + * PRISET + * =================================================================================================== + * Offset: 0x410 PDMA Fixed Priority Setting Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FPRISET |PDMA Fixed Priority Setting Bit[X] + * | | |Set this bit to 1 to enable fix priority level. + * | | |0 = No effect. + * | | |1 = Set PDMA channel [x] be fixed priority channel. + * | | |The PDMA channel priority is shown in the following table. + */ + __IO uint32_t PRISET; + + /** + * PRICLR + * =================================================================================================== + * Offset: 0x414 PDMA Fixed Priority Clear Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FPRICLR |PDMA Fix Priority Clear Bit [X] + * | | |Set this bit to 1 to clear fixed priority level. + * | | |0 = No effect. + * | | |1 = Set PDMA channel [x] to be round-robin priority channel. + * | | |Note: This field is Write-Only, and software can indicate the channel priority by reading PDMA_FPIOSEL register. + */ + __O uint32_t PRICLR; + + /** + * INTEN + * =================================================================================================== + * Offset: 0x418 PDMA Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |INTEN |PDMA Interrupt Enable Control Register [X] + * | | |This field is used for enabling PDMA channel[x] interrupt. + * | | |0 = PDMA channel [x] interrupt Disabled. + * | | |1 = PDMA channel [x] interrupt Enabled. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x41C PDMA Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ABTIF |PDMA Read/Write Target Abort Interrupt Status Flag + * | | |This bit indicates that PDMA has target abort error; Software can read PDMA_TABORTF register to find which channel has target abort error. + * | | |0 = No bus ERROR response received. + * | | |1 = Bus ERROR response received. + * | | |Note: This field is read only. + * |[1] |TDIF |Transfer Done Interrupt Status Flag + * | | |This bit indicates that PDMA has finished transmission; Software can read PDMA_TDSTS register to indicate which channel finished transfer. + * | | |0 = Not finished yet. + * | | |1 = PDMA channel has finished transmission. + * | | |Note: This field is Read only. + * |[2] |TEIF |Table Empty Interrupt Status Flag + * | | |This bit indicates that PDMA has finished each table transmission and the operation is Stop mode. + * | | |Software can read TEIF register to indicate which channel finished transfer. + * | | |0 = Not finished yet. + * | | |1 = PDMA channel has finished and the operation is Stop mode. + * | | |Note: This field is Read only. + */ + __IO uint32_t INTSTS; + + /** + * ABTSTS + * =================================================================================================== + * Offset: 0x420 PDMA Read/Write Target Abort Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |ABTIF |PDMA Read/Write Target Abort Interrupt Status Flag + * | | |This bit indicates which PDMA has target abort error + * | | |0 = No bus ERROR response received. + * | | |1 = Bus ERROR response received. + * | | |Note: This field is read only, but software can write 1 to clear it. + */ + __IO uint32_t ABTSTS; + + /** + * TDSTS + * =================================================================================================== + * Offset: 0x424 PDMA Transfer Done Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |TDIF |Transfer Done Flag [X] + * | | |This bit indicates which PDMA channel has finished transmission. + * | | |0 = Not finished yet. + * | | |1 = PDMA channel has finished transmission. + * | | |Note: This field is read only, but software can write 1 to clear. + */ + __IO uint32_t TDSTS; + + /** + * SCATSTS + * =================================================================================================== + * Offset: 0x428 PDMA Scatter-Gather Transfer Done Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |TEMPTYF |Table Empty Flag Bit [X] + * | | |This bit indicates which PDMA channel table has finished transmission and the operation mode is Stop mode + * | | |0 = Not finished or not in Stop mode. + * | | |1 = PDMA channel has finished transmission and the operation is Stop mode. + * | | |Note: This field is read only, but software can write 1 to clear. + */ + __IO uint32_t SCATSTS; + + /** + * TACTSTS + * =================================================================================================== + * Offset: 0x42C PDMA Transfer on Active Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |TXACTF |Transfer On Active Flag Bit [X] + * | | |This bit indicates which PDMA channel is on active. + * | | |0 = PDMA channel is not finished. + * | | |1 = PDMA channel is on active. + */ + __I uint32_t TACTSTS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SCATBA + * =================================================================================================== + * Offset: 0x43C PDMA Scatter-Gather Descriptor Table Base Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[16:31] |SCATBA |PDMA Scatter-Gather Descriptor Table Base Address Bits + * | | |In Scatter-Gather mode, this is the base address for calculating the next link - list address. + * | | |The next link address equation is. + * | | |Next Link Address = { SCATBA[15:0], EMBTA_NTAAR[15:2], 2'b00}. + * | | |Note: Only useful in Scatter-Gather mode. + */ + __IO uint32_t SCATBA; + + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[16]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * REQSEL0_3 + * =================================================================================================== + * Offset: 0x480 PDMA Source Module Select Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:4] |REQSRC0 |Channel 0 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 0. + * | | |Software can configure the peripheral by setting REQSRC0. + * | | |00000 = Connect to SPI0_TX. + * | | |00001 = Connect to SPI1_TX. + * | | |00010 = Connect to SPI2_TX. + * | | |00011 = Connect to SPI3_TX. + * | | |00100 = Connect to UART0_TX. + * | | |00101 = Connect to UART1_TX. + * | | |00110 = Connect to UART2_TX. + * | | |00111 = Connect to UART3_TX. + * | | |01000 = Connect to UART4_TX. + * | | |01001 = Connect to UART5_TX. + * | | |01010 = Reserved. + * | | |01011 = Connect to I2S_TX. + * | | |01100 = Connect to I2S1_TX. + * | | |01101 = Connect to SPI0_RX. + * | | |01110 = Connect to SPI1_RX. + * | | |01111 = Connect to SPI2_RX. + * | | |10000 = Connect to SPI3_RX. + * | | |10001 = Connect to UART0_RX. + * | | |10010 = Connect to UART1_RX. + * | | |10011 = Connect to UART2_RX. + * | | |10100 = Connect to UART3_RX. + * | | |10101 = Connect to UART4_RX. + * | | |10110 = Connect to UART5_RX. + * | | |10111 = Reserved. + * | | |11000 = Connect to ADC. + * | | |11001 = Connect to I2S_RX. + * | | |11010 = Connect to I2S1_RX. + * | | |Other = Reserved. + * |[8:12] |REQSRC1 |Channel 1 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 1. + * | | |Software can configure the peripheral setting by REQSRC1. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[16:20] |REQSRC2 |Channel 2 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 2. + * | | |Software can configure the peripheral setting by REQSRC2. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[24:28] |REQSRC3 |Channel 3 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 3. + * | | |Software can configure the peripheral setting by REQSRC3. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + */ + __IO uint32_t REQSEL0_3; + + /** + * REQSEL4_7 + * =================================================================================================== + * Offset: 0x484 PDMA Source Module Select Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:4] |REQSRC4 |Channel 0 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 4. + * | | |Software can configure the peripheral setting by REQSRC4. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[8:12] |REQSRC5 |Channel 1 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 5. + * | | |Software can configure the peripheral setting by REQSRC5. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[16:20] |REQSRC6 |Channel 6 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 6. + * | | |Software can configure the peripheral setting by REQSRC6. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[24:28] |REQSRC7 |Channel 7 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 7. + * | | |Software can configure the peripheral setting by REQSRC7. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + */ + __IO uint32_t REQSEL4_7; + + /** + * REQSEL8_11 + * =================================================================================================== + * Offset: 0x488 PDMA Source Module Select Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:4] |REQSRC8 |Channel 8 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 8. + * | | |Software can configure the peripheral setting by REQSRC8. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[8:12] |REQSRC9 |Channel 9 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 9. + * | | |Software can configure the peripheral setting by REQSRC9. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[16:20] |REQSRC10 |Channel 10 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 10. + * | | |Software can configure the peripheral setting by REQSRC10. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[24:28] |REQSRC11 |Channel 11 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 11. + * | | |Software can configure the peripheral setting by REQSRC11. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + */ + __IO uint32_t REQSEL8_11; + + /** + * REQSEL12_15 + * =================================================================================================== + * Offset: 0x48C PDMA Source Module Select Register 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:4] |REQSRC12 |Channel 12 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 12. + * | | |Software can configure the peripheral setting by REQSRC12. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[8:12] |REQSRC13 |Channel 13 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 13. + * | | |Software can configure the peripheral setting by REQSRC13. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[16:20] |REQSRC14 |Channel 14 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 14. + * | | |Software can configure the peripheral setting by REQSRC14. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + * |[24:28] |REQSRC15 |Channel 15 Selection + * | | |This filed defines which peripheral is connected to PDMA channel 15. + * | | |Software can configure the peripheral setting by REQSRC15. + * | | |The channel configuration is the same as REQSRC0 field. + * | | |Please refer to the explanation of REQSRC0. + */ + __IO uint32_t REQSEL12_15; + +} PDMA_T; + +/** + @addtogroup PDMA_CONST PDMA Bit Field Definition + Constant Definitions for PDMA Controller +@{ */ + +#define PDMA_DSCT_CTL_OPMODE_Pos (0) /*!< DSCT_T::CTL: OPMODE Position */ +#define PDMA_DSCT_CTL_OPMODE_Msk (0x3ul << PDMA_DSCT_CTL_OPMODE_Pos) /*!< DSCT_T::CTL: OPMODE Mask */ + +#define PDMA_DSCT_CTL_TXTYPE_Pos (2) /*!< DSCT_T::CTL: TXTYPE Position */ +#define PDMA_DSCT_CTL_TXTYPE_Msk (0x1ul << PDMA_DSCT_CTL_TXTYPE_Pos) /*!< DSCT_T::CTL: TXTYPE Mask */ + +#define PDMA_DSCT_CTL_BURSIZE_Pos (4) /*!< DSCT_T::CTL: BURSIZE Position */ +#define PDMA_DSCT_CTL_BURSIZE_Msk (0x7ul << PDMA_DSCT_CTL_BURSIZE_Pos) /*!< DSCT_T::CTL: BURSIZE Mask */ + +#define PDMA_DSCT_CTL_TBINTDIS_Pos (7) /*!< DSCT_T::CTL: TBINTDIS Position */ +#define PDMA_DSCT_CTL_TBINTDIS_Msk (0x1ul << PDMA_DSCT_CTL_TBINTDIS_Pos) /*!< DSCT_T::CTL: TBINTDIS Mask */ + +#define PDMA_DSCT_CTL_SAINC_Pos (8) /*!< DSCT_T::CTL: SAINC Position */ +#define PDMA_DSCT_CTL_SAINC_Msk (0x3ul << PDMA_DSCT_CTL_SAINC_Pos) /*!< DSCT_T::CTL: SAINC Mask */ + +#define PDMA_DSCT_CTL_DAINC_Pos (10) /*!< DSCT_T::CTL: DAINC Position */ +#define PDMA_DSCT_CTL_DAINC_Msk (0x3ul << PDMA_DSCT_CTL_DAINC_Pos) /*!< DSCT_T::CTL: DAINC Mask */ + +#define PDMA_DSCT_CTL_TXWIDTH_Pos (12) /*!< DSCT_T::CTL: TXWIDTH Position */ +#define PDMA_DSCT_CTL_TXWIDTH_Msk (0x3ul << PDMA_DSCT_CTL_TXWIDTH_Pos) /*!< DSCT_T::CTL: TXWIDTH Mask */ + +#define PDMA_DSCT_CTL_TXCNT_Pos (16) /*!< DSCT_T::CTL: TXCNT Position */ +#define PDMA_DSCT_CTL_TXCNT_Msk (0x3ffful << PDMA_DSCT_CTL_TXCNT_Pos) /*!< DSCT_T::CTL: TXCNT Mask */ + +#define PDMA_DSCT_ENDSA_ENDSA_Pos (0) /*!< DSCT_T::ENDSA: ENDSA Position */ +#define PDMA_DSCT_ENDSA_ENDSA_Msk (0xfffffffful << PDMA_DSCT_ENDSA_ENDSA_Pos) /*!< DSCT_T::ENDSA: ENDSA Mask */ + +#define PDMA_DSCT_ENDDA_ENDDA_Pos (0) /*!< DSCT_T::ENDDA: ENDDA Position */ +#define PDMA_DSCT_ENDDA_ENDDA_Msk (0xfffffffful << PDMA_DSCT_ENDDA_ENDDA_Pos) /*!< DSCT_T::ENDDA: ENDDA Mask */ + +#define PDMA_DSCT_NEXT_NEXT_Pos (2) /*!< DSCT_T::NEXT: NEXT Position */ +#define PDMA_DSCT_NEXT_NEXT_Msk (0x3ffful << PDMA_DSCT_NEXT_NEXT_Pos) /*!< DSCT_T::NEXT: NEXT Mask */ + +#define PDMA_CHCTL_CHEN_Pos (0) /*!< PDMA_T::CHCTL: CHEN Position */ +#define PDMA_CHCTL_CHEN_Msk (0xfffful << PDMA_CHCTL_CHEN_Pos) /*!< PDMA_T::CHCTL: CHEN Mask */ + +#define PDMA_STOP_STOP_Pos (0) /*!< PDMA_T::STOP: STOP Position */ +#define PDMA_STOP_STOP_Msk (0xfffful << PDMA_STOP_STOP_Pos) /*!< PDMA_T::STOP: STOP Mask */ + +#define PDMA_SWREQ_SWREQ_Pos (0) /*!< PDMA_T::SWREQ: SWREQ Position */ +#define PDMA_SWREQ_SWREQ_Msk (0xffful << PDMA_SWREQ_SWREQ_Pos) /*!< PDMA_T::SWREQ: SWREQ Mask */ + +#define PDMA_TRGSTS_REQSTS_Pos (0) /*!< PDMA_T::TRGSTS: REQSTS Position */ +#define PDMA_TRGSTS_REQSTS_Msk (0xfffful << PDMA_TRGSTS_REQSTS_Pos) /*!< PDMA_T::TRGSTS: REQSTS Mask */ + +#define PDMA_PRISET_FPRISET_Pos (0) /*!< PDMA_T::PRISET: FPRISET Position */ +#define PDMA_PRISET_FPRISET_Msk (0xfffful << PDMA_PRISET_FPRISET_Pos) /*!< PDMA_T::PRISET: FPRISET Mask */ + +#define PDMA_PRICLR_FPRICLR_Pos (0) /*!< PDMA_T::PRICLR: FPRICLR Position */ +#define PDMA_PRICLR_FPRICLR_Msk (0xfffful << PDMA_PRICLR_FPRICLR_Pos) /*!< PDMA_T::PRICLR: FPRICLR Mask */ + +#define PDMA_INTEN_INTEN_Pos (0) /*!< PDMA_T::INTEN: INTEN Position */ +#define PDMA_INTEN_INTEN_Msk (0xfffful << PDMA_INTEN_INTEN_Pos) /*!< PDMA_T::INTEN: INTEN Mask */ + +#define PDMA_INTSTS_ABTIF_Pos (0) /*!< PDMA_T::INTSTS: ABTIF Position */ +#define PDMA_INTSTS_ABTIF_Msk (0x1ul << PDMA_INTSTS_ABTIF_Pos) /*!< PDMA_T::INTSTS: ABTIF Mask */ + +#define PDMA_INTSTS_TDIF_Pos (1) /*!< PDMA_T::INTSTS: TDIF Position */ +#define PDMA_INTSTS_TDIF_Msk (0x1ul << PDMA_INTSTS_TDIF_Pos) /*!< PDMA_T::INTSTS: TDIF Mask */ + +#define PDMA_INTSTS_TEIF_Pos (2) /*!< PDMA_T::INTSTS: TEIF Position */ +#define PDMA_INTSTS_TEIF_Msk (0x1ul << PDMA_INTSTS_TEIF_Pos) /*!< PDMA_T::INTSTS: TEIF Mask */ + +#define PDMA_ABTSTS_ABTIF_Pos (0) /*!< PDMA_T::ABTSTS: ABTIF Position */ +#define PDMA_ABTSTS_ABTIF_Msk (0xfffful << PDMA_ABTSTS_ABTIF_Pos) /*!< PDMA_T::ABTSTS: ABTIF Mask */ + +#define PDMA_TDSTS_TDIF_Pos (0) /*!< PDMA_T::TDSTS: TDIF Position */ +#define PDMA_TDSTS_TDIF_Msk (0xfffful << PDMA_TDSTS_TDIF_Pos) /*!< PDMA_T::TDSTS: TDIF Mask */ + +#define PDMA_SCATSTS_TEMPTYF_Pos (0) /*!< PDMA_T::SCATSTS: TEMPTYF Position */ +#define PDMA_SCATSTS_TEMPTYF_Msk (0xfffful << PDMA_SCATSTS_TEMPTYF_Pos) /*!< PDMA_T::SCATSTS: TEMPTYF Mask */ + +#define PDMA_TACTSTS_TXACTF_Pos (0) /*!< PDMA_T::TACTSTS: TXACTF Position */ +#define PDMA_TACTSTS_TXACTF_Msk (0xfffful << PDMA_TACTSTS_TXACTF_Pos) /*!< PDMA_T::TACTSTS: TXACTF Mask */ + +#define PDMA_SCATBA_SCATBA_Pos (16) /*!< PDMA_T::SCATBA: SCATBA Position */ +#define PDMA_SCATBA_SCATBA_Msk (0xfffful << PDMA_SCATBA_SCATBA_Pos) /*!< PDMA_T::SCATBA: SCATBA Mask */ + +#define PDMA_REQSEL0_3_REQSRC0_Pos (0) /*!< PDMA_T::REQSEL0_3: REQSRC0 Position */ +#define PDMA_REQSEL0_3_REQSRC0_Msk (0x1ful << PDMA_REQSEL0_3_REQSRC0_Pos) /*!< PDMA_T::REQSEL0_3: REQSRC0 Mask */ + +#define PDMA_REQSEL0_3_REQSRC1_Pos (8) /*!< PDMA_T::REQSEL0_3: REQSRC1 Position */ +#define PDMA_REQSEL0_3_REQSRC1_Msk (0x1ful << PDMA_REQSEL0_3_REQSRC1_Pos) /*!< PDMA_T::REQSEL0_3: REQSRC1 Mask */ + +#define PDMA_REQSEL0_3_REQSRC2_Pos (16) /*!< PDMA_T::REQSEL0_3: REQSRC2 Position */ +#define PDMA_REQSEL0_3_REQSRC2_Msk (0x1ful << PDMA_REQSEL0_3_REQSRC2_Pos) /*!< PDMA_T::REQSEL0_3: REQSRC2 Mask */ + +#define PDMA_REQSEL0_3_REQSRC3_Pos (24) /*!< PDMA_T::REQSEL0_3: REQSRC3 Position */ +#define PDMA_REQSEL0_3_REQSRC3_Msk (0x1ful << PDMA_REQSEL0_3_REQSRC3_Pos) /*!< PDMA_T::REQSEL0_3: REQSRC3 Mask */ + +#define PDMA_REQSEL4_7_REQSRC4_Pos (0) /*!< PDMA_T::REQSEL4_7: REQSRC4 Position */ +#define PDMA_REQSEL4_7_REQSRC4_Msk (0x1ful << PDMA_REQSEL4_7_REQSRC4_Pos) /*!< PDMA_T::REQSEL4_7: REQSRC4 Mask */ + +#define PDMA_REQSEL4_7_REQSRC5_Pos (8) /*!< PDMA_T::REQSEL4_7: REQSRC5 Position */ +#define PDMA_REQSEL4_7_REQSRC5_Msk (0x1ful << PDMA_REQSEL4_7_REQSRC5_Pos) /*!< PDMA_T::REQSEL4_7: REQSRC5 Mask */ + +#define PDMA_REQSEL4_7_REQSRC6_Pos (16) /*!< PDMA_T::REQSEL4_7: REQSRC6 Position */ +#define PDMA_REQSEL4_7_REQSRC6_Msk (0x1ful << PDMA_REQSEL4_7_REQSRC6_Pos) /*!< PDMA_T::REQSEL4_7: REQSRC6 Mask */ + +#define PDMA_REQSEL4_7_REQSRC7_Pos (24) /*!< PDMA_T::REQSEL4_7: REQSRC7 Position */ +#define PDMA_REQSEL4_7_REQSRC7_Msk (0x1ful << PDMA_REQSEL4_7_REQSRC7_Pos) /*!< PDMA_T::REQSEL4_7: REQSRC7 Mask */ + +#define PDMA_REQSEL8_11_REQSRC8_Pos (0) /*!< PDMA_T::REQSEL8_11: REQSRC8 Position */ +#define PDMA_REQSEL8_11_REQSRC8_Msk (0x1ful << PDMA_REQSEL8_11_REQSRC8_Pos) /*!< PDMA_T::REQSEL8_11: REQSRC8 Mask */ + +#define PDMA_REQSEL8_11_REQSRC9_Pos (8) /*!< PDMA_T::REQSEL8_11: REQSRC9 Position */ +#define PDMA_REQSEL8_11_REQSRC9_Msk (0x1ful << PDMA_REQSEL8_11_REQSRC9_Pos) /*!< PDMA_T::REQSEL8_11: REQSRC9 Mask */ + +#define PDMA_REQSEL8_11_REQSRC10_Pos (16) /*!< PDMA_T::REQSEL8_11: REQSRC10 Position */ +#define PDMA_REQSEL8_11_REQSRC10_Msk (0x1ful << PDMA_REQSEL8_11_REQSRC10_Pos) /*!< PDMA_T::REQSEL8_11: REQSRC10 Mask */ + +#define PDMA_REQSEL8_11_REQSRC11_Pos (24) /*!< PDMA_T::REQSEL8_11: REQSRC11 Position */ +#define PDMA_REQSEL8_11_REQSRC11_Msk (0x1ful << PDMA_REQSEL8_11_REQSRC11_Pos) /*!< PDMA_T::REQSEL8_11: REQSRC11 Mask */ + +#define PDMA_REQSEL12_15_REQSRC12_Pos (0) /*!< PDMA_T::REQSEL12_15: REQSRC12 Position */ +#define PDMA_REQSEL12_15_REQSRC12_Msk (0x1ful << PDMA_REQSEL12_15_REQSRC12_Pos) /*!< PDMA_T::REQSEL12_15: REQSRC12 Mask */ + +#define PDMA_REQSEL12_15_REQSRC13_Pos (8) /*!< PDMA_T::REQSEL12_15: REQSRC13 Position */ +#define PDMA_REQSEL12_15_REQSRC13_Msk (0x1ful << PDMA_REQSEL12_15_REQSRC13_Pos) /*!< PDMA_T::REQSEL12_15: REQSRC13 Mask */ + +#define PDMA_REQSEL12_15_REQSRC14_Pos (16) /*!< PDMA_T::REQSEL12_15: REQSRC14 Position */ +#define PDMA_REQSEL12_15_REQSRC14_Msk (0x1ful << PDMA_REQSEL12_15_REQSRC14_Pos) /*!< PDMA_T::REQSEL12_15: REQSRC14 Mask */ + +#define PDMA_REQSEL12_15_REQSRC15_Pos (24) /*!< PDMA_T::REQSEL12_15: REQSRC15 Position */ +#define PDMA_REQSEL12_15_REQSRC15_Msk (0x1ful << PDMA_REQSEL12_15_REQSRC15_Pos) /*!< PDMA_T::REQSEL12_15: REQSRC15 Mask */ + +/**@}*/ /* PDMA_CONST */ +/**@}*/ /* end of PDMA register group */ + + +/*---------------------- PS/2 Device Controller -------------------------*/ +/** + @addtogroup PS2 PS/2 Device Controller(PS2) + Memory Mapped Structure for PS2 Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 PS/2 Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |PS2EN |PS/2 Device Enable Control + * | | |Enable PS/2 device controller. + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[1] |TXIEN |Transmit Interrupt Enable Control + * | | |0 = Data transmit complete interrupt Disabled. + * | | |1 = Data transmit complete interrupt Enabled. + * |[2] |RXIEN |Receive Interrupt Enable Control + * | | |0 = Data receive complete interrupt Disabled. + * | | |1 = Data receive complete interrupt Enabled. + * |[3:6] |TXFDEPTH |Transmit Data FIFO Depth + * | | |There is 16-byte buffer for data transmit. + * | | |Software can define the FIFO depth from 1 to 16 bytes depending on the application. + * | | |0 = 1 byte. + * | | |1 = 2 bytes. + * | | |... + * | | |14 = 15 bytes. + * | | |15 = 16 bytes. + * |[7] |ACK |Acknowledge Enable Control + * | | |0 = Always sends acknowledge to host at 12th clock for host to device communication. + * | | |1 = If parity error or stop bit is not received correctly, acknowledge bit will not be sent to host at 12th clock. + * |[8] |CLRFIFO |Clear TX FIFO + * | | |Write 1 to this bit to terminate device to host transmission. + * | | |The TXEMPTY(PS2_STATUS[7]) bit will be set to 1 and pointer BYTEIDEX(PS2_STATUS[11:8]) is reset to 0 regardless there is residue data in buffer or not. + * | | |The buffer content is not been cleared. + * | | |0 = Not active. + * | | |1 = Clear FIFO. + * |[9] |OVERRIDE |Software Override PS/2 CLK/DATA Pin State + * | | |0 = CLKSTAT and DATSTAT pins are controlled by internal state machine. + * | | |1 = CLKSTAT and DATSTAT pins are controlled by software. + * |[10] |FPS2CLK |Force CLKSTAT Line + * | | |It forces CLKSTAT line high or low regardless of the internal state of the device controller if OVERRIDE is set to high. + * | | |0 = Force CLKSTAT line low. + * | | |1 = Force CLKSTAT line high. + * |[11] |FPS2DAT |Force DATSTAT Line + * | | |It forces DATSTAT high or low regardless of the internal state of the device controller if OVERRIDE is set to high. + * | | |0 = Force DATSTAT low. + * | | |1 = Force DATSTAT high. + */ + __IO uint32_t CTL; + + /** + * TXDAT0 + * =================================================================================================== + * Offset: 0x04 PS/2 Transmit DATA Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DAT |Transmit Data + * | | |Write data to this register starts device to host communication if bus is in IDLE state. + * | | |Software must enable PS2EN(PS2_CTL[0]) before writing data to TX buffer. + */ + __IO uint32_t TXDAT0; + + /** + * TXDAT1 + * =================================================================================================== + * Offset: 0x08 PS/2 Transmit DATA Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DAT |Transmit Data + * | | |Write data to this register starts device to host communication if bus is in IDLE state. + * | | |Software must enable PS2EN(PS2_CTL[0]) before writing data to TX buffer. + */ + __IO uint32_t TXDAT1; + + /** + * TXDAT2 + * =================================================================================================== + * Offset: 0x0C PS/2 Transmit DATA Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DAT |Transmit Data + * | | |Write data to this register starts device to host communication if bus is in IDLE state. + * | | |Software must enable PS2EN(PS2_CTL[0]) before writing data to TX buffer. + */ + __IO uint32_t TXDAT2; + + /** + * TXDAT3 + * =================================================================================================== + * Offset: 0x10 PS/2 Transmit DATA Register 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DAT |Transmit Data + * | | |Write data to this register starts device to host communication if bus is in IDLE state. + * | | |Software must enable PS2EN(PS2_CTL[0]) before writing data to TX buffer. + */ + __IO uint32_t TXDAT3; + + /** + * RXDAT + * =================================================================================================== + * Offset: 0x14 PS/2 Receive DATA Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DAT |Received Data + * | | |For host to device communication, after acknowledge bit is sent, the received data is copied from receive shift register to PS2_RXDAT register. + * | | |CPU must read this register before next byte reception complete; otherwise, the data will be overwritten and RXOV(PS2_STATUS[6]) bit will be set to 1. + */ + __I uint32_t RXDAT; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x18 PS/2 Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CLKSTAT |CLK Pin State + * | | |This bit reflects the status of the CLKSTAT line after synchronizing. + * |[1] |DATSTAT |DATA Pin State + * | | |This bit reflects the status of the DATSTAT line after synchronizing and sampling. + * |[2] |FRAMEERR |Frame Error + * | | |For host to device communication, if STOP bit (logic 1) is not received it is a frame error. + * | | |If frame error occurs, DATA line may keep at low state after 12th clock. + * | | |At this moment, software overrides CLKSTAT to send clock till DATSTAT release to high state. + * | | |After that, device sends a "Resend" command to host. + * | | |0 = No frame error. + * | | |1 = Frame error occurred . + * | | |Note: Write 1 to clear this bit. + * |[3] |RXPARITY |Received Parity + * | | |This bit reflects the parity bit for the last received data byte (odd parity). + * | | |Note: This bit is read only. + * |[4] |RXBUSY |Receive Busy + * | | |This bit indicates that the PS/2 device is currently receiving data. + * | | |0 = Idle. + * | | |1 = Currently receiving data. + * | | |Note: This bit is read only. + * |[5] |TXBUSY |Transmit Busy + * | | |This bit indicates that the PS/2 device is currently sending data. + * | | |0 = Idle. + * | | |1 = Currently sending data. + * | | |Note: This bit is read only. + * |[6] |RXOV |RX Buffer Overwrite + * | | |0 = No overwrite. + * | | |1 = Data in PS2_RXDAT register is overwritten by new received data. + * | | |Note: Write 1 to clear this bit. + * |[7] |TXEMPTY |TX FIFO Empty + * | | |When software writes any data to PS2_TXDAT0-3 the TXEMPTY bit is cleared to 0 immediately if PS2EN is enabled. + * | | |When transmitted data byte number is equal to FIFODEPTH then TXEMPTY bit is set to 1. + * | | |0 = There is data to be transmitted. + * | | |1 = FIFO is empty. + * | | |Note: This bit is read only. + * |[8:11] |BYTEIDX |Byte Index + * | | |It indicates which data byte in transmit data shift register. + * | | |When all data in FIFO is transmitted and it will be cleared to 0. + * | | |Note: This bit is read only. + * | | |BYTEIDX DATA Transmit + * | | |0000 TXDATA0[7:0] + * | | |0001 TXDATA0[15:8] + * | | |0010 TXDATA0[23:16] + * | | |0011 TXDATA0[31:24] + * | | |0100 TXDATA1[7:0] + * | | |0101 TXDATA1[15:8] + * | | |0110 TXDATA1[23:16] + * | | |0111 TXDATA1[31:24] + * | | |1000 TXDATA2[7:0] + * | | |1001 TXDATA2[15:8] + * | | |1010 TXDATA2[23:16] + * | | |1011 TXDATA2[31:24] + * | | |1100 TXDATA3[7:0] + * | | |1101 TXDATA3[15:8] + * | | |1110 TXDATA3[23:16] + * | | |1111 TXDATA3[31:24] + */ + __IO uint32_t STATUS; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x1C PS/2 Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXIF |Receive Interrupt + * | | |This bit is set to 1 when acknowledge bit is sent for Host to device communication. + * | | |Interrupt occurs if RXIEN(PS2_CTL[2]) bit is set to 1. + * | | |0 = No interrupt. + * | | |1 = Receive interrupt occurred. + * | | |Note: Write 1 to clear this bit to 0. + * |[1] |TXIF |Transmit Interrupt + * | | |This bit is set to 1 after STOP bit is transmitted. Interrupt occurs if TXIEN(PS2_CTL[1]) bit is set + * | | |to 1. + * | | |0 = No interrupt. + * | | |1 = Transmit interrupt occurred. + * | | |Note: Write 1 to clear this bit to 0. + */ + __IO uint32_t INTSTS; + +} PS2_T; + +/** + @addtogroup PS2_CONST PS2 Bit Field Definition + Constant Definitions for PS2 Controller +@{ */ + +#define PS2_CTL_PS2EN_Pos (0) /*!< PS2_T::CTL: PS2EN Position */ +#define PS2_CTL_PS2EN_Msk (0x1ul << PS2_CTL_PS2EN_Pos) /*!< PS2_T::CTL: PS2EN Mask */ + +#define PS2_CTL_TXIEN_Pos (1) /*!< PS2_T::CTL: TXIEN Position */ +#define PS2_CTL_TXIEN_Msk (0x1ul << PS2_CTL_TXIEN_Pos) /*!< PS2_T::CTL: TXIEN Mask */ + +#define PS2_CTL_RXIEN_Pos (2) /*!< PS2_T::CTL: RXIEN Position */ +#define PS2_CTL_RXIEN_Msk (0x1ul << PS2_CTL_RXIEN_Pos) /*!< PS2_T::CTL: RXIEN Mask */ + +#define PS2_CTL_TXFDEPTH_Pos (3) /*!< PS2_T::CTL: TXFDEPTH Position */ +#define PS2_CTL_TXFDEPTH_Msk (0xful << PS2_CTL_TXFDEPTH_Pos) /*!< PS2_T::CTL: TXFDEPTH Mask */ + +#define PS2_CTL_ACK_Pos (7) /*!< PS2_T::CTL: ACK Position */ +#define PS2_CTL_ACK_Msk (0x1ul << PS2_CTL_ACK_Pos) /*!< PS2_T::CTL: ACK Mask */ + +#define PS2_CTL_CLRFIFO_Pos (8) /*!< PS2_T::CTL: CLRFIFO Position */ +#define PS2_CTL_CLRFIFO_Msk (0x1ul << PS2_CTL_CLRFIFO_Pos) /*!< PS2_T::CTL: CLRFIFO Mask */ + +#define PS2_CTL_OVERRIDE_Pos (9) /*!< PS2_T::CTL: OVERRIDE Position */ +#define PS2_CTL_OVERRIDE_Msk (0x1ul << PS2_CTL_OVERRIDE_Pos) /*!< PS2_T::CTL: OVERRIDE Mask */ + +#define PS2_CTL_FPS2CLK_Pos (10) /*!< PS2_T::CTL: FPS2CLK Position */ +#define PS2_CTL_FPS2CLK_Msk (0x1ul << PS2_CTL_FPS2CLK_Pos) /*!< PS2_T::CTL: FPS2CLK Mask */ + +#define PS2_CTL_FPS2DAT_Pos (11) /*!< PS2_T::CTL: FPS2DAT Position */ +#define PS2_CTL_FPS2DAT_Msk (0x1ul << PS2_CTL_FPS2DAT_Pos) /*!< PS2_T::CTL: FPS2DAT Mask */ + +#define PS2_TXDAT0_DAT_Pos (0) /*!< PS2_T::TXDAT0: DAT Position */ +#define PS2_TXDAT0_DAT_Msk (0xfffffffful << PS2_TXDAT0_DAT_Pos) /*!< PS2_T::TXDAT0: DAT Mask */ + +#define PS2_TXDAT1_DAT_Pos (0) /*!< PS2_T::TXDAT1: DAT Position */ +#define PS2_TXDAT1_DAT_Msk (0xfffffffful << PS2_TXDAT1_DAT_Pos) /*!< PS2_T::TXDAT1: DAT Mask */ + +#define PS2_TXDAT2_DAT_Pos (0) /*!< PS2_T::TXDAT2: DAT Position */ +#define PS2_TXDAT2_DAT_Msk (0xfffffffful << PS2_TXDAT2_DAT_Pos) /*!< PS2_T::TXDAT2: DAT Mask */ + +#define PS2_TXDAT3_DAT_Pos (0) /*!< PS2_T::TXDAT3: DAT Position */ +#define PS2_TXDAT3_DAT_Msk (0xfffffffful << PS2_TXDAT3_DAT_Pos) /*!< PS2_T::TXDAT3: DAT Mask */ + +#define PS2_RXDAT_DAT_Pos (0) /*!< PS2_T::RXDAT: DAT Position */ +#define PS2_RXDAT_DAT_Msk (0xfful << PS2_RXDAT_DAT_Pos) /*!< PS2_T::RXDAT: DAT Mask */ + +#define PS2_STATUS_CLKSTAT_Pos (0) /*!< PS2_T::STATUS: CLKSTAT Position */ +#define PS2_STATUS_CLKSTAT_Msk (0x1ul << PS2_STATUS_CLKSTAT_Pos) /*!< PS2_T::STATUS: CLKSTAT Mask */ + +#define PS2_STATUS_DATSTAT_Pos (1) /*!< PS2_T::STATUS: DATSTAT Position */ +#define PS2_STATUS_DATSTAT_Msk (0x1ul << PS2_STATUS_DATSTAT_Pos) /*!< PS2_T::STATUS: DATSTAT Mask */ + +#define PS2_STATUS_FRAMEERR_Pos (2) /*!< PS2_T::STATUS: FRAMEERR Position */ +#define PS2_STATUS_FRAMEERR_Msk (0x1ul << PS2_STATUS_FRAMEERR_Pos) /*!< PS2_T::STATUS: FRAMEERR Mask */ + +#define PS2_STATUS_RXPARITY_Pos (3) /*!< PS2_T::STATUS: RXPARITY Position */ +#define PS2_STATUS_RXPARITY_Msk (0x1ul << PS2_STATUS_RXPARITY_Pos) /*!< PS2_T::STATUS: RXPARITY Mask */ + +#define PS2_STATUS_RXBUSY_Pos (4) /*!< PS2_T::STATUS: RXBUSY Position */ +#define PS2_STATUS_RXBUSY_Msk (0x1ul << PS2_STATUS_RXBUSY_Pos) /*!< PS2_T::STATUS: RXBUSY Mask */ + +#define PS2_STATUS_TXBUSY_Pos (5) /*!< PS2_T::STATUS: TXBUSY Position */ +#define PS2_STATUS_TXBUSY_Msk (0x1ul << PS2_STATUS_TXBUSY_Pos) /*!< PS2_T::STATUS: TXBUSY Mask */ + +#define PS2_STATUS_RXOV_Pos (6) /*!< PS2_T::STATUS: RXOV Position */ +#define PS2_STATUS_RXOV_Msk (0x1ul << PS2_STATUS_RXOV_Pos) /*!< PS2_T::STATUS: RXOV Mask */ + +#define PS2_STATUS_TXEMPTY_Pos (7) /*!< PS2_T::STATUS: TXEMPTY Position */ +#define PS2_STATUS_TXEMPTY_Msk (0x1ul << PS2_STATUS_TXEMPTY_Pos) /*!< PS2_T::STATUS: TXEMPTY Mask */ + +#define PS2_STATUS_BYTEIDX_Pos (8) /*!< PS2_T::STATUS: BYTEIDX Position */ +#define PS2_STATUS_BYTEIDX_Msk (0xful << PS2_STATUS_BYTEIDX_Pos) /*!< PS2_T::STATUS: BYTEIDX Mask */ + +#define PS2_INTSTS_RXIF_Pos (0) /*!< PS2_T::INTSTS: RXIF Position */ +#define PS2_INTSTS_RXIF_Msk (0x1ul << PS2_INTSTS_RXIF_Pos) /*!< PS2_T::INTSTS: RXIF Mask */ + +#define PS2_INTSTS_TXIF_Pos (1) /*!< PS2_T::INTSTS: TXIF Position */ +#define PS2_INTSTS_TXIF_Msk (0x1ul << PS2_INTSTS_TXIF_Pos) /*!< PS2_T::INTSTS: TXIF Mask */ + +/**@}*/ /* PS2_CONST */ +/**@}*/ /* end of PS2 register group */ + + +/*---------------------- Pulse Width Modulation Controller -------------------------*/ +/** + @addtogroup PWM Pulse Width Modulation Controller(PWM) + Memory Mapped Structure for PWM Controller +@{ */ + +typedef struct { + + + /** + * CLKPSC + * =================================================================================================== + * Offset: 0x00 PWM Clock Prescale Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |CLKPSC01 |PWM Counter Base-Clock Prescale For PWM Pair Of Channel 0 And Channel 1 + * | | |The base-clock of PWM counter is decided by clock pre-scalar and clock divider. + * | | |Each PWM pair share one PWM counter base-clock prescaler. + * | | |The base-clock of PWM counter is divided by (CLKPSC01 + 1). + * | | |If the value of CLKPSC01 is zero, the base-clock prescaler will stop output clock and corresponding PWM counter will also stop. + * |[8:15] |CLKPSC23 |PWM Counter Base-Clock Prescale For PWM Pair Of Channel 2 And Channel 3 + * | | |The base-clock of PWM counter is decided by clock pre-scalar and clock divider. + * | | |Each PWM pair share one PWM counter base-clock prescaler. + * | | |The base-clock of PWM counter is divided by (CLKPSC23 + 1). + * | | |If the value of CLKPSC23 is zero, the base-clock prescaler will stop output clock and corresponding PWM counter will also stop. + * |[16:23] |CLKPSC45 |PWM Counter Base-Clock Prescale For PWM Pair Of Channel 4 And Channel 5 + * | | |The base-clock of PWM counter is decided by clock pre-scalar and clock divider. + * | | |Each PWM pair share one PWM counter base-clock prescaler. + * | | |The base-clock of PWM counter is divided by (CLKPSC45 + 1). + * | | |If the value of CLKPSC45 is zero, the base-clock prescaler will stop output clock and corresponding PWM counter will also stop. + */ + __IO uint32_t CLKPSC; + + /** + * CLKDIV + * =================================================================================================== + * Offset: 0x04 PWM Clock Divide Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |CLKDIV0 |PWM Counter Base-Clock Divide For PWMx_CH0 + * | | |(Table is the same as CLKDIV5) + * |[4:6] |CLKDIV1 |PWM Counter Base-Clock Divide For PWMx_CH1 + * | | |(Table is the same as CLKDIV5) + * |[8:10] |CLKDIV2 |PWM Counter Base-Clock Divide For PWMx_CH2 + * | | |(Table is the same as CLKDIV5) + * |[12:14] |CLKDIV3 |PWM Counter Base-Clock Divide For PWMx_CH3 + * | | |(Table is the same as CLKDIV5) + * |[16:18] |CLKDIV4 |PWM Counter Base-Clock Divide For PWMx_CH4 + * | | |(Table is the same as CLKDIV5) + * |[20:22] |CLKDIV5 |PWM Counter Base-Clock Divide For PWMx_CH5 + * | | |The base-clock of PWM counter is decided by clock pre-scalar and clock divider. + * | | |Each PWM counter has independent clock divider control register and the divided value is listed in the table below:. + * | | |000 = 2. + * | | |001 = 4. + * | | |010 = 8. + * | | |011 = 16. + * | | |100 = 1. + */ + __IO uint32_t CLKDIV; + + /** + * CTL + * =================================================================================================== + * Offset: 0x08 PWM Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |CMPINV |PWM Comparator Output Inverter Enable Control + * | | |When CMPINV is set to high, the PWM comparator output signals will be inversed, + * | | |0 = Comparator output inverter Disabled. + * | | |1 = Comparator output inverter Enabled. + * | | |Note: Each bit control corresponding PWM channel + * |[6] |OUTMODE |PWM Output Mode + * | | |The register controls the output mode of PWM + * | | |0 = PWM output at independent mode. + * | | |1 = PWM output at complementary mode. + * |[7] |GROUPEN |Group Mode Enable Control + * | | |0 = The signals timing of each PWM channel are independent. + * | | |1 = Unify the signals timing of PWM0, PWM2 and PWM4 in the same phase which is controlled by PWM0 and unify the signals timing of PWM1, PWM3 and PWM5 in the same phase which is controlled by PWM1. + * |[8:13] |PINV |PWM Output Polar Inverse Enable Control + * | | |The register controls polarity state of PWM output + * | | |0 = PWM output polar inverse Disabled. + * | | |1 = PWM output polar inverse Enabled. + * | | |Note: Each bit controls the corresponding PWM channel. + * |[15] |SYNCEN |Synchronous Mode Enable Control + * | | |0 = The signals timing of each PWM channel are independent. + * | | |1 = Unify the signals timing of PWM0 and PWM1 in the same phase which is controlled by PWM0 and so as another two PWM pair. + * | | |Note: If Group and Synchronous mode are enabled simultaneously, the Synchronous mode will be inactive. + * |[16:21] |CNTMODE |PWM Counter Operation Mode + * | | |0 = PWM counter working as One-shot mode. + * | | |1 = PWM counter working as Auto-reload mode. + * | | |Note: Each bit control corresponding PWM channel + * | | |Note: If there is a transition at this bit, it will cause PWM_PERIODn and PWM_CMPDATn be cleared. + * |[24:29] |CNTTYPE |PWM Counter Operation Aligned Type + * | | |0 = PWM counter operating as Edge-aligned type. + * | | |1 = PWM counter operating as Center-aligned type. + * | | |Note: Each bit control corresponding PWM channel + * |[31] |DBGTRIOFF |ICE Debug Mode Acknowledge Disable Control (Write Protect) + * | | |0 = ICE debug mode acknowledgement effects PWM output. + * | | |PWM pin will be forced as tri-state while ICE debug mode acknowledged. + * | | |1 = ICE debug mode acknowledgement disabled. + * | | |PWM pin will keep output no matter ICE debug mode acknowledged or not. + */ + __IO uint32_t CTL; + + /** + * CNTEN + * =================================================================================================== + * Offset: 0x0C PWM Counter Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |CNTEN |PWM Counter Enable Control + * | | |0 = PWM Counter Stop Running. + * | | |1 = PWM Counter Start Running. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t CNTEN; + + /** + * PERIOD + * =================================================================================================== + * Offset: 0x10 ~ 0x24 PWM Counter Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |PERIOD |PWM Period Register + * | | |PERIOD determines the PWM period. + * | | |PWM frequency = PWMxy_CLK/[(prescale+1)*(clock divider)*(PERIOD+1)]; where xy, could be 01, 23 or 45, depends on selected PWM channel. + * | | |For Edge-aligned mode: + * | | |l Duty ratio = (CMP+1)/(PERIOD+1). + * | | |l CMP >= PERIOD: PWM output is always high. + * | | |l CMP < PERIOD: PWM low width = (PERIOD-CMP) unit; PWM high width = (CMP+1) unit. + * | | |l CMP = 0: PWM low width = (PERIOD) unit; PWM high width = 1 unit. + * | | |For Center-aligned mode: + * | | |l Duty ratio = [(2 x CMP) + 1]/[2 x (PERIOD+1)]. + * | | |l CMP > PERIOD: PWM output is always high. + * | | |l CMP <= PERIOD: PWM low width = 2 x (PERIOD-CMP) + 1 unit; PWM high width = (2 x CMP) + 1 unit. + * | | |l CMP = 0: PWM low width = 2 x PERIOD + 1 unit; PWM high width = 1 unit. + * | | |(Unit = one PWM clock cycle). + * | | |Note1: Any write to PERIOD will take effect in next PWM cycle. + * | | |Note2: When PWM operating at center-aligned type, PERIOD value should be set between 0x0000 to 0xFFFE. + * | | |If PERIOD equal to 0xFFFF, the PWM will work unpredictable. + * | | |Note3: When PERIOD value is set to 0, PWM output is always high. + */ + __IO uint32_t PERIOD[6]; + + /** + * CMPDAT + * =================================================================================================== + * Offset: 0x28 ~0x3C PWM Comparator Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |CMP |PWM Duty Register + * | | |CMP determines the PWM duty. + * | | |PWM frequency = PWMxy_CLK/[(prescale+1)*(clock divider)*(PERIOD+1)]; where xy, could be 01, 23 or, 45, depends on selected PWM channel. + * | | |For Edge-aligned mode: + * | | |l Duty ratio = (CMP+1)/(PERIOD+1). + * | | |l CMP >= PERIOD: PWM output is always high. + * | | |l CMP < PERIOD: PWM low width = (PERIOD-CMP) unit; PWM high width = (CMP+1) unit. + * | | |l CMP = 0: PWM low width = (PERIOD) unit; PWM high width = 1 unit. + * | | |For Center-aligned mode: + * | | |l Duty ratio = [(2 x CMP) + 1]/[2 x (PERIOD+1)]. + * | | |l CMP > PERIOD: PWM output is always high. + * | | |l CMP <= PERIOD: PWM low width = 2 x (PERIOD-CMP) + 1 unit; PWM high width = (2 x CMP) + 1 unit. + * | | |l CMP = 0: PWM low width = 2 x PERIOD + 1 unit; PWM high width = 1 unit. + * | | |(Unit = one PWM clock cycle). + * | | |Note: Any write to CMP will take effect in next PWM cycle. + */ + __IO uint32_t CMPDAT[6]; + + /** + * CNT + * =================================================================================================== + * Offset: 0x40 ~ 0x54 PWM Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |CNT |PWM Data Register + * | | |User can monitor CNT to know the current value in 16-bit down counter. + * | | |Note: It is recommended that read this register when PWM engine clock is source from system clock, otherwise a transition value of PWM counter may be read. + */ + __I uint32_t CNT[6]; + + /** + * MSKEN + * =================================================================================================== + * Offset: 0x58 PWM Mask Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |MSKEN |PWM Mask Enable Control + * | | |The PWM output signal will be masked when this bit is enabled. + * | | |The corresponding PWMn channel will be output with MSKDAT data. + * | | |0 = PWM output signal is non-masked. + * | | |1 = PWM output signal is masked and output with MSKDAT data. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t MSKEN; + + /** + * MSK + * =================================================================================================== + * Offset: 0x5C PWM Mask Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |MSKDAT |PWM Mask Data Bit: + * | | |This data bit control the state of PWMn output pin, if corresponding mask function is enabled. + * | | |0 = Output logic low to PWMn. + * | | |1 = Output logic high to PWMn. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t MSK; + + /** + * DTCTL + * =================================================================================================== + * Offset: 0x60 PWM Dead-zone Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DTCNT01 |Dead-Zone Interval For PWM Pair Of Channel 0 And Channel 1 + * | | |These 8-bit determine the Dead-zone length. + * | | |The unit time of Dead-zone length is received from corresponding PWM_CLKDIV. + * |[8:15] |DTCNT23 |Dead-Zone Interval For PWM Pair Of Channel 2 And Channel 3 + * | | |These 8-bit determine the Dead-zone length. + * | | |The unit time of Dead-zone length is received from corresponding PWM_CLKDIV. + * |[16:23] |DTCNT45 |Dead-Zone Interval For PWM Pair Of Channel 4 And Channel 5 + * | | |These 8-bit determine the Dead-zone length. + * | | |The unit time of Dead-zone length is received from corresponding PWM_CLKDIV. + * |[24:25] |DTDIV |Dead-Zone Generator Divider + * | | |00 = Dead-zone clock equal to PWM base clock divide 1. + * | | |01 = Dead-zone clock equal to PWM base clock divide 2. + * | | |10 = Dead-zone clock equal to PWM base clock divide 4. + * | | |11 = Dead-zone clock equal to PWM base clock divide 8. + * |[28] |DTEN01 |Dead-Zone Enable Control For PWM Pair Of Channel 0 And Channel 1 + * | | |Dead-zone insertion is only active when this pair of complementary PWM is enabled. + * | | |If Dead-zone insertion is inactive, the outputs of pin pair are complementary without any delay. + * | | |0 = Dead-zone insertion Disabled. + * | | |1 = Dead-zone insertion Enabled. + * |[29] |DTEN23 |Dead-Zone Enable Control For PWM Pair Of Channel 2 And Channel 3 + * | | |Dead-zone insertion is only active when this pair of complementary PWM is enabled. + * | | |If Dead-zone insertion is inactive, the outputs of pin pair are complementary without any delay. + * | | |0 = Dead-zone insertion Disabled. + * | | |1 = Dead-zone insertion Enabled. + * |[30] |DTEN45 |Dead-Zone Enable Control For PWM Pair Of Channel 4 And Channel 5 + * | | |Dead-zone insertion is only active when this pair of complementary PWM is enabled. + * | | |If Dead-zone insertion is inactive, the outputs of pin pair are complementary without any delay. + * | | |0 = Dead-zone insertion Disabled. + * | | |1 = Dead-zone insertion Enabled. + */ + __IO uint32_t DTCTL; + + /** + * TRGADCTL + * =================================================================================================== + * Offset: 0x64 PWM Trigger Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |PTRGEN |PWM Period Point Trigger Enable Control + * | | |0 = PWM period point trigger ADC function Disabled. + * | | |1 = PWM period point trigger ADC function Enabled. + * | | |PWM can trigger ADC to start conversion when PWM counter down count to zero if this bit is set to1. + * | | |Note: Each bit controls the corresponding PWM channel. + * |[8:13] |CTRGEN |PWM Center Point Trigger Enable Control + * | | |0 = PWM center point trigger ADC function Disabled. + * | | |1 = PWM center point trigger ADC function Enabled. + * | | |PWM can trigger ADC to start conversion when PWM counter up count to (PERIODn+1) if this bit is set to1. + * | | |Note1: This bit should keep at 0 when PWM counter operating in Edge-aligned type. + * | | |Note2: Each bit controls the corresponding PWM channel. + * |[16:21] |FTRGEN |PWM Falling Edge Point Trigger Enable Control + * | | |0 = PWM falling edge point trigger ADC function Disabled. + * | | |1 = PWM falling edge point trigger ADC function Enabled. + * | | |PWM can trigger ADC to start conversion when PWM output pin falling edge is detected if this bit is set to1. + * | | |Note: Each bit controls the corresponding PWM channel. + * |[24:29] |RTRGEN |PWM Rising Edge Point Trigger Enable Control + * | | |0 = PWM rising edge point trigger ADC function Disabled. + * | | |1 = PWM rising edge point trigger ADC function Enabled. + * | | |PWM can trigger ADC to start conversion when PWM output pin rising edge is detected if this bit is set to1. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t TRGADCTL; + + /** + * TRGADCSTS + * =================================================================================================== + * Offset: 0x68 PWM Trigger ADC Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |PTRGF |PWM Period Point Trigger Flag + * | | |This bit is set to 1 by hardware when PWM counter down count to zero if corresponding PTRGEN bit is 1. + * | | |After this bit is set to 1, ADC will start conversion if ADC triggered source is selected by PWM. + * | | |Note1: Write 1 to clear this bit. + * | | |Note2: Each bit controls the corresponding PWM channel. + * |[8:13] |CTRGF |PWM Center Point Trigger Flag + * | | |This bit is set to 1 by hardware when PWM counter up counts to (PERIODn+1) if the corresponding CTRGEN bit is 1. + * | | |After this bit is set to 1, ADC will start conversion if ADC triggered source is selected by PWM. + * | | |Note1: Write 1 to clear this bit. + * | | |Note2: Each bit controls the corresponding PWM channel. + * |[16:21] |FTRGF |PWM Falling Edge Point Trigger Indicator + * | | |This bit is set to 1 by hardware when PWM output pin falling edge is detected if corresponding FETRGEN bit is 1. + * | | |After this bit is set to 1, ADC will start conversion if ADC triggered source is selected by PWM. + * | | |Note1: Write 1 to clear this bit. + * | | |Note2: Each bit controls the corresponding PWM channel. + * |[24:29] |RTRGF |PWM Rising Edge Point Trigger Indicator + * | | |This bit is set to 1 by hardware when PWM output pin rising edge is detected if corresponding RETRGEN bit is 1. + * | | |After this bit is set to 1, ADC will start conversion if ADC triggered source is selected by PWM. + * | | |Note1: Write 1 to clear this bit. + * | | |Note2: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t TRGADCSTS; + + /** + * BRKCTL + * =================================================================================================== + * Offset: 0x6C PWM Brake Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BRKP0EN |Brake0 Function Enable Control + * | | |0 = Brake0 detect function Disabled. + * | | |1 = Brake0 detect function Enabled. + * |[1] |BRK0NFDIS |PWM Brake 0 Noise Filter Disable Control + * | | |0 = Noise filter of PWM Brake 0 Enabled. + * | | |1 = Noise filter of PWM Brake 0 Disabled. + * |[2] |BRK0INV |Inverse BKP0 State + * | | |0 = The state of pin BKPx0 is passed to the negative edge detector. + * | | |1 = The inversed state of pin BKPx0 is passed to the negative edge detector. + * |[6:7] |BRK0NFSEL |Brake 0 (BKPx0 Pin) Edge Detector Filter Clock Selection + * | | |00 = Filter clock = HCLK. + * | | |01 = Filter clock = HCLK/2. + * | | |10 = Filter clock = HCLK/4. + * | | |11 = Filter clock = HCLK/16. + * |[8] |BRKP1EN |Brake1 Function Enable Control + * | | |0 = Brake1 function Disabled. + * | | |1 = Brake1 function Enabled. + * |[9] |BRK1NFDIS |PWM Brake 1 Noise Filter Disable Control + * | | |0 = Noise filter of PWM Brake 1 Enabled. + * | | |1 = Noise filter of PWM Brake 1 Disabled. + * |[10] |BRK1INV |Inverse BKP1 State + * | | |0 = The state of pin BKPx1 is passed to the negative edge detector. + * | | |1 = The inversed state of pin BKPx1 is passed to the negative edge detector. + * |[12:13] |BK1SEL |Brake Function 1 Source Selection + * | | |00 = From external pin BKP1. + * | | |01 = From analog comparator 0 output (CPO0). + * | | |10 = From analog comparator 1 output (CPO1). + * | | |11 = Reserved. + * |[14:15] |BRK1NFSEL |Brake 1 (BKPx1 Pin) Edge Detector Filter Clock Selection + * | | |00 = Filter clock = HCLK. + * | | |01 = Filter clock = HCLK/2. + * | | |10 = Filter clock = HCLK/4. + * | | |11 = Filter clock = HCLK/16. + * |[16] |CPO0BKEN |CPO0 Digital Output As Brake0 Source Enable Control + * | | |0 = CPO0 as one brake source in Brake 0 Disabled. + * | | |1 = CPO0 as one brake source in Brake 0 Enabled. + * |[17] |CPO1BKEN |CPO1 Digital Output As Brake 0 Source Enable Control + * | | |0 = CPO1 as one brake source in Brake 0 Disabled. + * | | |1 = CPO1 as one brake source in Brake 0 Enabled. + * |[18] |CPO2BKEN |CPO2 Digital Output As Brake 0 Source Enable Control + * | | |0 = CPO2 as one brake source in Brake 0 Disabled. + * | | |1 = CPO2 as one brake source in Brake 0 Enabled. + * |[19] |LVDBKEN |Low-Level Detection Trigger PWM Brake Function 1 Enable Control + * | | |0 = Brake Function 1 triggered by Low-level detection Disabled. + * | | |1 = Brake Function 1 triggered by Low-level detection Enabled. + * |[24:29] |BKOD |PWM Brake Output Data Register + * | | |0 = PWM output low when fault brake conditions asserted. + * | | |1 = PWM output high when fault brake conditions asserted. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t BRKCTL; + + /** + * INTCTL + * =================================================================================================== + * Offset: 0x70 PWM Interrupt Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |PINTTYPE |PWM Period Interrupt Type Selection + * | | |0 = PIF[n] will be set if PWM counter underflow. + * | | |1 = PIF[n] will be set if PWM counter matches PWM_PERIODn register. + * | | |Note1: This bit should keep at 0 when PWM counter operating in Edge-aligned type. + * | | |Note2: Each bit controls the corresponding PWM channel. + * |[8:13] |DINTTYPE |PWM Duty Interrupt Type Selection + * | | |0 = DIF[n] will be set if PWM counter matches PWM_CMPDATn register during down counting. + * | | |1 = DIF[n] will be set if PWM counter matches PWM_CMPDATn register during up counting. + * | | |Note1: This bit should keep at 0 when PWM counter operating in Edge-aligned type. + * | | |Note2: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t INTCTL; + + /** + * INTEN + * =================================================================================================== + * Offset: 0x74 PWM Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |PIEN |PWM Period Interrupt Enable Control + * | | |0 = Period interrupt Disabled. + * | | |1 = Period interrupt Enabled. + * | | |Note: Each bit controls the corresponding PWM channel. + * |[6] |BRKIEN |Brake0 And Brak1 Interrupt Enable Control + * | | |0 = Disabling flags BFK0 and BFK1 to trigger PWM interrupt. + * | | |1 = Enabling flags BRKIF0 and BRKIF1 can trigger PWM interrupt. + * |[8:13] |DIEN |PWM Duty Interrupt Enable Control + * | | |0 = Duty interrupt Disabled. + * | | |1 = Duty interrupt Enabled. + * | | |Note: Each bit controls the corresponding PWM channel. + * |[16:21] |RLIEN |Rising Latch Interrupt Enable Control + * | | |0 = Rising latch interrupt Disabled. + * | | |1 = Rising latch interrupt Enabled. + * | | |Note: Each bit controls the corresponding PWM channel. + * |[24:29] |FLIEN |Falling Latch Interrupt Enable Control + * | | |0 = Falling latch interrupt Disabled. + * | | |1 = Falling latch interrupt Enabled. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x78 PWM Interrupt Flag Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |PIF |PWM Period Interrupt Flag + * | | |This bit is set by hardware when PWM counter reaches the requirement condition of interrupt (depending on PINTTYPE (PWM_INTCTL[n]) ). + * | | |Software can write 1 to clear this bit to 0. + * |[6] |BRKIF0 |PWM Brake0 Flag + * | | |0 = PWM Brake 0 is able to poll falling signal at BKP0 and has not recognized any one. + * | | |1 = When PWM Brake 0 detects a falling signal at BKP0, this flag will be set to high. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[7] |BRKIF1 |PWM Brake1 Flag + * | | |0 = PWM Brake 1 is able to poll falling signal at BKP1 and has not recognized any one. + * | | |1 = When PWM Brake 1 detects a falling signal at pin BKP1, this flag will be set to high. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[8:13] |DIF |PWM Duty Interrupt Flag + * | | |Flag is set by hardware when channel 0 PWM counter down count and reaches CMP0. + * | | |Software can clear this bit by writing 1 to it. + * | | |Note: If CMP is equal to PERIOD, this flag is not working in edge-aligned type selection. + * |[14] |BRKLK0 |PWM Brake0 Locked + * | | |0 = Brake 0 state is released. + * | | |1 = When PWM Brake detects a falling signal at BKP0, this flag will be set to high to indicate the Brake0 state is locked. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[16:21] |CRLIF |Capture Rising Latch Interrupt Flag + * | | |0 = No capture rising latch condition happened. + * | | |1 = Capture rising latch condition happened, this flag will be set to high. + * | | |Note: This bit must be cleared by writing 1 to it. + * |[22] |BRKSTS0 |Brake 0 Status (Read Only) + * | | |0 = PWM had been out of Brake 0 state. + * | | |1 = PWM is in Brake 0 state. + * |[23] |BRKSTS1 |Brake 1 Status (Read Only) + * | | |0 = PWM had been out of Brake 1 state. + * | | |1 = PWM is in Brake 1 state. + * |[24:29] |CFLIF |Capture Falling Latch Interrupt Flag + * | | |0 = No capture falling latch condition happened. + * | | |1 = Capture falling latch condition happened, this flag will be set to high. + * | | |Note: This bit must be cleared by writing 1 to it. + */ + __IO uint32_t INTSTS; + + /** + * POEN + * =================================================================================================== + * Offset: 0x7C PWM Output Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |POEN |PWM Pin Output Enable Control + * | | |0 = PWM pin at tri-state. + * | | |1 = PWM pin in output mode. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t POEN; + + /** + * CAPCTL + * =================================================================================================== + * Offset: 0x80 PWM Capture Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |CAPEN |Capture Function Enable Control + * | | |0 = Capture function Disabled. RCAPDAT and FCAPDAT will not be updated. + * | | |1 = Capture function Enabled. + * | | |Capture latched the PWM counter value and saved to RCAPDAT (Rising latch) and FCAPDAT (Falling latch). + * | | |Note: Each bit controls the corresponding PWM channel. + * |[8:13] |CAPINV |Capture Inverter Enable Control + * | | |0 = Capture source inverter Disabled. + * | | |1 = Capture source inverter Enabled. Reverse the input signal from GPIO + * | | |Note: Each bit controls the corresponding PWM channel. + * |[16:21] |RCRLDEN |Rising Latch Reload Enable Control + * | | |0 = Rising latch reload counter Enabled. + * | | |1 = Rising latch reload counter Enabled. + * |[24:29] |FCRLDEN |Falling Latch Reload Enable Control + * | | |0 = Falling latch reload counter Disabled. + * | | |1 = Falling latch + * | | |reload counter Enabled. + */ + __IO uint32_t CAPCTL; + + /** + * CAPINEN + * =================================================================================================== + * Offset: 0x84 PWM Capture Input Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |CAPINEN |Capture Input Enable Control + * | | |0 = PWM Channel capture input path Disabled. + * | | |The input of PWM channel capture function is always regarded as 0. + * | | |1 = PWM Channel capture input path Enabled. + * | | |The input of PWM channel capture function comes from correlative multifunction pin. + * | | |Note: Each bit controls the corresponding PWM channel. + */ + __IO uint32_t CAPINEN; + + /** + * CAPSTS + * =================================================================================================== + * Offset: 0x88 PWM Capture Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |CRIFOV |Rising Latch Interrupt Flag Overrun Status + * | | |This flag indicates if rising latch happened when the corresponding CRLIF is 1 + * | | |Note: This bit will be cleared automatically when user clear corresponding CRLIF. + * |[8:13] |FLIFOV |Falling Latch Interrupt Flag Overrun Status + * | | |This flag indicates if falling latch happened when the corresponding CFLIF is 1 + * | | |Note: This bit will be cleared automatically when user clear corresponding CFLIF. + */ + __I uint32_t CAPSTS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * RCAPDAT0 + * =================================================================================================== + * Offset: 0x90 PWM Capture Rising Latch Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RCAPDAT |Capture Rising Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has rising transition. + */ + __I uint32_t RCAPDAT0; + + /** + * FCAPDAT0 + * =================================================================================================== + * Offset: 0x94 PWM Capture Falling Latch Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FCAPDAT |Capture Falling Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has Falling transition. + */ + __I uint32_t FCAPDAT0; + + /** + * RCAPDAT1 + * =================================================================================================== + * Offset: 0x98 PWM Capture Rising Latch Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RCAPDAT |Capture Rising Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has rising transition. + */ + __I uint32_t RCAPDAT1; + + /** + * FCAPDAT1 + * =================================================================================================== + * Offset: 0x9C PWM Capture Falling Latch Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FCAPDAT |Capture Falling Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has Falling transition. + */ + __I uint32_t FCAPDAT1; + + /** + * RCAPDAT2 + * =================================================================================================== + * Offset: 0xA0 PWM Capture Rising Latch Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RCAPDAT |Capture Rising Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has rising transition. + */ + __I uint32_t RCAPDAT2; + + /** + * FCAPDAT2 + * =================================================================================================== + * Offset: 0xA4 PWM Capture Falling Latch Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FCAPDAT |Capture Falling Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has Falling transition. + */ + __I uint32_t FCAPDAT2; + + /** + * RCAPDAT3 + * =================================================================================================== + * Offset: 0xA8 PWM Capture Rising Latch Register 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RCAPDAT |Capture Rising Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has rising transition. + */ + __I uint32_t RCAPDAT3; + + /** + * FCAPDAT3 + * =================================================================================================== + * Offset: 0xAC PWM Capture Falling Latch Register 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FCAPDAT |Capture Falling Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has Falling transition. + */ + __I uint32_t FCAPDAT3; + + /** + * RCAPDAT4 + * =================================================================================================== + * Offset: 0xB0 PWM Capture Rising Latch Register 4 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RCAPDAT |Capture Rising Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has rising transition. + */ + __I uint32_t RCAPDAT4; + + /** + * FCAPDAT4 + * =================================================================================================== + * Offset: 0xB4 PWM Capture Falling Latch Register 4 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FCAPDAT |Capture Falling Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has Falling transition. + */ + __I uint32_t FCAPDAT4; + + /** + * RCAPDAT5 + * =================================================================================================== + * Offset: 0xB8 PWM Capture Rising Latch Register 5 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RCAPDAT |Capture Rising Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has rising transition. + */ + __I uint32_t RCAPDAT5; + + /** + * FCAPDAT5 + * =================================================================================================== + * Offset: 0xBC PWM Capture Falling Latch Register 5 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FCAPDAT |Capture Falling Latch Register + * | | |Latch the PWM counter when Channel 0/1/2/3/4/5 has Falling transition. + */ + __I uint32_t FCAPDAT5; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[8]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SBS0 + * =================================================================================================== + * Offset: 0xE0 PWM0 Synchronous Busy Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SYNCBUSY |PWM Synchronous Busy + * | | |When software writes PWM_PERIOD0/PWM_CMPDAT0/PWM_CLKPSC or switch PWM0 counter operation mode CNTMOD (CONR[16]), PWM will have a busy time to update these values completely because PWM clock may be different from system clock domain. + * | | |Software needs to check this busy status before writes PWM_PERIOD0/PWM_CMPDAT0/ PWM_CLKPSC or switch PWM0 counter operation mode to make sure previous setting has been update completely. + * | | |This bit will be set when software writes PWM_PERIOD0/PWM_CMPDAT0/PWM_CLKPSC or switch PWM0 operation mode CNTMOD (CONR[16]) and will be cleared by hardware automatically when PWM update these value completely. + */ + __I uint32_t SBS[6]; + +} PWM_T; + +/** + @addtogroup PWM_CONST PWM Bit Field Definition + Constant Definitions for PWM Controller +@{ */ + +#define PWM_CLKPSC_CLKPSC01_Pos (0) /*!< PWM_T::CLKPSC: CLKPSC01 Position */ +#define PWM_CLKPSC_CLKPSC01_Msk (0xfful << PWM_CLKPSC_CLKPSC01_Pos) /*!< PWM_T::CLKPSC: CLKPSC01 Mask */ + +#define PWM_CLKPSC_CLKPSC23_Pos (8) /*!< PWM_T::CLKPSC: CLKPSC23 Position */ +#define PWM_CLKPSC_CLKPSC23_Msk (0xfful << PWM_CLKPSC_CLKPSC23_Pos) /*!< PWM_T::CLKPSC: CLKPSC23 Mask */ + +#define PWM_CLKPSC_CLKPSC45_Pos (16) /*!< PWM_T::CLKPSC: CLKPSC45 Position */ +#define PWM_CLKPSC_CLKPSC45_Msk (0xfful << PWM_CLKPSC_CLKPSC45_Pos) /*!< PWM_T::CLKPSC: CLKPSC45 Mask */ + +#define PWM_CLKDIV_CLKDIV0_Pos (0) /*!< PWM_T::CLKDIV: CLKDIV0 Position */ +#define PWM_CLKDIV_CLKDIV0_Msk (0x7ul << PWM_CLKDIV_CLKDIV0_Pos) /*!< PWM_T::CLKDIV: CLKDIV0 Mask */ + +#define PWM_CLKDIV_CLKDIV1_Pos (4) /*!< PWM_T::CLKDIV: CLKDIV1 Position */ +#define PWM_CLKDIV_CLKDIV1_Msk (0x7ul << PWM_CLKDIV_CLKDIV1_Pos) /*!< PWM_T::CLKDIV: CLKDIV1 Mask */ + +#define PWM_CLKDIV_CLKDIV2_Pos (8) /*!< PWM_T::CLKDIV: CLKDIV2 Position */ +#define PWM_CLKDIV_CLKDIV2_Msk (0x7ul << PWM_CLKDIV_CLKDIV2_Pos) /*!< PWM_T::CLKDIV: CLKDIV2 Mask */ + +#define PWM_CLKDIV_CLKDIV3_Pos (12) /*!< PWM_T::CLKDIV: CLKDIV3 Position */ +#define PWM_CLKDIV_CLKDIV3_Msk (0x7ul << PWM_CLKDIV_CLKDIV3_Pos) /*!< PWM_T::CLKDIV: CLKDIV3 Mask */ + +#define PWM_CLKDIV_CLKDIV4_Pos (16) /*!< PWM_T::CLKDIV: CLKDIV4 Position */ +#define PWM_CLKDIV_CLKDIV4_Msk (0x7ul << PWM_CLKDIV_CLKDIV4_Pos) /*!< PWM_T::CLKDIV: CLKDIV4 Mask */ + +#define PWM_CLKDIV_CLKDIV5_Pos (20) /*!< PWM_T::CLKDIV: CLKDIV5 Position */ +#define PWM_CLKDIV_CLKDIV5_Msk (0x7ul << PWM_CLKDIV_CLKDIV5_Pos) /*!< PWM_T::CLKDIV: CLKDIV5 Mask */ + +#define PWM_CTL_CMPINV_Pos (0) /*!< PWM_T::CTL: CMPINV Position */ +#define PWM_CTL_CMPINV_Msk (0x3ful << PWM_CTL_CMPINV_Pos) /*!< PWM_T::CTL: CMPINV Mask */ + +#define PWM_CTL_OUTMODE_Pos (6) /*!< PWM_T::CTL: OUTMODE Position */ +#define PWM_CTL_OUTMODE_Msk (0x1ul << PWM_CTL_OUTMODE_Pos) /*!< PWM_T::CTL: OUTMODE Mask */ + +#define PWM_CTL_GROUPEN_Pos (7) /*!< PWM_T::CTL: GROUPEN Position */ +#define PWM_CTL_GROUPEN_Msk (0x1ul << PWM_CTL_GROUPEN_Pos) /*!< PWM_T::CTL: GROUPEN Mask */ + +#define PWM_CTL_PINV_Pos (8) /*!< PWM_T::CTL: PINV Position */ +#define PWM_CTL_PINV_Msk (0x3ful << PWM_CTL_PINV_Pos) /*!< PWM_T::CTL: PINV Mask */ + +#define PWM_CTL_SYNCEN_Pos (15) /*!< PWM_T::CTL: SYNCEN Position */ +#define PWM_CTL_SYNCEN_Msk (0x1ul << PWM_CTL_SYNCEN_Pos) /*!< PWM_T::CTL: SYNCEN Mask */ + +#define PWM_CTL_CNTMODE_Pos (16) /*!< PWM_T::CTL: CNTMODE Position */ +#define PWM_CTL_CNTMODE_Msk (0x3ful << PWM_CTL_CNTMODE_Pos) /*!< PWM_T::CTL: CNTMODE Mask */ + +#define PWM_CTL_CNTTYPE_Pos (24) /*!< PWM_T::CTL: CNTTYPE Position */ +#define PWM_CTL_CNTTYPE_Msk (0x3ful << PWM_CTL_CNTTYPE_Pos) /*!< PWM_T::CTL: CNTTYPE Mask */ + +#define PWM_CTL_DBGTRIOFF_Pos (31) /*!< PWM_T::CTL: DBGTRIOFF Position */ +#define PWM_CTL_DBGTRIOFF_Msk (0x1ul << PWM_CTL_DBGTRIOFF_Pos) /*!< PWM_T::CTL: DBGTRIOFF Mask */ + +#define PWM_CNTEN_CNTEN_Pos (0) /*!< PWM_T::CNTEN: CNTEN Position */ +#define PWM_CNTEN_CNTEN_Msk (0x3ful << PWM_CNTEN_CNTEN_Pos) /*!< PWM_T::CNTEN: CNTEN Mask */ + +#define PWM_PERIOD0_PERIOD_Pos (0) /*!< PWM_T::PERIOD: PERIOD Position */ +#define PWM_PERIOD0_PERIOD_Msk (0xfffful << PWM_PERIOD0_PERIOD_Pos) /*!< PWM_T::PERIOD: PERIOD Mask */ + +#define PWM_PERIOD1_PERIOD_Pos (0) /*!< PWM_T::PERIOD: PERIOD Position */ +#define PWM_PERIOD1_PERIOD_Msk (0xfffful << PWM_PERIOD1_PERIOD_Pos) /*!< PWM_T::PERIOD: PERIOD Mask */ + +#define PWM_PERIOD2_PERIOD_Pos (0) /*!< PWM_T::PERIOD: PERIOD Position */ +#define PWM_PERIOD2_PERIOD_Msk (0xfffful << PWM_PERIOD2_PERIOD_Pos) /*!< PWM_T::PERIOD: PERIOD Mask */ + +#define PWM_PERIOD3_PERIOD_Pos (0) /*!< PWM_T::PERIOD: PERIOD Position */ +#define PWM_PERIOD3_PERIOD_Msk (0xfffful << PWM_PERIOD3_PERIOD_Pos) /*!< PWM_T::PERIOD: PERIOD Mask */ + +#define PWM_PERIOD4_PERIOD_Pos (0) /*!< PWM_T::PERIOD: PERIOD Position */ +#define PWM_PERIOD4_PERIOD_Msk (0xfffful << PWM_PERIOD4_PERIOD_Pos) /*!< PWM_T::PERIOD: PERIOD Mask */ + +#define PWM_PERIOD5_PERIOD_Pos (0) /*!< PWM_T::PERIOD: PERIOD Position */ +#define PWM_PERIOD5_PERIOD_Msk (0xfffful << PWM_PERIOD5_PERIOD_Pos) /*!< PWM_T::PERIOD: PERIOD Mask */ + +#define PWM_CMPDAT0_CMP_Pos (0) /*!< PWM_T::CMPDAT: CMP Position */ +#define PWM_CMPDAT0_CMP_Msk (0xfffful << PWM_CMPDAT0_CMP_Pos) /*!< PWM_T::CMPDAT: CMP Mask */ + +#define PWM_CMPDAT1_CMP_Pos (0) /*!< PWM_T::CMPDAT: CMP Position */ +#define PWM_CMPDAT1_CMP_Msk (0xfffful << PWM_CMPDAT1_CMP_Pos) /*!< PWM_T::CMPDAT: CMP Mask */ + +#define PWM_CMPDAT2_CMP_Pos (0) /*!< PWM_T::CMPDAT: CMP Position */ +#define PWM_CMPDAT2_CMP_Msk (0xfffful << PWM_CMPDAT2_CMP_Pos) /*!< PWM_T::CMPDAT: CMP Mask */ + +#define PWM_CMPDAT3_CMP_Pos (0) /*!< PWM_T::CMPDAT: CMP Position */ +#define PWM_CMPDAT3_CMP_Msk (0xfffful << PWM_CMPDAT3_CMP_Pos) /*!< PWM_T::CMPDAT: CMP Mask */ + +#define PWM_CMPDAT4_CMP_Pos (0) /*!< PWM_T::CMPDAT: CMP Position */ +#define PWM_CMPDAT4_CMP_Msk (0xfffful << PWM_CMPDAT4_CMP_Pos) /*!< PWM_T::CMPDAT: CMP Mask */ + +#define PWM_CMPDAT5_CMP_Pos (0) /*!< PWM_T::CMPDAT: CMP Position */ +#define PWM_CMPDAT5_CMP_Msk (0xfffful << PWM_CMPDAT5_CMP_Pos) /*!< PWM_T::CMPDAT: CMP Mask */ + +#define PWM_CNT0_CNT_Pos (0) /*!< PWM_T::CNT: CNT Position */ +#define PWM_CNT0_CNT_Msk (0xfffful << PWM_CNT0_CNT_Pos) /*!< PWM_T::CNT: CNT Mask */ + +#define PWM_CNT1_CNT_Pos (0) /*!< PWM_T::CNT: CNT Position */ +#define PWM_CNT1_CNT_Msk (0xfffful << PWM_CNT1_CNT_Pos) /*!< PWM_T::CNT: CNT Mask */ + +#define PWM_CNT2_CNT_Pos (0) /*!< PWM_T::CNT: CNT Position */ +#define PWM_CNT2_CNT_Msk (0xfffful << PWM_CNT2_CNT_Pos) /*!< PWM_T::CNT: CNT Mask */ + +#define PWM_CNT3_CNT_Pos (0) /*!< PWM_T::CNT: CNT Position */ +#define PWM_CNT3_CNT_Msk (0xfffful << PWM_CNT3_CNT_Pos) /*!< PWM_T::CNT: CNT Mask */ + +#define PWM_CNT4_CNT_Pos (0) /*!< PWM_T::CNT: CNT Position */ +#define PWM_CNT4_CNT_Msk (0xfffful << PWM_CNT4_CNT_Pos) /*!< PWM_T::CNT: CNT Mask */ + +#define PWM_CNT5_CNT_Pos (0) /*!< PWM_T::CNT: CNT Position */ +#define PWM_CNT5_CNT_Msk (0xfffful << PWM_CNT5_CNT_Pos) /*!< PWM_T::CNT: CNT Mask */ + +#define PWM_MSKEN_MSKEN_Pos (0) /*!< PWM_T::MSKEN: MSKEN Position */ +#define PWM_MSKEN_MSKEN_Msk (0x3ful << PWM_MSKEN_MSKEN_Pos) /*!< PWM_T::MSKEN: MSKEN Mask */ + +#define PWM_MSK_MSKDAT_Pos (0) /*!< PWM_T::MSK: MSKDAT Position */ +#define PWM_MSK_MSKDAT_Msk (0x3ful << PWM_MSK_MSKDAT_Pos) /*!< PWM_T::MSK: MSKDAT Mask */ + +#define PWM_DTCTL_DTCNT01_Pos (0) /*!< PWM_T::DTCTL: DTCNT01 Position */ +#define PWM_DTCTL_DTCNT01_Msk (0xfful << PWM_DTCTL_DTCNT01_Pos) /*!< PWM_T::DTCTL: DTCNT01 Mask */ + +#define PWM_DTCTL_DTCNT23_Pos (8) /*!< PWM_T::DTCTL: DTCNT23 Position */ +#define PWM_DTCTL_DTCNT23_Msk (0xfful << PWM_DTCTL_DTCNT23_Pos) /*!< PWM_T::DTCTL: DTCNT23 Mask */ + +#define PWM_DTCTL_DTCNT45_Pos (16) /*!< PWM_T::DTCTL: DTCNT45 Position */ +#define PWM_DTCTL_DTCNT45_Msk (0xfful << PWM_DTCTL_DTCNT45_Pos) /*!< PWM_T::DTCTL: DTCNT45 Mask */ + +#define PWM_DTCTL_DTDIV_Pos (24) /*!< PWM_T::DTCTL: DTDIV Position */ +#define PWM_DTCTL_DTDIV_Msk (0x3ul << PWM_DTCTL_DTDIV_Pos) /*!< PWM_T::DTCTL: DTDIV Mask */ + +#define PWM_DTCTL_DTEN01_Pos (28) /*!< PWM_T::DTCTL: DTEN01 Position */ +#define PWM_DTCTL_DTEN01_Msk (0x1ul << PWM_DTCTL_DTEN01_Pos) /*!< PWM_T::DTCTL: DTEN01 Mask */ + +#define PWM_DTCTL_DTEN23_Pos (29) /*!< PWM_T::DTCTL: DTEN23 Position */ +#define PWM_DTCTL_DTEN23_Msk (0x1ul << PWM_DTCTL_DTEN23_Pos) /*!< PWM_T::DTCTL: DTEN23 Mask */ + +#define PWM_DTCTL_DTEN45_Pos (30) /*!< PWM_T::DTCTL: DTEN45 Position */ +#define PWM_DTCTL_DTEN45_Msk (0x1ul << PWM_DTCTL_DTEN45_Pos) /*!< PWM_T::DTCTL: DTEN45 Mask */ + +#define PWM_TRGADCTL_PTRGEN_Pos (0) /*!< PWM_T::TRGADCTL: PTRGEN Position */ +#define PWM_TRGADCTL_PTRGEN_Msk (0x3ful << PWM_TRGADCTL_PTRGEN_Pos) /*!< PWM_T::TRGADCTL: PTRGEN Mask */ + +#define PWM_TRGADCTL_CTRGEN_Pos (8) /*!< PWM_T::TRGADCTL: CTRGEN Position */ +#define PWM_TRGADCTL_CTRGEN_Msk (0x3ful << PWM_TRGADCTL_CTRGEN_Pos) /*!< PWM_T::TRGADCTL: CTRGEN Mask */ + +#define PWM_TRGADCTL_FTRGEN_Pos (16) /*!< PWM_T::TRGADCTL: FTRGEN Position */ +#define PWM_TRGADCTL_FTRGEN_Msk (0x3ful << PWM_TRGADCTL_FTRGEN_Pos) /*!< PWM_T::TRGADCTL: FTRGEN Mask */ + +#define PWM_TRGADCTL_RTRGEN_Pos (24) /*!< PWM_T::TRGADCTL: RTRGEN Position */ +#define PWM_TRGADCTL_RTRGEN_Msk (0x3ful << PWM_TRGADCTL_RTRGEN_Pos) /*!< PWM_T::TRGADCTL: RTRGEN Mask */ + +#define PWM_TRGADCSTS_PTRGF_Pos (0) /*!< PWM_T::TRGADCSTS: PTRGF Position */ +#define PWM_TRGADCSTS_PTRGF_Msk (0x3ful << PWM_TRGADCSTS_PTRGF_Pos) /*!< PWM_T::TRGADCSTS: PTRGF Mask */ + +#define PWM_TRGADCSTS_CTRGF_Pos (8) /*!< PWM_T::TRGADCSTS: CTRGF Position */ +#define PWM_TRGADCSTS_CTRGF_Msk (0x3ful << PWM_TRGADCSTS_CTRGF_Pos) /*!< PWM_T::TRGADCSTS: CTRGF Mask */ + +#define PWM_TRGADCSTS_FTRGF_Pos (16) /*!< PWM_T::TRGADCSTS: FTRGF Position */ +#define PWM_TRGADCSTS_FTRGF_Msk (0x3ful << PWM_TRGADCSTS_FTRGF_Pos) /*!< PWM_T::TRGADCSTS: FTRGF Mask */ + +#define PWM_TRGADCSTS_RTRGF_Pos (24) /*!< PWM_T::TRGADCSTS: RTRGF Position */ +#define PWM_TRGADCSTS_RTRGF_Msk (0x3ful << PWM_TRGADCSTS_RTRGF_Pos) /*!< PWM_T::TRGADCSTS: RTRGF Mask */ + +#define PWM_BRKCTL_BRK0EN_Pos (0) /*!< PWM_T::BRKCTL: BRK0EN Position */ +#define PWM_BRKCTL_BRK0EN_Msk (0x1ul << PWM_BRKCTL_BRK0EN_Pos) /*!< PWM_T::BRKCTL: BRK0EN Mask */ + +#define PWM_BRKCTL_BRK0NFDIS_Pos (1) /*!< PWM_T::BRKCTL: BRK0NFDIS Position */ +#define PWM_BRKCTL_BRK0NFDIS_Msk (0x1ul << PWM_BRKCTL_BRK0NFDIS_Pos) /*!< PWM_T::BRKCTL: BRK0NFDIS Mask */ + +#define PWM_BRKCTL_BRK0INV_Pos (2) /*!< PWM_T::BRKCTL: BRK0INV Position */ +#define PWM_BRKCTL_BRK0INV_Msk (0x1ul << PWM_BRKCTL_BRK0INV_Pos) /*!< PWM_T::BRKCTL: BRK0INV Mask */ + +#define PWM_BRKCTL_BRK0NFSEL_Pos (6) /*!< PWM_T::BRKCTL: BRK0NFSEL Position */ +#define PWM_BRKCTL_BRK0NFSEL_Msk (0x3ul << PWM_BRKCTL_BRK0NFSEL_Pos) /*!< PWM_T::BRKCTL: BRK0NFSEL Mask */ + +#define PWM_BRKCTL_BRK1EN_Pos (8) /*!< PWM_T::BRKCTL: BRK1EN Position */ +#define PWM_BRKCTL_BRK1EN_Msk (0x1ul << PWM_BRKCTL_BRK1EN_Pos) /*!< PWM_T::BRKCTL: BRK1EN Mask */ + +#define PWM_BRKCTL_BRK1NFDIS_Pos (9) /*!< PWM_T::BRKCTL: BRK1NFDIS Position */ +#define PWM_BRKCTL_BRK1NFDIS_Msk (0x1ul << PWM_BRKCTL_BRK1NFDIS_Pos) /*!< PWM_T::BRKCTL: BRK1NFDIS Mask */ + +#define PWM_BRKCTL_BRK1INV_Pos (10) /*!< PWM_T::BRKCTL: BRK1INV Position */ +#define PWM_BRKCTL_BRK1INV_Msk (0x1ul << PWM_BRKCTL_BRK1INV_Pos) /*!< PWM_T::BRKCTL: BRK1INV Mask */ + +#define PWM_BRKCTL_BK1SEL_Pos (12) /*!< PWM_T::BRKCTL: BK1SEL Position */ +#define PWM_BRKCTL_BK1SEL_Msk (0x3ul << PWM_BRKCTL_BK1SEL_Pos) /*!< PWM_T::BRKCTL: BK1SEL Mask */ + +#define PWM_BRKCTL_BRK1NFSEL_Pos (14) /*!< PWM_T::BRKCTL: BRK1NFSEL Position */ +#define PWM_BRKCTL_BRK1NFSEL_Msk (0x3ul << PWM_BRKCTL_BRK1NFSEL_Pos) /*!< PWM_T::BRKCTL: BRK1NFSEL Mask */ + +#define PWM_BRKCTL_CPO0BKEN_Pos (16) /*!< PWM_T::BRKCTL: CPO0BKEN Position */ +#define PWM_BRKCTL_CPO0BKEN_Msk (0x1ul << PWM_BRKCTL_CPO0BKEN_Pos) /*!< PWM_T::BRKCTL: CPO0BKEN Mask */ + +#define PWM_BRKCTL_CPO1BKEN_Pos (17) /*!< PWM_T::BRKCTL: CPO1BKEN Position */ +#define PWM_BRKCTL_CPO1BKEN_Msk (0x1ul << PWM_BRKCTL_CPO1BKEN_Pos) /*!< PWM_T::BRKCTL: CPO1BKEN Mask */ + +#define PWM_BRKCTL_CPO2BKEN_Pos (18) /*!< PWM_T::BRKCTL: CPO2BKEN Position */ +#define PWM_BRKCTL_CPO2BKEN_Msk (0x1ul << PWM_BRKCTL_CPO2BKEN_Pos) /*!< PWM_T::BRKCTL: CPO2BKEN Mask */ + +#define PWM_BRKCTL_LVDBKEN_Pos (19) /*!< PWM_T::BRKCTL: LVDBKEN Position */ +#define PWM_BRKCTL_LVDBKEN_Msk (0x1ul << PWM_BRKCTL_LVDBKEN_Pos) /*!< PWM_T::BRKCTL: LVDBKEN Mask */ + +#define PWM_BRKCTL_BKOD_Pos (24) /*!< PWM_T::BRKCTL: BKOD Position */ +#define PWM_BRKCTL_BKOD_Msk (0x3ful << PWM_BRKCTL_BKOD_Pos) /*!< PWM_T::BRKCTL: BKOD Mask */ + +#define PWM_INTCTL_PINTTYPE_Pos (0) /*!< PWM_T::INTCTL: PINTTYPE Position */ +#define PWM_INTCTL_PINTTYPE_Msk (0x3ful << PWM_INTCTL_PINTTYPE_Pos) /*!< PWM_T::INTCTL: PINTTYPE Mask */ + +#define PWM_INTCTL_DINTTYPE_Pos (8) /*!< PWM_T::INTCTL: DINTTYPE Position */ +#define PWM_INTCTL_DINTTYPE_Msk (0x3ful << PWM_INTCTL_DINTTYPE_Pos) /*!< PWM_T::INTCTL: DINTTYPE Mask */ + +#define PWM_INTEN_PIEN_Pos (0) /*!< PWM_T::INTEN: PIEN Position */ +#define PWM_INTEN_PIEN_Msk (0x3ful << PWM_INTEN_PIEN_Pos) /*!< PWM_T::INTEN: PIEN Mask */ + +#define PWM_INTEN_BRKIEN_Pos (6) /*!< PWM_T::INTEN: BRKIEN Position */ +#define PWM_INTEN_BRKIEN_Msk (0x1ul << PWM_INTEN_BRKIEN_Pos) /*!< PWM_T::INTEN: BRKIEN Mask */ + +#define PWM_INTEN_DIEN_Pos (8) /*!< PWM_T::INTEN: DIEN Position */ +#define PWM_INTEN_DIEN_Msk (0x3ful << PWM_INTEN_DIEN_Pos) /*!< PWM_T::INTEN: DIEN Mask */ + +#define PWM_INTEN_RLIEN_Pos (16) /*!< PWM_T::INTEN: RLIEN Position */ +#define PWM_INTEN_RLIEN_Msk (0x3ful << PWM_INTEN_RLIEN_Pos) /*!< PWM_T::INTEN: RLIEN Mask */ + +#define PWM_INTEN_FLIEN_Pos (24) /*!< PWM_T::INTEN: FLIEN Position */ +#define PWM_INTEN_FLIEN_Msk (0x3ful << PWM_INTEN_FLIEN_Pos) /*!< PWM_T::INTEN: FLIEN Mask */ + +#define PWM_INTSTS_PIF_Pos (0) /*!< PWM_T::INTSTS: PIF Position */ +#define PWM_INTSTS_PIF_Msk (0x3ful << PWM_INTSTS_PIF_Pos) /*!< PWM_T::INTSTS: PIF Mask */ + +#define PWM_INTSTS_BRKIF0_Pos (6) /*!< PWM_T::INTSTS: BRKIF0 Position */ +#define PWM_INTSTS_BRKIF0_Msk (0x1ul << PWM_INTSTS_BRKIF0_Pos) /*!< PWM_T::INTSTS: BRKIF0 Mask */ + +#define PWM_INTSTS_BRKIF1_Pos (7) /*!< PWM_T::INTSTS: BRKIF1 Position */ +#define PWM_INTSTS_BRKIF1_Msk (0x1ul << PWM_INTSTS_BRKIF1_Pos) /*!< PWM_T::INTSTS: BRKIF1 Mask */ + +#define PWM_INTSTS_DIF_Pos (8) /*!< PWM_T::INTSTS: DIF Position */ +#define PWM_INTSTS_DIF_Msk (0x3ful << PWM_INTSTS_DIF_Pos) /*!< PWM_T::INTSTS: DIF Mask */ + +#define PWM_INTSTS_BRKLK0_Pos (14) /*!< PWM_T::INTSTS: BRKLK0 Position */ +#define PWM_INTSTS_BRKLK0_Msk (0x1ul << PWM_INTSTS_BRKLK0_Pos) /*!< PWM_T::INTSTS: BRKLK0 Mask */ + +#define PWM_INTSTS_CRLIF_Pos (16) /*!< PWM_T::INTSTS: CRLIF Position */ +#define PWM_INTSTS_CRLIF_Msk (0x3ful << PWM_INTSTS_CRLIF_Pos) /*!< PWM_T::INTSTS: CRLIF Mask */ + +#define PWM_INTSTS_BRKSTS0_Pos (22) /*!< PWM_T::INTSTS: BRKSTS0 Position */ +#define PWM_INTSTS_BRKSTS0_Msk (0x1ul << PWM_INTSTS_BRKSTS0_Pos) /*!< PWM_T::INTSTS: BRKSTS0 Mask */ + +#define PWM_INTSTS_BRKSTS1_Pos (23) /*!< PWM_T::INTSTS: BRKSTS1 Position */ +#define PWM_INTSTS_BRKSTS1_Msk (0x1ul << PWM_INTSTS_BRKSTS1_Pos) /*!< PWM_T::INTSTS: BRKSTS1 Mask */ + +#define PWM_INTSTS_CFLIF_Pos (24) /*!< PWM_T::INTSTS: CFLIF Position */ +#define PWM_INTSTS_CFLIF_Msk (0x3ful << PWM_INTSTS_CFLIF_Pos) /*!< PWM_T::INTSTS: CFLIF Mask */ + +#define PWM_POEN_POEN_Pos (0) /*!< PWM_T::POEN: POEN Position */ +#define PWM_POEN_POEN_Msk (0x3ful << PWM_POEN_POEN_Pos) /*!< PWM_T::POEN: POEN Mask */ + +#define PWM_CAPCTL_CAPEN_Pos (0) /*!< PWM_T::CAPCTL: CAPEN Position */ +#define PWM_CAPCTL_CAPEN_Msk (0x3ful << PWM_CAPCTL_CAPEN_Pos) /*!< PWM_T::CAPCTL: CAPEN Mask */ + +#define PWM_CAPCTL_CAPINV_Pos (8) /*!< PWM_T::CAPCTL: CAPINV Position */ +#define PWM_CAPCTL_CAPINV_Msk (0x3ful << PWM_CAPCTL_CAPINV_Pos) /*!< PWM_T::CAPCTL: CAPINV Mask */ + +#define PWM_CAPCTL_RCRLDEN_Pos (16) /*!< PWM_T::CAPCTL: RCRLDEN Position */ +#define PWM_CAPCTL_RCRLDEN_Msk (0x3ful << PWM_CAPCTL_RCRLDEN_Pos) /*!< PWM_T::CAPCTL: RCRLDEN Mask */ + +#define PWM_CAPCTL_FCRLDEN_Pos (24) /*!< PWM_T::CAPCTL: FCRLDEN Position */ +#define PWM_CAPCTL_FCRLDEN_Msk (0x3ful << PWM_CAPCTL_FCRLDEN_Pos) /*!< PWM_T::CAPCTL: FCRLDEN Mask */ + +#define PWM_CAPINEN_CAPINEN_Pos (0) /*!< PWM_T::CAPINEN: CAPINEN Position */ +#define PWM_CAPINEN_CAPINEN_Msk (0x3ful << PWM_CAPINEN_CAPINEN_Pos) /*!< PWM_T::CAPINEN: CAPINEN Mask */ + +#define PWM_CAPSTS_CRIFOV_Pos (0) /*!< PWM_T::CAPSTS: CRIFOV Position */ +#define PWM_CAPSTS_CRIFOV_Msk (0x3ful << PWM_CAPSTS_CRIFOV_Pos) /*!< PWM_T::CAPSTS: CRIFOV Mask */ + +#define PWM_CAPSTS_FLIFOV_Pos (8) /*!< PWM_T::CAPSTS: FLIFOV Position */ +#define PWM_CAPSTS_FLIFOV_Msk (0x3ful << PWM_CAPSTS_FLIFOV_Pos) /*!< PWM_T::CAPSTS: FLIFOV Mask */ + +#define PWM_RCAPDAT0_RCAPDAT_Pos (0) /*!< PWM_T::RCAPDAT0: RCAPDAT Position */ +#define PWM_RCAPDAT0_RCAPDAT_Msk (0xfffful << PWM_RCAPDAT0_RCAPDAT_Pos) /*!< PWM_T::RCAPDAT0: RCAPDAT Mask */ + +#define PWM_FCAPDAT0_FCAPDAT_Pos (0) /*!< PWM_T::FCAPDAT0: FCAPDAT Position */ +#define PWM_FCAPDAT0_FCAPDAT_Msk (0xfffful << PWM_FCAPDAT0_FCAPDAT_Pos) /*!< PWM_T::FCAPDAT0: FCAPDAT Mask */ + +#define PWM_RCAPDAT1_RCAPDAT_Pos (0) /*!< PWM_T::RCAPDAT1: RCAPDAT Position */ +#define PWM_RCAPDAT1_RCAPDAT_Msk (0xfffful << PWM_RCAPDAT1_RCAPDAT_Pos) /*!< PWM_T::RCAPDAT1: RCAPDAT Mask */ + +#define PWM_FCAPDAT1_FCAPDAT_Pos (0) /*!< PWM_T::FCAPDAT1: FCAPDAT Position */ +#define PWM_FCAPDAT1_FCAPDAT_Msk (0xfffful << PWM_FCAPDAT1_FCAPDAT_Pos) /*!< PWM_T::FCAPDAT1: FCAPDAT Mask */ + +#define PWM_RCAPDAT2_RCAPDAT_Pos (0) /*!< PWM_T::RCAPDAT2: RCAPDAT Position */ +#define PWM_RCAPDAT2_RCAPDAT_Msk (0xfffful << PWM_RCAPDAT2_RCAPDAT_Pos) /*!< PWM_T::RCAPDAT2: RCAPDAT Mask */ + +#define PWM_FCAPDAT2_FCAPDAT_Pos (0) /*!< PWM_T::FCAPDAT2: FCAPDAT Position */ +#define PWM_FCAPDAT2_FCAPDAT_Msk (0xfffful << PWM_FCAPDAT2_FCAPDAT_Pos) /*!< PWM_T::FCAPDAT2: FCAPDAT Mask */ + +#define PWM_RCAPDAT3_RCAPDAT_Pos (0) /*!< PWM_T::RCAPDAT3: RCAPDAT Position */ +#define PWM_RCAPDAT3_RCAPDAT_Msk (0xfffful << PWM_RCAPDAT3_RCAPDAT_Pos) /*!< PWM_T::RCAPDAT3: RCAPDAT Mask */ + +#define PWM_FCAPDAT3_FCAPDAT_Pos (0) /*!< PWM_T::FCAPDAT3: FCAPDAT Position */ +#define PWM_FCAPDAT3_FCAPDAT_Msk (0xfffful << PWM_FCAPDAT3_FCAPDAT_Pos) /*!< PWM_T::FCAPDAT3: FCAPDAT Mask */ + +#define PWM_RCAPDAT4_RCAPDAT_Pos (0) /*!< PWM_T::RCAPDAT4: RCAPDAT Position */ +#define PWM_RCAPDAT4_RCAPDAT_Msk (0xfffful << PWM_RCAPDAT4_RCAPDAT_Pos) /*!< PWM_T::RCAPDAT4: RCAPDAT Mask */ + +#define PWM_FCAPDAT4_FCAPDAT_Pos (0) /*!< PWM_T::FCAPDAT4: FCAPDAT Position */ +#define PWM_FCAPDAT4_FCAPDAT_Msk (0xfffful << PWM_FCAPDAT4_FCAPDAT_Pos) /*!< PWM_T::FCAPDAT4: FCAPDAT Mask */ + +#define PWM_RCAPDAT5_RCAPDAT_Pos (0) /*!< PWM_T::RCAPDAT5: RCAPDAT Position */ +#define PWM_RCAPDAT5_RCAPDAT_Msk (0xfffful << PWM_RCAPDAT5_RCAPDAT_Pos) /*!< PWM_T::RCAPDAT5: RCAPDAT Mask */ + +#define PWM_FCAPDAT5_FCAPDAT_Pos (0) /*!< PWM_T::FCAPDAT5: FCAPDAT Position */ +#define PWM_FCAPDAT5_FCAPDAT_Msk (0xfffful << PWM_FCAPDAT5_FCAPDAT_Pos) /*!< PWM_T::FCAPDAT5: FCAPDAT Mask */ + +#define PWM_SBS0_SYNCBUSY_Pos (0) /*!< PWM_T::SBS: SYNCBUSY Position */ +#define PWM_SBS0_SYNCBUSY_Msk (0x1ul << PWM_SBS0_SYNCBUSY_Pos) /*!< PWM_T::SBS: SYNCBUSY Mask */ + +#define PWM_SBS1_SYNCBUSY_Pos (0) /*!< PWM_T::SBS: SYNCBUSY Position */ +#define PWM_SBS1_SYNCBUSY_Msk (0x1ul << PWM_SBS1_SYNCBUSY_Pos) /*!< PWM_T::SBS: SYNCBUSY Mask */ + +#define PWM_SBS2_SYNCBUSY_Pos (0) /*!< PWM_T::SBS: SYNCBUSY Position */ +#define PWM_SBS2_SYNCBUSY_Msk (0x1ul << PWM_SBS2_SYNCBUSY_Pos) /*!< PWM_T::SBS: SYNCBUSY Mask */ + +#define PWM_SBS3_SYNCBUSY_Pos (0) /*!< PWM_T::SBS: SYNCBUSY Position */ +#define PWM_SBS3_SYNCBUSY_Msk (0x1ul << PWM_SBS3_SYNCBUSY_Pos) /*!< PWM_T::SBS: SYNCBUSY Mask */ + +#define PWM_SBS4_SYNCBUSY_Pos (0) /*!< PWM_T::SBS: SYNCBUSY Position */ +#define PWM_SBS4_SYNCBUSY_Msk (0x1ul << PWM_SBS4_SYNCBUSY_Pos) /*!< PWM_T::SBS: SYNCBUSY Mask */ + +#define PWM_SBS5_SYNCBUSY_Pos (0) /*!< PWM_T::SBS: SYNCBUSY Position */ +#define PWM_SBS5_SYNCBUSY_Msk (0x1ul << PWM_SBS5_SYNCBUSY_Pos) /*!< PWM_T::SBS: SYNCBUSY Mask */ + +/**@}*/ /* PWM_CONST */ +/**@}*/ /* end of PWM register group */ + + +/*---------------------- Quadrature Encoder Interface -------------------------*/ +/** + @addtogroup QEI Quadrature Encoder Interface(QEI) + Memory Mapped Structure for QEI Controller +@{ */ + +typedef struct { + + + /** + * CNT + * =================================================================================================== + * Offset: 0x00 QEI Pulse Counter + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |VAL |Quadrature Encoder Pulse Counter + * | | |A 32-bit up/down counter. + * | | |When an effective phase pulse is detected, this counter is increased by one if the bit DIRF (QEI_STATUS[27]) is one or decreased by one if the bit DIRF is zero. + * | | |This register performs an integrator which count value is proportional to the encoder position. + * | | |The pulse counter may be initialized to a predetermined value by one of three events occurs:. + * | | |1. Software written if QEIEN (QEI_CTR[29]) = 0. + * | | |2. Compare-match event if QEIEN=1 and QEI is in compare-counting mode. + * | | |3. Index signal change if QEIEN=1 and IDXRLDEN (QEI_CTR[27])=1. + */ + __IO uint32_t CNT; + + /** + * CNTHOLD + * =================================================================================================== + * Offset: 0x04 QEI Pulse Counter Hold Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |VAL |Quadrature Encoder Pulse Counter Hold Register + * | | |When bit HOLDCNT (QEIx_CTR[24]) goes from low to high, the QEI_CNT value is copied into QEI_CNTHOLD register. + */ + __IO uint32_t CNTHOLD; + + /** + * CNTLATCH + * =================================================================================================== + * Offset: 0x08 QEI Pulse Counter Index Latch Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |VAL |Quadrature Encoder Pulse Counter Index Latch + * | | |When the IDXF (QEI_STATUS[18]) bit is set, the QEI_CNT value is copied into QEI_CNTLATCH register. + */ + __IO uint32_t CNTLATCH; + + /** + * CNTCMP + * =================================================================================================== + * Offset: 0x0C QEI Pulse Counter Compare Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |VAL |Quadrature Encoder Pulse Counter Compare + * | | |if the QEI controller is in the compare-counting mode CMPENN (QEI_CTR[28]) =1, when the value of QEI_CNT matches the value of VAL the bit CMPF will be set. + * | | |This register is software writeable. + */ + __IO uint32_t CNTCMP; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * MAXCNT + * =================================================================================================== + * Offset: 0x14 QEI Pre-set Maximum Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |VAL |Quadrature Encoder Preset Maximum Count + * | | |This register value determined by user stores the maximum value which may be the number of the quadrature encoder pulses in a revolution for the QEI controller compare-counting mode + */ + __IO uint32_t CNTMAX; + + /** + * CTR + * =================================================================================================== + * Offset: 0x18 QEI Controller Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |NFCLKSEL |Noise Filter Clock Pre-Divide Selection + * | | |To determine the sampling frequency of the Noise Filter clock . + * | | |00 = QEI_CLK. + * | | |01 = QEI_CLK/2. + * | | |10 = QEI_CLK/4. + * | | |11 = QEI_CLK/16. + * |[3] |NFDIS |QEI Controller Input Noise Filter Disable Control + * | | |0 = The noise filter of QEI controller Enabled. + * | | |1 = The noise filter of QEI controller Disabled. + * |[4] |CHAEN |QEA Input To QEI Controller Enable Control + * | | |0 = QEA input to QEI Controller Disabled. + * | | |1 = QEA input to QEI Controller Enabled. + * |[5] |CHBEN |QEB Input To QEI Controller Enable Control + * | | |0 = QEB input to QEI Controller Disabled. + * | | |1 = QEB input to QEI Controller Enabled. + * |[6] |IDXEN |IDX Input To QEI Controller Enable Control + * | | |0 = IDX input to QEI Controller Disabled. + * | | |1 = IDX input to QEI Controller Enabled. + * |[8:9] |MODE |QEI Counting Mode Selection + * | | |There are four quadrature encoder pulse counter operation modes. + * | | |00 = X4 Free-counting Mode. + * | | |01 = X2 Free-counting Mode. + * | | |10 = X4 Compare-counting Mode. + * | | |11 = X2 Compare-counting Mode. + * |[12] |CHAINV |Inverse QEA Input Polarity + * | | |0 = Not inverse QEA input polarity. + * | | |1 = QEA input polarity is inversed to QEI controller. + * |[13] |CHBINV |Inverse QEB Input Polarity + * | | |0 = Not inverse QEB input polarity. + * | | |1 = QEB input polarity is inversed to QEI controller. + * |[14] |IDXINV |Inverse IDX Input Polarity + * | | |0 = Not inverse IDX input polarity. + * | | |1 = IDX input polarity is inversed to QEI controller. + * |[16] |OVUNIEN |OVUNF Trigger QEI Interrupt Enable Control + * | | |0 = OVUNF can trigger QEI controller interrupt Disabled. + * | | |1 = OVUNF can trigger QEI controller interrupt Enabled. + * |[17] |DIRIEN |DIRCHGF Trigger QEI Interrupt Enable Control + * | | |0 = DIRCHGF can trigger QEI controller interrupt Disabled. + * | | |1 = DIRCHGF can trigger QEI controller interrupt Enabled. + * |[18] |CMPIEN |CMPF Trigger QEI Interrupt Enable Control + * | | |0 = CMPF can trigger QEI controller interrupt Disabled. + * | | |1 = CMPF can trigger QEI controller interrupt Enabled. + * |[19] |IDXIEN |IDXF Trigger QEI Interrupt Enable Control + * | | |0 = The IDXF can trigger QEI interrupt Disabled. + * | | |1 = The IDXF can trigger QEI interrupt Enabled. + * |[20] |HOLDTMR0 |Hold QEI_CNT By Timer 0 + * | | |0 = TIF (TISR0[0]) has no effect on HOLDCNT. + * | | |1 = A rising edge of bit TIF (TISR0[0]) in timer 0 sets HOLDCNT to 1. + * |[21] |HOLDTMR1 |Hold QEI_CNT By Timer 1 + * | | |0 = TIF (TISR1[0]) has no effect on HOLDCNT. + * | | |1 = A rising edge of bit TIF (TISR1[0]) in timer 1 sets HOLDCNT to 1. + * |[22] |HOLDTMR2 |Hold QEI_CNT By Timer 2 + * | | |0 = TIF (TISR2[0]) has no effect on HOLDCNT. + * | | |1 = A rising edge of bit TIF (TISR2[0]) in timer 2 sets HOLDCNT to 1. + * |[23] |HOLDTMR3 |Hold QEI_CNT By Timer 3 + * | | |0 = TIF (TISR3[0]) has no effect on HOLDCNT. + * | | |1 = A rising edge of bit TIF (TISR3[0]) in timer 3 sets HOLDCNT to 1. + * |[24] |HOLDCNT |Hold QEI_CNT Control + * | | |When this bit is set from low to high, the QEI_CNT value is copied into QEI_CNTHOLD. + * | | |This bit may be set by writing 1 to it or Timer0~Timer3 interrupt flag TIF (TISTRx[0]). + * | | |0 = No operation. + * | | |1 = QEI_CNT content is captured and stored in QEI_CNTHOLD. + * | | |Note: This bit is automatically cleared after QEI_CNTHOLD holds QEI_CNT value. + * |[25] |IDXLATEN |Index Latch QEI_CNT Enable Control + * | | |If this bit is set to high, the QEI_CNT content will be latched into QEI_CNTLATCH at every rising on signal CHX. + * | | |0 = The index signal latch QEI counter function Disabled. + * | | |1 = The index signal latch QEI counter function Enabled. + * |[27] |IDXRLDEN |Index Trigger QEI_CNT Reload Enable Control + * | | |When this bit is high and a rising edge comes on signal CHX, the QEI_CNT will be reset to zero if the counter is in up-counting type (DIRF = 1); while the QEI_CNT will be reloaded with QEI_MAXCNT content if the counter is in down-counting type (DIRF = 0). + * | | |0 = Reload function Disabled. + * | | |1 = QEI_CNT re-initialized by Index signal Enabled. + * |[28] |CMPENN |The Compare Function Enable Control + * | | |The compare function in QEI controller is to compare the dynamic counting QEI_CNT with the compare register QEI_CNTCMP, if QEI_CNT value reaches QEI_CNTCMP, the flag CMPF will be set. + * | | |0 = Compare function Disabled. + * | | |1 = Compare function Enabled. + * |[29] |QEIEN |Quadrature Encoder Interface Controller Enable Control + * | | |0 = QEI controller function Disabled. + * | | |1 = QEI controller function Enabled. + */ + __IO uint32_t CTR; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[4]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * STATUS + * =================================================================================================== + * Offset: 0x2C QEI Controller Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |IDXF |IDX Detected Flag + * | | |When the QEI controller detects a rising edge on signal CHX it will set flag IDXF to high. + * | | |0 = No rising edge detected on signal CHX. + * | | |1 = A rising edge occurs on signal CHX. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[1] |CMPF |Compare-Match Flag + * | | |If the QEI compare function is enabled, the flag is set by hardware while QEI counter up or down counts and reach to the QEI_CNTCMP value. + * | | |0 = QEI counter does not match with QEI_CNTCMP value. + * | | |1 = QEI counter counts to the same as QEI_CNTCMP value. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[2] |OVUNF |QEI Counter Overflow Or Underflow Flag + * | | |Flag is set by hardware while QEI_CNT overflows from 0xFFFF_FFFF to zero in free-counting mode or from the QEI_MAXCNT value to zero in compare-counting mode. + * | | |Similarly, the flag is set wile QEI counter underflows from zero to 0xFFFF_FFFF or QEI_MAXCNT. + * | | |0 = No overflow or underflow occurs in QEI counter. + * | | |1 = QEI counter occurs counting overflow or underflow. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[3] |DIRCHGF |Direction Change Flag + * | | |Flag is set by hardware while QEI counter counting direction is changed. + * | | |Software can clear this bit by writing 1 to it. + * | | |0 = No change in QEI counter counting direction. + * | | |1 = QEI counter counting direction is changed. + * | | |Note: This bit is only cleared by writing 1 to it. + * |[8] |DIRF |QEI Counter Counting Direction Indication + * | | |0 = QEI Counter is in down-counting. + * | | |1 = QEI Counter is in up-counting. + * | | |Note: This bit is set/reset by hardware according to the phase detection between CHA and CHB. + */ + __IO uint32_t STATUS; + +} QEI_T; + +/** + @addtogroup QEI_CONST QEI Bit Field Definition + Constant Definitions for QEI Controller +@{ */ + +#define QEI_CNT_VAL_Pos (0) /*!< QEI_T::CNT: VAL Position */ +#define QEI_CNT_VAL_Msk (0xfffffffful << QEI_CNT_VAL_Pos) /*!< QEI_T::CNT: VAL Mask */ + +#define QEI_CNTHOLD_VAL_Pos (0) /*!< QEI_T::CNTHOLD: VAL Position */ +#define QEI_CNTHOLD_VAL_Msk (0xfffffffful << QEI_CNTHOLD_VAL_Pos) /*!< QEI_T::CNTHOLD: VAL Mask */ + +#define QEI_CNTLATCH_VAL_Pos (0) /*!< QEI_T::CNTLATCH: VAL Position */ +#define QEI_CNTLATCH_VAL_Msk (0xfffffffful << QEI_CNTLATCH_VAL_Pos) /*!< QEI_T::CNTLATCH: VAL Mask */ + +#define QEI_CNTCMP_VAL_Pos (0) /*!< QEI_T::CNTCMP: VAL Position */ +#define QEI_CNTCMP_VAL_Msk (0xfffffffful << QEI_CNTCMP_VAL_Pos) /*!< QEI_T::CNTCMP: VAL Mask */ + +#define QEI_CNTMAX_VAL_Pos (0) /*!< QEI_T::CNTMAX: VAL Position */ +#define QEI_CNTMAX_VAL_Msk (0xfffffffful << QEI_CNTMAX_VAL_Pos) /*!< QEI_T::CNTMAX: VAL Mask */ + +#define QEI_CTR_NFCLKSEL_Pos (0) /*!< QEI_T::CTR: NFCLKSEL Position */ +#define QEI_CTR_NFCLKSEL_Msk (0x3ul << QEI_CTR_NFCLKSEL_Pos) /*!< QEI_T::CTR: NFCLKSEL Mask */ + +#define QEI_CTR_NFDIS_Pos (3) /*!< QEI_T::CTR: NFDIS Position */ +#define QEI_CTR_NFDIS_Msk (0x1ul << QEI_CTR_NFDIS_Pos) /*!< QEI_T::CTR: NFDIS Mask */ + +#define QEI_CTR_CHAEN_Pos (4) /*!< QEI_T::CTR: CHAEN Position */ +#define QEI_CTR_CHAEN_Msk (0x1ul << QEI_CTR_CHAEN_Pos) /*!< QEI_T::CTR: CHAEN Mask */ + +#define QEI_CTR_CHBEN_Pos (5) /*!< QEI_T::CTR: CHBEN Position */ +#define QEI_CTR_CHBEN_Msk (0x1ul << QEI_CTR_CHBEN_Pos) /*!< QEI_T::CTR: CHBEN Mask */ + +#define QEI_CTR_IDXEN_Pos (6) /*!< QEI_T::CTR: IDXEN Position */ +#define QEI_CTR_IDXEN_Msk (0x1ul << QEI_CTR_IDXEN_Pos) /*!< QEI_T::CTR: IDXEN Mask */ + +#define QEI_CTR_MODE_Pos (8) /*!< QEI_T::CTR: MODE Position */ +#define QEI_CTR_MODE_Msk (0x3ul << QEI_CTR_MODE_Pos) /*!< QEI_T::CTR: MODE Mask */ + +#define QEI_CTR_CHAINV_Pos (12) /*!< QEI_T::CTR: CHAINV Position */ +#define QEI_CTR_CHAINV_Msk (0x1ul << QEI_CTR_CHAINV_Pos) /*!< QEI_T::CTR: CHAINV Mask */ + +#define QEI_CTR_CHBINV_Pos (13) /*!< QEI_T::CTR: CHBINV Position */ +#define QEI_CTR_CHBINV_Msk (0x1ul << QEI_CTR_CHBINV_Pos) /*!< QEI_T::CTR: CHBINV Mask */ + +#define QEI_CTR_IDXINV_Pos (14) /*!< QEI_T::CTR: IDXINV Position */ +#define QEI_CTR_IDXINV_Msk (0x1ul << QEI_CTR_IDXINV_Pos) /*!< QEI_T::CTR: IDXINV Mask */ + +#define QEI_CTR_OVUNIEN_Pos (16) /*!< QEI_T::CTR: OVUNIEN Position */ +#define QEI_CTR_OVUNIEN_Msk (0x1ul << QEI_CTR_OVUNIEN_Pos) /*!< QEI_T::CTR: OVUNIEN Mask */ + +#define QEI_CTR_DIRIEN_Pos (17) /*!< QEI_T::CTR: DIRIEN Position */ +#define QEI_CTR_DIRIEN_Msk (0x1ul << QEI_CTR_DIRIEN_Pos) /*!< QEI_T::CTR: DIRIEN Mask */ + +#define QEI_CTR_CMPIEN_Pos (18) /*!< QEI_T::CTR: CMPIEN Position */ +#define QEI_CTR_CMPIEN_Msk (0x1ul << QEI_CTR_CMPIEN_Pos) /*!< QEI_T::CTR: CMPIEN Mask */ + +#define QEI_CTR_IDXIEN_Pos (19) /*!< QEI_T::CTR: IDXIEN Position */ +#define QEI_CTR_IDXIEN_Msk (0x1ul << QEI_CTR_IDXIEN_Pos) /*!< QEI_T::CTR: IDXIEN Mask */ + +#define QEI_CTR_HOLDTMR0_Pos (20) /*!< QEI_T::CTR: HOLDTMR0 Position */ +#define QEI_CTR_HOLDTMR0_Msk (0x1ul << QEI_CTR_HOLDTMR0_Pos) /*!< QEI_T::CTR: HOLDTMR0 Mask */ + +#define QEI_CTR_HOLDTMR1_Pos (21) /*!< QEI_T::CTR: HOLDTMR1 Position */ +#define QEI_CTR_HOLDTMR1_Msk (0x1ul << QEI_CTR_HOLDTMR1_Pos) /*!< QEI_T::CTR: HOLDTMR1 Mask */ + +#define QEI_CTR_HOLDTMR2_Pos (22) /*!< QEI_T::CTR: HOLDTMR2 Position */ +#define QEI_CTR_HOLDTMR2_Msk (0x1ul << QEI_CTR_HOLDTMR2_Pos) /*!< QEI_T::CTR: HOLDTMR2 Mask */ + +#define QEI_CTR_HOLDTMR3_Pos (23) /*!< QEI_T::CTR: HOLDTMR3 Position */ +#define QEI_CTR_HOLDTMR3_Msk (0x1ul << QEI_CTR_HOLDTMR3_Pos) /*!< QEI_T::CTR: HOLDTMR3 Mask */ + +#define QEI_CTR_HOLDCNT_Pos (24) /*!< QEI_T::CTR: HOLDCNT Position */ +#define QEI_CTR_HOLDCNT_Msk (0x1ul << QEI_CTR_HOLDCNT_Pos) /*!< QEI_T::CTR: HOLDCNT Mask */ + +#define QEI_CTR_IDXLATEN_Pos (25) /*!< QEI_T::CTR: IDXLATEN Position */ +#define QEI_CTR_IDXLATEN_Msk (0x1ul << QEI_CTR_IDXLATEN_Pos) /*!< QEI_T::CTR: IDXLATEN Mask */ + +#define QEI_CTR_IDXRLDEN_Pos (27) /*!< QEI_T::CTR: IDXRLDEN Position */ +#define QEI_CTR_IDXRLDEN_Msk (0x1ul << QEI_CTR_IDXRLDEN_Pos) /*!< QEI_T::CTR: IDXRLDEN Mask */ + +#define QEI_CTR_CMPENN_Pos (28) /*!< QEI_T::CTR: CMPENN Position */ +#define QEI_CTR_CMPENN_Msk (0x1ul << QEI_CTR_CMPENN_Pos) /*!< QEI_T::CTR: CMPENN Mask */ + +#define QEI_CTR_QEIEN_Pos (29) /*!< QEI_T::CTR: QEIEN Position */ +#define QEI_CTR_QEIEN_Msk (0x1ul << QEI_CTR_QEIEN_Pos) /*!< QEI_T::CTR: QEIEN Mask */ + +#define QEI_STATUS_IDXF_Pos (0) /*!< QEI_T::STATUS: IDXF Position */ +#define QEI_STATUS_IDXF_Msk (0x1ul << QEI_STATUS_IDXF_Pos) /*!< QEI_T::STATUS: IDXF Mask */ + +#define QEI_STATUS_CMPF_Pos (1) /*!< QEI_T::STATUS: CMPF Position */ +#define QEI_STATUS_CMPF_Msk (0x1ul << QEI_STATUS_CMPF_Pos) /*!< QEI_T::STATUS: CMPF Mask */ + +#define QEI_STATUS_OVUNF_Pos (2) /*!< QEI_T::STATUS: OVUNF Position */ +#define QEI_STATUS_OVUNF_Msk (0x1ul << QEI_STATUS_OVUNF_Pos) /*!< QEI_T::STATUS: OVUNF Mask */ + +#define QEI_STATUS_DIRCHGF_Pos (3) /*!< QEI_T::STATUS: DIRCHGF Position */ +#define QEI_STATUS_DIRCHGF_Msk (0x1ul << QEI_STATUS_DIRCHGF_Pos) /*!< QEI_T::STATUS: DIRCHGF Mask */ + +#define QEI_STATUS_DIRF_Pos (8) /*!< QEI_T::STATUS: DIRF Position */ +#define QEI_STATUS_DIRF_Msk (0x1ul << QEI_STATUS_DIRF_Pos) /*!< QEI_T::STATUS: DIRF Mask */ + +/**@}*/ /* QEI_CONST */ +/**@}*/ /* end of QEI register group */ + + +/*---------------------- Real Time Clock Controller -------------------------*/ +/** + @addtogroup RTC Real Time Clock Controller(RTC) + Memory Mapped Structure for RTC Controller +@{ */ + +typedef struct { + + /** + * INIT + * =================================================================================================== + * Offset: 0x00 RTC Initiation Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |INIT_Active|RTC Active Status (Read Only) + * | | |0 = RTC is at reset state. + * | | |1 = RTC is at normal active state. + * |[1:31] |INIT |RTC Initiation + * | | |When RTC block is powered on, RTC is at reset state. + * | | |User has to write a number (0x a5eb1357) to INIT to make RTC leaving reset state. + * | | |Once the INIT is written as 0xa5eb1357, the RTC will be in un-reset state permanently. + * | | |The INIT is a write-only field and read value will be always "0". + */ + __IO uint32_t INIT; + + /** + * RWEN + * =================================================================================================== + * Offset: 0x04 RTC Access Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |RWEN |RTC Register Access Enable Password (Write Only) + * | | |Writing 0xA965 to this register will enable RTC access and keep 1024 RTC clock. + * |[16] |RWENF |RTC Register Access Enable Flag (Read Only) + * | | |0 = RTC register read/write Disabled. + * | | |1 = RTC register read/write Enabled. + * | | |This bit will be set after RTC_RWEN[15:0] register is load a 0xA965, and be cleared automatically after 1024 RTC clock. + */ + __O uint32_t RWEN; + + /** + * FREQADJ + * =================================================================================================== + * Offset: 0x08 RTC Frequency Compensation Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |FRACTION |Fraction Part + * | | |Formula = (fraction part of detected value) x 60. + * | | |Note: Digit in RTC_FREQADJ must be expressed as hexadecimal number. + * |[8:11] |INTEGER |Integer Part + */ + __IO uint32_t FREQADJ; + + /** + * TIME + * =================================================================================================== + * Offset: 0x0C Time Loading Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |SEC |1-Sec Time Digit (0~9) + * |[4:6] |TENSEC |10-Sec Time Digit (0~5) + * |[8:11] |MIN |1-Min Time Digit (0~9) + * |[12:14] |TENMIN |10-Min Time Digit (0~5) + * |[16:19] |HR |1-Hour Time Digit (0~9) + * |[20:21] |TENHR |10-Hour Time Digit (0~2) + */ + __IO uint32_t TIME; + + /** + * CAL + * =================================================================================================== + * Offset: 0x10 Calendar Loading Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |DAY |1-Day Calendar Digit (0~9) + * |[4:5] |TENDAY |10-Day Calendar Digit (0~3) + * |[8:11] |MON |1-Month Calendar Digit (0~9) + * |[12] |TENMON |10-Month Calendar Digit (0~1) + * |[16:19] |YEAR |1-Year Calendar Digit (0~9) + * |[20:23] |TENYEAR |10-Year Calendar Digit (0~9) + */ + __IO uint32_t CAL; + + /** + * CLKFMT + * =================================================================================================== + * Offset: 0x14 Time Scale Selection Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |24HEN |24-Hour / 12-Hour Time Scale Selection + * | | |Indicates that RTC_TIME and RTC_TALM are in 24-hour time scale or 12-hour time scale + * | | |0 = 12-hour time scale with AM and PM indication selected. + * | | |1 = 24-hour time scale selected. + */ + __IO uint32_t CLKFMT; + + /** + * WEEKDAY + * =================================================================================================== + * Offset: 0x18 Day of the Week Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |WEEKDAY |Day Of The Week Bits + * | | |000 = Sunday. + * | | |001 = Monday. + * | | |010 = Tuesday. + * | | |011 = Wednesday. + * | | |100 = Thursday. + * | | |101 = Friday. + * | | |110 = Saturday. + * | | |111 = Reserved + */ + __IO uint32_t WEEKDAY; + + /** + * TALM + * =================================================================================================== + * Offset: 0x1C Time Alarm Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |SEC |1-Sec Time Digit of Alarm Setting (0~9) + * |[4:6] |TENSEC |10-Sec Time Digit of Alarm Setting (0~5) + * |[8:11] |MIN |1-Min Time Digit of Alarm Setting (0~9) + * |[12:14] |TENMIN |10-Min Time Digit of Alarm Setting (0~5) + * |[16:19] |HR |1-Hour Time Digit of Alarm Setting (0~9) + * |[20:21] |TENHR |10-Hour Time Digit of Alarm Setting (0~2) + */ + __IO uint32_t TALM; + + /** + * CALM + * =================================================================================================== + * Offset: 0x20 Calendar Alarm Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |DAY |1-Day Calendar Digit of Alarm Setting (0~9) + * |[4:5] |TENDAY |10-Day Calendar Digit of Alarm Setting (0~3) + * |[8:11] |MON |1-Month Calendar Digit of Alarm Setting (0~9) + * |[12] |TENMON |10-Month Calendar Digit of Alarm Setting (0~1) + * |[16:19] |YEAR |1-Year Calendar Digit of Alarm Setting (0~9) + * |[20:23] |TENYEAR |10-Year Calendar Digit of Alarm Setting (0~9) + */ + __IO uint32_t CALM; + + /** + * LEAPYEAR + * =================================================================================================== + * Offset: 0x24 Leap Year Indication Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |LEAPYEAR |Leap Year Indicator (Read Only) + * | | |0 = This year is not a leap year. + * | | |1 = This year is leap year. + */ + __I uint32_t LEAPYEAR; + + /** + * INTEN + * =================================================================================================== + * Offset: 0x28 RTC Interrupt Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ALMIEN |Alarm Interrupt Enable Control + * | | |0 = RTC Alarm Interrupt Disabled. + * | | |1 = RTC Alarm Interrupt Enabled. + * |[1] |TICKIEN |Time Tick Interrupt Enable Control + * | | |0 = RTC Time Tick Interrupt Disabled. + * | | |1 = RTC Time Tick Interrupt Enabled. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x2C RTC Interrupt Indicator Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ALMIF |RTC Alarm Interrupt Flag + * | | |When RTC real time counters RTC_TIME and RTC_CAL reach the alarm setting time registers RTC_TALM and RTC_CALM, this bit will be set to 1 and an interrupt will be generated if RTC Alarm Interrupt enabled (ALMIEN (RTC_INTEN(0)) is set to 1. + * | | |Chip will also be waken up if RTC Alarm Interrupt is enabled and this bit is set to 1 when chip is running at Power-down mode. + * | | |Note: This bit can be cleared by writing 1 to it. + * |[1] |TICKIF |RTC Time Tick Interrupt Flag + * | | |When RTC Time Tick happened, this bit will be set to 1 and an interrupt will be generated if RTC Tick Interrupt enabled (TICKIEN (RTC_INTEN[1])) is set to 1. + * | | |Chip will also be waken up if RTC Tick Interrupt is enabled and this bit is set to 1 when chip is running at Power-down mode. + * | | |Note: This bit can be cleared by writing 1 to it. + */ + __IO uint32_t INTSTS; + + /** + * TICK + * =================================================================================================== + * Offset: 0x30 RTC Time Tick Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |TICKSEL |Time Tick Bits + * | | |The RTC time tick period for Periodic Time Tick Interrupt request. + * | | |000 = Time tick is 1 second. + * | | |001 = Time tick is 1/2 second. + * | | |010 = Time tick is 1/4 second. + * | | |011 = Time tick is 1/8 second. + * | | |100 = Time tick is 1/16 second. + * | | |101 = Time tick is 1/32 second. + * | | |110 = Time tick is 1/64 second. + * | | |111 = Time tick is 1/128 second. + * | | |Note: These bits can be read back after the RTC register access enable bit RWENF (RTC_RWEN[16]) is active. + */ + __IO uint32_t TICK; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[2]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SPRCTL + * =================================================================================================== + * Offset: 0x3C RTC Spare Functional Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[2] |SPRRWEN |SPR Register Enable Control + * | | |This bit controls the spare register to be enabled or not. + * | | |0 = Spare register Disabled and RTC_SPR0 ~ RTC_SPR23 cannot be accessed. + * | | |1 = Spare register Enabled and RTC_SPR0 ~ RTC_SPR23 can be accessed. + * |[7] |SPRRWRDY |SPR Register Ready + * | | |This bit indicates if the registers RTC_SPRCTL, RTC_SPR0 ~ RTC_SPR23 are ready to be accessed. + * | | |After CPU writing registers RTC_SPRCTL, RTC_SPR0 ~ RTC_SPR23, polling this bit to check if these registers are updated done is necessary. + * | | |This bit is read only and any write to it won't take any effect. + * | | |0 = RTC_SPRCTL, RTC_SPR0 ~ RTC_SPR23 updating is in progress. + * | | |1 = RTC_SPRCTL, RTC_SPR0 ~ RTC_SPR23 are updated done and ready to be accessed. + */ + __IO uint32_t SPRCTL; + + /** + * SPRx + * =================================================================================================== + * Offset: 0x40 RTC Spare Register 0 ~ 23 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SPARE |SPARE Bits + * | | |This field is used to store back-up information defined by software. + * | | |This field will be cleared by hardware automatically once a snooper pin event is detected. + * | | |Before storing back-up information in to SPARE register, software should write 0xA965 to RTC_RWEN to make sure register read/write enabled. + */ + __IO uint32_t SPR[24]; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[28]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TAMPCTL + * =================================================================================================== + * Offset: 0x110 Tamper Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TIEN |Tamper Interrupt Enable Control + * | | |0 = Tamper interrupt Disabled. + * | | |1 = Tamper interrupt Enabled. + * |[1] |DESTROYEN |Destroy Spare Register Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[2] |TAMPEN0 |Tamper0 Detect Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[3] |TAMPEN1 |Tamper1 Detect Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[4] |TAMPDBEN0 |Tamper0 De-Bounce Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[5] |TAMPDBEN1 |Tamper1 De-Bounce Enable Control + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[6] |TAMPLV0 |Tamper0 Level + * | | |0 = Low. + * | | |1 = High. + * |[7] |TAMPLV1 |Tamper1 Level + * | | |0 = Low. + * | | |1 = High. + */ + __IO uint32_t TAMPCTL; + + /** + * TAMPSTS + * =================================================================================================== + * Offset: 0x114 Tamper Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TAMPSTS0 |Tamper0 Sense Flag + * | | |0 = No invasion. + * | | |1 = Tamper0 detect invasion. + * | | |Note: Write 1 to clear it + * |[1] |TAMPSTS1 |Tamper1 Sense Flag + * | | |0 = No invasion. + * | | |1 = Tamper1 detect invasion. + * | | |Note: Write 1 to clear it + */ + __IO uint32_t TAMPSTS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TAMP0PCTL + * =================================================================================================== + * Offset: 0x124 TAMPER0 Pin I/O Mode Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |OUTLV |Output Level + * | | |0 = Low. + * | | |1 = High. + * |[1] |OUTEN |Output Enable Control + * | | |0 = Output Enabled. + * | | |1 = Output Disabled. + * |[2] |TRIEN |Tri-State + * | | |0 = Tri-state Disabled. + * | | |1 = Tri-state Enabled. + * |[3] |TYPE |Type + * | | |0 = Input Schmitt Trigger function Disabled. + * | | |1 = Input Schmitt Trigger function Enabled. + * |[4] |DINOFF |Off Digital + * | | |0 = Off digital Disabled. + * | | |1 = Off digital Enabled. + */ + __IO uint32_t TAMP0PCTL; + + /** + * TAMP1PCTL + * =================================================================================================== + * Offset: 0x128 TAMPER1 Pin I/O Mode Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |OUTLV |Output Level + * | | |0 = Low. + * | | |1 = High. + * |[1] |OUTEN |Output Enable Control + * | | |0 = Output Enabled. + * | | |1 = Output Disabled. + * |[2] |TRIEN |Tri-State + * | | |0 = Tri-state Disabled. + * | | |1 = Tri-state Enabled. + * |[3] |TYPE |Type + * | | |0 = Input Schmitt Trigger function Disabled. + * | | |1 = Input Schmitt Trigger function Enabled. + * |[4] |DINOFF |Off Digital + * | | |0 = Off digital Disabled. + * | | |1 = Off digital Enabled. + */ + __IO uint32_t TAMP1PCTL; + + /** + * LXTIPCTL + * =================================================================================================== + * Offset: 0x12C 32K Input Pin I/O Mode Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |OUTLV |Output Level + * | | |0 = Low. + * | | |1 = High. + * |[1] |OUTEN |Output Enable Control + * | | |0 = Output Enabled. + * | | |1 = Output Disabled. + * |[2] |TRIEN |Tri-State + * | | |0 = Tri-state Disabled. + * | | |1 = Tri-state Enabled. + * |[3] |TYPE |Type + * | | |0 = Input Schmitt Trigger function Disabled. + * | | |1 = Input Schmitt Trigger function Enabled. + * |[4] |DINOFF |Off Digital + * | | |0 = Off digital Disabled. + * | | |1 = Off digital Enabled. + */ + __IO uint32_t LXTIPCTL; + + /** + * LXTOPCTL + * =================================================================================================== + * Offset: 0x130 32K Output Pin I/O Mode Control + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |OUTLV |Output Level + * | | |0 = Low. + * | | |1 = High. + * |[1] |OUTEN |Output Enable Control + * | | |0 = Output Enabled. + * | | |1 = Output Disabled. + * |[2] |TRIEN |Tri-State + * | | |0 = Tri-state Disabled. + * | | |1 = Tri-state Enabled. + * |[3] |TYPE |Type + * | | |0 = Input Schmitt Trigger function Disabled. + * | | |1 = Input Schmitt Trigger function Enabled. + * |[4] |DINOFF |Off Digital + * | | |0 = Off digital Disabled. + * | | |1 = Off digital Enabled. + */ + __IO uint32_t LXTOPCTL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE3[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TAMSK + * =================================================================================================== + * Offset: 0x140 Time Alarm MASK Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |MSEC |Mask 1-Sec Time Digit of Alarm Setting (0~9) + * |[1] |MTENSEC |Mask 10-Sec Time Digit of Alarm Setting (0~5) + * |[2] |MMIN |Mask 1-Min Time Digit of Alarm Setting (0~9) + * |[3] |MTENMIN |Mask 10-Min Time Digit of Alarm Setting (0~5) + * |[4] |MHR |Mask 1-Hour Time Digit of Alarm Setting (0~9) + * |[5] |MTENHR |Mask 10-Hour Time Digit of Alarm Setting (0~2) + */ + __IO uint32_t TAMSK; + + /** + * CAMSK + * =================================================================================================== + * Offset: 0x144 Calendar Alarm MASK Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |MDAY |Mask 1-Day Calendar Digit of Alarm Setting (0~9) + * |[1] |MTENDAY |Mask 10-Day Calendar Digit of Alarm Setting (0~3) + * |[2] |MMON |Mask 1-Month Calendar Digit of Alarm Setting (0~9) + * |[3] |MTENMON |Mask 10-Month Calendar Digit of Alarm Setting (0~1) + * |[4] |MYEAR |Mask 1-Year Calendar Digit of Alarm Setting (0~9) + * |[5] |MTENYEAR |Mask 10-Year Calendar Digit of Alarm Setting (0~9) + */ + __IO uint32_t CAMSK; + +} RTC_T; + +/** + @addtogroup RTC_CONST RTC Bit Field Definition + Constant Definitions for RTC Controller +@{ */ + +#define RTC_INIT_INIT_Active_Pos (0) /*!< RTC_T::INIT: INIT_Active Position */ +#define RTC_INIT_INIT_Active_Msk (0x1ul << RTC_INIT_INIT_Active_Pos) /*!< RTC_T::INIT: INIT_Active Mask */ + +#define RTC_INIT_INIT_Pos (1) /*!< RTC_T::INIT: INIT Position */ +#define RTC_INIT_INIT_Msk (0x7ffffffful << RTC_INIT_INIT_Pos) /*!< RTC_T::INIT: INIT Mask */ + +#define RTC_RWEN_RWEN_Pos (0) /*!< RTC_T::RWEN: RWEN Position */ +#define RTC_RWEN_RWEN_Msk (0xfffful << RTC_RWEN_RWEN_Pos) /*!< RTC_T::RWEN: RWEN Mask */ + +#define RTC_RWEN_RWENF_Pos (16) /*!< RTC_T::RWEN: RWENF Position */ +#define RTC_RWEN_RWENF_Msk (0x1ul << RTC_RWEN_RWENF_Pos) /*!< RTC_T::RWEN: RWENF Mask */ + +#define RTC_FREQADJ_FRACTION_Pos (0) /*!< RTC_T::FREQADJ: FRACTION Position */ +#define RTC_FREQADJ_FRACTION_Msk (0x3ful << RTC_FREQADJ_FRACTION_Pos) /*!< RTC_T::FREQADJ: FRACTION Mask */ + +#define RTC_FREQADJ_INTEGER_Pos (8) /*!< RTC_T::FREQADJ: INTEGER Position */ +#define RTC_FREQADJ_INTEGER_Msk (0xful << RTC_FREQADJ_INTEGER_Pos) /*!< RTC_T::FREQADJ: INTEGER Mask */ + +#define RTC_TIME_SEC_Pos (0) /*!< RTC_T::TIME: SEC Position */ +#define RTC_TIME_SEC_Msk (0xful << RTC_TIME_SEC_Pos) /*!< RTC_T::TIME: SEC Mask */ + +#define RTC_TIME_TENSEC_Pos (4) /*!< RTC_T::TIME: TENSEC Position */ +#define RTC_TIME_TENSEC_Msk (0x7ul << RTC_TIME_TENSEC_Pos) /*!< RTC_T::TIME: TENSEC Mask */ + +#define RTC_TIME_MIN_Pos (8) /*!< RTC_T::TIME: MIN Position */ +#define RTC_TIME_MIN_Msk (0xful << RTC_TIME_MIN_Pos) /*!< RTC_T::TIME: MIN Mask */ + +#define RTC_TIME_TENMIN_Pos (12) /*!< RTC_T::TIME: TENMIN Position */ +#define RTC_TIME_TENMIN_Msk (0x7ul << RTC_TIME_TENMIN_Pos) /*!< RTC_T::TIME: TENMIN Mask */ + +#define RTC_TIME_HR_Pos (16) /*!< RTC_T::TIME: HR Position */ +#define RTC_TIME_HR_Msk (0xful << RTC_TIME_HR_Pos) /*!< RTC_T::TIME: HR Mask */ + +#define RTC_TIME_TENHR_Pos (20) /*!< RTC_T::TIME: TENHR Position */ +#define RTC_TIME_TENHR_Msk (0x3ul << RTC_TIME_TENHR_Pos) /*!< RTC_T::TIME: TENHR Mask */ + +#define RTC_CAL_DAY_Pos (0) /*!< RTC_T::CAL: DAY Position */ +#define RTC_CAL_DAY_Msk (0xful << RTC_CAL_DAY_Pos) /*!< RTC_T::CAL: DAY Mask */ + +#define RTC_CAL_TENDAY_Pos (4) /*!< RTC_T::CAL: TENDAY Position */ +#define RTC_CAL_TENDAY_Msk (0x3ul << RTC_CAL_TENDAY_Pos) /*!< RTC_T::CAL: TENDAY Mask */ + +#define RTC_CAL_MON_Pos (8) /*!< RTC_T::CAL: MON Position */ +#define RTC_CAL_MON_Msk (0xful << RTC_CAL_MON_Pos) /*!< RTC_T::CAL: MON Mask */ + +#define RTC_CAL_TENMON_Pos (12) /*!< RTC_T::CAL: TENMON Position */ +#define RTC_CAL_TENMON_Msk (0x1ul << RTC_CAL_TENMON_Pos) /*!< RTC_T::CAL: TENMON Mask */ + +#define RTC_CAL_YEAR_Pos (16) /*!< RTC_T::CAL: YEAR Position */ +#define RTC_CAL_YEAR_Msk (0xful << RTC_CAL_YEAR_Pos) /*!< RTC_T::CAL: YEAR Mask */ + +#define RTC_CAL_TENYEAR_Pos (20) /*!< RTC_T::CAL: TENYEAR Position */ +#define RTC_CAL_TENYEAR_Msk (0xful << RTC_CAL_TENYEAR_Pos) /*!< RTC_T::CAL: TENYEAR Mask */ + +#define RTC_CLKFMT_24HEN_Pos (0) /*!< RTC_T::CLKFMT: 24HEN Position */ +#define RTC_CLKFMT_24HEN_Msk (0x1ul << RTC_CLKFMT_24HEN_Pos) /*!< RTC_T::CLKFMT: 24HEN Mask */ + +#define RTC_WEEKDAY_WEEKDAY_Pos (0) /*!< RTC_T::WEEKDAY: WEEKDAY Position */ +#define RTC_WEEKDAY_WEEKDAY_Msk (0x7ul << RTC_WEEKDAY_WEEKDAY_Pos) /*!< RTC_T::WEEKDAY: WEEKDAY Mask */ + +#define RTC_TALM_SEC_Pos (0) /*!< RTC_T::TALM: SEC Position */ +#define RTC_TALM_SEC_Msk (0xful << RTC_TALM_SEC_Pos) /*!< RTC_T::TALM: SEC Mask */ + +#define RTC_TALM_TENSEC_Pos (4) /*!< RTC_T::TALM: TENSEC Position */ +#define RTC_TALM_TENSEC_Msk (0x7ul << RTC_TALM_TENSEC_Pos) /*!< RTC_T::TALM: TENSEC Mask */ + +#define RTC_TALM_MIN_Pos (8) /*!< RTC_T::TALM: MIN Position */ +#define RTC_TALM_MIN_Msk (0xful << RTC_TALM_MIN_Pos) /*!< RTC_T::TALM: MIN Mask */ + +#define RTC_TALM_TENMIN_Pos (12) /*!< RTC_T::TALM: TENMIN Position */ +#define RTC_TALM_TENMIN_Msk (0x7ul << RTC_TALM_TENMIN_Pos) /*!< RTC_T::TALM: TENMIN Mask */ + +#define RTC_TALM_HR_Pos (16) /*!< RTC_T::TALM: HR Position */ +#define RTC_TALM_HR_Msk (0xful << RTC_TALM_HR_Pos) /*!< RTC_T::TALM: HR Mask */ + +#define RTC_TALM_TENHR_Pos (20) /*!< RTC_T::TALM: TENHR Position */ +#define RTC_TALM_TENHR_Msk (0x3ul << RTC_TALM_TENHR_Pos) /*!< RTC_T::TALM: TENHR Mask */ + +#define RTC_CALM_DAY_Pos (0) /*!< RTC_T::CALM: DAY Position */ +#define RTC_CALM_DAY_Msk (0xful << RTC_CALM_DAY_Pos) /*!< RTC_T::CALM: DAY Mask */ + +#define RTC_CALM_TENDAY_Pos (4) /*!< RTC_T::CALM: TENDAY Position */ +#define RTC_CALM_TENDAY_Msk (0x3ul << RTC_CALM_TENDAY_Pos) /*!< RTC_T::CALM: TENDAY Mask */ + +#define RTC_CALM_MON_Pos (8) /*!< RTC_T::CALM: MON Position */ +#define RTC_CALM_MON_Msk (0xful << RTC_CALM_MON_Pos) /*!< RTC_T::CALM: MON Mask */ + +#define RTC_CALM_TENMON_Pos (12) /*!< RTC_T::CALM: TENMON Position */ +#define RTC_CALM_TENMON_Msk (0x1ul << RTC_CALM_TENMON_Pos) /*!< RTC_T::CALM: TENMON Mask */ + +#define RTC_CALM_YEAR_Pos (16) /*!< RTC_T::CALM: YEAR Position */ +#define RTC_CALM_YEAR_Msk (0xful << RTC_CALM_YEAR_Pos) /*!< RTC_T::CALM: YEAR Mask */ + +#define RTC_CALM_TENYEAR_Pos (20) /*!< RTC_T::CALM: TENYEAR Position */ +#define RTC_CALM_TENYEAR_Msk (0xful << RTC_CALM_TENYEAR_Pos) /*!< RTC_T::CALM: TENYEAR Mask */ + +#define RTC_LEAPYEAR_LEAPYEAR_Pos (0) /*!< RTC_T::LEAPYEAR: LEAPYEAR Position */ +#define RTC_LEAPYEAR_LEAPYEAR_Msk (0x1ul << RTC_LEAPYEAR_LEAPYEAR_Pos) /*!< RTC_T::LEAPYEAR: LEAPYEAR Mask */ + +#define RTC_INTEN_ALMIEN_Pos (0) /*!< RTC_T::INTEN: ALMIEN Position */ +#define RTC_INTEN_ALMIEN_Msk (0x1ul << RTC_INTEN_ALMIEN_Pos) /*!< RTC_T::INTEN: ALMIEN Mask */ + +#define RTC_INTEN_TICKIEN_Pos (1) /*!< RTC_T::INTEN: TICKIEN Position */ +#define RTC_INTEN_TICKIEN_Msk (0x1ul << RTC_INTEN_TICKIEN_Pos) /*!< RTC_T::INTEN: TICKIEN Mask */ + +#define RTC_INTSTS_ALMIF_Pos (0) /*!< RTC_T::INTSTS: ALMIF Position */ +#define RTC_INTSTS_ALMIF_Msk (0x1ul << RTC_INTSTS_ALMIF_Pos) /*!< RTC_T::INTSTS: ALMIF Mask */ + +#define RTC_INTSTS_TICKIF_Pos (1) /*!< RTC_T::INTSTS: TICKIF Position */ +#define RTC_INTSTS_TICKIF_Msk (0x1ul << RTC_INTSTS_TICKIF_Pos) /*!< RTC_T::INTSTS: TICKIF Mask */ + +#define RTC_TICK_TICKSEL_Pos (0) /*!< RTC_T::TICK: TICKSEL Position */ +#define RTC_TICK_TICKSEL_Msk (0x7ul << RTC_TICK_TICKSEL_Pos) /*!< RTC_T::TICK: TICKSEL Mask */ + +#define RTC_SPRCTL_SPRRWEN_Pos (2) /*!< RTC_T::SPRCTL: SPRRWEN Position */ +#define RTC_SPRCTL_SPRRWEN_Msk (0x1ul << RTC_SPRCTL_SPRRWEN_Pos) /*!< RTC_T::SPRCTL: SPRRWEN Mask */ + +#define RTC_SPRCTL_SPRRWRDY_Pos (7) /*!< RTC_T::SPRCTL: SPRRWRDY Position */ +#define RTC_SPRCTL_SPRRWRDY_Msk (0x1ul << RTC_SPRCTL_SPRRWRDY_Pos) /*!< RTC_T::SPRCTL: SPRRWRDY Mask */ + +#define RTC_TAMPCTL_TIEN_Pos (0) /*!< RTC_T::TAMPCTL: TIEN Position */ +#define RTC_TAMPCTL_TIEN_Msk (0x1ul << RTC_TAMPCTL_TIEN_Pos) /*!< RTC_T::TAMPCTL: TIEN Mask */ + +#define RTC_TAMPCTL_DESTROYEN_Pos (1) /*!< RTC_T::TAMPCTL: DESTROYEN Position */ +#define RTC_TAMPCTL_DESTROYEN_Msk (0x1ul << RTC_TAMPCTL_DESTROYEN_Pos) /*!< RTC_T::TAMPCTL: DESTROYEN Mask */ + +#define RTC_TAMPCTL_TAMPEN0_Pos (2) /*!< RTC_T::TAMPCTL: TAMPEN0 Position */ +#define RTC_TAMPCTL_TAMPEN0_Msk (0x1ul << RTC_TAMPCTL_TAMPEN0_Pos) /*!< RTC_T::TAMPCTL: TAMPEN0 Mask */ + +#define RTC_TAMPCTL_TAMPEN1_Pos (3) /*!< RTC_T::TAMPCTL: TAMPEN1 Position */ +#define RTC_TAMPCTL_TAMPEN1_Msk (0x1ul << RTC_TAMPCTL_TAMPEN1_Pos) /*!< RTC_T::TAMPCTL: TAMPEN1 Mask */ + +#define RTC_TAMPCTL_TAMPDBEN0_Pos (4) /*!< RTC_T::TAMPCTL: TAMPDBEN0 Position */ +#define RTC_TAMPCTL_TAMPDBEN0_Msk (0x1ul << RTC_TAMPCTL_TAMPDBEN0_Pos) /*!< RTC_T::TAMPCTL: TAMPDBEN0 Mask */ + +#define RTC_TAMPCTL_TAMPDBEN1_Pos (5) /*!< RTC_T::TAMPCTL: TAMPDBEN1 Position */ +#define RTC_TAMPCTL_TAMPDBEN1_Msk (0x1ul << RTC_TAMPCTL_TAMPDBEN1_Pos) /*!< RTC_T::TAMPCTL: TAMPDBEN1 Mask */ + +#define RTC_TAMPCTL_TAMPLV0_Pos (6) /*!< RTC_T::TAMPCTL: TAMPLV0 Position */ +#define RTC_TAMPCTL_TAMPLV0_Msk (0x1ul << RTC_TAMPCTL_TAMPLV0_Pos) /*!< RTC_T::TAMPCTL: TAMPLV0 Mask */ + +#define RTC_TAMPCTL_TAMPLV1_Pos (7) /*!< RTC_T::TAMPCTL: TAMPLV1 Position */ +#define RTC_TAMPCTL_TAMPLV1_Msk (0x1ul << RTC_TAMPCTL_TAMPLV1_Pos) /*!< RTC_T::TAMPCTL: TAMPLV1 Mask */ + +#define RTC_TAMPSTS_TAMPSTS0_Pos (0) /*!< RTC_T::TAMPSTS: TAMPSTS0 Position */ +#define RTC_TAMPSTS_TAMPSTS0_Msk (0x1ul << RTC_TAMPSTS_TAMPSTS0_Pos) /*!< RTC_T::TAMPSTS: TAMPSTS0 Mask */ + +#define RTC_TAMPSTS_TAMPSTS1_Pos (1) /*!< RTC_T::TAMPSTS: TAMPSTS1 Position */ +#define RTC_TAMPSTS_TAMPSTS1_Msk (0x1ul << RTC_TAMPSTS_TAMPSTS1_Pos) /*!< RTC_T::TAMPSTS: TAMPSTS1 Mask */ + +#define RTC_TAMP0PCTL_OUTLV_Pos (0) /*!< RTC_T::TAMP0PCTL: OUTLV Position */ +#define RTC_TAMP0PCTL_OUTLV_Msk (0x1ul << RTC_TAMP0PCTL_OUTLV_Pos) /*!< RTC_T::TAMP0PCTL: OUTLV Mask */ + +#define RTC_TAMP0PCTL_OUTEN_Pos (1) /*!< RTC_T::TAMP0PCTL: OUTEN Position */ +#define RTC_TAMP0PCTL_OUTEN_Msk (0x1ul << RTC_TAMP0PCTL_OUTEN_Pos) /*!< RTC_T::TAMP0PCTL: OUTEN Mask */ + +#define RTC_TAMP0PCTL_TRIEN_Pos (2) /*!< RTC_T::TAMP0PCTL: TRIEN Position */ +#define RTC_TAMP0PCTL_TRIEN_Msk (0x1ul << RTC_TAMP0PCTL_TRIEN_Pos) /*!< RTC_T::TAMP0PCTL: TRIEN Mask */ + +#define RTC_TAMP0PCTL_TYPE_Pos (3) /*!< RTC_T::TAMP0PCTL: TYPE Position */ +#define RTC_TAMP0PCTL_TYPE_Msk (0x1ul << RTC_TAMP0PCTL_TYPE_Pos) /*!< RTC_T::TAMP0PCTL: TYPE Mask */ + +#define RTC_TAMP0PCTL_DINOFF_Pos (4) /*!< RTC_T::TAMP0PCTL: DINOFF Position */ +#define RTC_TAMP0PCTL_DINOFF_Msk (0x1ul << RTC_TAMP0PCTL_DINOFF_Pos) /*!< RTC_T::TAMP0PCTL: DINOFF Mask */ + +#define RTC_TAMP1PCTL_OUTLV_Pos (0) /*!< RTC_T::TAMP1PCTL: OUTLV Position */ +#define RTC_TAMP1PCTL_OUTLV_Msk (0x1ul << RTC_TAMP1PCTL_OUTLV_Pos) /*!< RTC_T::TAMP1PCTL: OUTLV Mask */ + +#define RTC_TAMP1PCTL_OUTEN_Pos (1) /*!< RTC_T::TAMP1PCTL: OUTEN Position */ +#define RTC_TAMP1PCTL_OUTEN_Msk (0x1ul << RTC_TAMP1PCTL_OUTEN_Pos) /*!< RTC_T::TAMP1PCTL: OUTEN Mask */ + +#define RTC_TAMP1PCTL_TRIEN_Pos (2) /*!< RTC_T::TAMP1PCTL: TRIEN Position */ +#define RTC_TAMP1PCTL_TRIEN_Msk (0x1ul << RTC_TAMP1PCTL_TRIEN_Pos) /*!< RTC_T::TAMP1PCTL: TRIEN Mask */ + +#define RTC_TAMP1PCTL_TYPE_Pos (3) /*!< RTC_T::TAMP1PCTL: TYPE Position */ +#define RTC_TAMP1PCTL_TYPE_Msk (0x1ul << RTC_TAMP1PCTL_TYPE_Pos) /*!< RTC_T::TAMP1PCTL: TYPE Mask */ + +#define RTC_TAMP1PCTL_DINOFF_Pos (4) /*!< RTC_T::TAMP1PCTL: DINOFF Position */ +#define RTC_TAMP1PCTL_DINOFF_Msk (0x1ul << RTC_TAMP1PCTL_DINOFF_Pos) /*!< RTC_T::TAMP1PCTL: DINOFF Mask */ + +#define RTC_LXTIPCTL_OUTLV_Pos (0) /*!< RTC_T::LXTIPCTL: OUTLV Position */ +#define RTC_LXTIPCTL_OUTLV_Msk (0x1ul << RTC_LXTIPCTL_OUTLV_Pos) /*!< RTC_T::LXTIPCTL: OUTLV Mask */ + +#define RTC_LXTIPCTL_OUTEN_Pos (1) /*!< RTC_T::LXTIPCTL: OUTEN Position */ +#define RTC_LXTIPCTL_OUTEN_Msk (0x1ul << RTC_LXTIPCTL_OUTEN_Pos) /*!< RTC_T::LXTIPCTL: OUTEN Mask */ + +#define RTC_LXTIPCTL_TRIEN_Pos (2) /*!< RTC_T::LXTIPCTL: TRIEN Position */ +#define RTC_LXTIPCTL_TRIEN_Msk (0x1ul << RTC_LXTIPCTL_TRIEN_Pos) /*!< RTC_T::LXTIPCTL: TRIEN Mask */ + +#define RTC_LXTIPCTL_TYPE_Pos (3) /*!< RTC_T::LXTIPCTL: TYPE Position */ +#define RTC_LXTIPCTL_TYPE_Msk (0x1ul << RTC_LXTIPCTL_TYPE_Pos) /*!< RTC_T::LXTIPCTL: TYPE Mask */ + +#define RTC_LXTIPCTL_DINOFF_Pos (4) /*!< RTC_T::LXTIPCTL: DINOFF Position */ +#define RTC_LXTIPCTL_DINOFF_Msk (0x1ul << RTC_LXTIPCTL_DINOFF_Pos) /*!< RTC_T::LXTIPCTL: DINOFF Mask */ + +#define RTC_LXTOPCTL_OUTLV_Pos (0) /*!< RTC_T::LXTOPCTL: OUTLV Position */ +#define RTC_LXTOPCTL_OUTLV_Msk (0x1ul << RTC_LXTOPCTL_OUTLV_Pos) /*!< RTC_T::LXTOPCTL: OUTLV Mask */ + +#define RTC_LXTOPCTL_OUTEN_Pos (1) /*!< RTC_T::LXTOPCTL: OUTEN Position */ +#define RTC_LXTOPCTL_OUTEN_Msk (0x1ul << RTC_LXTOPCTL_OUTEN_Pos) /*!< RTC_T::LXTOPCTL: OUTEN Mask */ + +#define RTC_LXTOPCTL_TRIEN_Pos (2) /*!< RTC_T::LXTOPCTL: TRIEN Position */ +#define RTC_LXTOPCTL_TRIEN_Msk (0x1ul << RTC_LXTOPCTL_TRIEN_Pos) /*!< RTC_T::LXTOPCTL: TRIEN Mask */ + +#define RTC_LXTOPCTL_TYPE_Pos (3) /*!< RTC_T::LXTOPCTL: TYPE Position */ +#define RTC_LXTOPCTL_TYPE_Msk (0x1ul << RTC_LXTOPCTL_TYPE_Pos) /*!< RTC_T::LXTOPCTL: TYPE Mask */ + +#define RTC_LXTOPCTL_DINOFF_Pos (4) /*!< RTC_T::LXTOPCTL: DINOFF Position */ +#define RTC_LXTOPCTL_DINOFF_Msk (0x1ul << RTC_LXTOPCTL_DINOFF_Pos) /*!< RTC_T::LXTOPCTL: DINOFF Mask */ + +#define RTC_TAMSK_MSEC_Pos (0) /*!< RTC_T::TAMSK: MSEC Position */ +#define RTC_TAMSK_MSEC_Msk (0x1ul << RTC_TAMSK_MSEC_Pos) /*!< RTC_T::TAMSK: MSEC Mask */ + +#define RTC_TAMSK_MTENSEC_Pos (1) /*!< RTC_T::TAMSK: MTENSEC Position */ +#define RTC_TAMSK_MTENSEC_Msk (0x1ul << RTC_TAMSK_MTENSEC_Pos) /*!< RTC_T::TAMSK: MTENSEC Mask */ + +#define RTC_TAMSK_MMIN_Pos (2) /*!< RTC_T::TAMSK: MMIN Position */ +#define RTC_TAMSK_MMIN_Msk (0x1ul << RTC_TAMSK_MMIN_Pos) /*!< RTC_T::TAMSK: MMIN Mask */ + +#define RTC_TAMSK_MTENMIN_Pos (3) /*!< RTC_T::TAMSK: MTENMIN Position */ +#define RTC_TAMSK_MTENMIN_Msk (0x1ul << RTC_TAMSK_MTENMIN_Pos) /*!< RTC_T::TAMSK: MTENMIN Mask */ + +#define RTC_TAMSK_MHR_Pos (4) /*!< RTC_T::TAMSK: MHR Position */ +#define RTC_TAMSK_MHR_Msk (0x1ul << RTC_TAMSK_MHR_Pos) /*!< RTC_T::TAMSK: MHR Mask */ + +#define RTC_TAMSK_MTENHR_Pos (5) /*!< RTC_T::TAMSK: MTENHR Position */ +#define RTC_TAMSK_MTENHR_Msk (0x1ul << RTC_TAMSK_MTENHR_Pos) /*!< RTC_T::TAMSK: MTENHR Mask */ + +#define RTC_CAMSK_MDAY_Pos (0) /*!< RTC_T::CAMSK: MDAY Position */ +#define RTC_CAMSK_MDAY_Msk (0x1ul << RTC_CAMSK_MDAY_Pos) /*!< RTC_T::CAMSK: MDAY Mask */ + +#define RTC_CAMSK_MTENDAY_Pos (1) /*!< RTC_T::CAMSK: MTENDAY Position */ +#define RTC_CAMSK_MTENDAY_Msk (0x1ul << RTC_CAMSK_MTENDAY_Pos) /*!< RTC_T::CAMSK: MTENDAY Mask */ + +#define RTC_CAMSK_MMON_Pos (2) /*!< RTC_T::CAMSK: MMON Position */ +#define RTC_CAMSK_MMON_Msk (0x1ul << RTC_CAMSK_MMON_Pos) /*!< RTC_T::CAMSK: MMON Mask */ + +#define RTC_CAMSK_MTENMON_Pos (3) /*!< RTC_T::CAMSK: MTENMON Position */ +#define RTC_CAMSK_MTENMON_Msk (0x1ul << RTC_CAMSK_MTENMON_Pos) /*!< RTC_T::CAMSK: MTENMON Mask */ + +#define RTC_CAMSK_MYEAR_Pos (4) /*!< RTC_T::CAMSK: MYEAR Position */ +#define RTC_CAMSK_MYEAR_Msk (0x1ul << RTC_CAMSK_MYEAR_Pos) /*!< RTC_T::CAMSK: MYEAR Mask */ + +#define RTC_CAMSK_MTENYEAR_Pos (5) /*!< RTC_T::CAMSK: MTENYEAR Position */ +#define RTC_CAMSK_MTENYEAR_Msk (0x1ul << RTC_CAMSK_MTENYEAR_Pos) /*!< RTC_T::CAMSK: MTENYEAR Mask */ + +/**@}*/ /* RTC_CONST */ +/**@}*/ /* end of RTC register group */ + + +/*---------------------- Smart Card Host Interface Controller -------------------------*/ +/** + @addtogroup SC Smart Card Host Interface Controller(SC) + Memory Mapped Structure for SC Controller +@{ */ + +typedef struct { + + + /** + * DAT + * =================================================================================================== + * Offset: 0x00 SC Receive and Transmit Buffer Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DAT |Receiving/ Transmit Buffer + * | | |Write Operation: + * | | |By writing data to DAT, the SC will send out an 8-bit data. + * | | |Note: If SCEN(SC_CTL[0]) is not enabled, DAT cannot be programmed. + * | | |Read Operation: + * | | |By reading DAT, the SC will return an 8-bit received data. + */ + __IO uint32_t DAT; + + /** + * CTL + * =================================================================================================== + * Offset: 0x04 SC Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SCEN |SC Engine Enable Control + * | | |Set this bit to 1 to enable SC operation. + * | | |If this bit is cleared, SC will force all transition to IDLE state. + * |[1] |RXOFF |RX Transition Disable Control + * | | |0 = The receiver Enabled. + * | | |1 = The receiver Disabled. + * | | |Note: If AUTOCEN is enabled, this fields must be ignored. + * |[2] |TXOFF |TX Transition Disable Control + * | | |0 = The transceiver Enabled. + * | | |1 = The transceiver Disabled. + * |[3] |AUTOCEN |Auto Convention Enable Control + * | | |0 = Auto-convention Disabled. + * | | |1 = Auto-convention Enabled. + * | | |When hardware receives TS in answer to reset state and the TS is direct convention, CONSEL(SC_CTL[5:4]) will be set to 00 automatically, otherwise if the TS is inverse convention, and CONSEL (SC_CTL[5:4]) will be set to 11. + * | | |If software enables auto convention function, the setting step must be done before Answer to Reset state and the first data must be 3B or 3F. + * | | |After hardware received first data and stored it at buffer, hardware will decided the convention and change the CONSEL (SC_CTL[5:4]) bits automatically. + * | | |If the first data is not 3B or 3F, hardware will generate an interrupt INT_ACON_ERR (if ACON_ERR IE (SC_INTEN[10]) = 1 to CPU. + * |[4:5] |CONSEL |Convention Selection + * | | |00 = Direct convention. + * | | |01 = Reserved. + * | | |10 = Reserved. + * | | |11 = Inverse convention. + * | | |Note: If AUTOCEN(SC_CTL[3]) enabled, this fields are ignored. + * |[6:7] |RXTRGLV |Rx Buffer Trigger Level + * | | |When the number of bytes in the receiving buffer equals the RXTRGLV, the RDA_IF will be set (if IER [RDAIENN] is enabled, an interrupt will be generated). + * | | |00 = INTR_RDA Trigger Level with 01 Bytes. + * | | |01 = INTR_RDA Trigger Level with 02 Bytes. + * | | |10 = INTR_RDA Trigger Level with 03 Bytes. + * | | |11 = Reserved. + * |[8:12] |BGT |Block Guard Time (BGT) + * | | |Block guard time means the minimum bit length between the leading edges of two consecutive characters between different transfer directions. + * | | |This field indicates the counter for the bit length of block guard time. + * | | |According to ISO7816-3, in T = 0 mode, software must fill 15 (real block guard time = 16.5) to this field; in T = 1 mode, software must fill 21 (real block guard time = 22.5) to it. + * | | |In RX mode, software can enable SC_ALTCTL [RXBGTEN] to detect the first coming character timing. + * | | |If the incoming data timing less than BGT, an interrupt will be generated. + * | | |Note: The real block guard time is BGT + 1. + * |[13:14] |TMRSEL |Timer Selection + * | | |00 = All internal timer function Disabled. + * | | |01 = Internal 24 bit timer Enabled. + * | | |Software can configure it by setting SC_TMRCTL0 [23:0]. + * | | |SC_TMRCTL1 and SC_TMRCTL2 will be ignored in this mode. + * | | |10 = internal 24 bit timer and 8 bit internal timer Enabled. + * | | |Software can configure the 24 bit timer by setting SC_TMRCTL0 [23:0] and configure the 8 bit timer by setting SC_TMRCTL1[7:0]. + * | | |SC_TMRCTL2 will be ignored in this mode. + * | | |11 = Internal 24 bit timer and two 8 bit timers Enabled. + * | | |Software can configure them by setting SC_TMRCTL0 [23:0], SC_TMRCTL1 [7:0] and SC_TMRCTL2 [7:0]. + * |[15] |NSB |Stop Bit Length + * | | |This field indicates the length of stop bit. + * | | |0 = The stop bit length is 2 ETU. + * | | |1= The stop bit length is 1 ETU. + * | | |Note: The default stop bit length is 2. SMC and UART adopts NSB to program the stop bit length + * |[16:18] |RXRTY |RX Error Retry Count Number + * | | |This field indicates the maximum number of receiver retries that are allowed when parity error has occurred + * | | |Note1: The real retry number is RXRTY + 1, so 8 is the maximum retry number. + * | | |Note2: This field cannot be changed when RXRTYEN enabled. + * | | |The change flow is to disable RX_ETRTRY_EN first and then fill in new retry value. + * |[19] |RXRTYEN |RX Error Retry Enable Control + * | | |This bit enables receiver retry function when parity error has occurred. + * | | |1 = RX error retry function Enabled. + * | | |0 = RX error retry function Disabled. + * | | |Note: Software must fill in the RXRTY value before enabling this bit. + * |[20:22] |TXRTY |TX Error Retry Count Number + * | | |This field indicates the maximum number of transmitter retries that are allowed when parity error has occurred. + * | | |Note1: The real retry number is TXRTY + 1, so 8 is the maximum retry number. + * | | |Note2: This field cannot be changed when TXRTYEN enabled. + * | | |The change flow is to disable TX_ETRTRY_EN first and then fill in new retry value. + * |[23] |TXRTYEN |TX Error Retry Enable Control + * | | |This bit enables transmitter retry function when parity error has occurred. + * | | |0 = TX error retry function Disabled. + * | | |1 = TX error retry function Enabled. + * |[24:25] |CDDBSEL |Card Detect De-Bounce Selection + * | | |This field indicates the card detect de-bounce selection. + * | | |00 = De-bounce sample card insert once per 384 (128 * 3) engine clocks and de-bounce sample card removal once per 128 engine clocks. + * | | |01 = De-bounce sample card insert once per 192 (64 * 3) engine clocks and de-bounce sample card removal once per 64 engine clocks. + * | | |10 = De-bounce sample card insert once per 96 (32 * 3) engine clocks and de-bounce sample card removal once per 32 engine clocks. + * | | |11 = De-bounce sample card insert once per 48 (16 * 3) engine clocks and de-bounce sample card removal once per 16 engine clocks. + * |[26] |CDLV |Card Detect Level + * | | |0 = When hardware detects the card detect pin from high to low, it indicates a card is detected. + * | | |1 = When hardware detects the card detect pin from low to high, it indicates a card is detected. + * | | |Note: Software must select card detect level before Smart Card engine enabled. + * |[30] |SYNC |SYNC Flag Indicator + * | | |Due to synchronization, software should check this bit before writing a new value to RXRTY and TXRTY. + * | | |0 = synchronizing is completion, user can write new data to SC_PINCTL register. + * | | |1 = Last value is synchronizing. + * | | |Note: This bit is read only. + */ + __IO uint32_t CTL; + + /** + * ALTCTL + * =================================================================================================== + * Offset: 0x08 SC Alternate Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TXRST |TX Software Reset + * | | |When TXRST is set, all the bytes in the transmit buffer and TX internal state machine will be cleared. + * | | |0 = No effect. + * | | |1 = Reset the TX internal state machine and pointers. + * | | |Note: This bit will be auto cleared after reset is complete. + * |[1] |RXRST |Rx Software Reset + * | | |When RXRST is set, all the bytes in the receiver buffer and Rx internal state machine will be cleared. + * | | |0 = No effect. + * | | |1 = Reset the Rx internal state machine and pointers. + * | | |Note: This bit will be auto cleared after reset is complete. + * |[2] |DACTEN |Deactivation Sequence Generator Enable Control + * | | |This bit enables SC controller to initiate the card by deactivation sequence + * | | |0 = No effect. + * | | |1 = Deactivation sequence generator Enabled. + * | | |Note1: When the deactivation sequence completed, this bit will be cleared automatically and the INITIF(SC_INTSTS[8]) will be set to 1. + * | | |Note2: This field will be cleared by TXRST(SC_ALTCTL[0]) and RXRST(SC_ALTCTL[1]). + * | | |So don't fill this bit, TXRST, and RXRST at the same time. + * | | |Note3: If SC_CTL [SCEN] not enabled, this filed cannot be programmed. + * |[3] |ACTEN |Activation Sequence Generator Enable Control + * | | |This bit enables SC controller to initiate the card by activation sequence + * | | |0 = No effect. + * | | |1 = Activation sequence generator Enabled. + * | | |Note1: When the activation sequence completed, this bit will be cleared automatically and the INITIF(SC_INTSTS[8]) will be set to 1. + * | | |Note2: This field will be cleared by TXRST(SC_ALTCTL[0]) and RXRST(SC_ALTCTL[1]), so don't fill this bit, TXRST(SC_ALTCTL[0]), and RXRST(SC_ALTCTL[1]) at the same time. + * | | |Note3: If SCEN(SC_CTL[0]) is not enabled, this filed cannot be programmed. + * |[4] |WARSTEN |Warm Reset Sequence Generator Enable Control + * | | |This bit enables SC controller to initiate the card by warm reset sequence + * | | |0 = No effect. + * | | |1 = Warm reset sequence generator Enabled. + * | | |Note1: When the warm reset sequence completed, this bit will be cleared automatically and the INITIF(SC_INTSTS[8]) will be set to 1. + * | | |Note2: This field will be cleared by TXRST(SC_ALTCTL[0]) and RXRST(SC_ALTCTL[1]), so don't fill this bit, TXRST, and RXRST at the same time. + * | | |Note3: If SCEN(SC_CTL[0]) is not enabled, this filed cannot be programmed. + * |[5] |CNTEN0 |Internal Timer0 Start Enable Control + * | | |This bit enables Timer 0 to start counting. + * | | |Software can fill 0 to stop it and set 1 to reload and count. + * | | |0 = Stops counting. + * | | |1 = Start counting. + * | | |Note1: This field is used for internal 24 bit timer when TMRSEL (SC_CTL[14:13]) = 01. + * | | |Note2: If the operation mode is not in auto-reload mode (SC_TMRCTL0[26] = 0), this bit will be auto-cleared by hardware. + * | | |Note3: This field will be cleared by TXRST(SC_ALTCTL[0]) and RXRST(SC_ALTCTL[1]). + * | | |So don't fill this bit, TXRST and RXRST at the same time. + * | | |Note4: If SCEN(SC_CTL[0]) is not enabled, this filed cannot be programmed. + * |[6] |CNTEN1 |Internal Timer1 Start Enable Control + * | | |This bit enables Timer 1 to start counting. + * | | |Software can fill 0 to stop it and set 1 to reload and count. + * | | |0 = Stops counting. + * | | |1 = Start counting. + * | | |Note1: This field is used for internal 8 bit timer when TMRSEL(SC_CTL[14:13]) = 10 or TMRSEL(SC_CTL[14:13]) = 11. + * | | |Don't filled CNTEN1 when SC_CTL([TMRSEL] = 00 or SC_CTL[TMRSEL] = 01. + * | | |Note2: If the operation mode is not in auto-reload mode (SC_TMRCTL1[26] = 0), this bit will be auto-cleared by hardware. + * | | |Note3: This field will be cleared by TXRST(SC_ALTCTL[0]) and RXRST(SC_ALTCTL[1]), so don't fill this bit, TXRST(SC_ALTCTL[0]), and RXRST(SC_ALTCTL[1]) at the same time. + * | | |Note4: If SCEN(SC_CTL[0]) is not enabled, this filed cannot be programmed. + * |[7] |CNTEN2 |Internal Timer2 Start Enable Control + * | | |This bit enables Timer 2 to start counting. + * | | |Software can fill 0 to stop it and set 1 to reload and count. + * | | |0 = Stops counting. + * | | |1 = Start counting. + * | | |Note1: This field is used for internal 8 bit timer when TMRSEL(SC_CTL[14:13]) = 11. + * | | |Don't filled CNTEN2 when TMRSEL(SC_CTL[14:13]) = 00 or TMRSEL(SC_CTL[14:13]) = 01 or TMRSEL(SC_CTL[14:13]) = 10. + * | | |Note2: If the operation mode is not in auto-reload mode (SC_TMRCTL2[26] = 0), this bit will be auto-cleared by hardware. + * | | |Note3: This field will be cleared by TXRST(SC_ALTCTL[0]) and RXRST(SC_ALTCTL[1]). + * | | |So don't fill this bit, TXRST(SC_ALTCTL[0]), and RXRST(SC_ALTCTL[1]) at the same time. + * | | |Note4: If SCEN(SC_CTL[0]) is not enabled, this filed cannot be programmed. + * |[8:9] |INITSEL |Initial Timing Selection + * | | |This fields indicates the timing of hardware initial state (activation or warm-reset or deactivation). + * | | |Unit: SC clock + * | | |Activation: refer to SC Activation Sequence in Figure 5.19-4. + * | | |Warm-reset: refer to Warm-Reset Sequence in Figure 5.19-5 + * | | |Deactivation: refer to Deactivation Sequence in Figure 5.19-6 + * |[11] |ADACEN |Auto Deactivation When Card Removal + * | | |0 = Auto deactivation Disabled when hardware detected the card removal. + * | | |1 = Auto deactivation Enabled when hardware detected the card removal. + * | | |Note: When the card is removed, hardware will stop any process and then do deactivation sequence (if this bit is set). + * | | |If this process completes, hardware will generate an interrupt INT_INIT to CPU. + * |[12] |RXBGTEN |Receiver Block Guard Time Function Enable Control + * | | |0 = Receiver block guard time function Disabled. + * | | |1 = Receiver block guard time function Enabled. + * |[13] |ACTSTS0 |Internal Timer0 Active State (Read Only) + * | | |This bit indicates the timer counter status of timer0. + * | | |0 = Timer0 is not active. + * | | |1 = Timer0 is active. + * |[14] |ACTSTS1 |Internal Timer1 Active State (Read Only) + * | | |This bit indicates the timer counter status of timer1. + * | | |0 = Timer1 is not active. + * | | |1 = Timer1 is active. + * |[15] |ACTSTS2 |Internal Timer2 Active State (Read Only) + * | | |This bit indicates the timer counter status of timer2. + * | | |0 = Timer2 is not active. + * | | |1 = Timer2 is active. + */ + __IO uint32_t ALTCTL; + + /** + * EGT + * =================================================================================================== + * Offset: 0x0C SC Extend Guard Time Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |EGT |Extended Guard Time + * | | |This field indicates the extended guard timer value. + * | | |Note: The counter is ETU base and the real extended guard time is EGT. + */ + __IO uint32_t EGT; + + /** + * RXTOUT + * =================================================================================================== + * Offset: 0x10 SC Receive Buffer Time-out Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:8] |RFTM |SC Receiver Buffer Time-Out (ETU Base) + * | | |The time-out counter resets and starts counting whenever the RX buffer received a new data word. + * | | |Once the counter decrease to 1 and no new data is received or CPU does not read data by reading SC_DAT buffer, a receiver time-out interrupt INT_RTMR will be generated(if RXTOIF(SC_INTEN[9]) = 1 ). + * | | |Note1: The counter unit is ETU based and the interval of time-out is RFTM + 0.5 + * | | |Note2: Fill all 0 to this field indicates to disable this function. + */ + __IO uint32_t RXTOUT; + + /** + * ETUCTL + * =================================================================================================== + * Offset: 0x14 SC ETU Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |ETURDIV |ETU Rate Divider + * | | |The field indicates the clock rate divider. + * | | |The real ETU is ETURDIV + 1. + * | | |Note: Software can configure this field, but this field must be greater than 0x004. + * |[15] |CMPEN |Compensation Mode Enable Control + * | | |This bit enables clock compensation function. + * | | |When this bit enabled, hardware will alternate between n clock cycles and n-1 clock cycles, where n is the value to be written into the ETURDIV . + * | | |0 = Compensation function Disabled. + * | | |1 = Compensation function Enabled. + */ + __IO uint32_t ETUCTL; + + /** + * INTEN + * =================================================================================================== + * Offset: 0x18 SC Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RDAIEN |Receive Data Reach Interrupt Enable Control + * | | |This field is used for received data reaching trigger level RXTRGLV (SC_CTL[7:6]) interrupt enable. + * | | |0 = Receive data reach trigger level interrupt Disabled. + * | | |1 = Receive data reach trigger level interrupt Enabled. + * |[1] |TBEIEN |Transmit Buffer Empty Interrupt Enable Control + * | | |This field is used for transmit buffer empty interrupt enable. + * | | |0 = Transmit buffer empty interrupt Disabled. + * | | |1 = Transmit buffer empty interrupt Enabled. + * |[2] |TERRIEN |Transfer Error Interrupt Enable Control + * | | |This field is used for transfer error interrupt enable. + * | | |The transfer error states is at SC_STATUS register which includes receiver break error BEF(SC_STATUS[6]), frame error FEF(SC_STATUS[5]), parity error PEF(SC_STATUS[4]), receiver buffer overflow error RXOV(SC_STATUS[0]), transmit buffer overflow error TXOVER(SC_STATUS[8]), receiver retry over limit error RXOVERR(SC_STATUS[22] and transmitter retry over limit error TXOVERR(SC_STATUS[30]. + * | | |0 = Transfer error interrupt Disabled. + * | | |1 = Transfer error interrupt Enabled. + * |[3] |TMR0IEN |Timer0 Interrupt Enable Control + * | | |This field is used to enable TMR0 interrupt enable. + * | | |0 = Timer0 interrupt Disabled. + * | | |1 = Timer0 interrupt Enabled. + * |[4] |TMR1IEN |Timer1 Interrupt Enable Control + * | | |This field is used to enable the TMR1 interrupt. + * | | |0 = Timer1 interrupt Disabled. + * | | |1 = Timer1 interrupt Enabled. + * |[5] |TMR2IEN |Timer2 Interrupt Enable Control + * | | |This field is used for TMR2 interrupt enable. + * | | |0 = Timer2 interrupt Disabled. + * | | |1 = Timer2 interrupt Enabled. + * |[6] |BGTIEN |Block Guard Time Interrupt Enable Control + * | | |This field is used for block guard time interrupt enable. + * | | |0 = Block guard time Disabled. + * | | |1 = Block guard time Enabled. + * |[7] |CDIEN |Card Detect Interrupt Enable Control + * | | |This field is used for card detect interrupt enable. The card detect status is CINSERT(SC_STATUS[12]) + * | | |0 = Card detect interrupt Disabled. + * | | |1 = Card detect interrupt Enabled. + * |[8] |INITIEN |Initial End Interrupt Enable Control + * | | |This field is used for activation (ACTEN(SC_ALTCTL[3] = 1)), deactivation (DACTEN SC_ALTCTL[2] = 1) and warm reset (SC_ALTCTL [WARSTEN]) sequence interrupt enable. + * | | |0 = Initial end interrupt Disabled. + * | | |1 = Initial end interrupt Enabled. + * |[9] |RXTOIF |Receiver Buffer Time-Out Interrupt Enable Control + * | | |This field is used for receiver buffer time-out interrupt enable. + * | | |0 = Receiver buffer time-out interrupt Disabled. + * | | |1 = Receiver buffer time-out interrupt Enabled. + * |[10] |ACERRIEN |Auto Convention Error Interrupt Enable Control + * | | |This field is used for auto-convention error interrupt enable. + * | | |0 = Auto-convention error interrupt Disabled. + * | | |1 = Auto-convention error interrupt Enabled. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x1C SC Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RDAIF |Receive Data Reach Interrupt Status Flag (Read Only) + * | | |This field is used for received data reaching trigger level RXTRGLV (SC_CTL[7:6]) interrupt status flag. + * | | |Note: This field is the status flag of received data reaching RXTRGLV (SC_CTL[7:6]). + * | | |If software reads data from SC_DAT and receiver buffer data byte number is less than RXTRGLV (SC_CTL[7:6]), this bit will be cleared automatically. + * |[1] |TBEIF |Transmit Buffer Empty Interrupt Status Flag (Read Only) + * | | |This field is used for transmit buffer empty interrupt status flag. + * | | |Note: This field is the status flag of transmit buffer empty state. + * | | |If software wants to clear this bit, software must write data to SC_DAT buffer and then this bit will be cleared automatically. + * |[2] |TERRIF |Transfer Error Interrupt Status Flag (Read Only) + * | | |This field is used for transfer error interrupt status flag. + * | | |The transfer error states is at SC_STATUS register which includes receiver break error BEF(SC_STATUS[6]), frame error FEF(SC_STATUS[5], parity error PEF(SC_STATUS[4] and receiver buffer overflow error RXOV(SC_STATUS[0]), transmit buffer overflow error TXOVER(SC_STATUS[8]), receiver retry over limit error RXOVERR(SC_STATUS[22] and transmitter retry over limit error TXOVERR(SC_SC[30]). + * | | |Note: This field is the status flag of BEF(SC_STATUS[6]), FEF(SC_STATUS[5], PEF(SC_STATUS[4], RXOV(SC_STATUS[0]), TXOVER(SC_STATUS[8]), RXOVERR(SC_STATUS[22] or TXOVERR(SC_SC[30]). + * | | |So, if software wants to clear this bit, software must write 1 to each field. + * |[3] |TMR0IF |Timer0 Interrupt Status Flag (Read Only) + * | | |This field is used for TMR0 interrupt status flag. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + * |[4] |TMR1IF |Timer1 Interrupt Status Flag (Read Only) + * | | |This field is used for TMR1 interrupt status flag. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + * |[5] |TMR2IF |Timer2 Interrupt Status Flag (Read Only) + * | | |This field is used for TMR2 interrupt status flag. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + * |[6] |BGTIF |Block Guard Time Interrupt Status Flag (Read Only) + * | | |This field is used for block guard time interrupt status flag. + * | | |Note1: This bit is valid when RXBGTEN (SC_ALTCTL[12]) is enabled. + * | | |Note2: This bit is read only, but it can be cleared by writing "1" to it. + * |[7] |CDIF |Card Detect Interrupt Status Flag (Read Only) + * | | |This field is used for card detect interrupt status flag. + * | | |The card detect status is CINSERT (SC_STATUS[12])] and CREMOVE(SC_STATUS[11]). + * | | |Note: This field is the status flag of CINSERT SC_STATUS[12]) SC_PINCTL[CINSERT] or CREMOVE(SC_STATUS[11])]. + * | | |So if software wants to clear this bit, software must write 1 to this field. + * |[8] |INITIF |Initial End Interrupt Status Flag (Read Only) + * | | |This field is used for activation (ACTEN(SC_ALTCTL[3])), deactivation (DACTEN (SC_ALTCTL[2])) and warm reset (WARSTEN (SC_ALTCTL[4])) sequence interrupt status flag. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + * |[9] |RBTOIF |Receiver Buffer Time-Out Interrupt Status Flag (Read Only) + * | | |This field is used for receiver buffer time-out interrupt status flag. + * | | |Note: This field is the status flag of receiver buffer time-out state. + * | | |If software wants to clear this bit, software must read all receiver buffer remaining data by reading SC_DAT buffer,. + * |[10] |ACERRIF |Auto Convention Error Interrupt Status Flag (Read Only) + * | | |This field indicates auto convention sequence error. + * | | |If the received TS at ATR state is neither 3B nor 3F, this bit will be set. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + */ + __IO uint32_t INTSTS; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x20 SC Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXOV |RX Overflow Error Status Flag (Read Only) + * | | |This bit is set when RX buffer overflow. + * | | |If the number of received bytes is greater than Rx Buffer size (4 bytes), this bit will be set. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + * |[1] |RXEMPTY |Receiver Buffer Empty Status Flag(Read Only) + * | | |This bit indicates RX buffer empty or not. + * | | |When the last byte of Rx buffer has been read by CPU, hardware sets this bit high. + * | | |It will be cleared when SC receives any new data. + * |[2] |RXFULL |Receiver Buffer Full Status Flag (Read Only) + * | | |This bit indicates RX buffer full or not. + * | | |This bit is set when RX pointer is equal to 4, otherwise it is cleared by hardware. + * |[4] |PEF |Receiver Parity Error Status Flag (Read Only) + * | | |This bit is set to logic 1 whenever the received character does not have a valid + * | | |"parity bit". + * | | |Note1: This bit is read only, but it can be cleared by writing 1 to it. + * | | |Note2: If CPU sets receiver retries function by setting RXRTYEN(SC_CTL[19]) , hardware will not set this flag. + * |[5] |FEF |Receiver Frame Error Status Flag (Read Only) + * | | |This bit is set to logic 1 whenever the received character does not have a valid "stop bit" (that is, the stop bit following the last data bit or parity bit is detected as a logic 0). + * | | |Note1: This bit is read only, but it can be cleared by writing 1 to it. + * | | |Note2: If CPU sets receiver retries function by setting RXRTYEN(SC_CTL[19]) , hardware will not set this flag. + * |[6] |BEF |Receiver Break Error Status Flag (Read Only) + * | | |This bit is set to a logic 1 whenever the received data input (RX) held in the "spacing state" (logic 0) is longer than a full word transmission time (that is, the total time of "start bit" + data bits + parity + stop bits). + * | | |. + * | | |Note1: This bit is read only, but it can be cleared by writing 1 to it. + * | | |Note2: If CPU sets receiver retries function by setting RXRTYEN(SC_CTL[19]) , hardware will not set this flag. + * |[8] |TXOV |TX Overflow Error Interrupt Status Flag (Read Only) + * | | |If TX buffer is full, an additional write to SC_DAT will cause this bit be set to "1" by hardware. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + * |[9] |TXEMPTY |Transmit Buffer Empty Status Flag (Read Only) + * | | |This bit indicates TX buffer empty or not. + * | | |When the last byte of TX buffer has been transferred to Transmitter Shift Register, hardware sets this bit high. + * | | |It will be cleared when writing data into SC_DAT (TX buffer not empty). + * |[10] |TXFULL |Transmit Buffer Full Status Flag (Read Only) + * | | |This bit indicates TX buffer full or not. + * | | |This bit is set when TX pointer is equal to 4, otherwise is cleared by hardware. + * |[11] |CREMOVE |Card Detect Removal Status Of SC_CD Pin (Read Only) + * | | |This bit is set whenever card has been removal. + * | | |0 = No effect. + * | | |1 = Card removed. + * | | |Note1: This bit is read only, but it can be cleared by writing "1" to it. + * | | |Note2: Card detect engine will start after SCEN (SC_CTL[0])set. + * |[12] |CINSERT |Card Detect Insert Status Of SC_CD Pin (Read Only) + * | | |This bit is set whenever card has been inserted. + * | | |0 = No effect.1 = Card insert. + * | | |Note1: This bit is read only, but it can be cleared by writing "1" to it. + * | | |Note2: The card detect engine will start after SCEN (SC_CTL[0]) set. + * |[13] |CDPINSTS |Card Detect Status Of SC_CD Pin Status (Read Only) + * | | |This bit is the pin status flag of SC_CD + * | | |0 = The SC_CD pin state at low. + * | | |1 = The SC_CD pin state at high. + * |[16:17] |RXPOINT |Receiver Buffer Pointer Status Flag (Read Only) + * | | |This field indicates the RX buffer pointer status flag. + * | | |When SC receives one byte from external device, RXPOINT(SC_STATUS[17:16]) increases one. + * | | |When one byte of RX buffer is read by CPU, RXPOINT(SC_STATUS[17:16]) decreases one. + * |[21] |RXRERR |Receiver Retry Error (Read Only) + * | | |This bit is set by hardware when RX has any error and retries transfer. + * | | |Note1: This bit is read only, but it can be cleared by writing 1 to it. + * | | |Note2 This bit is a flag and cannot generate any interrupt to CPU. + * | | |Note3: If CPU enables receiver retry function by setting RXRTYEN (SC_CTL[19]) , the PEF(SC_STATUS[4]) flag will be ignored (hardware will not set PEF(SC_STATUS[4])). + * |[22] |RXOVERR |Receiver Over Retry Error (Read Only) + * | | |This bit is set by hardware when RX transfer error retry over retry number limit. + * | | |Note1: This bit is read only, but it can be cleared by writing 1 to it. + * | | |Note2: If CPU enables receiver retries function by setting RXRTYEN (SC_CTL[19]), the PEF(SC_STATUS[4]) flag will be ignored (hardware will not set PEF(SC_STATUS[4])). + * |[23] |RXACT |Receiver In Active Status Flag (Read Only) + * | | |This bit is set by hardware when RX transfer is in active. + * | | |This bit is cleared automatically when RX transfer is finished. + * |[24:25] |TXPOINT |Transmit Buffer Pointer Status Flag (Read Only) + * | | |This field indicates the TX buffer pointer status flag. + * | | |When CPU writes data into SC_DAT, TXPOINT increases one. + * | | |When one byte of TX Buffer is transferred to transmitter shift register, TXPOINT decreases one. + * |[29] |TXRERR |Transmitter Retry Error (Read Only) + * | | |This bit is set by hardware when transmitter re-transmits. + * | | |Note1: This bit is read only, but it can be cleared by writing 1 to it. + * | | |Note2 This bit is a flag and cannot generate any interrupt to CPU. + * |[30] |TXOVERR |Transmitter Over Retry Error (Read Only) + * | | |This bit is set by hardware when transmitter re-transmits over retry number limitation. + * | | |Note: This bit is read only, but it can be cleared by writing 1 to it. + * |[31] |TXACT |Transmit In Active Status Flag (Read Only) + * | | |0 = This bit is cleared automatically when TX transfer is finished or the last byte transmission has completed. + * | | |1 = This bit is set by hardware when TX transfer is in active and the STOP bit of the last byte has been transmitted. + */ + __IO uint32_t STATUS; + + /** + * PINCTL + * =================================================================================================== + * Offset: 0x24 SC Pin Control State Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |PWREN |SC_PWREN Pin Signal + * | | |Software can set PWREN and PWRINV to decide SC_PWR pin is in high or low level. + * | | |Write this field to drive SC_PWR pin + * | | |Refer PWRINV description for programming SC_PWR pin voltage level. + * | | |Read this field to get SC_PWR pin status. + * | | |0 = SC_PWR pin status is low. + * | | |1 = SC_PWR pin status is high. + * | | |Note: When operating at activation, warm reset or deactivation mode, this bit will be changed automatically. + * | | |So don't fill this field when operating in these modes. + * |[1] |SCRST |SCRST Pin Signal + * | | |This bit is the pin status of SCRST but user can drive SCRST pin to high or low by setting this bit. + * | | |Write this field to drive SCRST pin. + * | | |0 = Drive SCRST pin to low. + * | | |1 = Drive SCRST pin to high. + * | | |Read this + * | | |field to get SCRST pin status. + * | | |0 = SCRST pin status is low. + * | | |1 = SCRST pin status is high. + * | | |Note: When operating at activation, warm reset or deactivation mode, this bit will be changed automatically. + * | | |So don't fill this field when operating in these modes. + * |[6] |CLKKEEP |SC Clock Enable Control + * | | |0 = SC clock generation Disabled. + * | | |1 = SC clock always keeps free running. + * | | |Note: When operating in activation, warm reset or deactivation mode, this bit will be changed automatically. + * | | |So don't fill this field when operating in these modes. + * |[9] |SCDOOUT |SC Data Output Pin + * | | |This bit is the pin status of SCDOOUT but user can drive SCDOOUT pin to high or low by setting this bit. + * | | |0 = Drive SCDOOUT pin to low. + * | | |1 = Drive SCDOOUT pin to high. + * | | |Note: When SC is at activation, warm reset or deactivation mode, this bit will be changed automatically. + * | | |So don't fill this field when SC is in these modes. + * |[11] |PWRINV |SC_POW Pin Inverse + * | | |This bit is used for inverse the SC_POW pin. + * | | |There are four kinds of combination for SC_POW pin setting by PWRINV and PWREN(SC_PINCTL[0]). + * | | |PWRINV is bit 1 and PWREN is bit 0 for SC_POW_Pin as high or low voltage selection. + * | | |PWRINV is 0 and PWREN is 0, than SC_POW Pin output 0. + * | | |PWRINV is 0 and PWREN is 1, than SC_POW Pin output 1. + * | | |PWRINV is 1 and PWREN is 0, than SC_POW Pin output 1. + * | | |PWRINV is 1 and PWREN is 1, than SC_POW Pin output 0. + * | | |Note: Software must select PWRINV before Smart Card is enabled by SCEN (SC_CTL[0]). + * |[16] |DATSTS |This bit is the pin status of SC_DAT + * | | |0 = The SC_DAT pin is low. + * | | |1 = The SC_DAT pin is high. + * |[17] |PWRSTS |SC_PWR Pin Signal + * | | |This bit is the pin status of SC_PWR + * | | |0 = SC_PWR pin to low. + * | | |1 = SC_PWR pin to high. + * | | |Note: When SC is operated at activation, warm reset or deactivation mode, this bit will be changed automatically. + * | | |This bit is not allowed to program when SC is operated at these modes. + * |[18] |RSTSTS |SC_RST Pin Signals + * | | |This bit is the pin status of SC_RST + * | | |0 = SC_RST pin is low. + * | | |1 = SC_RST pin is high. + * | | |Note: When SC is operated at activation, warm reset or deactivation mode, this bit will be changed automatically. + * | | |This bit is not allowed to program when SC is operated at these modes. + * |[30] |SYNC |SYNC Flag Indicator + * | | |Due to synchronization, software should check this bit when writing a new value to SC_PINCTL register. + * | | |0 = Synchronizing is completion, user can write new data to SC_PINCTL register. + * | | |1 = Last value is synchronizing. + * | | |Note: This bit is read only. + */ + __IO uint32_t PINCTL; + + /** + * TMRCTL0 + * =================================================================================================== + * Offset: 0x28 SC Internal Timer Control Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |CNT |Timer 0 Counter Value (ETU Base) + * | | |This field indicates the internal timer operation values. + * |[24:27] |OPMODE |Timer 0 Operation Mode Selection + * | | |This field indicates the internal 24-bit timer operation selection. + * | | |Refer to 6.25.4.4 for programming Timer0. + */ + __IO uint32_t TMRCTL0; + + /** + * TMRCTL1 + * =================================================================================================== + * Offset: 0x2C SC Internal Timer Control Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |CNT |Timer 1 Counter Value (ETU Base) + * | | |This field indicates the internal timer operation values. + * |[24:27] |OPMODE |Timer 1 Operation Mode Selection + * | | |This field indicates the internal 8-bit timer operation selection. + * | | |Refer to 6.25.4.4 for programming Timer1. + */ + __IO uint32_t TMRCTL1; + + /** + * TMRCTL2 + * =================================================================================================== + * Offset: 0x30 SC Internal Timer Control Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |CNT |Timer 2 Counter Value (ETU Base) + * | | |This field indicates the internal timer operation values. + * |[24:27] |OPMODE |Timer 2 Operation Mode Selection + * | | |This field indicates the internal 8-bit timer operation selection + * | | |Refer to 6.25.4.4 for programming Timer2 + */ + __IO uint32_t TMRCTL2; + + /** + * UARTCTL + * =================================================================================================== + * Offset: 0x34 SC UART Mode Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |UARTEN |UART Mode Enable Control + * | | |0 = Smart Card mode. + * | | |1 = UART mode. + * | | |Note1: When operating in UART mode, user must set CONSEL (SC_CTL[5:4]) = 00 and AUTOCEN(SC_CTL[3]) = 0. + * | | |Note2: When operating in Smart Card mode, user must set SC_UARTCTL [7:0] = 00. + * | | |Note3: When UART is enabled, hardware will generate a reset to resetFIFO and internal state machine. + * |[4:5] |WLS |Data Length + * | | |00 = Character Data Length is 8 bits. + * | | |01 = Character Data Length is 7 bits. + * | | |10 = Character Data length is 6 bits. + * | | |11 = Character Data Length is 5 bits. + * | | |Note: In smart card mode, this WLS must be '00' + * |[6] |PBOFF |Parity Bit Disable Control + * | | |0 = Parity bit is generated or checked between the "last data word bit" and "stop bit" of the serial data. + * | | |1 = Parity bit is not generated (transmitting data) or checked (receiving data) during transfer. + * | | |Note: In smart card mode, this field must be '0' (default setting is with parity bit) + * |[7] |OPE |Odd Parity Enable Control + * | | |0 = Even number of logic 1's are transmitted or check the data word and parity bits in receiving mode. + * | | |1 = Odd number of logic 1's are transmitted or check the data word and parity bits in receiving mode. + * | | |Note: This bit has effect only when PBOFF bit is '0'. + */ + __IO uint32_t UARTCTL; + + /** + * TMRDAT0 + * =================================================================================================== + * Offset: 0x38 SC Timer 0 Current Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |CNT0 |Timer0 Current Counter Value (Read Only) + * | | |This field indicates the current count values of timer0. + */ + __I uint32_t TMRDAT0; + + /** + * TMRDAT1_2 + * =================================================================================================== + * Offset: 0x3C SC Timer 1 and 2 Current Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |CNT1 |Timer1 Current Counter Value (Read Only) + * | | |This field indicates the current count values of timer1. + * |[8:15] |CNT2 |Timer2 Current Counter Value (Read Only) + * | | |This field indicates the current count values of timer2. + */ + __I uint32_t TMRDAT1_2; + +} SC_T; + +/** + @addtogroup SC_CONST SC Bit Field Definition + Constant Definitions for SC Controller +@{ */ + +#define SC_DAT_DAT_Pos (0) /*!< SC_T::DAT: DAT Position */ +#define SC_DAT_DAT_Msk (0xfful << SC_DAT_DAT_Pos) /*!< SC_T::DAT: DAT Mask */ + +#define SC_CTL_SCEN_Pos (0) /*!< SC_T::CTL: SCEN Position */ +#define SC_CTL_SCEN_Msk (0x1ul << SC_CTL_SCEN_Pos) /*!< SC_T::CTL: SCEN Mask */ + +#define SC_CTL_RXOFF_Pos (1) /*!< SC_T::CTL: RXOFF Position */ +#define SC_CTL_RXOFF_Msk (0x1ul << SC_CTL_RXOFF_Pos) /*!< SC_T::CTL: RXOFF Mask */ + +#define SC_CTL_TXOFF_Pos (2) /*!< SC_T::CTL: TXOFF Position */ +#define SC_CTL_TXOFF_Msk (0x1ul << SC_CTL_TXOFF_Pos) /*!< SC_T::CTL: TXOFF Mask */ + +#define SC_CTL_AUTOCEN_Pos (3) /*!< SC_T::CTL: AUTOCEN Position */ +#define SC_CTL_AUTOCEN_Msk (0x1ul << SC_CTL_AUTOCEN_Pos) /*!< SC_T::CTL: AUTOCEN Mask */ + +#define SC_CTL_CONSEL_Pos (4) /*!< SC_T::CTL: CONSEL Position */ +#define SC_CTL_CONSEL_Msk (0x3ul << SC_CTL_CONSEL_Pos) /*!< SC_T::CTL: CONSEL Mask */ + +#define SC_CTL_RXTRGLV_Pos (6) /*!< SC_T::CTL: RXTRGLV Position */ +#define SC_CTL_RXTRGLV_Msk (0x3ul << SC_CTL_RXTRGLV_Pos) /*!< SC_T::CTL: RXTRGLV Mask */ + +#define SC_CTL_BGT_Pos (8) /*!< SC_T::CTL: BGT Position */ +#define SC_CTL_BGT_Msk (0x1ful << SC_CTL_BGT_Pos) /*!< SC_T::CTL: BGT Mask */ + +#define SC_CTL_TMRSEL_Pos (13) /*!< SC_T::CTL: TMRSEL Position */ +#define SC_CTL_TMRSEL_Msk (0x3ul << SC_CTL_TMRSEL_Pos) /*!< SC_T::CTL: TMRSEL Mask */ + +#define SC_CTL_NSB_Pos (15) /*!< SC_T::CTL: NSB Position */ +#define SC_CTL_NSB_Msk (0x1ul << SC_CTL_NSB_Pos) /*!< SC_T::CTL: NSB Mask */ + +#define SC_CTL_RXRTY_Pos (16) /*!< SC_T::CTL: RXRTY Position */ +#define SC_CTL_RXRTY_Msk (0x7ul << SC_CTL_RXRTY_Pos) /*!< SC_T::CTL: RXRTY Mask */ + +#define SC_CTL_RXRTYEN_Pos (19) /*!< SC_T::CTL: RXRTYEN Position */ +#define SC_CTL_RXRTYEN_Msk (0x1ul << SC_CTL_RXRTYEN_Pos) /*!< SC_T::CTL: RXRTYEN Mask */ + +#define SC_CTL_TXRTY_Pos (20) /*!< SC_T::CTL: TXRTY Position */ +#define SC_CTL_TXRTY_Msk (0x7ul << SC_CTL_TXRTY_Pos) /*!< SC_T::CTL: TXRTY Mask */ + +#define SC_CTL_TXRTYEN_Pos (23) /*!< SC_T::CTL: TXRTYEN Position */ +#define SC_CTL_TXRTYEN_Msk (0x1ul << SC_CTL_TXRTYEN_Pos) /*!< SC_T::CTL: TXRTYEN Mask */ + +#define SC_CTL_CDDBSEL_Pos (24) /*!< SC_T::CTL: CDDBSEL Position */ +#define SC_CTL_CDDBSEL_Msk (0x3ul << SC_CTL_CDDBSEL_Pos) /*!< SC_T::CTL: CDDBSEL Mask */ + +#define SC_CTL_CDLV_Pos (26) /*!< SC_T::CTL: CDLV Position */ +#define SC_CTL_CDLV_Msk (0x1ul << SC_CTL_CDLV_Pos) /*!< SC_T::CTL: CDLV Mask */ + +#define SC_CTL_SYNC_Pos (30) /*!< SC_T::CTL: SYNC Position */ +#define SC_CTL_SYNC_Msk (0x1ul << SC_CTL_SYNC_Pos) /*!< SC_T::CTL: SYNC Mask */ + +#define SC_ALTCTL_TXRST_Pos (0) /*!< SC_T::ALTCTL: TXRST Position */ +#define SC_ALTCTL_TXRST_Msk (0x1ul << SC_ALTCTL_TXRST_Pos) /*!< SC_T::ALTCTL: TXRST Mask */ + +#define SC_ALTCTL_RXRST_Pos (1) /*!< SC_T::ALTCTL: RXRST Position */ +#define SC_ALTCTL_RXRST_Msk (0x1ul << SC_ALTCTL_RXRST_Pos) /*!< SC_T::ALTCTL: RXRST Mask */ + +#define SC_ALTCTL_DACTEN_Pos (2) /*!< SC_T::ALTCTL: DACTEN Position */ +#define SC_ALTCTL_DACTEN_Msk (0x1ul << SC_ALTCTL_DACTEN_Pos) /*!< SC_T::ALTCTL: DACTEN Mask */ + +#define SC_ALTCTL_ACTEN_Pos (3) /*!< SC_T::ALTCTL: ACTEN Position */ +#define SC_ALTCTL_ACTEN_Msk (0x1ul << SC_ALTCTL_ACTEN_Pos) /*!< SC_T::ALTCTL: ACTEN Mask */ + +#define SC_ALTCTL_WARSTEN_Pos (4) /*!< SC_T::ALTCTL: WARSTEN Position */ +#define SC_ALTCTL_WARSTEN_Msk (0x1ul << SC_ALTCTL_WARSTEN_Pos) /*!< SC_T::ALTCTL: WARSTEN Mask */ + +#define SC_ALTCTL_CNTEN0_Pos (5) /*!< SC_T::ALTCTL: CNTEN0 Position */ +#define SC_ALTCTL_CNTEN0_Msk (0x1ul << SC_ALTCTL_CNTEN0_Pos) /*!< SC_T::ALTCTL: CNTEN0 Mask */ + +#define SC_ALTCTL_CNTEN1_Pos (6) /*!< SC_T::ALTCTL: CNTEN1 Position */ +#define SC_ALTCTL_CNTEN1_Msk (0x1ul << SC_ALTCTL_CNTEN1_Pos) /*!< SC_T::ALTCTL: CNTEN1 Mask */ + +#define SC_ALTCTL_CNTEN2_Pos (7) /*!< SC_T::ALTCTL: CNTEN2 Position */ +#define SC_ALTCTL_CNTEN2_Msk (0x1ul << SC_ALTCTL_CNTEN2_Pos) /*!< SC_T::ALTCTL: CNTEN2 Mask */ + +#define SC_ALTCTL_INITSEL_Pos (8) /*!< SC_T::ALTCTL: INITSEL Position */ +#define SC_ALTCTL_INITSEL_Msk (0x3ul << SC_ALTCTL_INITSEL_Pos) /*!< SC_T::ALTCTL: INITSEL Mask */ + +#define SC_ALTCTL_ADACEN_Pos (11) /*!< SC_T::ALTCTL: ADACEN Position */ +#define SC_ALTCTL_ADACEN_Msk (0x1ul << SC_ALTCTL_ADACEN_Pos) /*!< SC_T::ALTCTL: ADACEN Mask */ + +#define SC_ALTCTL_RXBGTEN_Pos (12) /*!< SC_T::ALTCTL: RXBGTEN Position */ +#define SC_ALTCTL_RXBGTEN_Msk (0x1ul << SC_ALTCTL_RXBGTEN_Pos) /*!< SC_T::ALTCTL: RXBGTEN Mask */ + +#define SC_ALTCTL_ACTSTS0_Pos (13) /*!< SC_T::ALTCTL: ACTSTS0 Position */ +#define SC_ALTCTL_ACTSTS0_Msk (0x1ul << SC_ALTCTL_ACTSTS0_Pos) /*!< SC_T::ALTCTL: ACTSTS0 Mask */ + +#define SC_ALTCTL_ACTSTS1_Pos (14) /*!< SC_T::ALTCTL: ACTSTS1 Position */ +#define SC_ALTCTL_ACTSTS1_Msk (0x1ul << SC_ALTCTL_ACTSTS1_Pos) /*!< SC_T::ALTCTL: ACTSTS1 Mask */ + +#define SC_ALTCTL_ACTSTS2_Pos (15) /*!< SC_T::ALTCTL: ACTSTS2 Position */ +#define SC_ALTCTL_ACTSTS2_Msk (0x1ul << SC_ALTCTL_ACTSTS2_Pos) /*!< SC_T::ALTCTL: ACTSTS2 Mask */ + +#define SC_EGT_EGT_Pos (0) /*!< SC_T::EGT: EGT Position */ +#define SC_EGT_EGT_Msk (0xfful << SC_EGT_EGT_Pos) /*!< SC_T::EGT: EGT Mask */ + +#define SC_RXTOUT_RFTM_Pos (0) /*!< SC_T::RXTOUT: RFTM Position */ +#define SC_RXTOUT_RFTM_Msk (0x1fful << SC_RXTOUT_RFTM_Pos) /*!< SC_T::RXTOUT: RFTM Mask */ + +#define SC_ETUCTL_ETURDIV_Pos (0) /*!< SC_T::ETUCTL: ETURDIV Position */ +#define SC_ETUCTL_ETURDIV_Msk (0xffful << SC_ETUCTL_ETURDIV_Pos) /*!< SC_T::ETUCTL: ETURDIV Mask */ + +#define SC_ETUCTL_CMPEN_Pos (15) /*!< SC_T::ETUCTL: CMPEN Position */ +#define SC_ETUCTL_CMPEN_Msk (0x1ul << SC_ETUCTL_CMPEN_Pos) /*!< SC_T::ETUCTL: CMPEN Mask */ + +#define SC_INTEN_RDAIEN_Pos (0) /*!< SC_T::INTEN: RDAIEN Position */ +#define SC_INTEN_RDAIEN_Msk (0x1ul << SC_INTEN_RDAIEN_Pos) /*!< SC_T::INTEN: RDAIEN Mask */ + +#define SC_INTEN_TBEIEN_Pos (1) /*!< SC_T::INTEN: TBEIEN Position */ +#define SC_INTEN_TBEIEN_Msk (0x1ul << SC_INTEN_TBEIEN_Pos) /*!< SC_T::INTEN: TBEIEN Mask */ + +#define SC_INTEN_TERRIEN_Pos (2) /*!< SC_T::INTEN: TERRIEN Position */ +#define SC_INTEN_TERRIEN_Msk (0x1ul << SC_INTEN_TERRIEN_Pos) /*!< SC_T::INTEN: TERRIEN Mask */ + +#define SC_INTEN_TMR0IEN_Pos (3) /*!< SC_T::INTEN: TMR0IEN Position */ +#define SC_INTEN_TMR0IEN_Msk (0x1ul << SC_INTEN_TMR0IEN_Pos) /*!< SC_T::INTEN: TMR0IEN Mask */ + +#define SC_INTEN_TMR1IEN_Pos (4) /*!< SC_T::INTEN: TMR1IEN Position */ +#define SC_INTEN_TMR1IEN_Msk (0x1ul << SC_INTEN_TMR1IEN_Pos) /*!< SC_T::INTEN: TMR1IEN Mask */ + +#define SC_INTEN_TMR2IEN_Pos (5) /*!< SC_T::INTEN: TMR2IEN Position */ +#define SC_INTEN_TMR2IEN_Msk (0x1ul << SC_INTEN_TMR2IEN_Pos) /*!< SC_T::INTEN: TMR2IEN Mask */ + +#define SC_INTEN_BGTIEN_Pos (6) /*!< SC_T::INTEN: BGTIEN Position */ +#define SC_INTEN_BGTIEN_Msk (0x1ul << SC_INTEN_BGTIEN_Pos) /*!< SC_T::INTEN: BGTIEN Mask */ + +#define SC_INTEN_CDIEN_Pos (7) /*!< SC_T::INTEN: CDIEN Position */ +#define SC_INTEN_CDIEN_Msk (0x1ul << SC_INTEN_CDIEN_Pos) /*!< SC_T::INTEN: CDIEN Mask */ + +#define SC_INTEN_INITIEN_Pos (8) /*!< SC_T::INTEN: INITIEN Position */ +#define SC_INTEN_INITIEN_Msk (0x1ul << SC_INTEN_INITIEN_Pos) /*!< SC_T::INTEN: INITIEN Mask */ + +#define SC_INTEN_RXTOIF_Pos (9) /*!< SC_T::INTEN: RXTOIF Position */ +#define SC_INTEN_RXTOIF_Msk (0x1ul << SC_INTEN_RXTOIF_Pos) /*!< SC_T::INTEN: RXTOIF Mask */ + +#define SC_INTEN_ACERRIEN_Pos (10) /*!< SC_T::INTEN: ACERRIEN Position */ +#define SC_INTEN_ACERRIEN_Msk (0x1ul << SC_INTEN_ACERRIEN_Pos) /*!< SC_T::INTEN: ACERRIEN Mask */ + +#define SC_INTSTS_RDAIF_Pos (0) /*!< SC_T::INTSTS: RDAIF Position */ +#define SC_INTSTS_RDAIF_Msk (0x1ul << SC_INTSTS_RDAIF_Pos) /*!< SC_T::INTSTS: RDAIF Mask */ + +#define SC_INTSTS_TBEIF_Pos (1) /*!< SC_T::INTSTS: TBEIF Position */ +#define SC_INTSTS_TBEIF_Msk (0x1ul << SC_INTSTS_TBEIF_Pos) /*!< SC_T::INTSTS: TBEIF Mask */ + +#define SC_INTSTS_TERRIF_Pos (2) /*!< SC_T::INTSTS: TERRIF Position */ +#define SC_INTSTS_TERRIF_Msk (0x1ul << SC_INTSTS_TERRIF_Pos) /*!< SC_T::INTSTS: TERRIF Mask */ + +#define SC_INTSTS_TMR0IF_Pos (3) /*!< SC_T::INTSTS: TMR0IF Position */ +#define SC_INTSTS_TMR0IF_Msk (0x1ul << SC_INTSTS_TMR0IF_Pos) /*!< SC_T::INTSTS: TMR0IF Mask */ + +#define SC_INTSTS_TMR1IF_Pos (4) /*!< SC_T::INTSTS: TMR1IF Position */ +#define SC_INTSTS_TMR1IF_Msk (0x1ul << SC_INTSTS_TMR1IF_Pos) /*!< SC_T::INTSTS: TMR1IF Mask */ + +#define SC_INTSTS_TMR2IF_Pos (5) /*!< SC_T::INTSTS: TMR2IF Position */ +#define SC_INTSTS_TMR2IF_Msk (0x1ul << SC_INTSTS_TMR2IF_Pos) /*!< SC_T::INTSTS: TMR2IF Mask */ + +#define SC_INTSTS_BGTIF_Pos (6) /*!< SC_T::INTSTS: BGTIF Position */ +#define SC_INTSTS_BGTIF_Msk (0x1ul << SC_INTSTS_BGTIF_Pos) /*!< SC_T::INTSTS: BGTIF Mask */ + +#define SC_INTSTS_CDIF_Pos (7) /*!< SC_T::INTSTS: CDIF Position */ +#define SC_INTSTS_CDIF_Msk (0x1ul << SC_INTSTS_CDIF_Pos) /*!< SC_T::INTSTS: CDIF Mask */ + +#define SC_INTSTS_INITIF_Pos (8) /*!< SC_T::INTSTS: INITIF Position */ +#define SC_INTSTS_INITIF_Msk (0x1ul << SC_INTSTS_INITIF_Pos) /*!< SC_T::INTSTS: INITIF Mask */ + +#define SC_INTSTS_RBTOIF_Pos (9) /*!< SC_T::INTSTS: RBTOIF Position */ +#define SC_INTSTS_RBTOIF_Msk (0x1ul << SC_INTSTS_RBTOIF_Pos) /*!< SC_T::INTSTS: RBTOIF Mask */ + +#define SC_INTSTS_ACERRIF_Pos (10) /*!< SC_T::INTSTS: ACERRIF Position */ +#define SC_INTSTS_ACERRIF_Msk (0x1ul << SC_INTSTS_ACERRIF_Pos) /*!< SC_T::INTSTS: ACERRIF Mask */ + +#define SC_STATUS_RXOV_Pos (0) /*!< SC_T::STATUS: RXOV Position */ +#define SC_STATUS_RXOV_Msk (0x1ul << SC_STATUS_RXOV_Pos) /*!< SC_T::STATUS: RXOV Mask */ + +#define SC_STATUS_RXEMPTY_Pos (1) /*!< SC_T::STATUS: RXEMPTY Position */ +#define SC_STATUS_RXEMPTY_Msk (0x1ul << SC_STATUS_RXEMPTY_Pos) /*!< SC_T::STATUS: RXEMPTY Mask */ + +#define SC_STATUS_RXFULL_Pos (2) /*!< SC_T::STATUS: RXFULL Position */ +#define SC_STATUS_RXFULL_Msk (0x1ul << SC_STATUS_RXFULL_Pos) /*!< SC_T::STATUS: RXFULL Mask */ + +#define SC_STATUS_PEF_Pos (4) /*!< SC_T::STATUS: PEF Position */ +#define SC_STATUS_PEF_Msk (0x1ul << SC_STATUS_PEF_Pos) /*!< SC_T::STATUS: PEF Mask */ + +#define SC_STATUS_FEF_Pos (5) /*!< SC_T::STATUS: FEF Position */ +#define SC_STATUS_FEF_Msk (0x1ul << SC_STATUS_FEF_Pos) /*!< SC_T::STATUS: FEF Mask */ + +#define SC_STATUS_BEF_Pos (6) /*!< SC_T::STATUS: BEF Position */ +#define SC_STATUS_BEF_Msk (0x1ul << SC_STATUS_BEF_Pos) /*!< SC_T::STATUS: BEF Mask */ + +#define SC_STATUS_TXOV_Pos (8) /*!< SC_T::STATUS: TXOV Position */ +#define SC_STATUS_TXOV_Msk (0x1ul << SC_STATUS_TXOV_Pos) /*!< SC_T::STATUS: TXOV Mask */ + +#define SC_STATUS_TXEMPTY_Pos (9) /*!< SC_T::STATUS: TXEMPTY Position */ +#define SC_STATUS_TXEMPTY_Msk (0x1ul << SC_STATUS_TXEMPTY_Pos) /*!< SC_T::STATUS: TXEMPTY Mask */ + +#define SC_STATUS_TXFULL_Pos (10) /*!< SC_T::STATUS: TXFULL Position */ +#define SC_STATUS_TXFULL_Msk (0x1ul << SC_STATUS_TXFULL_Pos) /*!< SC_T::STATUS: TXFULL Mask */ + +#define SC_STATUS_CREMOVE_Pos (11) /*!< SC_T::STATUS: CREMOVE Position */ +#define SC_STATUS_CREMOVE_Msk (0x1ul << SC_STATUS_CREMOVE_Pos) /*!< SC_T::STATUS: CREMOVE Mask */ + +#define SC_STATUS_CINSERT_Pos (12) /*!< SC_T::STATUS: CINSERT Position */ +#define SC_STATUS_CINSERT_Msk (0x1ul << SC_STATUS_CINSERT_Pos) /*!< SC_T::STATUS: CINSERT Mask */ + +#define SC_STATUS_CDPINSTS_Pos (13) /*!< SC_T::STATUS: CDPINSTS Position */ +#define SC_STATUS_CDPINSTS_Msk (0x1ul << SC_STATUS_CDPINSTS_Pos) /*!< SC_T::STATUS: CDPINSTS Mask */ + +#define SC_STATUS_RXPOINT_Pos (16) /*!< SC_T::STATUS: RXPOINT Position */ +#define SC_STATUS_RXPOINT_Msk (0x3ul << SC_STATUS_RXPOINT_Pos) /*!< SC_T::STATUS: RXPOINT Mask */ + +#define SC_STATUS_RXRERR_Pos (21) /*!< SC_T::STATUS: RXRERR Position */ +#define SC_STATUS_RXRERR_Msk (0x1ul << SC_STATUS_RXRERR_Pos) /*!< SC_T::STATUS: RXRERR Mask */ + +#define SC_STATUS_RXOVERR_Pos (22) /*!< SC_T::STATUS: RXOVERR Position */ +#define SC_STATUS_RXOVERR_Msk (0x1ul << SC_STATUS_RXOVERR_Pos) /*!< SC_T::STATUS: RXOVERR Mask */ + +#define SC_STATUS_RXACT_Pos (23) /*!< SC_T::STATUS: RXACT Position */ +#define SC_STATUS_RXACT_Msk (0x1ul << SC_STATUS_RXACT_Pos) /*!< SC_T::STATUS: RXACT Mask */ + +#define SC_STATUS_TXPOINT_Pos (24) /*!< SC_T::STATUS: TXPOINT Position */ +#define SC_STATUS_TXPOINT_Msk (0x3ul << SC_STATUS_TXPOINT_Pos) /*!< SC_T::STATUS: TXPOINT Mask */ + +#define SC_STATUS_TXRERR_Pos (29) /*!< SC_T::STATUS: TXRERR Position */ +#define SC_STATUS_TXRERR_Msk (0x1ul << SC_STATUS_TXRERR_Pos) /*!< SC_T::STATUS: TXRERR Mask */ + +#define SC_STATUS_TXOVERR_Pos (30) /*!< SC_T::STATUS: TXOVERR Position */ +#define SC_STATUS_TXOVERR_Msk (0x1ul << SC_STATUS_TXOVERR_Pos) /*!< SC_T::STATUS: TXOVERR Mask */ + +#define SC_STATUS_TXACT_Pos (31) /*!< SC_T::STATUS: TXACT Position */ +#define SC_STATUS_TXACT_Msk (0x1ul << SC_STATUS_TXACT_Pos) /*!< SC_T::STATUS: TXACT Mask */ + +#define SC_PINCTL_PWREN_Pos (0) /*!< SC_T::PINCTL: PWREN Position */ +#define SC_PINCTL_PWREN_Msk (0x1ul << SC_PINCTL_PWREN_Pos) /*!< SC_T::PINCTL: PWREN Mask */ + +#define SC_PINCTL_SCRST_Pos (1) /*!< SC_T::PINCTL: SCRST Position */ +#define SC_PINCTL_SCRST_Msk (0x1ul << SC_PINCTL_SCRST_Pos) /*!< SC_T::PINCTL: SCRST Mask */ + +#define SC_PINCTL_CLKKEEP_Pos (6) /*!< SC_T::PINCTL: CLKKEEP Position */ +#define SC_PINCTL_CLKKEEP_Msk (0x1ul << SC_PINCTL_CLKKEEP_Pos) /*!< SC_T::PINCTL: CLKKEEP Mask */ + +#define SC_PINCTL_SCDOUT_Pos (9) /*!< SC_T::PINCTL: SCDOUT Position */ +#define SC_PINCTL_SCDOUT_Msk (0x1ul << SC_PINCTL_SCDOUT_Pos) /*!< SC_T::PINCTL: SCDOUT Mask */ + +#define SC_PINCTL_PWRINV_Pos (11) /*!< SC_T::PINCTL: PWRINV Position */ +#define SC_PINCTL_PWRINV_Msk (0x1ul << SC_PINCTL_PWRINV_Pos) /*!< SC_T::PINCTL: PWRINV Mask */ + +#define SC_PINCTL_DATSTS_Pos (16) /*!< SC_T::PINCTL: DATSTS Position */ +#define SC_PINCTL_DATSTS_Msk (0x1ul << SC_PINCTL_DATSTS_Pos) /*!< SC_T::PINCTL: DATSTS Mask */ + +#define SC_PINCTL_PWRSTS_Pos (17) /*!< SC_T::PINCTL: PWRSTS Position */ +#define SC_PINCTL_PWRSTS_Msk (0x1ul << SC_PINCTL_PWRSTS_Pos) /*!< SC_T::PINCTL: PWRSTS Mask */ + +#define SC_PINCTL_RSTSTS_Pos (18) /*!< SC_T::PINCTL: RSTSTS Position */ +#define SC_PINCTL_RSTSTS_Msk (0x1ul << SC_PINCTL_RSTSTS_Pos) /*!< SC_T::PINCTL: RSTSTS Mask */ + +#define SC_PINCTL_SYNC_Pos (30) /*!< SC_T::PINCTL: SYNC Position */ +#define SC_PINCTL_SYNC_Msk (0x1ul << SC_PINCTL_SYNC_Pos) /*!< SC_T::PINCTL: SYNC Mask */ + +#define SC_TMRCTL0_CNT_Pos (0) /*!< SC_T::TMRCTL0: CNT Position */ +#define SC_TMRCTL0_CNT_Msk (0xfffffful << SC_TMRCTL0_CNT_Pos) /*!< SC_T::TMRCTL0: CNT Mask */ + +#define SC_TMRCTL0_OPMODE_Pos (24) /*!< SC_T::TMRCTL0: OPMODE Position */ +#define SC_TMRCTL0_OPMODE_Msk (0xful << SC_TMRCTL0_OPMODE_Pos) /*!< SC_T::TMRCTL0: OPMODE Mask */ + +#define SC_TMRCTL1_CNT_Pos (0) /*!< SC_T::TMRCTL1: CNT Position */ +#define SC_TMRCTL1_CNT_Msk (0xfful << SC_TMRCTL1_CNT_Pos) /*!< SC_T::TMRCTL1: CNT Mask */ + +#define SC_TMRCTL1_OPMODE_Pos (24) /*!< SC_T::TMRCTL1: OPMODE Position */ +#define SC_TMRCTL1_OPMODE_Msk (0xful << SC_TMRCTL1_OPMODE_Pos) /*!< SC_T::TMRCTL1: OPMODE Mask */ + +#define SC_TMRCTL2_CNT_Pos (0) /*!< SC_T::TMRCTL2: CNT Position */ +#define SC_TMRCTL2_CNT_Msk (0xfful << SC_TMRCTL2_CNT_Pos) /*!< SC_T::TMRCTL2: CNT Mask */ + +#define SC_TMRCTL2_OPMODE_Pos (24) /*!< SC_T::TMRCTL2: OPMODE Position */ +#define SC_TMRCTL2_OPMODE_Msk (0xful << SC_TMRCTL2_OPMODE_Pos) /*!< SC_T::TMRCTL2: OPMODE Mask */ + +#define SC_UARTCTL_UARTEN_Pos (0) /*!< SC_T::UARTCTL: UARTEN Position */ +#define SC_UARTCTL_UARTEN_Msk (0x1ul << SC_UARTCTL_UARTEN_Pos) /*!< SC_T::UARTCTL: UARTEN Mask */ + +#define SC_UARTCTL_WLS_Pos (4) /*!< SC_T::UARTCTL: WLS Position */ +#define SC_UARTCTL_WLS_Msk (0x3ul << SC_UARTCTL_WLS_Pos) /*!< SC_T::UARTCTL: WLS Mask */ + +#define SC_UARTCTL_PBOFF_Pos (6) /*!< SC_T::UARTCTL: PBOFF Position */ +#define SC_UARTCTL_PBOFF_Msk (0x1ul << SC_UARTCTL_PBOFF_Pos) /*!< SC_T::UARTCTL: PBOFF Mask */ + +#define SC_UARTCTL_OPE_Pos (7) /*!< SC_T::UARTCTL: OPE Position */ +#define SC_UARTCTL_OPE_Msk (0x1ul << SC_UARTCTL_OPE_Pos) /*!< SC_T::UARTCTL: OPE Mask */ + +#define SC_TMRDAT0_TDR0_Pos (0) /*!< SC_T::TMRDAT0: TDR0 Position */ +#define SC_TMRDAT0_TDR0_Msk (0xfffffful << SC_TMRDAT0_TDR0_Pos) /*!< SC_T::TMRDAT0: TDR0 Mask */ + +#define SC_TMRDAT1_2_TDR1_Pos (0) /*!< SC_T::TMRDAT1_2: TDR1 Position */ +#define SC_TMRDAT1_2_TDR1_Msk (0xfful << SC_TMRDAT1_2_TDR1_Pos) /*!< SC_T::TMRDAT1_2: TDR1 Mask */ + +#define SC_TMRDAT1_2_TDR2_Pos (8) /*!< SC_T::TMRDAT1_2: TDR2 Position */ +#define SC_TMRDAT1_2_TDR2_Msk (0xfful << SC_TMRDAT1_2_TDR2_Pos) /*!< SC_T::TMRDAT1_2: TDR2 Mask */ + +/**@}*/ /* SC_CONST */ +/**@}*/ /* end of SC register group */ + + +/*---------------------- SD Card Host Interface -------------------------*/ +/** + @addtogroup SDH SD Card Host Interface(SDH) + Memory Mapped Structure for SDH Controller +@{ */ + +typedef struct { + + /** + * FBx + * =================================================================================================== + * Offset: 0x00 ~ 0x7C Shared Buffer (FIFO) 0 ~ 31 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |BUF |Shared Buffer + + */ + uint32_t FB[32]; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[224]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * DMACTL + * =================================================================================================== + * Offset: 0x400 DMA Control and Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DMAEN |DMA Engine Enable Control + * | | |0 = DMA Disabled. + * | | |1 = DMA Enabled. + * | | |If this bit is cleared, DMA will ignore all requests from SD host and force bus master into IDLE state. + * | | |Note: If target abort is occurred, DMAEN will be cleared. + * |[1] |DMARST |Software Engine Reset + * | | |0 = No effect. + * | | |1 = Reset internal state machine and pointers. + * | | |The contents of control register will not be cleared. + * | | |This bit will auto be cleared after few clock cycles. + * | | |Note: The software reset DMA related registers. + * |[3] |SGEN |Scatter-Gather Function Enable Control + * | | |0 = Scatter-gather function Disabled (DMA will treat the starting address in DMASAR as starting pointer of a single block memory). + * | | |1 = Scatter-gather function Enabled (DMA will treat the starting address in DMASAR as a starting address of Physical Address Descriptor (PAD) table. + * | | |The format of these Pads' will be described later). + * |[9] |DMABUSY |DMA Transfer Is In Progress + * | | |This bit indicates if SD Host is granted and doing DMA transfer or not. + * | | |0 = DMA transfer is not in progress. + * | | |1 = DMA transfer is in progress. + */ + __IO uint32_t DMACTL; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * DMASA + * =================================================================================================== + * Offset: 0x408 DMA Transfer Starting Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ORDER |Determined To The PAD Table Fetching Is In Order Or Out Of Order + * | | |0 = PAD table is fetched in order. + * | | |1 = PAD table is fetched out of order. + * | | |Note: the bit0 is valid in scatter-gather mode when SGEN = 1. + * |[1:31] |DMASA |DMA Transfer Starting Address + * | | |This field pads 0 as least significant bit indicates a 32-bit starting address of system memory (SRAM) for DMA to retrieve or fill in data. + * | | |If DMA is not in normal mode, this field will be interpreted as a starting address of Physical Address Descriptor (PAD) table. + */ + __IO uint32_t DMASA; + + /** + * DMABCNT + * =================================================================================================== + * Offset: 0x40C DMA Transfer Byte Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:25] |BCNT |DMA Transfer Byte Count (Read Only) + * | | |This field indicates the remained byte count of DMA transfer. + * | | |The value of this field is valid only when DMA is busy; otherwise, it is 0. + */ + __I uint32_t DMABCNT; + + /** + * DMAINTEN + * =================================================================================================== + * Offset: 0x410 DMA Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ABORTIEN |DMA Read/Write Target Abort Interrupt Enable Control + * | | |0 = Target abort interrupt generation Disabled during DMA transfer. + * | | |1 = Target abort interrupt generation Enabled during DMA transfer. + * |[1] |WEOTIEN |Wrong EOT Encountered Interrupt Enable Control + * | | |0 = Interrupt generation Disabled when wrong EOT is encountered. + * | | |1 = Interrupt generation Enabled when wrong EOT is encountered. + */ + __IO uint32_t DMAINTEN; + + /** + * DMAINTSTS + * =================================================================================================== + * Offset: 0x414 DMA Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |ABORTIF |DMA Read/Write Target Abort Interrupt Flag + * | | |0 = No bus ERROR response received. + * | | |1 = Bus ERROR response received. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + * |[1] |WEOTIF |Wrong EOT Encountered Interrupt Flag + * | | |When DMA Scatter-Gather function is enabled, and EOT of the descriptor is encountered before DMA transfer finished (that means the total sector count of all PAD is less than the sector count of SD host), this bit will be set. + * | | |0 = No EOT encountered before DMA transfer finished. + * | | |1 = EOT encountered before DMA transfer finished. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + */ + __IO uint32_t DMAINTSTS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[250]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * GCTL + * =================================================================================================== + * Offset: 0x800 Global Control and Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |GCTLRST |Software Engine Reset + * | | |0 = No effect. + * | | |1 = Reset SD host. + * | | |The contents of control register will not be cleared. + * | | |This bit will auto cleared after reset complete. + * |[1] |SDEN |Secure Digital Functionality Enable Control + * | | |0 = SD functionality disabled. + * | | |1 = SD functionality enabled. + */ + __IO uint32_t GCTL; + + /** + * GINTEN + * =================================================================================================== + * Offset: 0x804 Global Interrupt Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DTAIEN |DMA READ/WRITE Target Abort Interrupt Enable Control + * | | |0 = DMA READ/WRITE target abort interrupt generation disabled. + * | | |1 = DMA READ/WRITE target abort interrupt generation enabled. + */ + __IO uint32_t GINTEN; + + /** + * GINTSTS + * =================================================================================================== + * Offset: 0x808 Global Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DTAIF |DMA READ/WRITE Target Abort Interrupt Flag (Read Only) + * | | |This bit indicates DMA received an ERROR response from internal AHB bus during DMA read/write operation. + * | | |When Target Abort is occurred, please reset all engine. + * | | |0 = No bus ERROR response received. + * | | |1 = Bus ERROR response received. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + */ + __I uint32_t GINTSTS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE3[5]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * CTL + * =================================================================================================== + * Offset: 0x820 SD Control and Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |COEN |Command Output Enable Control + * | | |0 = No effect. (Please use DMARST (SDH_CTL [0]) to clear this bit.) + * | | |1 = Enabled, SD host will output a command to SD card. + * | | |Note: When operation is finished, this bit will be cleared automatically, so don't write 0 to this bit (the controller will be abnormal). + * |[1] |RIEN |Response Input Enable Control + * | | |0 = No effect. (Please use DMARST (SDH_CTL [0]) to clear this bit.) + * | | |1 = Enabled, SD host will wait to receive a response from SD card. + * | | |Note: When operation is finished, this bit will be cleared automatically, so don't write 0 to this bit (the controller will be abnormal). + * |[2] |DIEN |Data Input Enable Control + * | | |0 = No effect. (Please use DMARST (SDH_CTL [0]) to clear this bit.) + * | | |1 = Enabled, SD host will wait to receive block data and the CRC16 value from SD card. + * | | |Note: When operation is finished, this bit will be cleared automatically, so don't write 0 to this bit (the controller will be abnormal). + * |[3] |DOEN |Data Output Enable Control + * | | |0 = No effect. (Please use DMARST (SDH_CTL [0]) to clear this bit.) + * | | |1 = Enabled, SD host will transfer block data and the CRC16 value to SD card. + * | | |Note: When operation is finished, this bit will be cleared automatically, so don't write 0 to this bit (the controller will be abnormal). + * |[4] |R2EN |Response R2 Input Enable Control + * | | |0 = No effect. (Please use DMARST (SDH_CTL [0]) to clear this bit.) + * | | |1 = Enabled, SD host will wait to receive a response R2 from SD card and store the response data into DMC's flash buffer (exclude CRC7). + * | | |Note: When operation is finished, this bit will be cleared automatically, so don't write 0 to this bit (the controller will be abnormal). + * |[5] |CLK74OEN |Initial 74 Clock Cycles Output Enable Control + * | | |0 = No effect. (Please use DMARST (SDH_CTL [0]) to clear this bit.) + * | | |1 = Enabled, SD host will output 74 clock cycles to SD card. + * | | |Note: When operation is finished, this bit will be cleared automatically, so don't write 0 to this bit (the controller will be abnormal). + * |[6] |CLK8OEN |Generating 8 Clock Cycles Output Enable Control + * | | |0 = No effect. (Please use DMARST (SDH_CTL [0]) to clear this bit.) + * | | |1 = Enabled, SD host will output 8 clock cycles. + * | | |Note: When operation is finished, this bit will be cleared automatically, so don't write 0 to this bit (the controller will be abnormal). + * |[7] |CLKKEEP0 |SD Clock Enable Control For Port 0 + * | | |0 = SD host decided when to output clock and when to disable clock output automatically. + * | | |1 = SD clock always keeps free running. + * |[8:13] |CMDCODE |SD Command Code + * | | |This register contains the SD command code (0x00 - 0x3F). + * |[14] |CTLRST |Software Engine Reset + * | | |0 = No effect. + * | | |1 = Reset the internal state machine and counters. + * | | |The contents of control register will not be cleared (but RIEN, DIEN, DOEN and R2_EN will be cleared). + * | | |This bit will be auto cleared after few clock cycles. + * |[15] |DBW |SD Data Bus Width (For 1-Bit / 4-Bit Selection) + * | | |0 = Data bus width is 1-bit. + * | | |1 = Data bus width is 4-bit. + * |[16:23] |BLKCNT |Block Counts To Be Transferred Or Received + * | | |This field contains the block counts for data-in and data-out transfer. + * | | |For READ_MULTIPLE_BLOCK and WRITE_MULTIPLE_BLOCK command, software can use this function to accelerate data transfer and improve performance. + * | | |Don't fill 0x0 to this field. + * | | |Note: For READ_MULTIPLE_BLOCK and WRITE_MULTIPLE_BLOCK command, the actual total length is BLKCNT * (BLKLEN +1). + * |[24:27] |SDNWR |NWR Parameter For Block Write Operation + * | | |This value indicates the NWR parameter for data block write operation in SD clock counts. + * | | |The actual clock cycle will be SDNWR+1. + * |[29:30] |SDPORT |SD Port Selection + * | | |00 = Port 0 selected. + * | | |01 = Port 1 selected. + * | | |Other = Reserved. + * |[31] |CLKKEEP1 |SD Clock Enable Control For Port 1 + * | | |0 = SD host decided when to output clock and when to disable clock output automatically. + * | | |1 = SD clock always keeps free running. + */ + __IO uint32_t CTL; + + /** + * CMDARG + * =================================================================================================== + * Offset: 0x824 SD Command Argument Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |ARGUMENT |SD Command Argument + * | | |This register contains a 32-bit value specifies the argument of SD command from host controller to SD card. + * | | |Before trigger COEN (SDH_CTL [0]), software should fill argument in this field. + */ + __IO uint32_t CMDARG; + + /** + * INTEN + * =================================================================================================== + * Offset: 0x828 SD Interrupt Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BLKDIEN |Block Transfer Done Interrupt Enable Control + * | | |0 = SD host will not generate interrupt when data-in (out) transfer done. + * | | |1 = SD host will generate interrupt when data-in (out) transfer done. + * |[1] |CRCIEN |CRC7, CRC16 And CRC Status Error Interrupt Enable Control + * | | |0 = SD host will not generate interrupt when CRC7, CRC16 and CRC status is error. + * | | |1 = SD host will generate interrupt when CRC7, CRC16 and CRC status is error. + * |[8] |CDIEN0 |SD0 Card Detection Interrupt Enable Control + * | | |Enable/Disable interrupts generation of SD controller when card 0 is inserted or removed. + * | | |0 = Disable. + * | | |1 = Enabled. + * |[9] |CDIEN1 |SD1 Card Detection Interrupt Enable Control + * | | |Enable/Disable interrupts generation of SD controller when card 1 is inserted or removed. + * | | |0 = Disable. + * | | |1 = Enabled. + * |[12] |RTOIEN |Response Time-Out Interrupt Enable Control + * | | |Enable/Disable interrupts generation of SD controller when receiving response or R2 time-out. + * | | |Time-out value is specified at TOUT register. + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[13] |DITOIEN |Data Input Time-Out Interrupt Enable Control + * | | |Enable/Disable interrupts generation of SD controller when data input time-out. + * | | |Time-out value is specified at TOUT register. + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[14] |WKIEN |Wake-Up Signal Generating Enable Control + * | | |Enable/Disable wake-up signal generating of SD host when current using SD card issues an interrupt (wake-up) via DAT [1] to host. + * | | |0 = Disabled. + * | | |1 = Enabled. + * |[30] |CDSRC0 |SD0 Card Detect Source Selection + * | | |0 = From SD0 card's DAT3 pin. + * | | |Host need clock to got data on pin DAT3. + * | | |Please make sure CLKKEEP0 (SDH_CTL[7]) is 1 in order to generate free running clock for DAT3 pin. + * | | |1 = From GPIO pin. + * |[31] |CDSRC1 |SD1 Card Detect Source Selection + * | | |0 = From SD1 card's DAT3 pin. + * | | |Host need clock to got data on pin DAT3. + * | | |Please make sure CLKKEEP1 (SDH_CTL[31]) is 1 in order to generate free running clock for DAT3 pin. + * | | |1 = From GPIO pin. + */ + __IO uint32_t INTEN; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x82C SD Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BLKDIF |Block Transfer Done Interrupt Flag (Read Only) + * | | |This bit indicates that SD host has finished all data-in or data-out block transfer. + * | | |If there is a CRC16 error or incorrect CRC status during multiple block data transfer, the transfer will be broken and this bit will also be set. + * | | |0 = Not finished yet. + * | | |1 = Done. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + * |[1] |CRCIF |CRC7, CRC16 And CRC Status Error Interrupt Flag (Read Only) + * | | |This bit indicates that SD host has occurred CRC error during response in, data-in or data-out (CRC status error) transfer. + * | | |When CRC error is occurred, software should reset SD engine. + * | | |Some response (ex. + * | | |R3) doesn't have CRC7 information with it; SD host will still calculate CRC7, get CRC error and set this flag. + * | | |In this condition, software should ignore CRC error and clears this bit manually. + * | | |0 = No CRC error is occurred. + * | | |1 = CRC error is occurred. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + * |[2] |CRC7 |CRC7 Check Status (Read Only) + * | | |SD host will check CRC7 correctness during each response in. + * | | |If that response does not contain CRC7 information (ex. + * | | |R3), then software should turn off CRCIEN (SDH_INTEN[1]) and ignore this bit. + * | | |0 = Fault. + * | | |1 = OK. + * |[3] |CRC16 |CRC16 Check Status Of Data-In Transfer (Read Only) + * | | |SD host will check CRC16 correctness after data-in transfer. + * | | |0 = Fault. + * | | |1 = OK. + * |[4:6] |CRCSTS |CRC Status Value Of Data-Out Transfer (Read Only) + * | | |SD host will record CRC status of data-out transfer. + * | | |Software could use this value to identify what type of error is during data-out transfer. + * | | |010 = Positive CRC status. + * | | |101 = Negative CRC status. + * | | |111 = SD card programming error occurs. + * |[7] |DAT0STS |DAT0 Pin Status Of Current Selected SD Port (Read Only) + * | | |This bit is the DAT0 pin status of current selected SD port. + * |[8] |CDIF0 |SD0 Card Detection Interrupt Flag (Read Only) + * | | |This bit indicates that SD card 0 is inserted or removed. + * | | |Only when CDIEN0 (SDH_INTEN[8]) is set to 1, this bit is active. + * | | |0 = No card is inserted or removed. + * | | |1 = There is a card inserted in or removed from SD0. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + * |[9] |CDIF1 |SD1 Card Detection Interrupt Flag (Read Only) + * | | |This bit indicates that SD card 1 is inserted or removed. + * | | |Only when CDIEN1 (SDH_INTEN[9]) is set to 1, this bit is active. + * | | |0 = No card is inserted or removed. + * | | |1 = There is a card inserted in or removed from SD1. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + * |[12] |RTOIF |Response Time-Out Interrupt Flag (Read Only) + * | | |This bit indicates that SD host counts to time-out value when receiving response or R2 (waiting start bit). + * | | |0 = Not time-out. + * | | |1 = Response time-out. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + * |[13] |DITOIF |Data Input Time-Out Interrupt Flag (Read Only) + * | | |This bit indicates that SD host counts to time-out value when receiving data (waiting start bit). + * | | |0 = Not time-out. + * | | |1 = Data input time-out. + * | | |Note: This bit is read only, but can be cleared by writing '1' to it. + * |[16] |CDSTS0 |Card Detect Status Of SD0 (Read Only) + * | | |This bit indicates the card detect pin status of SD0, and is used for card detection. + * | | |When there is a card inserted in or removed from SD0, software should check this bit to confirm if there is really a card insertion or removal. + * | | |If CDSRC0 (SDH_INTEN[30]) = 0, to select DAT3 for card detection:. + * | | |0 = Card removed. + * | | |1 = Card inserted. + * | | |If CDSRC0 (SDH_INTEN[30]) = 1, to select GPIO for card detection:. + * | | |0 = Card inserted. + * | | |1 = Card removed. + * |[17] |CDSTS1 |Card Detect Status Of SD1 (Read Only) + * | | |This bit indicates the card detect pin status of SD1, and is used for card detection. + * | | |When there is a card inserted in or removed from SD1, software should check this bit to confirm if there is really a card insertion or removal. + * | | |If CDSRC1 (SDH_INTEN[31]) = 0, to select DAT3 for card detection:. + * | | |0 = Card removed. + * | | |1 = Card inserted. + * | | |If CDSRC1 (SDH_INTEN[31]) = 1, to select GPIO for card detection:. + * | | |0 = Card inserted. + * | | |1 = Card removed. + * |[18] |DAT1STS |DAT1 Pin Status Of SD Port (Read Only) + * | | |This bit indicates the DAT1 pin status of SD port. + */ + __IO uint32_t INTSTS; + + /** + * RESP0 + * =================================================================================================== + * Offset: 0x830 SD Receiving Response Token Register 0 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |RESPTK0 |SD Receiving Response Token 0 + * | | |SD host controller will receive a response token for getting a reply from SD card when RIEN (SDH_CTL[1]) is set. + * | | |This field contains response bit 47-16 of the response token. + */ + __I uint32_t RESP0; + + /** + * RESP1 + * =================================================================================================== + * Offset: 0x834 SD Receiving Response Token Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |RESPTK1 |SD Receiving Response Token 1 + * | | |SD host controller will receive a response token for getting a reply from SD card when RIEN (SDH_CTL[1]) is set. + * | | |This register contains the bit 15-8 of the response token. + */ + __I uint32_t RESP1; + + /** + * BLEN + * =================================================================================================== + * Offset: 0x838 SD Block Length Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:10] |BLKLEN |SD BLOCK LENGTH In Byte Unit + * | | |An 11-bit value specifies the SD transfer byte count of a block. + * | | |The actual byte count is equal to BLKLEN+1. + * | | |Note: The default SD block length is 512 bytes + */ + __IO uint32_t BLEN; + + /** + * TOUT + * =================================================================================================== + * Offset: 0x83C SD Response/Data-in Time-out Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |TOUT |SD Response/Data-In Time-Out Value + * | | |A 24-bit value specifies the time-out counts of response and data input. + * | | |SD host controller will wait start bit of response or data-in until this value reached. + * | | |The time period depends on SD engine clock frequency. + * | | |Do not write a small number into this field, or you may never get response or data due to time-out. + * | | |Note: Filling 0x0 into this field will disable hardware time-out function. + */ + __IO uint32_t TOUT; + +} SDH_T; + +/** + @addtogroup SDH_CONST SDH Bit Field Definition + Constant Definitions for SDH Controller +@{ */ + +#define SDH_DMACTL_DMAEN_Pos (0) /*!< SDH_T::DMACTL: DMAEN Position */ +#define SDH_DMACTL_DMAEN_Msk (0x1ul << SDH_DMACTL_DMAEN_Pos) /*!< SDH_T::DMACTL: DMAEN Mask */ + +#define SDH_DMACTL_DMARST_Pos (1) /*!< SDH_T::DMACTL: DMARST Position */ +#define SDH_DMACTL_DMARST_Msk (0x1ul << SDH_DMACTL_DMARST_Pos) /*!< SDH_T::DMACTL: DMARST Mask */ + +#define SDH_DMACTL_SGEN_Pos (3) /*!< SDH_T::DMACTL: SGEN Position */ +#define SDH_DMACTL_SGEN_Msk (0x1ul << SDH_DMACTL_SGEN_Pos) /*!< SDH_T::DMACTL: SGEN Mask */ + +#define SDH_DMACTL_DMABUSY_Pos (9) /*!< SDH_T::DMACTL: DMABUSY Position */ +#define SDH_DMACTL_DMABUSY_Msk (0x1ul << SDH_DMACTL_DMABUSY_Pos) /*!< SDH_T::DMACTL: DMABUSY Mask */ + +#define SDH_DMASA_ORDER_Pos (0) /*!< SDH_T::DMASA: ORDER Position */ +#define SDH_DMASA_ORDER_Msk (0x1ul << SDH_DMASA_ORDER_Pos) /*!< SDH_T::DMASA: ORDER Mask */ + +#define SDH_DMASA_DMASA_Pos (1) /*!< SDH_T::DMASA: DMASA Position */ +#define SDH_DMASA_DMASA_Msk (0x7ffffffful << SDH_DMASA_DMASA_Pos) /*!< SDH_T::DMASA: DMASA Mask */ + +#define SDH_DMABCNT_BCNT_Pos (0) /*!< SDH_T::DMABCNT: BCNT Position */ +#define SDH_DMABCNT_BCNT_Msk (0x3fffffful << SDH_DMABCNT_BCNT_Pos) /*!< SDH_T::DMABCNT: BCNT Mask */ + +#define SDH_DMAINTEN_ABORTIEN_Pos (0) /*!< SDH_T::DMAINTEN: ABORTIEN Position */ +#define SDH_DMAINTEN_ABORTIEN_Msk (0x1ul << SDH_DMAINTEN_ABORTIEN_Pos) /*!< SDH_T::DMAINTEN: ABORTIEN Mask */ + +#define SDH_DMAINTEN_WEOTIEN_Pos (1) /*!< SDH_T::DMAINTEN: WEOTIEN Position */ +#define SDH_DMAINTEN_WEOTIEN_Msk (0x1ul << SDH_DMAINTEN_WEOTIEN_Pos) /*!< SDH_T::DMAINTEN: WEOTIEN Mask */ + +#define SDH_DMAINTSTS_ABORTIF_Pos (0) /*!< SDH_T::DMAINTSTS: ABORTIF Position */ +#define SDH_DMAINTSTS_ABORTIF_Msk (0x1ul << SDH_DMAINTSTS_ABORTIF_Pos) /*!< SDH_T::DMAINTSTS: ABORTIF Mask */ + +#define SDH_DMAINTSTS_WEOTIF_Pos (1) /*!< SDH_T::DMAINTSTS: WEOTIF Position */ +#define SDH_DMAINTSTS_WEOTIF_Msk (0x1ul << SDH_DMAINTSTS_WEOTIF_Pos) /*!< SDH_T::DMAINTSTS: WEOTIF Mask */ + +#define SDH_GCTL_GCTLRST_Pos (0) /*!< SDH_T::GCTL: GCTLRST Position */ +#define SDH_GCTL_GCTLRST_Msk (0x1ul << SDH_GCTL_GCTLRST_Pos) /*!< SDH_T::GCTL: GCTLRST Mask */ + +#define SDH_GCTL_SDEN_Pos (1) /*!< SDH_T::GCTL: SDEN Position */ +#define SDH_GCTL_SDEN_Msk (0x1ul << SDH_GCTL_SDEN_Pos) /*!< SDH_T::GCTL: SDEN Mask */ + +#define SDH_GINTEN_DTAIEN_Pos (0) /*!< SDH_T::GINTEN: DTAIEN Position */ +#define SDH_GINTEN_DTAIEN_Msk (0x1ul << SDH_GINTEN_DTAIEN_Pos) /*!< SDH_T::GINTEN: DTAIEN Mask */ + +#define SDH_GINTSTS_DTAIF_Pos (0) /*!< SDH_T::GINTSTS: DTAIF Position */ +#define SDH_GINTSTS_DTAIF_Msk (0x1ul << SDH_GINTSTS_DTAIF_Pos) /*!< SDH_T::GINTSTS: DTAIF Mask */ + +#define SDH_CTL_COEN_Pos (0) /*!< SDH_T::CTL: COEN Position */ +#define SDH_CTL_COEN_Msk (0x1ul << SDH_CTL_COEN_Pos) /*!< SDH_T::CTL: COEN Mask */ + +#define SDH_CTL_RIEN_Pos (1) /*!< SDH_T::CTL: RIEN Position */ +#define SDH_CTL_RIEN_Msk (0x1ul << SDH_CTL_RIEN_Pos) /*!< SDH_T::CTL: RIEN Mask */ + +#define SDH_CTL_DIEN_Pos (2) /*!< SDH_T::CTL: DIEN Position */ +#define SDH_CTL_DIEN_Msk (0x1ul << SDH_CTL_DIEN_Pos) /*!< SDH_T::CTL: DIEN Mask */ + +#define SDH_CTL_DOEN_Pos (3) /*!< SDH_T::CTL: DOEN Position */ +#define SDH_CTL_DOEN_Msk (0x1ul << SDH_CTL_DOEN_Pos) /*!< SDH_T::CTL: DOEN Mask */ + +#define SDH_CTL_R2EN_Pos (4) /*!< SDH_T::CTL: R2EN Position */ +#define SDH_CTL_R2EN_Msk (0x1ul << SDH_CTL_R2EN_Pos) /*!< SDH_T::CTL: R2EN Mask */ + +#define SDH_CTL_CLK74OEN_Pos (5) /*!< SDH_T::CTL: CLK74OEN Position */ +#define SDH_CTL_CLK74OEN_Msk (0x1ul << SDH_CTL_CLK74OEN_Pos) /*!< SDH_T::CTL: CLK74OEN Mask */ + +#define SDH_CTL_CLK8OEN_Pos (6) /*!< SDH_T::CTL: CLK8OEN Position */ +#define SDH_CTL_CLK8OEN_Msk (0x1ul << SDH_CTL_CLK8OEN_Pos) /*!< SDH_T::CTL: CLK8OEN Mask */ + +#define SDH_CTL_CLKKEEP0_Pos (7) /*!< SDH_T::CTL: CLKKEEP0 Position */ +#define SDH_CTL_CLKKEEP0_Msk (0x1ul << SDH_CTL_CLKKEEP0_Pos) /*!< SDH_T::CTL: CLKKEEP0 Mask */ + +#define SDH_CTL_CMDCODE_Pos (8) /*!< SDH_T::CTL: CMDCODE Position */ +#define SDH_CTL_CMDCODE_Msk (0x3ful << SDH_CTL_CMDCODE_Pos) /*!< SDH_T::CTL: CMDCODE Mask */ + +#define SDH_CTL_CTLRST_Pos (14) /*!< SDH_T::CTL: CTLRST Position */ +#define SDH_CTL_CTLRST_Msk (0x1ul << SDH_CTL_CTLRST_Pos) /*!< SDH_T::CTL: CTLRST Mask */ + +#define SDH_CTL_DBW_Pos (15) /*!< SDH_T::CTL: DBW Position */ +#define SDH_CTL_DBW_Msk (0x1ul << SDH_CTL_DBW_Pos) /*!< SDH_T::CTL: DBW Mask */ + +#define SDH_CTL_BLKCNT_Pos (16) /*!< SDH_T::CTL: BLKCNT Position */ +#define SDH_CTL_BLKCNT_Msk (0xfful << SDH_CTL_BLKCNT_Pos) /*!< SDH_T::CTL: BLKCNT Mask */ + +#define SDH_CTL_SDNWR_Pos (24) /*!< SDH_T::CTL: SDNWR Position */ +#define SDH_CTL_SDNWR_Msk (0xful << SDH_CTL_SDNWR_Pos) /*!< SDH_T::CTL: SDNWR Mask */ + +#define SDH_CTL_SDPORT_Pos (29) /*!< SDH_T::CTL: SDPORT Position */ +#define SDH_CTL_SDPORT_Msk (0x3ul << SDH_CTL_SDPORT_Pos) /*!< SDH_T::CTL: SDPORT Mask */ + +#define SDH_CTL_CLKKEEP1_Pos (31) /*!< SDH_T::CTL: CLKKEEP1 Position */ +#define SDH_CTL_CLKKEEP1_Msk (0x1ul << SDH_CTL_CLKKEEP1_Pos) /*!< SDH_T::CTL: CLKKEEP1 Mask */ + +#define SDH_CMDARG_ARGUMENT_Pos (0) /*!< SDH_T::CMDARG: ARGUMENT Position */ +#define SDH_CMDARG_ARGUMENT_Msk (0xfffffffful << SDH_CMDARG_ARGUMENT_Pos) /*!< SDH_T::CMDARG: ARGUMENT Mask */ + +#define SDH_INTEN_BLKDIEN_Pos (0) /*!< SDH_T::INTEN: BLKDIEN Position */ +#define SDH_INTEN_BLKDIEN_Msk (0x1ul << SDH_INTEN_BLKDIEN_Pos) /*!< SDH_T::INTEN: BLKDIEN Mask */ + +#define SDH_INTEN_CRCIEN_Pos (1) /*!< SDH_T::INTEN: CRCIEN Position */ +#define SDH_INTEN_CRCIEN_Msk (0x1ul << SDH_INTEN_CRCIEN_Pos) /*!< SDH_T::INTEN: CRCIEN Mask */ + +#define SDH_INTEN_CDIEN0_Pos (8) /*!< SDH_T::INTEN: CDIEN0 Position */ +#define SDH_INTEN_CDIEN0_Msk (0x1ul << SDH_INTEN_CDIEN0_Pos) /*!< SDH_T::INTEN: CDIEN0 Mask */ + +#define SDH_INTEN_CDIEN1_Pos (9) /*!< SDH_T::INTEN: CDIEN1 Position */ +#define SDH_INTEN_CDIEN1_Msk (0x1ul << SDH_INTEN_CDIEN1_Pos) /*!< SDH_T::INTEN: CDIEN1 Mask */ + +#define SDH_INTEN_SDHOST0IEN_Pos (10) /*!< SDH_T::INTSTS: SDHOST0IEN Position */ +#define SDH_INTEN_SDHOST0IEN_Msk (0x1ul << SDH_INTEN_SDHOST0IEN_Pos) /*!< SDH_T::INTSTS: SDHOST0IEN Mask */ + +#define SDH_INTEN_SDHOST1IEN_Pos (11) /*!< SDH_T::INTSTS: SDHOST1IEN Position */ +#define SDH_INTEN_SDHOST1IEN_Msk (0x1ul << SDH_INTEN_SDHOST1IEN_Pos) /*!< SDH_T::INTSTS: SDHOST1IEN Mask */ + +#define SDH_INTEN_RTOIEN_Pos (12) /*!< SDH_T::INTEN: RTOIEN Position */ +#define SDH_INTEN_RTOIEN_Msk (0x1ul << SDH_INTEN_RTOIEN_Pos) /*!< SDH_T::INTEN: RTOIEN Mask */ + +#define SDH_INTEN_DITOIEN_Pos (13) /*!< SDH_T::INTEN: DITOIEN Position */ +#define SDH_INTEN_DITOIEN_Msk (0x1ul << SDH_INTEN_DITOIEN_Pos) /*!< SDH_T::INTEN: DITOIEN Mask */ + +#define SDH_INTEN_WKIEN_Pos (14) /*!< SDH_T::INTEN: WKIEN Position */ +#define SDH_INTEN_WKIEN_Msk (0x1ul << SDH_INTEN_WKIEN_Pos) /*!< SDH_T::INTEN: WKIEN Mask */ + +#define SDH_INTEN_CDSRC0_Pos (30) /*!< SDH_T::INTEN: CDSRC0 Position */ +#define SDH_INTEN_CDSRC0_Msk (0x1ul << SDH_INTEN_CDSRC0_Pos) /*!< SDH_T::INTEN: CDSRC0 Mask */ + +#define SDH_INTEN_CDSRC1_Pos (31) /*!< SDH_T::INTEN: CDSRC1 Position */ +#define SDH_INTEN_CDSRC1_Msk (0x1ul << SDH_INTEN_CDSRC1_Pos) /*!< SDH_T::INTEN: CDSRC1 Mask */ + +#define SDH_INTSTS_BLKDIF_Pos (0) /*!< SDH_T::INTSTS: BLKDIF Position */ +#define SDH_INTSTS_BLKDIF_Msk (0x1ul << SDH_INTSTS_BLKDIF_Pos) /*!< SDH_T::INTSTS: BLKDIF Mask */ + +#define SDH_INTSTS_CRCIF_Pos (1) /*!< SDH_T::INTSTS: CRCIF Position */ +#define SDH_INTSTS_CRCIF_Msk (0x1ul << SDH_INTSTS_CRCIF_Pos) /*!< SDH_T::INTSTS: CRCIF Mask */ + +#define SDH_INTSTS_CRC7_Pos (2) /*!< SDH_T::INTSTS: CRC7 Position */ +#define SDH_INTSTS_CRC7_Msk (0x1ul << SDH_INTSTS_CRC7_Pos) /*!< SDH_T::INTSTS: CRC7 Mask */ + +#define SDH_INTSTS_CRC16_Pos (3) /*!< SDH_T::INTSTS: CRC16 Position */ +#define SDH_INTSTS_CRC16_Msk (0x1ul << SDH_INTSTS_CRC16_Pos) /*!< SDH_T::INTSTS: CRC16 Mask */ + +#define SDH_INTSTS_CRCSTS_Pos (4) /*!< SDH_T::INTSTS: CRCSTS Position */ +#define SDH_INTSTS_CRCSTS_Msk (0x7ul << SDH_INTSTS_CRCSTS_Pos) /*!< SDH_T::INTSTS: CRCSTS Mask */ + +#define SDH_INTSTS_DAT0STS_Pos (7) /*!< SDH_T::INTSTS: DAT0STS Position */ +#define SDH_INTSTS_DAT0STS_Msk (0x1ul << SDH_INTSTS_DAT0STS_Pos) /*!< SDH_T::INTSTS: DAT0STS Mask */ + +#define SDH_INTSTS_CDIF0_Pos (8) /*!< SDH_T::INTSTS: CDIF0 Position */ +#define SDH_INTSTS_CDIF0_Msk (0x1ul << SDH_INTSTS_CDIF0_Pos) /*!< SDH_T::INTSTS: CDIF0 Mask */ + +#define SDH_INTSTS_CDIF1_Pos (9) /*!< SDH_T::INTSTS: CDIF1 Position */ +#define SDH_INTSTS_CDIF1_Msk (0x1ul << SDH_INTSTS_CDIF1_Pos) /*!< SDH_T::INTSTS: CDIF1 Mask */ + +#define SDH_INTSTS_SDHOST0IF_Pos (10) /*!< SDH_T::INTSTS: SDHOST0IF Position */ +#define SDH_INTSTS_SDHOST0IF_Msk (0x1ul << SDH_INTSTS_SDHOST0IF_Pos) /*!< SDH_T::INTSTS: SDHOST0IF Mask */ + +#define SDH_INTSTS_SDHOST1IF_Pos (11) /*!< SDH_T::INTSTS: SDHOST1IF Position */ +#define SDH_INTSTS_SDHOST1IF_Msk (0x1ul << SDH_INTSTS_SDHOST1IF_Pos) /*!< SDH_T::INTSTS: SDHOST1IF Mask */ + +#define SDH_INTSTS_RTOIF_Pos (12) /*!< SDH_T::INTSTS: RTOIF Position */ +#define SDH_INTSTS_RTOIF_Msk (0x1ul << SDH_INTSTS_RTOIF_Pos) /*!< SDH_T::INTSTS: RTOIF Mask */ + +#define SDH_INTSTS_DINTOIF_Pos (13) /*!< SDH_T::INTSTS: DINTOIF Position */ +#define SDH_INTSTS_DINTOIF_Msk (0x1ul << SDH_INTSTS_DINTOIF_Pos) /*!< SDH_T::INTSTS: DINTOIF Mask */ + +#define SDH_INTSTS_CDSTS0_Pos (16) /*!< SDH_T::INTSTS: CDSTS0 Position */ +#define SDH_INTSTS_CDSTS0_Msk (0x1ul << SDH_INTSTS_CDSTS0_Pos) /*!< SDH_T::INTSTS: CDSTS0 Mask */ + +#define SDH_INTSTS_CDSTS1_Pos (17) /*!< SDH_T::INTSTS: CDSTS1 Position */ +#define SDH_INTSTS_CDSTS1_Msk (0x1ul << SDH_INTSTS_CDSTS1_Pos) /*!< SDH_T::INTSTS: CDSTS1 Mask */ + +#define SDH_INTSTS_DAT1STS_Pos (18) /*!< SDH_T::INTSTS: DAT1STS Position */ +#define SDH_INTSTS_DAT1STS_Msk (0x1ul << SDH_INTSTS_DAT1STS_Pos) /*!< SDH_T::INTSTS: DAT1STS Mask */ + +#define SDH_RESP0_RESPTK0_Pos (0) /*!< SDH_T::RESP0: RESPTK0 Position */ +#define SDH_RESP0_RESPTK0_Msk (0xfffffffful << SDH_RESP0_RESPTK0_Pos) /*!< SDH_T::RESP0: RESPTK0 Mask */ + +#define SDH_RESP1_RESPTK1_Pos (0) /*!< SDH_T::RESP1: RESPTK1 Position */ +#define SDH_RESP1_RESPTK1_Msk (0xfful << SDH_RESP1_RESPTK1_Pos) /*!< SDH_T::RESP1: RESPTK1 Mask */ + +#define SDH_BLEN_BLKLEN_Pos (0) /*!< SDH_T::BLEN: BLKLEN Position */ +#define SDH_BLEN_BLKLEN_Msk (0x7fful << SDH_BLEN_BLKLEN_Pos) /*!< SDH_T::BLEN: BLKLEN Mask */ + +#define SDH_TOUT_TOUT_Pos (0) /*!< SDH_T::TOUT: TOUT Position */ +#define SDH_TOUT_TOUT_Msk (0xfffffful << SDH_TOUT_TOUT_Pos) /*!< SDH_T::TOUT: TOUT Mask */ + +/**@}*/ /* SDH_CONST */ +/**@}*/ /* end of SDH register group */ + + +/*---------------------- Serial Peripheral Interface Controller -------------------------*/ +/** + @addtogroup SPI Serial Peripheral Interface Controller(SPI) + Memory Mapped Structure for SPI Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 SPI Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SPIEN |SPI Transfer Control Enable Control + * | | |0 = Transfer control Disabled. + * | | |1 = Transfer control Enabled. + * | | |Note1: In Master mode, the transfer will start when there is data in the FIFO buffer after this is set to 1. + * | | |In Slave mode, this device is ready to receive data when this bit is set to 1. + * | | |Note2: All configurations should be set before writing 1 to this SPIEN bit. + * | | |(eg: TXNEG, RXNEG, DWIDTH, LSB, CLKPOL, and so on). + * |[1] |RXNEG |Receive On Negative Edge + * | | |0 = Received data input signal is latched on the rising edge of SPICLK. + * | | |1 = Received data input signal is latched on the falling edge of SPICLK. + * |[2] |TXNEG |Transmit On Negative Edge + * | | |0 = Transmitted data output signal is changed on the rising edge of SPICLK. + * | | |1 = Transmitted data output signal is changed on the falling edge of SPICLK. + * |[3] |CLKPOL |Clock Polarity + * | | |0 = SPICLK is idle low. + * | | |1 = SPICLK is idle high. + * |[4:7] |SUSPITV |Suspend Interval (Master Only) + * | | |SUSPITV = 0x0 ... 0.5 SPICLK clock cycle. + * | | |SUSPITV = 0x1 ... 1.5 SPICLK clock cycle. + * | | |...... + * | | |SUSPITV = 0xE ... 14.5 SPICLK clock cycle. + * | | |SUSPITV = 0xF ... 15.5 SPICLK clock cycle. + * | | |Note: The four bits provide configurable suspend interval between two successive transmit/receive transaction in a transfer. + * | | |The definition of the suspend interval is the interval between the last clock edge of the preceding transaction word and the first clock edge of the following transaction word. + * | | |The default value is 0x3. + * | | |The period of the suspend interval is obtained according to the following equation. + * | | |(SUSPITV[3:0] + 0.5) * period of SPICLK clock cycle + * |[8:12] |DWIDTH |Data Transmit Bit Width + * | | |This field specifies how many bits can be transmitted / received in one transaction. + * | | |The minimum bit length is 8 bits and can up to 32 bits. + * | | |DWIDTH = 0x08 ... 8 bits. + * | | |DWIDTH = 0x09 ... 9 bits. + * | | |...... + * | | |DWIDTH = 0x1F ... 31 bits. + * | | |DWIDTH = 0x00 ... 32 bits. + * |[13] |LSB |Send LSB First + * | | |0 = MSB first. + * | | |1 = LSB first. + * | | |Note1: The LSB, bit 0 of the SPI TX register, is sent first to the SPI data output pin, and the first bit received from the SPI data input pin will be put in the LSB position of the RX register (bit 0 of SPI_RX). + * | | |Note2: The MSB, which bit of transmit/receive register depends on the setting of DWIDTH, is transmitted/received first. + * |[16] |TWOBIT |2-Bit Mode Enable Control + * | | |0 = 2-bit mode Disabled. + * | | |1 = 2-bit mode Enabled. + * | | |Note: When 2-bit mode is enabled, the first serial transmitted bit data is from the first FIFO buffer data, and the 2nd + * | | |serial transmitted bit data is from the second FIFO buffer data. + * | | |As the same as transmitted function, the first received bit data is stored into the first FIFO buffer and the 2nd received bit data is stored into the second FIFO buffer at the same time. + * |[17] |UNITIEN |Unit Transfer Interrupt Enable Control + * | | |0 = SPI unit transfer interrupt Disabled. + * | | |1 = SPI unit transfer interrupt Enabled. + * |[18] |SLAVE |Slave Mode Enable Control + * | | |0 = Master mode. + * | | |1 = Slave mode. + * |[19] |REORDER |Byte Reorder Function Enable Control + * | | |0 = Byte reorder function Disabled. + * | | |1 = Byte reorder function Enabled. + * | | |Note1: Byte reorder function is only available if DWIDTH is defined as 16, 24, and 32 bits. + * | | |Note2: The byte reorder function is not supported when the Quad or Dual I/O mode is enabled. + * | | |Note3: A byte suspend interval will be inserted among each byte. + * | | |The period of the byte suspend interval depends on the setting of SUSPITV. + * |[20] |QDIODIR |Quad Or Dual I/O Mode Direction Control + * | | |0 = Quad or Dual Input mode. + * | | |1 = Quad or Dual Output mode. + * |[21] |DUALIOEN |Dual I/O Mode Enable Control + * | | |0 = Dual I/O mode Disabled. + * | | |1 = Dual I/O mode Enabled. + * |[22] |QUADIOEN |Quad I/O Mode Enable Control + * | | |0 = Quad I/O mode Disabled. + * | | |1 = Quad I/O mode Enabled. + */ + __IO uint32_t CTL; + + /** + * CLKDIV + * =================================================================================================== + * Offset: 0x04 SPI Clock Divider Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DIVIDER |Clock Divider Register + * | | |The value in this field is the frequency divider for generating the peripheral clock, fspi_eclk, and the SPI bus clock of SPI master. + * | | |The frequency is obtained according to the following equation. + * | | |Note1: is the peripheral clock source, which is defined in the clock control, CLK_SEL1 register. + * | | |Note2: is the peripheral clock which is used to drive the SPI logic unit. + */ + __IO uint32_t CLKDIV; + + /** + * SSCTL + * =================================================================================================== + * Offset: 0x08 SPI Slave Select Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |SS |Slave Select Control (Master Only) + * | | |If AUTOSS bit is cleared to 0, + * | | |0 = Set the SPI_SS line to inactive state. + * | | |1 = Set the proper SPI_SS line to active state. + * | | |If AUTOSS bit is set to 1, + * | | |0 = Keep the SPI_SS line at inactive state. + * | | |1 = Select the SPI_SS line to be automatically driven to active state for the duration of transmission/reception, and will be driven to inactive state for the rest of the time. + * | | |The active state of SPI_SS is specified in SSACTPOL bit. + * | | |Note: SPI_SS0 is defined as the slave select input in Slave mode. + * |[2] |SSACTPOL |Slave Select Active Level + * | | |0 = The slave select signal SPI_SS0/1 is active on low-level. + * | | |1 = The slave select signal SPI_SS0/1 is active on high-level. + * | | |Note: This bit defines the active status of slave select signal (SPI_SS0/1). + * |[3] |AUTOSS |Automatic Slave Select Function Enable Control (Master Only) + * | | |0 = Automatic slave select function Disabled. + * | | |1 = Automatic slave select function Enabled. + * | | |Note1: If this bit is cleared, slave select signals will be asserted/de-asserted by setting /clearing the corresponding bits of SPI_SSCTL[1:0]. + * | | |Note2: If this bit is set, SPI_SS0/1 signals will be generated automatically. + * | | |It means that device/slave select signal, which is set in SPI_SSCTL[1:0], will be asserted by the SPI controller when transmit/receive is started, and will be de-asserted after each transmit/receive is finished. + * |[4] |SLV3WIRE |Slave 3-Wire Mode Enable Control + * | | |0 = 4-wire bi-direction interface. + * | | |1 = 3-wire bi-direction interface. + * | | |Note: This is used to ignore the slave select signal in Slave mode. + * | | |The SPI controller can work with 3-wire interface including SPI_CLK, SPI_MISO, and SPI_MOSI. + * |[5] |SLVTOIEN |Slave Mode Time-Out Interrupt Enable Control + * | | |0 = Slave mode time-out interrupt Disabled. + * | | |1 = Slave mode time-out interrupt Enabled. + * |[6] |SLVTORST |Slave Mode Time-Out FIFO Clear + * | | |0 = Time out FIFO clear Disabled. + * | | |1 = Time out FIFO clear Enabled. + * | | |Note: Both the FIFO clear function, TX_CLK and RXRST, active automatically when there is slave mode time-out event. + * |[8] |SLVBEIEN |Slave Mode Error 0 Interrupt Enable Control + * | | |0 = Slave mode error 0 interrupt Disabled. + * | | |1 = Slave mode error 0 interrupt Enabled. + * |[9] |SLVURIEN |Slave Mode Error 1 Interrupt Enable Control + * | | |0 = Slave mode error 1 interrupt Disabled. + * | | |1 = Slave mode error 1 interrupt Enabled. + * |[12] |SSACTIEN |Slave Select Active Interrupt Enable Control + * | | |0 = Slave select active interrupt Disabled. + * | | |1 = Slave select active interrupt Enabled. + * |[13] |SSINAIEN |Slave Select Inactive Interrupt Enable Control + * | | |0 = Slave select inactive interrupt Disabled. + * | | |1 = Slave select inactive interrupt Enabled. + * |[16:31] |SLVTOCNT |Slave Mode Time-Out Period + * | | |0 = Slave time out function disabled. + * | | |Others = Slave time out period. + * | | |Note: In Slave mode, these bits indicate the time-out period when there is bus clock input during slave select active. + * | | |The clock source of the time-out counter is Slave peripheral clock. + * | | |If the value is 0, it indicates the slave mode time-out function is disabled. + */ + __IO uint32_t SSCTL; + + /** + * PDMACTL + * =================================================================================================== + * Offset: 0x0C SPI PDMA Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TXPDMAEN |Transmit DMA Enable Control + * | | |0 = Transmit PDMA Disabled. + * | | |1 = Transmit PDMA Enabled. + * | | |Note: Setting this bit to 1 will start the transmit PDMA process. + * | | |SPI controller will issue request to PDMA controller automatically. + * | | |Hardware will clear this bit to 0 automatically after PDMA transfer done. + * |[1] |RXPDMAEN |Receive PDMA Enable Control + * | | |0 = Receive PDMA Disabled. + * | | |1 = Receive PDMA Enabled. + * | | |Note: Setting this bit to 1 will start the receive PDMA process. + * | | |The SPI controller will issue request to PDMA controller automatically when the SPI receive buffer is not empty. + * | | |This bit will be cleared to 0 by hardware automatically after PDMA transfer is done. + * |[2] |PDMARST |PDMA Reset + * | | |0 = No effect. + * | | |1 = Reset the PDMA control logic of the SPI controller. This bit will be cleared to 0 automatically. + */ + __IO uint32_t PDMACTL; + + /** + * FIFOCTL + * =================================================================================================== + * Offset: 0x10 SPI FIFO Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXRST |Clear Receive FIFO Buffer + * | | |0 = No effect. + * | | |1 = Clear receive FIFO buffer. + * | | |Note1: If there is slave receive time-out event, the RXRST will be set 1 when the SLVTORST, SPI_SSCTL[6], is enabled. + * | | |Note2: The RXFULL bit will be cleared to 0 and the RXEMPTY bit will be set to 1. + * | | |This bit will be cleared to 0 by hardware about 3 system clocks + 3 peripheral clock after it is set to 1. + * |[1] |TXRST |Clear Transmit FIFO Buffer + * | | |0 = No effect. + * | | |1 = Clear transmit FIFO buffer. + * | | |Note1: If there is slave receive time-out event, the TXRST will be set 1 when the SLVTORST, SPI_SSCTL[6], is enabled. + * | | |Note2: The TXFULL bit will be cleared to 0 and the TXEMPTY bit will be set to 1. + * | | |This bit will be cleared to 0 by hardware about 3 system clocks + 3 peripheral clock after it is set to 1. + * |[2] |RXTHIEN |Receive FIFO Threshold Interrupt Enable Control + * | | |0 = RX FIFO threshold interrupt Disabled. + * | | |1 = RX FIFO threshold interrupt Enabled. + * |[3] |TXTHIEN |Transmit FIFO Threshold Interrupt Enable Control + * | | |0 = TX FIFO threshold interrupt Disabled. + * | | |1 = TX FIFO threshold interrupt Enabled. + * |[4] |RXTOIEN |Slave Receive Time-Out Interrupt Enable Control (Slave Only) + * | | |0 = Receive time-out interrupt Disabled. + * | | |1 = Receive time-out interrupt Enabled. + * |[5] |RXOVIEN |Receive FIFO Overrun Interrupt Enable Control + * | | |0 = Receive FIFO overrun interrupt Disabled. + * | | |1 = Receive FIFO overrun interrupt Enabled. + * |[6] |TXUFPOL |Transmit Under-Run Data Out (Slave Only) + * | | |0 = The SPI data bus is keep low if there is transmit under-run event. + * | | |1 = The SPI data bus is keep high if there is transmit under-run event. + * | | |Note1: The under run event is activated after the bus clock input and the hardware synchronous, so that the first 1~3 bit (depending on the relation between system clock and the peripheral clock) data out will be the last transaction data. + * | | |Note2: If the frequency of system clock approach to peripheral clock, they may need 3-bit time to report the transmit under-run event. + * |[7] |TXUFIEN |Transmit Under Run Interrupt Enable Control (Slave Only) + * | | |0 = Transmit FIFO under-run interrupt Disabled. + * | | |1 = Transmit FIFO under-run interrupt Enabled. + * |[24:26] |RXTH |Receive FIFO Threshold + * | | |If the valid data count of the receive FIFO buffer is larger than the RXTH setting, the RXTHIF bit will be set to 1, else the RXTHIF bit will be cleared to 0. + * |[28:30] |TXTH |Transmit FIFO Threshold + * | | |If the valid data count of the transmit FIFO buffer is less than or equal to the TXTH setting, the TXTHIF bit will be set to 1, else the TXTHIF bit will be cleared to 0. + */ + __IO uint32_t FIFOCTL; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x14 SPI Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BUSY |Busy Status (Read Only) + * | | |0 = SPI controller is in Idle state. + * | | |1 = SPI controller is in busy state. + * | | |The following listing are the bus busy conditions: + * | | |*. SPIEN = 1 and the TXEMPTY = 0. + * | | |*. For SPI Master, the TXEMPTY = 1 but the current transaction is not finished yet. + * | | |*. For SPI Slave receive mode, the SPIEN = 1 and there is serial clock input into the SPI core logic when slave select is active. + * | | |*. For SPI Slave transmit mode, the SPIEN = 1 and the transmit buffer is not empty in SPI core logic even if the slave select is inactive. + * |[1] |UNITIF |Unit Transfer Interrupt Status + * | | |0 = No transaction has been finished since this bit was cleared to 0. + * | | |1 = SPI controller has finished one unit transfer. + * | | |Note: This bit will be cleared by writing 1 to it. + * |[2] |SSACTIF |Slave Select Active Interrupt Status + * | | |0 = Slave select active interrupt is clear or not occur. + * | | |1 = Slave select active interrupt event occurred. + * | | |Note: This bit will be cleared by writing 1 to it. + * |[3] |SSINAIF |Slave Select Inactive Interrupt Status + * | | |0 = Slave select inactive interrupt is clear or not occur. + * | | |1 = Slave select inactive interrupt event occurred. + * | | |Note: This bit will be cleared by writing 1 to it. + * |[4] |SSLINE |Slave Select Line Bus Status (Read Only) + * | | |0 = Indicates the slave select line bus status is 0. + * | | |1 = Indicates the slave select line bus status is 1. + * | | |Note: If SSACTPOL, SPI_SSCTL[2], is set 0, and the SSLINE is 1, the SPI slave select is in inactive status. + * |[5] |SLVTOIF |Slave Time-Out Interrupt Status + * | | |0 = Slave time-out is not active. + * | | |1 = Slave time-out is active. + * | | |Note1: If the DWIDTH is set 16, one transaction is equal 16 bits bus clock period. + * | | |This bit will be cleared by writing 1 to it. + * | | |Note2: When the Slave Select is active and the value of SLVTOCNT is not 0 and the busclock input, the slave time-out counter in SPI controller logic will be start. + * | | |When the value of time-out counter greater or equal than the value of SLVTOCNT, SPI_SSCTL[31:16], during before one transaction done, the slave time-out interrupt event will active. + * |[6] |SLVBEIF |Slave Mode Error 0 Interrupt Status + * | | |0 = No Slave mode error 0 event. + * | | |1 = Slave mode error 0 occurs. + * | | |Note1: If the slave select active but there is no any bus clock input, the SLVER0_INTSTS also active when the slave select goes to inactive state. + * | | |This bit will be cleared by writing 1 to it. + * | | |Note2: In Slave mode, there is bit counter mismatch with DWIDTH when the slave select line goes to inactive state. + * |[7] |SLVURIF |Slave Mode Error 1 Interrupt Status + * | | |0 = No Slave mode error 1 event. + * | | |1 = Slave mode error 1 occurs. + * | | |Note: In Slave mode, transmit under-run occurs when the slave select line goes to inactive state. + * | | |This bit will be cleared by writing 1 to it. + * |[8] |RXEMPTY |Receive FIFO Buffer Empty Indicator (Read Only) + * | | |0 = Receive FIFO buffer is not empty. + * | | |1 = Receive FIFO buffer is empty. + * |[9] |RXFULL |Receive FIFO Buffer Empty Indicator (Read Only) + * | | |0 = Receive FIFO buffer is not empty. + * | | |1 = Receive FIFO buffer is empty. + * |[10] |RXTHIF |Receive FIFO Threshold Interrupt Status (Read Only) + * | | |0 = The valid data count within the Rx FIFO buffer is smaller than or equal to the setting value of RXTH. + * | | |1 = The valid data count within the receive FIFO buffer is larger than the setting value of RXTH. + * | | |Note: If RX_INTEN = 1 and RX_INTSTS = 1, the SPI controller will generate a SPI interrupt request. + * |[11] |RXOVIF |Receive FIFO Overrun Status + * | | |0 = No FIFO over-run event. + * | | |1 = FIFO over-run event occurred. + * | | |Note: When the receive FIFO buffer is full, the follow-up data will be dropped and this bit will be set to 1. + * | | |This bit will be cleared by writing 1 to it. + * |[12] |RXTOIF |Receive Time-Out Interrupt Status + * | | |0 = No receive FIFO time-out event. + * | | |1 = FIFO time-out event occurred. + * | | |Note: Receive FIFO buffer is not empty and no read operation on receive FIFO buffer over 64 SPI clock period in Master mode or over 576 peripheral clock period in Slave mode. + * | | |When the received FIFO buffer is read by software, the time-out status will be cleared automatically. + * | | |This bit will be cleared by writing 1 to it. + * |[15] |SPIENSTS |SPI Enable Bit Status (Read Only) + * | | |0 = Indicates the transmit control bit is disabled. + * | | |1 = Indicates the transfer control bit is active. + * | | |Note: The clock source of SPI controller logic is peripheral clock, it is asynchronous with the system clock. + * | | |In order to make sure the function is disabled in SPI controller logic, this bit indicates the real status of SPIEN in SPI controller logic for user. + * |[16] |TXEMPTY |Transmit FIFO Buffer Empty Indicator (Read Only) + * | | |0 = Transmit FIFO buffer is not empty. + * | | |1 = Transmit FIFO buffer is empty. + * |[17] |TXFULL |Transmit FIFO Buffer Full Indicator (Read Only) + * | | |0 = Transmit FIFO buffer is not full. + * | | |1 = Transmit FIFO buffer is full. + * |[18] |TXTHIF |Transmit FIFO Threshold Interrupt Status (Read Only) + * | | |0 = The valid data count within the transmit FIFO buffer is larger than the setting value of TXTH. + * | | |1 = The valid data count within the transmit FIFO buffer is less than or equal to the setting value of TXTH. + * | | |Note: If TXTHIEN = 1 and TXTHIF = 1, the SPI controller will generate a SPI interrupt request. + * |[19] |TXUFIF |Transmit FIFO Under-Run Interrupt Status + * | | |0 =No under-run interrupt event. + * | | |1 = Under-run interrupt occurred. + * | | |Note: When the transmit FIFO buffer is empty and there is no datum written into the FIFO buffer, if there is more bus clock input , the output data depends on the setting of SLVUDFPOL and this bit will be set to 1 and this bit will be cleared by writing 1 to it. + * |[23] |TXRXRST |FIFO CLR Status (Read Only) + * | | |0 = Done the FIFO buffer clear function of TXRST or RXRST. + * | | |1 = Doing the FIFO buffer clear function of TXRST or RXRST. + * | | |Note: Both the TXRST, RXRST, need 3 system clock + 3 peripheral clock , the status of this bit support the user to monitor the clear function is doing or done. + * |[24:27] |RXCNT |Receive FIFO Data Count (Read Only) + * | | |This bit field indicates the valid data count of receive FIFO buffer. + * |[28:31] |TXCNT |Transmit FIFO Data Count (Read Only) + * | | |This bit field indicates the valid data count of transmit FIFO buffer. + */ + __IO uint32_t STATUS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[2]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * TX + * =================================================================================================== + * Offset: 0x20 SPI Data Transmit Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |TX |Data Transmit Bits + * | | |The data transmit registers pass through the transmitted data into the 8-level transmit FIFO buffer. + * | | |The number of valid bits depends on the setting of transmit bit width field of the SPI_CTL register. + * | | |In Master mode, the serial data in SPI bus output need 5 module clock cycle when the data transmit registers pass through the transmitted data into the 8-level transmit FIFO buffer. + * | | |For example, if DWIDTH is set to 0x08, the bits TX[7:0] will be transmitted. + * | | |If DWIDTH is set to 0x00, the SPI controller will perform a 32-bit transfer. + */ + __O uint32_t TX; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[3]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * RX + * =================================================================================================== + * Offset: 0x30 SPI Data Receive Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |RX |Data Receive Bits + * | | |There is 8-level FIFO buffer in this controller. + * | | |The data receive register holds the earliest datum received from SPI data input pin. + * | | |If the RXEMPTY bit, SPI_STATUS[8], is not set to 1, the receive FIFO buffer can be accessed through software by reading this register. + * | | |This is a read only register. + */ + __I uint32_t RX; + +} SPI_T; + +/** + @addtogroup SPI_CONST SPI Bit Field Definition + Constant Definitions for SPI Controller +@{ */ + +#define SPI_CTL_SPIEN_Pos (0) /*!< SPI_T::CTL: SPIEN Position */ +#define SPI_CTL_SPIEN_Msk (0x1ul << SPI_CTL_SPIEN_Pos) /*!< SPI_T::CTL: SPIEN Mask */ + +#define SPI_CTL_RXNEG_Pos (1) /*!< SPI_T::CTL: RXNEG Position */ +#define SPI_CTL_RXNEG_Msk (0x1ul << SPI_CTL_RXNEG_Pos) /*!< SPI_T::CTL: RXNEG Mask */ + +#define SPI_CTL_TXNEG_Pos (2) /*!< SPI_T::CTL: TXNEG Position */ +#define SPI_CTL_TXNEG_Msk (0x1ul << SPI_CTL_TXNEG_Pos) /*!< SPI_T::CTL: TXNEG Mask */ + +#define SPI_CTL_CLKPOL_Pos (3) /*!< SPI_T::CTL: CLKPOL Position */ +#define SPI_CTL_CLKPOL_Msk (0x1ul << SPI_CTL_CLKPOL_Pos) /*!< SPI_T::CTL: CLKPOL Mask */ + +#define SPI_CTL_SUSPITV_Pos (4) /*!< SPI_T::CTL: SUSPITV Position */ +#define SPI_CTL_SUSPITV_Msk (0xful << SPI_CTL_SUSPITV_Pos) /*!< SPI_T::CTL: SUSPITV Mask */ + +#define SPI_CTL_DWIDTH_Pos (8) /*!< SPI_T::CTL: DWIDTH Position */ +#define SPI_CTL_DWIDTH_Msk (0x1ful << SPI_CTL_DWIDTH_Pos) /*!< SPI_T::CTL: DWIDTH Mask */ + +#define SPI_CTL_LSB_Pos (13) /*!< SPI_T::CTL: LSB Position */ +#define SPI_CTL_LSB_Msk (0x1ul << SPI_CTL_LSB_Pos) /*!< SPI_T::CTL: LSB Mask */ + +#define SPI_CTL_TWOBIT_Pos (16) /*!< SPI_T::CTL: TWOBIT Position */ +#define SPI_CTL_TWOBIT_Msk (0x1ul << SPI_CTL_TWOBIT_Pos) /*!< SPI_T::CTL: TWOBIT Mask */ + +#define SPI_CTL_UNITIEN_Pos (17) /*!< SPI_T::CTL: UNITIEN Position */ +#define SPI_CTL_UNITIEN_Msk (0x1ul << SPI_CTL_UNITIEN_Pos) /*!< SPI_T::CTL: UNITIEN Mask */ + +#define SPI_CTL_SLAVE_Pos (18) /*!< SPI_T::CTL: SLAVE Position */ +#define SPI_CTL_SLAVE_Msk (0x1ul << SPI_CTL_SLAVE_Pos) /*!< SPI_T::CTL: SLAVE Mask */ + +#define SPI_CTL_REORDER_Pos (19) /*!< SPI_T::CTL: REORDER Position */ +#define SPI_CTL_REORDER_Msk (0x1ul << SPI_CTL_REORDER_Pos) /*!< SPI_T::CTL: REORDER Mask */ + +#define SPI_CTL_QDIODIR_Pos (20) /*!< SPI_T::CTL: QDIODIR Position */ +#define SPI_CTL_QDIODIR_Msk (0x1ul << SPI_CTL_QDIODIR_Pos) /*!< SPI_T::CTL: QDIODIR Mask */ + +#define SPI_CTL_DUALIOEN_Pos (21) /*!< SPI_T::CTL: DUALIOEN Position */ +#define SPI_CTL_DUALIOEN_Msk (0x1ul << SPI_CTL_DUALIOEN_Pos) /*!< SPI_T::CTL: DUALIOEN Mask */ + +#define SPI_CTL_QUADIOEN_Pos (22) /*!< SPI_T::CTL: QUADIOEN Position */ +#define SPI_CTL_QUADIOEN_Msk (0x1ul << SPI_CTL_QUADIOEN_Pos) /*!< SPI_T::CTL: QUADIOEN Mask */ + +#define SPI_CLKDIV_DIVIDER_Pos (0) /*!< SPI_T::CLKDIV: DIVIDER Position */ +#define SPI_CLKDIV_DIVIDER_Msk (0xfful << SPI_CLKDIV_DIVIDER_Pos) /*!< SPI_T::CLKDIV: DIVIDER Mask */ + +#define SPI_SSCTL_SS_Pos (0) /*!< SPI_T::SSCTL: SS Position */ +#define SPI_SSCTL_SS_Msk (0x3ul << SPI_SSCTL_SS_Pos) /*!< SPI_T::SSCTL: SS Mask */ + +#define SPI_SSCTL_SSACTPOL_Pos (2) /*!< SPI_T::SSCTL: SSACTPOL Position */ +#define SPI_SSCTL_SSACTPOL_Msk (0x1ul << SPI_SSCTL_SSACTPOL_Pos) /*!< SPI_T::SSCTL: SSACTPOL Mask */ + +#define SPI_SSCTL_AUTOSS_Pos (3) /*!< SPI_T::SSCTL: AUTOSS Position */ +#define SPI_SSCTL_AUTOSS_Msk (0x1ul << SPI_SSCTL_AUTOSS_Pos) /*!< SPI_T::SSCTL: AUTOSS Mask */ + +#define SPI_SSCTL_SLV3WIRE_Pos (4) /*!< SPI_T::SSCTL: SLV3WIRE Position */ +#define SPI_SSCTL_SLV3WIRE_Msk (0x1ul << SPI_SSCTL_SLV3WIRE_Pos) /*!< SPI_T::SSCTL: SLV3WIRE Mask */ + +#define SPI_SSCTL_SLVTOIEN_Pos (5) /*!< SPI_T::SSCTL: SLVTOIEN Position */ +#define SPI_SSCTL_SLVTOIEN_Msk (0x1ul << SPI_SSCTL_SLVTOIEN_Pos) /*!< SPI_T::SSCTL: SLVTOIEN Mask */ + +#define SPI_SSCTL_SLVTORST_Pos (6) /*!< SPI_T::SSCTL: SLVTORST Position */ +#define SPI_SSCTL_SLVTORST_Msk (0x1ul << SPI_SSCTL_SLVTORST_Pos) /*!< SPI_T::SSCTL: SLVTORST Mask */ + +#define SPI_SSCTL_SLVBEIEN_Pos (8) /*!< SPI_T::SSCTL: SLVBEIEN Position */ +#define SPI_SSCTL_SLVBEIEN_Msk (0x1ul << SPI_SSCTL_SLVBEIEN_Pos) /*!< SPI_T::SSCTL: SLVBEIEN Mask */ + +#define SPI_SSCTL_SLVURIEN_Pos (9) /*!< SPI_T::SSCTL: SLVURIEN Position */ +#define SPI_SSCTL_SLVURIEN_Msk (0x1ul << SPI_SSCTL_SLVURIEN_Pos) /*!< SPI_T::SSCTL: SLVURIEN Mask */ + +#define SPI_SSCTL_SSACTIEN_Pos (12) /*!< SPI_T::SSCTL: SSACTIEN Position */ +#define SPI_SSCTL_SSACTIEN_Msk (0x1ul << SPI_SSCTL_SSACTIEN_Pos) /*!< SPI_T::SSCTL: SSACTIEN Mask */ + +#define SPI_SSCTL_SSINAIEN_Pos (13) /*!< SPI_T::SSCTL: SSINAIEN Position */ +#define SPI_SSCTL_SSINAIEN_Msk (0x1ul << SPI_SSCTL_SSINAIEN_Pos) /*!< SPI_T::SSCTL: SSINAIEN Mask */ + +#define SPI_SSCTL_SLVTOCNT_Pos (16) /*!< SPI_T::SSCTL: SLVTOCNT Position */ +#define SPI_SSCTL_SLVTOCNT_Msk (0xfffful << SPI_SSCTL_SLVTOCNT_Pos) /*!< SPI_T::SSCTL: SLVTOCNT Mask */ + +#define SPI_PDMACTL_TXPDMAEN_Pos (0) /*!< SPI_T::PDMACTL: TXPDMAEN Position */ +#define SPI_PDMACTL_TXPDMAEN_Msk (0x1ul << SPI_PDMACTL_TXPDMAEN_Pos) /*!< SPI_T::PDMACTL: TXPDMAEN Mask */ + +#define SPI_PDMACTL_RXPDMAEN_Pos (1) /*!< SPI_T::PDMACTL: RXPDMAEN Position */ +#define SPI_PDMACTL_RXPDMAEN_Msk (0x1ul << SPI_PDMACTL_RXPDMAEN_Pos) /*!< SPI_T::PDMACTL: RXPDMAEN Mask */ + +#define SPI_PDMACTL_PDMARST_Pos (2) /*!< SPI_T::PDMACTL: PDMARST Position */ +#define SPI_PDMACTL_PDMARST_Msk (0x1ul << SPI_PDMACTL_PDMARST_Pos) /*!< SPI_T::PDMACTL: PDMARST Mask */ + +#define SPI_FIFOCTL_RXRST_Pos (0) /*!< SPI_T::FIFOCTL: RXRST Position */ +#define SPI_FIFOCTL_RXRST_Msk (0x1ul << SPI_FIFOCTL_RXRST_Pos) /*!< SPI_T::FIFOCTL: RXRST Mask */ + +#define SPI_FIFOCTL_TXRST_Pos (1) /*!< SPI_T::FIFOCTL: TXRST Position */ +#define SPI_FIFOCTL_TXRST_Msk (0x1ul << SPI_FIFOCTL_TXRST_Pos) /*!< SPI_T::FIFOCTL: TXRST Mask */ + +#define SPI_FIFOCTL_RXTHIEN_Pos (2) /*!< SPI_T::FIFOCTL: RXTHIEN Position */ +#define SPI_FIFOCTL_RXTHIEN_Msk (0x1ul << SPI_FIFOCTL_RXTHIEN_Pos) /*!< SPI_T::FIFOCTL: RXTHIEN Mask */ + +#define SPI_FIFOCTL_TXTHIEN_Pos (3) /*!< SPI_T::FIFOCTL: TXTHIEN Position */ +#define SPI_FIFOCTL_TXTHIEN_Msk (0x1ul << SPI_FIFOCTL_TXTHIEN_Pos) /*!< SPI_T::FIFOCTL: TXTHIEN Mask */ + +#define SPI_FIFOCTL_RXTOIEN_Pos (4) /*!< SPI_T::FIFOCTL: RXTOIEN Position */ +#define SPI_FIFOCTL_RXTOIEN_Msk (0x1ul << SPI_FIFOCTL_RXTOIEN_Pos) /*!< SPI_T::FIFOCTL: RXTOIEN Mask */ + +#define SPI_FIFOCTL_RXOVIEN_Pos (5) /*!< SPI_T::FIFOCTL: RXOVIEN Position */ +#define SPI_FIFOCTL_RXOVIEN_Msk (0x1ul << SPI_FIFOCTL_RXOVIEN_Pos) /*!< SPI_T::FIFOCTL: RXOVIEN Mask */ + +#define SPI_FIFOCTL_TXUFPOL_Pos (6) /*!< SPI_T::FIFOCTL: TXUFPOL Position */ +#define SPI_FIFOCTL_TXUFPOL_Msk (0x1ul << SPI_FIFOCTL_TXUFPOL_Pos) /*!< SPI_T::FIFOCTL: TXUFPOL Mask */ + +#define SPI_FIFOCTL_TXUFIEN_Pos (7) /*!< SPI_T::FIFOCTL: TXUFIEN Position */ +#define SPI_FIFOCTL_TXUFIEN_Msk (0x1ul << SPI_FIFOCTL_TXUFIEN_Pos) /*!< SPI_T::FIFOCTL: TXUFIEN Mask */ + +#define SPI_FIFOCTL_RXTH_Pos (24) /*!< SPI_T::FIFOCTL: RXTH Position */ +#define SPI_FIFOCTL_RXTH_Msk (0x7ul << SPI_FIFOCTL_RXTH_Pos) /*!< SPI_T::FIFOCTL: RXTH Mask */ + +#define SPI_FIFOCTL_TXTH_Pos (28) /*!< SPI_T::FIFOCTL: TXTH Position */ +#define SPI_FIFOCTL_TXTH_Msk (0x7ul << SPI_FIFOCTL_TXTH_Pos) /*!< SPI_T::FIFOCTL: TXTH Mask */ + +#define SPI_STATUS_BUSY_Pos (0) /*!< SPI_T::STATUS: BUSY Position */ +#define SPI_STATUS_BUSY_Msk (0x1ul << SPI_STATUS_BUSY_Pos) /*!< SPI_T::STATUS: BUSY Mask */ + +#define SPI_STATUS_UNITIF_Pos (1) /*!< SPI_T::STATUS: UNITIF Position */ +#define SPI_STATUS_UNITIF_Msk (0x1ul << SPI_STATUS_UNITIF_Pos) /*!< SPI_T::STATUS: UNITIF Mask */ + +#define SPI_STATUS_SSACTIF_Pos (2) /*!< SPI_T::STATUS: SSACTIF Position */ +#define SPI_STATUS_SSACTIF_Msk (0x1ul << SPI_STATUS_SSACTIF_Pos) /*!< SPI_T::STATUS: SSACTIF Mask */ + +#define SPI_STATUS_SSINAIF_Pos (3) /*!< SPI_T::STATUS: SSINAIF Position */ +#define SPI_STATUS_SSINAIF_Msk (0x1ul << SPI_STATUS_SSINAIF_Pos) /*!< SPI_T::STATUS: SSINAIF Mask */ + +#define SPI_STATUS_SSLINE_Pos (4) /*!< SPI_T::STATUS: SSLINE Position */ +#define SPI_STATUS_SSLINE_Msk (0x1ul << SPI_STATUS_SSLINE_Pos) /*!< SPI_T::STATUS: SSLINE Mask */ + +#define SPI_STATUS_SLVTOIF_Pos (5) /*!< SPI_T::STATUS: SLVTOIF Position */ +#define SPI_STATUS_SLVTOIF_Msk (0x1ul << SPI_STATUS_SLVTOIF_Pos) /*!< SPI_T::STATUS: SLVTOIF Mask */ + +#define SPI_STATUS_SLVBEIF_Pos (6) /*!< SPI_T::STATUS: SLVBEIF Position */ +#define SPI_STATUS_SLVBEIF_Msk (0x1ul << SPI_STATUS_SLVBEIF_Pos) /*!< SPI_T::STATUS: SLVBEIF Mask */ + +#define SPI_STATUS_SLVUDRIF_Pos (7) /*!< SPI_T::STATUS: SLVUDRIF Position */ +#define SPI_STATUS_SLVUDRIF_Msk (0x1ul << SPI_STATUS_SLVUDRIF_Pos) /*!< SPI_T::STATUS: SLVUDRIF Mask */ + +#define SPI_STATUS_RXEMPTY_Pos (8) /*!< SPI_T::STATUS: RXEMPTY Position */ +#define SPI_STATUS_RXEMPTY_Msk (0x1ul << SPI_STATUS_RXEMPTY_Pos) /*!< SPI_T::STATUS: RXEMPTY Mask */ + +#define SPI_STATUS_RXFULL_Pos (9) /*!< SPI_T::STATUS: RXFULL Position */ +#define SPI_STATUS_RXFULL_Msk (0x1ul << SPI_STATUS_RXFULL_Pos) /*!< SPI_T::STATUS: RXFULL Mask */ + +#define SPI_STATUS_RXTHIF_Pos (10) /*!< SPI_T::STATUS: RXTHIF Position */ +#define SPI_STATUS_RXTHIF_Msk (0x1ul << SPI_STATUS_RXTHIF_Pos) /*!< SPI_T::STATUS: RXTHIF Mask */ + +#define SPI_STATUS_RXOVIF_Pos (11) /*!< SPI_T::STATUS: RXOVIF Position */ +#define SPI_STATUS_RXOVIF_Msk (0x1ul << SPI_STATUS_RXOVIF_Pos) /*!< SPI_T::STATUS: RXOVIF Mask */ + +#define SPI_STATUS_RXTOIF_Pos (12) /*!< SPI_T::STATUS: RXTOIF Position */ +#define SPI_STATUS_RXTOIF_Msk (0x1ul << SPI_STATUS_RXTOIF_Pos) /*!< SPI_T::STATUS: RXTOIF Mask */ + +#define SPI_STATUS_SPIENSTS_Pos (15) /*!< SPI_T::STATUS: SPIENSTS Position */ +#define SPI_STATUS_SPIENSTS_Msk (0x1ul << SPI_STATUS_SPIENSTS_Pos) /*!< SPI_T::STATUS: SPIENSTS Mask */ + +#define SPI_STATUS_TXEMPTY_Pos (16) /*!< SPI_T::STATUS: TXEMPTY Position */ +#define SPI_STATUS_TXEMPTY_Msk (0x1ul << SPI_STATUS_TXEMPTY_Pos) /*!< SPI_T::STATUS: TXEMPTY Mask */ + +#define SPI_STATUS_TXFULL_Pos (17) /*!< SPI_T::STATUS: TXFULL Position */ +#define SPI_STATUS_TXFULL_Msk (0x1ul << SPI_STATUS_TXFULL_Pos) /*!< SPI_T::STATUS: TXFULL Mask */ + +#define SPI_STATUS_TXTHIF_Pos (18) /*!< SPI_T::STATUS: TXTHIF Position */ +#define SPI_STATUS_TXTHIF_Msk (0x1ul << SPI_STATUS_TXTHIF_Pos) /*!< SPI_T::STATUS: TXTHIF Mask */ + +#define SPI_STATUS_TXUFIF_Pos (19) /*!< SPI_T::STATUS: TXUFIF Position */ +#define SPI_STATUS_TXUFIF_Msk (0x1ul << SPI_STATUS_TXUFIF_Pos) /*!< SPI_T::STATUS: TXUFIF Mask */ + +#define SPI_STATUS_TXRXRST_Pos (23) /*!< SPI_T::STATUS: TXRXRST Position */ +#define SPI_STATUS_TXRXRST_Msk (0x1ul << SPI_STATUS_TXRXRST_Pos) /*!< SPI_T::STATUS: TXRXRST Mask */ + +#define SPI_STATUS_RXCNT_Pos (24) /*!< SPI_T::STATUS: RXCNT Position */ +#define SPI_STATUS_RXCNT_Msk (0xful << SPI_STATUS_RXCNT_Pos) /*!< SPI_T::STATUS: RXCNT Mask */ + +#define SPI_STATUS_TXCNT_Pos (28) /*!< SPI_T::STATUS: TXCNT Position */ +#define SPI_STATUS_TXCNT_Msk (0xful << SPI_STATUS_TXCNT_Pos) /*!< SPI_T::STATUS: TXCNT Mask */ + +#define SPI_TX_TX_Pos (0) /*!< SPI_T::TX: TX Position */ +#define SPI_TX_TX_Msk (0xfffffffful << SPI_TX_TX_Pos) /*!< SPI_T::TX: TX Mask */ + +#define SPI_RX_RX_Pos (0) /*!< SPI_T::RX: RX Position */ +#define SPI_RX_RX_Msk (0xfffffffful << SPI_RX_RX_Pos) /*!< SPI_T::RX: RX Mask */ + +/**@}*/ /* SPI_CONST */ +/**@}*/ /* end of SPI register group */ + + +/*---------------------- System Manger Controller -------------------------*/ +/** + @addtogroup SYS System Manger Controller(SYS) + Memory Mapped Structure for SYS Controller +@{ */ + +typedef struct { + + + /** + * PDID + * =================================================================================================== + * Offset: 0x00 Part Device Identification Number Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |SYS_PDID |Part Device Identification Number + * | | |This register reflects device part number code. + * | | |S/W can read this register to identify which device is used. + */ + __I uint32_t PDID; + + /** + * RSTSTS + * =================================================================================================== + * Offset: 0x04 System Reset Source Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |PORF |The PORF Flag Is Set By The "Reset Signal" From The Power-On Reset (POR) Controller Or Bit CHIPRST (SYS_IPRST0[0]) To Indicate The Previous Reset Source + * | | |0 = No reset from POR or CHIPRST. + * | | |1 = Power-On Reset (POR) or CHIPRST had issued the reset signal to reset the system. + * | | |Note: Write 1 to clear this bit to 0. + * |[1] |PINRF |The PINRF Flag Is Set By The "Reset Signal" From The /RESET Pin To Indicate The Previous Reset Source + * | | |0 = No reset from /RESET pin. + * | | |1 = The Pin /RESET had issued the reset signal to reset the system. + * | | |Note: Write 1 to clear this bit to 0. + * |[2] |WDTRF |The WDTRF Flag Is Set By The "Reset Signal" From The Watchdog Timer To Indicate The Previous Reset Source + * | | |0 = No reset from watchdog timer. + * | | |1 = The watchdog timer had issued the reset signal to reset the system. + * | | |Note: Write 1 to clear this bit to 0. + * |[3] |LVRF |The LVRF Flag Is Set By The "Reset Signal" From The Low-Voltage-Reset Controller To Indicate The Previous Reset Source + * | | |0 = No reset from LVR. + * | | |1 = The LVR controller had issued the reset signal to reset the system. + * | | |Note: Write 1 to clear this bit to 0. + * |[4] |BODRF |The BODRF Flag Is Set By The "Reset Signal" From The Brown-Out-Detector To Indicate The Previous Reset Source + * | | |0 = No reset from BOD. + * | | |1 = The BOD had issued the reset signal to reset the system. + * | | |Note: Write 1 to clear this bit to 0. + * |[5] |SYSRF |The SYSRF Flag Is Set By The "Reset Signal" From The Cortex(TM)-M4 Core To Indicate The Previous Reset Source + * | | |0 = No reset from Cortex(TM)-M4. + * | | |1 = The Cortex(TM)-M4 had issued the reset signal to reset the system by writing 1 to the bit SYSRESETREQ(AIRCR[2], Application Interrupt and Reset Control Register, address = 0xE000ED0C) in system control registers of Cortex(TM)-M4 core. + * | | |Note: Write 1 to clear this bit to 0. + * |[7] |CPURF |The CPURF Flag Is Set By Hardware If Software Writes CPURST (SYS_IPRST0[1]) 1 To Reset Cortex(TM)-M4 Core And Flash Memory Controller (FMC) + * | | |0 = No reset from CPU. + * | | |1 = The Cortex(TM)-M4 Core and FMC are reset by software setting CPURST to 1. + * | | |Note: Write 1 to clear this bit to 0. + */ + __IO uint32_t RSTSTS; + + /** + * IPRST0 + * =================================================================================================== + * Offset: 0x08 Peripheral Controller Reset Control Register 1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CHIPRST |Chip One-Shot Reset (Write Protect) + * | | |Setting this bit will reset the whole chip, including Processor core and all peripherals, and this bit will automatically return to 0 after the 2 clock cycles. + * | | |The CHIPRST is same as the POR reset, all the chip controllers is reset and the chip setting from flash are also reload. + * | | |This bit is a write protected bit, which means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = Chip normal operation. + * | | |1 = Chip one shot reset. + * |[1] |CPURST |Processor Core One-Shot Reset (Write Protect) + * | | |Setting this bit will only reset the processor core and Flash Memory Controller(FMC), and this bit will automatically return to 0 after the 2 clock cycles + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = Processor core normal operation. + * | | |1 = Processor core one-shot reset. + * |[2] |PDMARST |PDMA Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the PDMA. + * | | |User needs to set this bit to 0 to release from reset state. + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = PDMA controller normal operation. + * | | |1 = PDMA controller reset. + * |[3] |EBIRST |EBI Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the EBI. + * | | |User needs to set this bit to 0 to release from the reset state. + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = EBI controller normal operation. + * | | |1 = EBI controller reset. + * |[4] |USBHRST |UHC Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the HSB HOST controller. + * | | |User needs to set this bit to 0 to release from the reset state. + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = UHC controller normal operation. + * | | |1 = UHC controller reset. + * |[5] |SDHRST |EMAC Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the EMAC controller. + * | | |User needs to set this bit to 0 to release from the reset state. + * | | |This bit is the protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = EMAC controller normal operation. + * | | |1 = EMAC controller reset. + * |[6] |SDHOST_RST|SD HOST Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the SD HOST controller. + * | | |User needs to set this bit to 0 to release from the reset state. + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = SD HOST controller normal operation. + * | | |1 = SD HOST controller reset. + * |[7] |CRCRST |CRC Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the CRC controller. + * | | |User needs to set this bit to 0 to release from the reset state. + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Reference the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = CRC controller normal operation. + * | | |1 = CRC controller reset. + * |[8] |CAPRST |Image Capture Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the CAP controller. + * | | |User needs to set this bit to 0 to release from the reset state. + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Reference the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = CAP controller normal operation. + * | | |1 = CAP controller reset. + * |[12] |CRPT_RST |CRYPTO Controller Reset (Write Protect) + * | | |Setting this bit to 1 will generate a reset signal to the CRYPTO controller. + * | | |User needs to set this bit to 0 to release from the reset state. + * | | |This bit is a write protected bit, It means programming this bit needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * | | |0 = CRYPTO controller normal operation. + * | | |1 = CRYPTO controller reset. + */ + __IO uint32_t IPRST0; + + /** + * IPRST1 + * =================================================================================================== + * Offset: 0x0C Peripheral Controller Reset Control Register 2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1] |GPIORST |GPIO Controller Reset + * | | |0 = GPIO controller normal operation. + * | | |1 = GPIO controller reset. + * |[2] |TMR0RST |Timer0 Controller Reset + * | | |0 = Timer0 controller normal operation. + * | | |1 = Timer0 controller reset. + * |[3] |TMR1RST |Timer1 Controller Reset + * | | |0 = Timer1 controller normal operation. + * | | |1 = Timer1 controller reset. + * |[4] |TMR2RST |Timer2 Controller Reset + * | | |0 = Timer2 controller normal operation. + * | | |1 = Timer2 controller reset. + * |[5] |TMR3RST |Timer3 Controller Reset + * | | |0 = Timer3 controller normal operation. + * | | |1 = Timer3 controller reset. + * |[7] |ACMPRST |Analog Comparator Controller Reset + * | | |0 = Analog Comparator controller normal operation. + * | | |1 = Analog Comparator controller reset. + * |[8] |I2C0RST |I2C0 Controller Reset + * | | |0 = I2C0 controller normal operation. + * | | |1 = I2C0 controller reset. + * |[9] |I2C1RST |I2C1 Controller Reset + * | | |0 = I2C1 controller normal operation. + * | | |1 = I2C1 controller reset. + * |[12] |SPI0RST |SPI0 Controller Reset + * | | |0 = SPI0 controller normal operation. + * | | |1 = SPI0 controller reset. + * |[13] |SPI1RST |SPI1 Controller Reset + * | | |0 = SPI1 controller normal operation. + * | | |1 = SPI1 controller reset. + * |[14] |SPI2RST |SPI2 Controller Reset + * | | |0 = SPI2 controller normal operation. + * | | |1 = SPI2 controller reset. + * |[15] |SPI3RST |SPI3 Controller Reset + * | | |0 = SPI3 controller normal operation. + * | | |1 = SPI3 controller reset. + * |[16] |UART0RST |UART0 Controller Reset + * | | |0 = UART0 controller normal operation. + * | | |1 = UART0 controller reset. + * |[17] |UART1RST |UART1 Controller Reset + * | | |0 = UART1 controller normal operation. + * | | |1 = UART1 controller reset. + * |[18] |UART2RST |UART2 Controller Reset + * | | |0 = UART2 controller normal operation. + * | | |1 = UART2 controller reset. + * |[19] |UART3RST |UART3 Controller Reset + * | | |0 = UART3 controller normal operation. + * | | |1 = UART3 controller reset. + * |[20] |UART4RST |UART4 Controller Reset + * | | |0 = UART4 controller normal operation. + * | | |1 = UART4 controller reset. + * |[21] |UART5RST |UART2 Controller Reset + * | | |0 = UART5 controller normal operation. + * | | |1 = UART5 controller reset. + * |[24] |CAN0RST |CAN0 Controller Reset + * | | |0 = CAN0 controller normal operation. + * | | |1 = CAN0 controller reset. + * |[25] |CAN1RST |CAN1 Controller Reset + * | | |0 = CAN1 controller normal operation. + * | | |1 = CAN1 controller reset. + * |[27] |USBDRST |USB Device Controller Reset + * | | |0 = USB device controller normal operation. + * | | |1 = USB device controller reset. + * |[28] |ADCRST |ADC Controller Reset + * | | |0 = ADC controller normal operation. + * | | |1 = ADC controller reset. + * |[29] |I2SRST |I2S Controller Reset + * | | |0 = I2S controller normal operation. + * | | |1 = I2S controller reset. + * |[30] |I2S1RST |I2S1 Controller Reset + * | | |0 = I2S1 controller normal operation. + * | | |1 = I2S1 controller reset. + * |[31] |PS2RST |PS/2 Controller Reset + * | | |0 = PS/2 controller normal operation. + * | | |1 = PS/2 controller reset. + */ + __IO uint32_t IPRST1; + + /** + * IPRST2 + * =================================================================================================== + * Offset: 0x10 Peripheral Controller Reset Control Register 3 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SC0RST |SC0 Controller Reset + * | | |0 = SC0 controller normal operation. + * | | |1 = SC0 controller reset. + * |[1] |SC1RST |SC1 Controller Reset + * | | |0 = SC1 controller normal operation. + * | | |1 = SC1 controller reset. + * |[2] |SC2RST |SC2 Controller Reset + * | | |0 = SC2 controller normal operation. + * | | |1 = SC2 controller reset. + * |[3] |SC3RST |SC3 Controller Reset + * | | |0 = SC3 controller normal operation. + * | | |1 = SC3 controller reset. + * |[4] |SC4RST |SC4 Controller Reset + * | | |0 = SC4 controller normal operation. + * | | |1 = SC4 controller reset. + * |[5] |SC5RST |SC5 Controller Reset + * | | |0 = SC5 controller normal operation. + * | | |1 = SC5 controller reset. + * |[8] |I2C4RST |I2C4 Controller Reset + * | | |0 = I2C4 controller normal operation. + * | | |1 = I2C4 controller reset. + * |[16] |PWM0RST |PWM0 Controller Reset + * | | |0 = PWM0 controller normal operation. + * | | |1 = PWM0 controller reset. + * |[17] |PWM1RST |PWM1 Controller Reset + * | | |0 = PWM1 controller normal operation. + * | | |1 = PWM1 controller reset. + * |[22] |QEI0RST |QEI0 Controller Reset + * | | |0 = QEI0 controller normal operation. + * | | |1 = QEI0 controller reset. + * |[23] |QEI1RST |QEI1 Controller Reset + * | | |0 = QEI1 controller normal operation. + * | | |1 = QEI1 controller reset. + */ + __IO uint32_t IPRST2; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * BODCTL + * =================================================================================================== + * Offset: 0x18 Brown-out Detector Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BODEN |Brown-Out Detector Enable Control (Write Protect) + * | | |The default value is set by flash controller user configuration register config0 bit[23] + * | | |0 = Brown-out Detector function Disabled. + * | | |1 = Brown-out Detector function Enabled. + * | | |This bit is the protected bit, which means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * |[1:2] |BODVL |Brown-Out Detector Threshold Voltage Selection (Write Protect) + * | | |The default value is set by flash controller user configuration register config0 bit[22:21] + * | | |Relationship between BODVL and Brown-out voltage listed below: + * | | |00 = 2.2V. + * | | |01 = 2.7V. + * | | |10 = 3.8V. + * | | |11 = 4.5V. + * | | |This bit is the protected bit, which means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * |[3] |BODRSTEN |Brown-Out Reset Enable Control (Write Protect) + * | | |While the Brown-out Detector function is enabled (BODEN high) and BOD reset function is enabled (BODRSTEN high), BOD will assert a signal to reset chip when the detected voltage is lower than the threshold (BODOUT high). + * | | |While the BOD function is enabled (BODEN high) and BOD interrupt function is enabled (BODRSTEN low), BOD will assert an interrupt if BODOUT is high. + * | | |BOD interrupt will keep till to the BODEN set to 0. + * | | |BOD interrupt can be blocked by disabling the NVIC BOD interrupt or disabling BOD function (set BODEN low). + * | | |The default value is set by flash controller user configuration register config0 bit[20]. + * | | |0 = Brown-out "INTERRUPT" function Enabled. + * | | |1 = Brown-out "RESET" function Enabled. + * | | |This bit is the protected bit, which means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * |[4] |BODINTF |Brown-Out Detector Interrupt Flag + * | | |0 = Brown-out Detector does not detect any voltage draft at VDD down through or up through the voltage of BODVL setting. + * | | |1 = When Brown-out Detector detects the VDD is dropped down through the voltage of BODVL setting or the VDD is raised up through the voltage of BODVL setting, this bit is set to 1 and the brown-out interrupt is requested if brown-out interrupt is enabled. + * | | |Note: Write 1 to clear this bit to 0. + * |[5] |BODLPM |Brown-Out Detector Low Power Mode (Write Protect) + * | | |The BOD consumes about 100uA in normal mode, the low power mode can reduce the current to about 1/10 but slow the BOD response. + * | | |0 = BOD operate in normal mode (default). + * | | |1 = BOD Low Power mode Enabled. + * | | |This bit is the protected bit, which means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + * |[6] |BODOUT |Brown-Out Detector Output Status + * | | |0 = Brown-out Detector output status is 0. + * | | |It means the detected voltage is higher than BODVL setting or BODEN is 0. + * | | |1 = Brown-out Detector output status is 1. + * | | |It means the detected voltage is lower than BODVL setting. + * | | |If the BODEN is 0, BOD function disabled , this bit always responds 0000. + * |[7] |LVREN |Low Voltage Reset Enable Control (Write Protect) + * | | |The LVR function reset the chip when the input power voltage is lower than LVR circuit setting. + * | | |LVR function is enabled in default. + * | | |0 = Low Voltage Reset function Disabled. + * | | |1 = Low Voltage Reset function Enabled - After enabling the bit, the LVR function will be active with 100uS delay for LVR output stable (default). + * | | |This bit is the protected bit, which means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + */ + __IO uint32_t BODCTL; + + /** + * TEMPCTL + * =================================================================================================== + * Offset: 0x1C Temperature Sensor Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |VTEMPEN |Temperature Sensor Enable Control + * | | |This bit is used to enable/disable temperature sensor function. + * | | |0 = Temperature sensor function Disabled (default). + * | | |1 = Temperature sensor function Enabled. + * | | |After this bit is set to 1, the value of temperature sensor output can be obtained from ADC conversion result. + * | | |Please refer to ADC function chapter for details. + */ + __IO uint32_t TEMPCTL; + + /** + * VCID + * =================================================================================================== + * Offset: 0x20 Hardware Version Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |VCID |Hardware Version Control (Ready Only) + * | | |These registers repress hardware version. + * | | |These bits are the read protected bits. + * | | |It means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + */ + __I uint32_t VCID; + + /** + * PORCTL + * =================================================================================================== + * Offset: 0x24 Power-On-Reset Controller Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |POROFF |Power-On-Reset Enable Control (Write Protect) + * | | |When power on, the POR circuit generates a reset signal to reset the whole chip function, but noise on the power may cause the POR active again. + * | | |User can disable internal POR circuit to avoid unpredictable noise to cause chip reset by writing 0x5AA5 to this field. + * | | |The POR function will be active again when this field is set to another value or chip is reset by other reset source, including: + * | | |/RESET, Watch dog, LVR reset, BOD reset, ICE reset command and the software-chip reset function + * | | |This bit is the protected bit, which means programming this needs to write "59h", "16h", "88h" to address 0x4000_0100 to disable register protection. + * | | |Refer to the register SYS_REGLCTL at address GCR_BA+0x100. + */ + __IO uint32_t PORCTL; + + /** + * VREFCTL + * =================================================================================================== + * Offset: 0x28 ADC VREF Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:4] |VREFCTL |Vref control bits (Write Protect) + * | | |00011=Vref is internal 2.65V + * | | |00111=Vref is internal 2.048V + * | | |01011=Vref is internal 3.072V + * | | |01111=Vref is internal 4.096V + * | | |10000=Vref is from AVDD + * | | |Others=Reserved + * |[8] |ADCMODESEL|ADC IP Selection (Write Protect) + * | | |0 = ADC mode. + * | | |1 = E ADC mode. + * |[9] |PWMSYNCMODE|PWM SYNC MODE (Write Protect) + * | | |0 = PWM SYNC MODE Disabled; PWM engine clock can different with HCLK. + * | | |1 = PWM SYNC MODE Enabled; PWM engine clock is same as HCLK. + */ + __IO uint32_t VREFCTL; + + /** + * USBPHY + * =================================================================================================== + * Offset: 0x2C USB PHY Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |USBROLE |USB Role Configuration (Write Protect) + * | | |USB role configuration can be from ROMMAP or software setting if software setting option, controlled by ROMMAP, is enabled. + * | | |00 = Standard USB device. + * | | |01 = Standard USB host. + * | | |10 = ID dependent device. + * | | |11 = On-The-Go device. + * |[8] |LDO33EN |LDO33 Enable Control (Write Protect) + * | | |0 = USB LDO33 Disabled. + * | | |1 = USB LDO33 Enabled. + */ + __IO uint32_t USBPHY; + + /** + * GPA_MFPL + * =================================================================================================== + * Offset: 0x30 Port A Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PA0MFP |PA.0 Multi-function Pin Selection + * |[4:7] |PA1MFP |PA.1 Multi-function Pin Selection + * |[8:11] |PA2MFP |PA.2 Multi-function Pin Selection + * |[12:15] |PA3MFP |PA.3 Multi-function Pin Selection + * |[16:19] |PA4MFP |PA.4 Multi-function Pin Selection + * |[20:23] |PA5MFP |PA.5 Multi-function Pin Selection + * |[24:27] |PA6MFP |PA.6 Multi-function Pin Selection + * |[28:31] |PA7MFP |PA.7 Multi-function Pin Selection + */ + __IO uint32_t GPA_MFPL; + + /** + * GPA_MFPH + * =================================================================================================== + * Offset: 0x34 Port A High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PA8MFP |PA.8 Multi-function Pin Selection + * |[4:7] |PA9MFP |PA.9 Multi-function Pin Selection + * |[8:11] |PA10MFP |PA.10 Multi-function Pin Selection + * |[12:15] |PA11MFP |PA.11 Multi-function Pin Selection + * |[16:19] |PA12MFP |PA.12 Multi-function Pin Selection + * |[20:23] |PA13MFP |PA.13 Multi-function Pin Selection + * |[24:27] |PA14MFP |PA.14 Multi-function Pin Selection + * |[28:31] |PA15MFP |PA.15 Multi-function Pin Selection + */ + __IO uint32_t GPA_MFPH; + + /** + * GPB_MFPL + * =================================================================================================== + * Offset: 0x38 Port B Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PB0MFP |PB.0 Multi-function Pin Selection + * |[4:7] |PB1MFP |PB.1 Multi-function Pin Selection + * |[8:11] |PB2MFP |PB.2 Multi-function Pin Selection + * |[12:15] |PB3MFP |PB.3 Multi-function Pin Selection + * |[16:19] |PB4MFP |PB.4 Multi-function Pin Selection + * |[20:23] |PB5MFP |PB.5 Multi-function Pin Selection + * |[24:27] |PB6MFP |PB.6 Multi-function Pin Selection + * |[28:31] |PB7MFP |PB.7 Multi-function Pin Selection + */ + __IO uint32_t GPB_MFPL; + + /** + * GPB_MFPH + * =================================================================================================== + * Offset: 0x3C Port B High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PB8MFP |PB.8 Multi-function Pin Selection + * |[4:7] |PB9MFP |PB.9 Multi-function Pin Selection + * |[8:11] |PB10MFP |PB.10 Multi-function Pin Selection + * |[12:15] |PB11MFP |PB.11 Multi-function Pin Selection + * |[16:19] |PB12MFP |PB.12 Multi-function Pin Selection + * |[20:23] |PB13MFP |PB.13 Multi-function Pin Selection + * |[24:27] |PB14MFP |PB.14 Multi-function Pin Selection + * |[28:31] |PB15MFP |PB.15 Multi-function Pin Selection + */ + __IO uint32_t GPB_MFPH; + + /** + * GPC_MFPL + * =================================================================================================== + * Offset: 0x40 Port C Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PC0MFP |PC.0 Multi-function Pin Selection + * |[4:7] |PC1MFP |PC.1 Multi-function Pin Selection + * |[8:11] |PC2MFP |PC.2 Multi-function Pin Selection + * |[12:15] |PC3MFP |PC.3 Multi-function Pin Selection + * |[16:19] |PC4MFP |PC.4 Multi-function Pin Selection + * |[20:23] |PC5MFP |PC.5 Multi-function Pin Selection + * |[24:27] |PC6MFP |PC.6 Multi-function Pin Selection + * |[28:31] |PC7MFP |PC.7 Multi-function Pin Selection + */ + __IO uint32_t GPC_MFPL; + + /** + * GPC_MFPH + * =================================================================================================== + * Offset: 0x44 Port C High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PC8MFP |PC.8 Multi-function Pin Selection + * |[4:7] |PC9MFP |PC.9 Multi-function Pin Selection + * |[8:11] |PC10MFP |PC.10 Multi-function Pin Selection + * |[12:15] |PC11MFP |PC.11 Multi-function Pin Selection + * |[16:19] |PC12MFP |PC.12 Multi-function Pin Selection + * |[20:23] |PC13MFP |PC.13 Multi-function Pin Selection + * |[24:27] |PC14MFP |PC.14 Multi-function Pin Selection + * |[28:31] |PC15MFP |PC.15 Multi-function Pin Selection + */ + __IO uint32_t GPC_MFPH; + + /** + * GPD_MFPL + * =================================================================================================== + * Offset: 0x48 Port D Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PD0MFP |PD.0 Multi-function Pin Selection + * |[4:7] |PD1MFP |PD.1 Multi-function Pin Selection + * |[8:11] |PD2MFP |PD.2 Multi-function Pin Selection + * |[12:15] |PD3MFP |PD.3 Multi-function Pin Selection + * |[16:19] |PD4MFP |PD.4 Multi-function Pin Selection + * |[20:23] |PD5MFP |PD.5 Multi-function Pin Selection + * |[24:27] |PD6MFP |PD.6 Multi-function Pin Selection + * |[28:31] |PD7MFP |PD.7 Multi-function Pin Selection + */ + __IO uint32_t GPD_MFPL; + + /** + * GPD_MFPH + * =================================================================================================== + * Offset: 0x4C Port D High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PD8MFP |PD.8 Multi-function Pin Selection + * |[4:7] |PD9MFP |PD.9 Multi-function Pin Selection + * |[8:11] |PD10MFP |PD.10 Multi-function Pin Selection + * |[12:15] |PD11MFP |PD.11 Multi-function Pin Selection + * |[16:19] |PD12MFP |PD.12 Multi-function Pin Selection + * |[20:23] |PD13MFP |PD.13 Multi-function Pin Selection + * |[24:27] |PD14MFP |PD.14 Multi-function Pin Selection + * |[28:31] |PD15MFP |PD.15 Multi-function Pin Selection + */ + __IO uint32_t GPD_MFPH; + + /** + * GPE_MFPL + * =================================================================================================== + * Offset: 0x50 Port E Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PE0MFP |PE.0 Multi-function Pin Selection + * |[4:7] |PE1MFP |PE.1 Multi-function Pin Selection + * |[8:11] |PE2MFP |PE.2 Multi-function Pin Selection + * |[12:15] |PE3MFP |PE.3 Multi-function Pin Selection + * |[16:19] |PE4MFP |PE.4 Multi-function Pin Selection + * |[20:23] |PE5MFP |PE.5 Multi-function Pin Selection + * |[24:27] |PE6MFP |PE.6 Multi-function Pin Selection + * |[28:31] |PE7MFP |PE.7 Multi-function Pin Selection + */ + __IO uint32_t GPE_MFPL; + + /** + * GPE_MFPH + * =================================================================================================== + * Offset: 0x54 Port E High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PE8MFP |PE.8 Multi-function Pin Selection + * |[4:7] |PE9MFP |PE.9 Multi-function Pin Selection + * |[8:11] |PE10MFP |PE.10 Multi-function Pin Selection + * |[12:15] |PE11MFP |PE.11 Multi-function Pin Selection + * |[16:19] |PE12MFP |PE.12 Multi-function Pin Selection + * |[20:23] |PE13MFP |PE.13 Multi-function Pin Selection + * |[24:27] |PE14MFP |PE.14 Multi-function Pin Selection + * |[28:31] |PE15MFP |PE.15 Multi-function Pin Selection + */ + __IO uint32_t GPE_MFPH; + + /** + * GPF_MFPL + * =================================================================================================== + * Offset: 0x58 Port F Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PF0MFP |PF.0 Multi-function Pin Selection + * |[4:7] |PF1MFP |PF.1 Multi-function Pin Selection + * |[8:11] |PF2MFP |PF.2 Multi-function Pin Selection + * |[12:15] |PF3MFP |PF.3 Multi-function Pin Selection + * |[16:19] |PF4MFP |PF.4 Multi-function Pin Selection + * |[20:23] |PF5MFP |PF.5 Multi-function Pin Selection + * |[24:27] |PF6MFP |PF.6 Multi-function Pin Selection + * |[28:31] |PF7MFP |PF.7 Multi-function Pin Selection + */ + __IO uint32_t GPF_MFPL; + + /** + * GPF_MFPH + * =================================================================================================== + * Offset: 0x5C Port F High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PF8MFP |PF.8 Multi-function Pin Selection + * |[4:7] |PF9MFP |PF.9 Multi-function Pin Selection + * |[8:11] |PF10MFP |PF.10 Multi-function Pin Selection + * |[12:15] |PF11MFP |PF.11 Multi-function Pin Selection + * |[16:19] |PF12MFP |PF.12 Multi-function Pin Selection + * |[20:23] |PF13MFP |PF.13 Multi-function Pin Selection + * |[24:27] |PF14MFP |PF.14 Multi-function Pin Selection + * |[28:31] |PF15MFP |PF.15 Multi-function Pin Selection + */ + __IO uint32_t GPF_MFPH; + + /** + * GPG_MFPL + * =================================================================================================== + * Offset: 0x60 Port G Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PG0MFP |PG.0 Multi-function Pin Selection + * |[4:7] |PG1MFP |PG.1 Multi-function Pin Selection + * |[8:11] |PG2MFP |PG.2 Multi-function Pin Selection + * |[12:15] |PG3MFP |PG.3 Multi-function Pin Selection + * |[16:19] |PG4MFP |PG.4 Multi-function Pin Selection + * |[20:23] |PG5MFP |PG.5 Multi-function Pin Selection + * |[24:27] |PG6MFP |PG.6 Multi-function Pin Selection + * |[28:31] |PG7MFP |PG.7 Multi-function Pin Selection + */ + __IO uint32_t GPG_MFPL; + + /** + * GPG_MFPH + * =================================================================================================== + * Offset: 0x64 Port G High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PG8MFP |PG.8 Multi-function Pin Selection + * |[4:7] |PG9MFP |PG.9 Multi-function Pin Selection + * |[8:11] |PG10MFP |PG.10 Multi-function Pin Selection + * |[12:15] |PG11MFP |PG.11 Multi-function Pin Selection + * |[16:19] |PG12MFP |PG.12 Multi-function Pin Selection + * |[20:23] |PG13MFP |PG.13 Multi-function Pin Selection + * |[24:27] |PG14MFP |PG.14 Multi-function Pin Selection + * |[28:31] |PG15MFP |PG.15 Multi-function Pin Selection + */ + __IO uint32_t GPG_MFPH; + + /** + * GPH_MFPL + * =================================================================================================== + * Offset: 0x68 Port H Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PH0MFP |PH.0 Multi-function Pin Selection + * |[4:7] |PH1MFP |PH.1 Multi-function Pin Selection + * |[8:11] |PH2MFP |PH.2 Multi-function Pin Selection + * |[12:15] |PH3MFP |PH.3 Multi-function Pin Selection + * |[16:19] |PH4MFP |PH.4 Multi-function Pin Selection + * |[20:23] |PH5MFP |PH.5 Multi-function Pin Selection + * |[24:27] |PH6MFP |PH.6 Multi-function Pin Selection + * |[28:31] |PH7MFP |PH.7 Multi-function Pin Selection + */ + __IO uint32_t GPH_MFPL; + + /** + * GPH_MFPH + * =================================================================================================== + * Offset: 0x6C Port H High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PH8MFP |PH.8 Multi-function Pin Selection + * |[4:7] |PH9MFP |PH.9 Multi-function Pin Selection + * |[8:11] |PH10MFP |PH.10 Multi-function Pin Selection + * |[12:15] |PH11MFP |PH.11 Multi-function Pin Selection + * |[16:19] |PH12MFP |PH.12 Multi-function Pin Selection + * |[20:23] |PH13MFP |PH.13 Multi-function Pin Selection + * |[24:27] |PH14MFP |PH.14 Multi-function Pin Selection + * |[28:31] |PH15MFP |PH.15 Multi-function Pin Selection + */ + __IO uint32_t GPH_MFPH; + + /** + * GPI_MFPL + * =================================================================================================== + * Offset: 0x70 Port I Low Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PI0MFP |PI.0 Multi-function Pin Selection + * |[4:7] |PI1MFP |PI.1 Multi-function Pin Selection + * |[8:11] |PI2MFP |PI.2 Multi-function Pin Selection + * |[12:15] |PI3MFP |PI.3 Multi-function Pin Selection + * |[16:19] |PI4MFP |PI.4 Multi-function Pin Selection + * |[20:23] |PI5MFP |PI.5 Multi-function Pin Selection + * |[24:27] |PI6MFP |PI.6 Multi-function Pin Selection + * |[28:31] |PI7MFP |PI.7 Multi-function Pin Selection + */ + __IO uint32_t GPI_MFPL; + + /** + * GPI_MFPH + * =================================================================================================== + * Offset: 0x74 Port I High Byte Multi-function Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |PI8MFP |PI.8 Multi-function Pin Selection + * |[4:7] |PI9MFP |PI.9 Multi-function Pin Selection + * |[8:11] |PI10MFP |PI.10 Multi-function Pin Selection + * |[12:15] |PI11MFP |PI.11 Multi-function Pin Selection + * |[16:19] |PI12MFP |PI.12 Multi-function Pin Selection + * |[20:23] |PI13MFP |PI.13 Multi-function Pin Selection + * |[24:27] |PI14MFP |PI.14 Multi-function Pin Selection + * |[28:31] |PI15MFP |PI.15 Multi-function Pin Selection + */ + __IO uint32_t GPI_MFPH; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[18]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * SRAM_INTCTL + * =================================================================================================== + * Offset: 0xC0 SRAM Failed Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |PERRIEN |SRAM Parity Check Fail Interrupt Enable Control + * | | |0 = SRAMF INT Disabled. + * | | |1 = SRAMF INT Enabled when SRAM fail flag. + */ + __IO uint32_t SRAM_INTCTL; + + /** + * SRAM_STATUS + * =================================================================================================== + * Offset: 0xC4 SRAM Parity Check Error Flag + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |PERRIF0 |SRAM Parity Check Fail Flag + * | | |0 = No first 1 SRAM fail. + * | | |1 = First SRAM Fail. + * |[1] |PERRIF1 |SRAM Parity Check Fail Flag + * | | |0 = 2nd SRAM fail. + * | | |1 = 2nd SRAM Fail. + */ + __IO uint32_t SRAM_STATUS; + + /** + * SRAM0_ERRADDR + * =================================================================================================== + * Offset: 0xC8 SRAM Parity Check Error First Address1 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |PERRADDR |First SRAM parity check fail address + */ + __I uint32_t SRAM0_ERRADDR; + + /** + * SRAM1_ERRADDR + * =================================================================================================== + * Offset: 0xCC SRAM Parity Check Error First Address2 + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |PERRADDR |2nd + * | | |SRAM parity check fail address + */ + __I uint32_t SRAM1_ERRADDR; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[8]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * IRCTCTL + * =================================================================================================== + * Offset: 0xF0 IRC Trim Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |FREQSEL |Trim Frequency Selection + * | | |This field indicates the target frequency of HIRC auto trim. + * | | |If no any target frequency is selected (FREQSEL is 00), the HIRC auto trim function is disabled. + * | | |During auto trim operation, if clock error detected with CESTOPEN is set to 1 or trim retry limitation count reached, this field will be cleared to 00 automatically. + * | | |00 = Disable HIRC auto trim function. + * | | |01 = Enable HIRC auto trim function and trim HIRC to 22.1184 MHz. + * | | |10 = Enable HIRC auto trim function and trim HIRC to 24 MHz. + * | | |11 = Reserved. + * |[4:5] |LOOPSEL |Trim Calculation Loop + * | | |This field defines that trim value calculation is based on how many 32.768 kHz clock. + * | | |For example, if CALCLOOP is set as 00, auto trim circuit will calculate trim value based on the average frequency difference in 4 32.768 kHz clock. + * | | |00 = Trim value calculation is based on average difference in 4 32.768 kHz clock. + * | | |01 = Trim value calculation is based on average difference in 8 32.768 kHz clock. + * | | |10 = Trim value calculation is based on average difference in 16 32.768 kHz clock. + * | | |11 = Trim value calculation is based on average difference in 32 32.768 kHz clock. + * |[6:7] |RETRYCNT |Trim Value Update Limitation Count + * | | |This field defines that how many times the auto trim circuit will try to update the HIRC trim value before the frequency of HIRC locked. + * | | |Once the HIRC locked, the internal trim value update counter will be reset. + * | | |If the trim value update counter reached this limitation value and frequency of HIRC still doesn't lock, the auto trim operation will be disabled and FREQSEL will be cleared to 00. + * | | |00 = Trim retry count limitation is 64. + * | | |01 = Trim retry count limitation is 128. + * | | |10 = Trim retry count limitation is 256. + * | | |11 = Trim retry count limitation is 512. + * |[8] |CESTOPEN |Clock Error Stop Enable Control + * | | |0 = The trim operation is keep going if clock is inaccuracy. + * | | |1 = The trim operation is stopped if clock is inaccuracy. + */ + __IO uint32_t IRCTCTL; + + /** + * IRCTIEN + * =================================================================================================== + * Offset: 0xF4 IRC Trim Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1] |TFAILIEN |Trim Failure Interrupt Enable + * | | |This bit controls if an interrupt will be triggered while HIRC trim value update limitation count reached and HIRC frequency still not locked on target frequency set by FREQSEL. + * | | |If this bit is high and TFAILIF is set during auto trim operation, an interrupt will be triggered to notify that HIRC trim value update limitation count was reached. + * | | |0 = Disable TFAILIF status to trigger an interrupt to CPU. + * | | |1 = Enable TFAILIF status to trigger an interrupt to CPU. + * |[2] |CLKEIEN |Clock Error Interrupt Enable Control + * | | |This bit controls if CPU would get an interrupt while clock is inaccuracy during auto trim operation. + * | | |If this bit is set to1, and CLKERRIF is set during auto trim operation, an interrupt will be triggered to notify the clock frequency is inaccuracy. + * | | |0 = Disable CLKERRIF status to trigger an interrupt to CPU. + * | | |1 = Enable CLKERRIF status to trigger an interrupt to CPU. + */ + __IO uint32_t IRCTIEN; + + /** + * IRCTISTS + * =================================================================================================== + * Offset: 0xF8 IRC Trim Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |FREQLOCK |HIRC Frequency Lock Status + * | | |This bit indicates the HIRC frequency is locked. + * | | |This is a status bit and doesn't trigger any interrupt. + * |[1] |TFAILIF |Trim Failure Interrupt Status + * | | |This bit indicates that HIRC trim value update limitation count reached and the HIRC clock frequency still doesn't be locked. + * | | |Once this bit is set, the auto trim operation stopped and FREQSEL will be cleared to 00 by hardware automatically. + * | | |If this bit is set and TFAILIEN is high, an interrupt will be triggered to notify that HIRC trim value update limitation count was reached. + * | | |Write 1 to clear this to 0. + * | | |0 = Trim value update limitation count does not reach. + * | | |1 = Trim value update limitation count reached and HIRC frequency still not locked. + * |[2] |CLKERRIF |Clock Error Interrupt Status + * | | |When the frequency of external 32.768 kHz low-speed crystal or HIRC is shift larger to unreasonable value, this bit will be set and to be an indicate that clock frequency is inaccuracy + * | | |Once this bit is set to 1, the auto trim operation stopped and FREQSEL will be cleared to 00 by hardware automatically if CESTOPEN is set to 1. + * | | |If this bit is set and CLKEIEN is high, an interrupt will be triggered to notify the clock frequency is inaccuracy. + * | | |Write 1 to clear this to 0. + * | | |0 = Clock frequency is accuracy. + * | | |1 = Clock frequency is inaccuracy. + */ + __IO uint32_t IRCTISTS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE3[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * REGLCTL + * =================================================================================================== + * Offset: 0x100 Register Write-Protection Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |REGLCTL |Register Write-Protection Disable Index (Read Only) + * | | |0 = Write-protection Enabled for writing protected registers. + * | | |Any write to the protected register is ignored. + * | | |1 = Write-protection Disabled for writing protected registers. + * | | |The Protected registers are: + * | | |SYS_IPRST0: address 0x4000_0008 + * | | |SYS_BODCTL: address 0x4000_0018 + * | | |SYS_PORCTL: address 0x4000_0024 + * | | |PWRCON: address 0x4000_0200 (bit[6] is not protected for power wake-up interrupt clear) + * | | |APBCLK bit[0]: address 0x4000_0208 (bit[0] is watchdog clock enable) + * | | |CLKSEL0: address 0x4000_0210 (for HCLK and CPU STCLK clock source select) + * | | |CLKSEL1 bit[1:0]: address 0x4000_0214 (for watchdog clock source select) + * | | |NMI_SEL]: address 0x4000_0300 (for NMI source select) + * | | |ISPCON: address 0x4000_5000 (Flash ISP Control register) + * | | |ISPTRG: address 0x4000_5010 (ISP Trigger Control register) + * | | |WTCR: address 0x4004_0000 + * | | |FATCON: address 0x4000_5018 + * | | |TAMPER: address 0x400E_1000 + * |[0:7] |SYS_REGLCTL|Register Write-Protection Code (Write Only) + * | | |Some registers have write-protection function. + * | | |Writing these registers have to disable the protected function by writing the sequence value "59h", "16h", "88h" to this field. + * | | |After this sequence is completed, the REGLCTL bit will be set to 1 and write-protection registers can be normal write. + */ + __IO uint32_t REGLCTL; + +} SYS_T; + +/** + @addtogroup SYS_CONST SYS Bit Field Definition + Constant Definitions for SYS Controller +@{ */ + +#define SYS_PDID_SYS_PDID_Pos (0) /*!< SYS_T::PDID: SYS_PDID Position */ +#define SYS_PDID_SYS_PDID_Msk (0xfffffffful << SYS_PDID_SYS_PDID_Pos) /*!< SYS_T::PDID: SYS_PDID Mask */ + +#define SYS_RSTSTS_PORF_Pos (0) /*!< SYS_T::RSTSTS: PORF Position */ +#define SYS_RSTSTS_PORF_Msk (0x1ul << SYS_RSTSTS_PORF_Pos) /*!< SYS_T::RSTSTS: PORF Mask */ + +#define SYS_RSTSTS_PINRF_Pos (1) /*!< SYS_T::RSTSTS: PINRF Position */ +#define SYS_RSTSTS_PINRF_Msk (0x1ul << SYS_RSTSTS_PINRF_Pos) /*!< SYS_T::RSTSTS: PINRF Mask */ + +#define SYS_RSTSTS_WDTRF_Pos (2) /*!< SYS_T::RSTSTS: WDTRF Position */ +#define SYS_RSTSTS_WDTRF_Msk (0x1ul << SYS_RSTSTS_WDTRF_Pos) /*!< SYS_T::RSTSTS: WDTRF Mask */ + +#define SYS_RSTSTS_LVRF_Pos (3) /*!< SYS_T::RSTSTS: LVRF Position */ +#define SYS_RSTSTS_LVRF_Msk (0x1ul << SYS_RSTSTS_LVRF_Pos) /*!< SYS_T::RSTSTS: LVRF Mask */ + +#define SYS_RSTSTS_BODRF_Pos (4) /*!< SYS_T::RSTSTS: BODRF Position */ +#define SYS_RSTSTS_BODRF_Msk (0x1ul << SYS_RSTSTS_BODRF_Pos) /*!< SYS_T::RSTSTS: BODRF Mask */ + +#define SYS_RSTSTS_SYSRF_Pos (5) /*!< SYS_T::RSTSTS: SYSRF Position */ +#define SYS_RSTSTS_SYSRF_Msk (0x1ul << SYS_RSTSTS_SYSRF_Pos) /*!< SYS_T::RSTSTS: SYSRF Mask */ + +#define SYS_RSTSTS_CPURF_Pos (7) /*!< SYS_T::RSTSTS: CPURF Position */ +#define SYS_RSTSTS_CPURF_Msk (0x1ul << SYS_RSTSTS_CPURF_Pos) /*!< SYS_T::RSTSTS: CPURF Mask */ + +#define SYS_IPRST0_CHIPRST_Pos (0) /*!< SYS_T::IPRST0: CHIPRST Position */ +#define SYS_IPRST0_CHIPRST_Msk (0x1ul << SYS_IPRST0_CHIPRST_Pos) /*!< SYS_T::IPRST0: CHIPRST Mask */ + +#define SYS_IPRST0_CPURST_Pos (1) /*!< SYS_T::IPRST0: CPURST Position */ +#define SYS_IPRST0_CPURST_Msk (0x1ul << SYS_IPRST0_CPURST_Pos) /*!< SYS_T::IPRST0: CPURST Mask */ + +#define SYS_IPRST0_PDMARST_Pos (2) /*!< SYS_T::IPRST0: PDMARST Position */ +#define SYS_IPRST0_PDMARST_Msk (0x1ul << SYS_IPRST0_PDMARST_Pos) /*!< SYS_T::IPRST0: PDMARST Mask */ + +#define SYS_IPRST0_EBIRST_Pos (3) /*!< SYS_T::IPRST0: EBIRST Position */ +#define SYS_IPRST0_EBIRST_Msk (0x1ul << SYS_IPRST0_EBIRST_Pos) /*!< SYS_T::IPRST0: EBIRST Mask */ + +#define SYS_IPRST0_USBHRST_Pos (4) /*!< SYS_T::IPRST0: USBHRST Position */ +#define SYS_IPRST0_USBHRST_Msk (0x1ul << SYS_IPRST0_USBHRST_Pos) /*!< SYS_T::IPRST0: USBHRST Mask */ + +#define SYS_IPRST0_EMACRST_Pos (5) /*!< SYS_T::IPRST0: EMACRST Position */ +#define SYS_IPRST0_EMACRST_Msk (0x1ul << SYS_IPRST0_EMACRST_Pos) /*!< SYS_T::IPRST0: EMACRST Mask */ + +#define SYS_IPRST0_SDHRST_Pos (6) /*!< SYS_T::IPRST0: SDHRST Position */ +#define SYS_IPRST0_SDHRST_Msk (0x1ul << SYS_IPRST0_SDHRST_Pos) /*!< SYS_T::IPRST0: SDHRST Mask */ + +#define SYS_IPRST0_CRCRST_Pos (7) /*!< SYS_T::IPRST0: CRCRST Position */ +#define SYS_IPRST0_CRCRST_Msk (0x1ul << SYS_IPRST0_CRCRST_Pos) /*!< SYS_T::IPRST0: CRCRST Mask */ + +#define SYS_IPRST0_CAPRST_Pos (8) /*!< SYS_T::IPRST0: CAPRST Position */ +#define SYS_IPRST0_CAPRST_Msk (0x1ul << SYS_IPRST0_CAPRST_Pos) /*!< SYS_T::IPRST0: CAPRST Mask */ + +#define SYS_IPRST0_CRPTRST_Pos (12) /*!< SYS_T::IPRST0: CRPTRST Position */ +#define SYS_IPRST0_CRPTRST_Msk (0x1ul << SYS_IPRST0_CRPTRST_Pos) /*!< SYS_T::IPRST0: CRPTRST Mask */ + +#define SYS_IPRST1_GPIORST_Pos (1) /*!< SYS_T::IPRST1: GPIORST Position */ +#define SYS_IPRST1_GPIORST_Msk (0x1ul << SYS_IPRST1_GPIORST_Pos) /*!< SYS_T::IPRST1: GPIORST Mask */ + +#define SYS_IPRST1_TMR0RST_Pos (2) /*!< SYS_T::IPRST1: TMR0RST Position */ +#define SYS_IPRST1_TMR0RST_Msk (0x1ul << SYS_IPRST1_TMR0RST_Pos) /*!< SYS_T::IPRST1: TMR0RST Mask */ + +#define SYS_IPRST1_TMR1RST_Pos (3) /*!< SYS_T::IPRST1: TMR1RST Position */ +#define SYS_IPRST1_TMR1RST_Msk (0x1ul << SYS_IPRST1_TMR1RST_Pos) /*!< SYS_T::IPRST1: TMR1RST Mask */ + +#define SYS_IPRST1_TMR2RST_Pos (4) /*!< SYS_T::IPRST1: TMR2RST Position */ +#define SYS_IPRST1_TMR2RST_Msk (0x1ul << SYS_IPRST1_TMR2RST_Pos) /*!< SYS_T::IPRST1: TMR2RST Mask */ + +#define SYS_IPRST1_TMR3RST_Pos (5) /*!< SYS_T::IPRST1: TMR3RST Position */ +#define SYS_IPRST1_TMR3RST_Msk (0x1ul << SYS_IPRST1_TMR3RST_Pos) /*!< SYS_T::IPRST1: TMR3RST Mask */ + +#define SYS_IPRST1_ACMPRST_Pos (7) /*!< SYS_T::IPRST1: ACMPRST Position */ +#define SYS_IPRST1_ACMPRST_Msk (0x1ul << SYS_IPRST1_ACMPRST_Pos) /*!< SYS_T::IPRST1: ACMPRST Mask */ + +#define SYS_IPRST1_I2C0RST_Pos (8) /*!< SYS_T::IPRST1: I2C0RST Position */ +#define SYS_IPRST1_I2C0RST_Msk (0x1ul << SYS_IPRST1_I2C0RST_Pos) /*!< SYS_T::IPRST1: I2C0RST Mask */ + +#define SYS_IPRST1_I2C1RST_Pos (9) /*!< SYS_T::IPRST1: I2C1RST Position */ +#define SYS_IPRST1_I2C1RST_Msk (0x1ul << SYS_IPRST1_I2C1RST_Pos) /*!< SYS_T::IPRST1: I2C1RST Mask */ + +#define SYS_IPRST1_I2C2RST_Pos (10) /*!< SYS_T::IPRST1: I2C2RST Position */ +#define SYS_IPRST1_I2C2RST_Msk (0x1ul << SYS_IPRST1_I2C2RST_Pos) /*!< SYS_T::IPRST1: I2C2RST Mask */ + +#define SYS_IPRST1_I2C3RST_Pos (11) /*!< SYS_T::IPRST1: I2C3RST Position */ +#define SYS_IPRST1_I2C3RST_Msk (0x1ul << SYS_IPRST1_I2C3RST_Pos) /*!< SYS_T::IPRST1: I2C3RST Mask */ + +#define SYS_IPRST1_SPI0RST_Pos (12) /*!< SYS_T::IPRST1: SPI0RST Position */ +#define SYS_IPRST1_SPI0RST_Msk (0x1ul << SYS_IPRST1_SPI0RST_Pos) /*!< SYS_T::IPRST1: SPI0RST Mask */ + +#define SYS_IPRST1_SPI1RST_Pos (13) /*!< SYS_T::IPRST1: SPI1RST Position */ +#define SYS_IPRST1_SPI1RST_Msk (0x1ul << SYS_IPRST1_SPI1RST_Pos) /*!< SYS_T::IPRST1: SPI1RST Mask */ + +#define SYS_IPRST1_SPI2RST_Pos (14) /*!< SYS_T::IPRST1: SPI2RST Position */ +#define SYS_IPRST1_SPI2RST_Msk (0x1ul << SYS_IPRST1_SPI2RST_Pos) /*!< SYS_T::IPRST1: SPI2RST Mask */ + +#define SYS_IPRST1_SPI3RST_Pos (15) /*!< SYS_T::IPRST1: SPI3RST Position */ +#define SYS_IPRST1_SPI3RST_Msk (0x1ul << SYS_IPRST1_SPI3RST_Pos) /*!< SYS_T::IPRST1: SPI3RST Mask */ + +#define SYS_IPRST1_UART0RST_Pos (16) /*!< SYS_T::IPRST1: UART0RST Position */ +#define SYS_IPRST1_UART0RST_Msk (0x1ul << SYS_IPRST1_UART0RST_Pos) /*!< SYS_T::IPRST1: UART0RST Mask */ + +#define SYS_IPRST1_UART1RST_Pos (17) /*!< SYS_T::IPRST1: UART1RST Position */ +#define SYS_IPRST1_UART1RST_Msk (0x1ul << SYS_IPRST1_UART1RST_Pos) /*!< SYS_T::IPRST1: UART1RST Mask */ + +#define SYS_IPRST1_UART2RST_Pos (18) /*!< SYS_T::IPRST1: UART2RST Position */ +#define SYS_IPRST1_UART2RST_Msk (0x1ul << SYS_IPRST1_UART2RST_Pos) /*!< SYS_T::IPRST1: UART2RST Mask */ + +#define SYS_IPRST1_UART3RST_Pos (19) /*!< SYS_T::IPRST1: UART3RST Position */ +#define SYS_IPRST1_UART3RST_Msk (0x1ul << SYS_IPRST1_UART3RST_Pos) /*!< SYS_T::IPRST1: UART3RST Mask */ + +#define SYS_IPRST1_UART4RST_Pos (20) /*!< SYS_T::IPRST1: UART4RST Position */ +#define SYS_IPRST1_UART4RST_Msk (0x1ul << SYS_IPRST1_UART4RST_Pos) /*!< SYS_T::IPRST1: UART4RST Mask */ + +#define SYS_IPRST1_UART5RST_Pos (21) /*!< SYS_T::IPRST1: UART5RST Position */ +#define SYS_IPRST1_UART5RST_Msk (0x1ul << SYS_IPRST1_UART5RST_Pos) /*!< SYS_T::IPRST1: UART5RST Mask */ + +#define SYS_IPRST1_CAN0RST_Pos (24) /*!< SYS_T::IPRST1: CAN0RST Position */ +#define SYS_IPRST1_CAN0RST_Msk (0x1ul << SYS_IPRST1_CAN0RST_Pos) /*!< SYS_T::IPRST1: CAN0RST Mask */ + +#define SYS_IPRST1_CAN1RST_Pos (25) /*!< SYS_T::IPRST1: CAN1RST Position */ +#define SYS_IPRST1_CAN1RST_Msk (0x1ul << SYS_IPRST1_CAN1RST_Pos) /*!< SYS_T::IPRST1: CAN1RST Mask */ + +#define SYS_IPRST1_USBDRST_Pos (27) /*!< SYS_T::IPRST1: USBDRST Position */ +#define SYS_IPRST1_USBDRST_Msk (0x1ul << SYS_IPRST1_USBDRST_Pos) /*!< SYS_T::IPRST1: USBDRST Mask */ + +#define SYS_IPRST1_ADCRST_Pos (28) /*!< SYS_T::IPRST1: ADCRST Position */ +#define SYS_IPRST1_ADCRST_Msk (0x1ul << SYS_IPRST1_ADCRST_Pos) /*!< SYS_T::IPRST1: ADCRST Mask */ + +#define SYS_IPRST1_I2S0RST_Pos (29) /*!< SYS_T::IPRST1: I2SRST Position */ +#define SYS_IPRST1_I2S0RST_Msk (0x1ul << SYS_IPRST1_I2S0RST_Pos) /*!< SYS_T::IPRST1: I2SRST Mask */ + +#define SYS_IPRST1_I2S1RST_Pos (30) /*!< SYS_T::IPRST1: I2S1RST Position */ +#define SYS_IPRST1_I2S1RST_Msk (0x1ul << SYS_IPRST1_I2S1RST_Pos) /*!< SYS_T::IPRST1: I2S1RST Mask */ + +#define SYS_IPRST1_PS2RST_Pos (31) /*!< SYS_T::IPRST1: PS2RST Position */ +#define SYS_IPRST1_PS2RST_Msk (0x1ul << SYS_IPRST1_PS2RST_Pos) /*!< SYS_T::IPRST1: PS2RST Mask */ + +#define SYS_IPRST2_SC0RST_Pos (0) /*!< SYS_T::IPRST2: SC0RST Position */ +#define SYS_IPRST2_SC0RST_Msk (0x1ul << SYS_IPRST2_SC0RST_Pos) /*!< SYS_T::IPRST2: SC0RST Mask */ + +#define SYS_IPRST2_SC1RST_Pos (1) /*!< SYS_T::IPRST2: SC1RST Position */ +#define SYS_IPRST2_SC1RST_Msk (0x1ul << SYS_IPRST2_SC1RST_Pos) /*!< SYS_T::IPRST2: SC1RST Mask */ + +#define SYS_IPRST2_SC2RST_Pos (2) /*!< SYS_T::IPRST2: SC2RST Position */ +#define SYS_IPRST2_SC2RST_Msk (0x1ul << SYS_IPRST2_SC2RST_Pos) /*!< SYS_T::IPRST2: SC2RST Mask */ + +#define SYS_IPRST2_SC3RST_Pos (3) /*!< SYS_T::IPRST2: SC3RST Position */ +#define SYS_IPRST2_SC3RST_Msk (0x1ul << SYS_IPRST2_SC3RST_Pos) /*!< SYS_T::IPRST2: SC3RST Mask */ + +#define SYS_IPRST2_SC4RST_Pos (4) /*!< SYS_T::IPRST2: SC4RST Position */ +#define SYS_IPRST2_SC4RST_Msk (0x1ul << SYS_IPRST2_SC4RST_Pos) /*!< SYS_T::IPRST2: SC4RST Mask */ + +#define SYS_IPRST2_SC5RST_Pos (5) /*!< SYS_T::IPRST2: SC5RST Position */ +#define SYS_IPRST2_SC5RST_Msk (0x1ul << SYS_IPRST2_SC5RST_Pos) /*!< SYS_T::IPRST2: SC5RST Mask */ + +#define SYS_IPRST2_I2C4RST_Pos (8) /*!< SYS_T::IPRST2: I2C4RST Position */ +#define SYS_IPRST2_I2C4RST_Msk (0x1ul << SYS_IPRST2_I2C4RST_Pos) /*!< SYS_T::IPRST2: I2C4RST Mask */ + +#define SYS_IPRST2_PWM0RST_Pos (16) /*!< SYS_T::IPRST2: PWM0RST Position */ +#define SYS_IPRST2_PWM0RST_Msk (0x1ul << SYS_IPRST2_PWM0RST_Pos) /*!< SYS_T::IPRST2: PWM0RST Mask */ + +#define SYS_IPRST2_PWM1RST_Pos (17) /*!< SYS_T::IPRST2: PWM1RST Position */ +#define SYS_IPRST2_PWM1RST_Msk (0x1ul << SYS_IPRST2_PWM1RST_Pos) /*!< SYS_T::IPRST2: PWM1RST Mask */ + +#define SYS_IPRST2_QEI0RST_Pos (22) /*!< SYS_T::IPRST2: QEI0RST Position */ +#define SYS_IPRST2_QEI0RST_Msk (0x1ul << SYS_IPRST2_QEI0RST_Pos) /*!< SYS_T::IPRST2: QEI0RST Mask */ + +#define SYS_IPRST2_QEI1RST_Pos (23) /*!< SYS_T::IPRST2: QEI1RST Position */ +#define SYS_IPRST2_QEI1RST_Msk (0x1ul << SYS_IPRST2_QEI1RST_Pos) /*!< SYS_T::IPRST2: QEI1RST Mask */ + +#define SYS_BODCTL_BODEN_Pos (0) /*!< SYS_T::BODCTL: BODEN Position */ +#define SYS_BODCTL_BODEN_Msk (0x1ul << SYS_BODCTL_BODEN_Pos) /*!< SYS_T::BODCTL: BODEN Mask */ + +#define SYS_BODCTL_BODVL_Pos (1) /*!< SYS_T::BODCTL: BODVL Position */ +#define SYS_BODCTL_BODVL_Msk (0x3ul << SYS_BODCTL_BODVL_Pos) /*!< SYS_T::BODCTL: BODVL Mask */ + +#define SYS_BODCTL_BODRSTEN_Pos (3) /*!< SYS_T::BODCTL: BODRSTEN Position */ +#define SYS_BODCTL_BODRSTEN_Msk (0x1ul << SYS_BODCTL_BODRSTEN_Pos) /*!< SYS_T::BODCTL: BODRSTEN Mask */ + +#define SYS_BODCTL_BODINTF_Pos (4) /*!< SYS_T::BODCTL: BODINTF Position */ +#define SYS_BODCTL_BODINTF_Msk (0x1ul << SYS_BODCTL_BODINTF_Pos) /*!< SYS_T::BODCTL: BODINTF Mask */ + +#define SYS_BODCTL_BODLPM_Pos (5) /*!< SYS_T::BODCTL: BODLPM Position */ +#define SYS_BODCTL_BODLPM_Msk (0x1ul << SYS_BODCTL_BODLPM_Pos) /*!< SYS_T::BODCTL: BODLPM Mask */ + +#define SYS_BODCTL_BODOUT_Pos (6) /*!< SYS_T::BODCTL: BODOUT Position */ +#define SYS_BODCTL_BODOUT_Msk (0x1ul << SYS_BODCTL_BODOUT_Pos) /*!< SYS_T::BODCTL: BODOUT Mask */ + +#define SYS_BODCTL_LVREN_Pos (7) /*!< SYS_T::BODCTL: LVREN Position */ +#define SYS_BODCTL_LVREN_Msk (0x1ul << SYS_BODCTL_LVREN_Pos) /*!< SYS_T::BODCTL: LVREN Mask */ + +#define SYS_TEMPCTL_VTEMPEN_Pos (0) /*!< SYS_T::TEMPCTL: VTEMPEN Position */ +#define SYS_TEMPCTL_VTEMPEN_Msk (0x1ul << SYS_TEMPCTL_VTEMPEN_Pos) /*!< SYS_T::TEMPCTL: VTEMPEN Mask */ + +#define SYS_VCID_VCID_Pos (0) /*!< SYS_T::VCID: VCID Position */ +#define SYS_VCID_VCID_Msk (0xfffful << SYS_VCID_VCID_Pos) /*!< SYS_T::VCID: VCID Mask */ + +#define SYS_PORCTL_POROFF_Pos (0) /*!< SYS_T::PORCTL: POROFF Position */ +#define SYS_PORCTL_POROFF_Msk (0xfffful << SYS_PORCTL_POROFF_Pos) /*!< SYS_T::PORCTL: POROFF Mask */ + +#define SYS_VREFCTL_VREFCTL_Pos (0) /*!< SYS_T::VREFCTL: VREFCTL Position */ +#define SYS_VREFCTL_VREFCTL_Msk (0x1ful << SYS_VREFCTL_VREFCTL_Pos) /*!< SYS_T::VREFCTL: VREFCTL Mask */ + +#define SYS_VREFCTL_ADCMODESEL_Pos (8) /*!< SYS_T::VREFCTL: ADCMODESEL Position */ +#define SYS_VREFCTL_ADCMODESEL_Msk (0x1ul << SYS_VREFCTL_ADCMODESEL_Pos) /*!< SYS_T::VREFCTL: ADCMODESEL Mask */ + +#define SYS_VREFCTL_PWMSYNCMODE_Pos (9) /*!< SYS_T::VREFCTL: PWMSYNCMODE Position */ +#define SYS_VREFCTL_PWMSYNCMODE_Msk (0x1ul << SYS_VREFCTL_PWMSYNCMODE_Pos) /*!< SYS_T::VREFCTL: PWMSYNCMODE Mask */ + +#define SYS_USBPHY_USBROLE_Pos (0) /*!< SYS_T::USBPHY: USBROLE Position */ +#define SYS_USBPHY_USBROLE_Msk (0x3ul << SYS_USBPHY_USBROLE_Pos) /*!< SYS_T::USBPHY: USBROLE Mask */ + +#define SYS_USBPHY_LDO33EN_Pos (8) /*!< SYS_T::USBPHY: LDO33EN Position */ +#define SYS_USBPHY_LDO33EN_Msk (0x1ul << SYS_USBPHY_LDO33EN_Pos) /*!< SYS_T::USBPHY: LDO33EN Mask */ + +#define SYS_GPA_MFPL_PA0MFP_Pos (0) /*!< SYS_T::GPA_MFPL: PA0MFP Position */ +#define SYS_GPA_MFPL_PA0MFP_Msk (0xful << SYS_GPA_MFPL_PA0MFP_Pos) /*!< SYS_T::GPA_MFPL: PA0MFP Mask */ + +#define SYS_GPA_MFPL_PA1MFP_Pos (4) /*!< SYS_T::GPA_MFPL: PA1MFP Position */ +#define SYS_GPA_MFPL_PA1MFP_Msk (0xful << SYS_GPA_MFPL_PA1MFP_Pos) /*!< SYS_T::GPA_MFPL: PA1MFP Mask */ + +#define SYS_GPA_MFPL_PA2MFP_Pos (8) /*!< SYS_T::GPA_MFPL: PA2MFP Position */ +#define SYS_GPA_MFPL_PA2MFP_Msk (0xful << SYS_GPA_MFPL_PA2MFP_Pos) /*!< SYS_T::GPA_MFPL: PA2MFP Mask */ + +#define SYS_GPA_MFPL_PA3MFP_Pos (12) /*!< SYS_T::GPA_MFPL: PA3MFP Position */ +#define SYS_GPA_MFPL_PA3MFP_Msk (0xful << SYS_GPA_MFPL_PA3MFP_Pos) /*!< SYS_T::GPA_MFPL: PA3MFP Mask */ + +#define SYS_GPA_MFPL_PA4MFP_Pos (16) /*!< SYS_T::GPA_MFPL: PA4MFP Position */ +#define SYS_GPA_MFPL_PA4MFP_Msk (0xful << SYS_GPA_MFPL_PA4MFP_Pos) /*!< SYS_T::GPA_MFPL: PA4MFP Mask */ + +#define SYS_GPA_MFPL_PA5MFP_Pos (20) /*!< SYS_T::GPA_MFPL: PA5MFP Position */ +#define SYS_GPA_MFPL_PA5MFP_Msk (0xful << SYS_GPA_MFPL_PA5MFP_Pos) /*!< SYS_T::GPA_MFPL: PA5MFP Mask */ + +#define SYS_GPA_MFPL_PA6MFP_Pos (24) /*!< SYS_T::GPA_MFPL: PA6MFP Position */ +#define SYS_GPA_MFPL_PA6MFP_Msk (0xful << SYS_GPA_MFPL_PA6MFP_Pos) /*!< SYS_T::GPA_MFPL: PA6MFP Mask */ + +#define SYS_GPA_MFPL_PA7MFP_Pos (28) /*!< SYS_T::GPA_MFPL: PA7MFP Position */ +#define SYS_GPA_MFPL_PA7MFP_Msk (0xful << SYS_GPA_MFPL_PA7MFP_Pos) /*!< SYS_T::GPA_MFPL: PA7MFP Mask */ + +#define SYS_GPA_MFPH_PA8MFP_Pos (0) /*!< SYS_T::GPA_MFPH: PA8MFP Position */ +#define SYS_GPA_MFPH_PA8MFP_Msk (0xful << SYS_GPA_MFPH_PA8MFP_Pos) /*!< SYS_T::GPA_MFPH: PA8MFP Mask */ + +#define SYS_GPA_MFPH_PA9MFP_Pos (4) /*!< SYS_T::GPA_MFPH: PA9MFP Position */ +#define SYS_GPA_MFPH_PA9MFP_Msk (0xful << SYS_GPA_MFPH_PA9MFP_Pos) /*!< SYS_T::GPA_MFPH: PA9MFP Mask */ + +#define SYS_GPA_MFPH_PA10MFP_Pos (8) /*!< SYS_T::GPA_MFPH: PA10MFP Position */ +#define SYS_GPA_MFPH_PA10MFP_Msk (0xful << SYS_GPA_MFPH_PA10MFP_Pos) /*!< SYS_T::GPA_MFPH: PA10MFP Mask */ + +#define SYS_GPA_MFPH_PA11MFP_Pos (12) /*!< SYS_T::GPA_MFPH: PA11MFP Position */ +#define SYS_GPA_MFPH_PA11MFP_Msk (0xful << SYS_GPA_MFPH_PA11MFP_Pos) /*!< SYS_T::GPA_MFPH: PA11MFP Mask */ + +#define SYS_GPA_MFPH_PA12MFP_Pos (16) /*!< SYS_T::GPA_MFPH: PA12MFP Position */ +#define SYS_GPA_MFPH_PA12MFP_Msk (0xful << SYS_GPA_MFPH_PA12MFP_Pos) /*!< SYS_T::GPA_MFPH: PA12MFP Mask */ + +#define SYS_GPA_MFPH_PA13MFP_Pos (20) /*!< SYS_T::GPA_MFPH: PA13MFP Position */ +#define SYS_GPA_MFPH_PA13MFP_Msk (0xful << SYS_GPA_MFPH_PA13MFP_Pos) /*!< SYS_T::GPA_MFPH: PA13MFP Mask */ + +#define SYS_GPA_MFPH_PA14MFP_Pos (24) /*!< SYS_T::GPA_MFPH: PA14MFP Position */ +#define SYS_GPA_MFPH_PA14MFP_Msk (0xful << SYS_GPA_MFPH_PA14MFP_Pos) /*!< SYS_T::GPA_MFPH: PA14MFP Mask */ + +#define SYS_GPA_MFPH_PA15MFP_Pos (28) /*!< SYS_T::GPA_MFPH: PA15MFP Position */ +#define SYS_GPA_MFPH_PA15MFP_Msk (0xful << SYS_GPA_MFPH_PA15MFP_Pos) /*!< SYS_T::GPA_MFPH: PA15MFP Mask */ + +#define SYS_GPB_MFPL_PB0MFP_Pos (0) /*!< SYS_T::GPB_MFPL: PB0MFP Position */ +#define SYS_GPB_MFPL_PB0MFP_Msk (0xful << SYS_GPB_MFPL_PB0MFP_Pos) /*!< SYS_T::GPB_MFPL: PB0MFP Mask */ + +#define SYS_GPB_MFPL_PB1MFP_Pos (4) /*!< SYS_T::GPB_MFPL: PB1MFP Position */ +#define SYS_GPB_MFPL_PB1MFP_Msk (0xful << SYS_GPB_MFPL_PB1MFP_Pos) /*!< SYS_T::GPB_MFPL: PB1MFP Mask */ + +#define SYS_GPB_MFPL_PB2MFP_Pos (8) /*!< SYS_T::GPB_MFPL: PB2MFP Position */ +#define SYS_GPB_MFPL_PB2MFP_Msk (0xful << SYS_GPB_MFPL_PB2MFP_Pos) /*!< SYS_T::GPB_MFPL: PB2MFP Mask */ + +#define SYS_GPB_MFPL_PB3MFP_Pos (12) /*!< SYS_T::GPB_MFPL: PB3MFP Position */ +#define SYS_GPB_MFPL_PB3MFP_Msk (0xful << SYS_GPB_MFPL_PB3MFP_Pos) /*!< SYS_T::GPB_MFPL: PB3MFP Mask */ + +#define SYS_GPB_MFPL_PB4MFP_Pos (16) /*!< SYS_T::GPB_MFPL: PB4MFP Position */ +#define SYS_GPB_MFPL_PB4MFP_Msk (0xful << SYS_GPB_MFPL_PB4MFP_Pos) /*!< SYS_T::GPB_MFPL: PB4MFP Mask */ + +#define SYS_GPB_MFPL_PB5MFP_Pos (20) /*!< SYS_T::GPB_MFPL: PB5MFP Position */ +#define SYS_GPB_MFPL_PB5MFP_Msk (0xful << SYS_GPB_MFPL_PB5MFP_Pos) /*!< SYS_T::GPB_MFPL: PB5MFP Mask */ + +#define SYS_GPB_MFPL_PB6MFP_Pos (24) /*!< SYS_T::GPB_MFPL: PB6MFP Position */ +#define SYS_GPB_MFPL_PB6MFP_Msk (0xful << SYS_GPB_MFPL_PB6MFP_Pos) /*!< SYS_T::GPB_MFPL: PB6MFP Mask */ + +#define SYS_GPB_MFPL_PB7MFP_Pos (28) /*!< SYS_T::GPB_MFPL: PB7MFP Position */ +#define SYS_GPB_MFPL_PB7MFP_Msk (0xful << SYS_GPB_MFPL_PB7MFP_Pos) /*!< SYS_T::GPB_MFPL: PB7MFP Mask */ + +#define SYS_GPB_MFPH_PB8MFP_Pos (0) /*!< SYS_T::GPB_MFPH: PB8MFP Position */ +#define SYS_GPB_MFPH_PB8MFP_Msk (0xful << SYS_GPB_MFPH_PB8MFP_Pos) /*!< SYS_T::GPB_MFPH: PB8MFP Mask */ + +#define SYS_GPB_MFPH_PB9MFP_Pos (4) /*!< SYS_T::GPB_MFPH: PB9MFP Position */ +#define SYS_GPB_MFPH_PB9MFP_Msk (0xful << SYS_GPB_MFPH_PB9MFP_Pos) /*!< SYS_T::GPB_MFPH: PB9MFP Mask */ + +#define SYS_GPB_MFPH_PB10MFP_Pos (8) /*!< SYS_T::GPB_MFPH: PB10MFP Position */ +#define SYS_GPB_MFPH_PB10MFP_Msk (0xful << SYS_GPB_MFPH_PB10MFP_Pos) /*!< SYS_T::GPB_MFPH: PB10MFP Mask */ + +#define SYS_GPB_MFPH_PB11MFP_Pos (12) /*!< SYS_T::GPB_MFPH: PB11MFP Position */ +#define SYS_GPB_MFPH_PB11MFP_Msk (0xful << SYS_GPB_MFPH_PB11MFP_Pos) /*!< SYS_T::GPB_MFPH: PB11MFP Mask */ + +#define SYS_GPB_MFPH_PB12MFP_Pos (16) /*!< SYS_T::GPB_MFPH: PB12MFP Position */ +#define SYS_GPB_MFPH_PB12MFP_Msk (0xful << SYS_GPB_MFPH_PB12MFP_Pos) /*!< SYS_T::GPB_MFPH: PB12MFP Mask */ + +#define SYS_GPB_MFPH_PB13MFP_Pos (20) /*!< SYS_T::GPB_MFPH: PB13MFP Position */ +#define SYS_GPB_MFPH_PB13MFP_Msk (0xful << SYS_GPB_MFPH_PB13MFP_Pos) /*!< SYS_T::GPB_MFPH: PB13MFP Mask */ + +#define SYS_GPB_MFPH_PB14MFP_Pos (24) /*!< SYS_T::GPB_MFPH: PB14MFP Position */ +#define SYS_GPB_MFPH_PB14MFP_Msk (0xful << SYS_GPB_MFPH_PB14MFP_Pos) /*!< SYS_T::GPB_MFPH: PB14MFP Mask */ + +#define SYS_GPB_MFPH_PB15MFP_Pos (28) /*!< SYS_T::GPB_MFPH: PB15MFP Position */ +#define SYS_GPB_MFPH_PB15MFP_Msk (0xful << SYS_GPB_MFPH_PB15MFP_Pos) /*!< SYS_T::GPB_MFPH: PB15MFP Mask */ + +#define SYS_GPC_MFPL_PC0MFP_Pos (0) /*!< SYS_T::GPC_MFPL: PC0MFP Position */ +#define SYS_GPC_MFPL_PC0MFP_Msk (0xful << SYS_GPC_MFPL_PC0MFP_Pos) /*!< SYS_T::GPC_MFPL: PC0MFP Mask */ + +#define SYS_GPC_MFPL_PC1MFP_Pos (4) /*!< SYS_T::GPC_MFPL: PC1MFP Position */ +#define SYS_GPC_MFPL_PC1MFP_Msk (0xful << SYS_GPC_MFPL_PC1MFP_Pos) /*!< SYS_T::GPC_MFPL: PC1MFP Mask */ + +#define SYS_GPC_MFPL_PC2MFP_Pos (8) /*!< SYS_T::GPC_MFPL: PC2MFP Position */ +#define SYS_GPC_MFPL_PC2MFP_Msk (0xful << SYS_GPC_MFPL_PC2MFP_Pos) /*!< SYS_T::GPC_MFPL: PC2MFP Mask */ + +#define SYS_GPC_MFPL_PC3MFP_Pos (12) /*!< SYS_T::GPC_MFPL: PC3MFP Position */ +#define SYS_GPC_MFPL_PC3MFP_Msk (0xful << SYS_GPC_MFPL_PC3MFP_Pos) /*!< SYS_T::GPC_MFPL: PC3MFP Mask */ + +#define SYS_GPC_MFPL_PC4MFP_Pos (16) /*!< SYS_T::GPC_MFPL: PC4MFP Position */ +#define SYS_GPC_MFPL_PC4MFP_Msk (0xful << SYS_GPC_MFPL_PC4MFP_Pos) /*!< SYS_T::GPC_MFPL: PC4MFP Mask */ + +#define SYS_GPC_MFPL_PC5MFP_Pos (20) /*!< SYS_T::GPC_MFPL: PC5MFP Position */ +#define SYS_GPC_MFPL_PC5MFP_Msk (0xful << SYS_GPC_MFPL_PC5MFP_Pos) /*!< SYS_T::GPC_MFPL: PC5MFP Mask */ + +#define SYS_GPC_MFPL_PC6MFP_Pos (24) /*!< SYS_T::GPC_MFPL: PC6MFP Position */ +#define SYS_GPC_MFPL_PC6MFP_Msk (0xful << SYS_GPC_MFPL_PC6MFP_Pos) /*!< SYS_T::GPC_MFPL: PC6MFP Mask */ + +#define SYS_GPC_MFPL_PC7MFP_Pos (28) /*!< SYS_T::GPC_MFPL: PC7MFP Position */ +#define SYS_GPC_MFPL_PC7MFP_Msk (0xful << SYS_GPC_MFPL_PC7MFP_Pos) /*!< SYS_T::GPC_MFPL: PC7MFP Mask */ + +#define SYS_GPC_MFPH_PC8MFP_Pos (0) /*!< SYS_T::GPC_MFPH: PC8MFP Position */ +#define SYS_GPC_MFPH_PC8MFP_Msk (0xful << SYS_GPC_MFPH_PC8MFP_Pos) /*!< SYS_T::GPC_MFPH: PC8MFP Mask */ + +#define SYS_GPC_MFPH_PC9MFP_Pos (4) /*!< SYS_T::GPC_MFPH: PC9MFP Position */ +#define SYS_GPC_MFPH_PC9MFP_Msk (0xful << SYS_GPC_MFPH_PC9MFP_Pos) /*!< SYS_T::GPC_MFPH: PC9MFP Mask */ + +#define SYS_GPC_MFPH_PC10MFP_Pos (8) /*!< SYS_T::GPC_MFPH: PC10MFP Position */ +#define SYS_GPC_MFPH_PC10MFP_Msk (0xful << SYS_GPC_MFPH_PC10MFP_Pos) /*!< SYS_T::GPC_MFPH: PC10MFP Mask */ + +#define SYS_GPC_MFPH_PC11MFP_Pos (12) /*!< SYS_T::GPC_MFPH: PC11MFP Position */ +#define SYS_GPC_MFPH_PC11MFP_Msk (0xful << SYS_GPC_MFPH_PC11MFP_Pos) /*!< SYS_T::GPC_MFPH: PC11MFP Mask */ + +#define SYS_GPC_MFPH_PC12MFP_Pos (16) /*!< SYS_T::GPC_MFPH: PC12MFP Position */ +#define SYS_GPC_MFPH_PC12MFP_Msk (0xful << SYS_GPC_MFPH_PC12MFP_Pos) /*!< SYS_T::GPC_MFPH: PC12MFP Mask */ + +#define SYS_GPC_MFPH_PC13MFP_Pos (20) /*!< SYS_T::GPC_MFPH: PC13MFP Position */ +#define SYS_GPC_MFPH_PC13MFP_Msk (0xful << SYS_GPC_MFPH_PC13MFP_Pos) /*!< SYS_T::GPC_MFPH: PC13MFP Mask */ + +#define SYS_GPC_MFPH_PC14MFP_Pos (24) /*!< SYS_T::GPC_MFPH: PC14MFP Position */ +#define SYS_GPC_MFPH_PC14MFP_Msk (0xful << SYS_GPC_MFPH_PC14MFP_Pos) /*!< SYS_T::GPC_MFPH: PC14MFP Mask */ + +#define SYS_GPC_MFPH_PC15MFP_Pos (28) /*!< SYS_T::GPC_MFPH: PC15MFP Position */ +#define SYS_GPC_MFPH_PC15MFP_Msk (0xful << SYS_GPC_MFPH_PC15MFP_Pos) /*!< SYS_T::GPC_MFPH: PC15MFP Mask */ + +#define SYS_GPD_MFPL_PD0MFP_Pos (0) /*!< SYS_T::GPD_MFPL: PD0MFP Position */ +#define SYS_GPD_MFPL_PD0MFP_Msk (0xful << SYS_GPD_MFPL_PD0MFP_Pos) /*!< SYS_T::GPD_MFPL: PD0MFP Mask */ + +#define SYS_GPD_MFPL_PD1MFP_Pos (4) /*!< SYS_T::GPD_MFPL: PD1MFP Position */ +#define SYS_GPD_MFPL_PD1MFP_Msk (0xful << SYS_GPD_MFPL_PD1MFP_Pos) /*!< SYS_T::GPD_MFPL: PD1MFP Mask */ + +#define SYS_GPD_MFPL_PD2MFP_Pos (8) /*!< SYS_T::GPD_MFPL: PD2MFP Position */ +#define SYS_GPD_MFPL_PD2MFP_Msk (0xful << SYS_GPD_MFPL_PD2MFP_Pos) /*!< SYS_T::GPD_MFPL: PD2MFP Mask */ + +#define SYS_GPD_MFPL_PD3MFP_Pos (12) /*!< SYS_T::GPD_MFPL: PD3MFP Position */ +#define SYS_GPD_MFPL_PD3MFP_Msk (0xful << SYS_GPD_MFPL_PD3MFP_Pos) /*!< SYS_T::GPD_MFPL: PD3MFP Mask */ + +#define SYS_GPD_MFPL_PD4MFP_Pos (16) /*!< SYS_T::GPD_MFPL: PD4MFP Position */ +#define SYS_GPD_MFPL_PD4MFP_Msk (0xful << SYS_GPD_MFPL_PD4MFP_Pos) /*!< SYS_T::GPD_MFPL: PD4MFP Mask */ + +#define SYS_GPD_MFPL_PD5MFP_Pos (20) /*!< SYS_T::GPD_MFPL: PD5MFP Position */ +#define SYS_GPD_MFPL_PD5MFP_Msk (0xful << SYS_GPD_MFPL_PD5MFP_Pos) /*!< SYS_T::GPD_MFPL: PD5MFP Mask */ + +#define SYS_GPD_MFPL_PD6MFP_Pos (24) /*!< SYS_T::GPD_MFPL: PD6MFP Position */ +#define SYS_GPD_MFPL_PD6MFP_Msk (0xful << SYS_GPD_MFPL_PD6MFP_Pos) /*!< SYS_T::GPD_MFPL: PD6MFP Mask */ + +#define SYS_GPD_MFPL_PD7MFP_Pos (28) /*!< SYS_T::GPD_MFPL: PD7MFP Position */ +#define SYS_GPD_MFPL_PD7MFP_Msk (0xful << SYS_GPD_MFPL_PD7MFP_Pos) /*!< SYS_T::GPD_MFPL: PD7MFP Mask */ + +#define SYS_GPD_MFPH_PD8MFP_Pos (0) /*!< SYS_T::GPD_MFPH: PD8MFP Position */ +#define SYS_GPD_MFPH_PD8MFP_Msk (0xful << SYS_GPD_MFPH_PD8MFP_Pos) /*!< SYS_T::GPD_MFPH: PD8MFP Mask */ + +#define SYS_GPD_MFPH_PD9MFP_Pos (4) /*!< SYS_T::GPD_MFPH: PD9MFP Position */ +#define SYS_GPD_MFPH_PD9MFP_Msk (0xful << SYS_GPD_MFPH_PD9MFP_Pos) /*!< SYS_T::GPD_MFPH: PD9MFP Mask */ + +#define SYS_GPD_MFPH_PD10MFP_Pos (8) /*!< SYS_T::GPD_MFPH: PD10MFP Position */ +#define SYS_GPD_MFPH_PD10MFP_Msk (0xful << SYS_GPD_MFPH_PD10MFP_Pos) /*!< SYS_T::GPD_MFPH: PD10MFP Mask */ + +#define SYS_GPD_MFPH_PD11MFP_Pos (12) /*!< SYS_T::GPD_MFPH: PD11MFP Position */ +#define SYS_GPD_MFPH_PD11MFP_Msk (0xful << SYS_GPD_MFPH_PD11MFP_Pos) /*!< SYS_T::GPD_MFPH: PD11MFP Mask */ + +#define SYS_GPD_MFPH_PD12MFP_Pos (16) /*!< SYS_T::GPD_MFPH: PD12MFP Position */ +#define SYS_GPD_MFPH_PD12MFP_Msk (0xful << SYS_GPD_MFPH_PD12MFP_Pos) /*!< SYS_T::GPD_MFPH: PD12MFP Mask */ + +#define SYS_GPD_MFPH_PD13MFP_Pos (20) /*!< SYS_T::GPD_MFPH: PD13MFP Position */ +#define SYS_GPD_MFPH_PD13MFP_Msk (0xful << SYS_GPD_MFPH_PD13MFP_Pos) /*!< SYS_T::GPD_MFPH: PD13MFP Mask */ + +#define SYS_GPD_MFPH_PD14MFP_Pos (24) /*!< SYS_T::GPD_MFPH: PD14MFP Position */ +#define SYS_GPD_MFPH_PD14MFP_Msk (0xful << SYS_GPD_MFPH_PD14MFP_Pos) /*!< SYS_T::GPD_MFPH: PD14MFP Mask */ + +#define SYS_GPD_MFPH_PD15MFP_Pos (28) /*!< SYS_T::GPD_MFPH: PD15MFP Position */ +#define SYS_GPD_MFPH_PD15MFP_Msk (0xful << SYS_GPD_MFPH_PD15MFP_Pos) /*!< SYS_T::GPD_MFPH: PD15MFP Mask */ + +#define SYS_GPE_MFPL_PE0MFP_Pos (0) /*!< SYS_T::GPE_MFPL: PE0MFP Position */ +#define SYS_GPE_MFPL_PE0MFP_Msk (0xful << SYS_GPE_MFPL_PE0MFP_Pos) /*!< SYS_T::GPE_MFPL: PE0MFP Mask */ + +#define SYS_GPE_MFPL_PE1MFP_Pos (4) /*!< SYS_T::GPE_MFPL: PE1MFP Position */ +#define SYS_GPE_MFPL_PE1MFP_Msk (0xful << SYS_GPE_MFPL_PE1MFP_Pos) /*!< SYS_T::GPE_MFPL: PE1MFP Mask */ + +#define SYS_GPE_MFPL_PE2MFP_Pos (8) /*!< SYS_T::GPE_MFPL: PE2MFP Position */ +#define SYS_GPE_MFPL_PE2MFP_Msk (0xful << SYS_GPE_MFPL_PE2MFP_Pos) /*!< SYS_T::GPE_MFPL: PE2MFP Mask */ + +#define SYS_GPE_MFPL_PE3MFP_Pos (12) /*!< SYS_T::GPE_MFPL: PE3MFP Position */ +#define SYS_GPE_MFPL_PE3MFP_Msk (0xful << SYS_GPE_MFPL_PE3MFP_Pos) /*!< SYS_T::GPE_MFPL: PE3MFP Mask */ + +#define SYS_GPE_MFPL_PE4MFP_Pos (16) /*!< SYS_T::GPE_MFPL: PE4MFP Position */ +#define SYS_GPE_MFPL_PE4MFP_Msk (0xful << SYS_GPE_MFPL_PE4MFP_Pos) /*!< SYS_T::GPE_MFPL: PE4MFP Mask */ + +#define SYS_GPE_MFPL_PE5MFP_Pos (20) /*!< SYS_T::GPE_MFPL: PE5MFP Position */ +#define SYS_GPE_MFPL_PE5MFP_Msk (0xful << SYS_GPE_MFPL_PE5MFP_Pos) /*!< SYS_T::GPE_MFPL: PE5MFP Mask */ + +#define SYS_GPE_MFPL_PE6MFP_Pos (24) /*!< SYS_T::GPE_MFPL: PE6MFP Position */ +#define SYS_GPE_MFPL_PE6MFP_Msk (0xful << SYS_GPE_MFPL_PE6MFP_Pos) /*!< SYS_T::GPE_MFPL: PE6MFP Mask */ + +#define SYS_GPE_MFPL_PE7MFP_Pos (28) /*!< SYS_T::GPE_MFPL: PE7MFP Position */ +#define SYS_GPE_MFPL_PE7MFP_Msk (0xful << SYS_GPE_MFPL_PE7MFP_Pos) /*!< SYS_T::GPE_MFPL: PE7MFP Mask */ + +#define SYS_GPE_MFPH_PE8MFP_Pos (0) /*!< SYS_T::GPE_MFPH: PE8MFP Position */ +#define SYS_GPE_MFPH_PE8MFP_Msk (0xful << SYS_GPE_MFPH_PE8MFP_Pos) /*!< SYS_T::GPE_MFPH: PE8MFP Mask */ + +#define SYS_GPE_MFPH_PE9MFP_Pos (4) /*!< SYS_T::GPE_MFPH: PE9MFP Position */ +#define SYS_GPE_MFPH_PE9MFP_Msk (0xful << SYS_GPE_MFPH_PE9MFP_Pos) /*!< SYS_T::GPE_MFPH: PE9MFP Mask */ + +#define SYS_GPE_MFPH_PE10MFP_Pos (8) /*!< SYS_T::GPE_MFPH: PE10MFP Position */ +#define SYS_GPE_MFPH_PE10MFP_Msk (0xful << SYS_GPE_MFPH_PE10MFP_Pos) /*!< SYS_T::GPE_MFPH: PE10MFP Mask */ + +#define SYS_GPE_MFPH_PE11MFP_Pos (12) /*!< SYS_T::GPE_MFPH: PE11MFP Position */ +#define SYS_GPE_MFPH_PE11MFP_Msk (0xful << SYS_GPE_MFPH_PE11MFP_Pos) /*!< SYS_T::GPE_MFPH: PE11MFP Mask */ + +#define SYS_GPE_MFPH_PE12MFP_Pos (16) /*!< SYS_T::GPE_MFPH: PE12MFP Position */ +#define SYS_GPE_MFPH_PE12MFP_Msk (0xful << SYS_GPE_MFPH_PE12MFP_Pos) /*!< SYS_T::GPE_MFPH: PE12MFP Mask */ + +#define SYS_GPE_MFPH_PE13MFP_Pos (20) /*!< SYS_T::GPE_MFPH: PE13MFP Position */ +#define SYS_GPE_MFPH_PE13MFP_Msk (0xful << SYS_GPE_MFPH_PE13MFP_Pos) /*!< SYS_T::GPE_MFPH: PE13MFP Mask */ + +#define SYS_GPE_MFPH_PE14MFP_Pos (24) /*!< SYS_T::GPE_MFPH: PE14MFP Position */ +#define SYS_GPE_MFPH_PE14MFP_Msk (0xful << SYS_GPE_MFPH_PE14MFP_Pos) /*!< SYS_T::GPE_MFPH: PE14MFP Mask */ + +#define SYS_GPE_MFPH_PE15MFP_Pos (28) /*!< SYS_T::GPE_MFPH: PE15MFP Position */ +#define SYS_GPE_MFPH_PE15MFP_Msk (0xful << SYS_GPE_MFPH_PE15MFP_Pos) /*!< SYS_T::GPE_MFPH: PE15MFP Mask */ + +#define SYS_GPF_MFPL_PF0MFP_Pos (0) /*!< SYS_T::GPF_MFPL: PF0MFP Position */ +#define SYS_GPF_MFPL_PF0MFP_Msk (0xful << SYS_GPF_MFPL_PF0MFP_Pos) /*!< SYS_T::GPF_MFPL: PF0MFP Mask */ + +#define SYS_GPF_MFPL_PF1MFP_Pos (4) /*!< SYS_T::GPF_MFPL: PF1MFP Position */ +#define SYS_GPF_MFPL_PF1MFP_Msk (0xful << SYS_GPF_MFPL_PF1MFP_Pos) /*!< SYS_T::GPF_MFPL: PF1MFP Mask */ + +#define SYS_GPF_MFPL_PF2MFP_Pos (8) /*!< SYS_T::GPF_MFPL: PF2MFP Position */ +#define SYS_GPF_MFPL_PF2MFP_Msk (0xful << SYS_GPF_MFPL_PF2MFP_Pos) /*!< SYS_T::GPF_MFPL: PF2MFP Mask */ + +#define SYS_GPF_MFPL_PF3MFP_Pos (12) /*!< SYS_T::GPF_MFPL: PF3MFP Position */ +#define SYS_GPF_MFPL_PF3MFP_Msk (0xful << SYS_GPF_MFPL_PF3MFP_Pos) /*!< SYS_T::GPF_MFPL: PF3MFP Mask */ + +#define SYS_GPF_MFPL_PF4MFP_Pos (16) /*!< SYS_T::GPF_MFPL: PF4MFP Position */ +#define SYS_GPF_MFPL_PF4MFP_Msk (0xful << SYS_GPF_MFPL_PF4MFP_Pos) /*!< SYS_T::GPF_MFPL: PF4MFP Mask */ + +#define SYS_GPF_MFPL_PF5MFP_Pos (20) /*!< SYS_T::GPF_MFPL: PF5MFP Position */ +#define SYS_GPF_MFPL_PF5MFP_Msk (0xful << SYS_GPF_MFPL_PF5MFP_Pos) /*!< SYS_T::GPF_MFPL: PF5MFP Mask */ + +#define SYS_GPF_MFPL_PF6MFP_Pos (24) /*!< SYS_T::GPF_MFPL: PF6MFP Position */ +#define SYS_GPF_MFPL_PF6MFP_Msk (0xful << SYS_GPF_MFPL_PF6MFP_Pos) /*!< SYS_T::GPF_MFPL: PF6MFP Mask */ + +#define SYS_GPF_MFPL_PF7MFP_Pos (28) /*!< SYS_T::GPF_MFPL: PF7MFP Position */ +#define SYS_GPF_MFPL_PF7MFP_Msk (0xful << SYS_GPF_MFPL_PF7MFP_Pos) /*!< SYS_T::GPF_MFPL: PF7MFP Mask */ + +#define SYS_GPF_MFPH_PF8MFP_Pos (0) /*!< SYS_T::GPF_MFPH: PF8MFP Position */ +#define SYS_GPF_MFPH_PF8MFP_Msk (0xful << SYS_GPF_MFPH_PF8MFP_Pos) /*!< SYS_T::GPF_MFPH: PF8MFP Mask */ + +#define SYS_GPF_MFPH_PF9MFP_Pos (4) /*!< SYS_T::GPF_MFPH: PF9MFP Position */ +#define SYS_GPF_MFPH_PF9MFP_Msk (0xful << SYS_GPF_MFPH_PF9MFP_Pos) /*!< SYS_T::GPF_MFPH: PF9MFP Mask */ + +#define SYS_GPF_MFPH_PF10MFP_Pos (8) /*!< SYS_T::GPF_MFPH: PF10MFP Position */ +#define SYS_GPF_MFPH_PF10MFP_Msk (0xful << SYS_GPF_MFPH_PF10MFP_Pos) /*!< SYS_T::GPF_MFPH: PF10MFP Mask */ + +#define SYS_GPF_MFPH_PF11MFP_Pos (12) /*!< SYS_T::GPF_MFPH: PF11MFP Position */ +#define SYS_GPF_MFPH_PF11MFP_Msk (0xful << SYS_GPF_MFPH_PF11MFP_Pos) /*!< SYS_T::GPF_MFPH: PF11MFP Mask */ + +#define SYS_GPF_MFPH_PF12MFP_Pos (16) /*!< SYS_T::GPF_MFPH: PF12MFP Position */ +#define SYS_GPF_MFPH_PF12MFP_Msk (0xful << SYS_GPF_MFPH_PF12MFP_Pos) /*!< SYS_T::GPF_MFPH: PF12MFP Mask */ + +#define SYS_GPF_MFPH_PF13MFP_Pos (20) /*!< SYS_T::GPF_MFPH: PF13MFP Position */ +#define SYS_GPF_MFPH_PF13MFP_Msk (0xful << SYS_GPF_MFPH_PF13MFP_Pos) /*!< SYS_T::GPF_MFPH: PF13MFP Mask */ + +#define SYS_GPF_MFPH_PF14MFP_Pos (24) /*!< SYS_T::GPF_MFPH: PF14MFP Position */ +#define SYS_GPF_MFPH_PF14MFP_Msk (0xful << SYS_GPF_MFPH_PF14MFP_Pos) /*!< SYS_T::GPF_MFPH: PF14MFP Mask */ + +#define SYS_GPF_MFPH_PF15MFP_Pos (28) /*!< SYS_T::GPF_MFPH: PF15MFP Position */ +#define SYS_GPF_MFPH_PF15MFP_Msk (0xful << SYS_GPF_MFPH_PF15MFP_Pos) /*!< SYS_T::GPF_MFPH: PF15MFP Mask */ + +#define SYS_GPG_MFPL_PG0MFP_Pos (0) /*!< SYS_T::GPG_MFPL: PG0MFP Position */ +#define SYS_GPG_MFPL_PG0MFP_Msk (0xful << SYS_GPG_MFPL_PG0MFP_Pos) /*!< SYS_T::GPG_MFPL: PG0MFP Mask */ + +#define SYS_GPG_MFPL_PG1MFP_Pos (4) /*!< SYS_T::GPG_MFPL: PG1MFP Position */ +#define SYS_GPG_MFPL_PG1MFP_Msk (0xful << SYS_GPG_MFPL_PG1MFP_Pos) /*!< SYS_T::GPG_MFPL: PG1MFP Mask */ + +#define SYS_GPG_MFPL_PG2MFP_Pos (8) /*!< SYS_T::GPG_MFPL: PG2MFP Position */ +#define SYS_GPG_MFPL_PG2MFP_Msk (0xful << SYS_GPG_MFPL_PG2MFP_Pos) /*!< SYS_T::GPG_MFPL: PG2MFP Mask */ + +#define SYS_GPG_MFPL_PG3MFP_Pos (12) /*!< SYS_T::GPG_MFPL: PG3MFP Position */ +#define SYS_GPG_MFPL_PG3MFP_Msk (0xful << SYS_GPG_MFPL_PG3MFP_Pos) /*!< SYS_T::GPG_MFPL: PG3MFP Mask */ + +#define SYS_GPG_MFPL_PG4MFP_Pos (16) /*!< SYS_T::GPG_MFPL: PG4MFP Position */ +#define SYS_GPG_MFPL_PG4MFP_Msk (0xful << SYS_GPG_MFPL_PG4MFP_Pos) /*!< SYS_T::GPG_MFPL: PG4MFP Mask */ + +#define SYS_GPG_MFPL_PG5MFP_Pos (20) /*!< SYS_T::GPG_MFPL: PG5MFP Position */ +#define SYS_GPG_MFPL_PG5MFP_Msk (0xful << SYS_GPG_MFPL_PG5MFP_Pos) /*!< SYS_T::GPG_MFPL: PG5MFP Mask */ + +#define SYS_GPG_MFPL_PG6MFP_Pos (24) /*!< SYS_T::GPG_MFPL: PG6MFP Position */ +#define SYS_GPG_MFPL_PG6MFP_Msk (0xful << SYS_GPG_MFPL_PG6MFP_Pos) /*!< SYS_T::GPG_MFPL: PG6MFP Mask */ + +#define SYS_GPG_MFPL_PG7MFP_Pos (28) /*!< SYS_T::GPG_MFPL: PG7MFP Position */ +#define SYS_GPG_MFPL_PG7MFP_Msk (0xful << SYS_GPG_MFPL_PG7MFP_Pos) /*!< SYS_T::GPG_MFPL: PG7MFP Mask */ + +#define SYS_GPG_MFPH_PG8MFP_Pos (0) /*!< SYS_T::GPG_MFPH: PG8MFP Position */ +#define SYS_GPG_MFPH_PG8MFP_Msk (0xful << SYS_GPG_MFPH_PG8MFP_Pos) /*!< SYS_T::GPG_MFPH: PG8MFP Mask */ + +#define SYS_GPG_MFPH_PG9MFP_Pos (4) /*!< SYS_T::GPG_MFPH: PG9MFP Position */ +#define SYS_GPG_MFPH_PG9MFP_Msk (0xful << SYS_GPG_MFPH_PG9MFP_Pos) /*!< SYS_T::GPG_MFPH: PG9MFP Mask */ + +#define SYS_GPG_MFPH_PG10MFP_Pos (8) /*!< SYS_T::GPG_MFPH: PG10MFP Position */ +#define SYS_GPG_MFPH_PG10MFP_Msk (0xful << SYS_GPG_MFPH_PG10MFP_Pos) /*!< SYS_T::GPG_MFPH: PG10MFP Mask */ + +#define SYS_GPG_MFPH_PG11MFP_Pos (12) /*!< SYS_T::GPG_MFPH: PG11MFP Position */ +#define SYS_GPG_MFPH_PG11MFP_Msk (0xful << SYS_GPG_MFPH_PG11MFP_Pos) /*!< SYS_T::GPG_MFPH: PG11MFP Mask */ + +#define SYS_GPG_MFPH_PG12MFP_Pos (16) /*!< SYS_T::GPG_MFPH: PG12MFP Position */ +#define SYS_GPG_MFPH_PG12MFP_Msk (0xful << SYS_GPG_MFPH_PG12MFP_Pos) /*!< SYS_T::GPG_MFPH: PG12MFP Mask */ + +#define SYS_GPG_MFPH_PG13MFP_Pos (20) /*!< SYS_T::GPG_MFPH: PG13MFP Position */ +#define SYS_GPG_MFPH_PG13MFP_Msk (0xful << SYS_GPG_MFPH_PG13MFP_Pos) /*!< SYS_T::GPG_MFPH: PG13MFP Mask */ + +#define SYS_GPG_MFPH_PG14MFP_Pos (24) /*!< SYS_T::GPG_MFPH: PG14MFP Position */ +#define SYS_GPG_MFPH_PG14MFP_Msk (0xful << SYS_GPG_MFPH_PG14MFP_Pos) /*!< SYS_T::GPG_MFPH: PG14MFP Mask */ + +#define SYS_GPG_MFPH_PG15MFP_Pos (28) /*!< SYS_T::GPG_MFPH: PG15MFP Position */ +#define SYS_GPG_MFPH_PG15MFP_Msk (0xful << SYS_GPG_MFPH_PG15MFP_Pos) /*!< SYS_T::GPG_MFPH: PG15MFP Mask */ + +#define SYS_GPH_MFPL_PH0MFP_Pos (0) /*!< SYS_T::GPH_MFPL: PH0MFP Position */ +#define SYS_GPH_MFPL_PH0MFP_Msk (0xful << SYS_GPH_MFPL_PH0MFP_Pos) /*!< SYS_T::GPH_MFPL: PH0MFP Mask */ + +#define SYS_GPH_MFPL_PH1MFP_Pos (4) /*!< SYS_T::GPH_MFPL: PH1MFP Position */ +#define SYS_GPH_MFPL_PH1MFP_Msk (0xful << SYS_GPH_MFPL_PH1MFP_Pos) /*!< SYS_T::GPH_MFPL: PH1MFP Mask */ + +#define SYS_GPH_MFPL_PH2MFP_Pos (8) /*!< SYS_T::GPH_MFPL: PH2MFP Position */ +#define SYS_GPH_MFPL_PH2MFP_Msk (0xful << SYS_GPH_MFPL_PH2MFP_Pos) /*!< SYS_T::GPH_MFPL: PH2MFP Mask */ + +#define SYS_GPH_MFPL_PH3MFP_Pos (12) /*!< SYS_T::GPH_MFPL: PH3MFP Position */ +#define SYS_GPH_MFPL_PH3MFP_Msk (0xful << SYS_GPH_MFPL_PH3MFP_Pos) /*!< SYS_T::GPH_MFPL: PH3MFP Mask */ + +#define SYS_GPH_MFPL_PH4MFP_Pos (16) /*!< SYS_T::GPH_MFPL: PH4MFP Position */ +#define SYS_GPH_MFPL_PH4MFP_Msk (0xful << SYS_GPH_MFPL_PH4MFP_Pos) /*!< SYS_T::GPH_MFPL: PH4MFP Mask */ + +#define SYS_GPH_MFPL_PH5MFP_Pos (20) /*!< SYS_T::GPH_MFPL: PH5MFP Position */ +#define SYS_GPH_MFPL_PH5MFP_Msk (0xful << SYS_GPH_MFPL_PH5MFP_Pos) /*!< SYS_T::GPH_MFPL: PH5MFP Mask */ + +#define SYS_GPH_MFPL_PH6MFP_Pos (24) /*!< SYS_T::GPH_MFPL: PH6MFP Position */ +#define SYS_GPH_MFPL_PH6MFP_Msk (0xful << SYS_GPH_MFPL_PH6MFP_Pos) /*!< SYS_T::GPH_MFPL: PH6MFP Mask */ + +#define SYS_GPH_MFPL_PH7MFP_Pos (28) /*!< SYS_T::GPH_MFPL: PH7MFP Position */ +#define SYS_GPH_MFPL_PH7MFP_Msk (0xful << SYS_GPH_MFPL_PH7MFP_Pos) /*!< SYS_T::GPH_MFPL: PH7MFP Mask */ + +#define SYS_GPH_MFPH_PH8MFP_Pos (0) /*!< SYS_T::GPH_MFPH: PH8MFP Position */ +#define SYS_GPH_MFPH_PH8MFP_Msk (0xful << SYS_GPH_MFPH_PH8MFP_Pos) /*!< SYS_T::GPH_MFPH: PH8MFP Mask */ + +#define SYS_GPH_MFPH_PH9MFP_Pos (4) /*!< SYS_T::GPH_MFPH: PH9MFP Position */ +#define SYS_GPH_MFPH_PH9MFP_Msk (0xful << SYS_GPH_MFPH_PH9MFP_Pos) /*!< SYS_T::GPH_MFPH: PH9MFP Mask */ + +#define SYS_GPH_MFPH_PH10MFP_Pos (8) /*!< SYS_T::GPH_MFPH: PH10MFP Position */ +#define SYS_GPH_MFPH_PH10MFP_Msk (0xful << SYS_GPH_MFPH_PH10MFP_Pos) /*!< SYS_T::GPH_MFPH: PH10MFP Mask */ + +#define SYS_GPH_MFPH_PH11MFP_Pos (12) /*!< SYS_T::GPH_MFPH: PH11MFP Position */ +#define SYS_GPH_MFPH_PH11MFP_Msk (0xful << SYS_GPH_MFPH_PH11MFP_Pos) /*!< SYS_T::GPH_MFPH: PH11MFP Mask */ + +#define SYS_GPH_MFPH_PH12MFP_Pos (16) /*!< SYS_T::GPH_MFPH: PH12MFP Position */ +#define SYS_GPH_MFPH_PH12MFP_Msk (0xful << SYS_GPH_MFPH_PH12MFP_Pos) /*!< SYS_T::GPH_MFPH: PH12MFP Mask */ + +#define SYS_GPH_MFPH_PH13MFP_Pos (20) /*!< SYS_T::GPH_MFPH: PH13MFP Position */ +#define SYS_GPH_MFPH_PH13MFP_Msk (0xful << SYS_GPH_MFPH_PH13MFP_Pos) /*!< SYS_T::GPH_MFPH: PH13MFP Mask */ + +#define SYS_GPH_MFPH_PH14MFP_Pos (24) /*!< SYS_T::GPH_MFPH: PH14MFP Position */ +#define SYS_GPH_MFPH_PH14MFP_Msk (0xful << SYS_GPH_MFPH_PH14MFP_Pos) /*!< SYS_T::GPH_MFPH: PH14MFP Mask */ + +#define SYS_GPH_MFPH_PH15MFP_Pos (28) /*!< SYS_T::GPH_MFPH: PH15MFP Position */ +#define SYS_GPH_MFPH_PH15MFP_Msk (0xful << SYS_GPH_MFPH_PH15MFP_Pos) /*!< SYS_T::GPH_MFPH: PH15MFP Mask */ + +#define SYS_GPI_MFPL_PI0MFP_Pos (0) /*!< SYS_T::GPI_MFPL: PI0MFP Position */ +#define SYS_GPI_MFPL_PI0MFP_Msk (0xful << SYS_GPI_MFPL_PI0MFP_Pos) /*!< SYS_T::GPI_MFPL: PI0MFP Mask */ + +#define SYS_GPI_MFPL_PI1MFP_Pos (4) /*!< SYS_T::GPI_MFPL: PI1MFP Position */ +#define SYS_GPI_MFPL_PI1MFP_Msk (0xful << SYS_GPI_MFPL_PI1MFP_Pos) /*!< SYS_T::GPI_MFPL: PI1MFP Mask */ + +#define SYS_GPI_MFPL_PI2MFP_Pos (8) /*!< SYS_T::GPI_MFPL: PI2MFP Position */ +#define SYS_GPI_MFPL_PI2MFP_Msk (0xful << SYS_GPI_MFPL_PI2MFP_Pos) /*!< SYS_T::GPI_MFPL: PI2MFP Mask */ + +#define SYS_GPI_MFPL_PI3MFP_Pos (12) /*!< SYS_T::GPI_MFPL: PI3MFP Position */ +#define SYS_GPI_MFPL_PI3MFP_Msk (0xful << SYS_GPI_MFPL_PI3MFP_Pos) /*!< SYS_T::GPI_MFPL: PI3MFP Mask */ + +#define SYS_GPI_MFPL_PI4MFP_Pos (16) /*!< SYS_T::GPI_MFPL: PI4MFP Position */ +#define SYS_GPI_MFPL_PI4MFP_Msk (0xful << SYS_GPI_MFPL_PI4MFP_Pos) /*!< SYS_T::GPI_MFPL: PI4MFP Mask */ + +#define SYS_GPI_MFPL_PI5MFP_Pos (20) /*!< SYS_T::GPI_MFPL: PI5MFP Position */ +#define SYS_GPI_MFPL_PI5MFP_Msk (0xful << SYS_GPI_MFPL_PI5MFP_Pos) /*!< SYS_T::GPI_MFPL: PI5MFP Mask */ + +#define SYS_GPI_MFPL_PI6MFP_Pos (24) /*!< SYS_T::GPI_MFPL: PI6MFP Position */ +#define SYS_GPI_MFPL_PI6MFP_Msk (0xful << SYS_GPI_MFPL_PI6MFP_Pos) /*!< SYS_T::GPI_MFPL: PI6MFP Mask */ + +#define SYS_GPI_MFPL_PI7MFP_Pos (28) /*!< SYS_T::GPI_MFPL: PI7MFP Position */ +#define SYS_GPI_MFPL_PI7MFP_Msk (0xful << SYS_GPI_MFPL_PI7MFP_Pos) /*!< SYS_T::GPI_MFPL: PI7MFP Mask */ + +#define SYS_GPI_MFPH_PI8MFP_Pos (0) /*!< SYS_T::GPI_MFPH: PI8MFP Position */ +#define SYS_GPI_MFPH_PI8MFP_Msk (0xful << SYS_GPI_MFPH_PI8MFP_Pos) /*!< SYS_T::GPI_MFPH: PI8MFP Mask */ + +#define SYS_GPI_MFPH_PI9MFP_Pos (4) /*!< SYS_T::GPI_MFPH: PI9MFP Position */ +#define SYS_GPI_MFPH_PI9MFP_Msk (0xful << SYS_GPI_MFPH_PI9MFP_Pos) /*!< SYS_T::GPI_MFPH: PI9MFP Mask */ + +#define SYS_GPI_MFPH_PI10MFP_Pos (8) /*!< SYS_T::GPI_MFPH: PI10MFP Position */ +#define SYS_GPI_MFPH_PI10MFP_Msk (0xful << SYS_GPI_MFPH_PI10MFP_Pos) /*!< SYS_T::GPI_MFPH: PI10MFP Mask */ + +#define SYS_GPI_MFPH_PI11MFP_Pos (12) /*!< SYS_T::GPI_MFPH: PI11MFP Position */ +#define SYS_GPI_MFPH_PI11MFP_Msk (0xful << SYS_GPI_MFPH_PI11MFP_Pos) /*!< SYS_T::GPI_MFPH: PI11MFP Mask */ + +#define SYS_GPI_MFPH_PI12MFP_Pos (16) /*!< SYS_T::GPI_MFPH: PI12MFP Position */ +#define SYS_GPI_MFPH_PI12MFP_Msk (0xful << SYS_GPI_MFPH_PI12MFP_Pos) /*!< SYS_T::GPI_MFPH: PI12MFP Mask */ + +#define SYS_GPI_MFPH_PI13MFP_Pos (20) /*!< SYS_T::GPI_MFPH: PI13MFP Position */ +#define SYS_GPI_MFPH_PI13MFP_Msk (0xful << SYS_GPI_MFPH_PI13MFP_Pos) /*!< SYS_T::GPI_MFPH: PI13MFP Mask */ + +#define SYS_GPI_MFPH_PI14MFP_Pos (24) /*!< SYS_T::GPI_MFPH: PI14MFP Position */ +#define SYS_GPI_MFPH_PI14MFP_Msk (0xful << SYS_GPI_MFPH_PI14MFP_Pos) /*!< SYS_T::GPI_MFPH: PI14MFP Mask */ + +#define SYS_GPI_MFPH_PI15MFP_Pos (28) /*!< SYS_T::GPI_MFPH: PI15MFP Position */ +#define SYS_GPI_MFPH_PI15MFP_Msk (0xful << SYS_GPI_MFPH_PI15MFP_Pos) /*!< SYS_T::GPI_MFPH: PI15MFP Mask */ + +#define SYS_SRAM_INTCTL_PERRIEN_Pos (0) /*!< SYS_T::SRAM_INTCTL: PERRIEN Position */ +#define SYS_SRAM_INTCTL_PERRIEN_Msk (0x1ul << SYS_SRAM_INTCTL_PERRIEN_Pos) /*!< SYS_T::SRAM_INTCTL: PERRIEN Mask */ + +#define SYS_SRAM_STATUS_PERRIF0_Pos (0) /*!< SYS_T::SRAM_STATUS: PERRIF0 Position */ +#define SYS_SRAM_STATUS_PERRIF0_Msk (0x1ul << SYS_SRAM_STATUS_PERRIF0_Pos) /*!< SYS_T::SRAM_STATUS: PERRIF0 Mask */ + +#define SYS_SRAM_STATUS_PERRIF1_Pos (1) /*!< SYS_T::SRAM_STATUS: PERRIF1 Position */ +#define SYS_SRAM_STATUS_PERRIF1_Msk (0x1ul << SYS_SRAM_STATUS_PERRIF1_Pos) /*!< SYS_T::SRAM_STATUS: PERRIF1 Mask */ + +#define SYS_SRAM0_ERRADDR_PERRADDR_Pos (0) /*!< SYS_T::SRAM0_ERRADDR: PERRADDR Position */ +#define SYS_SRAM0_ERRADDR_PERRADDR_Msk (0xfffffffful << SYS_SRAM0_ERRADDR_PERRADDR_Pos) /*!< SYS_T::SRAM0_ERRADDR: PERRADDR Mask */ + +#define SYS_SRAM1_ERRADDR_PERRADDR_Pos (0) /*!< SYS_T::SRAM1_ERRADDR: PERRADDR Position */ +#define SYS_SRAM1_ERRADDR_PERRADDR_Msk (0xfffffffful << SYS_SRAM1_ERRADDR_PERRADDR_Pos) /*!< SYS_T::SRAM1_ERRADDR: PERRADDR Mask */ + +#define SYS_IRCTCTL_FREQSEL_Pos (0) /*!< SYS_T::IRCTCTL: FREQSEL Position */ +#define SYS_IRCTCTL_FREQSEL_Msk (0x3ul << SYS_IRCTCTL_FREQSEL_Pos) /*!< SYS_T::IRCTCTL: FREQSEL Mask */ + +#define SYS_IRCTCTL_CALCLOOP_Pos (4) /*!< SYS_T::IRCTCTL: CALCLOOP Position */ +#define SYS_IRCTCTL_CALCLOOP_Msk (0x3ul << SYS_IRCTCTL_CALCLOOP_Pos) /*!< SYS_T::IRCTCTL: CALCLOOP Mask */ + +#define SYS_IRCTCTL_RETRYCNT_Pos (6) /*!< SYS_T::IRCTCTL: RETRYCNT Position */ +#define SYS_IRCTCTL_RETRYCNT_Msk (0x3ul << SYS_IRCTCTL_RETRYCNT_Pos) /*!< SYS_T::IRCTCTL: RETRYCNT Mask */ + +#define SYS_IRCTCTL_CESTOPEN_Pos (8) /*!< SYS_T::IRCTCTL: CESTOPEN Position */ +#define SYS_IRCTCTL_CESTOPEN_Msk (0x1ul << SYS_IRCTCTL_CESTOPEN_Pos) /*!< SYS_T::IRCTCTL: CESTOPEN Mask */ + +#define SYS_IRCTIEN_TFAILIEN_Pos (1) /*!< SYS_T::IRCTIEN: TFAILIEN Position */ +#define SYS_IRCTIEN_TFAILIEN_Msk (0x1ul << SYS_IRCTIEN_TFAILIEN_Pos) /*!< SYS_T::IRCTIEN: TFAILIEN Mask */ + +#define SYS_IRCTIEN_CLKEIEN_Pos (2) /*!< SYS_T::IRCTIEN: CLKEIEN Position */ +#define SYS_IRCTIEN_CLKEIEN_Msk (0x1ul << SYS_IRCTIEN_CLKEIEN_Pos) /*!< SYS_T::IRCTIEN: CLKEIEN Mask */ + +#define SYS_IRCTISTS_FREQLOCK_Pos (0) /*!< SYS_T::IRCTISTS: FREQLOCK Position */ +#define SYS_IRCTISTS_FREQLOCK_Msk (0x1ul << SYS_IRCTISTS_FREQLOCK_Pos) /*!< SYS_T::IRCTISTS: FREQLOCK Mask */ + +#define SYS_IRCTISTS_TFAILIF_Pos (1) /*!< SYS_T::IRCTISTS: TFAILIF Position */ +#define SYS_IRCTISTS_TFAILIF_Msk (0x1ul << SYS_IRCTISTS_TFAILIF_Pos) /*!< SYS_T::IRCTISTS: TFAILIF Mask */ + +#define SYS_IRCTISTS_CLKERRIF_Pos (2) /*!< SYS_T::IRCTISTS: CLKERRIF Position */ +#define SYS_IRCTISTS_CLKERRIF_Msk (0x1ul << SYS_IRCTISTS_CLKERRIF_Pos) /*!< SYS_T::IRCTISTS: CLKERRIF Mask */ + +#define SYS_REGLCTL_REGLCTL_Pos (0) /*!< SYS_T::REGLCTL: REGLCTL Position */ +#define SYS_REGLCTL_REGLCTL_Msk (0x1ul << SYS_REGLCTL_REGLCTL_Pos) /*!< SYS_T::REGLCTL: REGLCTL Mask */ + +#define SYS_REGLCTL_SYS_REGLCTL_Pos (0) /*!< SYS_T::REGLCTL: SYS_REGLCTL Position */ +#define SYS_REGLCTL_SYS_REGLCTL_Msk (0xfful << SYS_REGLCTL_SYS_REGLCTL_Pos) /*!< SYS_T::REGLCTL: SYS_REGLCTL Mask */ + +/**@}*/ /* SYS_CONST */ +/**@}*/ /* end of SYS register group */ + + +/*---------------------- Timer Controller -------------------------*/ +/** + @addtogroup TIMER Timer Controller(TIMER) + Memory Mapped Structure for TIMER Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 Timer Control and Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |PSC |PSC Counter + * | | |Timer input clock source is divided by (PSC+1) before it is fed to the timer up counter. + * | | |If this field is 0 (PSC = 0), then there is no scaling. + * |[16] |CNTDATEN |Data Load Enable + * | | |When this bit is set, timer counter value (TIMER_CNT) will be updated continuously to monitor internal 24-bit up counter value as the counter is counting. + * | | |0 = Timer Data Register update Disabled. + * | | |1 = Timer Data Register update Enabled while timer counter is active. + * |[21] |TOGDIS1 |Toggle Output 1 Disable + * | | |Setting this bit will disable the Toggle output pins group 1. + * | | |0 = Toggle output pins group 1 Enabled. + * | | |1 = Toggle output pins group 1 Disabled. + * | | |Note: The group1 pins are PB4, PB1, PC6, and PC1. + * |[22] |TOGDIS2 |Toggle Output 2 Disable + * | | |Setting this bit will disable the Toggle output pins group 2. + * | | |0 = Toggle output pins group 2 Enabled. + * | | |1 = Toggle output pins group 2 Disabled. + * | | |Note1: If both TOUT1 (group 1 pins) and TOUT2 (group 2 pins) function are enabled, toggle output signal is generated only from TOUT1 pins. + * | | |Note2: The group2 pins are PD1, PE8, PE1, and PD11. + * |[23] |WKEN |Wake-Up Enable + * | | |If this bit is set to 1, while timer interrupt flag TIF (TIMER_INTSTS[0]) is 1 and INTEN (TIMERX_CTL[29]) is enabled, the timer interrupt signal will generate a wake-up trigger event to CPU. + * | | |0 = Wake-up trigger event Disabled if timer interrupt signal generated. + * | | |1 = Wake-up trigger event Enabled if timer interrupt signal generated. + * |[24] |EXTCNTEN |Counter Mode Enable Bit + * | | |This bit is for external counting pin function enabled. + * | | |When timer is used as an event counter, this bit should be set to 1 and select PCLK as timer clock source. + * | | |0 = External counter mode Disabled. + * | | |1 = External counter mode Enabled. + * |[25] |ACTSTS |Timer Active Status Bit (Read Only) + * | | |This bit indicates the 24-bit up counter status. + * | | |0 = 24-bit up counter is not active. + * | | |1 = 24-bit up counter is active. + * |[26] |RSTCNT |Timer Reset Bit + * | | |Setting this bit will reset the 24-bit up counter value (TIMER_CNT) and also force CNTEN (TIMERX_CTL[30]) to 0 if ACTSTS (TIMERX_CTL[25]) is 1. + * | | |0 = No effect. + * | | |1 = Reset 8-bit PSC counter, 24-bit up counter value and CNTEN bit. + * |[27:28] |OPMODE |Timer Operation Mode + * | | |00 = The Timer controller is operated in One-shot mode. + * | | |01 = The Timer controller is operated in Periodic mode. + * | | |10 = The Timer controller is operated in Toggle-output mode. + * | | |11 = The Timer controller is operated in Continuous Counting mode. + * |[29] |INTEN |Interrupt Enable Bit + * | | |0 = Timer Interrupt Disabled. + * | | |1 = Timer Interrupt Enabled. + * | | |If this bit is enabled, when the timer interrupt flag TIF is set to 1, the timer interrupt signal is generated and inform to CPU. + * |[30] |CNTEN |Timer Enable + * | | |0 = Stops/Suspends counting. + * | | |1 = Starts counting. + * | | |Note1: In stop status, and then set CNTEN to 1 will enable the 24-bit up counter to keep counting from the last stop counting value. + * | | |Note2: This bit is auto-cleared by hardware in one-shot mode (TIMERX_CTL[28:27] = 00) when the timer interrupt flag TIF (TIMER_INTSTS[0]) is generated. + * |[31] |ICEDEBUG |ICE Debug Mode Acknowledge Disable (Write Protect) + * | | |0 = ICE debug mode acknowledgement effects TIMER counting. + * | | |TIMER counter will be held while CPU is held by ICE. + * | | |1 = ICE debug mode acknowledgement Disabled. + * | | |TIMER counter will keep going no matter CPU is held by ICE or not. + */ + __IO uint32_t CTL; + + /** + * CMP + * =================================================================================================== + * Offset: 0x04 Timer Compare Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |CMPDAT |Timer Compared Value + * | | |CMPDAT is a 24-bit compared value register. + * | | |When the internal 24-bit up counter value is equal to CMPDAT value, the TIF (TIMER_INTSTS[0] timer interrupt flag) will set to 1. + * | | |Time-out period = (Period of timer clock input) * (8-bit PSC + 1) * (24-bit CMPDAT). + * | | |Note1: Never write 0x0 or 0x1 in CMPDAT field, or the timer will run into unknown state. + * | | |Note2: When timer is operating at continuous counting mode, the 24-bit up counter will keep counting continuously even if software writes a new value into CMPDAT field. + * | | |But if timer is operating at other modes, the 24-bit up counter will restart counting and using newest CMPDAT value to be the timer compared value if software writes a new value into CMPDAT field. + */ + __IO uint32_t CMP; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x08 Timer Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |TIF |Timer Interrupt Flag + * | | |This bit indicates the interrupt flag status of Timer while TIMER_CNT value reaches to CMPDAT value. + * | | |0 = No effect. + * | | |1 = TIMER_CNT value matches the CMPDAT value. + * | | |Note: This bit is cleared by writing 1 to it. + * |[1] |TWKF |Timer Wake-Up Flag + * | | |This bit indicates the interrupt wake-up flag status of timer. + * | | |0 = Timer does not cause CPU wake-up. + * | | |1 = CPU wake-up from Idle or power-down mode if timer time-out interrupt signal generated. + * | | |Note: This bit is cleared by writing 1 to it. + */ + __IO uint32_t INTSTS; + + /** + * CNT + * =================================================================================================== + * Offset: 0x0C Timer Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |TIMER_CNT |Timer Data Register + * | | |1. EXTCNTEN (TIMERX_CTL[24] ) = 0 : TIMER_CNT is 24- bit counter value. + * | | |User can read TIMER_CNT for getting current 24- bit counter value if TIMERX_CTL[24] is set to 0 + * | | |2. EXTCNTEN (TIMERX_CTL[24] ) = 1 : TIMER_CNT is 24- bit event counter value. + * | | |User can read TIMER_CNT for getting current 24- bit event counter value if TIMERX_CTL[24] is 1 + */ + __I uint32_t CNT; + + /** + * CAP + * =================================================================================================== + * Offset: 0x10 Timer Capture Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:23] |CAPDAT |Timer Capture Data Register + * | | |When CAPEN (TIMER_EXTCTL[3]) bit is set, CAPFUNCS (TIMER_EXTCTL[4]) bit is 0, and a transition on TMx_EXT pin matched the CAPEDGE (TIMER_EXTCTL[2:1]) setting, CAPIF (TIMER_EINTSTS[0]) will set to 1 and the current timer counter value (TIMER_CNT value) will be auto-loaded into this CAPDAT field. + */ + __I uint32_t CAP; + + /** + * EXTCTL + * =================================================================================================== + * Offset: 0x14 Timer External Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CNTPHASE |Timer External Count Phase + * | | |This bit indicates the detection phase of external counting pin. + * | | |0 = A falling edge of external counting pin will be counted. + * | | |1 = A rising edge of external counting pin will be counted. + * |[1:2] |CAPEDGE |Timer External Pin Edge Detect + * | | |00 = A 1 to 0 transition on TMx_EXT (x= 0~3) pin will be detected. + * | | |01 = A 0 to 1 transition on TMx_EXT (x= 0~3) pin will be detected. + * | | |10 = Either 1 to 0 or 0 to 1 transition on TMx_EXT (x= 0~3) pin will be detected. + * | | |11 = Reserved. + * |[3] |CAPEN |Timer External Pin Enable + * | | |This bit enables the CAPFUNCS (TIMER_EXTCTL[4]) function on the TMx_EXT pin. + * | | |0 = CAPFUNCS function of TMx_EXT (x= 0~3) pin will be ignored. + * | | |1 = CAPFUNCS function of TMx_EXT (x= 0~3) pin is active. + * |[4] |CAPFUNCS |Timer External Reset Counter / Capture Mode Select + * | | |0 = Transition on TMx_EXT (x= 0~3) pin is using to save the 24-bit timer counter value. + * | | |(TIMER_CNT value) to timer capture value (TIMER_CAP value) if CAPIF (TIMER_EINTSTS[0]) is set to 1 + * | | |1 = Transition on TMx_EXT (x= 0~3) pin is using to reset the 24-bit timer counter value. + * |[5] |CAPIEN |Timer External Interrupt Enable + * | | |0 = TMx_EXT (x= 0~3) pin detection Interrupt Disabled. + * | | |1 = TMx_EXT (x= 0~3) pin detection Interrupt Enabled. + * | | |CAPIEN is used to enable timer external interrupt. + * | | |If CAPIEN enabled, timer will rise an interrupt when CAPIF = 1. + * | | |For example, while CAPIEN = 1, CAPEN = 1, and CAPEDGE = 00, a 1 to 0 transition on the TEX pin will cause the CAPIF(TIMER_EINTSTS[0]) interrupt flag to be set then the interrupt signal is generated and sent to NVIC to inform CPU. + * |[6] |CAPDBEN |Timer External Capture Pin De-Bounce Enable + * | | |0 = TMx_EXT (x= 0~3) pin de-bounce Disabled. + * | | |1 = TMx_EXT (x= 0~3) pin de-bounce Enabled. + * | | |If this bit is enabled, the edge detection of TMx_EXT pin is detected with de-bounce circuit. + * |[7] |ECNTDBEN |Timer Counter Pin De-Bounce Enable + * | | |0 = TMx (x= 0~3) pin de-bounce Disabled. + * | | |1 = TMx (x= 0~3) pin de-bounce Enabled. + * | | |If this bit is enabled, the edge detection of TMx pin is detected with de-bounce circuit. + */ + __IO uint32_t EXTCTL; + + /** + * EINTSTS + * =================================================================================================== + * Offset: 0x18 Timer External Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CAPIF |Timer External Interrupt Flag + * | | |This bit indicates the timer external interrupt flag status. + * | | |When CAPEN (TIMER_EXTCTL[3]) bit is set, CAPFUNCS (TIMER_EXTCTL[4]) bit is 0, and a transition on TMx_EXT (x= 0~3) pin matched the CAPEDGE (TIMER_EXTCTL[2:1]) setting, this bit will set to 1 by hardware. + * | | |0 = TMx_EXT (x= 0~3) pin interrupt did not occur. + * | | |1 = TMx_EXT (x= 0~3) pin interrupt occurred. + * | | |Note: This bit is cleared by writing 1 to it. + */ + __IO uint32_t EINTSTS; + +} TIMER_T; + +/** + @addtogroup TIMER_CONST TIMER Bit Field Definition + Constant Definitions for TIMER Controller +@{ */ + +#define TIMER_CTL_PSC_Pos (0) /*!< TIMER_T::CTL: PSC Position */ +#define TIMER_CTL_PSC_Msk (0xfful << TIMER_CTL_PSC_Pos) /*!< TIMER_T::CTL: PSC Mask */ + +#define TIMER_CTL_CNTDATEN_Pos (16) /*!< TIMER_T::CTL: CNTDATEN Position */ +#define TIMER_CTL_CNTDATEN_Msk (0x1ul << TIMER_CTL_CNTDATEN_Pos) /*!< TIMER_T::CTL: CNTDATEN Mask */ + +#define TIMER_CTL_TOGDIS1_Pos (21) /*!< TIMER_T::CTL: TOGDIS1 Position */ +#define TIMER_CTL_TOGDIS1_Msk (0x1ul << TIMER_CTL_TOGDIS1_Pos) /*!< TIMER_T::CTL: TOGDIS1 Mask */ + +#define TIMER_CTL_TOGDIS2_Pos (22) /*!< TIMER_T::CTL: TOGDIS2 Position */ +#define TIMER_CTL_TOGDIS2_Msk (0x1ul << TIMER_CTL_TOGDIS2_Pos) /*!< TIMER_T::CTL: TOGDIS2 Mask */ + +#define TIMER_CTL_WKEN_Pos (23) /*!< TIMER_T::CTL: WKEN Position */ +#define TIMER_CTL_WKEN_Msk (0x1ul << TIMER_CTL_WKEN_Pos) /*!< TIMER_T::CTL: WKEN Mask */ + +#define TIMER_CTL_EXTCNTEN_Pos (24) /*!< TIMER_T::CTL: EXTCNTEN Position */ +#define TIMER_CTL_EXTCNTEN_Msk (0x1ul << TIMER_CTL_EXTCNTEN_Pos) /*!< TIMER_T::CTL: EXTCNTEN Mask */ + +#define TIMER_CTL_ACTSTS_Pos (25) /*!< TIMER_T::CTL: ACTSTS Position */ +#define TIMER_CTL_ACTSTS_Msk (0x1ul << TIMER_CTL_ACTSTS_Pos) /*!< TIMER_T::CTL: ACTSTS Mask */ + +#define TIMER_CTL_RSTCNT_Pos (26) /*!< TIMER_T::CTL: RSTCNT Position */ +#define TIMER_CTL_RSTCNT_Msk (0x1ul << TIMER_CTL_RSTCNT_Pos) /*!< TIMER_T::CTL: RSTCNT Mask */ + +#define TIMER_CTL_OPMODE_Pos (27) /*!< TIMER_T::CTL: OPMODE Position */ +#define TIMER_CTL_OPMODE_Msk (0x3ul << TIMER_CTL_OPMODE_Pos) /*!< TIMER_T::CTL: OPMODE Mask */ + +#define TIMER_CTL_INTEN_Pos (29) /*!< TIMER_T::CTL: INTEN Position */ +#define TIMER_CTL_INTEN_Msk (0x1ul << TIMER_CTL_INTEN_Pos) /*!< TIMER_T::CTL: INTEN Mask */ + +#define TIMER_CTL_CNTEN_Pos (30) /*!< TIMER_T::CTL: CNTEN Position */ +#define TIMER_CTL_CNTEN_Msk (0x1ul << TIMER_CTL_CNTEN_Pos) /*!< TIMER_T::CTL: CNTEN Mask */ + +#define TIMER_CTL_ICEDEBUG_Pos (31) /*!< TIMER_T::CTL: ICEDEBUG Position */ +#define TIMER_CTL_ICEDEBUG_Msk (0x1ul << TIMER_CTL_ICEDEBUG_Pos) /*!< TIMER_T::CTL: ICEDEBUG Mask */ + +#define TIMER_CMP_CMPDAT_Pos (0) /*!< TIMER_T::CMP: CMPDAT Position */ +#define TIMER_CMP_CMPDAT_Msk (0xfffffful << TIMER_CMP_CMPDAT_Pos) /*!< TIMER_T::CMP: CMPDAT Mask */ + +#define TIMER_INTSTS_TIF_Pos (0) /*!< TIMER_T::INTSTS: TIF Position */ +#define TIMER_INTSTS_TIF_Msk (0x1ul << TIMER_INTSTS_TIF_Pos) /*!< TIMER_T::INTSTS: TIF Mask */ + +#define TIMER_INTSTS_TWKF_Pos (1) /*!< TIMER_T::INTSTS: TWKF Position */ +#define TIMER_INTSTS_TWKF_Msk (0x1ul << TIMER_INTSTS_TWKF_Pos) /*!< TIMER_T::INTSTS: TWKF Mask */ + +#define TIMER_CNT_TIMER_CNT_Pos (0) /*!< TIMER_T::CNT: TIMER_CNT Position */ +#define TIMER_CNT_TIMER_CNT_Msk (0xfffffful << TIMER_CNT_TIMER_CNT_Pos) /*!< TIMER_T::CNT: TIMER_CNT Mask */ + +#define TIMER_CAP_CAPDAT_Pos (0) /*!< TIMER_T::CAP: CAPDAT Position */ +#define TIMER_CAP_CAPDAT_Msk (0xfffffful << TIMER_CAP_CAPDAT_Pos) /*!< TIMER_T::CAP: CAPDAT Mask */ + +#define TIMER_EXTCTL_CNTPHASE_Pos (0) /*!< TIMER_T::EXTCTL: CNTPHASE Position */ +#define TIMER_EXTCTL_CNTPHASE_Msk (0x1ul << TIMER_EXTCTL_CNTPHASE_Pos) /*!< TIMER_T::EXTCTL: CNTPHASE Mask */ + +#define TIMER_EXTCTL_CAPEDGE_Pos (1) /*!< TIMER_T::EXTCTL: CAPEDGE Position */ +#define TIMER_EXTCTL_CAPEDGE_Msk (0x3ul << TIMER_EXTCTL_CAPEDGE_Pos) /*!< TIMER_T::EXTCTL: CAPEDGE Mask */ + +#define TIMER_EXTCTL_CAPEN_Pos (3) /*!< TIMER_T::EXTCTL: CAPEN Position */ +#define TIMER_EXTCTL_CAPEN_Msk (0x1ul << TIMER_EXTCTL_CAPEN_Pos) /*!< TIMER_T::EXTCTL: CAPEN Mask */ + +#define TIMER_EXTCTL_CAPFUNCS_Pos (4) /*!< TIMER_T::EXTCTL: CAPFUNCS Position */ +#define TIMER_EXTCTL_CAPFUNCS_Msk (0x1ul << TIMER_EXTCTL_CAPFUNCS_Pos) /*!< TIMER_T::EXTCTL: CAPFUNCS Mask */ + +#define TIMER_EXTCTL_CAPIEN_Pos (5) /*!< TIMER_T::EXTCTL: CAPIEN Position */ +#define TIMER_EXTCTL_CAPIEN_Msk (0x1ul << TIMER_EXTCTL_CAPIEN_Pos) /*!< TIMER_T::EXTCTL: CAPIEN Mask */ + +#define TIMER_EXTCTL_CAPDBEN_Pos (6) /*!< TIMER_T::EXTCTL: CAPDBEN Position */ +#define TIMER_EXTCTL_CAPDBEN_Msk (0x1ul << TIMER_EXTCTL_CAPDBEN_Pos) /*!< TIMER_T::EXTCTL: CAPDBEN Mask */ + +#define TIMER_EXTCTL_ECNTDBEN_Pos (7) /*!< TIMER_T::EXTCTL: ECNTDBEN Position */ +#define TIMER_EXTCTL_ECNTDBEN_Msk (0x1ul << TIMER_EXTCTL_ECNTDBEN_Pos) /*!< TIMER_T::EXTCTL: ECNTDBEN Mask */ + +#define TIMER_EINTSTS_CAPIF_Pos (0) /*!< TIMER_T::EINTSTS: CAPIF Position */ +#define TIMER_EINTSTS_CAPIF_Msk (0x1ul << TIMER_EINTSTS_CAPIF_Pos) /*!< TIMER_T::EINTSTS: CAPIF Mask */ + + +/**@}*/ /* TIMER_CONST */ +/**@}*/ /* end of TMR register group */ + + +/*---------------------- Universal Asynchronous Receiver/Transmitter Controller -------------------------*/ +/** + @addtogroup UART Universal Asynchronous Receiver/Transmitter Controller(UART) + Memory Mapped Structure for UART Controller +@{ */ + +typedef struct { + + + /** + * DAT + * =================================================================================================== + * Offset: 0x00 UARTx Receive / Transmit Buffer Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DAT |Receiving/Transmit Buffer + * | | |Write Operation: + * | | |By writing one byte to this register, the data byte will be stored in transmitter FIFO. The + * | | |UART Controller will send out the data stored in transmitter FIFO top location through the + * | | |UART_TXD. + * | | |Read Operation: + * | | |By reading this register, the UART will return an 8-bit data received from receiving FIFO + */ + __IO uint32_t DAT; + + /** + * INTEN + * =================================================================================================== + * Offset: 0x04 UARTx Interrupt Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RDAIEN |Receive Data Available Interrupt Enable Control + * | | |0 = INT_RDA Disabled. + * | | |1 = INT_RDA Enabled. + * |[1] |THREIEN |Transmit Holding Register Empty Interrupt Enable Control + * | | |0 = INT_THRE Disabled. + * | | |1 = INT_THRE Enabled. + * |[2] |RLSIEN |Receive Line Status Interrupt Enable Control + * | | |0 = INT_RLS Disabled. + * | | |1 = INT_RLS Enabled. + * |[3] |MODEMIEN |Modem Status Interrupt Enable Control + * | | |0 = INT_MODEM Disabled. + * | | |1 = INT_MODEM Enabled. + * |[4] |RXTOIEN |RX Time-Out Interrupt Enable Control + * | | |0 = NT_TOUT Disabled. + * | | |1 = INT_TOUT Enabled. + * |[5] |BUFERRIEN |Buffer Error Interrupt Enable Control + * | | |0 = INT_BUF_ERR Disabled. + * | | |1 = INT_BUF_ERR Enabled. + * |[6] |WKCTSIEN |UART Wake-Up Function Enable Control + * | | |0 = UART wake-up function Disabled. + * | | |1 = UART wake-up function Enabled when the chip is in Power-down mode, an external CTS change will wake up chip from Power-down mode. + * |[8] |LINIEN |LIN RX Break Field Detected Interrupt Enable Control + * | | |0 = Lin bus RX break filed interrupt Disabled. + * | | |1 = Lin bus RX break filed interrupt Enabled. + * | | |Note: This field is used for LIN function mode. + * |[11] |TOCNTEN |Time-Out Counter Enable Control + * | | |0 = Time-out counter Disabled. + * | | |1 = Time-out counter Enabled. + * |[12] |ATORTSEN |RTS Auto Flow Control Enable Control + * | | |0 = RTS auto flow control Disabled. + * | | |1 = RTS auto flow control Enabled. + * | | |When RTS auto-flow is enabled, if the number of bytes in the RX FIFO equals the RTSTRGLV (UART_FIFO[19:16]), the UART will de-assert RTS signal. + * |[13] |ATOCTSEN |CTS Auto Flow Control Enable Control + * | | |0 = CTS auto flow control Disabled. + * | | |1 = CTS auto flow control Enabled. + * | | |When CTS auto-flow is enabled, the UART will send data to external device when CTS input assert (UART will not send data to device until CTS is asserted). + * |[14] |TXPDMAEN |TX DMA Enable Control + * | | |This bit can enable or disable TX DMA service. + * | | |0 = TX DMA Disabled. + * | | |1 = TX DMA Enabled. + * |[15] |RXPDMAEN |RX DMA Enable Control + * | | |This bit can enable or disable RX DMA service. + * | | |0 = RX DMA Disabled. + * | | |1 = RX DMA Enabled. + */ + __IO uint32_t INTEN; + + /** + * FIFO + * =================================================================================================== + * Offset: 0x08 UARTx FIFO Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1] |RXRST |RX Field Software Reset + * | | |When RX_RST is set, all the byte in the receiver FIFO and RX internal state machine are cleared. + * | | |0 = No effect. + * | | |1 = Reset the RX internal state machine and pointers. + * | | |Note: This bit will be automatically cleared for at least 3 UART engine clock cycles. + * |[2] |TXRST |TX Field Software Reset + * | | |When TX_RST is set, all the byte in the transmit FIFO and TX internal state machine are cleared. + * | | |0 = No effect. + * | | |1 = Reset the TX internal state machine and pointers. + * | | |Note: This bit will auto clear needs at least 3 UART engine clock cycles. + * |[4:7] |RFITL |RX FIFO Interrupt (INT_RDA) Trigger Level + * | | |When the number of bytes in the receive FIFO equals the RFITL, the RDAIF will be set (if RDAIEN (UART_INTEN [0]) is enabled, an interrupt will generated). + * | | |0000 = 1 byte + * | | |0001 = 4 bytes + * | | |0010 = 8 bytes + * | | |0011 = 14 bytes + * | | |0100 = 30/14 bytes (High-speed/Normal Speed) + * | | |0101 = 46/14 bytes (High-speed/Normal Speed) + * | | |0110 = 62/14 bytes (High-speed/Normal Speed) + * | | |others = 62/14 bytes (High-speed/Normal Speed) + * |[8] |RXOFF |Receiver Disable + * | | |The receiver is disabled or not. + * | | |0 = Receiver Enabled. + * | | |1 = Receiver Disabled. + * | | |Note: This field is used for RS-485 Normal Multi-drop mode. + * | | |It should be programmed before RS-485_NMM (UART_ALTCTL [8]) is programmed. + * |[16:19] |RTSTRGLV |RTS Trigger Level For Auto-Flow Control Use + * | | |0000 = 01 byte + * | | |0001 = 04 bytes + * | | |0010 = 08 bytes + * | | |0011 = 14 bytes + * | | |0100 = 30/14 bytes (High-speed/Normal Speed) + * | | |0101 = 46/14 bytes (High-speed/Normal Speed) + * | | |0110 = 62/14 bytes (High-speed/Normal Speed) + * | | |others = 62/14 bytes (High-speed/Normal Speed) + * | | |Note: This field is used for auto RTS flow control. + */ + __IO uint32_t FIFO; + + /** + * LINE + * =================================================================================================== + * Offset: 0x0C UARTx Line Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |WLS |Word Length Selection + * | | |00 = 5-bit + * | | |01 = 6-bit + * | | |10 = 7-bit + * | | |11 = 8-bit + * |[2] |NSB |Number Of "STOP Bit" + * | | |0= One " STOP bit" is generated in the transmitted data. + * | | |1= One and a half " STOP bit" is generated in the transmitted data when 5-bit word length is selected. + * | | |Two "STOP bit" is generated when 6-, 7- and 8-bit word length is selected. + * |[3] |PBE |Parity Bit Enable Control + * | | |0 = No parity bit. + * | | |1 = Parity bit is generated on each outgoing character and is checked on each incoming data. + * |[4] |EPE |Even Parity Enable Control + * | | |0 = Odd number of logic 1's is transmitted and checked in each word. + * | | |1 = Even number of logic 1's is transmitted and checked in each word. + * | | |This bit is effective only when bit 3 (parity bit enable) is set. + * |[5] |SPE |Stick Parity Enable Control + * | | |0 = Stick parity Disabled. + * | | |1 = If bit 3 and 4 are logic 1, the parity bit is transmitted and checked as logic 0. + * | | |If bit 3 is 1 and bit 4 is 0 then the parity bit is transmitted and checked as 1. + * |[6] |BCB |Break Control + * | | |When this bit is set to logic 1, the serial data output (TX) is forced to the Spacing State (logic 0). + * | | |This bit acts only on TX and has no effect on the transmitter logic. + */ + __IO uint32_t LINE; + + /** + * MODEM + * =================================================================================================== + * Offset: 0x10 UARTx Modem Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1] |RTS |RTS (Request-To-Send) Signal + * | | |0 = Drive RTS pin to logic 1 (If the RTSACTLV + * | | |set to low level triggered). + * | | |1 = Drive RTS pin to logic 0 (If the RTSACTLV set to low level triggered). + * | | |0 = Drive RTS pin to logic 0 (If the RTSACTLV + * | | |set to high level triggered). + * | | |1 = Drive RTS pin to logic 1 (If the RTSACTLV set to high level triggered). + * |[9] |RTSACTLV |RTS Trigger Level + * | | |This bit can change the RTS trigger level. + * | | |0= Low level triggered. + * | | |1= High level triggered. + * |[13] |RTSSTS |RTS Pin State (Read Only) + * | | |This bit is the output pin status of RTS. + */ + __IO uint32_t MODEM; + + /** + * MODEMSTS + * =================================================================================================== + * Offset: 0x14 UARTx Modem Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CTSDETF |Detect CTS State Change Flag (Read Only) + * | | |This bit is set whenever CTS input has change state, and it will generate Modem interrupt to CPU when MODEMIEN (UART_INTEN[3]) is set to 1. + * | | |Software can write 1 to clear this bit to 0 + * |[4] |CTSSTS |CTS Pin Status (Read Only) + * | | |This bit is the pin status of CTS. + * |[8] |CTSACTLV |CTS Trigger Level + * | | |This bit can change the CTS trigger level. + * | | |0= Low level triggered. + * | | |1= High level triggered. + */ + __IO uint32_t MODEMSTS; + + /** + * FIFOSTS + * =================================================================================================== + * Offset: 0x18 UARTx FIFO Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RXOVIF |RX Overflow Error IF (Read Only) + * | | |This bit is set when RX FIFO overflow. + * | | |If the number of bytes of received data is greater than RX_FIFO (UART_DAT) size, 64/16 bytes of UART0/UART1, this bit will be set. + * | | |Note: This bit is read only, but it can be cleared by writing '1' to it. + * |[2] |SCERR |Smart Card Over Error Retry Flag + * | | |It is set to 1 when transmitter re-transmits over the retry number (TXRTY (UART_SCCTL[6:4])) or the receiver transfer error retry over retry number (RXRTY (UART_SCCTL[2:0])) + * | | |0 = No any transmitter re-transmits over or receiver transfer error retry over. + * | | |1 = one of the transmitter re-transmits over active or receiver transfer error retry over active. + * | | |Note1: This field is used for SC function mode. + * | | |Note2: This bit is read only, but it can be cleared by writing '1' to it. + * |[3] |ADDRDETF |RS-485 Address Byte Detection Flag (Read Only) + * | | |This bit is set to logic 1 and set RS-485_ADD_EN (UART_ALTCTL[15]) whenever in RS-485 mode the receiver detect any address byte received address byte character (bit9 = '1') bit, and it is reset whenever the CPU writes 1 to this bit. + * | | |Note1: This field is used for RS-485 function mode. + * | | |Note2: This bit is read only, but it can be cleared by writing '1' to it. + * |[4] |PEF |Parity Error Flag (Read Only) + * | | |This bit is set to logic 1 whenever the received character does not have a valid "parity bit", and is reset whenever the CPU writes 1 to this bit. + * | | |Note: This bit is read only, but it can be cleared by writing '1' to it. + * |[5] |FEF |Framing Error Flag (Read Only) + * | | |This bit is set to logic 1 whenever the received character does not have a valid "stop bit" (that is, the stop bit following the last data bit or parity bit is detected as a logic 0), and is reset whenever the CPU writes 1 to this bit. + * | | |Note: This bit is read only, but it can be cleared by writing '1' to it. + * |[6] |BIF |Break Interrupt Flag (Read Only) + * | | |This bit is set to a logic 1 whenever the received data input(RX) is held in the "spacing state" (logic 0) for longer than a full word transmission time (that is, the total time of "start bit" + data bits + parity + stop bits) and is reset whenever the CPU writes 1 to this bit. + * | | |Note: This bit is read only, but it can be cleared by writing '1' to it. + * |[8:13] |RXPTR |RX FIFO Pointer (Read Only) + * | | |This field indicates the RX FIFO Buffer Pointer. + * | | |When UART receives one byte from external device, RXPTR increases one. + * | | |When one byte of RX FIFO is read by CPU, RXPTR decreases one. + * |[14] |RXEMPTY |Receiver FIFO Empty (Read Only) + * | | |This bit initiate RX FIFO empty or not. + * | | |When the last byte of RX FIFO has been read by CPU, hardware sets this bit high. + * | | |It will be cleared when UART receives any new data. + * |[15] |RXFULL |Receiver FIFO Full (Read Only) + * | | |This bit initiates RX FIFO full or not. + * | | |This bit is set when RXPTR is equal to 64/16(UART0/UART1~5), otherwise is cleared by hardware. + * |[16:21] |TXPTR |TX FIFO Pointer (Read Only) + * | | |This field indicates the TX FIFO Buffer Pointer. + * | | |When CPU writes one byte into UART_DAT, TXPTR increases one. + * | | |When one byte of TX FIFO is transferred to Transmitter Shift Register, TXPTR decreases one. + * |[22] |TXEMPTY |Transmitter FIFO Empty (Read Only) + * | | |This bit indicates TX FIFO empty or not. + * | | |When the last byte of TX FIFO has been transferred to Transmitter Shift Register, hardware sets this bit high. + * | | |It will be cleared when writing data into DAT (TX FIFO not empty). + * |[23] |TX_FULL |Transmitter FIFO Full (Read Only) + * | | |This bit indicates TX FIFO full or not. + * | | |This bit is set when TXPTR is equal to 64/16(UART0/UART1~5), otherwise is cleared by hardware. + * |[24] |TXOVIF |TX Overflow Error Interrupt Flag (Read Only) + * | | |If TX FIFO (UART_DAT) is full, an additional write to UART_DAT will cause this bit to + * | | |logic 1. + * | | |Note: This bit is read only, but it can be cleared by writing '1' to it. + * |[28] |TXEMPTYF |Transmitter Empty Flag (Read Only) + * | | |Bit is set by hardware when TX FIFO (UART_DAT) is empty and the STOP bit of the last byte has been transmitted. + * | | |Bit is cleared automatically when TX FIFO is not empty or the last byte transmission has not completed. + */ + __IO uint32_t FIFOSTS; + + /** + * INTSTS + * =================================================================================================== + * Offset: 0x1C UARTx Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RDAIF |Receive Data Available Interrupt Flag (Read Only) + * | | |When the number of bytes in the RX FIFO equals the RFITL then the RDAIF will be set. + * | | |If RDAIEN bit (UART_INTEN[0]) is enabled, the RDA interrupt will be generated. + * | | |Note: This bit is read only and it will be cleared when the number of unread bytes of RX FIFO drops below the threshold level (RFITL). + * |[1] |THREIF |Transmit Holding Register Empty Interrupt Flag (Read Only) + * | | |This bit is set when the last data of TX FIFO is transferred to Transmitter Shift Register. + * | | |If THREIEN bit (UART_INTEN[1]) is enabled, the THRE interrupt will be generated. + * | | |Note: This bit is read only and it will be cleared when writing data into DAT (TX FIFO not empty). + * |[2] |RLSIF |Receive Line Interrupt Flag (Read Only) + * | | |This bit is set when the RX receive data have parity error, framing error or break error (at least one of 3 bits, BIF, FEF and PEF, is set). + * | | |If RLSIEN bit (UART_INTEN[2]) is enabled, the RLS interrupt will be generated. + * | | |Note1: In RS-485 function mode, this field include receiver detect any address byte received address byte character (bit9 = '1') bit. + * | | |Note2: In SC function mode, this field includes error retry over flag . + * | | |Note3: This bit is read only and reset to 0 when all bits of BIF, FEF and PEF are cleared. + * |[3] |MODENIF |MODEM Interrupt Flag (Read Only) + * | | |This bit is set when the CTS pin has state change (CTSDETF=1). + * | | |If MODEMIEN bit (UART_INTEN[3]) is enabled, the Modem interrupt will be generated. + * | | |Note: This bit is read only and reset to 0 when bit CTSDETF is cleared by a write 1 on CTSDETF. + * |[4] |RXTOIF |Time-Out Interrupt Flag (Read Only) + * | | |This bit is set when the RX FIFO is not empty and no activities occurred in the RX FIFO and the time-out counter equal to TOIC. + * | | |If TIME_OUT_IEN bit (UART_INTEN[11]) is enabled, the Time-out interrupt will be generated. + * | | |Note: This bit is read only and user can read UART_DAT (RX is in active) to clear it. + * |[5] |BUFERRIF |Buffer Error Interrupt Flag (Read Only) + * | | |This bit is set when the TX or RX FIFO overflows (TXOVIF or RXOVIF is set). + * | | |When BERRIF is set, the transfer maybe is not correct. + * | | |If BUFERRIEN bit (UART_INTEN[5]) is enabled, the buffer error interrupt will be generated. + * | | |Note: This bit is cleared when both TXOVIF and RXOVIF are cleared. + * |[7] |LIN_IF |LIN Bus Flag (Read Only) + * | | |This bit is set when LIN slave header detect (SLVHDETF=1), LIN break detect (BRKDETF=1), bit error detect (BITEF=1), LIN slave ID parity error (SLVIDPEF) or LIN slave header error detect (SLVHEF) If LIN_RX_BRK_ IEN bit (UART_INTEN[8]) is enabled the LIN interrupt will be generated. + * | | |Note: This bit is cleared when both SLVHDETF and LIN_BRDER_F and BITEF and LINS_IDPENR_F and SLVHEF are cleared + * |[8] |RDAINT |Receive Data Available Interrupt Indicator (Read Only) + * | | |This bit is set if RDAIEN and RDAIF are both set to 1. + * | | |0 = No RDA interrupt is generated. + * | | |1 = RDA interrupt is generated. + * |[9] |THREINT |Transmit Holding Register Empty Interrupt + * | | |Indicator (Read Only) + * | | |This bit is set if THREIEN and THREIF are both set to 1. + * | | |0 = No THRE interrupt is generated. + * | | |1 = THRE interrupt is generated. + * |[10] |RLSINT |Receive Line Status Interrupt Indicator (Read Only) + * | | |This bit is set if RLSIEN and RLSIF are both set to 1. + * | | |0 = No RLS interrupt is generated. + * | | |1 = RLS interrupt is generated. + * |[11] |MODEMINT |MODEM Status Interrupt Indicator (Read Only) + * | | |This bit is set if MODEMIEN and MODENIF are both set to 1. + * | | |0 = No Modem interrupt is generated. + * | | |1 = Modem interrupt is generated. + * |[12] |RXTOINT |Time-Out Interrupt Indicator (Read Only) + * | | |This bit is set if TOUT_IEN and RXTOIF are both set to 1. + * | | |0 = No Tout interrupt is generated. + * | | |1 = Tout interrupt is generated. + * |[13] |BUFERRINT |Buffer Error Interrupt Indicator (Read Only) + * | | |This bit is set if BUFERRIEN and BERRIF are both set to 1. + * | | |0 = No buffer error interrupt is generated. + * | | |1 = The buffer error interrupt is generated. + * |[15] |LININT |LIN Bus Interrupt Indicator (Read Only) + * | | |This bit is set if LIN_IEN and LIN_RX_BREAK_IF are both set to 1. + * | | |0 = No LIN RX Break interrupt is generated. + * | | |1 = LIN RX Break interrupt is generated. + * |[18] |HWRLSIF |In DMA Mode, Receive Line Status Flag (Read Only) + * | | |This bit is set when the RX receive data have parity error, framing error or break error (at least one of 3 bits, BIF, FEF and PEF, is set). + * | | |If RLSIEN bit (UART_INTEN[2]) is enabled, the RLS interrupt will be generated. + * | | |Note1: In RS-485 function mode, this field includes receiver detect any address byte received address byte character (bit9 = '1') bit. + * | | |Note2: In SC function mode, this field includes error retry over flag. + * | | |Note3: This bit is read only and reset to 0 when all bits of BIF, FEF and PEF are cleared. + * |[19] |HWMODIF |In DMA Mode, MODEM Interrupt Flag (Read Only) + * | | |This bit is set when the CTS pin has state change (CTSDETF = 1). + * | | |If MODEMIEN (UART_INTEN[3]) is enabled, the Modem interrupt will be generated. + * | | |Note: This bit is read only and reset to 0 when bit CTSDETF is cleared by a write 1 on CTSDETF. + * |[20] |HWTOIF |In DMA Mode, Time-Out Interrupt Flag (Read Only) + * | | |This bit is set when the RX FIFO is not empty and no activities occurred in the RX FIFO and the time-out counter equal to TOIC. + * | | |If TIME_OUT_IEN (UART_INTEN[11]) is enabled, the Time-out interrupt will be generated. + * | | |Note: This bit is read only and user can read UART_DAT (RX is in active) to clear it. + * |[21] |HWBUFEIF |In DMA Mode, Buffer Error Interrupt Flag (Read Only) + * | | |This bit is set when the TX or RX FIFO overflows (TXOVIF or RXOVIF is set). + * | | |When BERRIF is set, the transfer maybe is not correct. + * | | |If BUFERRIEN bit (UART_INTEN [5]) is enabled, the buffer error interrupt will be generated. + * | | |Note: This bit is cleared when both TXOVIF and RXOVIF are cleared. + * |[26] |HWRLSINT |In DMA Mode, Receive Line Status Interrupt Indicator (Read Only) + * | | |This bit is set if RLSIEN and HWRLSIF are both set to 1. + * | | |0 = No RLS interrupt is generated in DMA mode. + * | | |1 = RLS interrupt is generated in DMA mode. + * |[27] |HWMODINT |In DMA Mode, MODEM Status Interrupt Indicator (Read Only) + * | | |This bit is set if MODEMIEN and HWMODIF are both set to 1. + * | | |0 = No Modem interrupt is generated in DMA mode. + * | | |1 = Modem interrupt is generated in DMA mode. + * |[28] |HWTOINT |In DMA Mode, Time-Out Interrupt Indicator (Read Only) + * | | |This bit is set if TOUT_IEN and HWTOIF are both set to 1. + * | | |0 = No Tout interrupt is generated in DMA mode. + * | | |1 = Tout interrupt is generated in DMA mode. + * |[29] |HWBUFEINT |In DMA Mode, Buffer Error Interrupt Indicator (Read Only) + * | | |This bit is set if BUFERRIEN and HWBFERIF are both set to 1. + * | | |0 = No buffer error interrupt is generated in DMA mode. + * | | |1 = The buffer error interrupt is generated in DMA mode. + */ + __IO uint32_t INTSTS; + + /** + * TOUT + * =================================================================================================== + * Offset: 0x20 UARTx Time-out Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |TOIC |Time-Out Interrupt Comparator + * | | |The time-out counter resets and starts counting (the counting clock = baud rate clock) whenever the RX FIFO receives a new data word. + * | | |Once the content of time-out counter (TOUT_CNT) is equal to that of time-out interrupt comparator (TOIC), a receiver time-out interrupt (INT_TOUT) is generated if RXTOIEN (UART_INTEN[4]). + * | | |A new incoming data word or RX FIFO empty clears INT_TOUT. + * | | |In order to avoid receiver time-out interrupt generation immediately during one character is being received, TOIC value should be set between 40 and 255. + * | | |So, for example, if TOIC is set with 40, the time-out interrupt is generated after four characters are not received when 1 stop bit and no parity check is set for UART transfer. + * |[8:15] |DLY |TX Delay Time Value + * | | |This field is use to programming the transfer delay time between the last stop bit and next start bit. + * | | |Note: The counter clock is baud rate clock + */ + __IO uint32_t TOUT; + + /** + * BAUD + * =================================================================================================== + * Offset: 0x24 UARTx Baud Rate Divisor Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |BRD |Baud Rate Divider + * | | |The field indicated the baud rate divider + * |[24:27] |EDIVM1 |Divider X + * | | |The baud rate divider M = X+1. + * |[28] |BAUDM0 |Divider X Equal To 1 + * | | |0 = Divider M = X (the equation of M = X+1, but EDIVM1 (UART_BAUD[27:24]) must >= 8). + * | | |1 = Divider M = 1 (the equation of M = 1, but BRD (UART_BAUD[15:0]) must >= 3). + * | | |Refer to the table below for more information. + * |[29] |BAUDM1 |Divider X Enable Control + * | | |The BRD = Baud Rate Divider, and the baud rate equation is + * | | |Baud Rate = Clock / [M * (BRD + 2)]; The default value of M is 16. + * | | |0 = Divider X Disabled (the equation of M = 16). + * | | |1 = Divider X Enabled (the equation of M = X+1, but EDIVM1 (UART_BAUD[27:24]) must >= 8). + * | | |Refer to the table below for more information. + * | | |Note: In IrDA mode, this bit must disable. + */ + __IO uint32_t BAUD; + + /** + * IRDA + * =================================================================================================== + * Offset: 0x28 UARTx IrDA Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[1] |TXEN |IrDA Receiver/Transmitter Selection Enable Bit + * | | |0 = IrDA receiver Enabled. + * | | |1 = IrDA transmitter Enabled. + * |[5] |TXINV |IrDA Inverse Transmitting Output Signal + * | | |0 = No inversion. + * | | |1 = Inverse TX output signal. + * |[6] |RXINV |IrDA Inverse Receive Input Signal + * | | |0 = No inversion. + * | | |1 = Inverse RX input signal. + * |[7] |FIXPULSE |Pulse width of TX is fixed 1.6us. + */ + __IO uint32_t IRDA; + + /** + * ALTCTL + * =================================================================================================== + * Offset: 0x2C UARTx Alternate Control/Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |BKFL |LIN Break Field Length + * | | |This field indicates a 4-bit LIN TX break field count. + * | | |Note1: This break field length is BRKFL + 1. + * | | |Note2: According to LIN spec, the reset value is 0xC (break field length = 13). + * |[6] |LINRXEN |LIN RX Enable Control + * | | |0 = LIN RX mode Disabled. + * | | |1 = LIN RX mode Enabled. + * |[7] |LINTXEN |LIN TX Break Mode Enable Control + * | | |The LIN TX header can be "break field" or "break and sync field" or "break, sync and frame ID field" depending on the setting HSEL register. + * | | |0 = Send LIN TX header Disabled. + * | | |1 = Send LIN TX header Enabled. + * | | |Note: When transmitter header field (it may be "break" or "break + sync" or "break + sync + frame ID" selected by HSEL field) transfer operation finished, this bit will be cleared automatically. + * |[8] |RS485NMM |RS-485 Normal Multi-Drop Operation Mode (NMM) + * | | |0 = RS-485 Normal Multi-drop Operation Mode (NMM) Disabled. + * | | |1 = RS-485 Normal Multi-drop Operation Mode (NMM) Enabled. + * | | |Note: It can't be active with RS-485_AAD operation mode. + * |[9] |RS485AAD |RS-485 Auto Address Detection Operation Mode (AAD) + * | | |0 = RS-485 Auto Address Detection (AAD) Operation mode Disabled. + * | | |1 = RS-485 Auto Address Detection (AAD) Operation mode Enabled. + * | | |Note: It can't be active with RS-485_NMM operation mode. + * |[10] |RS485AUD |RS-485 Auto Direction Mode (AUD) + * | | |0 = RS-485 Auto Direction Operation (AUO) mode Disabled. + * | | |1 = RS-485 Auto Direction Operation (AUO) mode Enabled. + * | | |Note: It can be active with RS-485_AAD or RS-485_NMM operation mode. + * |[15] |ADDRDEN |RS-485 Address Detection Enable Control + * | | |This bit is use to enable RS-485 address detection mode. + * | | |0 = address detection mode Disabled. + * | | |1 = Address detection mode Enabled. + * | | |Note: This field is used for RS-485 any operation mode. + * |[24:31] |ADDRMV |Address Match Value + * | | |This field contains the RS-485 address match values. + * | | |Note: This field is used for RS-485 auto address detection mode. + */ + __IO uint32_t ALTCTL; + + /** + * FUNCSEL + * =================================================================================================== + * Offset: 0x30 UARTx Function Select Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |FUNCSEL |Function Select Enable Control + * | | |000 = UART function. + * | | |001 = LIN function Enabled. + * | | |010 = IrDA function Enabled. + * | | |011 = RS-485 function Enabled. + * | | |100 = Smart-Card function Enabled. + */ + __IO uint32_t FUNCSEL; + + /** + * LINCTL + * =================================================================================================== + * Offset: 0x34 UARTx LIN Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SLVEN |LIN Slave Mode Enable Control + * | | |0 = LIN slave mode Disabled. + * | | |1 = LIN slave mode Enabled. + * |[1] |SLVHDEN |LIN Slave Header Detection Enable Control + * | | |0 = LIN slave header detection Disabled. + * | | |1 = LIN slave header detection Enabled. + * | | |Note1: This bit only valid in LIN slave mode (SLVEN = 1). + * | | |Note2: In LIN function mode, when header field (break + sync + frame ID) is detected, hardware will generate an interrupt to CPU (INT_LIN) and the SLVHDETF flag (UART_LINSTS[0]) will be asserted. + * |[2] |SLVAREN |LIN Slave Automatic Resynchronization Mode Enable Control + * | | |0 = LIN automatic resynchronization Disabled. + * | | |1 = LIN automatic resynchronization Enabled. + * | | |Note1: This bit only valid in LIN slave mode (SLVEN = 1). + * | | |Note2: When operating in Automatic Resynchronization mode, the baud rate setting must be mode2 (BAUDM1 (UART_BAUD[29]) and BAUDM0 (UART_BAUD[28]) must be 1). + * | | |Note3: The control and interactions of this field are explained in 6.31.5.3. + * |[3] |SLVDUEN |LIN Slave Divider Update Method Enable Control + * | | |0 = UART_BAUD is updated as soon as UART_BAUD is writing by software (if no automatic resynchronization update occurs at the same time). + * | | |1 = UART_BAUD is updated at the next received character. + * | | |User must set the bit before checksum reception. + * | | |Note1: This bit only valid in LIN slave mode (SLVEN = 1). + * | | |Note2: This bit is used for LIN slave automatic resynchronization mode (for non-automatic resynchronization mode, this bit should be kept cleared). + * | | |Note3: The control and interactions of this field are explained in 6.31.5.3. + * |[4] |MUTE |LIN Mute Mode Enable Control + * | | |0 = LIN mute mode. Disabled + * | | |1 = LIN mute mode Enabled. + * | | |Note: The wake-up condition from mute mode and each control and interactions of this field are explained in 6.31.5.3. + * |[8] |SENDH |LIN TX Send Header Enable Control + * | | |The LIN TX header can be "break field" or "break and sync field" or "break, sync and frame ID field" depending on the setting HSEL register. + * | | |0 = Send LIN TX header Disabled. + * | | |1 = Send LIN TX header Enabled. + * | | |Note: When transmitter header field (it may be "break" or "break + sync" or "break + sync + frame ID" selected by HSEL field) transfer operation finished, this bit will be cleared automatically. + * |[9] |IDPEN |LIN ID Parity Enable Control + * | | |0 = LIN frame ID parity Disabled. + * | | |1 = LIN frame ID parity Enabled. + * | | |Note1: This bit can be used for LIN master to sending header field (SENDH = 1 and HSEL = 2'b10) or be used for enable LIN slave received frame ID parity checked. + * | | |Note2: This bit is only used when operation header transmitter is in HSEL = 2'b10. + * |[10] |BRKDETEN |LIN Break Detection Enable Control + * | | |When detect great than 11/10 bits are detected as 0, and are followed by a delimiter character, the BRKDETF flag (UART_LINSTS[8]) at the end of break field. + * | | |If the LINIEN bit (UART_INTEN[8]) = 1, an interrupt will be generated. + * | | |0 = LIN break detection Disabled. + * | | |1 = LIN break detection Enabled. + * |[11] |RXOFF |If the receiver is be enabled (RXOFF = 0), all received byte data will be accepted and stored in the RX-FIFO, and if the receiver is disabled (RXOFF = 1), all received byte data will be ignore. + * | | |0 = Bit error detection function Disabled. + * | | |1 = Bit error detection Enabled. + * | | |Note: This bit is only valid when operating in LIN function mode (UART_FUNCSEL = 2'b01). + * |[12] |BITERREN |Bit Error Detect Enable Control + * | | |0 = Bit error detection function Disabled. + * | | |1 = Bit error detection Enabled. + * | | |Note: In LIN function mode, when occur bit error, hardware will generate an interrupt to CPU (INT_LIN) and the BITEF (UART_LINSTS[9]) flag will be asserted. + * |[16:19] |BRKFL |LIN Break Field Length + * | | |This field indicates a 4-bit LIN TX break field count. + * | | |Note1: These registers are shadow registers of LIN_BKFL (UART_ALTCTL[3:0]), User can read/write it by setting LIN_BKFL (UART_ALTCTL[3:0]) or LIN_BKFL (UART_LINCTL[19:16]). + * | | |Note2: This break field length is BRKFL + 1. + * | | |Note3: According to LIN spec, the reset value is 0XC (break field length = 13). + * |[20:21] |BSL |LIN Break/Sync Delimiter Length + * | | |00 = LIN break/sync delimiter length is 1 bit time. + * | | |10 = The LIN break/sync delimiter length is 2 bit time. + * | | |10 = The LIN break/sync delimiter length is 3 bit time. + * | | |11 = The LIN break/sync delimiter length is 4 bit time. + * | | |Note: This bit used for LIN master to send header field. + * |[22:23] |HSEL |LIN Header Selection + * | | |00 = LIN header includes "break field". + * | | |01 = LIN header includes "break field" and "sync field". + * | | |10 = LIN header includes "break field", "sync field" and "frame ID field". + * | | |11 = LIN header includes "break field", "sync field" and "frame ID field", but this mode only supports Receiver mode, not support transmitter mode. + * | | |This mode difference with mode "10"; in this mode, the receiver will receive ID field (not check the PID (UART_LINCTL[31:24]) register) and when received ID field the SLVHDETF will be asserted (if SLVHDEN (UART_LINCTL[1]) be set). + * | | |Note: This bit is used to master mode for LIN to sending header field (SENDH = 1) or used to slave to indicates wake-up condition from mute mode (MUTE). + * |[24:31] |PID |This Field Contains The LIN Frame ID Value In LIN Function Mode, The Frame ID Parity Can Be Generated By Software Or Hardware Depending On UART_LINCTL [IDPEN] + * | | |If the parity generated by hardware (IDPEN (UART_LINCTL[9]) = 1), user fill ID0~ID5, hardware will calculi P0 and P1, otherwise user must filled frame ID and parity in this field. + * | | |Note1: User can fill any 8-bit value to this field and the bit 24 indicates ID0 (LSB first) + * | | |Note2: This field can be used for LIN Master mode or Slave mode. + */ + __IO uint32_t LINCTL; + + /** + * LINSTS + * =================================================================================================== + * Offset: 0x38 UARTx LIN Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SLVHDETF |LIN Slave Header Detection Flag (Read Only) + * | | |This bit is set by hardware when a LIN header is detected in LIN slave mode and be cleared by writing 1 to it. + * | | |0 = LIN header not detected. + * | | |1 = LIN header detected (break + sync + frame ID). + * | | |Note1: This bit is read only, but can be cleared by writing 1 to it. + * | | |Note2: This bit is only valid in LIN slave mode (SLVEN (UART_LINCTL[0]) = 1) and LIN slave header detection function (SLVHDEN (UART_LINCTL[1])) is enabled. + * | | |Note3: When the ID parity check (IDPEN (UART_LINCTL[9]) = 1) is enabled, if hardware detect complete harder ("break + sync + frame ID"), the LINS_HEDT_F (UART_LINCTL[1]) will be set no matter the frame ID is corrected or not. + * |[1] |SLVHEF |LIN Slave Header Error Flag (Read Only) + * | | |This bit is set by hardware when a LIN header error is detected in LIN slave mode and be cleared by writing 1 to it. + * | | |The header include "break delimiter is too short", "frame error in sync field or Identifier field", "sync field data is not 0x55 without automatic resynchronization mode", "sync field deviation error with automatic resynchronization mode", "sync field measure time-out with automatic resynchronization mode" and "LIN header reception time-out". + * | | |0 = LIN header error not detected. + * | | |1 = LIN header error detected. + * | | |Note1: This bit is read only, but can be cleared by writing 1 to it. + * | | |Note2: This bit is only valid in LIN slave mode (SLVEN (UART_LINCTL[0]) = 1) and LIN slave header detection function (SLVHDEN (UART_LINCTL[1])) is enabled. + * |[2] |SLVIDPEF |LIN Slave ID Parity Error Flag (Read Only) + * | | |This bit is set by hardware when receipted frame ID parity is not correct. + * | | |0 = no active. + * | | |1 = Receipted frame ID parity is not correct. + * | | |Note1: This bit is read only, but can be cleared by writing 1 to it. + * | | |Note2: This bit is only valid in LIN slave mode (SLVEN (UART_LINCTL[0]) = 1) and LIN frame ID parity check function (IDPEN (UART_LINCTL[9])) is enabled. + * |[3] |SLVSYNCF |LIN Slave Sync Field + * | | |This bit indicates that the LIN sync field is being analyzed. + * | | |When the receiver header have some error been detect, user must to reset the internal circuit to re-search new frame header by writing 1 to this bit. + * | | |0 = The current character is not at LIN sync state. + * | | |1 = The current character is at LIN sync state. + * | | |Note1: This bit only valid in LIN Slave mode (SLVEN = 1). + * | | |Note2: This bit is read only, but can be cleared by writing 1 to it. + * | | |Note3: When user writing 1 to it, hardware will reload the initial baud-rate and re-search new frame header, the control and interactions of this field are explained in 6.31.5.3. + * |[8] |BRKDETF |LIN Break Detection Flag (Read Only) + * | | |This bit is set by hardware when a break is detected and be cleared by writing 1 to it. + * | | |0 = LIN break not detected. + * | | |1 = LIN break detected. + * | | |Note1: This bit is read only, but can be cleared by writing 1 to it. + * | | |Note2: This bit is only valid when enable LIN break detection function (BRKDETEN (UART_LINCTL[10])) + * |[9] |BITEF |Bit Error Detect Status Flag (Read Only) + * | | |At TX transfer state, hardware will monitoring the bus state, if the input pin (SIN) state not equals to the output pin (SOUT) state, BITEF will be set. + * | | |When occur bit error, hardware will generate an interrupt to CPU (INT_LIN). + * | | |Note1: This bit is read only, but can be cleared by writing 1 to it. + * | | |Note2: This bit is only valid when enable bit error detection function (BRKL (UART_LINCTL[12]) == 1). + */ + __IO uint32_t LINSTS; + + /** + * LINDEBUG + * =================================================================================================== + * Offset: 0x3C UARTx LIN Debug Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DEVERRF |LIN Header Deviation Error (Read Only) + * | | |This bit indicates the header error cause by the sync field deviation error or sync field measure time-out with automatic resynchronization mode. + * |[1] |TOF |LIN Header Time-Out (Read Only) + * | | |This bit indicates the header error cause by the LIN header reception time-out. + * |[2] |FRAMEERRF |LIN Header Frame Error Flag (Read Only) + * | | |This bit indicates the header error cause by break delimiter is too short or frame error in sync field or Identifier field. + * |[3] |SYNCERRF |LIN Header Sync Data Error (Read Only) + * | | |This bit indicates the header error cause by the LIN received sync data is not 0x55. + */ + __IO uint32_t LINDEBUG; + + +} UART_T; + +/** + @addtogroup UART_CONST UART Bit Field Definition + Constant Definitions for UART Controller +@{ */ + +#define UART_DAT_DAT_Pos (0) /*!< UART_T::DAT: DAT Position */ +#define UART_DAT_DAT_Msk (0xfful << UART_DAT_DAT_Pos) /*!< UART_T::DAT: DAT Mask */ + +#define UART_INTEN_RDAIEN_Pos (0) /*!< UART_T::INTEN: RDAIEN Position */ +#define UART_INTEN_RDAIEN_Msk (0x1ul << UART_INTEN_RDAIEN_Pos) /*!< UART_T::INTEN: RDAIEN Mask */ + +#define UART_INTEN_THREIEN_Pos (1) /*!< UART_T::INTEN: THREIEN Position */ +#define UART_INTEN_THREIEN_Msk (0x1ul << UART_INTEN_THREIEN_Pos) /*!< UART_T::INTEN: THREIEN Mask */ + +#define UART_INTEN_RLSIEN_Pos (2) /*!< UART_T::INTEN: RLSIEN Position */ +#define UART_INTEN_RLSIEN_Msk (0x1ul << UART_INTEN_RLSIEN_Pos) /*!< UART_T::INTEN: RLSIEN Mask */ + +#define UART_INTEN_MODEMIEN_Pos (3) /*!< UART_T::INTEN: MODEMIEN Position */ +#define UART_INTEN_MODEMIEN_Msk (0x1ul << UART_INTEN_MODEMIEN_Pos) /*!< UART_T::INTEN: MODEMIEN Mask */ + +#define UART_INTEN_RXTOIEN_Pos (4) /*!< UART_T::INTEN: RXTOIEN Position */ +#define UART_INTEN_RXTOIEN_Msk (0x1ul << UART_INTEN_RXTOIEN_Pos) /*!< UART_T::INTEN: RXTOIEN Mask */ + +#define UART_INTEN_BUFERRIEN_Pos (5) /*!< UART_T::INTEN: BUFERRIEN Position */ +#define UART_INTEN_BUFERRIEN_Msk (0x1ul << UART_INTEN_BUFERRIEN_Pos) /*!< UART_T::INTEN: BUFERRIEN Mask */ + +#define UART_INTEN_WKCTSIEN_Pos (6) /*!< UART_T::INTEN: WKCTSIEN Position */ +#define UART_INTEN_WKCTSIEN_Msk (0x1ul << UART_INTEN_WKCTSIEN_Pos) /*!< UART_T::INTEN: WKCTSIEN Mask */ + +#define UART_INTEN_LINIEN_Pos (8) /*!< UART_T::INTEN: LINIEN Position */ +#define UART_INTEN_LINIEN_Msk (0x1ul << UART_INTEN_LINIEN_Pos) /*!< UART_T::INTEN: LINIEN Mask */ + +#define UART_INTEN_TOCNTEN_Pos (11) /*!< UART_T::INTEN: TOCNTEN Position */ +#define UART_INTEN_TOCNTEN_Msk (0x1ul << UART_INTEN_TOCNTEN_Pos) /*!< UART_T::INTEN: TOCNTEN Mask */ + +#define UART_INTEN_ATORTSEN_Pos (12) /*!< UART_T::INTEN: ATORTSEN Position */ +#define UART_INTEN_ATORTSEN_Msk (0x1ul << UART_INTEN_ATORTSEN_Pos) /*!< UART_T::INTEN: ATORTSEN Mask */ + +#define UART_INTEN_ATOCTSEN_Pos (13) /*!< UART_T::INTEN: ATOCTSEN Position */ +#define UART_INTEN_ATOCTSEN_Msk (0x1ul << UART_INTEN_ATOCTSEN_Pos) /*!< UART_T::INTEN: ATOCTSEN Mask */ + +#define UART_INTEN_TXPDMAEN_Pos (14) /*!< UART_T::INTEN: TXPDMAEN Position */ +#define UART_INTEN_TXPDMAEN_Msk (0x1ul << UART_INTEN_TXPDMAEN_Pos) /*!< UART_T::INTEN: TXPDMAEN Mask */ + +#define UART_INTEN_RXPDMAEN_Pos (15) /*!< UART_T::INTEN: RXPDMAEN Position */ +#define UART_INTEN_RXPDMAEN_Msk (0x1ul << UART_INTEN_RXPDMAEN_Pos) /*!< UART_T::INTEN: RXPDMAEN Mask */ + +#define UART_FIFO_RXRST_Pos (1) /*!< UART_T::FIFO: RXRST Position */ +#define UART_FIFO_RXRST_Msk (0x1ul << UART_FIFO_RXRST_Pos) /*!< UART_T::FIFO: RXRST Mask */ + +#define UART_FIFO_TXRST_Pos (2) /*!< UART_T::FIFO: TXRST Position */ +#define UART_FIFO_TXRST_Msk (0x1ul << UART_FIFO_TXRST_Pos) /*!< UART_T::FIFO: TXRST Mask */ + +#define UART_FIFO_RFITL_Pos (4) /*!< UART_T::FIFO: RFITL Position */ +#define UART_FIFO_RFITL_Msk (0xful << UART_FIFO_RFITL_Pos) /*!< UART_T::FIFO: RFITL Mask */ + +#define UART_FIFO_RXOFF_Pos (8) /*!< UART_T::FIFO: RXOFF Position */ +#define UART_FIFO_RXOFF_Msk (0x1ul << UART_FIFO_RXOFF_Pos) /*!< UART_T::FIFO: RXOFF Mask */ + +#define UART_FIFO_RTSTRGLV_Pos (16) /*!< UART_T::FIFO: RTSTRGLV Position */ +#define UART_FIFO_RTSTRGLV_Msk (0xful << UART_FIFO_RTSTRGLV_Pos) /*!< UART_T::FIFO: RTSTRGLV Mask */ + +#define UART_LINE_WLS_Pos (0) /*!< UART_T::LINE: WLS Position */ +#define UART_LINE_WLS_Msk (0x3ul << UART_LINE_WLS_Pos) /*!< UART_T::LINE: WLS Mask */ + +#define UART_LINE_NSB_Pos (2) /*!< UART_T::LINE: NSB Position */ +#define UART_LINE_NSB_Msk (0x1ul << UART_LINE_NSB_Pos) /*!< UART_T::LINE: NSB Mask */ + +#define UART_LINE_PBE_Pos (3) /*!< UART_T::LINE: PBE Position */ +#define UART_LINE_PBE_Msk (0x1ul << UART_LINE_PBE_Pos) /*!< UART_T::LINE: PBE Mask */ + +#define UART_LINE_EPE_Pos (4) /*!< UART_T::LINE: EPE Position */ +#define UART_LINE_EPE_Msk (0x1ul << UART_LINE_EPE_Pos) /*!< UART_T::LINE: EPE Mask */ + +#define UART_LINE_SPE_Pos (5) /*!< UART_T::LINE: SPE Position */ +#define UART_LINE_SPE_Msk (0x1ul << UART_LINE_SPE_Pos) /*!< UART_T::LINE: SPE Mask */ + +#define UART_LINE_BCB_Pos (6) /*!< UART_T::LINE: BCB Position */ +#define UART_LINE_BCB_Msk (0x1ul << UART_LINE_BCB_Pos) /*!< UART_T::LINE: BCB Mask */ + +#define UART_MODEM_RTS_Pos (1) /*!< UART_T::MODEM: RTS Position */ +#define UART_MODEM_RTS_Msk (0x1ul << UART_MODEM_RTS_Pos) /*!< UART_T::MODEM: RTS Mask */ + +#define UART_MODEM_RTSACTLV_Pos (9) /*!< UART_T::MODEM: RTSACTLV Position */ +#define UART_MODEM_RTSACTLV_Msk (0x1ul << UART_MODEM_RTSACTLV_Pos) /*!< UART_T::MODEM: RTSACTLV Mask */ + +#define UART_MODEM_RTSSTS_Pos (13) /*!< UART_T::MODEM: RTSSTS Position */ +#define UART_MODEM_RTSSTS_Msk (0x1ul << UART_MODEM_RTSSTS_Pos) /*!< UART_T::MODEM: RTSSTS Mask */ + +#define UART_MODEMSTS_CTSDETF_Pos (0) /*!< UART_T::MODEMSTS: CTSDETF Position */ +#define UART_MODEMSTS_CTSDETF_Msk (0x1ul << UART_MODEMSTS_CTSDETF_Pos) /*!< UART_T::MODEMSTS: CTSDETF Mask */ + +#define UART_MODEMSTS_CTSSTS_Pos (4) /*!< UART_T::MODEMSTS: CTSSTS Position */ +#define UART_MODEMSTS_CTSSTS_Msk (0x1ul << UART_MODEMSTS_CTSSTS_Pos) /*!< UART_T::MODEMSTS: CTSSTS Mask */ + +#define UART_MODEMSTS_CTSACTLV_Pos (8) /*!< UART_T::MODEMSTS: CTSACTLV Position */ +#define UART_MODEMSTS_CTSACTLV_Msk (0x1ul << UART_MODEMSTS_CTSACTLV_Pos) /*!< UART_T::MODEMSTS: CTSACTLV Mask */ + +#define UART_FIFOSTS_RXOVIF_Pos (0) /*!< UART_T::FIFOSTS: RXOVIF Position */ +#define UART_FIFOSTS_RXOVIF_Msk (0x1ul << UART_FIFOSTS_RXOVIF_Pos) /*!< UART_T::FIFOSTS: RXOVIF Mask */ + +#define UART_FIFOSTS_SCERR_Pos (2) /*!< UART_T::FIFOSTS: SCERR Position */ +#define UART_FIFOSTS_SCERR_Msk (0x1ul << UART_FIFOSTS_SCERR_Pos) /*!< UART_T::FIFOSTS: SCERR Mask */ + +#define UART_FIFOSTS_ADDRDETF_Pos (3) /*!< UART_T::FIFOSTS: ADDRDETF Position */ +#define UART_FIFOSTS_ADDRDETF_Msk (0x1ul << UART_FIFOSTS_ADDRDETF_Pos) /*!< UART_T::FIFOSTS: ADDRDETF Mask */ + +#define UART_FIFOSTS_PEF_Pos (4) /*!< UART_T::FIFOSTS: PEF Position */ +#define UART_FIFOSTS_PEF_Msk (0x1ul << UART_FIFOSTS_PEF_Pos) /*!< UART_T::FIFOSTS: PEF Mask */ + +#define UART_FIFOSTS_FEF_Pos (5) /*!< UART_T::FIFOSTS: FEF Position */ +#define UART_FIFOSTS_FEF_Msk (0x1ul << UART_FIFOSTS_FEF_Pos) /*!< UART_T::FIFOSTS: FEF Mask */ + +#define UART_FIFOSTS_BIF_Pos (6) /*!< UART_T::FIFOSTS: BIF Position */ +#define UART_FIFOSTS_BIF_Msk (0x1ul << UART_FIFOSTS_BIF_Pos) /*!< UART_T::FIFOSTS: BIF Mask */ + +#define UART_FIFOSTS_RXPTR_Pos (8) /*!< UART_T::FIFOSTS: RXPTR Position */ +#define UART_FIFOSTS_RXPTR_Msk (0x3ful << UART_FIFOSTS_RXPTR_Pos) /*!< UART_T::FIFOSTS: RXPTR Mask */ + +#define UART_FIFOSTS_RXEMPTY_Pos (14) /*!< UART_T::FIFOSTS: RXEMPTY Position */ +#define UART_FIFOSTS_RXEMPTY_Msk (0x1ul << UART_FIFOSTS_RXEMPTY_Pos) /*!< UART_T::FIFOSTS: RXEMPTY Mask */ + +#define UART_FIFOSTS_RXFULL_Pos (15) /*!< UART_T::FIFOSTS: RXFULL Position */ +#define UART_FIFOSTS_RXFULL_Msk (0x1ul << UART_FIFOSTS_RXFULL_Pos) /*!< UART_T::FIFOSTS: RXFULL Mask */ + +#define UART_FIFOSTS_TXPTR_Pos (16) /*!< UART_T::FIFOSTS: TXPTR Position */ +#define UART_FIFOSTS_TXPTR_Msk (0x3ful << UART_FIFOSTS_TXPTR_Pos) /*!< UART_T::FIFOSTS: TXPTR Mask */ + +#define UART_FIFOSTS_TXEMPTY_Pos (22) /*!< UART_T::FIFOSTS: TXEMPTY Position */ +#define UART_FIFOSTS_TXEMPTY_Msk (0x1ul << UART_FIFOSTS_TXEMPTY_Pos) /*!< UART_T::FIFOSTS: TXEMPTY Mask */ + +#define UART_FIFOSTS_TXFULL_Pos (23) /*!< UART_T::FIFOSTS: TXFULL Position */ +#define UART_FIFOSTS_TXFULL_Msk (0x1ul << UART_FIFOSTS_TXFULL_Pos) /*!< UART_T::FIFOSTS: TXFULL Mask */ + +#define UART_FIFOSTS_TXOVIF_Pos (24) /*!< UART_T::FIFOSTS: TXOVIF Position */ +#define UART_FIFOSTS_TXOVIF_Msk (0x1ul << UART_FIFOSTS_TXOVIF_Pos) /*!< UART_T::FIFOSTS: TXOVIF Mask */ + +#define UART_FIFOSTS_TXEMPTYF_Pos (28) /*!< UART_T::FIFOSTS: TXEMPTYF Position */ +#define UART_FIFOSTS_TXEMPTYF_Msk (0x1ul << UART_FIFOSTS_TXEMPTYF_Pos) /*!< UART_T::FIFOSTS: TXEMPTYF Mask */ + +#define UART_INTSTS_RDAIF_Pos (0) /*!< UART_T::INTSTS: RDAIF Position */ +#define UART_INTSTS_RDAIF_Msk (0x1ul << UART_INTSTS_RDAIF_Pos) /*!< UART_T::INTSTS: RDAIF Mask */ + +#define UART_INTSTS_THREIF_Pos (1) /*!< UART_T::INTSTS: THREIF Position */ +#define UART_INTSTS_THREIF_Msk (0x1ul << UART_INTSTS_THREIF_Pos) /*!< UART_T::INTSTS: THREIF Mask */ + +#define UART_INTSTS_RLSIF_Pos (2) /*!< UART_T::INTSTS: RLSIF Position */ +#define UART_INTSTS_RLSIF_Msk (0x1ul << UART_INTSTS_RLSIF_Pos) /*!< UART_T::INTSTS: RLSIF Mask */ + +#define UART_INTSTS_MODEMIF_Pos (3) /*!< UART_T::INTSTS: MODENIF Position */ +#define UART_INTSTS_MODEMIF_Msk (0x1ul << UART_INTSTS_MODEMIF_Pos) /*!< UART_T::INTSTS: MODENIF Mask */ + +#define UART_INTSTS_RXTOIF_Pos (4) /*!< UART_T::INTSTS: RXTOIF Position */ +#define UART_INTSTS_RXTOIF_Msk (0x1ul << UART_INTSTS_RXTOIF_Pos) /*!< UART_T::INTSTS: RXTOIF Mask */ + +#define UART_INTSTS_BUFERRIF_Pos (5) /*!< UART_T::INTSTS: BUFERRIF Position */ +#define UART_INTSTS_BUFERRIF_Msk (0x1ul << UART_INTSTS_BUFERRIF_Pos) /*!< UART_T::INTSTS: BUFERRIF Mask */ + +#define UART_INTSTS_LINIF_Pos (7) /*!< UART_T::INTSTS: LINIF Position */ +#define UART_INTSTS_LINIF_Msk (0x1ul << UART_INTSTS_LINIF_Pos) /*!< UART_T::INTSTS: LINIF Mask */ + +#define UART_INTSTS_RDAINT_Pos (8) /*!< UART_T::INTSTS: RDAINT Position */ +#define UART_INTSTS_RDAINT_Msk (0x1ul << UART_INTSTS_RDAINT_Pos) /*!< UART_T::INTSTS: RDAINT Mask */ + +#define UART_INTSTS_THREINT_Pos (9) /*!< UART_T::INTSTS: THERINT Position */ +#define UART_INTSTS_THREINT_Msk (0x1ul << UART_INTSTS_THREINT_Pos) /*!< UART_T::INTSTS: THERINT Mask */ + +#define UART_INTSTS_RLSINT_Pos (10) /*!< UART_T::INTSTS: RLSINT Position */ +#define UART_INTSTS_RLSINT_Msk (0x1ul << UART_INTSTS_RLSINT_Pos) /*!< UART_T::INTSTS: RLSINT Mask */ + +#define UART_INTSTS_MODEMINT_Pos (11) /*!< UART_T::INTSTS: MODEMINT Position */ +#define UART_INTSTS_MODEMINT_Msk (0x1ul << UART_INTSTS_MODEMINT_Pos) /*!< UART_T::INTSTS: MODEMINT Mask */ + +#define UART_INTSTS_RXTOINT_Pos (12) /*!< UART_T::INTSTS: RXTOINT Position */ +#define UART_INTSTS_RXTOINT_Msk (0x1ul << UART_INTSTS_RXTOINT_Pos) /*!< UART_T::INTSTS: RXTOINT Mask */ + +#define UART_INTSTS_BUFERRINT_Pos (13) /*!< UART_T::INTSTS: BUFERRINT Position */ +#define UART_INTSTS_BUFERRINT_Msk (0x1ul << UART_INTSTS_BUFERRINT_Pos) /*!< UART_T::INTSTS: BUFERRINT Mask */ + +#define UART_INTSTS_LININT_Pos (15) /*!< UART_T::INTSTS: LININT Position */ +#define UART_INTSTS_LININT_Msk (0x1ul << UART_INTSTS_LININT_Pos) /*!< UART_T::INTSTS: LININT Mask */ + +#define UART_INTSTS_HWRLSIF_Pos (18) /*!< UART_T::INTSTS: HWRLSIF Position */ +#define UART_INTSTS_HWRLSIF_Msk (0x1ul << UART_INTSTS_HWRLSIF_Pos) /*!< UART_T::INTSTS: HWRLSIF Mask */ + +#define UART_INTSTS_HWMODIF_Pos (19) /*!< UART_T::INTSTS: HWMODIF Position */ +#define UART_INTSTS_HWMODIF_Msk (0x1ul << UART_INTSTS_HWMODIF_Pos) /*!< UART_T::INTSTS: HWMODIF Mask */ + +#define UART_INTSTS_HWTOIF_Pos (20) /*!< UART_T::INTSTS: HWTOIF Position */ +#define UART_INTSTS_HWTOIF_Msk (0x1ul << UART_INTSTS_HWTOIF_Pos) /*!< UART_T::INTSTS: HWTOIF Mask */ + +#define UART_INTSTS_HWBUFEIF_Pos (21) /*!< UART_T::INTSTS: HWBUFEIF Position */ +#define UART_INTSTS_HWBUFEIF_Msk (0x1ul << UART_INTSTS_HWBUFEIF_Pos) /*!< UART_T::INTSTS: HWBUFEIF Mask */ + +#define UART_INTSTS_HWRLSINT_Pos (26) /*!< UART_T::INTSTS: HWRLSINT Position */ +#define UART_INTSTS_HWRLSINT_Msk (0x1ul << UART_INTSTS_HWRLSINT_Pos) /*!< UART_T::INTSTS: HWRLSINT Mask */ + +#define UART_INTSTS_HWMODINT_Pos (27) /*!< UART_T::INTSTS: HWMODINT Position */ +#define UART_INTSTS_HWMODINT_Msk (0x1ul << UART_INTSTS_HWMODINT_Pos) /*!< UART_T::INTSTS: HWMODINT Mask */ + +#define UART_INTSTS_HWTOINT_Pos (28) /*!< UART_T::INTSTS: HWTOINT Position */ +#define UART_INTSTS_HWTOINT_Msk (0x1ul << UART_INTSTS_HWTOINT_Pos) /*!< UART_T::INTSTS: HWTOINT Mask */ + +#define UART_INTSTS_HWBUFEINT_Pos (29) /*!< UART_T::INTSTS: HWBUFEINT Position */ +#define UART_INTSTS_HWBUFEINT_Msk (0x1ul << UART_INTSTS_HWBUFEINT_Pos) /*!< UART_T::INTSTS: HWBUFEINT Mask */ + +#define UART_TOUT_TOIC_Pos (0) /*!< UART_T::TOUT: TOIC Position */ +#define UART_TOUT_TOIC_Msk (0xfful << UART_TOUT_TOIC_Pos) /*!< UART_T::TOUT: TOIC Mask */ + +#define UART_TOUT_DLY_Pos (8) /*!< UART_T::TOUT: DLY Position */ +#define UART_TOUT_DLY_Msk (0xfful << UART_TOUT_DLY_Pos) /*!< UART_T::TOUT: DLY Mask */ + +#define UART_BAUD_BRD_Pos (0) /*!< UART_T::BAUD: BRD Position */ +#define UART_BAUD_BRD_Msk (0xfffful << UART_BAUD_BRD_Pos) /*!< UART_T::BAUD: BRD Mask */ + +#define UART_BAUD_EDIVM1_Pos (24) /*!< UART_T::BAUD: EDIVM1 Position */ +#define UART_BAUD_EDIVM1_Msk (0xful << UART_BAUD_EDIVM1_Pos) /*!< UART_T::BAUD: EDIVM1 Mask */ + +#define UART_BAUD_BAUDM0_Pos (28) /*!< UART_T::BAUD: BAUDM0 Position */ +#define UART_BAUD_BAUDM0_Msk (0x1ul << UART_BAUD_BAUDM0_Pos) /*!< UART_T::BAUD: BAUDM0 Mask */ + +#define UART_BAUD_BAUDM1_Pos (29) /*!< UART_T::BAUD: BAUDM1 Position */ +#define UART_BAUD_BAUDM1_Msk (0x1ul << UART_BAUD_BAUDM1_Pos) /*!< UART_T::BAUD: BAUDM1 Mask */ + +#define UART_IRDA_TXEN_Pos (1) /*!< UART_T::IRDA: TXEN Position */ +#define UART_IRDA_TXEN_Msk (0x1ul << UART_IRDA_TXEN_Pos) /*!< UART_T::IRDA: TXEN Mask */ + +#define UART_IRDA_TXINV_Pos (5) /*!< UART_T::IRDA: TXINV Position */ +#define UART_IRDA_TXINV_Msk (0x1ul << UART_IRDA_TXINV_Pos) /*!< UART_T::IRDA: TXINV Mask */ + +#define UART_IRDA_RXINV_Pos (6) /*!< UART_T::IRDA: RXINV Position */ +#define UART_IRDA_RXINV_Msk (0x1ul << UART_IRDA_RXINV_Pos) /*!< UART_T::IRDA: RXINV Mask */ + +#define UART_IRDA_FIXPULSE_Pos (7) /*!< UART_T::IRDA: FIXPULSE Position */ +#define UART_IRDA_FIXPULSE_Msk (0x1ul << UART_IRDA_FIXPULSE_Pos) /*!< UART_T::IRDA: FIXPULSE Mask */ + +#define UART_ALTCTL_BKFL_Pos (0) /*!< UART_T::ALTCTL: BKFL Position */ +#define UART_ALTCTL_BKFL_Msk (0xful << UART_ALTCTL_BKFL_Pos) /*!< UART_T::ALTCTL: BKFL Mask */ + +#define UART_ALTCTL_LINRXEN_Pos (6) /*!< UART_T::ALTCTL: LINRXEN Position */ +#define UART_ALTCTL_LINRXEN_Msk (0x1ul << UART_ALTCTL_LINRXEN_Pos) /*!< UART_T::ALTCTL: LINRXEN Mask */ + +#define UART_ALTCTL_LINTXEN_Pos (7) /*!< UART_T::ALTCTL: LINTXEN Position */ +#define UART_ALTCTL_LINTXEN_Msk (0x1ul << UART_ALTCTL_LINTXEN_Pos) /*!< UART_T::ALTCTL: LINTXEN Mask */ + +#define UART_ALTCTL_RS485NMM_Pos (8) /*!< UART_T::ALTCTL: RS485NMM Position */ +#define UART_ALTCTL_RS485NMM_Msk (0x1ul << UART_ALTCTL_RS485NMM_Pos) /*!< UART_T::ALTCTL: RS485NMM Mask */ + +#define UART_ALTCTL_RS485AAD_Pos (9) /*!< UART_T::ALTCTL: RS485AAD Position */ +#define UART_ALTCTL_RS485AAD_Msk (0x1ul << UART_ALTCTL_RS485AAD_Pos) /*!< UART_T::ALTCTL: RS485AAD Mask */ + +#define UART_ALTCTL_RS485AUD_Pos (10) /*!< UART_T::ALTCTL: RS485AUD Position */ +#define UART_ALTCTL_RS485AUD_Msk (0x1ul << UART_ALTCTL_RS485AUD_Pos) /*!< UART_T::ALTCTL: RS485AUD Mask */ + +#define UART_ALTCTL_ADDRDEN_Pos (15) /*!< UART_T::ALTCTL: ADDRDEN Position */ +#define UART_ALTCTL_ADDRDEN_Msk (0x1ul << UART_ALTCTL_ADDRDEN_Pos) /*!< UART_T::ALTCTL: ADDRDEN Mask */ + +#define UART_ALTCTL_ADDRMV_Pos (24) /*!< UART_T::ALTCTL: ADDRMV Position */ +#define UART_ALTCTL_ADDRMV_Msk (0xfful << UART_ALTCTL_ADDRMV_Pos) /*!< UART_T::ALTCTL: ADDRMV Mask */ + +#define UART_FUNCSEL_FUNCSEL_Pos (0) /*!< UART_T::FUNCSEL: FUNCSEL Position */ +#define UART_FUNCSEL_FUNCSEL_Msk (0x7ul << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_T::FUNCSEL: FUNCSEL Mask */ + +#define UART_LINCTL_SLVEN_Pos (0) /*!< UART_T::LINCTL: SLVEN Position */ +#define UART_LINCTL_SLVEN_Msk (0x1ul << UART_LINCTL_SLVEN_Pos) /*!< UART_T::LINCTL: SLVEN Mask */ + +#define UART_LINCTL_SLVHDEN_Pos (1) /*!< UART_T::LINCTL: SLVHDEN Position */ +#define UART_LINCTL_SLVHDEN_Msk (0x1ul << UART_LINCTL_SLVHDEN_Pos) /*!< UART_T::LINCTL: SLVHDEN Mask */ + +#define UART_LINCTL_SLVAREN_Pos (2) /*!< UART_T::LINCTL: SLVAREN Position */ +#define UART_LINCTL_SLVAREN_Msk (0x1ul << UART_LINCTL_SLVAREN_Pos) /*!< UART_T::LINCTL: SLVAREN Mask */ + +#define UART_LINCTL_SLVDUEN_Pos (3) /*!< UART_T::LINCTL: SLVDUEN Position */ +#define UART_LINCTL_SLVDUEN_Msk (0x1ul << UART_LINCTL_SLVDUEN_Pos) /*!< UART_T::LINCTL: SLVDUEN Mask */ + +#define UART_LINCTL_MUTE_Pos (4) /*!< UART_T::LINCTL: MUTE Position */ +#define UART_LINCTL_MUTE_Msk (0x1ul << UART_LINCTL_MUTE_Pos) /*!< UART_T::LINCTL: MUTE Mask */ + +#define UART_LINCTL_SENDH_Pos (8) /*!< UART_T::LINCTL: SENDH Position */ +#define UART_LINCTL_SENDH_Msk (0x1ul << UART_LINCTL_SENDH_Pos) /*!< UART_T::LINCTL: SENDH Mask */ + +#define UART_LINCTL_IDPEN_Pos (9) /*!< UART_T::LINCTL: IDPEN Position */ +#define UART_LINCTL_IDPEN_Msk (0x1ul << UART_LINCTL_IDPEN_Pos) /*!< UART_T::LINCTL: IDPEN Mask */ + +#define UART_LINCTL_BRKDETEN_Pos (10) /*!< UART_T::LINCTL: BRKDETEN Position */ +#define UART_LINCTL_BRKDETEN_Msk (0x1ul << UART_LINCTL_BRKDETEN_Pos) /*!< UART_T::LINCTL: BRKDETEN Mask */ + +#define UART_LINCTL_RXOFF_Pos (11) /*!< UART_T::LINCTL: RXOFF Position */ +#define UART_LINCTL_RXOFF_Msk (0x1ul << UART_LINCTL_RXOFF_Pos) /*!< UART_T::LINCTL: RXOFF Mask */ + +#define UART_LINCTL_BITERREN_Pos (12) /*!< UART_T::LINCTL: BITERREN Position */ +#define UART_LINCTL_BITERREN_Msk (0x1ul << UART_LINCTL_BITERREN_Pos) /*!< UART_T::LINCTL: BITERREN Mask */ + +#define UART_LINCTL_BRKFL_Pos (16) /*!< UART_T::LINCTL: BRKFL Position */ +#define UART_LINCTL_BRKFL_Msk (0xful << UART_LINCTL_BRKFL_Pos) /*!< UART_T::LINCTL: BRKFL Mask */ + +#define UART_LINCTL_BSL_Pos (20) /*!< UART_T::LINCTL: BSL Position */ +#define UART_LINCTL_BSL_Msk (0x3ul << UART_LINCTL_BSL_Pos) /*!< UART_T::LINCTL: BSL Mask */ + +#define UART_LINCTL_HSEL_Pos (22) /*!< UART_T::LINCTL: HSEL Position */ +#define UART_LINCTL_HSEL_Msk (0x3ul << UART_LINCTL_HSEL_Pos) /*!< UART_T::LINCTL: HSEL Mask */ + +#define UART_LINCTL_PID_Pos (24) /*!< UART_T::LINCTL: PID Position */ +#define UART_LINCTL_PID_Msk (0xfful << UART_LINCTL_PID_Pos) /*!< UART_T::LINCTL: PID Mask */ + +#define UART_LINSTS_SLVHDETF_Pos (0) /*!< UART_T::LINSTS: SLVHDETF Position */ +#define UART_LINSTS_SLVHDETF_Msk (0x1ul << UART_LINSTS_SLVHDETF_Pos) /*!< UART_T::LINSTS: SLVHDETF Mask */ + +#define UART_LINSTS_SLVHEF_Pos (1) /*!< UART_T::LINSTS: SLVHEF Position */ +#define UART_LINSTS_SLVHEF_Msk (0x1ul << UART_LINSTS_SLVHEF_Pos) /*!< UART_T::LINSTS: SLVHEF Mask */ + +#define UART_LINSTS_SLVIDPEF_Pos (2) /*!< UART_T::LINSTS: SLVIDPEF Position */ +#define UART_LINSTS_SLVIDPEF_Msk (0x1ul << UART_LINSTS_SLVIDPEF_Pos) /*!< UART_T::LINSTS: SLVIDPEF Mask */ + +#define UART_LINSTS_SLVSYNCF_Pos (3) /*!< UART_T::LINSTS: SLVSYNCF Position */ +#define UART_LINSTS_SLVSYNCF_Msk (0x1ul << UART_LINSTS_SLVSYNCF_Pos) /*!< UART_T::LINSTS: SLVSYNCF Mask */ + +#define UART_LINSTS_BRKDETF_Pos (8) /*!< UART_T::LINSTS: BRKDETF Position */ +#define UART_LINSTS_BRKDETF_Msk (0x1ul << UART_LINSTS_BRKDETF_Pos) /*!< UART_T::LINSTS: BRKDETF Mask */ + +#define UART_LINSTS_BITEF_Pos (9) /*!< UART_T::LINSTS: BITEF Position */ +#define UART_LINSTS_BITEF_Msk (0x1ul << UART_LINSTS_BITEF_Pos) /*!< UART_T::LINSTS: BITEF Mask */ + +#define UART_LINDEBUG_DEVERRF_Pos (0) /*!< UART_T::LINDEBUG: DEVERRF Position */ +#define UART_LINDEBUG_DEVERRF_Msk (0x1ul << UART_LINDEBUG_DEVERRF_Pos) /*!< UART_T::LINDEBUG: DEVERRF Mask */ + +#define UART_LINDEBUG_TOF_Pos (1) /*!< UART_T::LINDEBUG: TOF Position */ +#define UART_LINDEBUG_TOF_Msk (0x1ul << UART_LINDEBUG_TOF_Pos) /*!< UART_T::LINDEBUG: TOF Mask */ + +#define UART_LINDEBUG_FRAMEERRF_Pos (2) /*!< UART_T::LINDEBUG: FRAMEERRF Position */ +#define UART_LINDEBUG_FRAMEERRF_Msk (0x1ul << UART_LINDEBUG_FRAMEERRF_Pos) /*!< UART_T::LINDEBUG: FRAMEERRF Mask */ + +#define UART_LINDEBUG_SYNCERRF_Pos (3) /*!< UART_T::LINDEBUG: SYNCERRF Position */ +#define UART_LINDEBUG_SYNCERRF_Msk (0x1ul << UART_LINDEBUG_SYNCERRF_Pos) /*!< UART_T::LINDEBUG: SYNCERRF Mask */ + +/**@}*/ /* UART_CONST */ +/**@}*/ /* end of UART register group */ + + +/*---------------------- USB Host Controller -------------------------*/ +/** + @addtogroup USBH USB Host Controller(USBH) + Memory Mapped Structure for USBH Controller +@{ */ + +typedef struct { + /** + * HcRevision + * =================================================================================================== + * Offset: 0x00 Host Controller Revision Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |REV |Revision + * | | |Indicates the Open HCI Specification revision number implemented by the Hardware. + * | | |Host Controller supports 1.1 specification. + * | | |(X.Y = XYh). + */ + __I uint32_t HcRevision; + + /** + * HcControl + * =================================================================================================== + * Offset: 0x04 Host Controller Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |CBSR |Control Bulk Service Ratio + * | | |Specifies the number of Control Endpoints serviced for every Bulk Endpoint. + * | | |Encoding is N-1 where N is the number of Control Endpoints (i.e. + * | | |'00' = 1 Control Endpoint; '11' = 3 Control Endpoints). + * |[2] |PLE |Periodic List Enable Control + * | | |When set, this bit enables processing of the Periodic (interrupt and isochronous) list. + * | | |The Host Controller checks this bit prior to attempting any periodic transfers in a frame. + * |[3] |IE |Isochronous List Enable Control + * | | |When cleared, this bit disables the Isochronous List when the Periodic List is enabled (so Interrupt EDs may be serviced). + * | | |While processing the Periodic List, the Host Controller will check this bit when it finds an isochronous ED. + * |[4] |CLE |Control List Enable Control + * | | |When set, this bit enables processing of the Control list. + * |[5] |BLE |Bulk List Enable Control + * | | |When set, this bit enables processing of the Bulk list. + * |[6:7] |HCFS |Host Controller Functional State + * | | |This field sets the Host Controller state. + * | | |The Controller may force a state change from USBSUSPEND to USBRESUME after detecting resume signaling from a downstream port. + * | | |States are:. + * | | |00 = USBSUSPEND. + * | | |01 = USBRESUME. + * | | |10 = USBOPERATIONAL. + * | | |11 = USBRESET. + * |[9] |RWC |Remote Wake-Up Connected + * | | |This bit indicated whether the HC supports a remote wake-up signal. + * | | |This implementation does not support any such signal. + * | | |The bit is hard-coded to '0.'. + * |[10] |RWE |Remote Wake-Up Connected Enable Control + * | | |If a remote wake-up signal is supported, this bit enables that operation. + * | | |Since there is no remote wake-up signal supported, this bit is ignored. + */ + __IO uint32_t HcControl; + + /** + * HcCommandStatus + * =================================================================================================== + * Offset: 0x08 Host Controller Command Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |HCR |Host Controller Reset + * | | |This bit is set to initiate the software reset. + * | | |This bit is cleared by the Host Controller, upon completed of the reset operation. + * |[1] |CLF |Control List Filled + * | | |Set to indicate there is an active ED on the Control List. + * | | |It may be set by either software or the Host Controller and cleared by the Host Controller each time it begins processing the head of the Control List. + * |[2] |BLF |Bulk List Filled + * | | |Set to indicate there is an active ED on the Bulk List. + * | | |The bit may be set by either software or the Host Controller and cleared by the Host Controller each time it begins processing the head of the Bulk List. + * |[16:17] |SOC |Schedule Overrun Count + * | | |This field is incremented every time the SchedulingOverrun bit in HcInterruptStatus is set. + * | | |The count wraps from '11' to '00'. + */ + __IO uint32_t HcCommandStatus; + + /** + * HcInterruptStatus + * =================================================================================================== + * Offset: 0x0C Host Controller Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SO |Scheduling Overrun + * | | |Set when the List Processor determines a Schedule Overrun has occurred. + * |[1] |WDH |Write Back Done Head + * | | |Set after the Host Controller has written HcDoneHead to HccaDoneHead. + * |[2] |SF |Start Of Frame + * | | |Set when the Frame Management block signals a 'Start of Frame' event. + * |[3] |RD |Resume Detected + * | | |Set when Host Controller detects resume signaling on a downstream port. + * |[4] |UE |Unrecoverable Error + * | | |This event is not implemented and is hard-coded to '0.' Writes are ignored. + * |[5] |FNOF |Frame Number Overflow + * | | |Set when bit 15 of Frame Number changes value. + * |[6] |RHSC |Root Hub Status Change + * | | |This bit is set when the content of HcRhStatus or the content of any HcRhPortStatus register has changed. + */ + __IO uint32_t HcInterruptStatus; + + /** + * HcInterruptEnable + * =================================================================================================== + * Offset: 0x10 Host Controller Interrupt Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SO |Scheduling Overrun Enable Control + * | | |0 = The interrupt function Disabled. + * | | |1 = Interrupt generation Enabled due to Scheduling Overrun. + * |[1] |WDH |Write Back Done Head Enable Control + * | | |0 = The interrupt function Disabled. + * | | |1 = Interrupt generation Enabled due to Write-back Done Head. + * |[2] |SF |Start Of Frame Enable Control + * | | |0 = The interrupt function Disabled. + * | | |1 = interrupt generation Enabled due to Start of Frame. + * |[3] |RD |Resume Detected Enable Control + * | | |0 = The interrupt function Disabled. + * | | |1 = interrupt generation Enabled due to Resume Detected. + * |[4] |UE |Unrecoverable Error Enable Control + * | | |This event is not implemented. All writes to this bit are ignored. + * |[5] |FNO |Frame Number Overflow Enable Control + * | | |0 = The interrupt function Disabled. + * | | |1 = Interrupt generation Enabled due to Frame Number Overflow. + * |[6] |RHSC |Root Hub Status Change Enable Control + * | | |0 = The interrupt function Disabled. + * | | |1 = interrupt generation Enabled due to Root Hub Status Change. + * |[31] |MIE |Master Interrupt Enable Control + * | | |This bit is a global interrupt enable. + * | | |A write of '1' allows interrupts to be enabled via the specific enable bits listed above. + */ + __IO uint32_t HcInterruptEnable; + + /** + * HcInterruptDisable + * =================================================================================================== + * Offset: 0x14 Host Controller Interrupt Disable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SO |Scheduling Overrun Disable Control + * | | |0 = No effect. + * | | |1 = Interrupt generation Disabled due to Scheduling Overrun. + * |[1] |WDH |Write Back Done Head Disable Control + * | | |0 = No effect. + * | | |1 = Interrupt generation Disabled due to Write-back Done Head. + * |[2] |SF |Start Of Frame Disable Control + * | | |0 = No effect. + * | | |1 = Interrupt generation Disabled due to Start of Frame. + * |[3] |RD |Resume Detected Disable Control + * | | |0 = No effect. + * | | |1 = Interrupt generation Disabled due to Resume Detected. + * |[4] |UE |Unrecoverable Error Disable Control + * | | |This event is not implemented. All writes to this bit are ignored. + * |[5] |FNO |Frame Number Overflow Disable Control + * | | |0 = No effect. + * | | |1 = Interrupt generation Disabled due to Frame Number Overflow. + * |[6] |RHSC |Root Hub Status Change Disable Control + * | | |0 = No effect. + * | | |1 = Interrupt generation Disabled due to Root Hub Status Change. + * |[31] |MIE |Master Interrupt Disable Control + * | | |Global interrupt disable. Writing '1' to disable all interrupts. + */ + __IO uint32_t HcInterruptDisable; + + /** + * HcHCCA + * =================================================================================================== + * Offset: 0x18 Host Controller Communication Area Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[8:31] |HCCA |Host Controller Communication Area + * | | |Pointer to HCCA base address. + */ + __IO uint32_t HcHCCA; + + /** + * HcPeriodCurrentED + * =================================================================================================== + * Offset: 0x1C Host Controller Period Current ED Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[4:31] |PCED |Periodic Current ED + * | | |Pointer to the current Periodic List ED. + */ + __IO uint32_t HcPeriodCurrentED; + + /** + * HcControlHeadED + * =================================================================================================== + * Offset: 0x20 Host Controller Control Head ED Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[4:31] |CHED |Control Head ED + * | | |Pointer to the Control List Head ED. + */ + __IO uint32_t HcControlHeadED; + + /** + * HcControlCurrentED + * =================================================================================================== + * Offset: 0x24 Host Controller Control Current ED Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[4:31] |CCED |Control Current Head ED + * | | |Pointer to the current Control List Head ED. + */ + __IO uint32_t HcControlCurrentED; + + /** + * HcBulkHeadED + * =================================================================================================== + * Offset: 0x28 Host Controller Bulk Head ED Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[4:31] |BHED |Bulk Head ED + * | | |Pointer to the Bulk List Head ED. + */ + __IO uint32_t HcBulkHeadED; + + /** + * HcBulkCurrentED + * =================================================================================================== + * Offset: 0x2C Host Controller Bulk Current ED Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[4:31] |BCED |Bulk Current Head ED + * | | |Pointer to the current Bulk List Head ED. + */ + __IO uint32_t HcBulkCurrentED; + + /** + * HcDoneHead + * =================================================================================================== + * Offset: 0x30 Host Controller Done Head Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[4:31] |DH |Done Head + * | | |Pointer to the current Done List Head ED. + */ + __IO uint32_t HcDoneHead; + + /** + * HcFmInterval + * =================================================================================================== + * Offset: 0x34 Host Controller Frame Interval Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:13] |FI |Frame Interval + * | | |This field specifies the length of a frame as (bit times - 1). + * | | |For 12,000 bit times in a frame, a value of 11,999 is stored here. + * |[16:30] |FSMPS |FS Largest Data Packet + * | | |This field specifies a value that is loaded into the Largest Data Packet Counter at the beginning of each frame. + * |[31] |FIT |Frame Interval Toggle + * | | |This bit is toggled by HCD when it loads a new value into Frame Interval. + */ + __IO uint32_t HcFmInterval; + + /** + * HcFmRemaining + * =================================================================================================== + * Offset: 0x38 Host Controller Frame Remaining Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:13] |FR |Frame Remaining + * | | |When the Host Controller is in the USBOPERATIONAL state, this 14-bit field decrements each 12 MHz clock period. + * | | |When the count reaches 0, (end of frame) the counter reloads with Frame Interval. + * | | |In addition, the counter loads when the Host Controller transitions into USBOPERATIONAL. + * |[31] |FRT |Frame Remaining Toggle + * | | |Loaded with Frame Interval Toggle when FrameRemaining is loaded. + */ + __I uint32_t HcFmRemaining; + + /** + * HcFmNumber + * =================================================================================================== + * Offset: 0x3C Host Controller Frame Number Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |FN |Frame Number + * | | |This 16-bit incrementing counter field is incremented coincident with the loading of FrameRemaining. + * | | |The count rolls over from 'FFFFh' to '0h.'. + */ + __I uint32_t HcFmNumber; + + /** + * HcPeriodicStart + * =================================================================================================== + * Offset: 0x40 Host Controller Periodic Start Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:13] |PS |Periodic Start + * | | |This field contains a value used by the List Processor to determine where in a frame the Periodic List processing must begin. + */ + __IO uint32_t HcPeriodicStart; + + /** + * HcLSThreshold + * =================================================================================================== + * Offset: 0x44 Host Controller Low-speed Threshold Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |LST |Low-Speed Threshold + * | | |This field contains a value which is compared to the FrameRemaining field prior to initiating a Low-speed transaction. + * | | |The transaction is started only if FrameRemaining >= this field. + * | | |The value is calculated by HCD with the consideration of transmission and setup overhead. + */ + __IO uint32_t HcLSThreshold; + + /** + * HcRhDescriptorA + * =================================================================================================== + * Offset: 0x48 Host Controller Root Hub Descriptor A Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |NDP |Number Downstream Ports + * | | |Root Hub supports two downstream ports. It's 2 in this Root Hub. + * |[8] |PSM |Power Switching Mode + * | | |Global power switching mode implemented in Root Hub. + * | | |This bit is only valid when NPS bit is cleared. + * | | |This bit should be written '0'. + * | | |0 = Global Switching. + * | | |1 = Individual Switching. + * |[9] |NPS |No Power Switching + * | | |Global power switching implemented in Root Hub. + * | | |This bit should be written to support the external system port power switching implementation. + * | | |0 = Ports are power switched. + * | | |1 = Ports are always powered on. + * |[10] |DT |Device Type + * | | |The OHCI Root Hub is not a compound device. + * |[11] |OCPM |Overcurrent Protection Mode + * | | |Global overcurrent reporting implemented in Root Hub. + * | | |This bit should be written 0 and is only valid when NOCP bit is cleared. + * | | |0 = Global Overcurrent. + * | | |1 = Individual Overcurrent. + * |[12] |NOCP |No Overcurrent Protection + * | | |Global overcurrent reporting implemented in Root Hub. + * | | |This bit should be written to support the external system port overcurrent implementation. + * | | |0 = Overcurrent status is reported. + * | | |1 = Overcurrent status is not reported. + * |[24:31] |POTGT |Power On To Power Good Time + * | | |This field value is represented as the number of 2 ms intervals, which ensuring that the power switching is effective within 2 ms. + * | | |Only bits [25:24] are implemented as R/W. + * | | |The remaining bits are read only as '0'. + * | | |It is not expected that these bits be written to anything other than 1h, but limited adjustment is provided. + * | | |This field should be written to support system implementation. + * | | |This field should always be written to a non-zero value. + */ + __IO uint32_t HcRhDescriptorA; + + /** + * HcRhDescriptorB + * =================================================================================================== + * Offset: 0x4C Host Controller Root Hub Descriptor B Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |DR |Device Removable + * | | |Root Hub ports default to removable devices. + * | | |0 = Device not removable. + * | | |1 = Device removable. + * | | |Port Bit relationship: + * | | |DevRemove[0] = Reserved. + * | | |DevRemove[1] = Port 1. + * | | |DevRemove[2] = Port 2. + */ + __IO uint32_t HcRhDescriptorB; + + /** + * HcRhStatus + * =================================================================================================== + * Offset: 0x50 Host Controller Root Hub Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |LPS |LocalPowerStatus (Read) + * | | |Not Supported. Always read '0'. + * | | |ClearGlobalPower (Write) + * | | |Writing '1' issues a ClearGlobalPower command to the ports. Writing '0' has no effect. + * |[1] |OCI |Overcurrent Indicator + * | | |This bit reflects the state of the OVRCUR pin. + * | | |This field is only valid if NOCP (RHDESA[12]) and OCPM (RHDESA[11]) are cleared. + * | | |0 = No overcurrent condition. + * | | |1 = Overcurrent condition. + * |[15] |DRWE |Device Remote Wake-Up Enable Control (Read) + * | | |This bit enables ports' CC (HcRhPtr[0]) as a remote wake-up event. + * | | |0 = Disabled. + * | | |1 = Enabled. + * | | |Set Remote Wake-up Enable Control (Write) + * | | |Writing 1' sets DRWEn. Writing '0' has no effect. + * |[16] |LPSC |Local Power Status Change (Read) + * | | |Not supported. Always read '0'. + * | | |SetGlobalPower (Write) + * | | |Writing '1' issues a SetGlobalPower command to the ports. Writing '0' has no effect. + * |[17] |OCIC |Overcurrent Indicator Change + * | | |This bit is set when OC bit changes. + * | | |Writing '1' clears this bit. Writing '0' has no effect. + * |[31] |CRWE |Clear Remote Wake-Up Enable Control + * | | |Writing '1' to this bit clears DRWEn (HcRhStatus[15]). Writing '0' has no effect. + */ + __IO uint32_t HcRhStatus; + + /** + * HcRhPortStatus1/HcRhPortStatus2 + * =================================================================================================== + * Offset: 0x54,0x58 Host Controller Root Hub Port Status [1/2] + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |CCS |Current Connect Status (Read) + * | | |0 = No device connected. + * | | |1 = Device connected. + * | | |Clear Port Enable Control (Write) + * | | |Writing '1' a clears PE. Writing '0' has no effect. + * |[1] |PES |Port Enable Status (Read) + * | | |0 = Port Disabled. + * | | |1 = Port Enabled. + * | | |SetPortEnable (Write) + * | | |Writing '1' sets PE. Writing '0' has no effect. + * |[2] |PSS |PortSuspendStatus (Read) + * | | |0 = Port is not suspended. + * | | |1 = Port is selectively suspended. + * | | |SetPortSuspend (Write) + * | | |Writing '1' sets PortSuspendStatus. Writing '0' has no effect. + * |[3] |POCI |PortOverCurrentIndicator (Read) + * | | |Root Hub supports global overcurrent reporting. + * | | |This bit reflects the state of the OVRCUR pin dedicated to this port. + * | | |This field is only valid if NOCP (RHDESA[12]) is cleared and OCPM (RHDESA[11]) is set. + * | | |0 = No overcurrent condition. + * | | |1 = Overcurrent condition. + * | | |ClearPortSuspend (Write) + * | | |Writing '1' initiates the selective resume sequence for the port. Writing '0' has no effect. + * |[4] |PRS |PortResetStatus (Read) + * | | |This bit reflects the power state of the port regardless of the power switching mode. + * | | |0 = Port reset signal is not active. + * | | |1 = Port reset signal is active. + * | | |SetPortReset (Write) + * | | |Writing '1' sets PR. Writing '0' has no effect. + * |[8] |PPS |PortPowerStatus (Read) + * | | |This bit reflects the power state of the port regardless of the power switching mode. + * | | |0 = Port power is off. + * | | |1 = Port power is on. + * | | |Note: If NPS (RHDESA[9]) is set, this bit is always read as '1'. + * | | |SetPortPower (Write) + * | | |Writing '1' sets PPS. Writing '0' has no effect. + * |[9] |LSDA |LowSpeedDeviceAttached (Read) + * | | |This bit defines the speed (and bud idle) of the attached device. It is only valid when CC bit is set. + * | | |0 = Full Speed device. + * | | |1 = Low-speed device. + * | | |ClearPortPower (Write) + * | | |Writing '1' clears PPS bit. Writing '0' has no effect. + * |[16] |CSC |Connect Status Change + * | | |This bit indicates connect or disconnect event has been detected. + * | | |Writing '1' clears this bit. + * | | |Writing '0' has no effect. + * | | |0 = No connect/disconnect event. + * | | |1 = Hardware detection of connect/disconnect event. + * | | |Note: If DevRemove (HcRhDescriptorB[2:0]) is set, this bit resets to '1'. + * |[17] |PESC |Port Enable Status Change + * | | |This bit indicates that the port has been disabled due to a hardware event (cleared PE bit). + * | | |0 = No port enable change event. + * | | |1 = Port enable state has been changed. + * |[18] |PSSC |Port Reset Status Change + * | | |This bit indicates the completion of the selective resume sequence for the port. + * | | |0 = Port is not resumed. + * | | |1 = Port resume is complete. + * |[19] |OCIC |Port Overcurrent Indicator Change + * | | |This bit is set when OC (HcRhStatus[1]) changes. Writing '1' clears this bit. Writing '0' has no effect. + * |[20] |PRSC |Port Reset Status Change + * | | |This bit indicates that the port reset signal has completed. + * | | |0 = Port reset is not complete. + * | | |1 = Port reset is complete. + */ + __IO uint32_t HcRhPortStatus[2]; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[105]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * HcPhyControl + * =================================================================================================== + * Offset: 0x200 USB PHY Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[27] |STBYEN |USB Transceiver Standby Enable Control + * | | |This bit controls if USB 1.1 transceiver could enter the standby mode to reduce power consumption. + * | | |If this bit is low, the USB 1.1 transceiver would never enter the standby mode. + * | | |If this bit is high, the USB 1.1 transceiver will enter standby mode while port is in power off state (port power is inactive). + */ + __IO uint32_t HcPhyControl; + + /** + * HcMiscControl + * =================================================================================================== + * Offset: 0x204 USB Operational Mode Enable Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |DBR16 |Data Buffer Region 16 + * | | |When set, the size of the data buffer region is 16 bytes. Otherwise, the size is 32 bytes. + * |[1] |ABORT |AHB Bus ERROR Response + * | | |This bit indicates there is an ERROR response received in AHB bus. + * | | |0 = No ERROR response received. + * | | |1 = ERROR response received. + * |[3] |OCA |Overcurrent Active Low + * | | |This bit controls the polarity of overcurrent flag from external power IC. + * | | |0 = Overcurrent flag is high active. + * | | |1 = Overcurrent flag is low active. + * |[4] |PCAL |Port Power Control Active Low + * | | |This bit controls the polarity of port power control to external power IC. + * | | |0 = Port power control is high active. + * | | |1 = Port power control is low active. + * |[8] |SIEPD |SIE Pipeline Disable Control + * | | |When set, waits for all USB bus activity to complete prior to returning completion status to the List Processor. + * | | |This is a fail safe mechanism to avoid potential problems with the clk_dr transition between 1.5 MHz and 12 MHz. + * |[16] |DPRT1 |Port 1 Disable Control + * | | |This bit controls if the connection between USB host controller and transceiver of port 1 is disabled. + * | | |If the connection is disabled, the USB host controller will not recognize any event of USB bus. + * | | |Set this bit high, the transceiver of port 1 will also be forced into the standby mode no matter what USB host controller operation is. + * | | |0 = The connection between USB host controller and transceiver of port 1 is enabled. + * | | |1 = The connection between USB host controller and transceiver of port 1 is disabled and the transceiver of port 1 will also be forced into the standby mode. + * |[17] |DPRT2 |Port 2 Disable Control + * | | |This bit controls if the connection between USB host controller and transceiver of port 2 is disabled. + * | | |If the connection is disabled, the USB host controller will not recognize any event of USB bus. + * | | |Set this bit high, the transceiver of port 2 will also be forced into the standby mode no matter what USB host controller operation is. + * | | |0 = The connection between USB host controller and transceiver of port 2 is enabled. + * | | |1 = The connection between USB host controller and transceiver of port 2 is disabled and the transceiver of port 2 will also be forced into the standby mode. + */ + __IO uint32_t HcMiscControl; + +} USBH_T; + +/** + @addtogroup USBH_CONST USBH Bit Field Definition + Constant Definitions for USBH Controller +@{ */ + +#define USBH_HcRevision_REV_Pos (0) /*!< USBH_T::HcRevision: REV Position */ +#define USBH_HcRevision_REV_Msk (0xfful << USBH_HcRevision_REV_Pos) /*!< USBH_T::HcRevision: REV Mask */ + +#define USBH_HcControl_CBSR_Pos (0) /*!< USBH_T::HcControl: CBSR Position */ +#define USBH_HcControl_CBSR_Msk (0x3ul << USBH_HcControl_CBSR_Pos) /*!< USBH_T::HcControl: CBSR Mask */ + +#define USBH_HcControl_PLE_Pos (2) /*!< USBH_T::HcControl: CBSR Position */ +#define USBH_HcControl_PLE_Msk (0x1ul << USBH_HcControl_PLE_Pos) /*!< USBH_T::HcControl: CBSR Mask */ + +#define USBH_HcControl_IE_Pos (3) /*!< USBH_T::HcControl: IE Position */ +#define USBH_HcControl_IE_Msk (0x1ul << USBH_HcControl_IE_Pos) /*!< USBH_T::HcControl: IE Mask */ + +#define USBH_HcControl_CLE_Pos (4) /*!< USBH_T::HcControl: CLE Position */ +#define USBH_HcControl_CLE_Msk (0x1ul << USBH_HcControl_CLE_Pos) /*!< USBH_T::HcControl: CLE Mask */ + +#define USBH_HcControl_BLE_Pos (5) /*!< USBH_T::HcControl: BLE Position */ +#define USBH_HcControl_BLE_Msk (0x1ul << USBH_HcControl_BLE_Pos) /*!< USBH_T::HcControl: BLE Mask */ + +#define USBH_HcControl_HCFS_Pos (6) /*!< USBH_T::HcControl: HCFS Position */ +#define USBH_HcControl_HCFS_Msk (0x3ul << USBH_HcControl_HCFS_Pos) /*!< USBH_T::HcControl: HCFS Mask */ + +#define USBH_HcCommandStatus_HCR_Pos (0) /*!< USBH_T::HcCommandStatus: HCR Position */ +#define USBH_HcCommandStatus_HCR_Msk (0x1ul << USBH_HcCommandStatus_HCR_Pos) /*!< USBH_T::HcCommandStatus: HCR Mask */ + +#define USBH_HcCommandStatus_CLF_Pos (1) /*!< USBH_T::HcCommandStatus: CLF Position */ +#define USBH_HcCommandStatus_CLF_Msk (0x1ul << USBH_HcCommandStatus_CLF_Pos) /*!< USBH_T::HcCommandStatus: CLF Mask */ + +#define USBH_HcCommandStatus_BLF_Pos (2) /*!< USBH_T::HcCommandStatus: BLF Position */ +#define USBH_HcCommandStatus_BLF_Msk (0x1ul << USBH_HcCommandStatus_BLF_Pos) /*!< USBH_T::HcCommandStatus: BLF Mask */ + +#define USBH_HcCommandStatus_SOC_Pos (16) /*!< USBH_T::HcCommandStatus: SOC Position */ +#define USBH_HcCommandStatus_SOC_Msk (0x3ul << USBH_HcCommandStatus_SOC_Pos) /*!< USBH_T::HcCommandStatus: SOC Mask */ + +#define USBH_HcInterruptStatus_SO_Pos (0) /*!< USBH_T::HcInterruptStatus: SO Position */ +#define USBH_HcInterruptStatus_SO_Msk (0x1ul << USBH_HcInterruptStatus_SO_Pos) /*!< USBH_T::HcInterruptStatus: SO Mask */ + +#define USBH_HcInterruptStatus_WDH_Pos (1) /*!< USBH_T::HcInterruptStatus: WDH Position */ +#define USBH_HcInterruptStatus_WDH_Msk (0x1ul << USBH_HcInterruptStatus_WDH_Pos) /*!< USBH_T::HcInterruptStatus: WDH Mask */ + +#define USBH_HcInterruptStatus_SF_Pos (2) /*!< USBH_T::HcInterruptStatus: SF Position */ +#define USBH_HcInterruptStatus_SF_Msk (0x1ul << USBH_HcInterruptStatus_SF_Pos) /*!< USBH_T::HcInterruptStatus: SF Mask */ + +#define USBH_HcInterruptStatus_RD_Pos (3) /*!< USBH_T::HcInterruptStatus: RD Position */ +#define USBH_HcInterruptStatus_RD_Msk (0x1ul << USBH_HcInterruptStatus_RD_Pos) /*!< USBH_T::HcInterruptStatus: RD Mask */ + +#define USBH_HcInterruptStatus_FNO_Pos (5) /*!< USBH_T::HcInterruptStatus: FNO Position */ +#define USBH_HcInterruptStatus_FNO_Msk (0x1ul << USBH_HcInterruptStatus_FNO_Pos) /*!< USBH_T::HcInterruptStatus: FNO Mask */ + +#define USBH_HcInterruptStatus_RHSC_Pos (6) /*!< USBH_T::HcInterruptStatus: RHSC Position */ +#define USBH_HcInterruptStatus_RHSC_Msk (0x1ul << USBH_HcInterruptStatus_RHSC_Pos) /*!< USBH_T::HcInterruptStatus: RHSC Mask */ + +#define USBH_HcInterruptEnable_SO_Pos (0) /*!< USBH_T::HcInterruptEnable: SO Position */ +#define USBH_HcInterruptEnable_SO_Msk (0x1ul << USBH_HcInterruptEnable_SO_Pos) /*!< USBH_T::HcInterruptEnable: SO Mask */ + +#define USBH_HcInterruptEnable_WDH_Pos (1) /*!< USBH_T::HcInterruptEnable: WDH Position */ +#define USBH_HcInterruptEnable_WDH_Msk (0x1ul << USBH_HcInterruptEnable_WDH_Pos) /*!< USBH_T::HcInterruptEnable: WDH Mask */ + +#define USBH_HcInterruptEnable_SF_Pos (2) /*!< USBH_T::HcInterruptEnable: SF Position */ +#define USBH_HcInterruptEnable_SF_Msk (0x1ul << USBH_HcInterruptEnable_SF_Pos) /*!< USBH_T::HcInterruptEnable: SF Mask */ + +#define USBH_HcInterruptEnable_RD_Pos (3) /*!< USBH_T::HcInterruptEnable: RD Position */ +#define USBH_HcInterruptEnable_RD_Msk (0x1ul << USBH_HcInterruptEnable_RD_Pos) /*!< USBH_T::HcInterruptEnable: RD Mask */ + +#define USBH_HcInterruptEnable_FNO_Pos (5) /*!< USBH_T::HcInterruptEnable: FNO Position */ +#define USBH_HcInterruptEnable_FNO_Msk (0x1ul << USBH_HcInterruptEnable_FNO_Pos) /*!< USBH_T::HcInterruptEnable: FNO Mask */ + +#define USBH_HcInterruptEnable_RHSC_Pos (6) /*!< USBH_T::HcInterruptEnable: RHSC Position */ +#define USBH_HcInterruptEnable_RHSC_Msk (0x1ul << USBH_HcInterruptEnable_RHSC_Pos) /*!< USBH_T::HcInterruptEnable: RHSC Mask */ + +#define USBH_HcInterruptEnable_MIE_Pos (31) /*!< USBH_T::HcInterruptEnable: MIE Position */ +#define USBH_HcInterruptEnable_MIE_Msk (0x1ul << USBH_HcInterruptEnable_MIE_Pos) /*!< USBH_T::HcInterruptEnable: MIE Mask */ + +#define USBH_HcInterruptDisable_SO_Pos (0) /*!< USBH_T::HcInterruptDisable: SO Position */ +#define USBH_HcInterruptDisable_SO_Msk (0x1ul << USBH_HcInterruptDisable_SO_Pos) /*!< USBH_T::HcInterruptDisable: SO Mask */ + +#define USBH_HcInterruptDisable_WDH_Pos (1) /*!< USBH_T::HcInterruptDisable: WDH Position */ +#define USBH_HcInterruptDisable_WDH_Msk (0x1ul << USBH_HcInterruptDisable_WDH_Pos) /*!< USBH_T::HcInterruptDisable: WDH Mask */ + +#define USBH_HcInterruptDisable_SF_Pos (2) /*!< USBH_T::HcInterruptDisable: SF Position */ +#define USBH_HcInterruptDisable_SF_Msk (0x1ul << USBH_HcInterruptDisable_SF_Pos) /*!< USBH_T::HcInterruptDisable: SF Mask */ + +#define USBH_HcInterruptDisable_RD_Pos (3) /*!< USBH_T::HcInterruptDisable: RD Position */ +#define USBH_HcInterruptDisable_RD_Msk (0x1ul << USBH_HcInterruptDisable_RD_Pos) /*!< USBH_T::HcInterruptDisable: RD Mask */ + +#define USBH_HcInterruptDisable_FNO_Pos (5) /*!< USBH_T::HcInterruptDisable: FNO Position */ +#define USBH_HcInterruptDisable_FNO_Msk (0x1ul << USBH_HcInterruptDisable_FNO_Pos) /*!< USBH_T::HcInterruptDisable: FNO Mask */ + +#define USBH_HcInterruptDisable_RHSC_Pos (6) /*!< USBH_T::HcInterruptDisable: RHSC Position */ +#define USBH_HcInterruptDisable_RHSC_Msk (0x1ul << USBH_HcInterruptDisable_RHSC_Pos) /*!< USBH_T::HcInterruptDisable: RHSC Mask */ + +#define USBH_HcInterruptDisable_MIE_Pos (31) /*!< USBH_T::HcInterruptDisable: MIE Position */ +#define USBH_HcInterruptDisable_MIE_Msk (0x1ul << USBH_HcInterruptDisable_MIE_Pos) /*!< USBH_T::HcInterruptDisable: MIE Mask */ + +#define USBH_HcHCCA_HCCA_Pos (8) /*!< USBH_T::HcHCCA: HCCA Position */ +#define USBH_HcHCCA_HCCA_Msk (0xfffffful << USBH_HcHCCA_HCCA_Pos) /*!< USBH_T::HcHCCA: HCCA Mask */ + +#define USBH_HcPeriodCurrentED_PCED_Pos (4) /*!< USBH_T::HcPeriodCurrentED: PCED Position */ +#define USBH_HcPeriodCurrentED_PCED_Msk (0xffffffful << USBH_HcPeriodCurrentED_PCED_Pos) /*!< USBH_T::HcPeriodCurrentED: PCED Mask */ + +#define USBH_HcControlHeadED_CHED_Pos (4) /*!< USBH_T::HcControlHeadED: CHED Position */ +#define USBH_HcControlHeadED_CHED_Msk (0xffffffful << USBH_HcControlHeadED_CHED_Pos) /*!< USBH_T::HcControlHeadED: CHED Mask */ + +#define USBH_HcControlCurrentED_CCED_Pos (4) /*!< USBH_T::HcControlCurrentED: CCED Position */ +#define USBH_HcControlCurrentED_CCED_Msk (0xffffffful << USBH_HcControlCurrentED_CCED_Pos) /*!< USBH_T::HcControlCurrentED: CCED Mask */ + +#define USBH_HcBulkHeadED_BHED_Pos (4) /*!< USBH_T::HcBulkHeadED: BHED Position */ +#define USBH_HcBulkHeadED_BHED_Msk (0xffffffful << USBH_HcBulkHeadED_BHED_Pos) /*!< USBH_T::HcBulkHeadED: BHED Mask */ + +#define USBH_HcBulkCurrentED_BCED_Pos (4) /*!< USBH_T::HcBulkCurrentED: BCED Position */ +#define USBH_HcBulkCurrentED_BCED_Msk (0xffffffful << USBH_HcBulkCurrentED_BCED_Pos) /*!< USBH_T::HcBulkCurrentED: BCED Mask */ + +#define USBH_HcDoneHead_DH_Pos (4) /*!< USBH_T::HcDoneHead: DH Position */ +#define USBH_HcDoneHead_DH_Msk (0xffffffful << USBH_HcDoneHead_DH_Pos) /*!< USBH_T::HcDoneHead: DH Mask */ + +#define USBH_HcFmInterval_FI_Pos (0) /*!< USBH_T::HcFmInterval: FI Position */ +#define USBH_HcFmInterval_FI_Msk (0x3ffful << USBH_HcFmInterval_FI_Pos) /*!< USBH_T::HcFmInterval: FI Mask */ + +#define USBH_HcFmInterval_FSMPS_Pos (16) /*!< USBH_T::HcFmInterval: FSMPS Position */ +#define USBH_HcFmInterval_FSMPS_Msk (0x7ffful << USBH_HcFmInterval_FSMPS_Pos) /*!< USBH_T::HcFmInterval: FSMPS Mask */ + +#define USBH_HcFmInterval_FIT_Pos (31) /*!< USBH_T::HcFmInterval: FIT Position */ +#define USBH_HcFmInterval_FIT_Msk (0x1ul << USBH_HcFmInterval_FIT_Pos) /*!< USBH_T::HcFmInterval: FIT Mask */ + +#define USBH_HcFmRemaining_FR_Pos (0) /*!< USBH_T::HcFmRemaining: FR Position */ +#define USBH_HcFmRemaining_FR_Msk (0x3ffful << USBH_HcFmRemaining_FR_Pos) /*!< USBH_T::HcFmRemaining: FR Mask */ + +#define USBH_HcFmRemaining_FRT_Pos (31) /*!< USBH_T::HcFmRemaining: FRT Position */ +#define USBH_HcFmRemaining_FRT_Msk (0x1ul << USBH_HcFmRemaining_FRT_Pos) /*!< USBH_T::HcFmRemaining: FRT Mask */ + +#define USBH_HcFmNumber_FN_Pos (0) /*!< USBH_T::HcFmNumber: FN Position */ +#define USBH_HcFmNumber_FN_Msk (0xfffful << USBH_HcFmNumber_FN_Pos) /*!< USBH_T::HcFmNumber: FN Mask */ + +#define USBH_HcPeriodicStart_PS_Pos (0) /*!< USBH_T::HcPeriodicStart: PS Position */ +#define USBH_HcPeriodicStart_PS_Msk (0x3ffful << USBH_HcPeriodicStart_PS_Pos) /*!< USBH_T::HcPeriodicStart: PS Mask */ + +#define USBH_HcLSThreshold_LST_Pos (0) /*!< USBH_T::HcLSThreshold: LST Position */ +#define USBH_HcLSThreshold_LST_Msk (0xffful << USBH_HcLSThreshold_LST_Pos) /*!< USBH_T::HcLSThreshold: LST Mask */ + +#define USBH_HcRhDescriptorA_NDP_Pos (0) /*!< USBH_T::HcRhDescriptorA: NDP Position */ +#define USBH_HcRhDescriptorA_NDP_Msk (0xfful << USBH_HcRhDescriptorA_NDP_Pos) /*!< USBH_T::HcRhDescriptorA: NDP Mask */ + +#define USBH_HcRhDescriptorA_PSM_Pos (8) /*!< USBH_T::HcRhDescriptorA: PSM Position */ +#define USBH_HcRhDescriptorA_PSM_Msk (0x1ul << USBH_HcRhDescriptorA_PSM_Pos) /*!< USBH_T::HcRhDescriptorA: PSM Mask */ + +#define USBH_HcRhDescriptorA_NPS_Pos (9) /*!< USBH_T::HcRhDescriptorA: NPS Position */ +#define USBH_HcRhDescriptorA_NPS_Msk (0x1ul << USBH_HcRhDescriptorA_NPS_Pos) /*!< USBH_T::HcRhDescriptorA: NPS Mask */ + +#define USBH_HcRhDescriptorA_DT_Pos (10) /*!< USBH_T::HcRhDescriptorA: DT Position */ +#define USBH_HcRhDescriptorA_DT_Msk (0x1ul << USBH_HcRhDescriptorA_DT_Pos) /*!< USBH_T::HcRhDescriptorA: DT Mask */ + +#define USBH_HcRhDescriptorA_OCPM_Pos (11) /*!< USBH_T::HcRhDescriptorA: OCPM Position */ +#define USBH_HcRhDescriptorA_OCPM_Msk (0x1ul << USBH_HcRhDescriptorA_OCPM_Pos) /*!< USBH_T::HcRhDescriptorA: OCPM Mask */ + +#define USBH_HcRhDescriptorA_NOCP_Pos (12) /*!< USBH_T::HcRhDescriptorA: NOCP Position */ +#define USBH_HcRhDescriptorA_NOCP_Msk (0x1ul << USBH_HcRhDescriptorA_NOCP_Pos) /*!< USBH_T::HcRhDescriptorA: NOCP Mask */ + +#define USBH_HcRhDescriptorA_POTPGT_Pos (24) /*!< USBH_T::HcRhDescriptorA: POTPGT Position */ +#define USBH_HcRhDescriptorA_POTPGT_Msk (0xfful << USBH_HcRhDescriptorA_POTPGT_Pos) /*!< USBH_T::HcRhDescriptorA: POTPGT Mask */ + +#define USBH_HcRhDescriptorB_PPCM_Pos (16) /*!< USBH_T::HcRhDescriptorB: PPCM Position */ +#define USBH_HcRhDescriptorB_PPCM_Msk (0xfffful << USBH_HcRhDescriptorB_PPCM_Pos) /*!< USBH_T::HcRhDescriptorB: PPCM Mask */ + +#define USBH_HcRhStatus_LPS_Pos (0) /*!< USBH_T::HcRhStatus: LPS Position */ +#define USBH_HcRhStatus_LPS_Msk (0x1ul << USBH_HcRhStatus_LPS_Pos) /*!< USBH_T::HcRhStatus: LPS Mask */ + +#define USBH_HcRhStatus_OCI_Pos (1) /*!< USBH_T::HcRhStatus: OCI Position */ +#define USBH_HcRhStatus_OCI_Msk (0x1ul << USBH_HcRhStatus_OCI_Pos) /*!< USBH_T::HcRhStatus: OCI Mask */ + +#define USBH_HcRhStatus_DRWE_Pos (15) /*!< USBH_T::HcRhStatus: DRWE Position */ +#define USBH_HcRhStatus_DRWE_Msk (0x1ul << USBH_HcRhStatus_DRWE_Pos) /*!< USBH_T::HcRhStatus: DRWE Mask */ + +#define USBH_HcRhStatus_LPSC_Pos (16) /*!< USBH_T::HcRhStatus: LPSC Position */ +#define USBH_HcRhStatus_LPSC_Msk (0x1ul << USBH_HcRhStatus_LPSC_Pos) /*!< USBH_T::HcRhStatus: LPSC Mask */ + +#define USBH_HcRhStatus_OCIC_Pos (17) /*!< USBH_T::HcRhStatus: OCIC Position */ +#define USBH_HcRhStatus_OCIC_Msk (0x1ul << USBH_HcRhStatus_OCIC_Pos) /*!< USBH_T::HcRhStatus: OCIC Mask */ + +#define USBH_HcRhStatus_CRWE_Pos (31) /*!< USBH_T::HcRhStatus: CRWE Position */ +#define USBH_HcRhStatus_CRWE_Msk (0x1ul << USBH_HcRhStatus_CRWE_Pos) /*!< USBH_T::HcRhStatus: CRWE Mask */ + +#define USBH_HcRhPortStatus_CCS_Pos (0) /*!< USBH_T::HcRhPortStatus: CCS Position */ +#define USBH_HcRhPortStatus_CCS_Msk (0x1ul << USBH_HcRhPortStatus_CCS_Pos) /*!< USBH_T::HcRhPortStatus: CCS Mask */ + +#define USBH_HcRhPortStatus_PES_Pos (1) /*!< USBH_T::HcRhPortStatus: PES Position */ +#define USBH_HcRhPortStatus_PES_Msk (0x1ul << USBH_HcRhPortStatus_PES_Pos) /*!< USBH_T::HcRhPortStatus: PES Mask */ + +#define USBH_HcRhPortStatus_PSS_Pos (2) /*!< USBH_T::HcRhPortStatus: PSS Position */ +#define USBH_HcRhPortStatus_PSS_Msk (0x1ul << USBH_HcRhPortStatus_PSS_Pos) /*!< USBH_T::HcRhPortStatus: PSS Mask */ + +#define USBH_HcRhPortStatus_POCI_Pos (3) /*!< USBH_T::HcRhPortStatus: POCI Position */ +#define USBH_HcRhPortStatus_POCI_Msk (0x1ul << USBH_HcRhPortStatus_POCI_Pos) /*!< USBH_T::HcRhPortStatus: POCI Mask */ + +#define USBH_HcRhPortStatus_PRS_Pos (4) /*!< USBH_T::HcRhPortStatus: PRS Position */ +#define USBH_HcRhPortStatus_PRS_Msk (0x1ul << USBH_HcRhPortStatus_PRS_Pos) /*!< USBH_T::HcRhPortStatus: PRS Mask */ + +#define USBH_HcRhPortStatus_PPS_Pos (8) /*!< USBH_T::HcRhPortStatus: PPS Position */ +#define USBH_HcRhPortStatus_PPS_Msk (0x1ul << USBH_HcRhPortStatus_PPS_Pos) /*!< USBH_T::HcRhPortStatus: PPS Mask */ + +#define USBH_HcRhPortStatus_LSDA_Pos (9) /*!< USBH_T::HcRhPortStatus: LSDA Position */ +#define USBH_HcRhPortStatus_LSDA_Msk (0x1ul << USBH_HcRhPortStatus_LSDA_Pos) /*!< USBH_T::HcRhPortStatus: LSDA Mask */ + +#define USBH_HcRhPortStatus_CSC_Pos (16) /*!< USBH_T::HcRhPortStatus: CSC Position */ +#define USBH_HcRhPortStatus_CSC_Msk (0x1ul << USBH_HcRhPortStatus_CSC_Pos) /*!< USBH_T::HcRhPortStatus: CSC Mask */ + +#define USBH_HcRhPortStatus_PESC_Pos (17) /*!< USBH_T::HcRhPortStatus: PESC Position */ +#define USBH_HcRhPortStatus_PESC_Msk (0x1ul << USBH_HcRhPortStatus_PESC_Pos) /*!< USBH_T::HcRhPortStatus: PESC Mask */ + +#define USBH_HcRhPortStatus_PSSC_Pos (18) /*!< USBH_T::HcRhPortStatus: PSSC Position */ +#define USBH_HcRhPortStatus_PSSC_Msk (0x1ul << USBH_HcRhPortStatus_PSSC_Pos) /*!< USBH_T::HcRhPortStatus: PSSC Mask */ + +#define USBH_HcRhPortStatus_OCIC_Pos (19) /*!< USBH_T::HcRhPortStatus: OCIC Position */ +#define USBH_HcRhPortStatus_OCIC_Msk (0x1ul << USBH_HcRhPortStatus_OCIC_Pos) /*!< USBH_T::HcRhPortStatus: OCIC Mask */ + +#define USBH_HcRhPortStatus_PRSC_Pos (20) /*!< USBH_T::HcRhPortStatus: PRSC Position */ +#define USBH_HcRhPortStatus_PRSC_Msk (0x1ul << USBH_HcRhPortStatus_PRSC_Pos) /*!< USBH_T::HcRhPortStatus: PRSC Mask */ + +#define USBH_HcPhyControl_STBYEN_Pos (27) /*!< USBH_T::HcPhyControl: STBYEN Position */ +#define USBH_HcPhyControl_STBYEN_Msk (0x1ul << USBH_HcPhyControl_STBYEN_Pos) /*!< USBH_T::HcPhyControl: STBYEN Mask */ + +#define USBH_HcMiscControl_DBR16_Pos (0) /*!< USBH_T::HcMiscControl: DBR16 Position */ +#define USBH_HcMiscControl_DBR16_Msk (0x1ul << USBH_HcMiscControl_DBR16_Pos) /*!< USBH_T::HcMiscControl: DBR16 Mask */ + +#define USBH_HcMiscControl_ABORT_Pos (1) /*!< USBH_T::HcMiscControl: ABORT Position */ +#define USBH_HcMiscControl_ABORT_Msk (0x1ul << USBH_HcMiscControl_ABORT_Pos) /*!< USBH_T::HcMiscControl: ABORT Mask */ + +#define USBH_HcMiscControl_OCAL_Pos (3) /*!< USBH_T::HcMiscControl: OCAL Position */ +#define USBH_HcMiscControl_OCAL_Msk (0x1ul << USBH_HcMiscControl_OCAL_Pos) /*!< USBH_T::HcMiscControl: OCAL Mask */ + +#define USBH_HcMiscControl_PCAL_Pos (4) /*!< USBH_T::HcMiscControl: PCAL Position */ +#define USBH_HcMiscControl_PCAL_Msk (0x1ul << USBH_HcMiscControl_PCAL_Pos) /*!< USBH_T::HcMiscControl: PCAL Mask */ + +#define USBH_HcMiscControl_SIEPD_Pos (8) /*!< USBH_T::HcMiscControl: SIEPD Position */ +#define USBH_HcMiscControl_SIEPD_Msk (0x1ul << USBH_HcMiscControl_SIEPD_Pos) /*!< USBH_T::HcMiscControl: SIEPD Mask */ + +#define USBH_HcMiscControl_DPRT1_Pos (16) /*!< USBH_T::HcMiscControl: DPRT1 Position */ +#define USBH_HcMiscControl_DPRT1_Msk (0x1ul << USBH_HcMiscControl_DPRT1_Pos) /*!< USBH_T::HcMiscControl: DPRT1 Mask */ + +#define USBH_HcMiscControl_DPRT2_Pos (17) /*!< USBH_T::HcMiscControl: DPRT2 Position */ +#define USBH_HcMiscControl_DPRT2_Msk (0x1ul << USBH_HcMiscControl_DPRT2_Pos) /*!< USBH_T::HcMiscControl: DPRT2 Mask */ + +/**@}*/ /* USBH_CONST */ +/**@}*/ /* end of USBH register group */ + + +/*---------------------- USB Device Controller -------------------------*/ +/** + @addtogroup USBD USB Device Controller(USBD) + Memory Mapped Structure for USBD Controller +@{ */ +/** + * @brief USBD endpoints register + */ +typedef struct { + + union { + + /** + * EPxDAT + * =================================================================================================== + * Offset: 0x64+x*0x28 Endpoint x Data Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |EPDAT |Endpoint A~L Data Register + * | | |Endpoint A~L data buffer for the buffer transaction (read or write). + * | | |Note: Only word or byte access are supported. + */ + __IO uint32_t EPDAT; + /** + * EPxDAT_BYTE + * =================================================================================================== + * Offset: 0x64+x*0x28 Endpoint x Data Register for Byte Access + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |EPDAT |Endpoint A~L Data Register + * | | |Endpoint A~L data buffer for the buffer transaction (read or write). + * | | |Note: Only word or byte access are supported. + */ + __IO uint8_t EPDAT_BYTE; + + }; ///< Define EPA Data Register 32-bit or 8-bit access + + /** + * EPxINTSTS + * =================================================================================================== + * Offset: 0x68+x*0x28 Endpoint x Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BUFFULLIF |Buffer Full + * | | |For an IN endpoint, the currently selected buffer is full, or no buffer is available to the local side for writing (no space to write). + * | | |For an OUT endpoint, there is a buffer available on the local side, and there are FIFO full of bytes available to be read (entire packet is available for reading). + * | | |0 = The endpoint packet buffer is not full. + * | | |1 = The endpoint packet buffer is full. + * | | |Note: This bit is read-only. + * |[1] |BUFEMPTYIF|Buffer Empty + * | | |For an IN endpoint, a buffer is available to the local side for writing up to FIFO full of bytes. + * | | |0 = The endpoint buffer is not empty. + * | | |1 = The endpoint buffer is empty. + * | | |For an OUT endpoint: + * | | |0 = The currently selected buffer has not a count of 0. + * | | |1 = The currently selected buffer has a count of 0, or no buffer is available on the local side (nothing to read). + * | | |Note: This bit is read-only. + * |[2] |SHORTTXIF |Short Packet Transferred Interrupt + * | | |0 = The length of the last packet was not less than the Maximum Packet Size (EPMPS). + * | | |1 = The length of the last packet was less than the Maximum Packet Size (EPMPS). + * | | |Note: Write 1 to clear this bit to 0. + * |[3] |TXPKIF |Data Packet Transmitted Interrupt + * | | |0 = Not a data packet is transmitted from the endpoint to the host. + * | | |1 = A data packet is transmitted from the endpoint to the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[4] |RXPKIF |Data Packet Received Interrupt + * | | |0 = No data packet is received from the host by the endpoint. + * | | |1 = A data packet is received from the host by the endpoint. + * | | |Note: Write 1 to clear this bit to 0. + * |[5] |OUTTKIF |Data OUT Token Interrupt + * | | |0 = A Data OUT token has not been received from the host. + * | | |1 = A Data OUT token has been received from the host. + * | | |This bit also set by PING tokens(in high-speed only). + * | | |Note: Write 1 to clear this bit to 0. + * |[6] |INTKIF |Data IN Token Interrupt + * | | |0 = Not Data IN token has been received from the host. + * | | |1 = A Data IN token has been received from the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[7] |PINGIF |PING Token Interrupt + * | | |0 = A Data PING token has not been received from the host. + * | | |1 = A Data PING token has been received from the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[8] |NAKIF |USB NAK Sent + * | | |0 = The last USB IN packet could be provided, and was acknowledged with a ACK. + * | | |1 = The last USB IN packet could not be provided, and was acknowledged with a NAK. + * | | |Note: Write 1 to clear this bit to 0. + * |[9] |STALLIF |USB STALL Sent + * | | |0 = The last USB packet could be accepted or provided because the endpoint was stalled, and was acknowledged with a STALL. + * | | |1 = The last USB packet could not be accepted or provided because the endpoint was stalled, and was acknowledged with a STALL. + * | | |Note: Write 1 to clear this bit to 0. + * |[10] |NYETIF |NYET Sent + * | | |0 = The space available in the RAM is sufficient to accommodate the next on coming data packet. + * | | |1 = The space available in the RAM is not sufficient to accommodate the next on coming data packet. + * | | |Note: Write 1 to clear this bit to 0. + * |[11] |ERRIF |ERR Sent + * | | |0 = No any error in the transaction. + * | | |1 = There occurs any error in the transaction. + * | | |Note: Write 1 to clear this bit to 0. + * |[12] |SHORTRXIF |Bulk Out Short Packet Received + * | | |0 = No bulk out short packet is received. + * | | |1 = Received bulk out short packet (including zero length packet ). + * | | |Note: Write 1 to clear this bit to 0. + */ + __IO uint32_t EPINTSTS; + + /** + * EPxINTEN + * =================================================================================================== + * Offset: 0x6C+x*0x28 Endpoint x Interrupt Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |BUFFULLIEN|Buffer Full Interrupt + * | | |When set, this bit enables a local interrupt to be set when a buffer full condition is detected on the bus. + * | | |0 = Buffer full interrupt Disabled. + * | | |1 = Buffer full interrupt Enabled. + * |[1] |BUFEMPTYIEN|Buffer Empty Interrupt + * | | |When set, this bit enables a local interrupt to be set when a buffer empty condition is detected on the bus. + * | | |0 = Buffer empty interrupt Disabled. + * | | |1 = Buffer empty interrupt Enabled. + * |[2] |SHORTTXIEN|Short Packet Transferred Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a short data packet has been transferred to/from the host. + * | | |0 = Short data packet interrupt Disabled. + * | | |1 = Short data packet interrupt Enabled. + * |[3] |TXPKIEN |Data Packet Transmitted Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a data packet has been received from the host. + * | | |0 = Data packet has been received from the host interrupt Disabled. + * | | |1 = Data packet has been received from the host interrupt Enabled. + * |[4] |RXPKIEN |Data Packet Received Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a data packet has been transmitted to the host. + * | | |0 = Data packet has been transmitted to the host interrupt Disabled. + * | | |1 = Data packet has been transmitted to the host interrupt Enabled. + * |[5] |OUTTKIEN |Data OUT Token Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a Data OUT token has been received from the host. + * | | |0 = Data OUT token interrupt Disabled. + * | | |1 = Data OUT token interrupt Enabled. + * |[6] |INTKIEN |Data IN Token Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a Data IN token has been received from the host. + * | | |0 = Data IN token interrupt Disabled. + * | | |1 = Data IN token interrupt Enabled. + * |[7] |PINGIEN |PING Token Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a PING token has been received from the host. + * | | |0 = PING token interrupt Disabled. + * | | |1 = PING token interrupt Enabled. + * |[8] |NAKIEN |USB NAK Sent Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a NAK token is sent to the host. + * | | |0 = NAK token interrupt Disabled. + * | | |1 = NAK token interrupt Enabled. + * |[9] |STALLIEN |USB STALL Sent Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set when a stall token is sent to the host. + * | | |0 = STALL token interrupt Disabled. + * | | |1 = STALL token interrupt Enabled. + * |[10] |NYETIEN |NYET Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set whenever NYET condition occurs on the bus for this endpoint. + * | | |0 = NYET condition interrupt Disabled. + * | | |1 = NYET condition interrupt Enabled. + * |[11] |ERRIEN |ERR Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set whenever ERR condition occurs on the bus for this endpoint. + * | | |0 = Error event interrupt Disabled. + * | | |1 = Error event interrupt Enabled. + * |[12] |SHORTRXIEN|Bulk Out Short Packet Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be set whenever bulk out short packet occurs on the bus for this endpoint. + * | | |0 = Bulk out interrupt Disabled. + * | | |1 = Bulk out interrupt Enabled. + */ + __IO uint32_t EPINTEN; + + /** + * EPxDATCNT + * =================================================================================================== + * Offset: 0x70+x*0x28 Endpoint x Data Available Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |DATCNT |Data Count + * | | |For an OUT/IN endpoint, this register returns the number of valid bytes in the endpoint packet buffer. + * |[16:30] |DMALOOP |DMA Loop + * | | |This register is the remaining DMA loop to complete. Each loop means 32-byte transfer. + */ + __I uint32_t EPDATCNT; + + /** + * EPxRSPCTL + * =================================================================================================== + * Offset: 0x74+x*0x28 Endpoint x Response Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |FLUSH |Buffer Flush + * | | |Writing 1 to this bit causes the packet buffer to be flushed and the corresponding EP_AVAIL register to be cleared. + * | | |This bit is self-clearing. + * | | |This bit should always be written after an configuration event. + * | | |0 = The packet buffer is not flushed. + * | | |1 = The packet buffer is flushed by user. + * |[1:2] |MODE |Mode Control + * | | |The two bits decide the operation mode of the in-endpoint. + * | | |00: Auto-Validate Mode + * | | |01: Manual-Validate Mode + * | | |10: Fly Mode + * | | |11: Reserved + * | | |These bits are not valid for an out-endpoint. + * | | |The auto validate mode will be activated when the reserved mode is selected. + * |[3] |TOGGLE |Endpoint Toggle + * | | |This bit is used to clear the endpoint data toggle bit. + * | | |Reading this bit returns the current state of the endpoint data toggle bit. + * | | |The local CPU may use this bit to initialize the end-point's toggle in case of reception of a Set Interface request or a Clear Feature (ep_halt) request from the host. + * | | |Only when toggle bit is "1", this bit can be written into the inversed write data bit[3]. + * | | |0 = Not clear the endpoint data toggle bit. + * | | |1 = Clear the endpoint data toggle bit. + * |[4] |HALT |Endpoint Halt + * | | |This bit is used to send a STALL handshake as response to the token from the host. + * | | |When an Endpoint Set Feature (Endpoin_halt) is detected by the local CPU, it must write a '1' to this bit. + * | | |0 = Not send a STALL handshake as response to the token from the host. + * | | |1 = Send a STALL handshake as response to the token from the host. + * |[5] |ZEROLEN |Zero Length + * | | |This bit is used to send a zero-length packet n response to an IN-token. + * | | |When this bit is set, a zero packet is sent to the host on reception of an IN-token. + * | | |0 = A zero packet is not sent to the host on reception of an IN-token. + * | | |1 = A zero packet is sent to the host on reception of an IN-token. + * |[6] |SHORTTXEN |Short Packet Transfer Enable + * | | |This bit is applicable only in case of Auto-Validate Method. + * | | |This bit is set to validate any remaining data in the buffer which is not equal to the MPS of the endpoint, and happens to be the last transfer. + * | | |0 = Not validate any remaining data in the buffer which is not equal to the MPS of the endpoint. + * | | |1 = Validate any remaining data in the buffer which is not equal to the MPS of the endpoint. + * |[7] |DISBUF |Buffer Disable Control + * | | |This bit is used to disable buffer (set buffer size to 1) when a Bulk-OUT short packet is received. + * | | |0 = Buffer Not Disabled when Bulk-OUT short packet is received. + * | | |1 = Buffer Disabled when Bulk-OUT short packet is received. + */ + __IO uint32_t EPRSPCTL; + + /** + * EPxMPS + * =================================================================================================== + * Offset: 0x78+x*0x28 Endpoint x Maximum Packet Size Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:10] |EPMPS |Endpoint Maximum Packet Size + * | | |This field determines the Maximum Packet Size of the Endpoint. + */ + __IO uint32_t EPMPS; + + /** + * EPxTXCNT + * =================================================================================================== + * Offset: 0x7C+x*0x28 Endpoint x Transfer Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:10] |TXCNT |Endpoint Transfer Count + * | | |For IN endpoints, this field determines the total number of bytes to be sent to the host in case of manual validation method. + * | | |For OUT endpoints, this field has no effect. + */ + __IO uint32_t EPTXCNT; + + /** + * EPxCFG + * =================================================================================================== + * Offset: 0x80+x*0x28 Endpoint x Configuration Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |EPEN |Endpoint Valid + * | | |When set, this bit enables this endpoint. + * | | |This bit has no effect on Endpoint 0, which is always enabled. + * | | |0 = The endpoint Disabled. + * | | |1 = The endpoint Enabled. + * |[1:2] |EPTYPE |Endpoint Type + * | | |This field selects the type of this endpoint. Endpoint 0 is forced to a Control type. + * | | |00 = Reserved. + * | | |01 = Bulk. + * | | |10 = Interrupt. + * | | |11 = Isochronous. + * |[3] |EPDIR |Endpoint Direction + * | | |0 = out-endpoint (Host OUT to Device). + * | | |1 = in-endpoint (Host IN to Device). + * | | |Note: A maximum of one OUT and IN endpoint is allowed for each endpoint number. + * |[4:7] |EPNUM |Endpoint Number + * | | |This field selects the number of the endpoint. Valid numbers 1 to 15. + */ + __IO uint32_t EPCFG; + + /** + * EPxBUFSTART + * =================================================================================================== + * Offset: 0x84+x*0x28 Endpoint x RAM Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |SADDR |Endpoint Start Address + * | | |This is the start-address of the RAM space allocated for the endpoint A~L. + */ + __IO uint32_t EPBUFSTART; + + /** + * EPxBUFEND + * =================================================================================================== + * Offset: 0x88+x*0x28 Endpoint x RAM End Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |EADDR |Endpoint End Address + * | | |This is the end-address of the RAM space allocated for the endpoint A~L. + */ + __IO uint32_t EPBUFEND; + + +} USBD_EP_T; + + +typedef struct { + + + /** + * GINTSTS + * =================================================================================================== + * Offset: 0x00 Interrupt Status Low Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |USBIF |USB Interrupt + * | | |This bit conveys the interrupt status for USB specific events endpoint. + * | | |When set, USB interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[1] |CEPIF |Control Endpoint Interrupt + * | | |This bit conveys the interrupt status for control endpoint. + * | | |When set, Control-ep's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[2] |EPAIF |Endpoints A Interrupt + * | | |When set, the corresponding Endpoint A's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[3] |EPBIF |Endpoints B Interrupt + * | | |When set, the corresponding Endpoint B's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[4] |EPCIF |Endpoints C Interrupt + * | | |When set, the corresponding Endpoint C's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[5] |EPDIF |Endpoints D Interrupt + * | | |When set, the corresponding Endpoint D's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[6] |EPEIF |Endpoints E Interrupt + * | | |When set, the corresponding Endpoint E's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[7] |EPFIF |Endpoints F Interrupt + * | | |When set, the corresponding Endpoint F's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[8] |EPGIF |Endpoints G Interrupt + * | | |When set, the corresponding Endpoint G's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[9] |EPHIF |Endpoints H Interrupt + * | | |When set, the corresponding Endpoint H's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[10] |EPIIF |Endpoints I Interrupt + * | | |When set, the corresponding Endpoint I's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[11] |EPJIF |Endpoints J Interrupt + * | | |When set, the corresponding Endpoint J's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[12] |EPKIF |Endpoints K Interrupt + * | | |When set, the corresponding Endpoint K's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + * |[13] |EPLIF |Endpoints L Interrupt + * | | |When set, the corresponding Endpoint L's interrupt status register should be read to determine the cause of the interrupt. + * | | |0 = No interrupt event occurred. + * | | |1 = The related interrupt event is occurred. + */ + __I uint32_t GINTSTS; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE0[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * GINTEN + * =================================================================================================== + * Offset: 0x08 Interrupt Enable Low Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |USBIE |USB Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be generated when a USB event occurs on the bus. + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[1] |CEPIE |Control Endpoint Interrupt Enable Control + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the control endpoint. + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[2] |EPAIE |Interrupt Enable Control For Endpoint A + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint A. + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[3] |EPBIE |Interrupt Enable Control For Endpoint B + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint B + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[4] |EPCIE |Interrupt Enable Control For Endpoint C + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint C + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[5] |EPDIE |Interrupt Enable Control For Endpoint D + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint D + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[6] |EPEIE |Interrupt Enable Control For Endpoint E + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint E + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[7] |EPFIE |Interrupt Enable Control For Endpoint F + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint F + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[8] |EPGIE |Interrupt Enable Control For Endpoint G + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint G + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[9] |EPHIE |Interrupt Enable Control For Endpoint H + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint H + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[10] |EPIIE |Interrupt Enable Control For Endpoint I + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint I + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[11] |EPJIE |Interrupt Enable Control For Endpoint J + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint J + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[12] |EPKIE |Interrupt Enable Control For Endpoint K + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint K + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + * |[13] |EPLIE |Interrupt Enable Control For Endpoint L + * | | |When set, this bit enables a local interrupt to be generated when an interrupt is pending for the endpoint L + * | | |0 = The related interrupt Disabled. + * | | |1 = The related interrupt Enabled. + */ + __IO uint32_t GINTEN; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE1[1]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * BUSINTSTS + * =================================================================================================== + * Offset: 0x10 USB Bus Interrupt Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SOFIF |SOF Receive Control + * | | |This bit indicates when a start-of-frame packet has been received. + * | | |0 = No start-of-frame packet has been received. + * | | |1 = Start-of-frame packet has been received. + * | | |Note: Write 1 to clear this bit to 0. + * |[1] |RSTIF |Reset Status + * | | |When set, this bit indicates that either the USB root port reset is end. + * | | |0 = No USB root port reset is end. + * | | |1 = USB root port reset is end. + * | | |Note: Write 1 to clear this bit to 0. + * |[2] |RESUMEIF |Resume + * | | |When set, this bit indicates that a device resume has occurred. + * | | |0 = No device resume has occurred. + * | | |1 = Device resume has occurred. + * | | |Note: Write 1 to clear this bit to 0. + * |[3] |SUSPENDIF |Suspend Request + * | | |This bit is set as default and it has to be cleared by writing '1' before the USB reset. + * | | |This bit is also set when a USB Suspend request is detected from the host. + * | | |0 = No USB Suspend request is detected from the host. + * | | |1= USB Suspend request is detected from the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[4] |HISPDIF |High-Speed Settle + * | | |0 = No valid high-speed reset protocol is detected. + * | | |1 = Valid high-speed reset protocol is over and the device has settled in high-speed. + * | | |Note: Write 1 to clear this bit to 0. + * |[5] |DMADONEIF |DMA Completion Interrupt + * | | |0 = No DMA transfer over. + * | | |1 = DMA transfer is over. + * | | |Note: Write 1 to clear this bit to 0. + * |[6] |PHYCLKVLDIF|Usable Clock Interrupt + * | | |0 = Usable clock is not available. + * | | |1 = Usable clock is available from the transceiver. + * | | |Note: Write 1 to clear this bit to 0. + * |[8] |VBUSDETIF |VBUS Detection Interrupt Status + * | | |0 = No VBUS is plug-in. + * | | |1 = VBUS is plug-in. + * | | |Note: Write 1 to clear this bit to 0. + */ + __IO uint32_t BUSINTSTS; + + /** + * BUSINTEN + * =================================================================================================== + * Offset: 0x14 USB Bus Interrupt Enable Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SOFIEN |SOF Interrupt + * | | |This bit enables the SOF interrupt. + * | | |0 = SOF interrupt Disabled. + * | | |1 = SOF interrupt Enabled. + * |[1] |RSTIEN |Reset Status + * | | |This bit enables the USB-Reset interrupt. + * | | |0 = USB-Reset interrupt Disabled. + * | | |1 = USB-Reset interrupt Enabled. + * |[2] |RESUMEIEN |Resume + * | | |This bit enables the Resume interrupt. + * | | |0 = Resume interrupt Disabled. + * | | |1 = Resume interrupt Enabled. + * |[3] |SUSPENDIEN|Suspend Request + * | | |This bit enables the Suspend interrupt. + * | | |0 = Suspend interrupt Disabled. + * | | |1 = Suspend interrupt Enabled. + * |[4] |HISPDIEN |High-Speed Settle + * | | |This bit enables the high-speed settle interrupt. + * | | |0 = High-speed settle interrupt Disabled. + * | | |1 = High-speed settle interrupt Enabled. + * |[5] |DMADONEIEN|DMA Completion Interrupt + * | | |This bit enables the DMA completion interrupt + * | | |0 = DMA completion interrupt Disabled. + * | | |1 = DMA completion interrupt Enabled. + * |[6] |PHYCLKVLDIEN|Usable Clock Interrupt + * | | |This bit enables the usable clock interrupt. + * | | |0 = Usable clock interrupt Disabled. + * | | |1 = Usable clock interrupt Enabled. + * |[8] |VBUSDETIEN|VBUS Detection Interrupt Enable Control + * | | |This bit enables the VBUS floating detection interrupt. + * | | |0 = VBUS floating detection interrupt Disabled. + * | | |1 = VBUS floating detection interrupt Enabled. + */ + __IO uint32_t BUSINTEN; + + /** + * OPER + * =================================================================================================== + * Offset: 0x18 USB Operational Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RESUMEEN |Generate Resume + * | | |0 = No Resume sequence to be initiated to the host. + * | | |1 = A Resume sequence to be initiated to the host if device remote wakeup is enabled. + * | | |This bit is self-clearing. + * |[1] |HISPDEN |USB High-Speed + * | | |0 = The USB device controller to suppress the chirp-sequence during reset protocol, thereby allowing the USB device controller to settle in full-speed, even though it is connected to a USB2.0 Host. + * | | |1 = The USB device controller to initiate a chirp-sequence during reset protocol. + * |[2] |CURSPD |USB Current Speed + * | | |0 = The device has settled in Full Speed. + * | | |1 = The USB device controller has settled in High-speed. + */ + __IO uint32_t OPER; + + /** + * FRAMECNT + * =================================================================================================== + * Offset: 0x1C USB Frame Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |MFRAMECNT |Micro-Frame Counter + * | | |This field contains the micro-frame number for the frame number in the frame counter field. + * |[3:13] |FRAMECNT |Frame Counter + * | | |This field contains the frame count from the most recent start-of-frame packet. + */ + __I uint32_t FRAMECNT; + + /** + * FADDR + * =================================================================================================== + * Offset: 0x20 USB Function Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:6] |FADDR |USB Function Address + * | | |This field contains the current USB address of the device. + * | | |This field is cleared when a root port reset is detected. + */ + __IO uint32_t FADDR; + + /** + * TEST + * =================================================================================================== + * Offset: 0x24 USB Test Mode Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:2] |TESTMODE |Test Mode Selection + * | | |000 = Normal Operation. + * | | |001 = Test_J. + * | | |010 = Test_K. + * | | |011 = Test_SE0_NAK. + * | | |100 = Test_Packet. + * | | |101 = Test_Force_Enable. + * | | |110 = Reserved. + * | | |111 = Reserved. + * | | |Note: This field is cleared when root port reset is detected. + */ + __IO uint32_t TEST; + + union { + + /** + * CEPDAT + * =================================================================================================== + * Offset: 0x28 Control-Endpoint Data Buffer + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DAT |Control-Endpoint Data Buffer + * | | |Control endpoint data buffer for the buffer transaction (read or write). + * | | |Note: Only word or byte access are supported. + */ + __IO uint32_t CEPDAT; + /** + * CEPDAT_BYTE + * =================================================================================================== + * Offset: 0x28 Control-Endpoint Data Buffer for Byte Access + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |DAT |Control-Endpoint Data Buffer + * | | |Control endpoint data buffer for the buffer transaction (read or write). + * | | |Note: Only word or byte access are supported. + */ + __IO uint8_t CEPDAT_BYTE; + + };///< Define Control-Endpoint Data Register 32-bit or 8-bit access + + /** + * CEPCTL + * =================================================================================================== + * Offset: 0x2C Control-Endpoint Control and Status + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |NAKCLR |No Acknowledge Control + * | | |This bit plays a crucial role in any control transfer. + * | | |0 = The bit is being cleared by the local CPU by writing zero, the USB device controller will be responding with NAKs for the subsequent status phase. + * | | |This mechanism holds the host from moving to the next request, until the local CPU is also ready to process the next request. + * | | |1 = This bit is set to one by the USB device controller, whenever a setup token is received. + * | | |The local CPU can take its own time to finish off any house-keeping work based on the request and then clear this bit. + * | | |Note: Only when CPU writes data[1:0] is 2'b10 or 2'b00, this bit can be updated. + * |[1] |STALLEN |Stall Enable Control + * | | |When this stall bit is set, the control endpoint sends a stall handshake in response to any in or out token thereafter. + * | | |This is typically used for response to invalid/unsupported requests. + * | | |When this bit is being set the NAK clear bit has to be cleared at the same time since the NAK clear bit has highest priority than STALL. + * | | |It is automatically cleared on receipt of a next setup-token. + * | | |So, the local CPU need not write again to clear this bit. + * | | |0 = No sends a stall handshake in response to any in or out token thereafter. + * | | |1 = The control endpoint sends a stall handshake in response to any in or out token thereafter. + * | | |Note: Only when CPU writes data[1:0] is 2'b10 or 2'b00, this bit can be updated. + * |[2] |ZEROLEN |Zero Packet Length + * | | |This bit is valid for Auto Validation mode only. + * | | |0 = No zero length packet to the host during Data stage to an IN token. + * | | |1 = USB device controller can send a zero length packet to the host during Data stage to an IN token. + * | | |This bit gets cleared once the zero length data packet is sent. + * | | |So, the local CPU need not write again to clear this bit. + * |[3] |FLUSH |CEP-FLUSH Bit + * | | |0 = No the packet buffer and its corresponding USBD_CEPDATCNT register to be cleared. + * | | |1 = The packet buffer and its corresponding USBD_CEPDATCNT register to be cleared. + * | | |This bit is self-cleaning. + */ + __IO uint32_t CEPCTL; + + /** + * CEPINTEN + * =================================================================================================== + * Offset: 0x30 Control-Endpoint Interrupt Enable + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SETUPTKIEN|Setup Token Interrupt Enable Control + * | | |0 = The SETUP token interrupt in Control Endpoint Disabled. + * | | |1 = The SETUP token interrupt in Control Endpoint Enabled. + * |[1] |SETUPPKIEN|Setup Packet Interrupt + * | | |0 = The SETUP packet interrupt in Control Endpoint Disabled. + * | | |1 = The SETUP packet interrupt in Control Endpoint Enabled. + * |[2] |OUTTKIEN |Out Token Interrupt + * | | |0 = The OUT token interrupt in Control Endpoint Disabled. + * | | |1 = The OUT token interrupt in Control Endpoint Enabled. + * |[3] |INTKIEN |In Token Interrupt + * | | |0 = The IN token interrupt in Control Endpoint Disabled. + * | | |1 = The IN token interrupt in Control Endpoint Enabled. + * |[4] |PINGIEN |Ping Token Interrupt + * | | |0 = The ping token interrupt in Control Endpoint Disabled. + * | | |1 = The ping token interrupt Control Endpoint Enabled. + * |[5] |TXPKIEN |Data Packet Transmitted Interrupt + * | | |0 = The data packet transmitted interrupt in Control Endpoint Disabled. + * | | |1 = The data packet transmitted interrupt in Control Endpoint Enabled. + * |[6] |RXPKIEN |Data Packet Received Interrupt + * | | |0 = The data received interrupt in Control Endpoint Disabled. + * | | |1 = The data received interrupt in Control Endpoint Enabled. + * |[7] |NAKIEN |NAK Sent Interrupt + * | | |0 = The NAK sent interrupt in Control Endpoint Disabled. + * | | |1 = The NAK sent interrupt in Control Endpoint Enabled. + * |[8] |STALLIEN |STALL Sent Interrupt + * | | |0 = The STALL sent interrupt in Control Endpoint Disabled. + * | | |1 = The STALL sent interrupt in Control Endpoint Enabled. + * |[9] |ERRIEN |USB Error Interrupt + * | | |0 = The USB Error interrupt in Control Endpoint Disabled. + * | | |1 = The USB Error interrupt in Control Endpoint Enabled. + * |[10] |STSDONEIEN|Status Completion Interrupt + * | | |0 = The Status Completion interrupt in Control Endpoint Disabled. + * | | |1 = The Status Completion interrupt in Control Endpoint Enabled. + * |[11] |BUFFULLIEN|Buffer Full Interrupt + * | | |0 = The buffer full interrupt in Control Endpoint Disabled. + * | | |1 = The buffer full interrupt in Control Endpoint Enabled. + * |[12] |BUFEMPTYIEN|Buffer Empty Interrupt + * | | |0 = The buffer empty interrupt in Control Endpoint Disabled. + * | | |1= The buffer empty interrupt in Control Endpoint Enabled. + */ + __IO uint32_t CEPINTEN; + + /** + * CEPINTSTS + * =================================================================================================== + * Offset: 0x34 Control-Endpoint Interrupt Status + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |SETUPTKIF |Setup Token Interrupt + * | | |0 = Not a Setup token is received. + * | | |1 = A Setup token is received. Writing 1 clears this status bit + * | | |Note: Write 1 to clear this bit to 0. + * |[1] |SETUPPKIF |Setup Packet Interrupt + * | | |This bit must be cleared (by writing 1) before the next setup packet can be received. + * | | |If the bit is not cleared, then the successive setup packets will be overwritten in the setup packet buffer. + * | | |0 = Not a Setup packet has been received from the host. + * | | |1 = A Setup packet has been received from the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[2] |OUTTKIF |Out Token Interrupt + * | | |0 = The control-endpoint does not received an OUT token from the host. + * | | |1 = The control-endpoint receives an OUT token from the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[3] |INTKIF |In Token Interrupt + * | | |0 = The control-endpoint does not received an IN token from the host. + * | | |1 = The control-endpoint receives an IN token from the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[4] |PINGIF |Ping Token Interrupt + * | | |0 = The control-endpoint does not received a ping token from the host. + * | | |1 = The control-endpoint receives a ping token from the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[5] |TXPKIF |Data Packet Transmitted Interrupt + * | | |0 = Not a data packet is successfully transmitted to the host in response to an IN-token and an ACK-token is received for the same. + * | | |1 = A data packet is successfully transmitted to the host in response to an IN-token and an ACK-token is received for the same. + * | | |Note: Write 1 to clear this bit to 0. + * |[6] |RXPKIF |Data Packet Received Interrupt + * | | |0 = Not a data packet is successfully received from the host for an OUT-token and an ACK is sent to the host. + * | | |1 = A data packet is successfully received from the host for an OUT-token and an ACK is sent to the host. + * | | |Note: Write 1 to clear this bit to 0. + * |[7] |NAKIF |NAK Sent Interrupt + * | | |0 = Not a NAK-token is sent in response to an IN/OUT token. + * | | |1 = A NAK-token is sent in response to an IN/OUT token. + * | | |Note: Write 1 to clear this bit to 0. + * |[8] |STALLIF |STALL Sent Interrupt + * | | |0 = Not a stall-token is sent in response to an IN/OUT token. + * | | |1 = A stall-token is sent in response to an IN/OUT token. + * | | |Note: Write 1 to clear this bit to 0. + * |[9] |ERRIF |USB Error Interrupt + * | | |0 = No error had occurred during the transaction. + * | | |1 = An error had occurred during the transaction. + * | | |Note: Write 1 to clear this bit to 0. + * |[10] |STSDONEIF |Status Completion Interrupt + * | | |0 = Not a USB transaction has completed successfully. + * | | |1 = The status stage of a USB transaction has completed successfully. + * | | |Note: Write 1 to clear this bit to 0. + * |[11] |BUFFULLIF |Buffer Full Interrupt + * | | |0 = The control-endpoint buffer is not full. + * | | |1 = The control-endpoint buffer is full. + * | | |Note: Write 1 to clear this bit to 0. + * |[12] |BUFEMPTYIF|Buffer Empty Interrupt + * | | |0 = The control-endpoint buffer is not empty. + * | | |1 = The control-endpoint buffer is empty. + * | | |Note: Write 1 to clear this bit to 0. + */ + __IO uint32_t CEPINTSTS; + + /** + * CEPTXCNT + * =================================================================================================== + * Offset: 0x38 Control-Endpoint In-transfer Data Count + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |TXCNT |In-Transfer Data Count + * | | |There is no mode selection for the control endpoint (but it operates like manual mode).The local-CPU has to fill the control-endpoint buffer with the data to be sent for an in-token and to write the count of bytes in this register. + * | | |When zero is written into this field, a zero length packet is sent to the host. + * | | |When the count written in the register is more than the MPS, the data sent will be of only MPS. + */ + __IO uint32_t CEPTXCNT; + + /** + * CEPRXCNT + * =================================================================================================== + * Offset: 0x3C Control-Endpoint Out-transfer Data Count + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |RXCNT |Out-Transfer Data Count + * | | |The USB device controller maintains the count of the data received in case of an out transfer, during the control transfer. + */ + __I uint32_t CEPRXCNT; + + /** + * CEPDATCNT + * =================================================================================================== + * Offset: 0x40 Control-Endpoint data count + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:15] |DATCNT |Control-Endpoint Data Count + * | | |The USB device controller maintains the count of the data of control-endpoint. + */ + __I uint32_t CEPDATCNT; + + /** + * SETUP1_0 + * =================================================================================================== + * Offset: 0x44 Setup1 & Setup0 bytes + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SETUP0 |Setup Byte 0[7:0] + * | | |This register provides byte 0 of the last setup packet received. + * | | |For a Standard Device Request, the following bmRequestType information is returned. + * | | |Bit 7(Direction): + * | | | 0: Host to device + * | | | 1: Device to host + * | | |Bit 6-5 (Type): + * | | | 00: Standard + * | | | 01: Class + * | | | 10: Vendor + * | | | 11: Reserved + * | | |Bit 4-0 (Recipient) + * | | | 00000: Device + * | | | 00001: Interface + * | | | 00010: Endpoint + * | | | 00011: Other + * | | | Others: Reserved + * |[8:15] |SETUP1 |Setup Byte 1[15:8] + * | | |This register provides byte 1 of the last setup packet received. + * | | |For a Standard Device Request, the following bRequest Code information is returned. + * | | |00000000 = Get Status. + * | | |00000001 = Clear Feature. + * | | |00000010 = Reserved. + * | | |00000011 = Set Feature. + * | | |00000100 = Reserved. + * | | |00000101 = Set Address. + * | | |00000110 = Get Descriptor. + * | | |00000111 = Set Descriptor. + * | | |00001000 = Get Configuration. + * | | |00001001 = Set Configuration. + * | | |00001010 = Get Interface. + * | | |00001011 = Set Interface. + * | | |00001100 = Synch Frame. + */ + __I uint32_t SETUP1_0; + + /** + * SETUP3_2 + * =================================================================================================== + * Offset: 0x48 Setup3 & Setup2 Bytes + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SETUP2 |Setup Byte 2 [7:0] + * | | |This register provides byte 2 of the last setup packet received. + * | | |For a Standard Device Request, the least significant byte of the wValue field is returned. + * |[8:15] |SETUP3 |Setup Byte 3 [15:8] + * | | |This register provides byte 3 of the last setup packet received. + * | | |For a Standard Device Request, the most significant byte of the wValue field is returned. + */ + __I uint32_t SETUP3_2; + + /** + * SETUP5_4 + * =================================================================================================== + * Offset: 0x4C Setup5 & Setup4 Bytes + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SETUP4 |Setup Byte 4[7:0] + * | | |This register provides byte 4 of the last setup packet received. + * | | |For a Standard Device Request, the least significant byte of the wIndex is returned. + * |[8:15] |SETUP5 |Setup Byte 5[15:8] + * | | |This register provides byte 5 of the last setup packet received. + * | | |For a Standard Device Request, the most significant byte of the wIndex field is returned. + */ + __I uint32_t SETUP5_4; + + /** + * SETUP7_6 + * =================================================================================================== + * Offset: 0x50 Setup7 & Setup6 Bytes + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:7] |SETUP6 |Setup Byte 6[7:0] + * | | |This register provides byte 6 of the last setup packet received. + * | | |For a Standard Device Request, the least significant byte of the wLength field is returned. + * |[8:15] |SETUP7 |Setup Byte 7[15:8] + * | | |This register provides byte 7 of the last setup packet received. + * | | |For a Standard Device Request, the most significant byte of the wLength field is returned. + */ + __I uint32_t SETUP7_6; + + /** + * CEPBUFSTART + * =================================================================================================== + * Offset: 0x54 Control Endpoint RAM Start Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |SADDR |Control-Endpoint Start Address + * | | |This is the start-address of the RAM space allocated for the control-endpoint. + */ + __IO uint32_t CEPBUFSTART; + + /** + * CEPBUFEND + * =================================================================================================== + * Offset: 0x58 Control Endpoint RAM End Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:11] |EADDR |Control-Endpoint End Address + * | | |This is the end-address of the RAM space allocated for the control-endpoint. + */ + __IO uint32_t CEPBUFEND; + + /** + * DMACTL + * =================================================================================================== + * Offset: 0x5C DMA Control Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:3] |EPNUM |DMA Endpoint Address Bits + * | | |Used to define the Endpoint Address + * |[4] |DMARD |DMA Operation + * | | |0 = the operation is a DMA write. + * | | |1 = the operation is a DMA read. + * |[5] |DMAEN |DMA Enable Control + * | | |0 = DMA function Disabled. + * | | |1 = DMA function Enabled. + * |[6] |SGEN |Scatter Gather Function Enable Control + * | | |0 = Scatter gather function Disabled. + * | | |1 = Scatter gather function Enabled. + * |[7] |DMARST |Reset DMA State Machine + * | | |0 = No reset the DMA state machine. + * | | |1 = Reset the DMA state machine. + */ + __IO uint32_t DMACTL; + + /** + * DMACNT + * =================================================================================================== + * Offset: 0x60 DMA Count Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:19] |DMACNT |DMA Transfer Count + * | | |The transfer count of the DMA operation to be performed is written to this register. + */ + __IO uint32_t DMACNT; + + USBD_EP_T EP[12]; + /// @cond HIDDEN_SYMBOLS + uint32_t RESERVE2[303]; + /// @endcond //HIDDEN_SYMBOLS + + + /** + * DMAADDR + * =================================================================================================== + * Offset: 0x700 AHB DMA Address Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |DMAADDR |DMAADDR + * | | |The register specifies the address from which the DMA has to read / write. + * | | |The address must WORD (32-bit) aligned. + */ + __IO uint32_t DMAADDR; + + /** + * PHYCTL + * =================================================================================================== + * Offset: 0x704 USB PHY Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[8] |DPPUEN |DP Pull-Up + * | | |0 = Pull-up resistor on D+ Disabled. + * | | |1 = Pull-up resistor on D+ Enabled. + * |[9] |PHYEN |PHY Suspend Enable Control + * | | |0 = The USB PHY is suspend. + * | | |1 = The USB PHY is not suspend. + * |[24] |WKEN |Wake-Up Enable Control + * | | |0 = The wake-up function Disabled. + * | | |1 = The wake-up function Enabled. + * |[31] |VBUSDET |VBUS Status + * | | |0 = The VBUS is not detected yet. + * | | |1 = The VBUS is detected. + */ + __IO uint32_t PHYCTL; + +} USBD_T; + +/** + @addtogroup USBD_CONST USBD Bit Field Definition + Constant Definitions for USBD Controller +@{ */ + +#define USBD_GINTSTS_USBIF_Pos (0) /*!< USBD_T::GINTSTS: USBIF Position */ +#define USBD_GINTSTS_USBIF_Msk (0x1ul << USBD_GINTSTS_USBIF_Pos) /*!< USBD_T::GINTSTS: USBIF Mask */ + +#define USBD_GINTSTS_CEPIF_Pos (1) /*!< USBD_T::GINTSTS: CEPIF Position */ +#define USBD_GINTSTS_CEPIF_Msk (0x1ul << USBD_GINTSTS_CEPIF_Pos) /*!< USBD_T::GINTSTS: CEPIF Mask */ + +#define USBD_GINTSTS_EPAIF_Pos (2) /*!< USBD_T::GINTSTS: EPAIF Position */ +#define USBD_GINTSTS_EPAIF_Msk (0x1ul << USBD_GINTSTS_EPAIF_Pos) /*!< USBD_T::GINTSTS: EPAIF Mask */ + +#define USBD_GINTSTS_EPBIF_Pos (3) /*!< USBD_T::GINTSTS: EPBIF Position */ +#define USBD_GINTSTS_EPBIF_Msk (0x1ul << USBD_GINTSTS_EPBIF_Pos) /*!< USBD_T::GINTSTS: EPBIF Mask */ + +#define USBD_GINTSTS_EPCIF_Pos (4) /*!< USBD_T::GINTSTS: EPCIF Position */ +#define USBD_GINTSTS_EPCIF_Msk (0x1ul << USBD_GINTSTS_EPCIF_Pos) /*!< USBD_T::GINTSTS: EPCIF Mask */ + +#define USBD_GINTSTS_EPDIF_Pos (5) /*!< USBD_T::GINTSTS: EPDIF Position */ +#define USBD_GINTSTS_EPDIF_Msk (0x1ul << USBD_GINTSTS_EPDIF_Pos) /*!< USBD_T::GINTSTS: EPDIF Mask */ + +#define USBD_GINTSTS_EPEIF_Pos (6) /*!< USBD_T::GINTSTS: EPEIF Position */ +#define USBD_GINTSTS_EPEIF_Msk (0x1ul << USBD_GINTSTS_EPEIF_Pos) /*!< USBD_T::GINTSTS: EPEIF Mask */ + +#define USBD_GINTSTS_EPFIF_Pos (7) /*!< USBD_T::GINTSTS: EPFIF Position */ +#define USBD_GINTSTS_EPFIF_Msk (0x1ul << USBD_GINTSTS_EPFIF_Pos) /*!< USBD_T::GINTSTS: EPFIF Mask */ + +#define USBD_GINTSTS_EPGIF_Pos (8) /*!< USBD_T::GINTSTS: EPGIF Position */ +#define USBD_GINTSTS_EPGIF_Msk (0x1ul << USBD_GINTSTS_EPGIF_Pos) /*!< USBD_T::GINTSTS: EPGIF Mask */ + +#define USBD_GINTSTS_EPHIF_Pos (9) /*!< USBD_T::GINTSTS: EPHIF Position */ +#define USBD_GINTSTS_EPHIF_Msk (0x1ul << USBD_GINTSTS_EPHIF_Pos) /*!< USBD_T::GINTSTS: EPHIF Mask */ + +#define USBD_GINTSTS_EPIIF_Pos (10) /*!< USBD_T::GINTSTS: EPIIF Position */ +#define USBD_GINTSTS_EPIIF_Msk (0x1ul << USBD_GINTSTS_EPIIF_Pos) /*!< USBD_T::GINTSTS: EPIIF Mask */ + +#define USBD_GINTSTS_EPJIF_Pos (11) /*!< USBD_T::GINTSTS: EPJIF Position */ +#define USBD_GINTSTS_EPJIF_Msk (0x1ul << USBD_GINTSTS_EPJIF_Pos) /*!< USBD_T::GINTSTS: EPJIF Mask */ + +#define USBD_GINTSTS_EPKIF_Pos (12) /*!< USBD_T::GINTSTS: EPKIF Position */ +#define USBD_GINTSTS_EPKIF_Msk (0x1ul << USBD_GINTSTS_EPKIF_Pos) /*!< USBD_T::GINTSTS: EPKIF Mask */ + +#define USBD_GINTSTS_EPLIF_Pos (13) /*!< USBD_T::GINTSTS: EPLIF Position */ +#define USBD_GINTSTS_EPLIF_Msk (0x1ul << USBD_GINTSTS_EPLIF_Pos) /*!< USBD_T::GINTSTS: EPLIF Mask */ + +#define USBD_GINTEN_USBIE_Pos (0) /*!< USBD_T::GINTEN: USBIE Position */ +#define USBD_GINTEN_USBIE_Msk (0x1ul << USBD_GINTEN_USBIE_Pos) /*!< USBD_T::GINTEN: USBIE Mask */ + +#define USBD_GINTEN_CEPIE_Pos (1) /*!< USBD_T::GINTEN: CEPIE Position */ +#define USBD_GINTEN_CEPIE_Msk (0x1ul << USBD_GINTEN_CEPIE_Pos) /*!< USBD_T::GINTEN: CEPIE Mask */ + +#define USBD_GINTEN_EPAIE_Pos (2) /*!< USBD_T::GINTEN: EPAIE Position */ +#define USBD_GINTEN_EPAIE_Msk (0x1ul << USBD_GINTEN_EPAIE_Pos) /*!< USBD_T::GINTEN: EPAIE Mask */ + +#define USBD_GINTEN_EPBIE_Pos (3) /*!< USBD_T::GINTEN: EPBIE Position */ +#define USBD_GINTEN_EPBIE_Msk (0x1ul << USBD_GINTEN_EPBIE_Pos) /*!< USBD_T::GINTEN: EPBIE Mask */ + +#define USBD_GINTEN_EPCIE_Pos (4) /*!< USBD_T::GINTEN: EPCIE Position */ +#define USBD_GINTEN_EPCIE_Msk (0x1ul << USBD_GINTEN_EPCIE_Pos) /*!< USBD_T::GINTEN: EPCIE Mask */ + +#define USBD_GINTEN_EPDIE_Pos (5) /*!< USBD_T::GINTEN: EPDIE Position */ +#define USBD_GINTEN_EPDIE_Msk (0x1ul << USBD_GINTEN_EPDIE_Pos) /*!< USBD_T::GINTEN: EPDIE Mask */ + +#define USBD_GINTEN_EPEIE_Pos (6) /*!< USBD_T::GINTEN: EPEIE Position */ +#define USBD_GINTEN_EPEIE_Msk (0x1ul << USBD_GINTEN_EPEIE_Pos) /*!< USBD_T::GINTEN: EPEIE Mask */ + +#define USBD_GINTEN_EPFIE_Pos (7) /*!< USBD_T::GINTEN: EPFIE Position */ +#define USBD_GINTEN_EPFIE_Msk (0x1ul << USBD_GINTEN_EPFIE_Pos) /*!< USBD_T::GINTEN: EPFIE Mask */ + +#define USBD_GINTEN_EPGIE_Pos (8) /*!< USBD_T::GINTEN: EPGIE Position */ +#define USBD_GINTEN_EPGIE_Msk (0x1ul << USBD_GINTEN_EPGIE_Pos) /*!< USBD_T::GINTEN: EPGIE Mask */ + +#define USBD_GINTEN_EPHIE_Pos (9) /*!< USBD_T::GINTEN: EPHIE Position */ +#define USBD_GINTEN_EPHIE_Msk (0x1ul << USBD_GINTEN_EPHIE_Pos) /*!< USBD_T::GINTEN: EPHIE Mask */ + +#define USBD_GINTEN_EPIIE_Pos (10) /*!< USBD_T::GINTEN: EPIIE Position */ +#define USBD_GINTEN_EPIIE_Msk (0x1ul << USBD_GINTEN_EPIIE_Pos) /*!< USBD_T::GINTEN: EPIIE Mask */ + +#define USBD_GINTEN_EPJIE_Pos (11) /*!< USBD_T::GINTEN: EPJIE Position */ +#define USBD_GINTEN_EPJIE_Msk (0x1ul << USBD_GINTEN_EPJIE_Pos) /*!< USBD_T::GINTEN: EPJIE Mask */ + +#define USBD_GINTEN_EPKIE_Pos (12) /*!< USBD_T::GINTEN: EPKIE Position */ +#define USBD_GINTEN_EPKIE_Msk (0x1ul << USBD_GINTEN_EPKIE_Pos) /*!< USBD_T::GINTEN: EPKIE Mask */ + +#define USBD_GINTEN_EPLIE_Pos (13) /*!< USBD_T::GINTEN: EPLIE Position */ +#define USBD_GINTEN_EPLIE_Msk (0x1ul << USBD_GINTEN_EPLIE_Pos) /*!< USBD_T::GINTEN: EPLIE Mask */ + +#define USBD_BUSINTSTS_SOFIF_Pos (0) /*!< USBD_T::BUSINTSTS: SOFIF Position */ +#define USBD_BUSINTSTS_SOFIF_Msk (0x1ul << USBD_BUSINTSTS_SOFIF_Pos) /*!< USBD_T::BUSINTSTS: SOFIF Mask */ + +#define USBD_BUSINTSTS_RSTIF_Pos (1) /*!< USBD_T::BUSINTSTS: RSTIF Position */ +#define USBD_BUSINTSTS_RSTIF_Msk (0x1ul << USBD_BUSINTSTS_RSTIF_Pos) /*!< USBD_T::BUSINTSTS: RSTIF Mask */ + +#define USBD_BUSINTSTS_RESUMEIF_Pos (2) /*!< USBD_T::BUSINTSTS: RESUMEIF Position */ +#define USBD_BUSINTSTS_RESUMEIF_Msk (0x1ul << USBD_BUSINTSTS_RESUMEIF_Pos) /*!< USBD_T::BUSINTSTS: RESUMEIF Mask */ + +#define USBD_BUSINTSTS_SUSPENDIF_Pos (3) /*!< USBD_T::BUSINTSTS: SUSPENDIF Position */ +#define USBD_BUSINTSTS_SUSPENDIF_Msk (0x1ul << USBD_BUSINTSTS_SUSPENDIF_Pos) /*!< USBD_T::BUSINTSTS: SUSPENDIF Mask */ + +#define USBD_BUSINTSTS_HISPDIF_Pos (4) /*!< USBD_T::BUSINTSTS: HISPDIF Position */ +#define USBD_BUSINTSTS_HISPDIF_Msk (0x1ul << USBD_BUSINTSTS_HISPDIF_Pos) /*!< USBD_T::BUSINTSTS: HISPDIF Mask */ + +#define USBD_BUSINTSTS_DMADONEIF_Pos (5) /*!< USBD_T::BUSINTSTS: DMADONEIF Position */ +#define USBD_BUSINTSTS_DMADONEIF_Msk (0x1ul << USBD_BUSINTSTS_DMADONEIF_Pos) /*!< USBD_T::BUSINTSTS: DMADONEIF Mask */ + +#define USBD_BUSINTSTS_PHYCLKVLDIF_Pos (6) /*!< USBD_T::BUSINTSTS: PHYCLKVLDIF Position */ +#define USBD_BUSINTSTS_PHYCLKVLDIF_Msk (0x1ul << USBD_BUSINTSTS_PHYCLKVLDIF_Pos) /*!< USBD_T::BUSINTSTS: PHYCLKVLDIF Mask */ + +#define USBD_BUSINTSTS_VBUSDETIF_Pos (8) /*!< USBD_T::BUSINTSTS: VBUSDETIF Position */ +#define USBD_BUSINTSTS_VBUSDETIF_Msk (0x1ul << USBD_BUSINTSTS_VBUSDETIF_Pos) /*!< USBD_T::BUSINTSTS: VBUSDETIF Mask */ + +#define USBD_BUSINTEN_SOFIEN_Pos (0) /*!< USBD_T::BUSINTEN: SOFIEN Position */ +#define USBD_BUSINTEN_SOFIEN_Msk (0x1ul << USBD_BUSINTEN_SOFIEN_Pos) /*!< USBD_T::BUSINTEN: SOFIEN Mask */ + +#define USBD_BUSINTEN_RSTIEN_Pos (1) /*!< USBD_T::BUSINTEN: RSTIEN Position */ +#define USBD_BUSINTEN_RSTIEN_Msk (0x1ul << USBD_BUSINTEN_RSTIEN_Pos) /*!< USBD_T::BUSINTEN: RSTIEN Mask */ + +#define USBD_BUSINTEN_RESUMEIEN_Pos (2) /*!< USBD_T::BUSINTEN: RESUMEIEN Position */ +#define USBD_BUSINTEN_RESUMEIEN_Msk (0x1ul << USBD_BUSINTEN_RESUMEIEN_Pos) /*!< USBD_T::BUSINTEN: RESUMEIEN Mask */ + +#define USBD_BUSINTEN_SUSPENDIEN_Pos (3) /*!< USBD_T::BUSINTEN: SUSPENDIEN Position */ +#define USBD_BUSINTEN_SUSPENDIEN_Msk (0x1ul << USBD_BUSINTEN_SUSPENDIEN_Pos) /*!< USBD_T::BUSINTEN: SUSPENDIEN Mask */ + +#define USBD_BUSINTEN_HISPDIEN_Pos (4) /*!< USBD_T::BUSINTEN: HISPDIEN Position */ +#define USBD_BUSINTEN_HISPDIEN_Msk (0x1ul << USBD_BUSINTEN_HISPDIEN_Pos) /*!< USBD_T::BUSINTEN: HISPDIEN Mask */ + +#define USBD_BUSINTEN_DMADONEIEN_Pos (5) /*!< USBD_T::BUSINTEN: DMADONEIEN Position */ +#define USBD_BUSINTEN_DMADONEIEN_Msk (0x1ul << USBD_BUSINTEN_DMADONEIEN_Pos) /*!< USBD_T::BUSINTEN: DMADONEIEN Mask */ + +#define USBD_BUSINTEN_PHYCLKVLDIEN_Pos (6) /*!< USBD_T::BUSINTEN: PHYCLKVLDIEN Position */ +#define USBD_BUSINTEN_PHYCLKVLDIEN_Msk (0x1ul << USBD_BUSINTEN_PHYCLKVLDIEN_Pos) /*!< USBD_T::BUSINTEN: PHYCLKVLDIEN Mask */ + +#define USBD_BUSINTEN_VBUSDETIEN_Pos (8) /*!< USBD_T::BUSINTEN: VBUSDETIEN Position */ +#define USBD_BUSINTEN_VBUSDETIEN_Msk (0x1ul << USBD_BUSINTEN_VBUSDETIEN_Pos) /*!< USBD_T::BUSINTEN: VBUSDETIEN Mask */ + +#define USBD_OPER_RESUMEEN_Pos (0) /*!< USBD_T::OPER: RESUMEEN Position */ +#define USBD_OPER_RESUMEEN_Msk (0x1ul << USBD_OPER_RESUMEEN_Pos) /*!< USBD_T::OPER: RESUMEEN Mask */ + +#define USBD_OPER_HISPDEN_Pos (1) /*!< USBD_T::OPER: HISPDEN Position */ +#define USBD_OPER_HISPDEN_Msk (0x1ul << USBD_OPER_HISPDEN_Pos) /*!< USBD_T::OPER: HISPDEN Mask */ + +#define USBD_OPER_CURSPD_Pos (2) /*!< USBD_T::OPER: CURSPD Position */ +#define USBD_OPER_CURSPD_Msk (0x1ul << USBD_OPER_CURSPD_Pos) /*!< USBD_T::OPER: CURSPD Mask */ + +#define USBD_FRAMECNT_MFRAMECNT_Pos (0) /*!< USBD_T::FRAMECNT: MFRAMECNT Position */ +#define USBD_FRAMECNT_MFRAMECNT_Msk (0x7ul << USBD_FRAMECNT_MFRAMECNT_Pos) /*!< USBD_T::FRAMECNT: MFRAMECNT Mask */ + +#define USBD_FRAMECNT_FRAMECNT_Pos (3) /*!< USBD_T::FRAMECNT: FRAMECNT Position */ +#define USBD_FRAMECNT_FRAMECNT_Msk (0x7fful << USBD_FRAMECNT_FRAMECNT_Pos) /*!< USBD_T::FRAMECNT: FRAMECNT Mask */ + +#define USBD_FADDR_FADDR_Pos (0) /*!< USBD_T::FADDR: FADDR Position */ +#define USBD_FADDR_FADDR_Msk (0x7ful << USBD_FADDR_FADDR_Pos) /*!< USBD_T::FADDR: FADDR Mask */ + +#define USBD_TEST_TESTMODE_Pos (0) /*!< USBD_T::TEST: TESTMODE Position */ +#define USBD_TEST_TESTMODE_Msk (0x7ul << USBD_TEST_TESTMODE_Pos) /*!< USBD_T::TEST: TESTMODE Mask */ + +#define USBD_CEPDAT_DAT_Pos (0) /*!< USBD_T::CEPDAT: DAT Position */ +#define USBD_CEPDAT_DAT_Msk (0xfffffffful << USBD_CEPDAT_DAT_Pos) /*!< USBD_T::CEPDAT: DAT Mask */ + +#define USBD_CEPCTL_NAKCLR_Pos (0) /*!< USBD_T::CEPCTL: NAKCLR Position */ +#define USBD_CEPCTL_NAKCLR_Msk (0x1ul << USBD_CEPCTL_NAKCLR_Pos) /*!< USBD_T::CEPCTL: NAKCLR Mask */ + +#define USBD_CEPCTL_STALLEN_Pos (1) /*!< USBD_T::CEPCTL: STALLEN Position */ +#define USBD_CEPCTL_STALLEN_Msk (0x1ul << USBD_CEPCTL_STALLEN_Pos) /*!< USBD_T::CEPCTL: STALLEN Mask */ + +#define USBD_CEPCTL_ZEROLEN_Pos (2) /*!< USBD_T::CEPCTL: ZEROLEN Position */ +#define USBD_CEPCTL_ZEROLEN_Msk (0x1ul << USBD_CEPCTL_ZEROLEN_Pos) /*!< USBD_T::CEPCTL: ZEROLEN Mask */ + +#define USBD_CEPCTL_FLUSH_Pos (3) /*!< USBD_T::CEPCTL: FLUSH Position */ +#define USBD_CEPCTL_FLUSH_Msk (0x1ul << USBD_CEPCTL_FLUSH_Pos) /*!< USBD_T::CEPCTL: FLUSH Mask */ + +#define USBD_CEPINTEN_SETUPTKIEN_Pos (0) /*!< USBD_T::CEPINTEN: SETUPTKIEN Position */ +#define USBD_CEPINTEN_SETUPTKIEN_Msk (0x1ul << USBD_CEPINTEN_SETUPTKIEN_Pos) /*!< USBD_T::CEPINTEN: SETUPTKIEN Mask */ + +#define USBD_CEPINTEN_SETUPPKIEN_Pos (1) /*!< USBD_T::CEPINTEN: SETUPPKIEN Position */ +#define USBD_CEPINTEN_SETUPPKIEN_Msk (0x1ul << USBD_CEPINTEN_SETUPPKIEN_Pos) /*!< USBD_T::CEPINTEN: SETUPPKIEN Mask */ + +#define USBD_CEPINTEN_OUTTKIEN_Pos (2) /*!< USBD_T::CEPINTEN: OUTTKIEN Position */ +#define USBD_CEPINTEN_OUTTKIEN_Msk (0x1ul << USBD_CEPINTEN_OUTTKIEN_Pos) /*!< USBD_T::CEPINTEN: OUTTKIEN Mask */ + +#define USBD_CEPINTEN_INTKIEN_Pos (3) /*!< USBD_T::CEPINTEN: INTKIEN Position */ +#define USBD_CEPINTEN_INTKIEN_Msk (0x1ul << USBD_CEPINTEN_INTKIEN_Pos) /*!< USBD_T::CEPINTEN: INTKIEN Mask */ + +#define USBD_CEPINTEN_PINGIEN_Pos (4) /*!< USBD_T::CEPINTEN: PINGIEN Position */ +#define USBD_CEPINTEN_PINGIEN_Msk (0x1ul << USBD_CEPINTEN_PINGIEN_Pos) /*!< USBD_T::CEPINTEN: PINGIEN Mask */ + +#define USBD_CEPINTEN_TXPKIEN_Pos (5) /*!< USBD_T::CEPINTEN: TXPKIEN Position */ +#define USBD_CEPINTEN_TXPKIEN_Msk (0x1ul << USBD_CEPINTEN_TXPKIEN_Pos) /*!< USBD_T::CEPINTEN: TXPKIEN Mask */ + +#define USBD_CEPINTEN_RXPKIEN_Pos (6) /*!< USBD_T::CEPINTEN: RXPKIEN Position */ +#define USBD_CEPINTEN_RXPKIEN_Msk (0x1ul << USBD_CEPINTEN_RXPKIEN_Pos) /*!< USBD_T::CEPINTEN: RXPKIEN Mask */ + +#define USBD_CEPINTEN_NAKIEN_Pos (7) /*!< USBD_T::CEPINTEN: NAKIEN Position */ +#define USBD_CEPINTEN_NAKIEN_Msk (0x1ul << USBD_CEPINTEN_NAKIEN_Pos) /*!< USBD_T::CEPINTEN: NAKIEN Mask */ + +#define USBD_CEPINTEN_STALLIEN_Pos (8) /*!< USBD_T::CEPINTEN: STALLIEN Position */ +#define USBD_CEPINTEN_STALLIEN_Msk (0x1ul << USBD_CEPINTEN_STALLIEN_Pos) /*!< USBD_T::CEPINTEN: STALLIEN Mask */ + +#define USBD_CEPINTEN_ERRIEN_Pos (9) /*!< USBD_T::CEPINTEN: ERRIEN Position */ +#define USBD_CEPINTEN_ERRIEN_Msk (0x1ul << USBD_CEPINTEN_ERRIEN_Pos) /*!< USBD_T::CEPINTEN: ERRIEN Mask */ + +#define USBD_CEPINTEN_STSDONEIEN_Pos (10) /*!< USBD_T::CEPINTEN: STSDONEIEN Position */ +#define USBD_CEPINTEN_STSDONEIEN_Msk (0x1ul << USBD_CEPINTEN_STSDONEIEN_Pos) /*!< USBD_T::CEPINTEN: STSDONEIEN Mask */ + +#define USBD_CEPINTEN_BUFFULLIEN_Pos (11) /*!< USBD_T::CEPINTEN: BUFFULLIEN Position */ +#define USBD_CEPINTEN_BUFFULLIEN_Msk (0x1ul << USBD_CEPINTEN_BUFFULLIEN_Pos) /*!< USBD_T::CEPINTEN: BUFFULLIEN Mask */ + +#define USBD_CEPINTEN_BUFEMPTYIEN_Pos (12) /*!< USBD_T::CEPINTEN: BUFEMPTYIEN Position */ +#define USBD_CEPINTEN_BUFEMPTYIEN_Msk (0x1ul << USBD_CEPINTEN_BUFEMPTYIEN_Pos) /*!< USBD_T::CEPINTEN: BUFEMPTYIEN Mask */ + +#define USBD_CEPINTSTS_SETUPTKIF_Pos (0) /*!< USBD_T::CEPINTSTS: SETUPTKIF Position */ +#define USBD_CEPINTSTS_SETUPTKIF_Msk (0x1ul << USBD_CEPINTSTS_SETUPTKIF_Pos) /*!< USBD_T::CEPINTSTS: SETUPTKIF Mask */ + +#define USBD_CEPINTSTS_SETUPPKIF_Pos (1) /*!< USBD_T::CEPINTSTS: SETUPPKIF Position */ +#define USBD_CEPINTSTS_SETUPPKIF_Msk (0x1ul << USBD_CEPINTSTS_SETUPPKIF_Pos) /*!< USBD_T::CEPINTSTS: SETUPPKIF Mask */ + +#define USBD_CEPINTSTS_OUTTKIF_Pos (2) /*!< USBD_T::CEPINTSTS: OUTTKIF Position */ +#define USBD_CEPINTSTS_OUTTKIF_Msk (0x1ul << USBD_CEPINTSTS_OUTTKIF_Pos) /*!< USBD_T::CEPINTSTS: OUTTKIF Mask */ + +#define USBD_CEPINTSTS_INTKIF_Pos (3) /*!< USBD_T::CEPINTSTS: INTKIF Position */ +#define USBD_CEPINTSTS_INTKIF_Msk (0x1ul << USBD_CEPINTSTS_INTKIF_Pos) /*!< USBD_T::CEPINTSTS: INTKIF Mask */ + +#define USBD_CEPINTSTS_PINGIF_Pos (4) /*!< USBD_T::CEPINTSTS: PINGIF Position */ +#define USBD_CEPINTSTS_PINGIF_Msk (0x1ul << USBD_CEPINTSTS_PINGIF_Pos) /*!< USBD_T::CEPINTSTS: PINGIF Mask */ + +#define USBD_CEPINTSTS_TXPKIF_Pos (5) /*!< USBD_T::CEPINTSTS: TXPKIF Position */ +#define USBD_CEPINTSTS_TXPKIF_Msk (0x1ul << USBD_CEPINTSTS_TXPKIF_Pos) /*!< USBD_T::CEPINTSTS: TXPKIF Mask */ + +#define USBD_CEPINTSTS_RXPKIF_Pos (6) /*!< USBD_T::CEPINTSTS: RXPKIF Position */ +#define USBD_CEPINTSTS_RXPKIF_Msk (0x1ul << USBD_CEPINTSTS_RXPKIF_Pos) /*!< USBD_T::CEPINTSTS: RXPKIF Mask */ + +#define USBD_CEPINTSTS_NAKIF_Pos (7) /*!< USBD_T::CEPINTSTS: NAKIF Position */ +#define USBD_CEPINTSTS_NAKIF_Msk (0x1ul << USBD_CEPINTSTS_NAKIF_Pos) /*!< USBD_T::CEPINTSTS: NAKIF Mask */ + +#define USBD_CEPINTSTS_STALLIF_Pos (8) /*!< USBD_T::CEPINTSTS: STALLIF Position */ +#define USBD_CEPINTSTS_STALLIF_Msk (0x1ul << USBD_CEPINTSTS_STALLIF_Pos) /*!< USBD_T::CEPINTSTS: STALLIF Mask */ + +#define USBD_CEPINTSTS_ERRIF_Pos (9) /*!< USBD_T::CEPINTSTS: ERRIF Position */ +#define USBD_CEPINTSTS_ERRIF_Msk (0x1ul << USBD_CEPINTSTS_ERRIF_Pos) /*!< USBD_T::CEPINTSTS: ERRIF Mask */ + +#define USBD_CEPINTSTS_STSDONEIF_Pos (10) /*!< USBD_T::CEPINTSTS: STSDONEIF Position */ +#define USBD_CEPINTSTS_STSDONEIF_Msk (0x1ul << USBD_CEPINTSTS_STSDONEIF_Pos) /*!< USBD_T::CEPINTSTS: STSDONEIF Mask */ + +#define USBD_CEPINTSTS_BUFFULLIF_Pos (11) /*!< USBD_T::CEPINTSTS: BUFFULLIF Position */ +#define USBD_CEPINTSTS_BUFFULLIF_Msk (0x1ul << USBD_CEPINTSTS_BUFFULLIF_Pos) /*!< USBD_T::CEPINTSTS: BUFFULLIF Mask */ + +#define USBD_CEPINTSTS_BUFEMPTYIF_Pos (12) /*!< USBD_T::CEPINTSTS: BUFEMPTYIF Position */ +#define USBD_CEPINTSTS_BUFEMPTYIF_Msk (0x1ul << USBD_CEPINTSTS_BUFEMPTYIF_Pos) /*!< USBD_T::CEPINTSTS: BUFEMPTYIF Mask */ + +#define USBD_CEPTXCNT_TXCNT_Pos (0) /*!< USBD_T::CEPTXCNT: TXCNT Position */ +#define USBD_CEPTXCNT_TXCNT_Msk (0xfful << USBD_CEPTXCNT_TXCNT_Pos) /*!< USBD_T::CEPTXCNT: TXCNT Mask */ + +#define USBD_CEPRXCNT_RXCNT_Pos (0) /*!< USBD_T::CEPRXCNT: RXCNT Position */ +#define USBD_CEPRXCNT_RXCNT_Msk (0xfful << USBD_CEPRXCNT_RXCNT_Pos) /*!< USBD_T::CEPRXCNT: RXCNT Mask */ + +#define USBD_CEPDATCNT_DATCNT_Pos (0) /*!< USBD_T::CEPDATCNT: DATCNT Position */ +#define USBD_CEPDATCNT_DATCNT_Msk (0xfffful << USBD_CEPDATCNT_DATCNT_Pos) /*!< USBD_T::CEPDATCNT: DATCNT Mask */ + +#define USBD_SETUP1_0_SETUP0_Pos (0) /*!< USBD_T::SETUP1_0: SETUP0 Position */ +#define USBD_SETUP1_0_SETUP0_Msk (0xfful << USBD_SETUP1_0_SETUP0_Pos) /*!< USBD_T::SETUP1_0: SETUP0 Mask */ + +#define USBD_SETUP1_0_SETUP1_Pos (8) /*!< USBD_T::SETUP1_0: SETUP1 Position */ +#define USBD_SETUP1_0_SETUP1_Msk (0xfful << USBD_SETUP1_0_SETUP1_Pos) /*!< USBD_T::SETUP1_0: SETUP1 Mask */ + +#define USBD_SETUP3_2_SETUP2_Pos (0) /*!< USBD_T::SETUP3_2: SETUP2 Position */ +#define USBD_SETUP3_2_SETUP2_Msk (0xfful << USBD_SETUP3_2_SETUP2_Pos) /*!< USBD_T::SETUP3_2: SETUP2 Mask */ + +#define USBD_SETUP3_2_SETUP3_Pos (8) /*!< USBD_T::SETUP3_2: SETUP3 Position */ +#define USBD_SETUP3_2_SETUP3_Msk (0xfful << USBD_SETUP3_2_SETUP3_Pos) /*!< USBD_T::SETUP3_2: SETUP3 Mask */ + +#define USBD_SETUP5_4_SETUP4_Pos (0) /*!< USBD_T::SETUP5_4: SETUP4 Position */ +#define USBD_SETUP5_4_SETUP4_Msk (0xfful << USBD_SETUP5_4_SETUP4_Pos) /*!< USBD_T::SETUP5_4: SETUP4 Mask */ + +#define USBD_SETUP5_4_SETUP5_Pos (8) /*!< USBD_T::SETUP5_4: SETUP5 Position */ +#define USBD_SETUP5_4_SETUP5_Msk (0xfful << USBD_SETUP5_4_SETUP5_Pos) /*!< USBD_T::SETUP5_4: SETUP5 Mask */ + +#define USBD_SETUP7_6_SETUP6_Pos (0) /*!< USBD_T::SETUP7_6: SETUP6 Position */ +#define USBD_SETUP7_6_SETUP6_Msk (0xfful << USBD_SETUP7_6_SETUP6_Pos) /*!< USBD_T::SETUP7_6: SETUP6 Mask */ + +#define USBD_SETUP7_6_SETUP7_Pos (8) /*!< USBD_T::SETUP7_6: SETUP7 Position */ +#define USBD_SETUP7_6_SETUP7_Msk (0xfful << USBD_SETUP7_6_SETUP7_Pos) /*!< USBD_T::SETUP7_6: SETUP7 Mask */ + +#define USBD_CEPBUFSTART_SADDR_Pos (0) /*!< USBD_T::CEPBUFSTART: SADDR Position */ +#define USBD_CEPBUFSTART_SADDR_Msk (0xffful << USBD_CEPBUFSTART_SADDR_Pos) /*!< USBD_T::CEPBUFSTART: SADDR Mask */ + +#define USBD_CEPBUFEND_EADDR_Pos (0) /*!< USBD_T::CEPBUFEND: EADDR Position */ +#define USBD_CEPBUFEND_EADDR_Msk (0xffful << USBD_CEPBUFEND_EADDR_Pos) /*!< USBD_T::CEPBUFEND: EADDR Mask */ + +#define USBD_DMACTL_EPNUM_Pos (0) /*!< USBD_T::DMACTL: EPNUM Position */ +#define USBD_DMACTL_EPNUM_Msk (0xful << USBD_DMACTL_EPNUM_Pos) /*!< USBD_T::DMACTL: EPNUM Mask */ + +#define USBD_DMACTL_DMARD_Pos (4) /*!< USBD_T::DMACTL: DMARD Position */ +#define USBD_DMACTL_DMARD_Msk (0x1ul << USBD_DMACTL_DMARD_Pos) /*!< USBD_T::DMACTL: DMARD Mask */ + +#define USBD_DMACTL_DMAEN_Pos (5) /*!< USBD_T::DMACTL: DMAEN Position */ +#define USBD_DMACTL_DMAEN_Msk (0x1ul << USBD_DMACTL_DMAEN_Pos) /*!< USBD_T::DMACTL: DMAEN Mask */ + +#define USBD_DMACTL_SGEN_Pos (6) /*!< USBD_T::DMACTL: SGEN Position */ +#define USBD_DMACTL_SGEN_Msk (0x1ul << USBD_DMACTL_SGEN_Pos) /*!< USBD_T::DMACTL: SGEN Mask */ + +#define USBD_DMACTL_DMARST_Pos (7) /*!< USBD_T::DMACTL: DMARST Position */ +#define USBD_DMACTL_DMARST_Msk (0x1ul << USBD_DMACTL_DMARST_Pos) /*!< USBD_T::DMACTL: DMARST Mask */ + +#define USBD_DMACNT_DMACNT_Pos (0) /*!< USBD_T::DMACNT: DMACNT Position */ +#define USBD_DMACNT_DMACNT_Msk (0xffffful << USBD_DMACNT_DMACNT_Pos) /*!< USBD_T::DMACNT: DMACNT Mask */ + +#define USBD_EPDAT_EPDAT_Pos (0) /*!< USBD_EP_T::EPDAT: EPDAT Position */ +#define USBD_EPDAT_EPDAT_Msk (0xfffffffful << USBD_EPDAT_EPDAT_Pos) /*!< USBD_EP_T::EPDAT: EPDAT Mask */ + +#define USBD_EPINTSTS_BUFFULLIF_Pos (0) /*!< USBD_EP_T::EPINTSTS: BUFFULLIF Position */ +#define USBD_EPINTSTS_BUFFULLIF_Msk (0x1ul << USBD_EPINTSTS_BUFFULLIF_Pos) /*!< USBD_EP_T::EPINTSTS: BUFFULLIF Mask */ + +#define USBD_EPINTSTS_BUFEMPTYIF_Pos (1) /*!< USBD_EP_T::EPINTSTS: BUFEMPTYIF Position */ +#define USBD_EPINTSTS_BUFEMPTYIF_Msk (0x1ul << USBD_EPINTSTS_BUFEMPTYIF_Pos) /*!< USBD_EP_T::EPINTSTS: BUFEMPTYIF Mask */ + +#define USBD_EPINTSTS_SHORTTXIF_Pos (2) /*!< USBD_EP_T::EPINTSTS: SHORTTXIF Position */ +#define USBD_EPINTSTS_SHORTTXIF_Msk (0x1ul << USBD_EPINTSTS_SHORTTXIF_Pos) /*!< USBD_EP_T::EPINTSTS: SHORTTXIF Mask */ + +#define USBD_EPINTSTS_TXPKIF_Pos (3) /*!< USBD_EP_T::EPINTSTS: TXPKIF Position */ +#define USBD_EPINTSTS_TXPKIF_Msk (0x1ul << USBD_EPINTSTS_TXPKIF_Pos) /*!< USBD_EP_T::EPINTSTS: TXPKIF Mask */ + +#define USBD_EPINTSTS_RXPKIF_Pos (4) /*!< USBD_EP_T::EPINTSTS: RXPKIF Position */ +#define USBD_EPINTSTS_RXPKIF_Msk (0x1ul << USBD_EPINTSTS_RXPKIF_Pos) /*!< USBD_EP_T::EPINTSTS: RXPKIF Mask */ + +#define USBD_EPINTSTS_OUTTKIF_Pos (5) /*!< USBD_EP_T::EPINTSTS: OUTTKIF Position */ +#define USBD_EPINTSTS_OUTTKIF_Msk (0x1ul << USBD_EPINTSTS_OUTTKIF_Pos) /*!< USBD_EP_T::EPINTSTS: OUTTKIF Mask */ + +#define USBD_EPINTSTS_INTKIF_Pos (6) /*!< USBD_EP_T::EPINTSTS: INTKIF Position */ +#define USBD_EPINTSTS_INTKIF_Msk (0x1ul << USBD_EPINTSTS_INTKIF_Pos) /*!< USBD_EP_T::EPINTSTS: INTKIF Mask */ + +#define USBD_EPINTSTS_PINGIF_Pos (7) /*!< USBD_EP_T::EPINTSTS: PINGIF Position */ +#define USBD_EPINTSTS_PINGIF_Msk (0x1ul << USBD_EPINTSTS_PINGIF_Pos) /*!< USBD_EP_T::EPINTSTS: PINGIF Mask */ + +#define USBD_EPINTSTS_NAKIF_Pos (8) /*!< USBD_EP_T::EPINTSTS: NAKIF Position */ +#define USBD_EPINTSTS_NAKIF_Msk (0x1ul << USBD_EPINTSTS_NAKIF_Pos) /*!< USBD_EP_T::EPINTSTS: NAKIF Mask */ + +#define USBD_EPINTSTS_STALLIF_Pos (9) /*!< USBD_EP_T::EPINTSTS: STALLIF Position */ +#define USBD_EPINTSTS_STALLIF_Msk (0x1ul << USBD_EPINTSTS_STALLIF_Pos) /*!< USBD_EP_T::EPINTSTS: STALLIF Mask */ + +#define USBD_EPINTSTS_NYETIF_Pos (10) /*!< USBD_EP_T::EPINTSTS: NYETIF Position */ +#define USBD_EPINTSTS_NYETIF_Msk (0x1ul << USBD_EPINTSTS_NYETIF_Pos) /*!< USBD_EP_T::EPINTSTS: NYETIF Mask */ + +#define USBD_EPINTSTS_ERRIF_Pos (11) /*!< USBD_EP_T::EPINTSTS: ERRIF Position */ +#define USBD_EPINTSTS_ERRIF_Msk (0x1ul << USBD_EPINTSTS_ERRIF_Pos) /*!< USBD_EP_T::EPINTSTS: ERRIF Mask */ + +#define USBD_EPINTSTS_SHORTRXIF_Pos (12) /*!< USBD_EP_T::EPINTSTS: SHORTRXIF Position */ +#define USBD_EPINTSTS_SHORTRXIF_Msk (0x1ul << USBD_EPINTSTS_SHORTRXIF_Pos) /*!< USBD_EP_T::EPINTSTS: SHORTRXIF Mask */ + +#define USBD_EPINTEN_BUFFULLIEN_Pos (0) /*!< USBD_EP_T::EPINTEN: BUFFULLIEN Position */ +#define USBD_EPINTEN_BUFFULLIEN_Msk (0x1ul << USBD_EPINTEN_BUFFULLIEN_Pos) /*!< USBD_EP_T::EPINTEN: BUFFULLIEN Mask */ + +#define USBD_EPINTEN_BUFEMPTYIEN_Pos (1) /*!< USBD_EP_T::EPINTEN: BUFEMPTYIEN Position */ +#define USBD_EPINTEN_BUFEMPTYIEN_Msk (0x1ul << USBD_EPINTEN_BUFEMPTYIEN_Pos) /*!< USBD_EP_T::EPINTEN: BUFEMPTYIEN Mask */ + +#define USBD_EPINTEN_SHORTTXIEN_Pos (2) /*!< USBD_EP_T::EPINTEN: SHORTTXIEN Position */ +#define USBD_EPINTEN_SHORTTXIEN_Msk (0x1ul << USBD_EPINTEN_SHORTTXIEN_Pos) /*!< USBD_EP_T::EPINTEN: SHORTTXIEN Mask */ + +#define USBD_EPINTEN_TXPKIEN_Pos (3) /*!< USBD_EP_T::EPINTEN: TXPKIEN Position */ +#define USBD_EPINTEN_TXPKIEN_Msk (0x1ul << USBD_EPINTEN_TXPKIEN_Pos) /*!< USBD_EP_T::EPINTEN: TXPKIEN Mask */ + +#define USBD_EPINTEN_RXPKIEN_Pos (4) /*!< USBD_EP_T::EPINTEN: RXPKIEN Position */ +#define USBD_EPINTEN_RXPKIEN_Msk (0x1ul << USBD_EPINTEN_RXPKIEN_Pos) /*!< USBD_EP_T::EPINTEN: RXPKIEN Mask */ + +#define USBD_EPINTEN_OUTTKIEN_Pos (5) /*!< USBD_EP_T::EPINTEN: OUTTKIEN Position */ +#define USBD_EPINTEN_OUTTKIEN_Msk (0x1ul << USBD_EPINTEN_OUTTKIEN_Pos) /*!< USBD_EP_T::EPINTEN: OUTTKIEN Mask */ + +#define USBD_EPINTEN_INTKIEN_Pos (6) /*!< USBD_EP_T::EPINTEN: INTKIEN Position */ +#define USBD_EPINTEN_INTKIEN_Msk (0x1ul << USBD_EPINTEN_INTKIEN_Pos) /*!< USBD_EP_T::EPINTEN: INTKIEN Mask */ + +#define USBD_EPINTEN_PINGIEN_Pos (7) /*!< USBD_EP_T::EPINTEN: PINGIEN Position */ +#define USBD_EPINTEN_PINGIEN_Msk (0x1ul << USBD_EPINTEN_PINGIEN_Pos) /*!< USBD_EP_T::EPINTEN: PINGIEN Mask */ + +#define USBD_EPINTEN_NAKIEN_Pos (8) /*!< USBD_EP_T::EPINTEN: NAKIEN Position */ +#define USBD_EPINTEN_NAKIEN_Msk (0x1ul << USBD_EPINTEN_NAKIEN_Pos) /*!< USBD_EP_T::EPINTEN: NAKIEN Mask */ + +#define USBD_EPINTEN_STALLIEN_Pos (9) /*!< USBD_EP_T::EPINTEN: STALLIEN Position */ +#define USBD_EPINTEN_STALLIEN_Msk (0x1ul << USBD_EPINTEN_STALLIEN_Pos) /*!< USBD_EP_T::EPINTEN: STALLIEN Mask */ + +#define USBD_EPINTEN_NYETIEN_Pos (10) /*!< USBD_EP_T::EPINTEN: NYETIEN Position */ +#define USBD_EPINTEN_NYETIEN_Msk (0x1ul << USBD_EPINTEN_NYETIEN_Pos) /*!< USBD_EP_T::EPINTEN: NYETIEN Mask */ + +#define USBD_EPINTEN_ERRIEN_Pos (11) /*!< USBD_EP_T::EPINTEN: ERRIEN Position */ +#define USBD_EPINTEN_ERRIEN_Msk (0x1ul << USBD_EPINTEN_ERRIEN_Pos) /*!< USBD_EP_T::EPINTEN: ERRIEN Mask */ + +#define USBD_EPINTEN_SHORTRXIEN_Pos (12) /*!< USBD_EP_T::EPINTEN: SHORTRXIEN Position */ +#define USBD_EPINTEN_SHORTRXIEN_Msk (0x1ul << USBD_EPINTEN_SHORTRXIEN_Pos) /*!< USBD_EP_T::EPINTEN: SHORTRXIEN Mask */ + +#define USBD_EPDATCNT_DATCNT_Pos (0) /*!< USBD_EP_T::EPDATCNT: DATCNT Position */ +#define USBD_EPDATCNT_DATCNT_Msk (0xfffful << USBD_EPDATCNT_DATCNT_Pos) /*!< USBD_EP_T::EPDATCNT: DATCNT Mask */ + +#define USBD_EPDATCNT_DMALOOP_Pos (16) /*!< USBD_EP_T::EPDATCNT: DMALOOP Position */ +#define USBD_EPDATCNT_DMALOOP_Msk (0x7ffful << USBD_EPDATCNT_DMALOOP_Pos) /*!< USBD_EP_T::EPDATCNT: DMALOOP Mask */ + +#define USBD_EPRSPCTL_FLUSH_Pos (0) /*!< USBD_EP_T::EPRSPCTL: FLUSH Position */ +#define USBD_EPRSPCTL_FLUSH_Msk (0x1ul << USBD_EPRSPCTL_FLUSH_Pos) /*!< USBD_EP_T::EPRSPCTL: FLUSH Mask */ + +#define USBD_EPRSPCTL_MODE_Pos (1) /*!< USBD_EP_T::EPRSPCTL: MODE Position */ +#define USBD_EPRSPCTL_MODE_Msk (0x3ul << USBD_EPRSPCTL_MODE_Pos) /*!< USBD_EP_T::EPRSPCTL: MODE Mask */ + +#define USBD_EPRSPCTL_TOGGLE_Pos (3) /*!< USBD_EP_T::EPRSPCTL: TOGGLE Position */ +#define USBD_EPRSPCTL_TOGGLE_Msk (0x1ul << USBD_EPRSPCTL_TOGGLE_Pos) /*!< USBD_EP_T::EPRSPCTL: TOGGLE Mask */ + +#define USBD_EPRSPCTL_HALT_Pos (4) /*!< USBD_EP_T::EPRSPCTL: HALT Position */ +#define USBD_EPRSPCTL_HALT_Msk (0x1ul << USBD_EPRSPCTL_HALT_Pos) /*!< USBD_EP_T::EPRSPCTL: HALT Mask */ + +#define USBD_EPRSPCTL_ZEROLEN_Pos (5) /*!< USBD_EP_T::EPRSPCTL: ZEROLEN Position */ +#define USBD_EPRSPCTL_ZEROLEN_Msk (0x1ul << USBD_EPRSPCTL_ZEROLEN_Pos) /*!< USBD_EP_T::EPRSPCTL: ZEROLEN Mask */ + +#define USBD_EPRSPCTL_SHORTTXEN_Pos (6) /*!< USBD_EP_T::EPRSPCTL: SHORTTXEN Position */ +#define USBD_EPRSPCTL_SHORTTXEN_Msk (0x1ul << USBD_EPRSPCTL_SHORTTXEN_Pos) /*!< USBD_EP_T::EPRSPCTL: SHORTTXEN Mask */ + +#define USBD_EPRSPCTL_DISBUF_Pos (7) /*!< USBD_EP_T::EPRSPCTL: DISBUF Position */ +#define USBD_EPRSPCTL_DISBUF_Msk (0x1ul << USBD_EPRSPCTL_DISBUF_Pos) /*!< USBD_EP_T::EPRSPCTL: DISBUF Mask */ + +#define USBD_EPMPS_EPMPS_Pos (0) /*!< USBD_EP_T::EPMPS: EPMPS Position */ +#define USBD_EPMPS_EPMPS_Msk (0x7fful << USBD_EPMPS_EPMPS_Pos) /*!< USBD_EP_T::EPMPS: EPMPS Mask */ + +#define USBD_EPTXCNT_TXCNT_Pos (0) /*!< USBD_EP_T::EPTXCNT: TXCNT Position */ +#define USBD_EPTXCNT_TXCNT_Msk (0x7fful << USBD_EPTXCNT_TXCNT_Pos) /*!< USBD_EP_T::EPTXCNT: TXCNT Mask */ + +#define USBD_EPCFG_EPEN_Pos (0) /*!< USBD_EP_T::EPCFG: EPEN Position */ +#define USBD_EPCFG_EPEN_Msk (0x1ul << USBD_EPCFG_EPEN_Pos) /*!< USBD_EP_T::EPCFG: EPEN Mask */ + +#define USBD_EPCFG_EPTYPE_Pos (1) /*!< USBD_EP_T::EPCFG: EPTYPE Position */ +#define USBD_EPCFG_EPTYPE_Msk (0x3ul << USBD_EPCFG_EPTYPE_Pos) /*!< USBD_EP_T::EPCFG: EPTYPE Mask */ + +#define USBD_EPCFG_EPDIR_Pos (3) /*!< USBD_EP_T::EPCFG: EPDIR Position */ +#define USBD_EPCFG_EPDIR_Msk (0x1ul << USBD_EPCFG_EPDIR_Pos) /*!< USBD_EP_T::EPCFG: EPDIR Mask */ + +#define USBD_EPCFG_EPNUM_Pos (4) /*!< USBD_EP_T::EPCFG: EPNUM Position */ +#define USBD_EPCFG_EPNUM_Msk (0xful << USBD_EPCFG_EPNUM_Pos) /*!< USBD_EP_T::EPCFG: EPNUM Mask */ + +#define USBD_EPBUFSTART_SADDR_Pos (0) /*!< USBD_EP_T::EPBUFSTART: SADDR Position */ +#define USBD_EPBUFSTART_SADDR_Msk (0xffful << USBD_EPBUFSTART_SADDR_Pos) /*!< USBD_EP_T::EPBUFSTART: SADDR Mask */ + +#define USBD_EPBUFEND_EADDR_Pos (0) /*!< USBD_EP_T::EPBUFEND: EADDR Position */ +#define USBD_EPBUFEND_EADDR_Msk (0xffful << USBD_EPBUFEND_EADDR_Pos) /*!< USBD_EP_T::EPBUFEND: EADDR Mask */ + +#define USBD_DMAADDR_DMAADDR_Pos (0) /*!< USBD_T::DMAADDR: DMAADDR Position */ +#define USBD_DMAADDR_DMAADDR_Msk (0xfffffffful << USBD_DMAADDR_DMAADDR_Pos) /*!< USBD_T::DMAADDR: DMAADDR Mask */ + +#define USBD_PHYCTL_DPPUEN_Pos (8) /*!< USBD_T::PHYCTL: DPPUEN Position */ +#define USBD_PHYCTL_DPPUEN_Msk (0x1ul << USBD_PHYCTL_DPPUEN_Pos) /*!< USBD_T::PHYCTL: DPPUEN Mask */ + +#define USBD_PHYCTL_PHYEN_Pos (9) /*!< USBD_T::PHYCTL: PHYEN Position */ +#define USBD_PHYCTL_PHYEN_Msk (0x1ul << USBD_PHYCTL_PHYEN_Pos) /*!< USBD_T::PHYCTL: PHYEN Mask */ + +#define USBD_PHYCTL_WKEN_Pos (24) /*!< USBD_T::PHYCTL: WKEN Position */ +#define USBD_PHYCTL_WKEN_Msk (0x1ul << USBD_PHYCTL_WKEN_Pos) /*!< USBD_T::PHYCTL: WKEN Mask */ + +#define USBD_PHYCTL_VBUSDET_Pos (31) /*!< USBD_T::PHYCTL: VBUSDET Position */ +#define USBD_PHYCTL_VBUSDET_Msk (0x1ul << USBD_PHYCTL_VBUSDET_Pos) /*!< USBD_T::PHYCTL: VBUSDET Mask */ + +/**@}*/ /* USBD_CONST */ +/**@}*/ /* end of USBD register group */ + + +/*---------------------- Watch Dog Timer Controller -------------------------*/ +/** + @addtogroup WDT Watch Dog Timer Controller(WDT) + Memory Mapped Structure for WDT Controller +@{ */ + +typedef struct { + + + /** + * CTL + * =================================================================================================== + * Offset: 0x00 Watchdog Timer Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |RSTCNT |Clear Watchdog Timer (Write Protect) + * | | |0 = No effect. + * | | |1 = Reset the internal 18-bit WDT counter. + * | | |Note: This bit will be automatically cleared by hardware. + * |[1] |RSTEN |Watchdog Timer Reset Enable Control (Write Protect) + * | | |Setting this bit will enable the Watchdog Timer time-out reset function If the WDT counter value has not been cleared after the specific WDT reset delay period expires. + * | | |0 = Watchdog Timer time-out reset function Disabled. + * | | |1 = Watchdog Timer time-out reset function Enabled. + * |[2] |RSTF |Watchdog Timer Reset Flag + * | | |This bit indicates the system has been reset by WDT time-out reset or not. + * | | |0 = Watchdog Timer time-out reset did not occur. + * | | |1 = Watchdog Timer time-out reset occurred. + * | | |Note: This bit is cleared by writing 1 to this bit. + * |[3] |IF |Watchdog Timer Interrupt Flag + * | | |This bit will set to 1 while WDT counter value reaches the selected WDT time-out interval + * | | |0 = Watchdog Timer time-out interrupt did not occur. + * | | |1 = Watchdog Timer time-out interrupt occurred. + * | | |Note: This bit is cleared by writing 1 to this bit. + * |[4] |WKEN |Watchdog Timer Wake-Up Function Enable Control (Write Protect) + * | | |If this bit is set to 1, while WDT interrupt flag (WDT_CTL[3] IF) is generated to 1 and INTEN (WDT_CTL[6] WDT interrupt enable) is enabled, the WDT time-out interrupt signal will generate a wake-up trigger event to chip. + * | | |0 = Wake-up trigger event Disabled if WDT time-out interrupt signal generated. + * | | |1 = Wake-up trigger event Enabled if WDT time-out interrupt signal generated. + * | | |Note: Chip can be woken-up by WDT time-out interrupt signal generated only if WDT clock source is selected to 10 kHz oscillator. + * |[5] |WKF |Watchdog Timer Wake-Up Flag + * | | |This bit indicates the interrupt wake-up flag status of WDT + * | | |0 = Watchdog Timer does not cause chip wake-up. + * | | |1 = Chip wake-up from Idle or Power-down mode if WDT time-out interrupt signal generated. + * | | |Note: This bit is cleared by writing 1 to it. + * |[6] |INTEN |Watchdog Timer Interrupt Enable Control (Write Protect) + * | | |If this bit is enabled, the WDT time-out interrupt signal is generated and inform to CPU. + * | | |0 = Watchdog Timer interrupt Disabled. + * | | |1 = Watchdog Timer interrupt Enabled. + * |[7] |WDTEN |Watchdog Timer Enable Control (Write Protect) + * | | |0 = Watchdog Timer Disabled (This action will reset the internal counter). + * | | |1 = Watchdog Timer Enabled. + * | | |Note: If CWDTEN (Config0[31] watchdog enable) bit is set to 0, this bit is forced as 1 and software cannot change this bit to 0. + * |[8:10] |TOUTSEL |Watchdog Timer Time-Out Interval Selection (Write Protect) + * | | |These three bits select the time-out interval period for the Watchdog Timer. + * | | |000 = 2^4 * TWDT. + * | | |001 = 2^6 * TWDT. + * | | |010 = 2^8 * TWDT. + * | | |011 = 2^10 * TWDT. + * | | |100 = 2^12 * TWDT. + * | | |101 = 2^14 * TWDT. + * | | |110 = 2^16 * TWDT. + * | | |111 = 2^18 * TWDT. + * |[31] |ICEDEBUG |ICE Debug Mode Acknowledge Disable Control (Write Protect) + * | | |0 = ICE debug mode acknowledgement affects Watchdog Timer counting. + * | | |Watchdog Timer counter will be held while CPU is held by ICE. + * | | |1 = ICE debug mode acknowledgement Disabled. + * | | |Watchdog Timer counter will keep going no matter CPU is held by ICE or not. + */ + __IO uint32_t CTL; + + /** + * ALTCTL + * =================================================================================================== + * Offset: 0x04 Watchdog Timer Alternative Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:1] |RSTDSEL |Watchdog Timer Reset Delay Selection (Write Protect) + * | | |When WDT time-out happened, software has a time named WDT reset delay period to clear WDT counter to prevent WDT time-out reset happened. + * | | |Software can select a suitable value of WDT reset delay period for different WDT time-out period. + * | | |00 = Watchdog Timer reset delay period is (1024+2) * WDT_CLK. + * | | |01 = Watchdog Timer reset delay period is (128+2) * WDT_CLK. + * | | |10 = Watchdog Timer reset delay period is (16+2) * WDT_CLK. + * | | |11 = Watchdog Timer reset delay period is (1+2) * WDT_CLK. + * | | |Note: This register will be reset to 0 if WDT time-out reset happened + */ + __IO uint32_t ALTCTL; + +} WDT_T; + +/** + @addtogroup WDT_CONST WDT Bit Field Definition + Constant Definitions for WDT Controller +@{ */ + +#define WDT_CTL_RSTCNT_Pos (0) /*!< WDT_T::CTL: RSTCNT Position */ +#define WDT_CTL_RSTCNT_Msk (0x1ul << WDT_CTL_RSTCNT_Pos) /*!< WDT_T::CTL: RSTCNT Mask */ + +#define WDT_CTL_RSTEN_Pos (1) /*!< WDT_T::CTL: RSTEN Position */ +#define WDT_CTL_RSTEN_Msk (0x1ul << WDT_CTL_RSTEN_Pos) /*!< WDT_T::CTL: RSTEN Mask */ + +#define WDT_CTL_RSTF_Pos (2) /*!< WDT_T::CTL: RSTF Position */ +#define WDT_CTL_RSTF_Msk (0x1ul << WDT_CTL_RSTF_Pos) /*!< WDT_T::CTL: RSTF Mask */ + +#define WDT_CTL_IF_Pos (3) /*!< WDT_T::CTL: IF Position */ +#define WDT_CTL_IF_Msk (0x1ul << WDT_CTL_IF_Pos) /*!< WDT_T::CTL: IF Mask */ + +#define WDT_CTL_WKEN_Pos (4) /*!< WDT_T::CTL: WKEN Position */ +#define WDT_CTL_WKEN_Msk (0x1ul << WDT_CTL_WKEN_Pos) /*!< WDT_T::CTL: WKEN Mask */ + +#define WDT_CTL_WKF_Pos (5) /*!< WDT_T::CTL: WKF Position */ +#define WDT_CTL_WKF_Msk (0x1ul << WDT_CTL_WKF_Pos) /*!< WDT_T::CTL: WKF Mask */ + +#define WDT_CTL_INTEN_Pos (6) /*!< WDT_T::CTL: INTEN Position */ +#define WDT_CTL_INTEN_Msk (0x1ul << WDT_CTL_INTEN_Pos) /*!< WDT_T::CTL: INTEN Mask */ + +#define WDT_CTL_WDTEN_Pos (7) /*!< WDT_T::CTL: WDTEN Position */ +#define WDT_CTL_WDTEN_Msk (0x1ul << WDT_CTL_WDTEN_Pos) /*!< WDT_T::CTL: WDTEN Mask */ + +#define WDT_CTL_TOUTSEL_Pos (8) /*!< WDT_T::CTL: TOUTSEL Position */ +#define WDT_CTL_TOUTSEL_Msk (0x7ul << WDT_CTL_TOUTSEL_Pos) /*!< WDT_T::CTL: TOUTSEL Mask */ + +#define WDT_CTL_ICEDEBUG_Pos (31) /*!< WDT_T::CTL: ICEDEBUG Position */ +#define WDT_CTL_ICEDEBUG_Msk (0x1ul << WDT_CTL_ICEDEBUG_Pos) /*!< WDT_T::CTL: ICEDEBUG Mask */ + +#define WDT_ALTCTL_RSTDSEL_Pos (0) /*!< WDT_T::ALTCTL: RSTDSEL Position */ +#define WDT_ALTCTL_RSTDSEL_Msk (0x3ul << WDT_ALTCTL_RSTDSEL_Pos) /*!< WDT_T::ALTCTL: RSTDSEL Mask */ + +/**@}*/ /* WDT_CONST */ +/**@}*/ /* end of WDT register group */ + + +/*---------------------- Window Watchdog Timer -------------------------*/ +/** + @addtogroup WWDT Window Watchdog Timer(WWDT) + Memory Mapped Structure for WWDT Controller +@{ */ + +typedef struct { + + + /** + * RLDCNT + * =================================================================================================== + * Offset: 0x00 Window Watchdog Timer Reload Counter Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:31] |RLDCNT |WWDT Reload Counter Bit + * | | |Writing 0x00005AA5 to this register will reload the Window Watchdog Timer counter value to 0x3F. + * | | |Note: Software can only write RLDCNT to reload WWDT counter value when current WWDT counter value between 0 and CMPDAT. + * | | |If software writes RLDCNT when current WWDT counter value is larger than CMPDAT, WWDT reset signal will generate immediately. + */ + __O uint32_t RLDCNT; + + /** + * CTL + * =================================================================================================== + * Offset: 0x04 Window Watchdog Timer Control Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |WWDTEN |WWDT Enable Control + * | | |Set this bit to enable Window Watchdog Timer counter counting. + * | | |0 = Window Watchdog Timer counter is stopped. + * | | |1 = Window Watchdog Timer counter is starting counting. + * |[1] |INTEN |WWDT Interrupt Enable Control + * | | |If this bit is enabled, the WWDT counter compare match interrupt signal is generated and inform to CPU. + * | | |0 = WWDT counter compare match interrupt Disabled. + * | | |1 = WWDT counter compare match interrupt Enabled. + * |[8:11] |PSCSEL |WWDT Counter Prescale Period Selection + * | | |0000 = Pre-scale is 1; Max time-out period is 1 * 64 * TWWDT. + * | | |0001 = Pre-scale is 2; Max time-out period is 2 * 64 * TWWDT. + * | | |0010 = Pre-scale is 4; Max time-out period is 4 * 64 * TWWDT. + * | | |0011 = Pre-scale is 8; Max time-out period is 8 * 64 * TWWDT. + * | | |0100 = Pre-scale is 16; Max time-out period is 16 * 64 * TWWDT. + * | | |0101 = Pre-scale is 32; Max time-out period is 32 * 64 * TWWDT. + * | | |0110 = Pre-scale is 64; Max time-out period is 64 * 64 * TWWDT. + * | | |0111 = Pre-scale is 128; Max time-out period is 128 * 64 * TWWDT. + * | | |1000 = Pre-scale is 192; Max time-out period is 192 * 64 * TWWDT. + * | | |1001 = Pre-scale is 256; Max time-out period is 256 * 64 * TWWDT. + * | | |1010 = Pre-scale is 384; Max time-out period is 384 * 64 * TWWDT. + * | | |1011 = Pre-scale is 512; Max time-out period is 512 * 64 * TWWDT. + * | | |1100 = Pre-scale is 768; Max time-out period is 768 * 64 * TWWDT. + * | | |1101 = Pre-scale is 1024; Max time-out period is 1024 * 64 * TWWDT. + * | | |1110 = Pre-scale is 1536; Max time-out period is 1536 * 64 * TWWDT. + * | | |1111 = Pre-scale is 2048; Max time-out period is 2048 * 64 * TWWDT. + * |[16:21] |CMPDAT |WWDT Window Compare Bits + * | | |Set this register to adjust the valid reload window. + * | | |Note: Software can only write RLDCNT to reload WWDT counter value when current WWDT counter value between 0 and CMPDAT. + * | | |If Software writes RLDCNT when current WWDT counter value larger than CMPDAT, WWDT reset signal will generate immediately. + * |[31] |ICEDEBUG |ICE Debug Mode Acknowledge Disable Control + * | | |0 = ICE debug mode acknowledgement effects WWDT counting. + * | | |WWDT down counter will be held while CPU is held by ICE. + * | | |1 = ICE debug mode acknowledgement Disabled. + * | | |WWDT down counter will keep going no matter CPU is held by ICE or not. + */ + __IO uint32_t CTL; + + /** + * STATUS + * =================================================================================================== + * Offset: 0x08 Window Watchdog Timer Status Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0] |WWDTIF |WWDT Compare Match Interrupt Flag + * | | |This bit indicates the interrupt flag status of WWDT while WWDT counter value matches CMPDAT value. + * | | |0 = No effect. + * | | |1 = WWDT counter value matches CMPDAT value. + * | | |Note: This bit is cleared by writing 1 to it. + * |[1] |WWDTRF |WWDT Timer-Out Reset Flag + * | | |This bit indicates the system has been reset by WWDT time-out reset or not. + * | | |0 = WWDT time-out reset did not occur. + * | | |1 = WWDT time-out reset occurred. + * | | |Note: This bit is cleared by writing 1 to it. + */ + __IO uint32_t STATUS; + + /** + * CNT + * =================================================================================================== + * Offset: 0x0C Window Watchdog Timer Counter Value Register + * --------------------------------------------------------------------------------------------------- + * |Bits |Field |Descriptions + * | :----: | :----: | :---- | + * |[0:5] |CNTDAT |WWDT Counter Value + * | | |This register reflects the current WWDT counter value and is read only. + */ + __I uint32_t CNT; + +} WWDT_T; + +/** + @addtogroup WWDT_CONST WWDT Bit Field Definition + Constant Definitions for WWDT Controller +@{ */ + +#define WWDT_RLDCNT_RLDCNT_Pos (0) /*!< WWDT_T::RLDCNT: RLDCNT Position */ +#define WWDT_RLDCNT_RLDCNT_Msk (0xfffffffful << WWDT_RLDCNT_RLDCNT_Pos) /*!< WWDT_T::RLDCNT: RLDCNT Mask */ + +#define WWDT_CTL_WWDTEN_Pos (0) /*!< WWDT_T::CTL: WWDTEN Position */ +#define WWDT_CTL_WWDTEN_Msk (0x1ul << WWDT_CTL_WWDTEN_Pos) /*!< WWDT_T::CTL: WWDTEN Mask */ + +#define WWDT_CTL_INTEN_Pos (1) /*!< WWDT_T::CTL: INTEN Position */ +#define WWDT_CTL_INTEN_Msk (0x1ul << WWDT_CTL_INTEN_Pos) /*!< WWDT_T::CTL: INTEN Mask */ + +#define WWDT_CTL_PSCSEL_Pos (8) /*!< WWDT_T::CTL: PSCSEL Position */ +#define WWDT_CTL_PSCSEL_Msk (0xful << WWDT_CTL_PSCSEL_Pos) /*!< WWDT_T::CTL: PSCSEL Mask */ + +#define WWDT_CTL_CMPDAT_Pos (16) /*!< WWDT_T::CTL: CMPDAT Position */ +#define WWDT_CTL_CMPDAT_Msk (0x3ful << WWDT_CTL_CMPDAT_Pos) /*!< WWDT_T::CTL: CMPDAT Mask */ + +#define WWDT_CTL_ICEDEBUG_Pos (31) /*!< WWDT_T::CTL: ICEDEBUG Position */ +#define WWDT_CTL_ICEDEBUG_Msk (0x1ul << WWDT_CTL_ICEDEBUG_Pos) /*!< WWDT_T::CTL: ICEDEBUG Mask */ + +#define WWDT_STATUS_WWDTIF_Pos (0) /*!< WWDT_T::STATUS: WWDTIF Position */ +#define WWDT_STATUS_WWDTIF_Msk (0x1ul << WWDT_STATUS_WWDTIF_Pos) /*!< WWDT_T::STATUS: WWDTIF Mask */ + +#define WWDT_STATUS_WWDTRF_Pos (1) /*!< WWDT_T::STATUS: WWDTRF Position */ +#define WWDT_STATUS_WWDTRF_Msk (0x1ul << WWDT_STATUS_WWDTRF_Pos) /*!< WWDT_T::STATUS: WWDTRF Mask */ + +#define WWDT_CNT_CNTDAT_Pos (0) /*!< WWDT_T::CNT: CNTDAT Position */ +#define WWDT_CNT_CNTDAT_Msk (0x3ful << WWDT_CNT_CNTDAT_Pos) /*!< WWDT_T::CNT: CNTDAT Mask */ + +/**@}*/ /* WWDT_CONST */ +/**@}*/ /* end of WWDT register group */ + +#if defined ( __CC_ARM ) +#pragma no_anon_unions +#endif + + +/*@}*/ /* end of group NUC472_442_Peripherals */ + +/** @addtogroup NUC472_442_PERIPHERAL_MEM_MAP NUC472/NUC442 Peripheral Memory Base + Memory Mapped Structure for NUC472/NUC442 Peripheral + @{ + */ +/* Peripheral and SRAM base address */ +#define FLASH_BASE ((uint32_t)0x00000000) /*!< Flash base address */ +#define SRAM_BASE ((uint32_t)0x20000000) /*!< SRAM Base Address */ +#define PERIPH_BASE ((uint32_t)0x40000000) /*!< Peripheral Base Address */ +#define AHBPERIPH_BASE PERIPH_BASE /*!< AHB Base Address */ +#define APBPERIPH_BASE (PERIPH_BASE + 0x00040000) /*!< APB Base Address */ + +/*!< AHB peripherals */ +#define SYS_BASE (AHBPERIPH_BASE + 0x00000) +#define CLK_BASE (AHBPERIPH_BASE + 0x00200) +#define GPIOA_BASE (AHBPERIPH_BASE + 0x04000) +#define GPIOB_BASE (AHBPERIPH_BASE + 0x04040) +#define GPIOC_BASE (AHBPERIPH_BASE + 0x04080) +#define GPIOD_BASE (AHBPERIPH_BASE + 0x040C0) +#define GPIOE_BASE (AHBPERIPH_BASE + 0x04100) +#define GPIOF_BASE (AHBPERIPH_BASE + 0x04140) +#define GPIOG_BASE (AHBPERIPH_BASE + 0x04180) +#define GPIOH_BASE (AHBPERIPH_BASE + 0x041C0) +#define GPIOI_BASE (AHBPERIPH_BASE + 0x04200) +#define GPIO_DBCTL_BASE (AHBPERIPH_BASE + 0x04440) +#define GPIO_PIN_DATA_BASE (AHBPERIPH_BASE + 0x04800) +#define PDMA_BASE (AHBPERIPH_BASE + 0x08000) +#define USBH_BASE (AHBPERIPH_BASE + 0x09000) +#define EMAC_BASE (AHBPERIPH_BASE + 0x0B000) +#define FMC_BASE (AHBPERIPH_BASE + 0x0C000) +#define SD_BASE (AHBPERIPH_BASE + 0x0D000) +#define EBI_BASE (AHBPERIPH_BASE + 0x10000) +#define UDC20_BASE (AHBPERIPH_BASE + 0x19000) +#define CAP_BASE (AHBPERIPH_BASE + 0x30000) +#define CRC_BASE (AHBPERIPH_BASE + 0x31000) + +/*!< APB2 peripherals */ +#define WDT_BASE (APBPERIPH_BASE + 0x00000) +#define WWDT_BASE (APBPERIPH_BASE + 0x00100) +#define OPA_BASE (APBPERIPH_BASE + 0x06000) +#define I2S0_BASE (APBPERIPH_BASE + 0x08000) +#define TIMER0_BASE (APBPERIPH_BASE + 0x10000) +#define TIMER1_BASE (APBPERIPH_BASE + 0x10020) +#define PWM0_BASE (APBPERIPH_BASE + 0x18000) +#define EPWM0_BASE (APBPERIPH_BASE + 0x1C000) +#define SPI0_BASE (APBPERIPH_BASE + 0x20000) +#define SPI2_BASE (APBPERIPH_BASE + 0x22000) +#define UART0_BASE (APBPERIPH_BASE + 0x30000) +#define UART2_BASE (APBPERIPH_BASE + 0x32000) +#define UART4_BASE (APBPERIPH_BASE + 0x34000) +#define I2C0_BASE (APBPERIPH_BASE + 0x40000) +#define I2C2_BASE (APBPERIPH_BASE + 0x42000) +#define I2C4_BASE (APBPERIPH_BASE + 0x44000) +#define SC0_BASE (APBPERIPH_BASE + 0x50000) +#define SC2_BASE (APBPERIPH_BASE + 0x52000) +#define SC4_BASE (APBPERIPH_BASE + 0x54000) +#define CAN0_BASE (APBPERIPH_BASE + 0x60000) +#define QEI0_BASE (APBPERIPH_BASE + 0x70000) +#define ECAP0_BASE (APBPERIPH_BASE + 0x74000) +#define PS2D_BASE (APBPERIPH_BASE + 0xA0000) + +/*!< APB1 peripherals */ +#define RTC_BASE (APBPERIPH_BASE + 0x01000) +#define ADC_BASE (APBPERIPH_BASE + 0x03000) +#define EADC_BASE (APBPERIPH_BASE + 0x04000) +#define ACMP_BASE (APBPERIPH_BASE + 0x05000) +#define I2S1_BASE (APBPERIPH_BASE + 0x09000) +#define OTG_BASE (APBPERIPH_BASE + 0x0D000) +#define TIMER2_BASE (APBPERIPH_BASE + 0x11000) +#define TIMER3_BASE (APBPERIPH_BASE + 0x11020) +#define PWM1_BASE (APBPERIPH_BASE + 0x19000) +#define EPWM1_BASE (APBPERIPH_BASE + 0x1D000) +#define SPI1_BASE (APBPERIPH_BASE + 0x21000) +#define SPI3_BASE (APBPERIPH_BASE + 0x23000) +#define UART1_BASE (APBPERIPH_BASE + 0x31000) +#define UART3_BASE (APBPERIPH_BASE + 0x33000) +#define UART5_BASE (APBPERIPH_BASE + 0x35000) +#define I2C1_BASE (APBPERIPH_BASE + 0x41000) +#define I2C3_BASE (APBPERIPH_BASE + 0x43000) +#define SC1_BASE (APBPERIPH_BASE + 0x51000) +#define SC3_BASE (APBPERIPH_BASE + 0x53000) +#define SC5_BASE (APBPERIPH_BASE + 0x55000) +#define CAN1_BASE (APBPERIPH_BASE + 0x61000) +#define QEI1_BASE (APBPERIPH_BASE + 0x71000) +#define ECAP1_BASE (APBPERIPH_BASE + 0x75000) +#define CRPT_BASE (0x50080000UL) + +/*@}*/ /* end of group NUC472_442_PERIPHERAL_MEM_MAP */ + + +/** @addtogroup NUC472_442_PERIPHERAL_DECLARATION NUC472/NUC442 Peripheral Pointer + The Declaration of NUC472/NUC442 Peripheral + @{ + */ + +#define SYS ((SYS_T *) SYS_BASE) +#define CLK ((CLK_T *) CLK_BASE) +#define PA ((GPIO_T *) GPIOA_BASE) +#define PB ((GPIO_T *) GPIOB_BASE) +#define PC ((GPIO_T *) GPIOC_BASE) +#define PD ((GPIO_T *) GPIOD_BASE) +#define PE ((GPIO_T *) GPIOE_BASE) +#define PF ((GPIO_T *) GPIOF_BASE) +#define PG ((GPIO_T *) GPIOG_BASE) +#define PH ((GPIO_T *) GPIOH_BASE) +#define GPA ((GPIO_T *) GPIOA_BASE) +#define GPB ((GPIO_T *) GPIOB_BASE) +#define GPC ((GPIO_T *) GPIOC_BASE) +#define GPD ((GPIO_T *) GPIOD_BASE) +#define GPE ((GPIO_T *) GPIOE_BASE) +#define GPF ((GPIO_T *) GPIOF_BASE) +#define GPG ((GPIO_T *) GPIOG_BASE) +#define GPH ((GPIO_T *) GPIOH_BASE) +#define GPI ((GPIO_T *) GPIOI_BASE) +#define GPIO ((GPIO_DB_T *) GPIO_DBCTL_BASE) +#define PDMA ((PDMA_T *) PDMA_BASE) +#define USBH ((USBH_T *) USBH_BASE) +#define EMAC ((EMAC_T *) EMAC_BASE) +#define FMC ((FMC_T *) FMC_BASE) +#define SD ((SDH_T *) SD_BASE) +#define EBI ((EBI_T *) EBI_BASE) +#define ICAP ((CAP_T *) CAP_BASE) +#define CRC ((CRC_T *) CRC_BASE) + +#define WDT ((WDT_T *) WDT_BASE) +#define WWDT ((WWDT_T *) WWDT_BASE) +#define RTC ((RTC_T *) RTC_BASE) +#define ADC ((ADC_T *) ADC_BASE) +#define EADC ((EADC_T *) EADC_BASE) +#define ACMP ((ACMP_T *) ACMP_BASE) + +#define I2S0 ((I2S_T *) I2S0_BASE) +#define I2S1 ((I2S_T *) I2S1_BASE) +#define USBD ((USBD_T *) UDC20_BASE) +#define OTG ((OTG_T *) OTG_BASE) +#define TIMER0 ((TIMER_T *) TIMER0_BASE) +#define TIMER1 ((TIMER_T *) TIMER1_BASE) +#define TIMER2 ((TIMER_T *) TIMER2_BASE) +#define TIMER3 ((TIMER_T *) TIMER3_BASE) +#define PWM0 ((PWM_T *) PWM0_BASE) +#define PWM1 ((PWM_T *) PWM1_BASE) +#define EPWM0 ((EPWM_T *) EPWM0_BASE) +#define EPWM1 ((EPWM_T *) EPWM1_BASE) +#define ECAP0 ((ECAP_T *) ECAP0_BASE) +#define ECAP1 ((ECAP_T *) ECAP1_BASE) +#define QEI0 ((QEI_T *) QEI0_BASE) +#define QEI1 ((QEI_T *) QEI1_BASE) +#define SPI0 ((SPI_T *) SPI0_BASE) +#define SPI1 ((SPI_T *) SPI1_BASE) +#define SPI2 ((SPI_T *) SPI2_BASE) +#define SPI3 ((SPI_T *) SPI3_BASE) +#define UART0 ((UART_T *) UART0_BASE) +#define UART1 ((UART_T *) UART1_BASE) +#define UART2 ((UART_T *) UART2_BASE) +#define UART3 ((UART_T *) UART3_BASE) +#define UART4 ((UART_T *) UART4_BASE) +#define UART5 ((UART_T *) UART5_BASE) +#define I2C0 ((I2C_T *) I2C0_BASE) +#define I2C1 ((I2C_T *) I2C1_BASE) +#define I2C2 ((I2C_T *) I2C2_BASE) +#define I2C3 ((I2C_T *) I2C3_BASE) +#define I2C4 ((I2C_T *) I2C4_BASE) +#define SC0 ((SC_T *) SC0_BASE) +#define SC1 ((SC_T *) SC1_BASE) +#define SC2 ((SC_T *) SC2_BASE) +#define SC3 ((SC_T *) SC3_BASE) +#define SC4 ((SC_T *) SC4_BASE) +#define SC5 ((SC_T *) SC5_BASE) +#define CAN0 ((CAN_T *) CAN0_BASE) +#define CAN1 ((CAN_T *) CAN1_BASE) +#define PS2 ((PS2_T *) PS2D_BASE) +#define CRPT ((CRPT_T *) CRPT_BASE) +/*@}*/ /* end of group NUC472_442_PERIPHERAL_DECLARATION */ + +/** @addtogroup NUC472_442_IO_ROUTINE NUC472/NUC442 I/O Routines + The Declaration of NUC472/NUC442 I/O Routines + @{ + */ + +typedef volatile unsigned char vu8; ///< Define 8-bit unsigned volatile data type +typedef volatile unsigned short vu16; ///< Define 16-bit unsigned volatile data type +typedef volatile unsigned long vu32; ///< Define 32-bit unsigned volatile data type + +/** + * @brief Get a 8-bit unsigned value from specified address + * @param[in] addr Address to get 8-bit data from + * @return 8-bit unsigned value stored in specified address + */ +#define M8(addr) (*((vu8 *) (addr))) + +/** + * @brief Get a 16-bit unsigned value from specified address + * @param[in] addr Address to get 16-bit data from + * @return 16-bit unsigned value stored in specified address + * @note The input address must be 16-bit aligned + */ +#define M16(addr) (*((vu16 *) (addr))) + +/** + * @brief Get a 32-bit unsigned value from specified address + * @param[in] addr Address to get 32-bit data from + * @return 32-bit unsigned value stored in specified address + * @note The input address must be 32-bit aligned + */ +#define M32(addr) (*((vu32 *) (addr))) + +/** + * @brief Set a 32-bit unsigned value to specified I/O port + * @param[in] port Port address to set 32-bit data + * @param[in] value Value to write to I/O port + * @return None + * @note The output port must be 32-bit aligned + */ +#define outpw(port,value) *((volatile unsigned int *)(port)) = value + +/** + * @brief Get a 32-bit unsigned value from specified I/O port + * @param[in] port Port address to get 32-bit data from + * @return 32-bit unsigned value stored in specified I/O port + * @note The input port must be 32-bit aligned + */ +#define inpw(port) (*((volatile unsigned int *)(port))) + +/** + * @brief Set a 16-bit unsigned value to specified I/O port + * @param[in] port Port address to set 16-bit data + * @param[in] value Value to write to I/O port + * @return None + * @note The output port must be 16-bit aligned + */ +#define outps(port,value) *((volatile unsigned short *)(port)) = value + +/** + * @brief Get a 16-bit unsigned value from specified I/O port + * @param[in] port Port address to get 16-bit data from + * @return 16-bit unsigned value stored in specified I/O port + * @note The input port must be 16-bit aligned + */ +#define inps(port) (*((volatile unsigned short *)(port))) + +/** + * @brief Set a 8-bit unsigned value to specified I/O port + * @param[in] port Port address to set 8-bit data + * @param[in] value Value to write to I/O port + * @return None + */ +#define outpb(port,value) *((volatile unsigned char *)(port)) = value + +/** + * @brief Get a 8-bit unsigned value from specified I/O port + * @param[in] port Port address to get 8-bit data from + * @return 8-bit unsigned value stored in specified I/O port + */ +#define inpb(port) (*((volatile unsigned char *)(port))) + +/** + * @brief Set a 32-bit unsigned value to specified I/O port + * @param[in] port Port address to set 32-bit data + * @param[in] value Value to write to I/O port + * @return None + * @note The output port must be 32-bit aligned + */ +#define outp32(port,value) *((volatile unsigned int *)(port)) = value + +/** + * @brief Get a 32-bit unsigned value from specified I/O port + * @param[in] port Port address to get 32-bit data from + * @return 32-bit unsigned value stored in specified I/O port + * @note The input port must be 32-bit aligned + */ +#define inp32(port) (*((volatile unsigned int *)(port))) + +/** + * @brief Set a 16-bit unsigned value to specified I/O port + * @param[in] port Port address to set 16-bit data + * @param[in] value Value to write to I/O port + * @return None + * @note The output port must be 16-bit aligned + */ +#define outp16(port,value) *((volatile unsigned short *)(port)) = value + +/** + * @brief Get a 16-bit unsigned value from specified I/O port + * @param[in] port Port address to get 16-bit data from + * @return 16-bit unsigned value stored in specified I/O port + * @note The input port must be 16-bit aligned + */ +#define inp16(port) (*((volatile unsigned short *)(port))) + +/** + * @brief Set a 8-bit unsigned value to specified I/O port + * @param[in] port Port address to set 8-bit data + * @param[in] value Value to write to I/O port + * @return None + */ +#define outp8(port,value) *((volatile unsigned char *)(port)) = value + +/** + * @brief Get a 8-bit unsigned value from specified I/O port + * @param[in] port Port address to get 8-bit data from + * @return 8-bit unsigned value stored in specified I/O port + */ +#define inp8(port) (*((volatile unsigned char *)(port))) + + +/*@}*/ /* end of group NUC472_442_IO_ROUTINE */ + +/******************************************************************************/ +/* Legacy Constants */ +/******************************************************************************/ +/** @addtogroup NUC472_442_legacy_Constants NUC472/NUC442 Legacy Constants + NUC472/NUC442 Legacy Constants + @{ +*/ + +#ifndef NULL +#define NULL (0) ///< NULL pointer +#endif + +#define TRUE (1) ///< Boolean true, define to use in API parameters or return value +#define FALSE (0) ///< Boolean false, define to use in API parameters or return value + +#define ENABLE (1) ///< Enable, define to use in API parameters +#define DISABLE (0) ///< Disable, define to use in API parameters + +/* Define one bit mask */ +#define BIT0 (0x00000001) ///< Bit 0 mask of an 32 bit integer +#define BIT1 (0x00000002) ///< Bit 1 mask of an 32 bit integer +#define BIT2 (0x00000004) ///< Bit 2 mask of an 32 bit integer +#define BIT3 (0x00000008) ///< Bit 3 mask of an 32 bit integer +#define BIT4 (0x00000010) ///< Bit 4 mask of an 32 bit integer +#define BIT5 (0x00000020) ///< Bit 5 mask of an 32 bit integer +#define BIT6 (0x00000040) ///< Bit 6 mask of an 32 bit integer +#define BIT7 (0x00000080) ///< Bit 7 mask of an 32 bit integer +#define BIT8 (0x00000100) ///< Bit 8 mask of an 32 bit integer +#define BIT9 (0x00000200) ///< Bit 9 mask of an 32 bit integer +#define BIT10 (0x00000400) ///< Bit 10 mask of an 32 bit integer +#define BIT11 (0x00000800) ///< Bit 11 mask of an 32 bit integer +#define BIT12 (0x00001000) ///< Bit 12 mask of an 32 bit integer +#define BIT13 (0x00002000) ///< Bit 13 mask of an 32 bit integer +#define BIT14 (0x00004000) ///< Bit 14 mask of an 32 bit integer +#define BIT15 (0x00008000) ///< Bit 15 mask of an 32 bit integer +#define BIT16 (0x00010000) ///< Bit 16 mask of an 32 bit integer +#define BIT17 (0x00020000) ///< Bit 17 mask of an 32 bit integer +#define BIT18 (0x00040000) ///< Bit 18 mask of an 32 bit integer +#define BIT19 (0x00080000) ///< Bit 19 mask of an 32 bit integer +#define BIT20 (0x00100000) ///< Bit 20 mask of an 32 bit integer +#define BIT21 (0x00200000) ///< Bit 21 mask of an 32 bit integer +#define BIT22 (0x00400000) ///< Bit 22 mask of an 32 bit integer +#define BIT23 (0x00800000) ///< Bit 23 mask of an 32 bit integer +#define BIT24 (0x01000000) ///< Bit 24 mask of an 32 bit integer +#define BIT25 (0x02000000) ///< Bit 25 mask of an 32 bit integer +#define BIT26 (0x04000000) ///< Bit 26 mask of an 32 bit integer +#define BIT27 (0x08000000) ///< Bit 27 mask of an 32 bit integer +#define BIT28 (0x10000000) ///< Bit 28 mask of an 32 bit integer +#define BIT29 (0x20000000) ///< Bit 29 mask of an 32 bit integer +#define BIT30 (0x40000000) ///< Bit 30 mask of an 32 bit integer +#define BIT31 (0x80000000) ///< Bit 31 mask of an 32 bit integer + +/* Byte Mask Definitions */ +#define BYTE0_Msk (0x000000FF) ///< Mask to get bit0~bit7 from a 32 bit integer +#define BYTE1_Msk (0x0000FF00) ///< Mask to get bit8~bit15 from a 32 bit integer +#define BYTE2_Msk (0x00FF0000) ///< Mask to get bit16~bit23 from a 32 bit integer +#define BYTE3_Msk (0xFF000000) ///< Mask to get bit24~bit31 from a 32 bit integer + +#define GET_BYTE0(u32Param) ((u32Param & BYTE0_Msk) ) /*!< Extract Byte 0 (Bit 0~ 7) from parameter u32Param */ +#define GET_BYTE1(u32Param) ((u32Param & BYTE1_Msk) >> 8) /*!< Extract Byte 1 (Bit 8~15) from parameter u32Param */ +#define GET_BYTE2(u32Param) ((u32Param & BYTE2_Msk) >> 16) /*!< Extract Byte 2 (Bit 16~23) from parameter u32Param */ +#define GET_BYTE3(u32Param) ((u32Param & BYTE3_Msk) >> 24) /*!< Extract Byte 3 (Bit 24~31) from parameter u32Param */ + +/*@}*/ /* end of group NUC472_442_legacy_Constants */ + + +/******************************************************************************/ +/* Peripheral header files */ +/******************************************************************************/ +#include "sys.h" +#include "clk.h" + +#include "acmp.h" +#include "adc.h" +#include "eadc.h" +#include "cap.h" +#include "crypto.h" +#include "pdma.h" +#include "ebi.h" +#include "emac.h" +#include "fmc.h" +#include "gpio.h" +#include "i2c.h" +#include "pwm.h" +#include "epwm.h" +#include "rtc.h" +#include "sc.h" +#include "scuart.h" +#include "spi.h" +#include "timer.h" +#include "uart.h" +#include "usbd.h" +#include "wdt.h" +#include "wwdt.h" +#include "i2s.h" +#include "can.h" +#include "sd.h" +#include "ps2.h" +#include "crc.h" + +#ifdef __cplusplus +} +#endif + +#endif /* __NUC472_442_H__ */ + +/*** (C) COPYRIGHT 2014~2015 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Include/system_NUC472_442.h b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Include/system_NUC472_442.h new file mode 100644 index 0000000000000000000000000000000000000000..d78e9cdf6da4a217eb5214dea0b72d0e962c3311 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Include/system_NUC472_442.h @@ -0,0 +1,60 @@ +/**************************************************************************//** + * @file system_NUC472_442.h + * @version V1.00 + * $Revision: 5 $ + * $Date: 14/05/29 1:13p $ + * @brief NUC472/NUC442 system clock definition file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __SYSTEM_NUC472_442_H__ +#define __SYSTEM_NUC472_442_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + +/*---------------------------------------------------------------------------- + Define clocks + *----------------------------------------------------------------------------*/ +#define __HXT (12000000UL) /*!< High Speed External Crystal Clock Frequency 12MHz */ +#define __LXT (32768UL) /*!< Low Speed External Crystal Clock Frequency 32.768kHz */ +#define __HIRC (22118400UL) /*!< High Speed Internal 22MHz RC Oscillator Frequency */ +#define __LIRC (10000UL) /*!< Low Speed Internal 10kHz RC Oscillator Frequency */ +#define __HSI (__HIRC) /* Factory Default is internal 12MHz */ + + +extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +extern uint32_t CyclesPerUs; /*!< Cycles per micro second */ +extern uint32_t PllClock; /*!< PLL Output Clock Frequency */ + + +/** + * Initialize the system + * + * @return none + * + * @brief Setup the microcontroller system. + */ +extern void SystemInit (void); + +/** + * Update SystemCoreClock variable + * + * @return none + * + * @brief Updates the SystemCoreClock with current core Clock + * retrieved from CPU registers. + */ +extern void SystemCoreClockUpdate (void); + +#ifdef __cplusplus +} +#endif + +#endif /* __SYSTEM_NUC472_442_H__ */ +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/ARM/startup_NUC472_442.s b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/ARM/startup_NUC472_442.s new file mode 100644 index 0000000000000000000000000000000000000000..259cefb80072ec6f0eae9751cab91fd035f88267 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/ARM/startup_NUC472_442.s @@ -0,0 +1,542 @@ +;/****************************************************************************** +; * @file startup_NUC472_442.s +; * @version V1.00 +; * $Revision: 12 $ +; * $Date: 15/09/22 10:25a $ +; * @brief CMSIS ARM Cortex-M4 Core Device Startup File +; * +; * @note +; * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +;*****************************************************************************/ +;/* +;//-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ +;*/ + + +; Stack Configuration +; Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + + IF :LNOT: :DEF: Stack_Size +Stack_Size EQU 0x00001000 + ENDIF + + AREA STACK, NOINIT, READWRITE, ALIGN=3 +Stack_Mem SPACE Stack_Size +__initial_sp + + +; Heap Configuration +; Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> +; + + IF :LNOT: :DEF: Heap_Size +Heap_Size EQU 0x00000200 + ENDIF + + AREA HEAP, NOINIT, READWRITE, ALIGN=3 +__heap_base +Heap_Mem SPACE Heap_Size +__heap_limit + + + PRESERVE8 + THUMB + + +; Vector Table Mapped to Address 0 at Reset + + AREA RESET, DATA, READONLY + EXPORT __Vectors + EXPORT __Vectors_End + EXPORT __Vectors_Size + +__Vectors DCD __initial_sp ; Top of Stack + DCD Reset_Handler ; Reset Handler + DCD NMI_Handler ; NMI Handler + DCD HardFault_Handler ; Hard Fault Handler + DCD MemManage_Handler ; MPU Fault Handler + DCD BusFault_Handler ; Bus Fault Handler + DCD UsageFault_Handler ; Usage Fault Handler + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD 0 ; Reserved + DCD SVC_Handler ; SVCall Handler + DCD DebugMon_Handler ; Debug Monitor Handler + DCD 0 ; Reserved + DCD PendSV_Handler ; PendSV Handler + DCD SysTick_Handler ; SysTick Handler + + ; External Interrupts + DCD BOD_IRQHandler ; 0: Brown Out detection + DCD IRC_IRQHandler ; 1: Internal RC + DCD PWRWU_IRQHandler ; 2: Power Down Wake Up + DCD SRAMF_IRQHandler ; 3: Reserved. + DCD CLKF_IRQHandler ; 4: CLKF + DCD Default_Handler ; 5: Reserved. + DCD RTC_IRQHandler ; 6: Real Time Clock + DCD TAMPER_IRQHandler ; 7: Tamper detection + DCD EINT0_IRQHandler ; 8: External Input 0 + DCD EINT1_IRQHandler ; 9: External Input 1 + DCD EINT2_IRQHandler ; 10: External Input 2 + DCD EINT3_IRQHandler ; 11: External Input 3 + DCD EINT4_IRQHandler ; 12: External Input 4 + DCD EINT5_IRQHandler ; 13: External Input 5 + DCD EINT6_IRQHandler ; 14: External Input 6 + DCD EINT7_IRQHandler ; 15: External Input 7 + DCD GPA_IRQHandler ; 16: GPIO Port A + DCD GPB_IRQHandler ; 17: GPIO Port B + DCD GPC_IRQHandler ; 18: GPIO Port C + DCD GPD_IRQHandler ; 19: GPIO Port D + DCD GPE_IRQHandler ; 20: GPIO Port E + DCD GPF_IRQHandler ; 21: GPIO Port F + DCD GPG_IRQHandler ; 22: GPIO Port G + DCD GPH_IRQHandler ; 23: GPIO Port H + DCD GPI_IRQHandler ; 24: GPIO Port I + DCD Default_Handler ; 25: Reserved. + DCD Default_Handler ; 26: Reserved. + DCD Default_Handler ; 27: Reserved. + DCD Default_Handler ; 28: Reserved. + DCD Default_Handler ; 29: Reserved. + DCD Default_Handler ; 30: Reserved. + DCD Default_Handler ; 31: Reserved. + DCD TMR0_IRQHandler ; 32: Timer 0 + DCD TMR1_IRQHandler ; 33: Timer 1 + DCD TMR2_IRQHandler ; 34: Timer 2 + DCD TMR3_IRQHandler ; 35: Timer 3 + DCD Default_Handler ; 36: Reserved. + DCD Default_Handler ; 37: Reserved. + DCD Default_Handler ; 38: Reserved. + DCD Default_Handler ; 39: Reserved. + DCD PDMA_IRQHandler ; 40: Peripheral DMA + DCD Default_Handler ; 41: Reserved. + DCD ADC_IRQHandler ; 42: ADC + DCD Default_Handler ; 43: Reserved. + DCD Default_Handler ; 44: Reserved. + DCD Default_Handler ; 45: Reserved. + DCD WDT_IRQHandler ; 46: Watch Dog Timer + DCD WWDT_IRQHandler ; 47: Window Watch Dog Timer + DCD EADC0_IRQHandler ; 48: EDAC 0 + DCD EADC1_IRQHandler ; 49: EDAC 1 + DCD EADC2_IRQHandler ; 50: EDAC 2 + DCD EADC3_IRQHandler ; 51: EDAC 3 + DCD Default_Handler ; 52: Reserved. + DCD Default_Handler ; 53: Reserved. + DCD Default_Handler ; 54: Reserved. + DCD Default_Handler ; 55: Reserved. + DCD ACMP_IRQHandler ; 56: Analog Comparator + DCD Default_Handler ; 57: Reserved. + DCD Default_Handler ; 58: Reserved. + DCD Default_Handler ; 59: Reserved. + DCD OPA0_IRQHandler ; 60: OPA 0 + DCD OPA1_IRQHandler ; 61: OPA 1 + DCD ICAP0_IRQHandler ; 62: ICAP 0 + DCD ICAP1_IRQHandler ; 63: ICAP 1 + DCD PWM0CH0_IRQHandler ; 64: PWM0 CH0 + DCD PWM0CH1_IRQHandler ; 65: PWM0 CH1 + DCD PWM0CH2_IRQHandler ; 66: PWM0 CH2 + DCD PWM0CH3_IRQHandler ; 67: PWM0 CH3 + DCD PWM0CH4_IRQHandler ; 68: PWM0 CH4 + DCD PWM0CH5_IRQHandler ; 69: PWM0 CH5 + DCD PWM0_BRK_IRQHandler ; 70: PWM0 Brake + DCD QEI0_IRQHandler ; 71: QEI 0 + DCD PWM1CH0_IRQHandler ; 72: PWM1 CH0 + DCD PWM1CH1_IRQHandler ; 73: PWM1 CH1 + DCD PWM1CH2_IRQHandler ; 74: PWM1 CH2 + DCD PWM1CH3_IRQHandler ; 75: PWM1 CH3 + DCD PWM1CH4_IRQHandler ; 76: PWM1 CH4 + DCD PWM1CH5_IRQHandler ; 77: PWM1 CH5 + DCD PWM1_BRK_IRQHandler ; 78: PWM1 Brake + DCD QEI1_IRQHandler ; 79: QEI 1 + DCD EPWM0_IRQHandler ; 80: EPWM0 + DCD EPWM0BRK_IRQHandler ; 81: EPWM0 Brake + DCD EPWM1_IRQHandler ; 82: EPWM1 + DCD EPWM1BRK_IRQHandler ; 83: EPWM1 Brake + DCD Default_Handler ; 84: Reserved. + DCD Default_Handler ; 85: Reserved. + DCD Default_Handler ; 86: Reserved. + DCD Default_Handler ; 87: Reserved. + DCD USBD_IRQHandler ; 88: USB Device + DCD USBH_IRQHandler ; 89: USB Host + DCD USB_OTG_IRQHandler ; 90: USB OTG + DCD Default_Handler ; 91: Reserved. + DCD EMAC_TX_IRQHandler ; 92: Ethernet MAC TX + DCD EMAC_RX_IRQHandler ; 93: Ethernet MAC RX + DCD Default_Handler ; 94: Reserved. + DCD Default_Handler ; 95: Reserved. + DCD SPI0_IRQHandler ; 96: SPI 0 + DCD SPI1_IRQHandler ; 97: SPI 1 + DCD SPI2_IRQHandler ; 98: SPI 2 + DCD SPI3_IRQHandler ; 99: SPI 3 + DCD Default_Handler ; 100: Reserved. + DCD Default_Handler ; 101: Reserved. + DCD Default_Handler ; 102: Reserved. + DCD Default_Handler ; 103: Reserved. + DCD UART0_IRQHandler ; 104: UART 0 + DCD UART1_IRQHandler ; 105: UART 1 + DCD UART2_IRQHandler ; 106: UART 2 + DCD UART3_IRQHandler ; 107: UART 3 + DCD UART4_IRQHandler ; 108: UART 4 + DCD UART5_IRQHandler ; 109: UART 5 + DCD Default_Handler ; 110: Reserved. + DCD Default_Handler ; 111: Reserved. + DCD I2C0_IRQHandler ; 112: I2C 0 + DCD I2C1_IRQHandler ; 113: I2C 1 + DCD I2C2_IRQHandler ; 114: I2C 2 + DCD I2C3_IRQHandler ; 115: I2C 3 + DCD I2C4_IRQHandler ; 116: I2C 4 + DCD Default_Handler ; 117: Reserved. + DCD Default_Handler ; 118: Reserved. + DCD Default_Handler ; 119: Reserved. + DCD SC0_IRQHandler ; 120: Smart Card 0 + DCD SC1_IRQHandler ; 121: Smart Card 1 + DCD SC2_IRQHandler ; 122: Smart Card 2 + DCD SC3_IRQHandler ; 123: Smart Card 3 + DCD SC4_IRQHandler ; 124: Smart Card 4 + DCD SC5_IRQHandler ; 125: Smart Card 5 + DCD Default_Handler ; 126: Reserved. + DCD Default_Handler ; 127: Reserved. + DCD CAN0_IRQHandler ; 128: CAN 0 + DCD CAN1_IRQHandler ; 129: CAN 1 + DCD Default_Handler ; 130: Reserved. + DCD Default_Handler ; 131: Reserved. + DCD I2S0_IRQHandler ; 132: I2S 0 + DCD I2S1_IRQHandler ; 133: I2S 1 + DCD Default_Handler ; 134: Reserved. + DCD Default_Handler ; 135: Reserved. + DCD SD_IRQHandler ; 136: SD card + DCD Default_Handler ; 137: Reserved. + DCD PS2D_IRQHandler ; 138: PS/2 device + DCD CAP_IRQHandler ; 139: VIN + DCD CRYPTO_IRQHandler ; 140: CRYPTO + DCD CRC_IRQHandler ; 141: CRC + +__Vectors_End + +__Vectors_Size EQU __Vectors_End - __Vectors + + AREA |.text|, CODE, READONLY + + +; Reset Handler + +Reset_Handler PROC + EXPORT Reset_Handler [WEAK] + IMPORT SystemInit + IMPORT __main + ; Unlock Register + LDR R0, =0x40000100 + LDR R1, =0x59 + STR R1, [R0] + LDR R1, =0x16 + STR R1, [R0] + LDR R1, =0x88 + STR R1, [R0] + + ; Disable branch buffer if VCID is 0 + LDR R2, =0x40000020 + LDR R1, [R2] + CMP R1, #0 + BNE Lock + LDR R2, =0x4000C018 + LDR R1, [R2] + ORR R1, #0x80 + STR R1, [R2] + +Lock + ; Init POR + LDR R2, =0x40000024 + LDR R1, =0x00005AA5 + STR R1, [R2] + + ; Lock register + MOVS R1, #0 + STR R1, [R0] + + LDR R0, =SystemInit + BLX R0 + LDR R0, =__main + BX R0 + ENDP + + +; Dummy Exception Handlers (infinite loops which can be modified) + +NMI_Handler PROC + EXPORT NMI_Handler [WEAK] + B . + ENDP +HardFault_Handler\ + PROC + EXPORT HardFault_Handler [WEAK] + B . + ENDP +MemManage_Handler\ + PROC + EXPORT MemManage_Handler [WEAK] + B . + ENDP +BusFault_Handler\ + PROC + EXPORT BusFault_Handler [WEAK] + B . + ENDP +UsageFault_Handler\ + PROC + EXPORT UsageFault_Handler [WEAK] + B . + ENDP +SVC_Handler PROC + EXPORT SVC_Handler [WEAK] + B . + ENDP +DebugMon_Handler\ + PROC + EXPORT DebugMon_Handler [WEAK] + B . + ENDP +PendSV_Handler\ + PROC + EXPORT PendSV_Handler [WEAK] + B . + ENDP +SysTick_Handler\ + PROC + EXPORT SysTick_Handler [WEAK] + B . + ENDP + +Default_Handler PROC + + EXPORT BOD_IRQHandler [WEAK] + EXPORT IRC_IRQHandler [WEAK] + EXPORT PWRWU_IRQHandler [WEAK] + EXPORT SRAMF_IRQHandler [WEAK] + EXPORT CLKF_IRQHandler [WEAK] + EXPORT RTC_IRQHandler [WEAK] + EXPORT TAMPER_IRQHandler [WEAK] + EXPORT EINT0_IRQHandler [WEAK] + EXPORT EINT1_IRQHandler [WEAK] + EXPORT EINT2_IRQHandler [WEAK] + EXPORT EINT3_IRQHandler [WEAK] + EXPORT EINT4_IRQHandler [WEAK] + EXPORT EINT5_IRQHandler [WEAK] + EXPORT EINT6_IRQHandler [WEAK] + EXPORT EINT7_IRQHandler [WEAK] + EXPORT GPA_IRQHandler [WEAK] + EXPORT GPB_IRQHandler [WEAK] + EXPORT GPC_IRQHandler [WEAK] + EXPORT GPD_IRQHandler [WEAK] + EXPORT GPE_IRQHandler [WEAK] + EXPORT GPF_IRQHandler [WEAK] + EXPORT GPG_IRQHandler [WEAK] + EXPORT GPH_IRQHandler [WEAK] + EXPORT GPI_IRQHandler [WEAK] + EXPORT TMR0_IRQHandler [WEAK] + EXPORT TMR1_IRQHandler [WEAK] + EXPORT TMR2_IRQHandler [WEAK] + EXPORT TMR3_IRQHandler [WEAK] + EXPORT PDMA_IRQHandler [WEAK] + EXPORT ADC_IRQHandler [WEAK] + EXPORT WDT_IRQHandler [WEAK] + EXPORT WWDT_IRQHandler [WEAK] + EXPORT EADC0_IRQHandler [WEAK] + EXPORT EADC1_IRQHandler [WEAK] + EXPORT EADC2_IRQHandler [WEAK] + EXPORT EADC3_IRQHandler [WEAK] + EXPORT ACMP_IRQHandler [WEAK] + EXPORT OPA0_IRQHandler [WEAK] + EXPORT OPA1_IRQHandler [WEAK] + EXPORT ICAP0_IRQHandler [WEAK] + EXPORT ICAP1_IRQHandler [WEAK] + EXPORT PWM0CH0_IRQHandler [WEAK] + EXPORT PWM0CH1_IRQHandler [WEAK] + EXPORT PWM0CH2_IRQHandler [WEAK] + EXPORT PWM0CH3_IRQHandler [WEAK] + EXPORT PWM0CH4_IRQHandler [WEAK] + EXPORT PWM0CH5_IRQHandler [WEAK] + EXPORT PWM0_BRK_IRQHandler [WEAK] + EXPORT QEI0_IRQHandler [WEAK] + EXPORT PWM1CH0_IRQHandler [WEAK] + EXPORT PWM1CH1_IRQHandler [WEAK] + EXPORT PWM1CH2_IRQHandler [WEAK] + EXPORT PWM1CH3_IRQHandler [WEAK] + EXPORT PWM1CH4_IRQHandler [WEAK] + EXPORT PWM1CH5_IRQHandler [WEAK] + EXPORT PWM1_BRK_IRQHandler [WEAK] + EXPORT QEI1_IRQHandler [WEAK] + EXPORT EPWM0_IRQHandler [WEAK] + EXPORT EPWM0BRK_IRQHandler [WEAK] + EXPORT EPWM1_IRQHandler [WEAK] + EXPORT EPWM1BRK_IRQHandler [WEAK] + EXPORT USBD_IRQHandler [WEAK] + EXPORT USBH_IRQHandler [WEAK] + EXPORT USB_OTG_IRQHandler [WEAK] + EXPORT EMAC_TX_IRQHandler [WEAK] + EXPORT EMAC_RX_IRQHandler [WEAK] + EXPORT SPI0_IRQHandler [WEAK] + EXPORT SPI1_IRQHandler [WEAK] + EXPORT SPI2_IRQHandler [WEAK] + EXPORT SPI3_IRQHandler [WEAK] + EXPORT UART0_IRQHandler [WEAK] + EXPORT UART1_IRQHandler [WEAK] + EXPORT UART2_IRQHandler [WEAK] + EXPORT UART3_IRQHandler [WEAK] + EXPORT UART4_IRQHandler [WEAK] + EXPORT UART5_IRQHandler [WEAK] + EXPORT I2C0_IRQHandler [WEAK] + EXPORT I2C1_IRQHandler [WEAK] + EXPORT I2C2_IRQHandler [WEAK] + EXPORT I2C3_IRQHandler [WEAK] + EXPORT I2C4_IRQHandler [WEAK] + EXPORT SC0_IRQHandler [WEAK] + EXPORT SC1_IRQHandler [WEAK] + EXPORT SC2_IRQHandler [WEAK] + EXPORT SC3_IRQHandler [WEAK] + EXPORT SC4_IRQHandler [WEAK] + EXPORT SC5_IRQHandler [WEAK] + EXPORT CAN0_IRQHandler [WEAK] + EXPORT CAN1_IRQHandler [WEAK] + EXPORT I2S0_IRQHandler [WEAK] + EXPORT I2S1_IRQHandler [WEAK] + EXPORT SD_IRQHandler [WEAK] + EXPORT PS2D_IRQHandler [WEAK] + EXPORT CAP_IRQHandler [WEAK] + EXPORT CRYPTO_IRQHandler [WEAK] + EXPORT CRC_IRQHandler [WEAK] + +Default__IRQHandler +BOD_IRQHandler +IRC_IRQHandler +PWRWU_IRQHandler +SRAMF_IRQHandler +CLKF_IRQHandler +RTC_IRQHandler +TAMPER_IRQHandler +EINT0_IRQHandler +EINT1_IRQHandler +EINT2_IRQHandler +EINT3_IRQHandler +EINT4_IRQHandler +EINT5_IRQHandler +EINT6_IRQHandler +EINT7_IRQHandler +GPA_IRQHandler +GPB_IRQHandler +GPC_IRQHandler +GPD_IRQHandler +GPE_IRQHandler +GPF_IRQHandler +GPG_IRQHandler +GPH_IRQHandler +GPI_IRQHandler +TMR0_IRQHandler +TMR1_IRQHandler +TMR2_IRQHandler +TMR3_IRQHandler +PDMA_IRQHandler +ADC_IRQHandler +WDT_IRQHandler +WWDT_IRQHandler +EADC0_IRQHandler +EADC1_IRQHandler +EADC2_IRQHandler +EADC3_IRQHandler +ACMP_IRQHandler +OPA0_IRQHandler +OPA1_IRQHandler +ICAP0_IRQHandler +ICAP1_IRQHandler +PWM0CH0_IRQHandler +PWM0CH1_IRQHandler +PWM0CH2_IRQHandler +PWM0CH3_IRQHandler +PWM0CH4_IRQHandler +PWM0CH5_IRQHandler +PWM0_BRK_IRQHandler +QEI0_IRQHandler +PWM1CH0_IRQHandler +PWM1CH1_IRQHandler +PWM1CH2_IRQHandler +PWM1CH3_IRQHandler +PWM1CH4_IRQHandler +PWM1CH5_IRQHandler +PWM1_BRK_IRQHandler +QEI1_IRQHandler +EPWM0_IRQHandler +EPWM0BRK_IRQHandler +EPWM1_IRQHandler +EPWM1BRK_IRQHandler +USBD_IRQHandler +USBH_IRQHandler +USB_OTG_IRQHandler +EMAC_TX_IRQHandler +EMAC_RX_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +SPI3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +UART4_IRQHandler +UART5_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +I2C3_IRQHandler +I2C4_IRQHandler +SC0_IRQHandler +SC1_IRQHandler +SC2_IRQHandler +SC3_IRQHandler +SC4_IRQHandler +SC5_IRQHandler +CAN0_IRQHandler +CAN1_IRQHandler +I2S0_IRQHandler +I2S1_IRQHandler +SD_IRQHandler +PS2D_IRQHandler +CAP_IRQHandler +CRYPTO_IRQHandler +CRC_IRQHandler + + B . + ENDP + + + ALIGN + + +; User Initial Stack & Heap + + IF :DEF:__MICROLIB + + EXPORT __initial_sp + EXPORT __heap_base + EXPORT __heap_limit + + ELSE + + IMPORT __use_two_region_memory + EXPORT __user_initial_stackheap + +__user_initial_stackheap PROC + LDR R0, = Heap_Mem + LDR R1, =(Stack_Mem + Stack_Size) + LDR R2, = (Heap_Mem + Heap_Size) + LDR R3, = Stack_Mem + BX LR + ENDP + + ALIGN + + ENDIF + + + + END +;/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/GCC/startup.c b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/GCC/startup.c new file mode 100644 index 0000000000000000000000000000000000000000..c4bc353cf6311cce74b855a20da3b5aa0082fd95 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/GCC/startup.c @@ -0,0 +1,355 @@ +/* + * This file is part of the µOS++ distribution. + * (https://github.com/micro-os-plus) + * Copyright (c) 2014 Liviu Ionescu. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "string.h" + +void __attribute__((weak)) +Default_Handler(void); + +// Forward declaration of the specific IRQ handlers. These are aliased +// to the Default_Handler, which is a 'forever' loop. When the application +// defines a handler (with the same name), this will automatically take +// precedence over these weak definitions + +void __attribute__ ((weak)) HardFault_Handler(void); +void __attribute__ ((weak)) PendSV_Handler(void); +void __attribute__ ((weak)) NMI_Handler(void); +void __attribute__ ((weak)) MemManage_Handler(void); +void __attribute__ ((weak)) BusFault_Handler(void); +void __attribute__ ((weak)) UsageFault_Handler(void); +void __attribute__ ((weak)) SVC_Handler(void); +void __attribute__ ((weak)) DebugMon_Handler(void); +void __attribute__ ((weak)) SysTick_Handler(void); +void __attribute__ ((weak)) BOD_IRQHandler(void); +void __attribute__ ((weak)) IRC_IRQHandler(void); +void __attribute__ ((weak)) PWRWU_IRQHandler(void); +void __attribute__ ((weak)) CLKF_IRQHandler(void); +void __attribute__ ((weak)) RTC_IRQHandler(void); +void __attribute__ ((weak)) TAMPER_IRQHandler(void); +void __attribute__ ((weak)) EINT0_IRQHandler(void); +void __attribute__ ((weak)) EINT1_IRQHandler(void); +void __attribute__ ((weak)) EINT2_IRQHandler(void); +void __attribute__ ((weak)) EINT3_IRQHandler(void); +void __attribute__ ((weak)) EINT4_IRQHandler(void); +void __attribute__ ((weak)) EINT5_IRQHandler(void); +void __attribute__ ((weak)) EINT6_IRQHandler(void); +void __attribute__ ((weak)) EINT7_IRQHandler(void); +void __attribute__ ((weak)) GPA_IRQHandler(void); +void __attribute__ ((weak)) GPB_IRQHandler(void); +void __attribute__ ((weak)) GPC_IRQHandler(void); +void __attribute__ ((weak)) GPD_IRQHandler(void); +void __attribute__ ((weak)) GPE_IRQHandler(void); +void __attribute__ ((weak)) GPF_IRQHandler(void); +void __attribute__ ((weak)) GPG_IRQHandler(void); +void __attribute__ ((weak)) GPH_IRQHandler(void); +void __attribute__ ((weak)) GPI_IRQHandler(void); +void __attribute__ ((weak)) TMR0_IRQHandler(void); +void __attribute__ ((weak)) TMR1_IRQHandler(void); +void __attribute__ ((weak)) TMR2_IRQHandler(void); +void __attribute__ ((weak)) TMR3_IRQHandler(void); +void __attribute__ ((weak)) PDMA_IRQHandler(void); +void __attribute__ ((weak)) ADC_IRQHandler(void); +void __attribute__ ((weak)) WDT_IRQHandler(void); +void __attribute__ ((weak)) WWDT_IRQHandler(void); +void __attribute__ ((weak)) EADC0_IRQHandler(void); +void __attribute__ ((weak)) EADC1_IRQHandler(void); +void __attribute__ ((weak)) EADC2_IRQHandler(void); +void __attribute__ ((weak)) EADC3_IRQHandler(void); +void __attribute__ ((weak)) ACMP_IRQHandler(void); +void __attribute__ ((weak)) OPA0_IRQHandler(void); +void __attribute__ ((weak)) OPA1_IRQHandler(void); +void __attribute__ ((weak)) ICAP0_IRQHandler(void); +void __attribute__ ((weak)) ICAP1_IRQHandler(void); +void __attribute__ ((weak)) PWM0CH0_IRQHandler(void); +void __attribute__ ((weak)) PWM0CH1_IRQHandler(void); +void __attribute__ ((weak)) PWM0CH2_IRQHandler(void); +void __attribute__ ((weak)) PWM0CH3_IRQHandler(void); +void __attribute__ ((weak)) PWM0CH4_IRQHandler(void); +void __attribute__ ((weak)) PWM0CH5_IRQHandler(void); +void __attribute__ ((weak)) PWM0_BRK_IRQHandler(void); +void __attribute__ ((weak)) QEI0_IRQHandler(void); +void __attribute__ ((weak)) PWM1CH0_IRQHandler(void); +void __attribute__ ((weak)) PWM1CH1_IRQHandler(void); +void __attribute__ ((weak)) PWM1CH2_IRQHandler(void); +void __attribute__ ((weak)) PWM1CH3_IRQHandler(void); +void __attribute__ ((weak)) PWM1CH4_IRQHandler(void); +void __attribute__ ((weak)) PWM1CH5_IRQHandler(void); +void __attribute__ ((weak)) PWM1_BRK_IRQHandler(void); +void __attribute__ ((weak)) QEI1_IRQHandler(void); +void __attribute__ ((weak)) EPWM0_IRQHandler(void); +void __attribute__ ((weak)) EPWM0BRK_IRQHandler(void); +void __attribute__ ((weak)) EPWM1_IRQHandler(void); +void __attribute__ ((weak)) EPWM1BRK_IRQHandler(void); +void __attribute__ ((weak)) USBD_IRQHandler(void); +void __attribute__ ((weak)) USBH_IRQHandler(void); +void __attribute__ ((weak)) USB_OTG_IRQHandler(void); +void __attribute__ ((weak)) EMAC_TX_IRQHandler(void); +void __attribute__ ((weak)) EMAC_RX_IRQHandler(void); +void __attribute__ ((weak)) SPI0_IRQHandler(void); +void __attribute__ ((weak)) SPI1_IRQHandler(void); +void __attribute__ ((weak)) SPI2_IRQHandler(void); +void __attribute__ ((weak)) SPI3_IRQHandler(void); +void __attribute__ ((weak)) UART0_IRQHandler(void); +void __attribute__ ((weak)) UART1_IRQHandler(void); +void __attribute__ ((weak)) UART2_IRQHandler(void); +void __attribute__ ((weak)) UART3_IRQHandler(void); +void __attribute__ ((weak)) UART4_IRQHandler(void); +void __attribute__ ((weak)) UART5_IRQHandler(void); +void __attribute__ ((weak)) I2C0_IRQHandler(void); +void __attribute__ ((weak)) I2C1_IRQHandler(void); +void __attribute__ ((weak)) I2C2_IRQHandler(void); +void __attribute__ ((weak)) I2C3_IRQHandler(void); +void __attribute__ ((weak)) I2C4_IRQHandler(void); +void __attribute__ ((weak)) SC0_IRQHandler(void); +void __attribute__ ((weak)) SC1_IRQHandler(void); +void __attribute__ ((weak)) SC2_IRQHandler(void); +void __attribute__ ((weak)) SC3_IRQHandler(void); +void __attribute__ ((weak)) SC4_IRQHandler(void); +void __attribute__ ((weak)) SC5_IRQHandler(void); +void __attribute__ ((weak)) CAN0_IRQHandler(void); +void __attribute__ ((weak)) CAN1_IRQHandler(void); +void __attribute__ ((weak)) I2S0_IRQHandler(void); +void __attribute__ ((weak)) I2S1_IRQHandler(void); +void __attribute__ ((weak)) SD_IRQHandler(void); +void __attribute__ ((weak)) PS2D_IRQHandler(void); +void __attribute__ ((weak)) CAP_IRQHandler(void); +void __attribute__ ((weak)) CRYPTO_IRQHandler(void); +void __attribute__ ((weak)) CRC_IRQHandler(void); + +// ---------------------------------------------------------------------------- + +extern unsigned int _estack; +// defined in linker script +extern unsigned char _sidata; +// Begin address for the .data section// defined in linker script +extern unsigned char _sdata; +// End address for the .data section// defined in linker script +extern unsigned char _edata; +// Begin address for the .bss section// defined in linker script +extern unsigned char __bss_start__; +// End address for the .bss section// defined in linker script +extern unsigned char __bss_end__; + +extern int entry(void); + +typedef void (* const pHandler)(void); + +// ---------------------------------------------------------------------------- +static void Reset_Handler(void); + +// The vector table. +// This relies on the linker script to place at correct location in memory. + +__attribute__ ((section(".isr_vector"),used)) +pHandler g_pfnVectors[] = +{ + (pHandler) &_estack, // 0 The initial stack pointer + Reset_Handler, // 1 The reset handler + NMI_Handler, // 2 The NMI handler + HardFault_Handler, // 3 The hard fault handler + MemManage_Handler, // 4 Reserved + BusFault_Handler, // 5 Reserved + UsageFault_Handler, // 6 Reserved + 0, // 7 Reserved + 0, // 8 Reserved + 0, // 9 Reserved + 0, // 10 Reserved + SVC_Handler, // 11 SVCall handler + DebugMon_Handler, // 12 Reserved + 0, // 13 Reserved + PendSV_Handler, // 14 The PendSV handler + SysTick_Handler, // 15 The SysTick handler + + // ---------------------------------------------------------------------- + + BOD_IRQHandler, // 16 Brown Out detection + IRC_IRQHandler, // 17 Internal RC + PWRWU_IRQHandler, // 18 Power Down Wake Up + Default_Handler, // 19 Reserved. + CLKF_IRQHandler, // 20 CLKF + Default_Handler, // 21 Reserved. + RTC_IRQHandler, // 22 Real Time Clock + TAMPER_IRQHandler, // 23 Tamper detection + EINT0_IRQHandler, // 24 External Input 0 + EINT1_IRQHandler, // 25 External Input 1 + EINT2_IRQHandler, // 26 External Input 2 + EINT3_IRQHandler, // 27 External Input 3 + EINT4_IRQHandler, // 28 External Input 4 + EINT5_IRQHandler, // 29 External Input 5 + EINT6_IRQHandler, // 30 External Input 6 + EINT7_IRQHandler, // 31 External Input 7 + GPA_IRQHandler, // 32 GPIO Port A + GPB_IRQHandler, // 33 GPIO Port B + GPC_IRQHandler, // 34 GPIO Port C + GPD_IRQHandler, // 35 GPIO Port D + GPE_IRQHandler, // 36 GPIO Port E + GPF_IRQHandler, // 37 GPIO Port F + GPG_IRQHandler, // 38 GPIO Port G + GPH_IRQHandler, // 39 GPIO Port H + GPI_IRQHandler, // 40 GPIO Port I + Default_Handler, // 41 Reserved. + Default_Handler, // 42 Reserved. + Default_Handler, // 43 Reserved. + Default_Handler, // 44 Reserved. + Default_Handler, // 45 Reserved. + Default_Handler, // 46 Reserved. + Default_Handler, // 47 Reserved. + TMR0_IRQHandler, // 48 Timer 0 + TMR1_IRQHandler, // 49 Timer 1 + TMR2_IRQHandler, // 50 Timer 2 + TMR3_IRQHandler, // 51 Timer 3 + Default_Handler, // 52 Reserved. + Default_Handler, // 53 Reserved. + Default_Handler, // 54 Reserved. + Default_Handler, // 55 Reserved. + PDMA_IRQHandler, // 56 Peripheral DMA + Default_Handler, // 57 Reserved. + ADC_IRQHandler, // 58 ADC + Default_Handler, // 59 Reserved. + Default_Handler, // 60 Reserved. + Default_Handler, // 61 Reserved. + WDT_IRQHandler, // 62 Watch Dog Timer + WWDT_IRQHandler, // 63 Window Watch Dog Timer + EADC0_IRQHandler, // 64 EADC 0 + EADC1_IRQHandler, // 65 EADC 1 + EADC2_IRQHandler, // 66 EADC 2 + EADC3_IRQHandler, // 67 EADC 3 + Default_Handler, // 68 Reserved. + Default_Handler, // 69 Reserved. + Default_Handler, // 70 Reserved. + Default_Handler, // 71 Reserved. + ACMP_IRQHandler, // 72 Analog Comparator + Default_Handler, // 73 Reserved. + Default_Handler, // 74 Reserved. + Default_Handler, // 75 Reserved. + OPA0_IRQHandler, // 76 OPA 0 + OPA1_IRQHandler, // 77 OPA 1 + ICAP0_IRQHandler, // 78 ICAP 0 + ICAP1_IRQHandler, // 79 ICAP 1 + PWM0CH0_IRQHandler, // 80 PWMA CH0 + PWM0CH1_IRQHandler, // 81 PWMA CH1 + PWM0CH2_IRQHandler, // 82 PWMA CH2 + PWM0CH3_IRQHandler, // 83 PWMA CH3 + PWM0CH4_IRQHandler, // 84 PWMA CH4 + PWM0CH5_IRQHandler, // 85 PWMA CH5 + PWM0_BRK_IRQHandler, // 86 PWMA Brake + QEI0_IRQHandler, // 87 QEI 0 + PWM1CH0_IRQHandler, // 88 PWM1 CH0 + PWM1CH1_IRQHandler, // 89 PWM1 CH1 + PWM1CH2_IRQHandler, // 90 PWM1 CH2 + PWM1CH3_IRQHandler, // 91 PWM1 CH3 + PWM1CH4_IRQHandler, // 92 PWM1 CH4 + PWM1CH5_IRQHandler, // 93 PWM1 CH5 + PWM1_BRK_IRQHandler, // 94 PWM1 Brake + QEI1_IRQHandler, // 95 QEI 1 + EPWM0_IRQHandler, // 96 EPWM0 + EPWM0BRK_IRQHandler, // 97 EPWM0 Brake + EPWM1_IRQHandler, // 98 EPWM1 + EPWM1BRK_IRQHandler, // 99 EPWM1 Brake + Default_Handler, // 100 Reserved. + Default_Handler, // 101 Reserved. + Default_Handler, // 102 Reserved. + Default_Handler, // 103 Reserved. + USBD_IRQHandler, // 104 USB Device + USBH_IRQHandler, // 105 USB Host + USB_OTG_IRQHandler, // 106 USB OTG + Default_Handler, // 107 Reserved. + EMAC_TX_IRQHandler, // 108 Ethernet MAC TX + EMAC_RX_IRQHandler, // 109 Ethernet MAC RX + Default_Handler, // 110 Reserved. + Default_Handler, // 111 Reserved. + SPI0_IRQHandler, // 112 SPI 0 + SPI1_IRQHandler, // 113 SPI 1 + SPI2_IRQHandler, // 114 SPI 2 + SPI3_IRQHandler, // 115 SPI 3 + Default_Handler, // 116 Reserved. + Default_Handler, // 117 Reserved. + Default_Handler, // 118 Reserved. + Default_Handler, // 119 Reserved. + UART0_IRQHandler, // 120 UART 0 + UART1_IRQHandler, // 121 UART 1 + UART2_IRQHandler, // 122 UART 2 + UART3_IRQHandler, // 123 UART 3 + UART4_IRQHandler, // 124 UART 4 + UART5_IRQHandler, // 125 UART 5 + Default_Handler, // 126 Reserved. + Default_Handler, // 127 Reserved. + I2C0_IRQHandler, // 128 I2C 0 + I2C1_IRQHandler, // 129 I2C 1 + I2C2_IRQHandler, // 130 I2C 2 + I2C3_IRQHandler, // 131 I2C 3 + I2C4_IRQHandler, // 132 I2C 4 + Default_Handler, // 133 Reserved. + Default_Handler, // 134 Reserved. + Default_Handler, // 135 Reserved. + SC0_IRQHandler, // 136 Smart Card 0 + SC1_IRQHandler, // 137 Smart Card 1 + SC2_IRQHandler, // 138 Smart Card 2 + SC3_IRQHandler, // 139 Smart Card 3 + SC4_IRQHandler, // 140 Smart Card 4 + SC5_IRQHandler, // 141 Smart Card 5 + Default_Handler, // 142 Reserved. + Default_Handler, // 143 Reserved. + CAN0_IRQHandler, // 144 CAN 0 + CAN1_IRQHandler, // 145 CAN 1 + Default_Handler, // 146 Reserved. + Default_Handler, // 147 Reserved. + I2S0_IRQHandler, // 148 I2S 0 + I2S1_IRQHandler, // 149 I2S 1 + Default_Handler, // 150 Reserved. + Default_Handler, // 151 Reserved. + SD_IRQHandler, // 152 SD card + Default_Handler, // 153 Reserved. + PS2D_IRQHandler, // 154 PS/2 device + CAP_IRQHandler, // 155 CAP + CRYPTO_IRQHandler, // 156 CRYPTO + CRC_IRQHandler, // 157 CRC +}; + +void _start() +{ + memcpy(&_sdata, &_sidata, &_edata - &_sdata); + memset(&__bss_start__, 0, &__bss_end__ - &__bss_start__); +} + +static void Reset_Handler(void) +{ + _start(); + entry(); +} + +// ---------------------------------------------------------------------------- + +void __attribute__ ((section(".after_vectors"))) +Default_Handler(void) +{ + while (1) + { + } +} + +// ---------------------------------------------------------------------------- diff --git a/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/IAR/startup_NUC472_442.s b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/IAR/startup_NUC472_442.s new file mode 100644 index 0000000000000000000000000000000000000000..63c3876ad4905d3e22afa9d5e3c8e69514156aeb --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/IAR/startup_NUC472_442.s @@ -0,0 +1,481 @@ +;/****************************************************************************** +; * @file startup_NUC472_442.s +; * @version V1.00 +; * $Revision: 11 $ +; * $Date: 16/06/07 2:34p $ +; * @brief CMSIS ARM Cortex-M4 Core Device Startup File +; * +; * @note +; * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +;*****************************************************************************/ + + MODULE ?cstartup + + ;; Forward declaration of sections. + SECTION CSTACK:DATA:NOROOT(3) + + SECTION .intvec:CODE:NOROOT(2) + + EXTERN __iar_program_start + EXTERN HardFault_Handler + EXTERN SystemInit + PUBLIC __vector_table + PUBLIC __vector_table_0x1c + PUBLIC __Vectors + PUBLIC __Vectors_End + PUBLIC __Vectors_Size + + DATA + +__vector_table + DCD sfe(CSTACK) + DCD Reset_Handler + + DCD NMI_Handler + DCD HardFault_Handler + DCD MemManage_Handler + DCD BusFault_Handler + DCD UsageFault_Handler +__vector_table_0x1c + DCD 0 + DCD 0 + DCD 0 + DCD 0 + DCD SVC_Handler + DCD DebugMon_Handler + DCD 0 + DCD PendSV_Handler + DCD SysTick_Handler + + ; External Interrupts + DCD BOD_IRQHandler ; 0: Brown Out detection + DCD IRC_IRQHandler ; 1: Internal RC + DCD PWRWU_IRQHandler ; 2: Power Down Wake Up + DCD Default_Handler ; 3: Reserved. + DCD CLKF_IRQHandler ; 4: CLKF + DCD Default_Handler ; 5: Reserved. + DCD RTC_IRQHandler ; 6: Real Time Clock + DCD TAMPER_IRQHandler ; 7: Tamper detection + DCD EINT0_IRQHandler ; 8: External Input 0 + DCD EINT1_IRQHandler ; 9: External Input 1 + DCD EINT2_IRQHandler ; 10: External Input 2 + DCD EINT3_IRQHandler ; 11: External Input 3 + DCD EINT4_IRQHandler ; 12: External Input 4 + DCD EINT5_IRQHandler ; 13: External Input 5 + DCD EINT6_IRQHandler ; 14: External Input 6 + DCD EINT7_IRQHandler ; 15: External Input 7 + DCD GPA_IRQHandler ; 16: GPIO Port A + DCD GPB_IRQHandler ; 17: GPIO Port B + DCD GPC_IRQHandler ; 18: GPIO Port C + DCD GPD_IRQHandler ; 19: GPIO Port D + DCD GPE_IRQHandler ; 20: GPIO Port E + DCD GPF_IRQHandler ; 21: GPIO Port F + DCD GPG_IRQHandler ; 22: GPIO Port G + DCD GPH_IRQHandler ; 23: GPIO Port H + DCD GPI_IRQHandler ; 24: GPIO Port I + DCD Default_Handler ; 25: Reserved. + DCD Default_Handler ; 26: Reserved. + DCD Default_Handler ; 27: Reserved. + DCD Default_Handler ; 28: Reserved. + DCD Default_Handler ; 29: Reserved. + DCD Default_Handler ; 30: Reserved. + DCD Default_Handler ; 31: Reserved. + DCD TMR0_IRQHandler ; 32: Timer 0 + DCD TMR1_IRQHandler ; 33: Timer 1 + DCD TMR2_IRQHandler ; 34: Timer 2 + DCD TMR3_IRQHandler ; 35: Timer 3 + DCD Default_Handler ; 36: Reserved. + DCD Default_Handler ; 37: Reserved. + DCD Default_Handler ; 38: Reserved. + DCD Default_Handler ; 39: Reserved. + DCD PDMA_IRQHandler ; 40: Peripheral DMA + DCD Default_Handler ; 41: Reserved. + DCD ADC_IRQHandler ; 42: ADC + DCD Default_Handler ; 43: Reserved. + DCD Default_Handler ; 44: Reserved. + DCD Default_Handler ; 45: Reserved. + DCD WDT_IRQHandler ; 46: Watch Dog Timer + DCD WWDT_IRQHandler ; 47: Window Watch Dog Timer + DCD EADC0_IRQHandler ; 48: EADC 0 + DCD EADC1_IRQHandler ; 49: EADC 1 + DCD EADC2_IRQHandler ; 50: EADC 2 + DCD EADC3_IRQHandler ; 51: EADC 3 + DCD Default_Handler ; 52: Reserved. + DCD Default_Handler ; 53: Reserved. + DCD Default_Handler ; 54: Reserved. + DCD Default_Handler ; 55: Reserved. + DCD ACMP_IRQHandler ; 56: Analog Comparator + DCD Default_Handler ; 57: Reserved. + DCD Default_Handler ; 58: Reserved. + DCD Default_Handler ; 59: Reserved. + DCD OPA0_IRQHandler ; 60: OPA 0 + DCD OPA1_IRQHandler ; 61: OPA 1 + DCD ICAP0_IRQHandler ; 62: ICAP 0 + DCD ICAP1_IRQHandler ; 63: ICAP 1 + DCD PWM0CH0_IRQHandler ; 64: PWMA CH0 + DCD PWM0CH1_IRQHandler ; 65: PWMA CH1 + DCD PWM0CH2_IRQHandler ; 66: PWMA CH2 + DCD PWM0CH3_IRQHandler ; 67: PWMA CH3 + DCD PWM0CH4_IRQHandler ; 68: PWMA CH4 + DCD PWM0CH5_IRQHandler ; 69: PWMA CH5 + DCD PWM0_BRK_IRQHandler ; 70: PWMA Brake + DCD QEI0_IRQHandler ; 71: QEI 0 + DCD PWM1CH0_IRQHandler ; 72: PWM1 CH0 + DCD PWM1CH1_IRQHandler ; 73: PWM1 CH1 + DCD PWM1CH2_IRQHandler ; 74: PWM1 CH2 + DCD PWM1CH3_IRQHandler ; 75: PWM1 CH3 + DCD PWM1CH4_IRQHandler ; 76: PWM1 CH4 + DCD PWM1CH5_IRQHandler ; 77: PWM1 CH5 + DCD PWM1_BRK_IRQHandler ; 78: PWM1 Brake + DCD QEI1_IRQHandler ; 79: QEI 1 + DCD EPWM0_IRQHandler ; 80: EPWM0 + DCD EPWM0BRK_IRQHandler ; 81: EPWM0 Brake + DCD EPWM1_IRQHandler ; 82: EPWM1 + DCD EPWM1BRK_IRQHandler ; 83: EPWM1 Brake + DCD Default_Handler ; 84: Reserved. + DCD Default_Handler ; 85: Reserved. + DCD Default_Handler ; 86: Reserved. + DCD Default_Handler ; 87: Reserved. + DCD USBD_IRQHandler ; 88: USB Device + DCD USBH_IRQHandler ; 89: USB Host + DCD USB_OTG_IRQHandler ; 90: USB OTG + DCD Default_Handler ; 91: Reserved. + DCD EMAC_TX_IRQHandler ; 92: Ethernet MAC TX + DCD EMAC_RX_IRQHandler ; 93: Ethernet MAC RX + DCD Default_Handler ; 94: Reserved. + DCD Default_Handler ; 95: Reserved. + DCD SPI0_IRQHandler ; 96: SPI 0 + DCD SPI1_IRQHandler ; 97: SPI 1 + DCD SPI2_IRQHandler ; 98: SPI 2 + DCD SPI3_IRQHandler ; 99: SPI 3 + DCD Default_Handler ; 100: Reserved. + DCD Default_Handler ; 101: Reserved. + DCD Default_Handler ; 102: Reserved. + DCD Default_Handler ; 103: Reserved. + DCD UART0_IRQHandler ; 104: UART 0 + DCD UART1_IRQHandler ; 105: UART 1 + DCD UART2_IRQHandler ; 106: UART 2 + DCD UART3_IRQHandler ; 107: UART 3 + DCD UART4_IRQHandler ; 108: UART 4 + DCD UART5_IRQHandler ; 109: UART 5 + DCD Default_Handler ; 110: Reserved. + DCD Default_Handler ; 111: Reserved. + DCD I2C0_IRQHandler ; 112: I2C 0 + DCD I2C1_IRQHandler ; 113: I2C 1 + DCD I2C2_IRQHandler ; 114: I2C 2 + DCD I2C3_IRQHandler ; 115: I2C 3 + DCD I2C4_IRQHandler ; 116: I2C 4 + DCD Default_Handler ; 117: Reserved. + DCD Default_Handler ; 118: Reserved. + DCD Default_Handler ; 119: Reserved. + DCD SC0_IRQHandler ; 120: Smart Card 0 + DCD SC1_IRQHandler ; 121: Smart Card 1 + DCD SC2_IRQHandler ; 122: Smart Card 2 + DCD SC3_IRQHandler ; 123: Smart Card 3 + DCD SC4_IRQHandler ; 124: Smart Card 4 + DCD SC5_IRQHandler ; 125: Smart Card 5 + DCD Default_Handler ; 126: Reserved. + DCD Default_Handler ; 127: Reserved. + DCD CAN0_IRQHandler ; 128: CAN 0 + DCD CAN1_IRQHandler ; 129: CAN 1 + DCD Default_Handler ; 130: Reserved. + DCD Default_Handler ; 131: Reserved. + DCD I2S0_IRQHandler ; 132: I2S 0 + DCD I2S1_IRQHandler ; 133: I2S 1 + DCD Default_Handler ; 134: Reserved. + DCD Default_Handler ; 135: Reserved. + DCD SD_IRQHandler ; 136: SD card + DCD Default_Handler ; 137: Reserved. + DCD PS2D_IRQHandler ; 138: PS/2 device + DCD CAP_IRQHandler ; 139: CAP + DCD CRYPTO_IRQHandler ; 140: CRYPTO + DCD CRC_IRQHandler ; 141: CRC +__Vectors_End + +__Vectors EQU __vector_table +__Vectors_Size EQU __Vectors_End - __Vectors + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; +;; Default interrupt handlers. +;; + THUMB + + PUBWEAK Reset_Handler + SECTION .text:CODE:REORDER:NOROOT(2) +Reset_Handler + LDR R0, =SystemInit + BLX R0 + + LDR R0, =0x40000100 + ; Unlock Register + LDR R1, =0x59 + STR R1, [R0] + LDR R1, =0x16 + STR R1, [R0] + LDR R1, =0x88 + STR R1, [R0] + + ; Init POR + LDR R2, =0x40000024 + LDR R1, =0x00005AA5 + STR R1, [R2] + + ; Disable branch buffer if VCID is 0 + LDR R2, =0x40000020 + LDR R1, [R2] + CMP R1, #0 + BNE Lock + LDR R2, =0x4000C018 + LDR R1, [R2] + ORR R1, R1, #0x80 + STR R1, [R2] +Lock + ; Lock register + MOVS R1, #0 + STR R1, [R0] + + LDR R0, =__iar_program_start + BX R0 + + PUBWEAK NMI_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +NMI_Handler + B NMI_Handler + + PUBWEAK MemManage_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +MemManage_Handler + B MemManage_Handler + + PUBWEAK BusFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +BusFault_Handler + B BusFault_Handler + + PUBWEAK UsageFault_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +UsageFault_Handler + B UsageFault_Handler + + PUBWEAK SVC_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SVC_Handler + B SVC_Handler + + PUBWEAK DebugMon_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +DebugMon_Handler + B DebugMon_Handler + + PUBWEAK PendSV_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +PendSV_Handler + B PendSV_Handler + + PUBWEAK SysTick_Handler + SECTION .text:CODE:REORDER:NOROOT(1) +SysTick_Handler + B SysTick_Handler + + PUBWEAK BOD_IRQHandler + PUBWEAK IRC_IRQHandler + PUBWEAK PWRWU_IRQHandler + PUBWEAK CLKF_IRQHandler + PUBWEAK RTC_IRQHandler + PUBWEAK TAMPER_IRQHandler + PUBWEAK EINT0_IRQHandler + PUBWEAK EINT1_IRQHandler + PUBWEAK EINT2_IRQHandler + PUBWEAK EINT3_IRQHandler + PUBWEAK EINT4_IRQHandler + PUBWEAK EINT5_IRQHandler + PUBWEAK EINT6_IRQHandler + PUBWEAK EINT7_IRQHandler + PUBWEAK GPA_IRQHandler + PUBWEAK GPB_IRQHandler + PUBWEAK GPC_IRQHandler + PUBWEAK GPD_IRQHandler + PUBWEAK GPE_IRQHandler + PUBWEAK GPF_IRQHandler + PUBWEAK GPG_IRQHandler + PUBWEAK GPH_IRQHandler + PUBWEAK GPI_IRQHandler + PUBWEAK TMR0_IRQHandler + PUBWEAK TMR1_IRQHandler + PUBWEAK TMR2_IRQHandler + PUBWEAK TMR3_IRQHandler + PUBWEAK PDMA_IRQHandler + PUBWEAK ADC_IRQHandler + PUBWEAK WDT_IRQHandler + PUBWEAK WWDT_IRQHandler + PUBWEAK EADC0_IRQHandler + PUBWEAK EADC1_IRQHandler + PUBWEAK EADC2_IRQHandler + PUBWEAK EADC3_IRQHandler + PUBWEAK ACMP_IRQHandler + PUBWEAK OPA0_IRQHandler + PUBWEAK OPA1_IRQHandler + PUBWEAK ICAP0_IRQHandler + PUBWEAK ICAP1_IRQHandler + PUBWEAK PWM0CH0_IRQHandler + PUBWEAK PWM0CH1_IRQHandler + PUBWEAK PWM0CH2_IRQHandler + PUBWEAK PWM0CH3_IRQHandler + PUBWEAK PWM0CH4_IRQHandler + PUBWEAK PWM0CH5_IRQHandler + PUBWEAK PWM0_BRK_IRQHandler + PUBWEAK QEI0_IRQHandler + PUBWEAK PWM1CH0_IRQHandler + PUBWEAK PWM1CH1_IRQHandler + PUBWEAK PWM1CH2_IRQHandler + PUBWEAK PWM1CH3_IRQHandler + PUBWEAK PWM1CH4_IRQHandler + PUBWEAK PWM1CH5_IRQHandler + PUBWEAK PWM1_BRK_IRQHandler + PUBWEAK QEI1_IRQHandler + PUBWEAK EPWM0_IRQHandler + PUBWEAK EPWM0BRK_IRQHandler + PUBWEAK EPWM1_IRQHandler + PUBWEAK EPWM1BRK_IRQHandler + PUBWEAK USBD_IRQHandler + PUBWEAK USBH_IRQHandler + PUBWEAK USB_OTG_IRQHandler + PUBWEAK EMAC_TX_IRQHandler + PUBWEAK EMAC_RX_IRQHandler + PUBWEAK SPI0_IRQHandler + PUBWEAK SPI1_IRQHandler + PUBWEAK SPI2_IRQHandler + PUBWEAK SPI3_IRQHandler + PUBWEAK UART0_IRQHandler + PUBWEAK UART1_IRQHandler + PUBWEAK UART2_IRQHandler + PUBWEAK UART3_IRQHandler + PUBWEAK UART4_IRQHandler + PUBWEAK UART5_IRQHandler + PUBWEAK I2C0_IRQHandler + PUBWEAK I2C1_IRQHandler + PUBWEAK I2C2_IRQHandler + PUBWEAK I2C3_IRQHandler + PUBWEAK I2C4_IRQHandler + PUBWEAK SC0_IRQHandler + PUBWEAK SC1_IRQHandler + PUBWEAK SC2_IRQHandler + PUBWEAK SC3_IRQHandler + PUBWEAK SC4_IRQHandler + PUBWEAK SC5_IRQHandler + PUBWEAK CAN0_IRQHandler + PUBWEAK CAN1_IRQHandler + PUBWEAK I2S0_IRQHandler + PUBWEAK I2S1_IRQHandler + PUBWEAK SD_IRQHandler + PUBWEAK PS2D_IRQHandler + PUBWEAK CAP_IRQHandler + PUBWEAK CRYPTO_IRQHandler + PUBWEAK CRC_IRQHandler + SECTION .text:CODE:REORDER:NOROOT(1) + +BOD_IRQHandler +IRC_IRQHandler +PWRWU_IRQHandler +CLKF_IRQHandler +RTC_IRQHandler +TAMPER_IRQHandler +EINT0_IRQHandler +EINT1_IRQHandler +EINT2_IRQHandler +EINT3_IRQHandler +EINT4_IRQHandler +EINT5_IRQHandler +EINT6_IRQHandler +EINT7_IRQHandler +GPA_IRQHandler +GPB_IRQHandler +GPC_IRQHandler +GPD_IRQHandler +GPE_IRQHandler +GPF_IRQHandler +GPG_IRQHandler +GPH_IRQHandler +GPI_IRQHandler +TMR0_IRQHandler +TMR1_IRQHandler +TMR2_IRQHandler +TMR3_IRQHandler +PDMA_IRQHandler +ADC_IRQHandler +WDT_IRQHandler +WWDT_IRQHandler +EADC0_IRQHandler +EADC1_IRQHandler +EADC2_IRQHandler +EADC3_IRQHandler +ACMP_IRQHandler +OPA0_IRQHandler +OPA1_IRQHandler +ICAP0_IRQHandler +ICAP1_IRQHandler +PWM0CH0_IRQHandler +PWM0CH1_IRQHandler +PWM0CH2_IRQHandler +PWM0CH3_IRQHandler +PWM0CH4_IRQHandler +PWM0CH5_IRQHandler +PWM0_BRK_IRQHandler +QEI0_IRQHandler +PWM1CH0_IRQHandler +PWM1CH1_IRQHandler +PWM1CH2_IRQHandler +PWM1CH3_IRQHandler +PWM1CH4_IRQHandler +PWM1CH5_IRQHandler +PWM1_BRK_IRQHandler +QEI1_IRQHandler +EPWM0_IRQHandler +EPWM0BRK_IRQHandler +EPWM1_IRQHandler +EPWM1BRK_IRQHandler +USBD_IRQHandler +USBH_IRQHandler +USB_OTG_IRQHandler +EMAC_TX_IRQHandler +EMAC_RX_IRQHandler +SPI0_IRQHandler +SPI1_IRQHandler +SPI2_IRQHandler +SPI3_IRQHandler +UART0_IRQHandler +UART1_IRQHandler +UART2_IRQHandler +UART3_IRQHandler +UART4_IRQHandler +UART5_IRQHandler +I2C0_IRQHandler +I2C1_IRQHandler +I2C2_IRQHandler +I2C3_IRQHandler +I2C4_IRQHandler +SC0_IRQHandler +SC1_IRQHandler +SC2_IRQHandler +SC3_IRQHandler +SC4_IRQHandler +SC5_IRQHandler +CAN0_IRQHandler +CAN1_IRQHandler +I2S0_IRQHandler +I2S1_IRQHandler +SD_IRQHandler +PS2D_IRQHandler +CAP_IRQHandler +CRYPTO_IRQHandler +CRC_IRQHandler +Default_Handler + B Default_Handler + + + + + END +;/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/system_NUC472_442.c b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/system_NUC472_442.c new file mode 100644 index 0000000000000000000000000000000000000000..02f0beb4cc41cb79bfd8c51137b60335f35b5df3 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/Device/Nuvoton/NUC472_442/Source/system_NUC472_442.c @@ -0,0 +1,66 @@ +/**************************************************************************//** + * @file system_NUC472_442.c + * @version V1.00 + * $Revision: 17 $ + * $Date: 15/04/20 8:54a $ + * @brief NUC472/NUC442 system clock init code and assert handler + * + * @note + * Copyright (C) 2013~2015 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/*---------------------------------------------------------------------------- + Clock Variable definitions + *----------------------------------------------------------------------------*/ +uint32_t SystemCoreClock = __HSI; /*!< System Clock Frequency (Core Clock)*/ +uint32_t CyclesPerUs = (__HSI / 1000000); /*!< Cycles per micro second */ +uint32_t gau32ClkSrcTbl[] = {__HXT, __LXT, 0, __LIRC, 0, 0, 0, __HIRC}; /*!< System clock source table */ + + + +/*---------------------------------------------------------------------------- + Clock functions + *----------------------------------------------------------------------------*/ +void SystemCoreClockUpdate (void) /* Get Core Clock Frequency */ +{ + uint32_t u32Freq, u32ClkSrc; + uint32_t u32HclkDiv; + + u32ClkSrc = CLK->CLKSEL0 & CLK_CLKSEL0_HCLKSEL_Msk; + + if(u32ClkSrc != CLK_CLKSEL0_HCLKSEL_PLL) { + /* Use the clock sources directly */ + u32Freq = gau32ClkSrcTbl[u32ClkSrc]; + } else { + /* Use PLL clock */ + u32Freq = CLK_GetPLLClockFreq(); + } + + u32HclkDiv = (CLK->CLKDIV0 & CLK_CLKDIV0_HCLKDIV_Msk) + 1; + + /* Update System Core Clock */ + SystemCoreClock = u32Freq/u32HclkDiv; + + CyclesPerUs = (SystemCoreClock + 500000) / 1000000; +} + +/** + * Initialize the system + * + * @return none + * + * @brief Setup the micro controller system. + */ +void SystemInit (void) +{ + + /* FPU settings ------------------------------------------------------------*/ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */ + (3UL << 11*2) ); /* set CP11 Full Access */ +#endif + + +} +/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/Device/SConscript b/bsp/nuvoton_nuc472/Libraries/Device/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..3bd56ea9fe880696c34b4edfff4816354de5fe3c --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/Device/SConscript @@ -0,0 +1,25 @@ +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(""" +Nuvoton/NUC472_442/Source/system_NUC472_442.c +""") + +# add for startup script +if rtconfig.CROSS_TOOL == 'gcc': + src = src + ['Nuvoton/NUC472_442/Source/GCC/startup.c'] +elif rtconfig.CROSS_TOOL == 'keil': + src = src + ['Nuvoton/NUC472_442/Source/ARM/startup_NUC472_442.s'] +elif rtconfig.CROSS_TOOL == 'iar': + src = src + ['Nuvoton/NUC472_442/Source/IAR/startup_NUC472_442.s'] + +path = [cwd + '/Nuvoton/NUC472_442/Include',] + +group = DefineGroup('CMSIS', src, depend = [''], CPPPATH = path) + +Return('group') diff --git a/bsp/nuvoton_nuc472/Libraries/SConscript b/bsp/nuvoton_nuc472/Libraries/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..4c815c49b835a3a5ea61f337dc17154dd316d7d1 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/SConscript @@ -0,0 +1,15 @@ +# RT-Thread building script for bridge + +import os +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/nuvoton_nuc472/Libraries/StdDriver/SConscript b/bsp/nuvoton_nuc472/Libraries/StdDriver/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..fdb5eed3723913944d84f54f550231fece506eae --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*src/*.c') + Glob('src/*.cpp') +CPPPATH = [cwd + '/inc'] + +group = DefineGroup('NUC472_StdPeriph', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/acmp.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/acmp.h new file mode 100644 index 0000000000000000000000000000000000000000..3645fb405eef84335724433e6e5e5e7c399281ce --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/acmp.h @@ -0,0 +1,333 @@ +/**************************************************************************//** + * @file acmp.h + * @version V1.00 + * $Revision: 5 $ + * $Date: 15/11/04 7:29p $ + * @brief NUC472/NUC442 Analog Comparator(ACMP) driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#ifndef __ACMP_H__ +#define __ACMP_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_ACMP_Driver ACMP Driver + @{ +*/ + +/** @addtogroup NUC472_442_ACMP_EXPORTED_CONSTANTS ACMP Exported Constants + @{ +*/ + +/*---------------------------------------------------------------------------------------------------------*/ +/* ACMP_CR constant definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define ACMP_VNEG_PIN (0xFFUL) ///< Selecting the voltage of ACMP negative input pin as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_BANDGAP (0x00UL) ///< Selecting band-gap voltage as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_4_OVER_24_VDD (0x80UL) ///< Selecting 4/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_5_OVER_24_VDD (0x81UL) ///< Selecting 5/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_6_OVER_24_VDD (0x82UL) ///< Selecting 6/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_7_OVER_24_VDD (0x83UL) ///< Selecting 7/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_8_OVER_24_VDD (0x84UL) ///< Selecting 8/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_9_OVER_24_VDD (0x85UL) ///< Selecting 9/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_10_OVER_24_VDD (0x86UL) ///< Selecting 10/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_11_OVER_24_VDD (0x87UL) ///< Selecting 11/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_12_OVER_24_VDD (0x88UL) ///< Selecting 12/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_13_OVER_24_VDD (0x89UL) ///< Selecting 13/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_14_OVER_24_VDD (0x8AUL) ///< Selecting 14/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_15_OVER_24_VDD (0x8BUL) ///< Selecting 15/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_16_OVER_24_VDD (0x8CUL) ///< Selecting 16/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_17_OVER_24_VDD (0x8DUL) ///< Selecting 17/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_18_OVER_24_VDD (0x8EUL) ///< Selecting 18/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_19_OVER_24_VDD (0x8FUL) ///< Selecting 19/24 VDD as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_4_OVER_24_IREF (0xC0UL) ///< Selecting 4/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_5_OVER_24_IREF (0xC1UL) ///< Selecting 5/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_6_OVER_24_IREF (0xC2UL) ///< Selecting 6/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_7_OVER_24_IREF (0xC3UL) ///< Selecting 7/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_8_OVER_24_IREF (0xC4UL) ///< Selecting 8/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_9_OVER_24_IREF (0xC5UL) ///< Selecting 9/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_10_OVER_24_IREF (0xC6UL) ///< Selecting 10/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_11_OVER_24_IREF (0xC7UL) ///< Selecting 11/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_12_OVER_24_IREF (0xC8UL) ///< Selecting 12/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_13_OVER_24_IREF (0xC9UL) ///< Selecting 13/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_14_OVER_24_IREF (0xCAUL) ///< Selecting 14/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_15_OVER_24_IREF (0xCBUL) ///< Selecting 15/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_16_OVER_24_IREF (0xCCUL) ///< Selecting 16/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_17_OVER_24_IREF (0xCDUL) ///< Selecting 17/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_18_OVER_24_IREF (0xCEUL) ///< Selecting 18/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_VNEG_19_OVER_24_IREF (0xCFUL) ///< Selecting 19/24 IREF as the source of ACMP V- \hideinitializer +#define ACMP_HYSTERESIS_ENABLE (1UL << ACMP_CTL_HYSEN_Pos) ///< Enable hysteresis function \hideinitializer +#define ACMP_HYSTERESIS_DISABLE (0UL) ///< Disable hysteresis function \hideinitializer +#define ACMP_CH0_POSPIN_P0 (0UL) ///< Selecting ACMP0_P0 as ACMP Channel 0 positive input source \hideinitializer +#define ACMP_CH0_POSPIN_P1 (1UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP0_P1 as ACMP Channel 0 positive input source \hideinitializer +#define ACMP_CH0_POSPIN_P2 (2UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP0_P2 as ACMP Channel 0 positive input source \hideinitializer +#define ACMP_CH0_POSPIN_P3 (3UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP0_P3 as ACMP Channel 0 positive input source \hideinitializer +#define ACMP_CH0_POS_OPA0 (4UL << ACMP_CTL_POSSEL_Pos) ///< Selecting OPA0 as ACMP Channel 0 positive input source \hideinitializer +#define ACMP_CH1_POSPIN_P0 (0UL) ///< Selecting ACMP1_P0 as ACMP Channel 1 positive input source \hideinitializer +#define ACMP_CH1_POSPIN_P1 (1UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP1_P1 as ACMP Channel 1 positive input source \hideinitializer +#define ACMP_CH1_POSPIN_P2 (2UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP1_P2 as ACMP Channel 1 positive input source \hideinitializer +#define ACMP_CH1_POSPIN_P3 (3UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP1_P3 as ACMP Channel 1 positive input source \hideinitializer +#define ACMP_CH1_POS_OPA1 (4UL << ACMP_CTL_POSSEL_Pos) ///< Selecting OPA1 as ACMP Channel 1 positive input source \hideinitializer +#define ACMP_CH2_POSPIN_P0 (0UL) ///< Selecting ACMP2_P0 as ACMP Channel 2 positive input source \hideinitializer +#define ACMP_CH2_POSPIN_P1 (1UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP2_P1 as ACMP Channel 2 positive input source \hideinitializer +#define ACMP_CH2_POSPIN_P2 (2UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP2_P2 as ACMP Channel 2 positive input source \hideinitializer +#define ACMP_CH2_POSPIN_P3 (3UL << ACMP_CTL_POSSEL_Pos) ///< Selecting ACMP2_P3 as ACMP Channel 2 positive input source \hideinitializer + + +/*@}*/ /* end of group NUC472_442_ACMP_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_ACMP_EXPORTED_FUNCTIONS ACMP Exported Functions + @{ +*/ + +/** + * @brief This macro is used to select ACMP negative input source + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @param[in] u32Src is comparator negative input selection. Including : + * - \ref ACMP_VNEG_PIN + * - \ref ACMP_VNEG_BANDGAP + * - \ref ACMP_VNEG_4_OVER_24_VDD + * - \ref ACMP_VNEG_5_OVER_24_VDD + * - \ref ACMP_VNEG_6_OVER_24_VDD + * - \ref ACMP_VNEG_7_OVER_24_VDD + * - \ref ACMP_VNEG_8_OVER_24_VDD + * - \ref ACMP_VNEG_9_OVER_24_VDD + * - \ref ACMP_VNEG_10_OVER_24_VDD + * - \ref ACMP_VNEG_11_OVER_24_VDD + * - \ref ACMP_VNEG_12_OVER_24_VDD + * - \ref ACMP_VNEG_13_OVER_24_VDD + * - \ref ACMP_VNEG_14_OVER_24_VDD + * - \ref ACMP_VNEG_15_OVER_24_VDD + * - \ref ACMP_VNEG_16_OVER_24_VDD + * - \ref ACMP_VNEG_17_OVER_24_VDD + * - \ref ACMP_VNEG_18_OVER_24_VDD + * - \ref ACMP_VNEG_19_OVER_24_VDD + * - \ref ACMP_VNEG_4_OVER_24_IREF + * - \ref ACMP_VNEG_5_OVER_24_IREF + * - \ref ACMP_VNEG_6_OVER_24_IREF + * - \ref ACMP_VNEG_7_OVER_24_IREF + * - \ref ACMP_VNEG_8_OVER_24_IREF + * - \ref ACMP_VNEG_9_OVER_24_IREF + * - \ref ACMP_VNEG_10_OVER_24_IREF + * - \ref ACMP_VNEG_11_OVER_24_IREF + * - \ref ACMP_VNEG_12_OVER_24_IREF + * - \ref ACMP_VNEG_13_OVER_24_IREF + * - \ref ACMP_VNEG_14_OVER_24_IREF + * - \ref ACMP_VNEG_15_OVER_24_IREF + * - \ref ACMP_VNEG_16_OVER_24_IREF + * - \ref ACMP_VNEG_17_OVER_24_IREF + * - \ref ACMP_VNEG_18_OVER_24_IREF + * - \ref ACMP_VNEG_19_OVER_24_IREF + * + * @return None + * @note The V- setting is shared by all comparators if input source is not coming from PIN + * \hideinitializer + */ +#define ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src) do{\ + if(u32Src == ACMP_VNEG_PIN)\ + ACMP->CTL[u32ChNum] &= ~ACMP_CTL_NEGSEL_Msk;\ + else {\ + ACMP->CTL[u32ChNum] |= ACMP_CTL_NEGSEL_Msk;\ + ACMP->VREF = u32Src;\ + }\ + }while(0) + +/** + * @brief This macro is used to enable hysteresis function + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_HYSEN_Msk) + +/** + * @brief This macro is used to disable hysteresis function + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_HYSEN_Msk) + +/** + * @brief This macro is used to enable interrupt + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_ENABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPIE_Msk) + +/** + * @brief This macro is used to disable interrupt + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_DISABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPIE_Msk) + + +/** + * @brief This macro is used to enable ACMP + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_ENABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPEN_Msk) + +/** + * @brief This macro is used to disable ACMP + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_DISABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPEN_Msk) + +/** + * @brief This macro is used to get ACMP output value + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return 1 or 0 + * \hideinitializer + */ +#define ACMP_GET_OUTPUT(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPO0_Msk<<(u32ChNum))?1:0) + +/** + * @brief This macro is used to get ACMP interrupt flag + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return ACMP interrupt occurred or not + * \hideinitializer + */ +#define ACMP_GET_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum))?1:0) + +/** + * @brief This macro is used to clear ACMP interrupt flag + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_CLR_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS = (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum))) + +/** + * @brief This macro is used to select the V+ pin of ACMP + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @param[in] u32Pin The input pin. For channel 0, valid values are \ref ACMP_CH0_POSPIN_P0, + * \ref ACMP_CH0_POSPIN_P1, \ref ACMP_CH0_POSPIN_P2, \ref ACMP_CH0_POSPIN_P3, and \ref ACMP_CH0_POS_OPA0. + * For channel 1, valid values are , \ref ACMP_CH1_POSPIN_P0, \ref ACMP_CH1_POSPIN_P1, \ref ACMP_CH1_POSPIN_P2, + * \ref ACMP_CH1_POSPIN_P3, and \ref ACMP_CH1_POS_OPA1. For channel 2, valid values are , \ref ACMP_CH2_POSPIN_P0, + * \ref ACMP_CH2_POSPIN_P1, \ref ACMP_CH2_POSPIN_P2, and \ref ACMP_CH2_POSPIN_P3. + * @return None + * @note Except this setting, multi-function pin also needs to be configured + * \hideinitializer + */ +#define ACMP_SELECT_P(acmp, u32ChNum, u32Pin) (ACMP->CTL[u32ChNum] = (ACMP->CTL[u32ChNum] & ~ACMP_CTL_POSSEL_Msk) | u32Pin) +/** + * @brief This macro is used to set the level of CRV (Comparator Reference Voltage) + * @param[in] acmp The base address of ACMP module + * @param[in] u32Level CRV level, possible values are + * - \ref ACMP_VNEG_4_OVER_24_VDD + * - \ref ACMP_VNEG_5_OVER_24_VDD + * - \ref ACMP_VNEG_6_OVER_24_VDD + * - \ref ACMP_VNEG_7_OVER_24_VDD + * - \ref ACMP_VNEG_8_OVER_24_VDD + * - \ref ACMP_VNEG_9_OVER_24_VDD + * - \ref ACMP_VNEG_10_OVER_24_VDD + * - \ref ACMP_VNEG_11_OVER_24_VDD + * - \ref ACMP_VNEG_12_OVER_24_VDD + * - \ref ACMP_VNEG_13_OVER_24_VDD + * - \ref ACMP_VNEG_14_OVER_24_VDD + * - \ref ACMP_VNEG_15_OVER_24_VDD + * - \ref ACMP_VNEG_16_OVER_24_VDD + * - \ref ACMP_VNEG_17_OVER_24_VDD + * - \ref ACMP_VNEG_18_OVER_24_VDD + * - \ref ACMP_VNEG_19_OVER_24_VDD + * - \ref ACMP_VNEG_4_OVER_24_IREF + * - \ref ACMP_VNEG_5_OVER_24_IREF + * - \ref ACMP_VNEG_6_OVER_24_IREF + * - \ref ACMP_VNEG_7_OVER_24_IREF + * - \ref ACMP_VNEG_8_OVER_24_IREF + * - \ref ACMP_VNEG_9_OVER_24_IREF + * - \ref ACMP_VNEG_10_OVER_24_IREF + * - \ref ACMP_VNEG_11_OVER_24_IREF + * - \ref ACMP_VNEG_12_OVER_24_IREF + * - \ref ACMP_VNEG_13_OVER_24_IREF + * - \ref ACMP_VNEG_14_OVER_24_IREF + * - \ref ACMP_VNEG_15_OVER_24_IREF + * - \ref ACMP_VNEG_16_OVER_24_IREF + * - \ref ACMP_VNEG_17_OVER_24_IREF + * - \ref ACMP_VNEG_18_OVER_24_IREF + * - \ref ACMP_VNEG_19_OVER_24_IREF + * @return None + * @note This macro does not enable CRV. Please use \ref ACMP_ENABLE_CRV to enable CRV. + * \hideinitializer + */ +#define ACMP_CRV_SEL(acmp, u32Level) (ACMP->VREF = (ACMP->VREF & ~(ACMP_VREF_CRVSSEL_Msk | ACMP_VREF_CRVCTL_Msk)) | (u32Level)) +/** + * @brief This macro is used to enable CRV(Comparator Reference Voltage) + * @param[in] acmp The base address of ACMP module + * @return None + * \hideinitializer + */ +#define ACMP_ENABLE_CRV(acmp) (ACMP->VREF |= ACMP_VREF_IREFSEL_Msk) +/** + * @brief This macro is used to disable CRV(Comparator Reference Voltage) + * @param[in] acmp The base address of ACMP module + * @return None + * \hideinitializer + */ +#define ACMP_DISABLE_CRV(acmp) (ACMP->VREF &= ~ACMP_VREF_IREFSEL_Msk) + +/** + * @brief This macro is used to enable ACMP output inverse function + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_ENABLE_OUTPUT_INVERSE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPOINV_Msk) + +/** + * @brief This macro is used to disable ACMP output inverse function + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum The ACMP number, could 0, 1, or 2 + * @return None + * \hideinitializer + */ +#define ACMP_DISABLE_OUTPUT_INVERSE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPOINV_Msk) + + +void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn); +void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum); + +/*@}*/ /* end of group NUC472_442_ACMP_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_ACMP_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__ACMP_H__ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/adc.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/adc.h new file mode 100644 index 0000000000000000000000000000000000000000..5a15270de553b5e3bb368c199b05365734b50d56 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/adc.h @@ -0,0 +1,305 @@ +/**************************************************************************//** + * @file adc.h + * @version V1.00 + * $Revision: 23 $ + * $Date: 15/11/16 2:12p $ + * @brief NUC472/NUC442 ADC driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __ADC_H__ +#define __ADC_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_ADC_Driver ADC Driver + @{ +*/ + +/** @addtogroup NUC472_442_ADC_EXPORTED_CONSTANTS ADC Exported Constants + @{ +*/ + +#define ADC_CH_0_MASK (1UL << 0) /*!< ADC channel 0 mask \hideinitializer */ +#define ADC_CH_1_MASK (1UL << 1) /*!< ADC channel 1 mask \hideinitializer */ +#define ADC_CH_2_MASK (1UL << 2) /*!< ADC channel 2 mask \hideinitializer */ +#define ADC_CH_3_MASK (1UL << 3) /*!< ADC channel 3 mask \hideinitializer */ +#define ADC_CH_4_MASK (1UL << 4) /*!< ADC channel 4 mask \hideinitializer */ +#define ADC_CH_5_MASK (1UL << 5) /*!< ADC channel 5 mask \hideinitializer */ +#define ADC_CH_6_MASK (1UL << 6) /*!< ADC channel 6 mask \hideinitializer */ +#define ADC_CH_7_MASK (1UL << 7) /*!< ADC channel 7 mask \hideinitializer */ +#define ADC_CH_8_MASK (1UL << 8) /*!< ADC channel 8 mask \hideinitializer */ +#define ADC_CH_9_MASK (1UL << 9) /*!< ADC channel 9 mask \hideinitializer */ +#define ADC_CH_10_MASK (1UL << 10) /*!< ADC channel 10 mask \hideinitializer */ +#define ADC_CH_11_MASK (1UL << 11) /*!< ADC channel 11 mask \hideinitializer */ +#define ADC_CH_BG_MASK (1UL << 16) /*!< ADC channel 12 (band-gap ) mask \hideinitializer */ +#define ADC_CH_TS_MASK (1UL << 17) /*!< ADC channel 13 (temperature sensor) mask \hideinitializer */ +#define ADC_CMP_LESS_THAN (0UL) /*!< ADC compare condition less than \hideinitializer */ +#define ADC_CMP_GREATER_OR_EQUAL_TO (ADC_CMP0_CMPCOND_Msk) /*!< ADC compare condition greater or equal to \hideinitializer */ +#define ADC_TRIGGER_BY_EXT_PIN (0UL) /*!< ADC trigger by STADC pin \hideinitializer */ +#define ADC_TRIGGER_BY_PWM (ADC_CTL_HWTRGSEL_Msk) /*!< ADC trigger by PWM events \hideinitializer */ +#define ADC_LOW_LEVEL_TRIGGER (0UL << ADC_CTL_HWTRGCOND_Pos) /*!< External pin low level trigger ADC \hideinitializer */ +#define ADC_HIGH_LEVEL_TRIGGER (1UL << ADC_CTL_HWTRGCOND_Pos) /*!< External pin high level trigger ADC \hideinitializer */ +#define ADC_FALLING_EDGE_TRIGGER (2UL << ADC_CTL_HWTRGCOND_Pos) /*!< External pin falling edge trigger ADC \hideinitializer */ +#define ADC_RISING_EDGE_TRIGGER (3UL << ADC_CTL_HWTRGCOND_Pos) /*!< External pin rising edge trigger ADC \hideinitializer */ +#define ADC_ADF_INT (ADC_STATUS0_ADIF_Msk) /*!< ADC convert complete interrupt \hideinitializer */ +#define ADC_CMP0_INT (ADC_STATUS0_ADCMPF0_Msk) /*!< ADC comparator 0 interrupt \hideinitializer */ +#define ADC_CMP1_INT (ADC_STATUS0_ADCMPF1_Msk) /*!< ADC comparator 1 interrupt \hideinitializer */ +#define ADC_INPUT_MODE_SINGLE_END (0UL << ADC_CTL_DIFFEN_Pos) /*!< ADC input mode set to single end \hideinitializer */ +#define ADC_INPUT_MODE_DIFFERENTIAL (1UL << ADC_CTL_DIFFEN_Pos) /*!< ADC input mode set to differential \hideinitializer */ +#define ADC_OPERATION_MODE_SINGLE (0UL << ADC_CTL_OPMODE_Pos) /*!< ADC operation mode set to single conversion \hideinitializer */ +#define ADC_OPERATION_MODE_SINGLE_CYCLE (2UL << ADC_CTL_OPMODE_Pos) /*!< ADC operation mode set to single cycle scan \hideinitializer */ +#define ADC_OPERATION_MODE_CONTINUOUS (3UL << ADC_CTL_OPMODE_Pos) /*!< ADC operation mode set to continuous scan \hideinitializer */ +#define ADC_DMODE_OUT_FORMAT_UNSIGNED (0UL << ADC_CTL_DMOF_Pos) /*!< ADC differential mode output format with unsigned \hideinitializer */ +#define ADC_DMODE_OUT_FORMAT_2COMPLEMENT (1UL << ADC_CTL_DMOF_Pos) /*!< ADC differential mode output format with 2's complement \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_ADC_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_ADC_EXPORTED_FUNCTIONS ADC Exported Functions + @{ +*/ + +/** + * @brief Get the latest ADC conversion data + * @param[in] adc Base address of ADC module + * @param[in] u32ChNum Channel number + * @return Latest ADC conversion data + * \hideinitializer + */ +#define ADC_GET_CONVERSION_DATA(adc, u32ChNum) ( ADC->DAT[u32ChNum] & ADC_DAT0_RESULT_Msk) + +/** + * @brief Return the user-specified interrupt flags + * @param[in] adc Base address of ADC module + * @param[in] u32Mask The combination of following interrupt status bits. Each bit corresponds to a interrupt status. + * - \ref ADC_ADF_INT + * - \ref ADC_CMP0_INT + * - \ref ADC_CMP1_INT + * @return User specified interrupt flags + * \hideinitializer + */ +#define ADC_GET_INT_FLAG(adc, u32Mask) (ADC->STATUS0 & (u32Mask)) + +/** + * @brief This macro clear the selected interrupt status bits + * @param[in] adc Base address of ADC module + * @param[in] u32Mask The combination of following interrupt status bits. Each bit corresponds to a interrupt status. + * - \ref ADC_ADF_INT + * - \ref ADC_CMP0_INT + * - \ref ADC_CMP1_INT + * @return None + * \hideinitializer + */ +#define ADC_CLR_INT_FLAG(adc, u32Mask) (ADC->STATUS0 = (ADC->STATUS0 & ~(ADC_STATUS0_ADIF_Msk | \ + ADC_STATUS0_ADCMPF0_Msk | \ + ADC_STATUS0_ADCMPF1_Msk)) | (u32Mask)) + +/** + * @brief Get the busy state of ADC + * @param[in] adc Base address of ADC module + * @return busy state of ADC + * @retval 0 ADC is not busy + * @retval 1 ADC is busy + * \hideinitializer + */ +#define ADC_IS_BUSY(adc) (ADC->STATUS0 & ADC_STATUS0_BUSY_Msk ? 1 : 0) + +/** + * @brief Check if the ADC conversion data is over written or not + * @param[in] adc Base address of ADC module + * @param[in] u32ChNum Currently not used + * @return Over run state of ADC data + * @retval 0 ADC data is not overrun + * @retval 1 ADC data us overrun + * \hideinitializer + */ +#define ADC_IS_DATA_OVERRUN(adc, u32ChNum) (ADC->STATUS1 & ( 1 << (ADC_STATUS1_OV_Pos + u32ChNum)) ? 1 : 0) + +/** + * @brief Check if the ADC conversion data is valid or not + * @param[in] adc Base address of ADC module + * @param[in] u32ChNum Currently not used + * @return Valid state of ADC data + * @retval 0 ADC data is not valid + * @retval 1 ADC data us valid + * \hideinitializer + */ +#define ADC_IS_DATA_VALID(adc, u32ChNum) (ADC->STATUS1 & ( 1 << (ADC_STATUS1_VALID_Pos + u32ChNum)) ? 1 : 0) + +/** + * @brief Power down ADC module + * @param[in] adc Base address of ADC module + * @return None + * \hideinitializer + */ +#define ADC_POWER_DOWN(adc) (ADC->CTL &= ~ADC_CTL_ADCEN_Msk) + +/** + * @brief Power on ADC module + * @param[in] adc Base address of ADC module + * @return None + * \hideinitializer + */ +#define ADC_POWER_ON(adc) (ADC->CTL |= ADC_CTL_ADCEN_Msk) + +/** + * @brief Configure the comparator 0 and enable it + * @param[in] adc Base address of ADC module + * @param[in] u32ChNum Specifies the source channel, valid value are from 0 to 7 + * @param[in] u32Condition Specifies the compare condition + * - \ref ADC_CMP_LESS_THAN + * - \ref ADC_CMP_GREATER_OR_EQUAL_TO + * @param[in] u32Data Specifies the compare value. Valid value are between 0 ~ 0x3FF + * @param[in] u32MatchCount Specifies the match count setting, valid values are between 1~16 + * @return None + * @details For example, ADC_ENABLE_CMP0(ADC, 5, ADC_CMP_GREATER_OR_EQUAL_TO, 0x800, 10); + * Means ADC will assert comparator 0 flag if channel 5 conversion result is + * greater or equal to 0x800 for 10 times continuously. + * \hideinitializer + */ +#define ADC_ENABLE_CMP0(adc, \ + u32ChNum, \ + u32Condition, \ + u32Data, \ + u32MatchCount) (ADC->CMP[0] = ((u32ChNum) << ADC_CMP0_CMPCH_Pos) | \ + (u32Condition) | \ + ((u32Data) << ADC_CMP0_CMPDAT_Pos) | \ + (((u32MatchCount) - 1) << ADC_CMP0_CMPMCNT_Pos) |\ + ADC_CMP0_ADCMPEN_Msk) + +/** + * @brief Disable comparator 0 + * @param[in] adc Base address of ADC module + * \hideinitializer + */ +#define ADC_DISABLE_CMP0(adc) (ADC->CMP[0] = 0) + +/** + * @brief Configure the comparator 1 and enable it + * @param[in] adc Base address of ADC module + * @param[in] u32ChNum Specifies the source channel, valid value are from 0 to 7 + * @param[in] u32Condition Specifies the compare condition + * - \ref ADC_CMP_LESS_THAN + * - \ref ADC_CMP_GREATER_OR_EQUAL_TO + * @param[in] u32Data Specifies the compare value. Valid value are between 0 ~ 0x3FF + * @param[in] u32MatchCount Specifies the match count setting, valid values are between 1~16 + * @return None + * @details For example, ADC_ENABLE_CMP1(ADC, 5, ADC_CMP_GREATER_OR_EQUAL_TO, 0x800, 10); + * Means ADC will assert comparator 1 flag if channel 5 conversion result is + * greater or equal to 0x800 for 10 times continuously. + * \hideinitializer + */ +#define ADC_ENABLE_CMP1(adc, \ + u32ChNum, \ + u32Condition, \ + u32Data, \ + u32MatchCount) (ADC->CMP[1] = ((u32ChNum) << ADC_CMP1_CMPCH_Pos) | \ + (u32Condition) | \ + ((u32Data) << ADC_CMP1_CMPDAT_Pos) | \ + ((u32MatchCount - 1) << ADC_CMP1_CMPMCNT_Pos) |\ + ADC_CMP1_ADCMPEN_Msk) + +/** + * @brief Disable comparator 1 + * @param[in] adc Base address of ADC module + * \hideinitializer + */ +#define ADC_DISABLE_CMP1(adc) (ADC->CMP[1] = 0) + +/** + * @brief Set ADC input channel. Enabled channel will be converted while ADC starts. + * @param[in] adc Base address of ADC module + * @param[in] u32Mask Channel enable bit. Each bit corresponds to a input channel. Bit 0 is channel 0, bit 1 is channel 1... + * @return None + * \hideinitializer + */ +#define ADC_SET_INPUT_CHANNEL(adc, u32Mask) (ADC->CHEN = (ADC->CHEN & ~ADC_CHEN_CHEN_Msk) | (u32Mask)) + +/** + * @brief Start the A/D conversion. + * @param[in] adc Base address of ADC module + * @return None + * \hideinitializer + */ +#define ADC_START_CONV(adc) (ADC->CTL |= ADC_CTL_SWTRG_Msk) + +/** + * @brief Stop the A/D conversion. + * @param[in] adc Base address of ADC module + * @return None + * \hideinitializer + */ +#define ADC_STOP_CONV(adc) (ADC->CTL &= ~ADC_CTL_SWTRG_Msk) + +/** + * @brief Set the output format in differential input mode. + * @param[in] adc Base address of ADC module + * @param[in] u32Format Differential input mode output format. Valid values are: + * - \ref ADC_DMODE_OUT_FORMAT_UNSIGNED + * - \ref ADC_DMODE_OUT_FORMAT_2COMPLEMENT + * @return None + * \hideinitializer + */ +#define ADC_SET_DMOF(adc, u32Format) (ADC->CTL = (ADC->CTL & ~ADC_CTL_DMOF_Msk) | u32Format) + +/** + * @brief Enable PDMA transfer. + * @param[in] adc Base address of ADC module + * @return None + * \hideinitializer + */ +#define ADC_ENABLE_PDMA(adc) (ADC->CTL |= ADC_CTL_PDMAEN_Msk) + +/** + * @brief Disable PDMA transfer. + * @param[in] adc Base address of ADC module + * @return None + * \hideinitializer + */ +#define ADC_DISABLE_PDMA(adc) (ADC->CTL &= ~ADC_CTL_PDMAEN_Msk) + +/** + * @brief Get PDMA current transfer data + * @param[in] adc Base address of ADC module + * @return PDMA current transfer data + * \hideinitializer + */ +#define ADC_GET_PDMA_DATA(adc) ( ADC->CURDAT & ADC_CURDAT_CURDAT_Msk) + +void ADC_Open(ADC_T *adc, + uint32_t u32InputMode, + uint32_t u32OpMode, + uint32_t u32ChMask); +void ADC_Close(ADC_T *adc); +void ADC_EnableHWTrigger(ADC_T *adc, + uint32_t u32Source, + uint32_t u32Param); +void ADC_DisableHWTrigger(ADC_T *adc); +void ADC_EnableInt(ADC_T *adc, uint32_t u32Mask); +void ADC_DisableInt(ADC_T *adc, uint32_t u32Mask); + + + +/*@}*/ /* end of group NUC472_442_ADC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_ADC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__ADC_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/can.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/can.h new file mode 100644 index 0000000000000000000000000000000000000000..4d48711975164baffd3165cc296e28766318304e --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/can.h @@ -0,0 +1,171 @@ +/**************************************************************************//** + * @file can.h + * @version V1.00 + * $Revision: 8 $ + * $Date: 14/09/26 3:38p $ + * @brief NUC472/NUC442 CAN driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#ifndef __CAN_H__ +#define __CAN_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CAN_Driver CAN Driver + @{ +*/ + +/** @addtogroup NUC472_442_CAN_EXPORTED_TYPEDEF CAN Exported Type Defines + @{ +*/ + +/** + * @details Message ID types. + */ +typedef enum { + CAN_STD_ID = 0, /*!< Standard Identifier */ + CAN_EXT_ID = 1 /*!< Extended Identifier */ +} E_CAN_ID_TYPE; + +/** + * @details Message Frame types. + */ +typedef enum { + REMOTE_FRAME = 0, /*!< Remote Frame */ + DATA_FRAME = 1 /*!< Data Frame */ +} E_CAN_FRAME_TYPE; + +/** + * @details CAN message structure. + */ +typedef struct { + uint32_t IdType; /*!< Identifier Type */ + uint32_t FrameType; /*!< Frame Type */ + uint32_t Id; /*!< Message Identifier */ + uint8_t DLC; /*!< Data Length Code */ + uint8_t Data[8]; /*!< Data byte 0 ~ 7 */ +} STR_CANMSG_T; + +/** + * @details CAN mask message structure. + */ +typedef struct { + uint8_t u8Xtd; /*!< Extended Identifier */ + uint8_t u8Dir; /*!< Message Direction */ + uint32_t u32Id; /*!< Message Identifier */ + uint8_t u8IdType; /*!< Identifier Type */ +} STR_CANMASK_T; + +/** + * @details CAN operation mode: normal/basic mode. + */ +typedef enum { + CAN_NORMAL_MODE = 1, /*!< Normal Mode */ + CAN_BASIC_MODE = 2 /*!< Basic Mode */ +} CAN_MODE_SELECT; + +#define ALL_MSG 32 /*!< All Message ram number */ +#define MSG(id) id /*!< Message ram number */ + + +/*@}*/ /* end of group NUC472_442_CAN_EXPORTED_TYPEDEF */ + + +/** @addtogroup NUC472_442_CAN_EXPORTED_FUNCTIONS CAN Exported Functions + @{ +*/ + +/** + * @brief Get interrupt status + * + * @param[in] can The base address of can module + * + * @return CAN module status register value + * \hideinitializer + */ +#define CAN_GET_INT_STATUS(can) (can->STATUS) + +/** + * @brief Get specified interrupt pending status + * + * @param[in] can The base address of can module + * + * @return The source of the interrupt. + * \hideinitializer + */ +#define CAN_GET_INT_PENDING_STATUS(can) (can->IIDR) + +/** + * @brief Disable Wakeup function + * + * @param[in] can The base address of can module + * + * @return None + * \hideinitializer + */ +#define CAN_DISABLE_WAKEUP(can) (can->WU_IE = 0) + +/** + * @brief Enable Wakeup function + * + * @param[in] can The base address of can module + * + * @return None + * \hideinitializer + */ +#define CAN_ENABLE_WAKEUP(can) (can->WU_IE = CAN_WUEN_WAKUP_EN_Msk) + +/** + * @brief Get specified Message Object new data into bit value + * + * @param[in] can The base address of can module + * @param[in] u32MsgNum Specified Message Object number. (0 ~ 31) + * + * @return Specified Message Object new data into bit value. + * \hideinitializer + */ +#define CAN_GET_NEW_DATA_IN_BIT(can, u32MsgNum) (u32MsgNum < 16 ? can->NDAT1 & (1 << u32MsgNum) : can->NDAT2 & (1 << (u32MsgNum-16))) + + +/*---------------------------------------------------------------------------------------------------------*/ +/* Define CAN functions prototype */ +/*---------------------------------------------------------------------------------------------------------*/ +uint32_t CAN_SetBaudRate(CAN_T *tCAN, uint32_t u32BaudRate); +uint32_t CAN_Open(CAN_T *tCAN, uint32_t u32BaudRate, uint32_t u32Mode); +int32_t CAN_Transmit(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg); +int32_t CAN_Receive(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg); +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum); +void CAN_EnableInt(CAN_T *tCAN, uint32_t u32Mask); +void CAN_DisableInt(CAN_T *tCAN, uint32_t u32Mask); +int32_t CAN_SetMultiRxMsg(CAN_T *tCAN, uint32_t u32MsgNum , uint32_t u32MsgCount, uint32_t u32IDType, uint32_t u32ID); +int32_t CAN_SetRxMsg(CAN_T *tCAN, uint32_t u32MsgNum , uint32_t u32IDType, uint32_t u32ID); +int32_t CAN_SetTxMsg(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg); +int32_t CAN_TriggerTxMsg(CAN_T *tCAN, uint32_t u32MsgNum); + +/*@}*/ /* end of group NUC472_442_CAN_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CAN_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__CAN_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + + + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/cap.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/cap.h new file mode 100644 index 0000000000000000000000000000000000000000..03f3cc489863b7362c234866b97832aeeb545075 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/cap.h @@ -0,0 +1,169 @@ +/**************************************************************************//** + * @file cap.h + * @version V0.10 + * $Revision: 17 $ + * $Date: 15/10/22 10:00a $ + * @brief NUC470 series Image Capture Driver Header File + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + * + ******************************************************************************/ +#ifndef __CAP_H__ +#define __CAP_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CAP_Driver CAP Driver + @{ +*/ + +/** @addtogroup NUC472_442_CAP_EXPORTED_CONSTANTS CAP Exported Constants + @{ +*/ + +/*---------------------------------------------------------------------------------------------------------*/ +/* VINCTRL constant definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define CAP_CTL_CAPEN (1ul<CTL & CAP_CTL_CAPEN_Msk)?0:1) + +/** + * @brief Clear CAP flag + * + * @param[in] u32IntMask interrupt flags settings. It could be + * - \ref CAP_INT_VINTF_Msk + * - \ref CAP_INT_MEINTF_Msk + * - \ref CAP_INT_ADDRMINTF_Msk + * - \ref CAP_INT_MDINTF_Msk + * + * @return TRUE(Enable) or FALSE(Disable) + * + * @details Clear Image Capture Interface interrupt flag + * \hideinitializer + */ +#define CAP_CLR_INT_FLAG(u32IntMask) (ICAP->INT |=u32IntMask) + +/** + * @brief Get CAP Interrupt status + * + * @return TRUE(Enable) or FALSE(Disable) + * + * @details Get Image Capture Interface interrupt status. + * \hideinitializer + */ +#define CAP_GET_INT_STS() (ICAP->INT) + +void CAP_Open(uint32_t u32InFormat, uint32_t u32OutFormet); +void CAP_SetCroppingWindow(uint32_t u32VStart,uint32_t u32HStart, uint32_t u32Height, uint32_t u32Width); +void CAP_SetPacketBuf(uint32_t u32Address ); +void CAP_SetPlanarBuf(uint32_t u32YAddr, uint32_t u32UAddr, uint32_t u32VAddr); +void CAP_Close(void); +void CAP_EnableInt(uint32_t u32IntMask); +void CAP_DisableInt(uint32_t u32IntMask); +void CAP_Start(void); +void CAP_Stop(uint32_t u32FrameComplete); +void CAP_SetPacketScaling(uint32_t u32VNumerator, uint32_t u32VDenominator, uint32_t u32HNumerator, uint32_t u32HDenominator); +void CAP_SetPlanarScaling(uint32_t u32VNumerator, uint32_t u32VDenominator, uint32_t u32HNumerator, uint32_t u32HDenominator); +void CAP_SetPacketStride(uint32_t u32Stride ); +void CAP_SetPlanarStride(uint32_t u32Stride ); +void CAP_EnableMotionDet(uint32_t u32Freq, uint32_t u32BlockSize, uint32_t u32Format, uint32_t u32Threshold, uint32_t u32YDetAddr, uint32_t u32DetAddr); +void CAP_DisableMotionDet(void); + +/*@}*/ /* end of group NUC472_442_CAP_EXPORTED_FUNCTIONS */ + + + +/*@}*/ /* end of group NUC472_442_CAP_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__CAP_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/clk.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/clk.h new file mode 100644 index 0000000000000000000000000000000000000000..c152702ce871109ead569be61916558037710349 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/clk.h @@ -0,0 +1,437 @@ +/**************************************************************************//** + * @file CLK.h + * @version V1.0 + * $Revision 1 $ + * $Date: 15/11/19 10:06a $ + * @brief NUC472/NUC442 CLK Header File + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + ******************************************************************************/ +#ifndef __CLK_H__ +#define __CLK_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CLK_Driver CLK Driver + @{ +*/ + + +/** @addtogroup NUC472_442_CLK_EXPORTED_CONSTANTS CLK Exported Constants +@{ +*/ + +#define FREQ_500MHZ 500000000 +#define FREQ_250MHZ 250000000 +#define FREQ_200MHZ 200000000 +#define FREQ_125MHZ 125000000 +#define FREQ_72MHZ 72000000 +#define FREQ_50MHZ 50000000 +#define FREQ_25MHZ 25000000 +#define FREQ_24MHZ 24000000 +#define FREQ_22MHZ 22000000 +#define FREQ_32KHZ 32000 +#define FREQ_10KHZ 10000 + +/*---------------------------------------------------------------------------------------------------------*/ +/* PLLCTL constant definitions. PLL = FIN * NF / NR / NO */ +/*---------------------------------------------------------------------------------------------------------*/ +#define CLK_PLLCTL_PLLSRC_HIRC (0x1UL<>30) & 0x3) /*!< Calculate AHBCLK/APBCLK offset on MODULE index \hideinitializer */ +#define MODULE_CLKSEL(x) ((x >>28) & 0x3) /*!< Calculate CLKSEL offset on MODULE index \hideinitializer */ +#define MODULE_CLKSEL_Msk(x) ((x >>25) & 0x7) /*!< Calculate CLKSEL mask offset on MODULE index \hideinitializer */ +#define MODULE_CLKSEL_Pos(x) ((x >>20) & 0x1f) /*!< Calculate CLKSEL position offset on MODULE index \hideinitializer */ +#define MODULE_CLKDIV(x) ((x >>18) & 0x3) /*!< Calculate APBCLK CLKDIV on MODULE index \hideinitializer */ +#define MODULE_CLKDIV_Msk(x) ((x >>10) & 0xff) /*!< Calculate CLKDIV mask offset on MODULE index \hideinitializer */ +#define MODULE_CLKDIV_Pos(x) ((x >>5 ) & 0x1f) /*!< Calculate CLKDIV position offset on MODULE index \hideinitializer */ +#define MODULE_IP_EN_Pos(x) ((x >>0 ) & 0x1f) /*!< Calculate APBCLK offset on MODULE index \hideinitializer */ +#define MODULE_NoMsk 0x0 /*!< Not mask on MODULE index \hideinitializer */ +#define NA MODULE_NoMsk /*!< Not Available \hideinitializer */ + +#define MODULE_APBCLK_ENC(x) (((x) & 0x03) << 30) /*!< MODULE index, 0x0:AHBCLK, 0x1:APBCLK0, 0x2:APBCLK1 */ +#define MODULE_CLKSEL_ENC(x) (((x) & 0x03) << 28) /*!< CLKSEL offset on MODULE index, 0x0:CLKSEL0, 0x1:CLKSEL1, 0x2:CLKSEL2, 0x3:CLKSEL3 */ +#define MODULE_CLKSEL_Msk_ENC(x) (((x) & 0x07) << 25) /*!< CLKSEL mask offset on MODULE index */ +#define MODULE_CLKSEL_Pos_ENC(x) (((x) & 0x1f) << 20) /*!< CLKSEL position offset on MODULE index */ +#define MODULE_CLKDIV_ENC(x) (((x) & 0x03) << 18) /*!< APBCLK CLKDIV on MODULE index, 0x0:CLKDIV, 0x1:CLKDIV1 */ +#define MODULE_CLKDIV_Msk_ENC(x) (((x) & 0xff) << 10) /*!< CLKDIV mask offset on MODULE index */ +#define MODULE_CLKDIV_Pos_ENC(x) (((x) & 0x1f) << 5) /*!< CLKDIV position offset on MODULE index */ +#define MODULE_IP_EN_Pos_ENC(x) (((x) & 0x1f) << 0) /*!< AHBCLK/APBCLK offset on MODULE index */ +/*--------------------------------------------------------------------------------------------------------------------------------------*/ +/* AHBCLK/APBCLK(2) | CLKSEL(2) | CLKSEL_Msk(3) | CLKSEL_Pos(5) | CLKDIV(2) | CLKDIV_Msk(8) | CLKDIV_Pos(5) | IP_EN_Pos(5)*/ +/*--------------------------------------------------------------------------------------------------------------------------------------*/ +#define PDMA_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_AHBCLK_PDMACKEN_Pos) /*!< PDMA Module \hideinitializer */ +#define ISP_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_AHBCLK_ISPCKEN_Pos) /*!< ISP Module \hideinitializer */ +#define EBI_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_AHBCLK_EBICKEN_Pos) /*!< EBI Module \hideinitializer */ +#define USBH_MODULE ((0UL<<30)|(0<<28)|(1<<25) |( 8<<20)|(0<<18)|(0xF<<10) |( 4<<5)|CLK_AHBCLK_USBHCKEN_Pos) /*!< USBH Module \hideinitializer */ +#define EMAC_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|(10<<20)|(3<<18)|(0xFF<<10) |(16<<5)|CLK_AHBCLK_EMACCKEN_Pos) /*!< EMAC Module \hideinitializer */ +#define SDH_MODULE ((0UL<<30)|(0<<28)|(3<<25) |(20<<20)|(0<<18)|(0xFF<<10) |(24<<5)|CLK_AHBCLK_SDHCKEN_Pos) /*!< SDH Module \hideinitializer */ +#define CRC_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_AHBCLK_CRCCKEN_Pos) /*!< CRC Module \hideinitializer */ +#define CAP_MODULE ((0UL<<30)|(0<<28)|(3<<25) |(16<<20)|(3<<18)|(0xFF<<10) |( 0<<5)|CLK_AHBCLK_CAPCKEN_Pos) /*!< CAP Module \hideinitializer */ +#define SEN_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(3<<18)|(0xFF<<10) |( 8<<5)|CLK_AHBCLK_SENCKEN_Pos) /*!< Sensor Clock Module \hideinitializer */ +#define USBD_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_AHBCLK_USBDCKEN_Pos) /*!< USBD Module \hideinitializer */ +#define CRPT_MODULE ((0UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_AHBCLK_CRPTCKEN_Pos) /*!< CRYPTO Module \hideinitializer */ + +#define WDT_MODULE ((1UL<<30)|(1<<28)|(3<<25) |( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_WDTCKEN_Pos) /*!< Watchdog Timer Module \hideinitializer */ +#define WWDT_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(30<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_WDTCKEN_Pos) /*!< Window Watchdog Timer Module \hideinitializer */ +#define RTC_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_RTCCKEN_Pos) /*!< RTC Module \hideinitializer */ +#define TMR0_MODULE ((1UL<<30)|(1<<28)|(7<<25) |( 8<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_TMR0CKEN_Pos) /*!< Timer0 Module \hideinitializer */ +#define TMR1_MODULE ((1UL<<30)|(1<<28)|(7<<25) |(12<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_TMR1CKEN_Pos) /*!< Timer1 Module \hideinitializer */ +#define TMR2_MODULE ((1UL<<30)|(1<<28)|(7<<25) |(16<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_TMR2CKEN_Pos) /*!< Timer2 Module \hideinitializer */ +#define TMR3_MODULE ((1UL<<30)|(1<<28)|(7<<25) |(20<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_TMR3CKEN_Pos) /*!< Timer3 Module \hideinitializer */ +#define CLKO_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(28<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_CLKOCKEN_Pos) /*!< CLKO Module \hideinitializer */ +#define ACMP_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_ACMPCKEN_Pos) /*!< ACMP Module \hideinitializer */ +#define I2C0_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_I2C0CKEN_Pos) /*!< I2C0 Module \hideinitializer */ +#define I2C1_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_I2C1CKEN_Pos) /*!< I2C1 Module \hideinitializer */ +#define I2C2_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_I2C2CKEN_Pos) /*!< I2C2 Module \hideinitializer */ +#define I2C3_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_I2C3CKEN_Pos) /*!< I2C3 Module \hideinitializer */ +#define SPI0_MODULE ((1UL<<30)|(1<<28)|(1<<25) |( 4<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_SPI0CKEN_Pos) /*!< SPI0 Module \hideinitializer */ +#define SPI1_MODULE ((1UL<<30)|(1<<28)|(1<<25) |( 5<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_SPI1CKEN_Pos) /*!< SPI1 Module \hideinitializer */ +#define SPI2_MODULE ((1UL<<30)|(1<<28)|(1<<25) |( 6<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_SPI2CKEN_Pos) /*!< SPI2 Module \hideinitializer */ +#define SPI3_MODULE ((1UL<<30)|(1<<28)|(1<<25) |( 7<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_SPI3CKEN_Pos) /*!< SPI3 Module \hideinitializer */ +#define UART0_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(24<<20)|(0<<18)|(0xF<<10) |( 8<<5)|CLK_APBCLK0_UART0CKEN_Pos) /*!< UART0 Module \hideinitializer */ +#define UART1_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(24<<20)|(0<<18)|(0xF<<10) |( 8<<5)|CLK_APBCLK0_UART1CKEN_Pos) /*!< UART1 Module \hideinitializer */ +#define UART2_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(24<<20)|(0<<18)|(0xF<<10) |( 8<<5)|CLK_APBCLK0_UART2CKEN_Pos) /*!< UART2 Module \hideinitializer */ +#define UART3_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(24<<20)|(0<<18)|(0xF<<10) |( 8<<5)|CLK_APBCLK0_UART3CKEN_Pos) /*!< UART3 Module \hideinitializer */ +#define UART4_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(24<<20)|(0<<18)|(0xF<<10) |( 8<<5)|CLK_APBCLK0_UART4CKEN_Pos) /*!< UART4 Module \hideinitializer */ +#define UART5_MODULE ((1UL<<30)|(1<<28)|(3<<25) |(24<<20)|(0<<18)|(0xF<<10) |( 8<<5)|CLK_APBCLK0_UART5CKEN_Pos) /*!< UART5 Module \hideinitializer */ +#define CAN0_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_CAN0CKEN_Pos) /*!< CAN0 Module \hideinitializer */ +#define CAN1_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_CAN1CKEN_Pos) /*!< CAN1 Module \hideinitializer */ +#define OTG_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_OTGCKEN_Pos) /*!< OTG Module \hideinitializer */ +#define ADC_MODULE ((1UL<<30)|(1<<28)|(3<<25) |( 2<<20)|(0<<18)|(0xFF<<10) |(16<<5)|CLK_APBCLK0_ADCCKEN_Pos) /*!< ADC Module \hideinitializer */ +#define I2S0_MODULE ((1UL<<30)|(3<<28)|(3<<25) |(16<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_I2S0CKEN_Pos) /*!< I2S0 Module \hideinitializer */ +#define I2S1_MODULE ((1UL<<30)|(3<<28)|(3<<25) |(18<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_I2S1CKEN_Pos) /*!< I2S1 Module \hideinitializer */ +#define PS2_MODULE ((1UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK0_PS2CKEN_Pos) /*!< PS2 Module \hideinitializer */ + +#define SC0_MODULE ((2UL<<30)|(3<<28)|(3<<25) |( 0<<20)|(1<<18)|(0xFF<<10) |( 0<<5)|CLK_APBCLK1_SC0CKEN_Pos) /*!< SmartCard0 Module \hideinitializer */ +#define SC1_MODULE ((2UL<<30)|(3<<28)|(3<<25) |( 2<<20)|(1<<18)|(0xFF<<10) |( 8<<5)|CLK_APBCLK1_SC1CKEN_Pos) /*!< SmartCard1 Module \hideinitializer */ +#define SC2_MODULE ((2UL<<30)|(3<<28)|(3<<25) |( 4<<20)|(1<<18)|(0xFF<<10) |(16<<5)|CLK_APBCLK1_SC2CKEN_Pos) /*!< SmartCard2 Module \hideinitializer */ +#define SC3_MODULE ((2UL<<30)|(3<<28)|(3<<25) |( 6<<20)|(1<<18)|(0xFF<<10) |(24<<5)|CLK_APBCLK1_SC3CKEN_Pos) /*!< SmartCard3 Module \hideinitializer */ +#define SC4_MODULE ((2UL<<30)|(3<<28)|(3<<25) |( 8<<20)|(2<<18)|(0xFF<<10) |( 0<<5)|CLK_APBCLK1_SC4CKEN_Pos) /*!< SmartCard4 Module \hideinitializer */ +#define SC5_MODULE ((2UL<<30)|(3<<28)|(3<<25) |(10<<20)|(2<<18)|(0xFF<<10) |( 8<<5)|CLK_APBCLK1_SC5CKEN_Pos) /*!< SmartCard5 Module \hideinitializer */ +#define I2C4_MODULE ((2UL<<30)|(0<<28)|(0<<25) |( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_I2C4CKEN_Pos) /*!< I2C4 Module */ +#define PWM0CH01_MODULE ((2UL<<30)|(2<<28)|(7<<25) |( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_PWM0CH01CKEN_Pos) /*!< PWM0CH01 Module \hideinitializer */ +#define PWM0CH23_MODULE ((2UL<<30)|(2<<28)|(7<<25) |( 4<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_PWM0CH23CKEN_Pos) /*!< PWM0CH23 Module \hideinitializer */ +#define PWM0CH45_MODULE ((2UL<<30)|(2<<28)|(7<<25) |( 8<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_PWM0CH45CKEN_Pos) /*!< PWM0CH45 Module \hideinitializer */ +#define PWM1CH01_MODULE ((2UL<<30)|(2<<28)|(7<<25) |(12<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_PWM1CH01CKEN_Pos) /*!< PWM1CH01 Module \hideinitializer */ +#define PWM1CH23_MODULE ((2UL<<30)|(2<<28)|(7<<25) |(16<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_PWM1CH2345CKEN_Pos) /*!< PWM1CH23 Module \hideinitializer */ +#define PWM1CH45_MODULE ((2UL<<30)|(2<<28)|(7<<25) |(20<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_PWM1CH2345CKEN_Pos) /*!< PWM1CH45 Module \hideinitializer */ +#define QEI0_MODULE ((2UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_QEI0CKEN_Pos) /*!< QEI0 Module \hideinitializer */ +#define QEI1_MODULE ((2UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_QEI1CKEN_Pos) /*!< QEI1 Module \hideinitializer */ +#define ECAP0_MODULE ((2UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_ECAP0CKEN_Pos) /*!< ECAP0 Module \hideinitializer */ +#define ECAP1_MODULE ((2UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_ECAP1CKEN_Pos) /*!< ECAP1 Module \hideinitializer */ +#define EPWM0_MODULE ((2UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_EPWM0CKEN_Pos) /*!< EPWM0 Module \hideinitializer */ +#define EPWM1_MODULE ((2UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_EPWM1CKEN_Pos) /*!< EPWM1 Module \hideinitializer */ +#define OPA_MODULE ((2UL<<30)|(0<<28)|(MODULE_NoMsk<<25)|( 0<<20)|(0<<18)|(MODULE_NoMsk<<10)|( 0<<5)|CLK_APBCLK1_OPACKEN_Pos) /*!< OPA Module \hideinitializer */ +#define EADC_MODULE ((2UL<<30)|(1<<28)|(3<<25) |( 2<<20)|(0<<18)|(0xFF<<10) |(16<<5)|CLK_APBCLK1_EADCCKEN_Pos) /*!< EADC Module \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_CLK_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_CLK_EXPORTED_FUNCTIONS CLK Exported Functions + @{ +*/ + +void CLK_DisableCKO(void); +void CLK_EnableCKO(uint32_t u32ClkSrc, uint32_t u32ClkDiv, uint32_t u32ClkDivBy1En); +void CLK_PowerDown(void); +void CLK_Idle(void); +uint32_t CLK_GetHXTFreq(void); +uint32_t CLK_GetLXTFreq(void); +uint32_t CLK_GetHCLKFreq(void); +uint32_t CLK_GetPCLKFreq(void); +uint32_t CLK_GetCPUFreq(void); +uint32_t CLK_GetPLLClockFreq(void); +uint32_t CLK_SetCoreClock(uint32_t u32Hclk); +void CLK_SetHCLK(uint32_t u32ClkSrc, uint32_t u32ClkDiv); +void CLK_SetModuleClock(uint32_t u32ModuleIdx, uint32_t u32ClkSrc, uint32_t u32ClkDiv); +void CLK_SetSysTickClockSrc(uint32_t u32ClkSrc); +void CLK_EnableXtalRC(uint32_t u32ClkMask); +void CLK_DisableXtalRC(uint32_t u32ClkMask); +void CLK_EnableModuleClock(uint32_t u32ModuleIdx); +void CLK_DisableModuleClock(uint32_t u32ModuleIdx); +uint32_t CLK_EnablePLL(uint32_t u32PllClkSrc, uint32_t u32PllFreq); +void CLK_DisablePLL(void); +void CLK_SysTickDelay(uint32_t us); +uint32_t CLK_WaitClockReady(uint32_t u32ClkMask); +void CLK_EnableSysTick(uint32_t u32ClkSrc, uint32_t u32Count); +void CLK_DisableSysTick(void); + +/*@}*/ /* end of group NUC472_442_CLK_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CLK_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__CLK_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/crc.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/crc.h new file mode 100644 index 0000000000000000000000000000000000000000..51fa25b6a2510fad79f29b09178899fd1324c810 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/crc.h @@ -0,0 +1,112 @@ +/**************************************************************************//** + * @file crc.h + * @version V1.00 + * $Revision: 2 $ + * $Date: 15/12/01 9:57a $ + * @brief NUC472/NUC442 series CRC driver header file + * + * @note + * Copyright (C) 2015 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __CRC_H__ +#define __CRC_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CRC_Driver CRC Driver + @{ +*/ + +/** @addtogroup NUC472_442_CRC_EXPORTED_CONSTANTS CRC Exported Constants + @{ +*/ +/*---------------------------------------------------------------------------------------------------------*/ +/* CRC Polynomial Mode Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define CRC_CCITT 0x00000000UL /*!SEED = (u32Seed); CRC->CTL |= CRC_CTL_CRCRST_Msk; } + +/** + * @brief Get CRC Seed Value + * + * @param None + * + * @return CRC seed value + * + * @details This macro gets the current CRC seed value. + */ +#define CRC_GET_SEED() (CRC->SEED) + +/** + * @brief CRC Write Data + * + * @param[in] u32Data Write data + * + * @return None + * + * @details User can write data directly to CRC Write Data Register(CRC_DAT) by this macro to perform CRC operation. + */ +#define CRC_WRITE_DATA(u32Data) (CRC->DAT = (u32Data)) + +void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen); +uint32_t CRC_GetChecksum(void); + +/*@}*/ /* end of group NUC472_442_CRC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CRC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__CRC_H__ + +/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/crypto.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/crypto.h new file mode 100644 index 0000000000000000000000000000000000000000..c8210e5286c551385e50570f0e887de05f172134 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/crypto.h @@ -0,0 +1,302 @@ +/**************************************************************************//** + * @file crypto.h + * @version V1.10 + * $Revision: 14 $ + * $Date: 14/10/06 1:49p $ + * @brief Cryptographic Accelerator driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. + ******************************************************************************/ +#ifndef __CRYPTO_H__ +#define __CRYPTO_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CRYPTO_Driver CRYPTO Driver + @{ +*/ + + +/** @addtogroup NUC472_442_CRYPTO_EXPORTED_CONSTANTS CRYPTO Exported Constants + @{ +*/ + +#define PRNG_KEY_SIZE_64 0 /*!< Select to generate 64-bit random key \hideinitializer */ +#define PRNG_KEY_SIZE_128 1 /*!< Select to generate 128-bit random key \hideinitializer */ +#define PRNG_KEY_SIZE_192 2 /*!< Select to generate 192-bit random key \hideinitializer */ +#define PRNG_KEY_SIZE_256 3 /*!< Select to generate 256-bit random key \hideinitializer */ + +#define PRNG_SEED_CONT 0 /*!< PRNG using current seed \hideinitializer */ +#define PRNG_SEED_RELOAD 1 /*!< PRNG reload new seed \hideinitializer */ + +#define AES_KEY_SIZE_128 0 /*!< AES select 128-bit key length \hideinitializer */ +#define AES_KEY_SIZE_192 1 /*!< AES select 192-bit key length \hideinitializer */ +#define AES_KEY_SIZE_256 2 /*!< AES select 256-bit key length \hideinitializer */ + +#define AES_MODE_ECB 0 /*!< AES select ECB mode \hideinitializer */ +#define AES_MODE_CBC 1 /*!< AES select CBC mode \hideinitializer */ +#define AES_MODE_CFB 2 /*!< AES select CFB mode \hideinitializer */ +#define AES_MODE_OFB 3 /*!< AES select OFB mode \hideinitializer */ +#define AES_MODE_CTR 4 /*!< AES select CTR mode \hideinitializer */ +#define AES_MODE_CBC_CS1 0x10 /*!< AES select CBC CS1 mode \hideinitializer */ +#define AES_MODE_CBC_CS2 0x11 /*!< AES select CBC CS2 mode \hideinitializer */ +#define AES_MODE_CBC_CS3 0x12 /*!< AES select CBC CS3 mode \hideinitializer */ + +#define AES_NO_SWAP 0 /*!< AES do not swap input and output data \hideinitializer */ +#define AES_OUT_SWAP 1 /*!< AES swap output data \hideinitializer */ +#define AES_IN_SWAP 2 /*!< AES swap input data \hideinitializer */ +#define AES_IN_OUT_SWAP 3 /*!< AES swap both input and output data \hideinitializer */ + +#define DES_MODE_ECB 0x000 /*!< DES select ECB mode \hideinitializer */ +#define DES_MODE_CBC 0x100 /*!< DES select CBC mode \hideinitializer */ +#define DES_MODE_CFB 0x200 /*!< DES select CFB mode \hideinitializer */ +#define DES_MODE_OFB 0x300 /*!< DES select OFB mode \hideinitializer */ +#define DES_MODE_CTR 0x400 /*!< DES select CTR mode \hideinitializer */ +#define TDES_MODE_ECB 0x004 /*!< TDES select ECB mode \hideinitializer */ +#define TDES_MODE_CBC 0x104 /*!< TDES select CBC mode \hideinitializer */ +#define TDES_MODE_CFB 0x204 /*!< TDES select CFB mode \hideinitializer */ +#define TDES_MODE_OFB 0x304 /*!< TDES select OFB mode \hideinitializer */ +#define TDES_MODE_CTR 0x404 /*!< TDES select CTR mode \hideinitializer */ + +#define TDES_NO_SWAP 0 /*!< TDES do not swap data \hideinitializer */ +#define TDES_WHL_SWAP 1 /*!< TDES swap high-low word \hideinitializer */ +#define TDES_OUT_SWAP 2 /*!< TDES swap output data \hideinitializer */ +#define TDES_OUT_WHL_SWAP 3 /*!< TDES swap output data and high-low word \hideinitializer */ +#define TDES_IN_SWAP 4 /*!< TDES swap input data \hideinitializer */ +#define TDES_IN_WHL_SWAP 5 /*!< TDES swap input data and high-low word \hideinitializer */ +#define TDES_IN_OUT_SWAP 6 /*!< TDES swap both input and output data \hideinitializer */ +#define TDES_IN_OUT_WHL_SWAP 7 /*!< TDES swap input, output and high-low word \hideinitializer */ + +#define SHA_MODE_SHA1 0 /*!< SHA select SHA-1 160-bit \hideinitializer */ +#define SHA_MODE_SHA224 5 /*!< SHA select SHA-224 224-bit \hideinitializer */ +#define SHA_MODE_SHA256 4 /*!< SHA select SHA-256 256-bit \hideinitializer */ + +#define SHA_NO_SWAP 0 /*!< SHA do not swap input and output data \hideinitializer */ +#define SHA_OUT_SWAP 1 /*!< SHA swap output data \hideinitializer */ +#define SHA_IN_SWAP 2 /*!< SHA swap input data \hideinitializer */ +#define SHA_IN_OUT_SWAP 3 /*!< SHA swap both input and output data \hideinitializer */ + +#define CRYPTO_DMA_ONE_SHOT 0x5 /*!< Do one shot encrypt/decrypt with DMA \hideinitializer */ +#define CRYPTO_DMA_CONTINUE 0x6 /*!< Do one continuous encrypt/decrypt with DMA \hideinitializer */ +#define CRYPTO_DMA_LAST 0x6 /*!< Do last encrypt/decrypt with DMA \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_CRYPTO_EXPORTED_CONSTANTS */ + + + + +/** @addtogroup NUC472_442_CRYPTO_EXPORTED_FUNCTIONS CRYPTO Exported Functions + @{ +*/ + +/*----------------------------------------------------------------------------------------------*/ +/* Macros */ +/*----------------------------------------------------------------------------------------------*/ + +/** + * @brief This macro enables PRNG interrupt. + * @param None + * @return None + * \hideinitializer + */ +#define PRNG_ENABLE_INT() (CRPT->INTEN |= CRPT_INTEN_PRNGIEN_Msk) + +/** + * @brief This macro disables PRNG interrupt. + * @param None + * @return None + * \hideinitializer + */ +#define PRNG_DISABLE_INT() (CRPT->INTEN &= ~CRPT_INTEN_PRNGIEN_Msk) + +/** + * @brief This macro gets PRNG interrupt flag. + * @param None + * @return PRNG interrupt flag. + * \hideinitializer + */ +#define PRNG_GET_INT_FLAG() (CRPT->INTSTS & CRPT_INTSTS_PRNGIF_Msk) + +/** + * @brief This macro clears PRNG interrupt flag. + * @param None + * @return None + * \hideinitializer + */ +#define PRNG_CLR_INT_FLAG() (CRPT->INTSTS = CRPT_INTSTS_PRNGIF_Msk) + +/** + * @brief This macro enables AES interrupt. + * @param None + * @return None + * \hideinitializer + */ +#define AES_ENABLE_INT() (CRPT->INTEN |= (CRPT_INTEN_AESIEN_Msk|CRPT_INTEN_AESERRIEN_Msk)) + +/** + * @brief This macro disables AES interrupt. + * @param None + * @return None + * \hideinitializer + */ +#define AES_DISABLE_INT() (CRPT->INTEN &= ~(CRPT_INTEN_AESIEN_Msk|CRPT_INTEN_AESERRIEN_Msk)) + +/** + * @brief This macro gets AES interrupt flag. + * @param None + * @return AES interrupt flag. + * \hideinitializer + */ +#define AES_GET_INT_FLAG() (CRPT->INTSTS & (CRPT_INTSTS_AESIF_Msk|CRPT_INTSTS_AESERRIF_Msk)) + +/** + * @brief This macro clears AES interrupt flag. + * @param None + * @return None + * \hideinitializer + */ +#define AES_CLR_INT_FLAG() (CRPT->INTSTS = (CRPT_INTSTS_AESIF_Msk|CRPT_INTSTS_AESERRIF_Msk)) + +/** + * @brief This macro enables AES key protection. + * @param None + * @return None + * \hideinitializer + */ +#define AES_ENABLE_KEY_PROTECT() (CRPT->AES_CTL |= CRPT_AES_CTL_KEYPRT_Msk) + +/** + * @brief This macro disables AES key protection. + * @param None + * @return None + * \hideinitializer + */ +#define AES_DISABLE_KEY_PROTECT() (CRPT->AES_CTL = (CRPT->AES_CTL & ~CRPT_AES_CTL_KEYPRT_Msk) | (0x16<INTEN |= (CRPT_INTEN_TDESIEN_Msk|CRPT_INTEN_TDESERRIEN_Msk)) + +/** + * @brief This macro disables TDES interrupt. + * @param None + * @return None + * \hideinitializer + */ +#define TDES_DISABLE_INT() (CRPT->INTEN &= ~(CRPT_INTEN_TDESIEN_Msk|CRPT_INTEN_TDESERRIEN_Msk)) + +/** + * @brief This macro gets TDES interrupt flag. + * @param None + * @return TDES interrupt flag. + * \hideinitializer + */ +#define TDES_GET_INT_FLAG() (CRPT->INTSTS & (CRPT_INTSTS_TDESIF_Msk|CRPT_INTSTS_TDESERRIF_Msk)) + +/** + * @brief This macro clears TDES interrupt flag. + * @param None + * @return None + * \hideinitializer + */ +#define TDES_CLR_INT_FLAG() (CRPT->INTSTS = (CRPT_INTSTS_TDESIF_Msk|CRPT_INTSTS_TDESERRIF_Msk)) + +/** + * @brief This macro enables TDES key protection. + * @param None + * @return None + * \hideinitializer + */ +#define TDES_ENABLE_KEY_PROTECT() (CRPT->TDES_CTL |= CRPT_TDES_CTL_KEYPRT_Msk) + +/** + * @brief This macro disables TDES key protection. + * @param None + * @return None + * \hideinitializer + */ +#define TDES_DISABLE_KEY_PROTECT() (CRPT->TDES_CTL = (CRPT->TDES_CTL & ~CRPT_TDES_CTL_KEYPRT_Msk) | (0x16<INTEN |= (CRPT_INTEN_SHAIEN_Msk|CRPT_INTEN_SHAERRIEN_Msk)) + +/** + * @brief This macro disables SHA interrupt. + * @param None + * @return None + * \hideinitializer + */ +#define SHA_DISABLE_INT() (CRPT->INTEN &= ~(CRPT_INTEN_SHAIEN_Msk|CRPT_INTEN_SHAERRIEN_Msk)) + +/** + * @brief This macro gets SHA interrupt flag. + * @param None + * @return SHA interrupt flag. + * \hideinitializer + */ +#define SHA_GET_INT_FLAG() (CRPT->INTSTS & (CRPT_INTSTS_SHAIF_Msk|CRPT_INTSTS_SHAERRIF_Msk)) + +/** + * @brief This macro clears SHA interrupt flag. + * @param None + * @return None + * \hideinitializer + */ +#define SHA_CLR_INT_FLAG() (CRPT->INTSTS = (CRPT_INTSTS_SHAIF_Msk|CRPT_INTSTS_SHAERRIF_Msk)) + + + +/*---------------------------------------------------------------------------------------------------------*/ +/* Functions */ +/*---------------------------------------------------------------------------------------------------------*/ + +void PRNG_Open(uint32_t u32KeySize, uint32_t u32SeedReload, uint32_t u32Seed); +void PRNG_Start(void); +void PRNG_Read(uint32_t u32RandKey[]); +void AES_Open(uint32_t u32Channel, uint32_t u32EncDec, uint32_t u32OpMode, uint32_t u32KeySize, uint32_t u32SwapType); +void AES_Start(int32_t u32Channel, uint32_t u32DMAMode); +void AES_SetKey(uint32_t u32Channel, uint32_t au32Keys[], uint32_t u32KeySize); +void AES_SetInitVect(uint32_t u32Channel, uint32_t au32IV[]); +void AES_SetDMATransfer(uint32_t u32Channel, uint32_t u32SrcAddr, uint32_t u32DstAddr, uint32_t u32TransCnt); +void TDES_Open(uint32_t u32Channel, uint32_t u32EncDec, uint32_t u32OpMode, uint32_t u32SwapType); +void TDES_Start(int32_t u32Channel, uint32_t u32DMAMode); +void TDES_SetKey(uint32_t u32Channel, uint8_t au8Keys[3][8]); +void TDES_SetInitVect(uint32_t u32Channel, uint32_t u32IVH, uint32_t u32IVL); +void TDES_SetDMATransfer(uint32_t u32Channel, uint32_t u32SrcAddr, uint32_t u32DstAddr, uint32_t u32TransCnt); +void SHA_Open(uint32_t u32OpMode, uint32_t u32SwapType); +void SHA_Start(uint32_t u32DMAMode); +void SHA_SetDMATransfer(uint32_t u32SrcAddr, uint32_t u32TransCnt); +void SHA_Read(uint32_t u32Digest[]); + + +/*@}*/ /* end of group NUC472_442_CRYPTO_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CRYPTO_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif // __CRYPTO_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/eadc.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/eadc.h new file mode 100644 index 0000000000000000000000000000000000000000..23af43246687798fab29cfcce38339a7f0b12b45 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/eadc.h @@ -0,0 +1,622 @@ +/**************************************************************************//** + * @file eadc.h + * @version V1.00 + * $Revision: 17 $ + * $Date: 15/12/01 10:13a $ + * @brief NUC472/NUC442 EADC driver header file + * + * @note + * Copyright (C) 2015 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __EADC_H__ +#define __EADC_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_EADC_Driver EADC Driver + @{ +*/ + +/** @addtogroup NUC472_442_EADC_EXPORTED_CONSTANTS EADC Exported Constants + @{ +*/ + +/*---------------------------------------------------------------------------------------------------------*/ +/* EADC SAMPLE module number Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define EADC0_SAMPLE_MODULE0 0 /*!< EADC0 SAMPLE module 0 \hideinitializer */ +#define EADC0_SAMPLE_MODULE1 1 /*!< EADC0 SAMPLE module 1 \hideinitializer */ +#define EADC0_SAMPLE_MODULE2 2 /*!< EADC0 SAMPLE module 2 \hideinitializer */ +#define EADC0_SAMPLE_MODULE3 3 /*!< EADC0 SAMPLE module 3 \hideinitializer */ +#define EADC0_SAMPLE_MODULE4 4 /*!< EADC0 SAMPLE module 4 \hideinitializer */ +#define EADC0_SAMPLE_MODULE5 5 /*!< EADC0 SAMPLE module 5 \hideinitializer */ +#define EADC0_SAMPLE_MODULE6 6 /*!< EADC0 SAMPLE module 6 \hideinitializer */ +#define EADC0_SAMPLE_MODULE7 7 /*!< EADC0 SAMPLE module 7 \hideinitializer */ +#define EADC1_SAMPLE_MODULE0 8 /*!< EADC1 SAMPLE module 0 \hideinitializer */ +#define EADC1_SAMPLE_MODULE1 9 /*!< EADC1 SAMPLE module 1 \hideinitializer */ +#define EADC1_SAMPLE_MODULE2 10 /*!< EADC1 SAMPLE module 2 \hideinitializer */ +#define EADC1_SAMPLE_MODULE3 11 /*!< EADC1 SAMPLE module 3 \hideinitializer */ +#define EADC1_SAMPLE_MODULE4 12 /*!< EADC1 SAMPLE module 4 \hideinitializer */ +#define EADC1_SAMPLE_MODULE5 13 /*!< EADC1 SAMPLE module 5 \hideinitializer */ +#define EADC1_SAMPLE_MODULE6 14 /*!< EADC1 SAMPLE module 6 \hideinitializer */ +#define EADC1_SAMPLE_MODULE7 15 /*!< EADC1 SAMPLE module 7 \hideinitializer */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* EADC Compare SAMPLE module number Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define CMP_EADC0_SAMPLE_MODULE0 0 /*!< Compare EADC0 SAMPLE module 0 \hideinitializer */ +#define CMP_EADC0_SAMPLE_MODULE1 1 /*!< Compare EADC0 SAMPLE module 1 \hideinitializer */ +#define CMP_EADC0_SAMPLE_MODULE2 2 /*!< Compare EADC0 SAMPLE module 2 \hideinitializer */ +#define CMP_EADC0_SAMPLE_MODULE3 3 /*!< Compare EADC0 SAMPLE module 3 \hideinitializer */ +#define CMP_EADC1_SAMPLE_MODULE0 4 /*!< Compare EADC1 SAMPLE module 0 \hideinitializer */ +#define CMP_EADC1_SAMPLE_MODULE1 5 /*!< Compare EADC1 SAMPLE module 1 \hideinitializer */ +#define CMP_EADC1_SAMPLE_MODULE2 6 /*!< Compare EADC1 SAMPLE module 2 \hideinitializer */ +#define CMP_EADC1_SAMPLE_MODULE3 7 /*!< Compare EADC1 SAMPLE module 3 \hideinitializer */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* EADC_ADnSPCTLx Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define EADC_SCTL_CHSEL(x) ((x) << EADC_AD0SPCTL0_CHSEL_Pos) /*!< A/D sample module channel selection \hideinitializer */ +#define EADC_SCTL_TRGDLYDIV(x) ((x) << EADC_AD0SPCTL0_TRGDLYDIV_Pos) /*!< A/D sample module start of conversion trigger delay clock divider selection \hideinitializer */ +#define EADC_SCTL_TRGDLYCNT(x) ((x) << EADC_AD0SPCTL0_TRGDLYCNT_Pos) /*!< A/D sample module start of conversion trigger delay time \hideinitializer */ + +#define EADC_SOFTWARE_TRIGGER (0UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< Software trigger \hideinitializer */ +#define EADC_STADC_TRIGGER (1UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< External pin STADC trigger \hideinitializer */ +#define EADC_ADINT0_TRIGGER (2UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EADC ADINT0 interrupt EOC pulse trigger \hideinitializer */ +#define EADC_ADINT1_TRIGGER (3UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EADC ADINT1 interrupt EOC pulse trigger \hideinitializer */ +#define EADC_TIMER0_TRIGGER (4UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< Timer0 overflow pulse trigger \hideinitializer */ +#define EADC_TIMER1_TRIGGER (5UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< Timer1 overflow pulse trigger \hideinitializer */ +#define EADC_TIMER2_TRIGGER (6UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< Timer2 overflow pulse trigger \hideinitializer */ +#define EADC_TIMER3_TRIGGER (7UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< Timer3 overflow pulse trigger \hideinitializer */ +#define EADC_EPWM0CH0_TRIGGER (8UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EPWM0CH0 trigger \hideinitializer */ +#define EADC_EPWM0CH2_TRIGGER (9UL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EPWM0CH2 trigger \hideinitializer */ +#define EADC_EPWM0CH4_TRIGGER (0xAUL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EPWM0CH4 trigger \hideinitializer */ +#define EADC_EPWM1CH0_TRIGGER (0xBUL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EPWM1CH0 trigger \hideinitializer */ +#define EADC_EPWM1CH2_TRIGGER (0xCUL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EPWM1CH2 trigger \hideinitializer */ +#define EADC_EPWM1CH4_TRIGGER (0xDUL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< EPWM1CH4 trigger \hideinitializer */ +#define EADC_PWM0CH0_TRIGGER (0xEUL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< PWM0CH0 trigger \hideinitializer */ +#define EADC_PWM0CH1_TRIGGER (0xFUL << EADC_AD0SPCTL0_TRGSEL_Pos) /*!< PWM0CH1 trigger \hideinitializer */ + +#define EADC_SPCTL_TRGDLYDIV_DIVIDER_1 (0 << EADC_AD0SPCTL0_TRGDLYDIV_Pos) /*!< Trigger delay clock frequency is ADC_CLK/1 \hideinitializer */ +#define EADC_SPCTL_TRGDLYDIV_DIVIDER_2 (0x1UL << EADC_AD0SPCTL0_TRGDLYDIV_Pos) /*!< Trigger delay clock frequency is ADC_CLK/2 \hideinitializer */ +#define EADC_SPCTL_TRGDLYDIV_DIVIDER_4 (0x2UL << EADC_AD0SPCTL0_TRGDLYDIV_Pos) /*!< Trigger delay clock frequency is ADC_CLK/4 \hideinitializer */ +#define EADC_SPCTL_TRGDLYDIV_DIVIDER_16 (0x3UL << EADC_AD0SPCTL0_TRGDLYDIV_Pos) /*!< Trigger delay clock frequency is ADC_CLK/16 \hideinitializer */ + + +/*---------------------------------------------------------------------------------------------------------*/ +/* EADC_CMP Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define EADC_CMP_CMPCOND_LESS_THAN (0UL << EADC_CMP0_CMPCOND_Pos) /*!< The compare condition is "less than" \hideinitializer */ +#define EADC_CMP_CMPCOND_GREATER_OR_EQUAL (1UL << EADC_CMP0_CMPCOND_Pos) /*!< The compare condition is "greater than or equal to" \hideinitializer */ +#define EADC_CMP_ADCMPIE_ENABLE (EADC_CMP0_ADCMPIE_Msk) /*!< A/D result compare interrupt enable \hideinitializer */ +#define EADC_CMP_ADCMPIE_DISABLE (~EADC_CMP0_ADCMPIE_Msk) /*!< A/D result compare interrupt disable \hideinitializer */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* EADC PWM Trigger Condition Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define EADC0_TRIGGEREN0 0 /*!< A/D trigger condition for SAMPLE00 \hideinitializer */ +#define EADC0_TRIGGEREN1 1 /*!< A/D trigger condition for SAMPLE01 \hideinitializer */ +#define EADC0_TRIGGEREN2 2 /*!< A/D trigger condition for SAMPLE02 \hideinitializer */ +#define EADC0_TRIGGEREN3 3 /*!< A/D trigger condition for SAMPLE03 \hideinitializer */ +#define EADC1_TRIGGEREN0 4 /*!< A/D trigger condition for SAMPLE10 \hideinitializer */ +#define EADC1_TRIGGEREN1 5 /*!< A/D trigger condition for SAMPLE11 \hideinitializer */ +#define EADC1_TRIGGEREN2 6 /*!< A/D trigger condition for SAMPLE12 \hideinitializer */ +#define EADC1_TRIGGEREN3 7 /*!< A/D trigger condition for SAMPLE13 \hideinitializer */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* EADC Channel selection Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define EADC0_CH0 0 /*!< Select EADC0 channel 0 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_CH1 1 /*!< Select EADC0 channel 1 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_CH2 2 /*!< Select EADC0 channel 2 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_CH3 3 /*!< Select EADC0 channel 3 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_CH4 4 /*!< Select EADC0 channel 4 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_CH5 5 /*!< Select EADC0 channel 5 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_CH6 6 /*!< Select EADC0 channel 6 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_CH7 7 /*!< Select EADC0 channel 7 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_VBG 8 /*!< Select EADC0 VBG for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_VTEMP 9 /*!< Select EADC0 VTEMP for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_AVSS 10 /*!< Select EADC0 AVSS for EADC0 SAMPLE Module \hideinitializer */ +#define EADC0_OP0 11 /*!< Select EADC0 OP0 for EADC0 SAMPLE Module \hideinitializer */ +#define EADC1_CH0 0 /*!< Select EADC1 channel 0 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_CH1 1 /*!< Select EADC1 channel 1 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_CH2 2 /*!< Select EADC1 channel 2 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_CH3 3 /*!< Select EADC1 channel 3 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_CH4 4 /*!< Select EADC1 channel 4 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_CH5 5 /*!< Select EADC1 channel 5 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_CH6 6 /*!< Select EADC1 channel 6 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_CH7 7 /*!< Select EADC1 channel 7 for EADC1 SAMPLE Module \hideinitializer */ +#define EADC1_OP1 8 /*!< Select EADC1 OP1 for EADC1 SAMPLE Module \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_EADC_EXPORTED_CONSTANTS */ + +/** @addtogroup NUC472_442_EADC_EXPORTED_FUNCTIONS EADC Exported Functions + @{ +*/ +/*---------------------------------------------------------------------------------------------------------*/ +/* EADC Macro Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ + +/** + * @brief Power down EADC module + * @param[in] eadc Base address of EADC module + * @return None + * \hideinitializer + */ +#define EADC_POWER_DOWN(eadc) (EADC->CTL &= ~EADC_CTL_ADCEN_Msk) + +/** + * @brief Power on EADC module + * @param[in] eadc Base address of EADC module + * @return None + * \hideinitializer + */ +#define EADC_POWER_ON(eadc) (EADC->CTL |= EADC_CTL_ADCEN_Msk) + +/** + * @brief A/D Converter Control Circuits Reset. + * @param[in] eadc Base address of EADC module. + * @return None + * @details ADCRST bit (EADC_CT[1]) remains 1 during EADC reset, when EADC reset end, the ADCRST bit is automatically cleared to 0. + * \hideinitializer + */ +#define EADC_CONV_RESET(eadc) ((eadc)->CTL |= EADC_CTL_ADCRST_Msk) + +/** + * @brief Enable double buffer mode. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * @return None + * @details The EADC controller supports a double buffer mode in eadc0/1 sample module 0~3. + * \hideinitializer + */ +#define EADC_ENABLE_DOUBLE_BUFFER(eadc, u32ModuleNum) ((eadc)->DBMEN |= (1 << u32ModuleNum)) + +/** + * @brief Disable double buffer mode. + * @param[in] eadc Base address of EADC module.. + * @param[in] u32ModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * @return None + * @details Sample has one sample result register. + * \hideinitializer + */ +#define EADC_DISABLE_DOUBLE_BUFFER(eadc, u32ModuleNum) ((eadc)->DBMEN &= ~(1 << u32ModuleNum)) + +/** + * @brief Enable the interrupt. + * @param[in] eadc Base address of EADC module. + * @param[in] u32Mask Decides the combination of interrupt enable bits. Each bit corresponds to a interrupt enable. + * This parameter decides which interrupts will be enabled. Bit 0 is ADCIEN0, bit 1 is ADCIEN1..., bit 3 is ADCIEN3. + * @return None + * @details The A/D converter generates a conversion end ADIFn (EADC_STATUS1[n]) upon the end of specific sample module A/D conversion. + * If ADCIENn bit (EADC_CTL[n+2]) is set then conversion end interrupt request ADINTn is generated (n=0~3). + * \hideinitializer + */ +#define EADC_ENABLE_INT(eadc, u32Mask) ((eadc)->CTL |= ((u32Mask) << EADC_CTL_ADCIEN0_Pos)) + +/** + * @brief Disable the interrupt. + * @param[in] eadc Base address of EADC module. + * @param[in] u32Mask Decides the combination of interrupt enable bits. Each bit corresponds to a interrupt enable. + * This parameter decides which interrupts will be disabled. Bit 0 is ADCIEN0, bit 1 is ADCIEN1..., bit 3 is ADCIEN3. + * @return None + * @details Specific sample module A/D ADINT0 interrupt function Disabled. + * \hideinitializer + */ +#define EADC_DISABLE_INT(eadc, u32Mask) ((eadc)->CTL &= ~((u32Mask) << EADC_CTL_ADCIEN0_Pos)) + +/** + * @brief Enable the sample module interrupt. + * @param[in] eadc Base address of EADC module. + * @param[in] u32IntSel Decides which interrupt source will be used, valid value are from 0 to 3. + * @param[in] u32ModuleMask the combination of sample module interrupt enable bits. Each bit corresponds to a sample module interrupt enable. + * This parameter decides which sample module interrupts will be enabled, valid range are between 1~0xFFFF. + * @return None + * @details There are 4 EADC interrupts ADINT0~3, and each of these interrupts has its own interrupt vector address. + * \hideinitializer + */ +#define EADC_ENABLE_SAMPLE_MODULE_INT(eadc, u32IntSel, u32ModuleMask) ((eadc)->INTSRC[(u32IntSel)] |= (u32ModuleMask)) + +/** + * @brief Disable the sample module interrupt. + * @param[in] eadc Base address of EADC module. + * @param[in] u32IntSel Decides which interrupt source will be used, valid value are from 0 to 3. + * @param[in] u32ModuleMask the combination of sample module interrupt enable bits. Each bit corresponds to a sample module interrupt enable. + * This parameter decides which sample module interrupts will be disabled, valid range are between 1~0xFFFF. + * @return None + * @details There are 4 EADC interrupts ADINT0~3, and each of these interrupts has its own interrupt vector address. + * \hideinitializer + */ +#define EADC_DISABLE_SAMPLE_MODULE_INT(eadc, u32IntSel, u32ModuleMask) ((eadc)->INTSRC[(u32IntSel)] &= ~(u32ModuleMask)) + +/** + * @brief Start the A/D conversion. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleMask The combination of sample module. Each bit corresponds to a sample module. + * This parameter decides which sample module will be conversion, valid range are between 1~0xFFFF. + * Bit 0 is sample module 0, bit 1 is sample module 1..., bit 15 is sample module 15. + * @return None + * @details After write EADC_SWTRG register to start EADC conversion, the EADC_PENDSTS register will show which SAMPLE will conversion. + * \hideinitializer + */ +#define EADC_START_CONV(eadc, u32ModuleMask) ((eadc)->SWTRG = (u32ModuleMask)) + +/** + * @brief Get the conversion pending flag. + * @param[in] eadc Base address of EADC module. + * @return Return the conversion pending sample module. + * @return None + * @details This STPFn(EADC_PENDSTS[15:0]) bit remains 1 during pending state, when the respective EADC conversion is end, + * the STPFn (n=0~15) bit is automatically cleared to 0. + * \hideinitializer + */ +#define EADC_GET_PENDING_CONV(eadc) ((eadc)->PENDSTS) + +/** + * @brief Get the conversion data of the user-specified sample module. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref EADC0_SAMPLE_MODULE4 : EADC0 SAMPLE module 4 + * - \ref EADC0_SAMPLE_MODULE5 : EADC0 SAMPLE module 5 + * - \ref EADC0_SAMPLE_MODULE6 : EADC0 SAMPLE module 6 + * - \ref EADC0_SAMPLE_MODULE7 : EADC0 SAMPLE module 7 + * - \ref EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * - \ref EADC1_SAMPLE_MODULE4 : EADC1 SAMPLE module 4 + * - \ref EADC1_SAMPLE_MODULE5 : EADC1 SAMPLE module 5 + * - \ref EADC1_SAMPLE_MODULE6 : EADC1 SAMPLE module 6 + * - \ref EADC1_SAMPLE_MODULE7 : EADC1 SAMPLE module 7 + * @return Return the conversion data of the user-specified sample module. + * @details This macro is used to read RESULT bit (EADC_ADxDATn[11:0], x=0~1, n=0~7) field to get conversion data. + * \hideinitializer + */ +#define EADC_GET_CONV_DATA(eadc, u32ModuleNum) (*(__IO uint32_t *)(&((eadc)->AD0DAT0) + (u32ModuleNum)) & EADC_AD0DAT0_RESULT_Msk) + +/** + * @brief Get the data overrun flag of the user-specified sample module. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleMask The combination of data overrun status bits. Each bit corresponds to a data overrun status, valid range are between 1~0x7FFFF. + * @return Return the data overrun flag of the user-specified sample module. + * @details This macro is used to read OV bit (EADC_STATUS0[31:16]) field to get data overrun status. + * \hideinitializer + */ +#define EADC_GET_DATA_OVERRUN_FLAG(eadc, u32ModuleMask) (((eadc)->STATUS0 >> EADC_STATUS0_OV_Pos) & (u32ModuleMask)) + +/** + * @brief Get the data valid flag of the user-specified sample module. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleMask The combination of data valid status bits. Each bit corresponds to a data valid status, valid range are between 1~0x7FFFF. + * @return Return the data valid flag of the user-specified sample module. + * @details This macro is used to read VALID bit of EADC_STATUS0[15:0] to get data valid status. + * \hideinitializer + */ +#define EADC_GET_DATA_VALID_FLAG(eadc, u32ModuleMask) (((eadc)->STATUS0 & EADC_STATUS0_VALID_Msk) & (u32ModuleMask)) + +/** + * @brief Get the double data of the user-specified sample module. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * @return Return the double data of the user-specified sample module. + * @details This macro is used to read RESULT bit (EADC_ADxDDATn[11:0], x=0~1, n=0~3) field to get conversion data. + * \hideinitializer + */ +#define EADC_GET_DOUBLE_DATA(eadc, u32ModuleNum) (*(__IO uint32_t *)(&((eadc)->AD0DDAT0) + (u32ModuleNum)) & EADC_AD0DDAT0_RESULT_Msk) + +/** + * @brief Get the user-specified interrupt flags. + * @param[in] eadc Base address of EADC module. + * @param[in] u32Mask The combination of interrupt status bits. Each bit corresponds to a interrupt status. + * Bit 0 is ADIF0, bit 1 is ADIF1..., bit 3 is ADIF3. + * Bit 4 is ADCMPO0, bit 5 is ADCMPO1, bit 6 is ADCMPF0, bit 7 is ADCMPF1. + * @return Return the user-specified interrupt flags. + * @details This macro is used to get the user-specified interrupt flags. + * \hideinitializer + */ +#define EADC_GET_INT_FLAG(eadc, u32Mask) ((eadc)->STATUS1 & (u32Mask)) + +/** + * @brief Get the user-specified sample module overrun flags. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleMask The combination of sample module overrun status bits. Each bit corresponds to a sample module overrun status, valid range are between 1~0xFFFF. + * @return Return the user-specified sample module overrun flags. + * @details This macro is used to get the user-specified sample module overrun flags. + * \hideinitializer + */ +#define EADC_GET_SAMPLE_MODULE_OV_FLAG(eadc, u32ModuleMask) (((eadc)->STATUS0 >> EADC_STATUS0_OV_Pos) & u32ModuleMask) + +/** + * @brief Clear the selected interrupt status bits. + * @param[in] eadc Base address of EADC module. + * @param[in] u32Mask The combination of compare interrupt status bits. Each bit corresponds to a compare interrupt status. + * Bit 0 is ADIF0, bit 1 is ADIF1..., bit 3 is ADIF3. + * Bit 4 is ADCMPO0, bit 5 is ADCMPO1, bit 6 is ADCMPF0, bit 7 is ADCMPF1. + * @return None + * @details This macro is used to clear clear the selected interrupt status bits. + * \hideinitializer + */ +#define EADC_CLR_INT_FLAG(eadc, u32Mask) ((eadc)->STATUS1 = (u32Mask)) + +/** + * @brief Check all sample module A/D result data register overrun flags. + * @param[in] eadc Base address of EADC module. + * @retval 0 None of sample module data register overrun flag is set to 1. + * @retval 1 Any one of sample module data register overrun flag is set to 1. + * @details The AOV bit (EADC_STATUS1[27]) will keep 1 when any one of sample module data register overrun flag OVn (EADC_ADxDATn[16]) is set to 1. + * \hideinitializer + */ +#define EADC_IS_DATA_OV(eadc) (((eadc)->STATUS1 & EADC_STATUS1_AOV_Msk) >> EADC_STATUS1_AOV_Pos) + +/** + * @brief Check all sample module A/D result data register valid flags. + * @param[in] eadc Base address of EADC module. + * @retval 0 None of sample module data register valid flag is set to 1. + * @retval 1 Any one of sample module data register valid flag is set to 1. + * @details The AVALID bit (EADC_STATUS1[26]) will keep 1 when any one of sample module data register valid flag VALIDn (EADC_ADxDATn[17]) is set to 1. + * \hideinitializer + */ +#define EADC_IS_DATA_VALID(eadc) (((eadc)->STATUS1 & EADC_STATUS1_AVALID_Msk) >> EADC_STATUS1_AVALID_Pos) + +/** + * @brief Check all A/D sample module start of conversion overrun flags. + * @param[in] eadc Base address of EADC module. + * @retval 0 None of sample module event overrun flag is set to 1. + * @retval 1 Any one of sample module event overrun flag is set to 1. + * @details The STOVF bit (EADC_STATUS1[25]) will keep 1 when any one of sample module event overrun flag SPOVFn (EADC_OVSTS[n]) is set to 1. + * \hideinitializer + */ +#define EADC_IS_SAMPLE_MODULE_OV(eadc) (((eadc)->STATUS1 & EADC_STATUS1_STOVF_Msk) >> EADC_STATUS1_STOVF_Pos) + +/** + * @brief Check all A/D interrupt flag overrun bits. + * @param[in] eadc Base address of EADC module. + * @retval 0 None of ADINT interrupt flag is overwritten to 1. + * @retval 1 Any one of ADINT interrupt flag is overwritten to 1. + * @details The ADOVIF bit (EADC_STATUS1[24]) will keep 1 when any one of ADINT interrupt flag ADFOVn (EADC_ADIFOV[3:0]) is overwritten to 1. + * \hideinitializer + */ +#define EADC_IS_INT_FLAG_OV(eadc) (((eadc)->STATUS1 & EADC_STATUS1_ADOVIF_Msk) >> EADC_STATUS1_ADOVIF_Pos) + +/** + * @brief Get the busy state of EADC. + * @param[in] eadc Base address of EADC module. + * @param[in] converter Which converter, it should be 0 or 1. + * @retval 0 Idle state. + * @retval 1 Busy state. + * @details This macro is used to read BUSY0(EADC_STATUS1[8]) or BUSY1(EADC_STATUS1[16]) to get busy state. + * \hideinitializer + */ +#define EADC_IS_BUSY(eadc, converter) (((((eadc)->STATUS1 >> (EADC_STATUS1_BUSY0_Pos + (8 * converter)))) & EADC_STATUS1_BUSY0_Msk) ) + +/** + * @brief Configure the comparator 0 and enable it. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum specifies the compare sample module, valid values are: + * - \ref CMP_EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref CMP_EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref CMP_EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref CMP_EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref CMP_EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref CMP_EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref CMP_EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref CMP_EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * @param[in] u32Condition specifies the compare condition. Valid values are: + * - \ref EADC_CMP_CMPCOND_LESS_THAN :The compare condition is "less than the compare value" + * - \ref EADC_CMP_CMPCOND_GREATER_OR_EQUAL :The compare condition is "greater than or equal to the compare value + * @param[in] u16CMPData specifies the compare value, valid range are between 0~0xFFF. + * @param[in] u32MatchCount specifies the match count setting, valid range are between 0~0xF. + * @return None + * @details For example, ADC_ENABLE_CMP0(EADC, 5, ADC_ADCMPR_CMPCOND_GREATER_OR_EQUAL, 0x800, 10, EADC_CMP_CMPWEN_DISABLE, EADC_CMP_ADCMPIE_ENABLE); + * Means EADC will assert comparator 0 flag if sample module 5 conversion result is greater or + * equal to 0x800 for 10 times continuously, and a compare interrupt request is generated. + * \hideinitializer + */ +#define EADC_ENABLE_CMP0(eadc,\ + u32ModuleNum,\ + u32Condition,\ + u16CMPData,\ + u32MatchCount) ((eadc)->CMP[0] |=(((u32ModuleNum) << EADC_CMP0_CMPSPL_Pos)|\ + (u32Condition) |\ + ((u16CMPData) << EADC_CMP0_CMPDAT_Pos)| \ + (((u32MatchCount) - 1) << EADC_CMP0_CMPMCNT_Pos)|\ + EADC_CMP0_ADCMPEN_Msk)) + +/** + * @brief Configure the comparator 1 and enable it. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum specifies the compare sample module, valid values are: + * - \ref CMP_EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref CMP_EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref CMP_EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref CMP_EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref CMP_EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref CMP_EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref CMP_EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref CMP_EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * @param[in] u32Condition specifies the compare condition. Valid values are: + * - \ref EADC_CMP_CMPCOND_LESS_THAN :The compare condition is "less than the compare value" + * - \ref EADC_CMP_CMPCOND_GREATER_OR_EQUAL :The compare condition is "greater than or equal to the compare value + * @param[in] u16CMPData specifies the compare value, valid range are between 0~0xFFF. + * @param[in] u32MatchCount specifies the match count setting, valid range are between 0~0xF. + * @return None + * @details For example, ADC_ENABLE_CMP1(EADC, 5, ADC_ADCMPR_CMPCOND_GREATER_OR_EQUAL, 0x800, 10, EADC_CMP_ADCMPIE_ENABLE); + * Means EADC will assert comparator 1 flag if sample module 5 conversion result is greater or + * equal to 0x800 for 10 times continuously, and a compare interrupt request is generated. + * \hideinitializer + */ +#define EADC_ENABLE_CMP1(eadc,\ + u32ModuleNum,\ + u32Condition,\ + u16CMPData,\ + u32MatchCount) ((eadc)->CMP[1] |=(((u32ModuleNum) << EADC_CMP1_CMPSPL_Pos)|\ + (u32Condition) |\ + ((u16CMPData) << EADC_CMP1_CMPDAT_Pos)| \ + (((u32MatchCount) - 1) << EADC_CMP1_CMPMCNT_Pos)|\ + EADC_CMP1_ADCMPEN_Msk)) + +/** + * @brief Enable the compare interrupt. + * @param[in] eadc Base address of EADC module. + * @param[in] u32CMP Specifies the compare register, valid value are 0 and 1. + * @return None + * @details If the compare function is enabled and the compare condition matches the setting of CMPCOND (EADC_CMPn[2], n=0~1) + * and CMPMCNT (EADC_CMPn[11:8], n=0~1), ADCMPFn (EADC_STATUS1[7:6], n=0~1) will be asserted, in the meanwhile, + * if ADCMPIE is set to 1, a compare interrupt request is generated. + * \hideinitializer + */ +#define EADC_ENABLE_CMP_INT(eadc, u32CMP) ((eadc)->CMP[(u32CMP)] |= EADC_CMP0_ADCMPIE_Msk) + +/** + * @brief Disable the compare interrupt. + * @param[in] eadc Base address of EADC module. + * @param[in] u32CMP Specifies the compare register, valid value are 0 and 1. + * @return None + * @details This macro is used to disable the compare interrupt. + * \hideinitializer + */ +#define EADC_DISABLE_CMP_INT(eadc, u32CMP) ((eadc)->CMP[(u32CMP)] &= ~EADC_CMP0_ADCMPIE_Msk) + +/** + * @brief Disable comparator 0. + * @param[in] eadc Base address of EADC module. + * @return None + * @details This macro is used to disable comparator 0. + * \hideinitializer + */ +#define EADC_DISABLE_CMP0(eadc) ((eadc)->CMP[0] = 0) + +/** + * @brief Disable comparator 1. + * @param[in] eadc Base address of EADC module. + * @return None + * @details This macro is used to disable comparator 1. + * \hideinitializer + */ +#define EADC_DISABLE_CMP1(eadc) ((eadc)->CMP[1] = 0) + +/** + * @brief Enable simultaneous mode. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleMask The combination of sample module. Each bit corresponds to a sample module. + * This parameter decides which sample module will be set to simultaneous mode, valid range are between 1~0xFF. + * Bit 0 is sample module 0, bit 1 is sample module 1..., bit 7 is sample module 7. + * @return None + * @details This macro is used to set selected sample modules to be simultaneous mode. + * \hideinitializer + */ +#define EADC_ENABLE_SIMULTANEOUS(eadc,u32ModuleMask) ((eadc)->SIMUSEL |= (u32ModuleMask)) + +/** + * @brief Disable simultaneous mode. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleMask The combination of sample module. Each bit corresponds to a sample module. + * This parameter decides which sample module will be set to disable simultaneous mode, valid range are between 1~0xFF. + * Bit 0 is sample module 0, bit 1 is sample module 1..., bit 7 is sample module 7. + * @return None + * @details This macro is used to set selected sample modules to disable simultaneous mode. + * \hideinitializer + */ +#define EADC_DISABLE_SIMULTANEOUS(eadc,u32ModuleMask) ((eadc)->SIMUSEL &= ~(u32ModuleMask)) + +/** + * @brief Enable PWM and EPWM trigger trigger EADC condition. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ADTriggerModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_TRIGGEREN0 : AD trigger condition for SAMPLE00 + * - \ref EADC0_TRIGGEREN1 : AD trigger condition for SAMPLE01 + * - \ref EADC0_TRIGGEREN2 : AD trigger condition for SAMPLE02 + * - \ref EADC0_TRIGGEREN3 : AD trigger condition for SAMPLE03 + * - \ref EADC1_TRIGGEREN0 : AD trigger condition for SAMPLE10 + * - \ref EADC1_TRIGGEREN1 : AD trigger condition for SAMPLE11 + * - \ref EADC1_TRIGGEREN2 : AD trigger condition for SAMPLE12 + * - \ref EADC1_TRIGGEREN3 : AD trigger condition for SAMPLE13 + * @param[in] u32TriggerMask Decides the PWM and EPWM trigger EADC condition, valid range are between 0~0xFFFFFFFF. + * @return None + * @details This macro is used to enable PWM and EPWM trigger EADC condition. + */ +#define EADC_EnablePWMTriggerCondition(eadc,u32ADTriggerModuleNum,u32TriggerMask) (*(__IO uint32_t *)(&(eadc)->AD0TRGEN0 + (u32ADTriggerModuleNum)) |= (u32TriggerMask)) + +/** + * @brief Disable PWM and EPWM trigger trigger EADC condition. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ADTriggerModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_TRIGGEREN0 : AD trigger condition for SAMPLE00 + * - \ref EADC0_TRIGGEREN1 : AD trigger condition for SAMPLE01 + * - \ref EADC0_TRIGGEREN2 : AD trigger condition for SAMPLE02 + * - \ref EADC0_TRIGGEREN3 : AD trigger condition for SAMPLE03 + * - \ref EADC1_TRIGGEREN0 : AD trigger condition for SAMPLE10 + * - \ref EADC1_TRIGGEREN1 : AD trigger condition for SAMPLE11 + * - \ref EADC1_TRIGGEREN2 : AD trigger condition for SAMPLE12 + * - \ref EADC1_TRIGGEREN3 : AD trigger condition for SAMPLE13 + * @param[in] u32TriggerMask Decides the PWM and EPWM trigger EADC condition, valid range are between 0~0xFFFFFFFF. + * @return None + * @details This macro is used to disable PWM and EPWM trigger EADC condition. + */ +#define EADC_DisablePWMTriggerCondition(eadc,u32ADTriggerModuleNum,u32TriggerMask) (*(__IO uint32_t *)(&(eadc)->AD0TRGEN0 + (u32ADTriggerModuleNum)) |= (u32TriggerMask)) + +/*---------------------------------------------------------------------------------------------------------*/ +/* Define EADC functions prototype */ +/*---------------------------------------------------------------------------------------------------------*/ +void EADC_Open(EADC_T *eadc, uint32_t u32InputMode); +void EADC_Close(EADC_T *eadc); +void EADC_ConfigSampleModule(EADC_T *eadc, \ + uint32_t u32ModuleNum, \ + uint32_t u32TriggerSource, \ + uint32_t u32Channel); +void EADC_SetTriggerDelayTime(EADC_T *eadc, \ + uint32_t u32ModuleNum, \ + uint32_t u32TriggerDelayTime, \ + uint32_t u32DelayClockDivider); +void EADC_SetExtendSampleTime(EADC_T *eadc, uint32_t u32ModuleNum, uint32_t u32ExtendSampleTime); + +/*@}*/ /* end of group NUC472_442_EADC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_EADC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + + +#ifdef __cplusplus +} +#endif + +#endif //__EADC_H__ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/ebi.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/ebi.h new file mode 100644 index 0000000000000000000000000000000000000000..d340f8f0375ff10d502834c6abf2f80be5827f43 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/ebi.h @@ -0,0 +1,136 @@ +/****************************************************************************//** + * @file ebi.h + * @version V0.10 + * $Revision: 6 $ + * $Date: 14/09/30 1:12p $ + * @brief NUC472/NUC442 EBI driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#ifndef __EBI_H__ +#define __EBI_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_EBI_Driver EBI Driver + @{ +*/ + +/** @addtogroup NUC472_442_EBI_EXPORTED_CONSTANTS EBI Exported Constants + @{ +*/ + +/* Bank-0 constants */ +#define EBI0_BASE_ADDR 0x60000000 ///CTL |= EMAC_CTL_TXON_Msk) + + +/** + * @brief Enable EMAC Rx function + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_ENABLE_RX() do{EMAC->CTL |= EMAC_CTL_RXON_Msk; EMAC->RXST = 0;}while(0) + +/** + * @brief Disable EMAC Tx function + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_DISABLE_TX() (EMAC->CTL &= ~EMAC_CTL_TXON_Msk) + + +/** + * @brief Disable EMAC Rx function + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_DISABLE_RX() (EMAC->CTL &= ~EMAC_CTL_RXON_Msk) + +/** + * @brief Enable EMAC Magic Packet Wakeup function + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_ENABLE_MAGIC_PKT_WAKEUP() (EMAC->CTL |= EMAC_CTL_WOLEN_Msk) + + +/** + * @brief Disable EMAC Magic Packet Wakeup function + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_DISABLE_MAGIC_PKT_WAKEUP() (EMAC->CTL &= ~EMAC_CTL_WOLEN_Msk) + +/** + * @brief Enable EMAC MII interface + * @param None + * @return None + * @details After calling \ref EMAC_Open, EMAC use RMII interface by default, but can switch to + * MII interface by calling this macro + * \hideinitializer + */ +#define EMAC_ENABLE_MII_INTF() (EMAC->CTL &= ~(EMAC_CTL_RMIIEN_Msk | EMAC_CTL_RMIIRXCTL_Msk)) + +/** + * @brief Enable EMAC to receive broadcast packets + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_ENABLE_RECV_BCASTPKT() (EMAC->CAMCTL |= EMAC_CAMCTL_ABP_Msk) + +/** + * @brief Disable EMAC to receive broadcast packets + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_DISABLE_RECV_BCASTPKT() (EMAC->CAMCTL &= ~EMAC_CAMCTL_ABP_Msk) + +/** + * @brief Enable EMAC to receive multicast packets + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_ENABLE_RECV_MCASTPKT() (EMAC->CAMCTL |= EMAC_CAMCTL_AMP_Msk) + +/** + * @brief Disable EMAC Magic Packet Wakeup function + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_DISABLE_RECV_MCASTPKT() (EMAC->CAMCTL &= ~EMAC_CAMCTL_AMP_Msk) + +/** + * @brief Check if EMAC time stamp alarm interrupt occurred or not + * @param None + * @return If time stamp alarm interrupt occurred or not + * @retval 0 Alarm interrupt does not occur + * @retval 1 Alarm interrupt occurred + * \hideinitializer + */ +#define EMAC_GET_ALARM_FLAG() (EMAC->INTSTS & EMAC_INTSTS_TSALMIF_Msk ? 1 : 0) + +/** + * @brief Clear EMAC time stamp alarm interrupt flag + * @param None + * @return None + * \hideinitializer + */ +#define EMAC_CLR_ALARM_FLAG() (EMAC->INTSTS = EMAC_INTSTS_TSALMIF_Msk) + + +void EMAC_Open(uint8_t *pu8MacAddr); +void EMAC_Close(void); +void EMAC_SetMacAddr(uint8_t *pu8MacAddr); +void EMAC_EnableCamEntry(uint32_t u32Entry, uint8_t *pu8MacAddr); +void EMAC_DisableCamEntry(uint32_t u32Entry); + +uint32_t EMAC_RecvPkt(uint8_t *pu8Data, uint32_t *pu32Size); +uint32_t EMAC_RecvPktTS(uint8_t *pu8Data, uint32_t *pu32Size, uint32_t *pu32Sec, uint32_t *pu32Nsec); +void EMAC_RecvPktDone(void); + +uint32_t EMAC_SendPkt(uint8_t *pu8Data, uint32_t u32Size); +uint32_t EMAC_SendPktDone(void); +uint32_t EMAC_SendPktDoneTS(uint32_t *pu32Sec, uint32_t *pu32Nsec); + +void EMAC_EnableTS(uint32_t u32Sec, uint32_t u32Nsec); +void EMAC_DisableTS(void); +void EMAC_GetTime(uint32_t *pu32Sec, uint32_t *pu32Nsec); +void EMAC_SetTime(uint32_t u32Sec, uint32_t u32Nsec); +void EMAC_UpdateTime(uint32_t u32Neg, uint32_t u32Sec, uint32_t u32Nsec); +void EMAC_EnableAlarm(uint32_t u32Sec, uint32_t u32Nsec); +void EMAC_DisableAlarm(void); + + + +/*@}*/ /* end of group NUC472_442_EMAC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_EMAC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__EMAC_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/epwm.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/epwm.h new file mode 100644 index 0000000000000000000000000000000000000000..3a1550cae81a2841196da2a635281aa04293c43e --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/epwm.h @@ -0,0 +1,255 @@ +/**************************************************************************//** + * @file epwm.h + * @version V1.00 + * $Revision: 3 $ + * $Date: 15/12/02 5:23p $ + * @brief NUC472/NUC442 EPWM driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __EPWM_H__ +#define __EPWM_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_EPWM_Driver EPWM Driver + @{ +*/ + +/** @addtogroup NUC472_442_EPWM_EXPORTED_CONSTANTS EPWM Exported Constants + @{ +*/ +#define EPWM_CHANNEL_NUM (6) /*!< EPWM channel number \hideinitializer */ +#define EPWM_CH0 (0UL) /*!< EPWM channel 0 \hideinitializer */ +#define EPWM_CH1 (1UL) /*!< EPWM channel 1 \hideinitializer */ +#define EPWM_CH2 (2UL) /*!< EPWM channel 2 \hideinitializer */ +#define EPWM_CH3 (3UL) /*!< EPWM channel 3 \hideinitializer */ +#define EPWM_CH4 (4UL) /*!< EPWM channel 4 \hideinitializer */ +#define EPWM_CH5 (5UL) /*!< EPWM channel 5 \hideinitializer */ +#define EPWM_CH_0_MASK (1UL) /*!< EPWM channel 0 mask \hideinitializer */ +#define EPWM_CH_1_MASK (2UL) /*!< EPWM channel 1 mask \hideinitializer */ +#define EPWM_CH_2_MASK (4UL) /*!< EPWM channel 2 mask \hideinitializer */ +#define EPWM_CH_3_MASK (8UL) /*!< EPWM channel 3 mask \hideinitializer */ +#define EPWM_CH_4_MASK (16UL) /*!< EPWM channel 4 mask \hideinitializer */ +#define EPWM_CH_5_MASK (32UL) /*!< EPWM channel 5 mask \hideinitializer */ +#define EPWM_CH_6_MASK (64UL) /*!< EPWM channel 6 mask \hideinitializer */ +#define EPWM_CLK_DIV_1 (0UL) /*!< EPWM clock divide by 1 \hideinitializer */ +#define EPWM_CLK_DIV_2 (1UL) /*!< EPWM clock divide by 2 \hideinitializer */ +#define EPWM_CLK_DIV_4 (2UL) /*!< EPWM clock divide by 4 \hideinitializer */ +#define EPWM_CLK_DIV_16 (3UL) /*!< EPWM clock divide by 16 \hideinitializer */ +#define EPWM_EDGE_ALIGNED (0UL) /*!< EPWM working in edge aligned type \hideinitializer */ +#define EPWM_CENTER_ALIGNED (EPWM_CTL_CNTTYPE_Msk) /*!< EPWM working in center aligned type \hideinitializer */ +#define EPWM_BRK0_BKP0 (EPWM_CTL_BRKP0EN_Msk) /*!< Brake0 signal source from external pin BKP0 \hideinitializer */ +#define EPWM_BRK0_CPO0 (EPWM_CTL_CPO0BKEN_Msk) /*!< Brake0 signal source from analog comparator 0 output \hideinitializer */ +#define EPWM_BRK0_CPO1 (EPWM_CTL_CPO1BKEN_Msk) /*!< Brake0 signal source from analog comparator 1 output \hideinitializer */ +#define EPWM_BRK0_CPO2 (EPWM_CTL_CPO2BKEN_Msk) /*!< Brake0 signal source from analog comparator 2 output \hideinitializer */ +#define EPWM_BRK1_LVDBKEN (EPWM_CTL_LVDBKEN_Msk) /*!< Brake1 signal source from low level detection \hideinitializer */ +#define EPWM_BK1SEL_BKP1 (0UL << EPWM_CTL_BRK1SEL_Pos) /*!< Brake1 signal source from external pin BKP1 \hideinitializer */ +#define EPWM_BK1SEL_CPO0 (1UL << EPWM_CTL_BRK1SEL_Pos) /*!< Brake1 signal source from analog comparator 0 output \hideinitializer */ +#define EPWM_BK1SEL_CPO1 (2UL << EPWM_CTL_BRK1SEL_Pos) /*!< Brake1 signal source from analog comparator 1 output \hideinitializer */ +#define EPWM_BK1SEL_CPO2 (3UL << EPWM_CTL_BRK1SEL_Pos) /*!< Brake1 signal source from analog comparator 2 output \hideinitializer */ +#define EPWM_PERIOD_INT_UNDERFLOW (0) /*!< EPWM period interrupt trigger if counter underflow \hideinitializer */ +#define EPWM_PERIOD_INT_MATCH_CNR (EPWM_CTL_INTTYPE_Msk) /*!< EPWM period interrupt trigger if counter match CNR \hideinitializer */ +#define EPWM_MODE_INDEPENDENT (0UL) /*!< EPWM independent mode \hideinitializer */ +#define EPWM_MODE_COMPLEMENTARY (1UL) /*!< EPWM complementary mode \hideinitializer */ +#define EPWM_MODE_SYNCHRONIZED (2UL) /*!< EPWM synchronized mode \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_EPWM_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_EPWM_EXPORTED_FUNCTIONS EPWM Exported Functions + @{ +*/ + +/** + * @brief This macro enable complementary mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define EPWM_ENABLE_COMPLEMENTARY_MODE(pwm) ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_MODE_Msk) | (EPWM_MODE_COMPLEMENTARY << EPWM_CTL_MODE_Pos)) + +/** + * @brief This macro disable complementary mode, and enable independent mode. + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define EPWM_DISABLE_COMPLEMENTARY_MODE(pwm) ((pwm)->CTL &= ~EPWM_CTL_MODE_Msk) + +/** + * @brief This macro enable group mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define EPWM_ENABLE_GROUP_MODE(pwm) ((pwm)->CTL |= EPWM_CTL_GROUPEN_Msk) + +/** + * @brief This macro disable group mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define EPWM_DISABLE_GROUP_MODE(pwm) ((pwm)->CTL &= ~EPWM_CTL_GROUPEN_Msk) + +/** + * @brief This macro enable synchronous mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define EPWM_ENABLE_SYNC_MODE(pwm) ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_MODE_Msk) | (EPWM_MODE_SYNCHRONIZED << EPWM_CTL_MODE_Pos)) + +/** + * @brief This macro disable synchronous mode, and enable independent mode. + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define EPWM_DISABLE_SYNC_MODE(pwm) ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_MODE_Msk)) + +/** + * @brief This macro enable output inverter of specified channel(s) + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel + * Bit 0 represents channel 0, bit 1 represents channel 1... + * @return None + * \hideinitializer + */ +#define EPWM_ENABLE_OUTPUT_INVERTER(pwm, u32ChannelMask) \ +do { \ + if ((u32ChannelMask)) \ + ((pwm)->CTL |= EPWM_CTL_PINV_Msk); \ + else \ + ((pwm)->CTL &= ~EPWM_CTL_PINV_Msk); \ +}while(0) + +/** + * @brief This macro mask output output logic to high or low + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel + * Bit 0 represents channel 0, bit 1 represents channel 1... + * @param[in] u32LevelMask Output logic to high or low + * @return None + * \hideinitializer + */ +#define EPWM_MASK_OUTPUT(pwm, u32ChannelMask, u32LevelMask) \ +do { \ + (pwm)->MSKEN = u32ChannelMask; \ + (pwm)->MSK = u32ChannelMask; \ +}while(0) + +/** + * @brief This macro set the divider of the selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Divider Clock divider of specified channel. Valid values are + * - \ref EPWM_CLK_DIV_1 + * - \ref EPWM_CLK_DIV_2 + * - \ref EPWM_CLK_DIV_4 + * - \ref EPWM_CLK_DIV_16 + * @return None + * \hideinitializer + */ +#define EPWM_SET_DIVIDER(pwm, u32ChannelNum, u32Divider) \ + ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_CLKDIV_Msk) | ((u32Divider) << EPWM_CTL_CLKDIV_Pos)) + +/** + * @brief This macro set the duty of the selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32CMR Duty of specified channel. Valid values are between 0~0xFFFF + * @return None + * @note This new setting will take effect on next PWM period + * \hideinitializer + */ +#define EPWM_SET_CMR(pwm, u32ChannelNum, u32CMR) \ +do { \ + (pwm)->CMPDAT[(u32ChannelNum) >> 1] = (u32CMR); \ + (pwm)->CTL |= EPWM_CTL_LOAD_Msk; \ +}while(0) + +/** + * @brief This macro set the period of the selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32CNR Period of specified channel. Valid values are between 0~0xFFFF + * @return None + * @note This new setting will take effect on next PWM period + * @note PWM counter will stop if period length set to 0 + * \hideinitializer + */ +#define EPWM_SET_CNR(pwm, u32ChannelNum, u32CNR) \ +do { \ + (pwm)->PERIOD = (u32CNR); \ + (pwm)->CTL |= EPWM_CTL_LOAD_Msk; \ +}while(0) + +/** + * @brief This macro set the PWM aligned type + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask This parameter is not used + * @param[in] u32AlignedType PWM aligned type, valid values are: + * - \ref EPWM_EDGE_ALIGNED + * - \ref EPWM_CENTER_ALIGNED + * @return None + * \hideinitializer + */ +#define EPWM_SET_ALIGNED_TYPE(pwm, u32ChannelMask, u32AlignedType) \ + ((pwm)->CTL = ((pwm)->CTL & ~EPWM_CTL_CNTTYPE_Msk) | (u32AlignedType)) + + +uint32_t EPWM_ConfigOutputChannel(EPWM_T *pwm, + uint32_t u32ChannelNum, + uint32_t u32Frequency, + uint32_t u32DutyCycle); +void EPWM_Start (EPWM_T *pwm, uint32_t u32ChannelMask); +void EPWM_Stop(EPWM_T *pwm, uint32_t u32ChannelMask); +void EPWM_ForceStop(EPWM_T *pwm, uint32_t u32ChannelMask); +void EPWM_EnableFaultBrake(EPWM_T *pwm, + uint32_t u32ChannelMask, + uint32_t u32LevelMask, + uint32_t u32BrakeSource); +void EPWM_ClearFaultBrakeFlag(EPWM_T *pwm, uint32_t u32BrakeSource); +void EPWM_EnableOutput(EPWM_T *pwm, uint32_t u32ChannelMask); +void EPWM_DisableOutput(EPWM_T *pwm, uint32_t u32ChannelMask); +void EPWM_EnableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration); +void EPWM_DisableDeadZone(EPWM_T *pwm, uint32_t u32ChannelNum); +void EPWM_EnableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType); +void EPWM_DisableDutyInt(EPWM_T *pwm, uint32_t u32ChannelNum); +void EPWM_ClearDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum); +uint32_t EPWM_GetDutyIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum); +void EPWM_EnableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource); +void EPWM_DisableFaultBrakeInt(EPWM_T *pwm, uint32_t u32BrakeSource); +void EPWM_ClearFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource); +uint32_t EPWM_GetFaultBrakeIntFlag(EPWM_T *pwm, uint32_t u32BrakeSource); +void EPWM_EnablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType); +void EPWM_DisablePeriodInt(EPWM_T *pwm, uint32_t u32ChannelNum); +void EPWM_ClearPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum); +uint32_t EPWM_GetPeriodIntFlag(EPWM_T *pwm, uint32_t u32ChannelNum); + + + +/*@}*/ /* end of group NUC472_442_EPWM_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_EPWM_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__EPWM_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/fmc.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/fmc.h new file mode 100644 index 0000000000000000000000000000000000000000..60dff06de5034ba92c234dcc1ac76b952995ce68 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/fmc.h @@ -0,0 +1,212 @@ +/**************************************************************************//** + * @file fmc.h + * @version V1.10 + * $Revision: 14 $ + * $Date: 15/11/20 9:55a $ + * @brief NUC472/NUC442 Flash Memory Controller Driver Header File + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + * + ******************************************************************************/ +#ifndef __FMC_H__ +#define __FMC_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_FMC_Driver FMC Driver + @{ +*/ + + +/** @addtogroup NUC472_442_FMC_EXPORTED_CONSTANTS FMC Exported Constants + @{ +*/ + + +/*---------------------------------------------------------------------------------------------------------*/ +/* Define Base Address */ +/*---------------------------------------------------------------------------------------------------------*/ +#define FMC_APROM_BASE 0x00000000UL /*!< APROM Base Address \hideinitializer */ +#define FMC_APROM_END 0x00080000UL /*!< APROM End Address \hideinitializer */ +#define FMC_LDROM_BASE 0x00100000UL /*!< LDROM Base Address \hideinitializer */ +#define FMC_LDROM_END 0x00104000UL /*!< LDROM End Address \hideinitializer */ +#define FMC_CONFIG_BASE 0x00300000UL /*!< User Configuration Address \hideinitializer */ + +#define FMC_FLASH_PAGE_SIZE 0x800 /*!< Flash Page Size (2 Kbytes) \hideinitializer */ +#define FMC_LDROM_SIZE 0x4000 /*!< LDROM Size (16 Kbytes) \hideinitializer */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* ISPCMD constant definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define FMC_ISPCMD_READ 0x00 /*!< ISP Command: Read flash word \hideinitializer */ +#define FMC_ISPCMD_READ_64 0x40 /*!< ISP Command: Read flash double word \hideinitializer */ +#define FMC_ISPCMD_WRITE 0x21 /*!< ISP Command: Write flash word \hideinitializer */ +#define FMC_ISPCMD_WRITE_64 0x61 /*!< ISP Command: Write flash double word \hideinitializer */ +#define FMC_ISPCMD_PAGE_ERASE 0x22 /*!< ISP Command: Page Erase Flash \hideinitializer */ +#define FMC_ISPCMD_READ_CID 0x0B /*!< ISP Command: Read Company ID \hideinitializer */ +#define FMC_ISPCMD_READ_PID 0x0C /*!< ISP Command: Read ProductID \hideinitializer */ +#define FMC_ISPCMD_READ_UID 0x04 /*!< ISP Command: Read Unique ID \hideinitializer */ +#define ISP_ISPCMD_MULTI_WRITE 0x27 /*!< ISP Command: Multiple program \hideinitializer */ +#define FMC_ISPCMD_VECMAP 0x2E /*!< ISP Command: Vector Page Remap \hideinitializer */ + +#define IS_BOOT_FROM_APROM 0 /*!< Is booting from APROM \hideinitializer */ +#define IS_BOOT_FROM_LDROM 1 /*!< Is booting from LDROM \hideinitializer */ + + +/*@}*/ /* end of group NUC472_442_FMC_EXPORTED_CONSTANTS */ + + + +/** @addtogroup NUC472_442_FMC_EXPORTED_FUNCTIONS FMC Exported Functions + @{ +*/ + + +/*---------------------------------------------------------------------------------------------------------*/ +/* Macros */ +/*---------------------------------------------------------------------------------------------------------*/ + +/** + * @brief This macro selects booting from APROM. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_SET_APROM_BOOT() (FMC->ISPCTL &= ~FMC_ISPCTL_BS_Msk) + +/** + * @brief This macro selects booting from LDROM. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_SET_LDROM_BOOT() (FMC->ISPCTL |= FMC_ISPCTL_BS_Msk) + +/** + * @brief This macro enables APROM update function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_ENABLE_AP_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_APUEN_Msk) + +/** + * @brief This macro disables APROM update function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_DISABLE_AP_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_APUEN_Msk) + +/** + * @brief This macro enables User Configuration update function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_ENABLE_CFG_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_CFGUEN_Msk) + +/** + * @brief This macro disables User Configuration update function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_DISABLE_CFG_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_CFGUEN_Msk) + +/** + * @brief This macro enables LDROM update function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_ENABLE_LD_UPDATE() (FMC->ISPCTL |= FMC_ISPCTL_LDUEN_Msk) + +/** + * @brief This macro disables LDROM update function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_DISABLE_LD_UPDATE() (FMC->ISPCTL &= ~FMC_ISPCTL_LDUEN_Msk) + +/** + * @brief This macro enables ISP function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_ENABLE_ISP() (FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk) /*!< Enable ISP function \hideinitializer */ + +/** + * @brief This macro disables ISP function. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_DISABLE_ISP() (FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk) + +/** + * @brief This macro gets ISP fail flag value. + * @param None + * @return ISP fail flag value. + * \hideinitializer + */ +#define FMC_GET_FAIL_FLAG() ((FMC->ISPSTS & FMC_ISPSTS_ISPFF_Msk) ? 1 : 0) + +/** + * @brief This macro clears ISP fail flag. + * @param None + * @return None + * \hideinitializer + */ +#define FMC_CLR_FAIL_FLAG() (FMC->ISPSTS |= FMC_ISPSTS_ISPFF_Msk) /*!< Clear ISP fail flag \hideinitializer */ + + + + +/*---------------------------------------------------------------------------------------------------------*/ +/* Functions */ +/*---------------------------------------------------------------------------------------------------------*/ + +extern void FMC_Close(void); +extern int32_t FMC_Erase(uint32_t u32PageAddr); +extern int32_t FMC_GetBootSource(void); +extern void FMC_Open(void); +extern uint32_t FMC_Read(uint32_t u32Addr); +extern void FMC_Read_64(uint32_t u32Addr, uint32_t *u32Data0, uint32_t *u32Data1); +extern uint32_t FMC_ReadCID(void); +extern uint32_t FMC_ReadPID(void); +extern uint32_t FMC_ReadUCID(uint32_t u32Index); +extern uint32_t FMC_ReadUID(uint32_t u32Index); +extern uint32_t FMC_ReadDataFlashBaseAddr(void); +extern void FMC_SetVectorPageAddr(uint32_t u32PageAddr); +extern uint32_t FMC_GetVectorPageAddr(void); +extern void FMC_Write(uint32_t u32Addr, uint32_t u32Data); +extern void FMC_Write_64(uint32_t u32Addr, uint32_t u32Data0, uint32_t u32Data1); +extern int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count); +extern int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count); +extern uint32_t FMC_CRC8(uint32_t au32Data[], int i32Count); + + +/*@}*/ /* end of group NUC472_442_FMC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_FMC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/gpio.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/gpio.h new file mode 100644 index 0000000000000000000000000000000000000000..233b3cc89fda0543e1d2b5529476e30de98be580 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/gpio.h @@ -0,0 +1,509 @@ +/**************************************************************************//** + * @file gpio.h + * @version V1.00 + * $Revision: 13 $ + * $Date: 14/12/01 10:32a $ + * @brief NUC472/NUC442 GPIO driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __GPIO_H__ +#define __GPIO_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_GPIO_Driver GPIO Driver + @{ +*/ + +/** @addtogroup NUC472_442_GPIO_EXPORTED_CONSTANTS GPIO Exported Constants + @{ +*/ +#define GPIO_PIN_MAX 16 /*!< Specify Maximum Pins of Each GPIO Port */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* MODE Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define GPIO_MODE_INPUT 0x0UL /*!< Input Mode */ +#define GPIO_MODE_OUTPUT 0x1UL /*!< Output Mode */ +#define GPIO_MODE_OPEN_DRAIN 0x2UL /*!< Open-Drain Mode */ +#define GPIO_MODE_QUASI 0x3UL /*!< Quasi-bidirectional Mode */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* GPIO Interrupt Type Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define GPIO_INT_RISING 0x00010000UL /*!< Interrupt enable by Input Rising Edge */ +#define GPIO_INT_FALLING 0x00000001UL /*!< Interrupt enable by Input Falling Edge */ +#define GPIO_INT_BOTH_EDGE 0x00010001UL /*!< Interrupt enable by both Rising Edge and Falling Edge */ +#define GPIO_INT_HIGH 0x01010000UL /*!< Interrupt enable by Level-High */ +#define GPIO_INT_LOW 0x01000001UL /*!< Interrupt enable by Level-Level */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* IMD Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define GPIO_IMD_EDGE 0UL /*!< IMD Setting for Edge Trigger Mode */ +#define GPIO_IMD_LEVEL 1UL /*!< IMD Setting for Edge Level Mode */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* DBCTL Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define GPIO_DBCTL_ICLK_ON 0x00000020UL /*!< DBCTL setting for all IO pins edge detection circuit is always active after reset */ +#define GPIO_DBCTL_ICLK_OFF 0x00000000UL /*!< DBCTL setting for edge detection circuit is active only if IO pin corresponding GPIOx_IEN bit is set to 1 */ + +#define GPIO_DBCTL_DBCLKSRC_IRC10K 0x00000010UL /*!< DBCTL setting for de-bounce counter clock source is the internal 10 kHz */ +#define GPIO_DBCTL_DBCLKSRC_HCLK 0x00000000UL /*!< DBCTL setting for de-bounce counter clock source is the internal HCLK */ + +#define GPIO_DBCTL_DBCLKSEL_1 0x00000000UL /*!< DBCTL setting for sampling cycle = 1 clocks */ +#define GPIO_DBCTL_DBCLKSEL_2 0x00000001UL /*!< DBCTL setting for sampling cycle = 2 clocks */ +#define GPIO_DBCTL_DBCLKSEL_4 0x00000002UL /*!< v setting for sampling cycle = 4 clocks */ +#define GPIO_DBCTL_DBCLKSEL_8 0x00000003UL /*!< DBCTL setting for sampling cycle = 8 clocks */ +#define GPIO_DBCTL_DBCLKSEL_16 0x00000004UL /*!< DBCTL setting for sampling cycle = 16 clocks */ +#define GPIO_DBCTL_DBCLKSEL_32 0x00000005UL /*!< DBCTL setting for sampling cycle = 32 clocks */ +#define GPIO_DBCTL_DBCLKSEL_64 0x00000006UL /*!< DBCTL setting for sampling cycle = 64 clocks */ +#define GPIO_DBCTL_DBCLKSEL_128 0x00000007UL /*!< DBCTL setting for sampling cycle = 128 clocks */ +#define GPIO_DBCTL_DBCLKSEL_256 0x00000008UL /*!< DBCTL setting for sampling cycle = 256 clocks */ +#define GPIO_DBCTL_DBCLKSEL_512 0x00000009UL /*!< DBCTL setting for sampling cycle = 512 clocks */ +#define GPIO_DBCTL_DBCLKSEL_1024 0x0000000AUL /*!< DBCTL setting for sampling cycle = 1024 clocks */ +#define GPIO_DBCTL_DBCLKSEL_2048 0x0000000BUL /*!< DBCTL setting for sampling cycle = 2048 clocks */ +#define GPIO_DBCTL_DBCLKSEL_4096 0x0000000CUL /*!< DBCTL setting for sampling cycle = 4096 clocks */ +#define GPIO_DBCTL_DBCLKSEL_8192 0x0000000DUL /*!< DBCTL setting for sampling cycle = 8192 clocks */ +#define GPIO_DBCTL_DBCLKSEL_16384 0x0000000EUL /*!< DBCTL setting for sampling cycle = 16384 clocks */ +#define GPIO_DBCTL_DBCLKSEL_32768 0x0000000FUL /*!< DBCTL setting for sampling cycle = 32768 clocks */ + +/** Define GPIO Pin Data Input/Output. It could be used to control each I/O pin by pin address mapping. + * Example 1: + * + * PA0 = 1; + * + * It is used to set PA0 to high; + * + * Example 2: + * + * if (PA0) + * PA0 = 0; + * + * If PA0 pin status is high, then set PA0 data output to low. + */ +#define GPIO_PIN_ADDR(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) +#define PA0 GPIO_PIN_ADDR(0, 0) /*!< Specify PA0 Pin Data Input/Output */ +#define PA1 GPIO_PIN_ADDR(0, 1) /*!< Specify PA1 Pin Data Input/Output */ +#define PA2 GPIO_PIN_ADDR(0, 2) /*!< Specify PA2 Pin Data Input/Output */ +#define PA3 GPIO_PIN_ADDR(0, 3) /*!< Specify PA3 Pin Data Input/Output */ +#define PA4 GPIO_PIN_ADDR(0, 4) /*!< Specify PA4 Pin Data Input/Output */ +#define PA5 GPIO_PIN_ADDR(0, 5) /*!< Specify PA5 Pin Data Input/Output */ +#define PA6 GPIO_PIN_ADDR(0, 6) /*!< Specify PA6 Pin Data Input/Output */ +#define PA7 GPIO_PIN_ADDR(0, 7) /*!< Specify PA7 Pin Data Input/Output */ +#define PA8 GPIO_PIN_ADDR(0, 8) /*!< Specify PA8 Pin Data Input/Output */ +#define PA9 GPIO_PIN_ADDR(0, 9) /*!< Specify PA9 Pin Data Input/Output */ +#define PA10 GPIO_PIN_ADDR(0, 10) /*!< Specify PA10 Pin Data Input/Output */ +#define PA11 GPIO_PIN_ADDR(0, 11) /*!< Specify PA11 Pin Data Input/Output */ +#define PA12 GPIO_PIN_ADDR(0, 12) /*!< Specify PA12 Pin Data Input/Output */ +#define PA13 GPIO_PIN_ADDR(0, 13) /*!< Specify PA13 Pin Data Input/Output */ +#define PA14 GPIO_PIN_ADDR(0, 14) /*!< Specify PA14 Pin Data Input/Output */ +#define PA15 GPIO_PIN_ADDR(0, 15) /*!< Specify PA15 Pin Data Input/Output */ + +#define PB0 GPIO_PIN_ADDR(1, 0) /*!< Specify PB0 Pin Data Input/Output */ +#define PB1 GPIO_PIN_ADDR(1, 1) /*!< Specify PB1 Pin Data Input/Output */ +#define PB2 GPIO_PIN_ADDR(1, 2) /*!< Specify PB2 Pin Data Input/Output */ +#define PB3 GPIO_PIN_ADDR(1, 3) /*!< Specify PB3 Pin Data Input/Output */ +#define PB4 GPIO_PIN_ADDR(1, 4) /*!< Specify PB4 Pin Data Input/Output */ +#define PB5 GPIO_PIN_ADDR(1, 5) /*!< Specify PB5 Pin Data Input/Output */ +#define PB6 GPIO_PIN_ADDR(1, 6) /*!< Specify PB6 Pin Data Input/Output */ +#define PB7 GPIO_PIN_ADDR(1, 7) /*!< Specify PB7 Pin Data Input/Output */ +#define PB8 GPIO_PIN_ADDR(1, 8) /*!< Specify PB8 Pin Data Input/Output */ +#define PB9 GPIO_PIN_ADDR(1, 9) /*!< Specify PB9 Pin Data Input/Output */ +#define PB10 GPIO_PIN_ADDR(1, 10) /*!< Specify PB10 Pin Data Input/Output */ +#define PB11 GPIO_PIN_ADDR(1, 11) /*!< Specify PB11 Pin Data Input/Output */ +#define PB12 GPIO_PIN_ADDR(1, 12) /*!< Specify PB12 Pin Data Input/Output */ +#define PB13 GPIO_PIN_ADDR(1, 13) /*!< Specify PB13 Pin Data Input/Output */ +#define PB14 GPIO_PIN_ADDR(1, 14) /*!< Specify PB14 Pin Data Input/Output */ +#define PB15 GPIO_PIN_ADDR(1, 15) /*!< Specify PB15 Pin Data Input/Output */ + +#define PC0 GPIO_PIN_ADDR(2, 0) /*!< Specify PC0 Pin Data Input/Output */ +#define PC1 GPIO_PIN_ADDR(2, 1) /*!< Specify PC1 Pin Data Input/Output */ +#define PC2 GPIO_PIN_ADDR(2, 2) /*!< Specify PC2 Pin Data Input/Output */ +#define PC3 GPIO_PIN_ADDR(2, 3) /*!< Specify PC3 Pin Data Input/Output */ +#define PC4 GPIO_PIN_ADDR(2, 4) /*!< Specify PC4 Pin Data Input/Output */ +#define PC5 GPIO_PIN_ADDR(2, 5) /*!< Specify PC5 Pin Data Input/Output */ +#define PC6 GPIO_PIN_ADDR(2, 6) /*!< Specify PC6 Pin Data Input/Output */ +#define PC7 GPIO_PIN_ADDR(2, 7) /*!< Specify PC7 Pin Data Input/Output */ +#define PC8 GPIO_PIN_ADDR(2, 8) /*!< Specify PC8 Pin Data Input/Output */ +#define PC9 GPIO_PIN_ADDR(2, 9) /*!< Specify PC9 Pin Data Input/Output */ +#define PC10 GPIO_PIN_ADDR(2, 10) /*!< Specify PC10 Pin Data Input/Output */ +#define PC11 GPIO_PIN_ADDR(2, 11) /*!< Specify PC11 Pin Data Input/Output */ +#define PC12 GPIO_PIN_ADDR(2, 12) /*!< Specify PC12 Pin Data Input/Output */ +#define PC13 GPIO_PIN_ADDR(2, 13) /*!< Specify PC13 Pin Data Input/Output */ +#define PC14 GPIO_PIN_ADDR(2, 14) /*!< Specify PC14 Pin Data Input/Output */ +#define PC15 GPIO_PIN_ADDR(2, 15) /*!< Specify PC15 Pin Data Input/Output */ + +#define PD0 GPIO_PIN_ADDR(3, 0) /*!< Specify PD0 Pin Data Input/Output */ +#define PD1 GPIO_PIN_ADDR(3, 1) /*!< Specify PD1 Pin Data Input/Output */ +#define PD2 GPIO_PIN_ADDR(3, 2) /*!< Specify PD2 Pin Data Input/Output */ +#define PD3 GPIO_PIN_ADDR(3, 3) /*!< Specify PD3 Pin Data Input/Output */ +#define PD4 GPIO_PIN_ADDR(3, 4) /*!< Specify PD4 Pin Data Input/Output */ +#define PD5 GPIO_PIN_ADDR(3, 5) /*!< Specify PD5 Pin Data Input/Output */ +#define PD6 GPIO_PIN_ADDR(3, 6) /*!< Specify PD6 Pin Data Input/Output */ +#define PD7 GPIO_PIN_ADDR(3, 7) /*!< Specify PD7 Pin Data Input/Output */ +#define PD8 GPIO_PIN_ADDR(3, 8) /*!< Specify PD8 Pin Data Input/Output */ +#define PD9 GPIO_PIN_ADDR(3, 9) /*!< Specify PD9 Pin Data Input/Output */ +#define PD10 GPIO_PIN_ADDR(3, 10) /*!< Specify PD10 Pin Data Input/Output */ +#define PD11 GPIO_PIN_ADDR(3, 11) /*!< Specify PD11 Pin Data Input/Output */ +#define PD12 GPIO_PIN_ADDR(3, 12) /*!< Specify PD12 Pin Data Input/Output */ +#define PD13 GPIO_PIN_ADDR(3, 13) /*!< Specify PD13 Pin Data Input/Output */ +#define PD14 GPIO_PIN_ADDR(3, 14) /*!< Specify PD14 Pin Data Input/Output */ +#define PD15 GPIO_PIN_ADDR(3, 15) /*!< Specify PD15 Pin Data Input/Output */ + +#define PE0 GPIO_PIN_ADDR(4, 0) /*!< Specify PE0 Pin Data Input/Output */ +#define PE1 GPIO_PIN_ADDR(4, 1) /*!< Specify PE1 Pin Data Input/Output */ +#define PE2 GPIO_PIN_ADDR(4, 2) /*!< Specify PE2 Pin Data Input/Output */ +#define PE3 GPIO_PIN_ADDR(4, 3) /*!< Specify PE3 Pin Data Input/Output */ +#define PE4 GPIO_PIN_ADDR(4, 4) /*!< Specify PE4 Pin Data Input/Output */ +#define PE5 GPIO_PIN_ADDR(4, 5) /*!< Specify PE5 Pin Data Input/Output */ +#define PE6 GPIO_PIN_ADDR(4, 6) /*!< Specify PE6 Pin Data Input/Output */ +#define PE7 GPIO_PIN_ADDR(4, 7) /*!< Specify PE7 Pin Data Input/Output */ +#define PE8 GPIO_PIN_ADDR(4, 8) /*!< Specify PE8 Pin Data Input/Output */ +#define PE9 GPIO_PIN_ADDR(4, 9) /*!< Specify PE9 Pin Data Input/Output */ +#define PE10 GPIO_PIN_ADDR(4, 10) /*!< Specify PE10 Pin Data Input/Output */ +#define PE11 GPIO_PIN_ADDR(4, 11) /*!< Specify PE11 Pin Data Input/Output */ +#define PE12 GPIO_PIN_ADDR(4, 12) /*!< Specify PE12 Pin Data Input/Output */ +#define PE13 GPIO_PIN_ADDR(4, 13) /*!< Specify PE13 Pin Data Input/Output */ +#define PE14 GPIO_PIN_ADDR(4, 14) /*!< Specify PE14 Pin Data Input/Output */ +#define PE15 GPIO_PIN_ADDR(4, 15) /*!< Specify PE15 Pin Data Input/Output */ + +#define PF0 GPIO_PIN_ADDR(5, 0) /*!< Specify PF0 Pin Data Input/Output */ +#define PF1 GPIO_PIN_ADDR(5, 1) /*!< Specify PF1 Pin Data Input/Output */ +#define PF2 GPIO_PIN_ADDR(5, 2) /*!< Specify PF2 Pin Data Input/Output */ +#define PF3 GPIO_PIN_ADDR(5, 3) /*!< Specify PF3 Pin Data Input/Output */ +#define PF4 GPIO_PIN_ADDR(5, 4) /*!< Specify PF4 Pin Data Input/Output */ +#define PF5 GPIO_PIN_ADDR(5, 5) /*!< Specify PF5 Pin Data Input/Output */ +#define PF6 GPIO_PIN_ADDR(5, 6) /*!< Specify PF6 Pin Data Input/Output */ +#define PF7 GPIO_PIN_ADDR(5, 7) /*!< Specify PF7 Pin Data Input/Output */ +#define PF8 GPIO_PIN_ADDR(5, 8) /*!< Specify PF8 Pin Data Input/Output */ +#define PF9 GPIO_PIN_ADDR(5, 9) /*!< Specify PF9 Pin Data Input/Output */ +#define PF10 GPIO_PIN_ADDR(5, 10) /*!< Specify PF10 Pin Data Input/Output */ +#define PF11 GPIO_PIN_ADDR(5, 11) /*!< Specify PF11 Pin Data Input/Output */ +#define PF12 GPIO_PIN_ADDR(5, 12) /*!< Specify PF12 Pin Data Input/Output */ +#define PF13 GPIO_PIN_ADDR(5, 13) /*!< Specify PF13 Pin Data Input/Output */ +#define PF14 GPIO_PIN_ADDR(5, 14) /*!< Specify PF14 Pin Data Input/Output */ +#define PF15 GPIO_PIN_ADDR(5, 15) /*!< Specify PF15 Pin Data Input/Output */ + +#define PG0 GPIO_PIN_ADDR(6, 0) /*!< Specify PG0 Pin Data Input/Output */ +#define PG1 GPIO_PIN_ADDR(6, 1) /*!< Specify PG1 Pin Data Input/Output */ +#define PG2 GPIO_PIN_ADDR(6, 2) /*!< Specify PG2 Pin Data Input/Output */ +#define PG3 GPIO_PIN_ADDR(6, 3) /*!< Specify PG3 Pin Data Input/Output */ +#define PG4 GPIO_PIN_ADDR(6, 4) /*!< Specify PG4 Pin Data Input/Output */ +#define PG5 GPIO_PIN_ADDR(6, 5) /*!< Specify PG5 Pin Data Input/Output */ +#define PG6 GPIO_PIN_ADDR(6, 6) /*!< Specify PG6 Pin Data Input/Output */ +#define PG7 GPIO_PIN_ADDR(6, 7) /*!< Specify PG7 Pin Data Input/Output */ +#define PG8 GPIO_PIN_ADDR(6, 8) /*!< Specify PG8 Pin Data Input/Output */ +#define PG9 GPIO_PIN_ADDR(6, 9) /*!< Specify PG9 Pin Data Input/Output */ +#define PG10 GPIO_PIN_ADDR(6, 10) /*!< Specify PG10 Pin Data Input/Output */ +#define PG11 GPIO_PIN_ADDR(6, 11) /*!< Specify PG11 Pin Data Input/Output */ +#define PG12 GPIO_PIN_ADDR(6, 12) /*!< Specify PG12 Pin Data Input/Output */ +#define PG13 GPIO_PIN_ADDR(6, 13) /*!< Specify PG13 Pin Data Input/Output */ +#define PG14 GPIO_PIN_ADDR(6, 14) /*!< Specify PG14 Pin Data Input/Output */ +#define PG15 GPIO_PIN_ADDR(6, 15) /*!< Specify PG15 Pin Data Input/Output */ + +#define PH0 GPIO_PIN_ADDR(7, 0) /*!< Specify PH0 Pin Data Input/Output */ +#define PH1 GPIO_PIN_ADDR(7, 1) /*!< Specify PH1 Pin Data Input/Output */ +#define PH2 GPIO_PIN_ADDR(7, 2) /*!< Specify PH2 Pin Data Input/Output */ +#define PH3 GPIO_PIN_ADDR(7, 3) /*!< Specify PH3 Pin Data Input/Output */ +#define PH4 GPIO_PIN_ADDR(7, 4) /*!< Specify PH4 Pin Data Input/Output */ +#define PH5 GPIO_PIN_ADDR(7, 5) /*!< Specify PH5 Pin Data Input/Output */ +#define PH6 GPIO_PIN_ADDR(7, 6) /*!< Specify PH6 Pin Data Input/Output */ +#define PH7 GPIO_PIN_ADDR(7, 7) /*!< Specify PH7 Pin Data Input/Output */ +#define PH8 GPIO_PIN_ADDR(7, 8) /*!< Specify PH8 Pin Data Input/Output */ +#define PH9 GPIO_PIN_ADDR(7, 9) /*!< Specify PH9 Pin Data Input/Output */ +#define PH10 GPIO_PIN_ADDR(7, 10) /*!< Specify PH10 Pin Data Input/Output */ +#define PH11 GPIO_PIN_ADDR(7, 11) /*!< Specify PH11 Pin Data Input/Output */ +#define PH12 GPIO_PIN_ADDR(7, 12) /*!< Specify PH12 Pin Data Input/Output */ +#define PH13 GPIO_PIN_ADDR(7, 13) /*!< Specify PH13 Pin Data Input/Output */ +#define PH14 GPIO_PIN_ADDR(7, 14) /*!< Specify PH14 Pin Data Input/Output */ +#define PH15 GPIO_PIN_ADDR(7, 15) /*!< Specify PH15 Pin Data Input/Output */ + +#define PI0 GPIO_PIN_ADDR(8, 0) /*!< Specify PI0 Pin Data Input/Output */ +#define PI1 GPIO_PIN_ADDR(8, 1) /*!< Specify PI1 Pin Data Input/Output */ +#define PI2 GPIO_PIN_ADDR(8, 2) /*!< Specify PI2 Pin Data Input/Output */ +#define PI3 GPIO_PIN_ADDR(8, 3) /*!< Specify PI3 Pin Data Input/Output */ +#define PI4 GPIO_PIN_ADDR(8, 4) /*!< Specify PI4 Pin Data Input/Output */ +#define PI5 GPIO_PIN_ADDR(8, 5) /*!< Specify PI5 Pin Data Input/Output */ +#define PI6 GPIO_PIN_ADDR(8, 6) /*!< Specify PI6 Pin Data Input/Output */ +#define PI7 GPIO_PIN_ADDR(8, 7) /*!< Specify PI7 Pin Data Input/Output */ +#define PI8 GPIO_PIN_ADDR(8, 8) /*!< Specify PI8 Pin Data Input/Output */ +#define PI9 GPIO_PIN_ADDR(8, 9) /*!< Specify PI9 Pin Data Input/Output */ +#define PI10 GPIO_PIN_ADDR(8, 10) /*!< Specify PI10 Pin Data Input/Output */ +#define PI11 GPIO_PIN_ADDR(8, 11) /*!< Specify PI11 Pin Data Input/Output */ +#define PI12 GPIO_PIN_ADDR(8, 12) /*!< Specify PI12 Pin Data Input/Output */ +#define PI13 GPIO_PIN_ADDR(8, 13) /*!< Specify PI13 Pin Data Input/Output */ +#define PI14 GPIO_PIN_ADDR(8, 14) /*!< Specify PI14 Pin Data Input/Output */ +#define PI15 GPIO_PIN_ADDR(8, 15) /*!< Specify PI15 Pin Data Input/Output */ + +/*@}*/ /* end of group NUC472_442_GPIO_EXPORTED_CONSTANTS */ + +/** @addtogroup NUC472_442_GPIO_EXPORTED_FUNCTIONS GPIO Exported Functions + @{ +*/ + +/** + * @brief Clear GPIO Pin Interrupt Flag + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @return None + * + * @details Clear the interrupt status of specified GPIO pin. + */ +#define GPIO_CLR_INT_FLAG(gpio, u32PinMask) ((gpio)->INTSRC = u32PinMask) + +/** + * @brief Disable Pin De-bounce Function + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @return None + * + * @details Disable the interrupt de-bounce function of specified GPIO pin. + */ +#define GPIO_DISABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN &= ~u32PinMask) + +/** + * @brief Enable Pin De-bounce Function + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @return None + * + * @details Enable the interrupt de-bounce function of specified GPIO pin. + */ +#define GPIO_ENABLE_DEBOUNCE(gpio, u32PinMask) ((gpio)->DBEN |= u32PinMask) + +/** + * @brief Disable I/O Digital Input Path + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @return None + * + * @details Disable I/O digital input path of specified GPIO pin. + */ +#define GPIO_DISABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->DINOFF |= (u32PinMask << 16)) + +/** + * @brief Enable I/O Digital Input Path + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @return None + * + * @details Enable I/O digital input path of specified GPIO pin. + */ +#define GPIO_ENABLE_DIGITAL_PATH(gpio, u32PinMask) ((gpio)->DINOFF &= ~(u32PinMask << 16)) + +/** + * @brief Disable I/O DOUT mask + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @return None + * + * @details Disable I/O DOUT mask of specified GPIO pin. + */ +#define GPIO_DISABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DATMSK &= ~u32PinMask) + +/** + * @brief Enable I/O DOUT mask + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @return None + * + * @details Enable I/O DOUT mask of specified GPIO pin. + */ +#define GPIO_ENABLE_DOUT_MASK(gpio, u32PinMask) ((gpio)->DATMSK |= u32PinMask) + +/** + * @brief Get GPIO Pin Interrupt Flag + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * + * @retval 0 No interrupt at specified GPIO pin + * @retval 1 The specified GPIO pin generate an interrupt + * + * @details Get the interrupt status of specified GPIO pin. + */ +#define GPIO_GET_INT_FLAG(gpio, u32PinMask) ((gpio)->INTSRC & u32PinMask) + +/** + * @brief Set De-bounce Sampling Cycle Time + * + * @param[in] u32ClkSrc The de-bounce counter clock source. It could be \ref GPIO_DBCTL_DBCLKSRC_HCLK or \ref GPIO_DBCTL_DBCLKSRC_IRC10K. + * @param[in] u32ClkSel The de-bounce sampling cycle selection. It could be \n + * \ref GPIO_DBCTL_DBCLKSEL_1, \ref GPIO_DBCTL_DBCLKSEL_2, \ref GPIO_DBCTL_DBCLKSEL_4, \ref GPIO_DBCTL_DBCLKSEL_8, \n + * \ref GPIO_DBCTL_DBCLKSEL_16, \ref GPIO_DBCTL_DBCLKSEL_32, \ref GPIO_DBCTL_DBCLKSEL_64, \ref GPIO_DBCTL_DBCLKSEL_128, \n + * \ref GPIO_DBCTL_DBCLKSEL_256, \ref GPIO_DBCTL_DBCLKSEL_512, \ref GPIO_DBCTL_DBCLKSEL_1024, \ref GPIO_DBCTL_DBCLKSEL_2048, \n + * \ref GPIO_DBCTL_DBCLKSEL_4096, \ref GPIO_DBCTL_DBCLKSEL_8192, \ref GPIO_DBCTL_DBCLKSEL_16384, \ref GPIO_DBCTL_DBCLKSEL_32768. + * + * @return None + * + * @details Set the interrupt de-bounce sampling cycle time based on the debounce counter clock source. \n + * Example: _GPIO_SET_DEBOUNCE_TIME(GPIO_DBCTL_DBCLKSRC_IRC10K, GPIO_DBCTL_DBCLKSEL_4). \n + * It's meaning the De-debounce counter clock source is internal 10 KHz and sampling cycle selection is 4. \n + * Then the target de-bounce sampling cycle time is (2^4)*(1/(10*1000)) s = 16*0.0001 s = 1600 us, + * and system will sampling interrupt input once per 1600 us. + */ +#define GPIO_SET_DEBOUNCE_TIME(u32ClkSrc, u32ClkSel) (GPIO->DBCTL = (GPIO_DBCTL_ICLKON_Msk | u32ClkSrc | u32ClkSel)) + +/** + * @brief Get GPIO Port IN Data + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * + * @retval The specified port data + * + * @details Get the PIN register of specified GPIO port. + */ +#define GPIO_GET_IN_DATA(gpio) ((gpio)->PIN) + +/** + * @brief Set GPIO Port OUT Data + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Data GPIO port data. + * + * @retval None + * + * @details Set the Data into specified GPIO port. + */ +#define GPIO_SET_OUT_DATA(gpio, u32Data) ((gpio)->DOUT = (u32Data)) + + +/** + * @brief Toggle Specified GPIO pin + * + * @param[in] u32Pin Pxy + * + * @retval None + * + * @details Toggle the specified GPIO pint. + */ +#define GPIO_TOGGLE(u32Pin) ((u32Pin) ^= 1) + +/** + * @brief Enable External GPIO interrupt 0 + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. + * @param[in] u32IntAttribs The interrupt attribute of specified GPIO pin. It could be \n + * \ref GPIO_INT_RISING, \ref GPIO_INT_FALLING, \ref GPIO_INT_BOTH_EDGE, \ref GPIO_INT_HIGH, \ref GPIO_INT_LOW. + * + * @return None + * + * @details This function is used to enable specified GPIO pin interrupt. + */ +#define GPIO_EnableEINT0 GPIO_EnableInt + + +/** + * @brief Disable External GPIO interrupt 0 + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. It could be 0 ~ 15. + * + * @return None + * + * @details This function is used to enable specified GPIO pin interrupt. + */ +#define GPIO_DisableEINT0 GPIO_DisableInt + + +/** + * @brief Enable External GPIO interrupt 1 + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. + * @param[in] u32IntAttribs The interrupt attribute of specified GPIO pin. It could be \n + * \ref GPIO_INT_RISING, \ref GPIO_INT_FALLING, \ref GPIO_INT_BOTH_EDGE, \ref GPIO_INT_HIGH, \ref GPIO_INT_LOW. + * + * @return None + * + * @details This function is used to enable specified GPIO pin interrupt. + */ +#define GPIO_EnableEINT1 GPIO_EnableInt + + +/** + * @brief Disable External GPIO interrupt 1 + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. It could be 0 ~ 15. + * + * @return None + * + * @details This function is used to enable specified GPIO pin interrupt. + */ +#define GPIO_DisableEINT1 GPIO_DisableInt + +/** + * @brief Enable External GPIO interrupt n + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. + * @param[in] u32IntAttribs The interrupt attribute of specified GPIO pin. It could be \n + * \ref GPIO_INT_RISING, \ref GPIO_INT_FALLING, \ref GPIO_INT_BOTH_EDGE, \ref GPIO_INT_HIGH, \ref GPIO_INT_LOW. + * + * @return None + * + * @details This function is used to enable specified GPIO pin interrupt. + */ +#define GPIO_EnableEINT GPIO_EnableInt + + +/** + * @brief Disable External GPIO interrupt n + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. It could be 0 ~ 15. + * + * @return None + * + * @details This function is used to enable specified GPIO pin interrupt. + */ +#define GPIO_DisableEINT GPIO_DisableInt + + +void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode); +void GPIO_EnableInt(GPIO_T *gpio, uint32_t u32Pin, uint32_t u32IntAttribs); +void GPIO_DisableInt(GPIO_T *gpio, uint32_t u32Pin); + + + +/*@}*/ /* end of group NUC472_442_GPIO_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_GPIO_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__GPIO_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/i2c.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/i2c.h new file mode 100644 index 0000000000000000000000000000000000000000..ffcfb0e63552197de64188a0ce4cc5f354d59169 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/i2c.h @@ -0,0 +1,164 @@ +/****************************************************************************//** + * @file i2c.h + * @version V1.00 + * $Revision: 13 $ + * $Date: 15/11/20 7:27p $ + * @brief NUC472/NUC442 I2C driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#ifndef __I2C_H__ +#define __I2C_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_I2C_Driver I2C Driver + @{ +*/ + +/** @addtogroup NUC472_442_I2C_EXPORTED_CONSTANTS I2C Exported Constants + @{ +*/ + +#define I2C_STA 0x20 /*!< I2C START bit value \hideinitializer */ +#define I2C_STO 0x10 /*!< I2C STOP bit value \hideinitializer */ +#define I2C_SI 0x08 /*!< I2C SI bit value \hideinitializer */ +#define I2C_AA 0x04 /*!< I2C ACK bit value \hideinitializer */ + +#define I2C_GCMODE_ENABLE 1 /*!< Enable I2C GC Mode \hideinitializer */ +#define I2C_GCMODE_DISABLE 0 /*!< Disable I2C GC Mode \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_I2C_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_I2C_EXPORTED_FUNCTIONS I2C Exported Functions + @{ +*/ + +/** + * @brief This macro sets the I2C control register at one time. + * @param[in] i2c is the base address of I2C module. + * @param[in] u8Ctrl is the register value of I2C control register. + * @return none + * \hideinitializer + */ +#define I2C_SET_CONTROL_REG(i2c, u8Ctrl) ( (i2c)->CTL = ((i2c)->CTL & ~0x3c) | u8Ctrl ) + +/** + * @brief This macro only set START bit to the control register of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return none + * \hideinitializer + */ +#define I2C_START(i2c) ( (i2c)->CTL = ((i2c)->CTL & ~I2C_CTL_SI_Msk) | I2C_CTL_STA_Msk ) + +/** + * @brief This macro only set STOP bit to the control register of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return none + * \hideinitializer + */ +#define I2C_STOP(i2c) ( (i2c)->CTL = ((i2c)->CTL & ~0x3c) | I2C_CTL_SI_Msk | I2C_CTL_STO_Msk ) + +/** + * @brief This macro will return when I2C module is ready. + * @param[in] i2c is the base address of I2C module. + * @return none + * \hideinitializer + */ +#define I2C_WAIT_READY(i2c) while(!((i2c)->CTL & I2C_CTL_SI_Msk)) + +/** + * @brief This macro returns the data stored in data register of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return Data. + * \hideinitializer + */ +#define I2C_GET_DATA(i2c) ( (i2c)->DAT ) + +/** + * @brief This macro writes the data to data register of I2C module. + * @param[in] i2c is the base address of I2C module. + * @param[in] u8Data is the data which will be write to data register of I2C module. + * @return none + * \hideinitializer + */ +#define I2C_SET_DATA(i2c, u8Data) ( (i2c)->DAT = u8Data ) + +/** + * @brief This macro returns the status of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return Status. + * \hideinitializer + */ +#define I2C_GET_STATUS(i2c) ( (i2c)->STATUS ) + +/** + * @brief This macro returns time-out flag. + * @param[in] i2c is the base address of I2C module. + * @return Status. + * @retval 0 Flag is not set. + * @retval 1 Flag is set. + * \hideinitializer + */ +#define I2C_GET_TIMEOUT_FLAG(i2c) ( ((i2c)->TOCTL & I2C_TOCTL_TOIF_Msk) == I2C_TOCTL_TOIF_Msk ? 1:0 ) + +/** + * @brief This macro returns wakeup flag. + * @param[in] i2c is the base address of I2C module. + * @return Status. + * @retval 0 Flag is not set. + * @retval 1 Flag is set. + * \hideinitializer + */ +#define I2C_GET_WAKEUP_FLAG(i2c) ( ((i2c)->WKSTS & I2C_WKSTS_WKIF_Msk) == I2C_WKSTS_WKIF_Msk ? 1:0 ) + +/** + * @brief This macro clears wakeup flag. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +#define I2C_CLEAR_WAKEUP_FLAG(i2c) ((i2c)->WKSTS |= I2C_WKSTS_WKIF_Msk ) + + +uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock); +void I2C_Close(I2C_T *i2c); +void I2C_ClearTimeoutFlag(I2C_T *i2c); +void I2C_Trigger(I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack); +void I2C_DisableInt(I2C_T *i2c); +void I2C_EnableInt(I2C_T *i2c); +uint32_t I2C_GetBusClockFreq(I2C_T *i2c); +uint32_t I2C_SetBusClockFreq(I2C_T *i2c, uint32_t u32BusClock); +uint32_t I2C_GetIntFlag(I2C_T *i2c); +uint32_t I2C_GetStatus(I2C_T *i2c); +uint32_t I2C_GetData(I2C_T *i2c); +void I2C_SetData(I2C_T *i2c, uint8_t u8Data); +void I2C_SetSlaveAddr(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddr, uint8_t u8GCMode); +void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask); +void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout); +void I2C_DisableTimeout(I2C_T *i2c); +void I2C_EnableWakeup(I2C_T *i2c); +void I2C_DisableWakeup(I2C_T *i2c); + +/*@}*/ /* end of group NUC472_442_I2C_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_I2C_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__I2C_H__ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/i2s.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/i2s.h new file mode 100644 index 0000000000000000000000000000000000000000..53e8c17b756d7e525c35f882a116784b98a92c84 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/i2s.h @@ -0,0 +1,310 @@ +/****************************************************************************** + * @file i2s.h + * @version V0.10 + * $Revision: 12 $ + * $Date: 15/09/22 6:48p $ + * @brief NUC472/NUC442 I2S driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#ifndef __I2S_H__ +#define __I2S_H__ + +#include "NUC472_442.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_I2S_Driver I2S Driver + @{ +*/ + +/** @addtogroup NUC472_442_I2S_EXPORTED_CONSTANTS I2S Exported Constants + @{ +*/ +#define I2S_DATABIT_8 (0 << I2S_CTL_WDWIDTH_Pos) /*!< I2S data width is 8-bit \hideinitializer */ +#define I2S_DATABIT_16 (1 << I2S_CTL_WDWIDTH_Pos) /*!< I2S data width is 16-bit \hideinitializer */ +#define I2S_DATABIT_24 (2 << I2S_CTL_WDWIDTH_Pos) /*!< I2S data width is 24-bit \hideinitializer */ +#define I2S_DATABIT_32 (3 << I2S_CTL_WDWIDTH_Pos) /*!< I2S data width is 32-bit \hideinitializer */ + +/* Audio Format */ +#define I2S_MONO I2S_CTL_MONO_Msk /*!< Mono channel \hideinitializer */ +#define I2S_STEREO 0 /*!< Stereo channel \hideinitializer */ + +/* I2S Data Format */ +#define I2S_FORMAT_MSB I2S_CTL_FORMAT_Msk /*!< MSB data format \hideinitializer */ +#define I2S_FORMAT_I2S 0 /*!< I2S data format \hideinitializer */ +#define I2S_FORMAT_PCMB I2S_CTL_FORMAT_Msk /*!< PCMB data format \hideinitializer */ +#define I2S_FORMAT_PCMA 0 /*!< PCMA data format \hideinitializer */ + +/* I2S Interface */ +#define I2S_PCM I2S_CTL_PCMEN_Msk /*!< PCM interface is selected \hideinitializer */ +#define I2S_I2S 0 /*!< I2S interface is selected \hideinitializer */ + +/* I2S Operation mode */ +#define I2S_MODE_SLAVE I2S_CTL_SLAVE_Msk /*!< As slave mode \hideinitializer */ +#define I2S_MODE_MASTER 0 /*!< As master mode \hideinitializer */ + +/* I2S FIFO Threshold */ +#define I2S_FIFO_TX_LEVEL_WORD_0 0 /*!< TX threshold is 0 word \hideinitializer */ +#define I2S_FIFO_TX_LEVEL_WORD_1 (1 << I2S_CTL_TXTH_Pos) /*!< TX threshold is 1 word \hideinitializer */ +#define I2S_FIFO_TX_LEVEL_WORD_2 (2 << I2S_CTL_TXTH_Pos) /*!< TX threshold is 2 words \hideinitializer */ +#define I2S_FIFO_TX_LEVEL_WORD_3 (3 << I2S_CTL_TXTH_Pos) /*!< TX threshold is 3 words \hideinitializer */ +#define I2S_FIFO_TX_LEVEL_WORD_4 (4 << I2S_CTL_TXTH_Pos) /*!< TX threshold is 4 words \hideinitializer */ +#define I2S_FIFO_TX_LEVEL_WORD_5 (5 << I2S_CTL_TXTH_Pos) /*!< TX threshold is 5 words \hideinitializer */ +#define I2S_FIFO_TX_LEVEL_WORD_6 (6 << I2S_CTL_TXTH_Pos) /*!< TX threshold is 6 words \hideinitializer */ +#define I2S_FIFO_TX_LEVEL_WORD_7 (7 << I2S_CTL_TXTH_Pos) /*!< TX threshold is 7 words \hideinitializer */ + +#define I2S_FIFO_RX_LEVEL_WORD_1 0 /*!< RX threshold is 1 word \hideinitializer */ +#define I2S_FIFO_RX_LEVEL_WORD_2 (1 << I2S_CTL_RXTH_Pos) /*!< RX threshold is 2 words \hideinitializer */ +#define I2S_FIFO_RX_LEVEL_WORD_3 (2 << I2S_CTL_RXTH_Pos) /*!< RX threshold is 3 words \hideinitializer */ +#define I2S_FIFO_RX_LEVEL_WORD_4 (3 << I2S_CTL_RXTH_Pos) /*!< RX threshold is 4 words \hideinitializer */ +#define I2S_FIFO_RX_LEVEL_WORD_5 (4 << I2S_CTL_RXTH_Pos) /*!< RX threshold is 5 words \hideinitializer */ +#define I2S_FIFO_RX_LEVEL_WORD_6 (5 << I2S_CTL_RXTH_Pos) /*!< RX threshold is 6 words \hideinitializer */ +#define I2S_FIFO_RX_LEVEL_WORD_7 (6 << I2S_CTL_RXTH_Pos) /*!< RX threshold is 7 words \hideinitializer */ +#define I2S_FIFO_RX_LEVEL_WORD_8 (7 << I2S_CTL_RXTH_Pos) /*!< RX threshold is 8 words \hideinitializer */ + +/* I2S Record Channel */ +#define I2S_MONO_RIGHT 0 /*!< Record mono right channel \hideinitializer */ +#define I2S_MONO_LEFT I2S_CTL_RXLCH_Msk /*!< Record mono left channel \hideinitializer */ + +/* I2S Channel */ +#define I2S_RIGHT 0 /*!< Select right channel \hideinitializer */ +#define I2S_LEFT 1 /*!< Select left channel \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_I2S_EXPORTED_CONSTANTS */ + +/** @addtogroup NUC472_442_I2S_EXPORTED_FUNCTIONS I2S Exported Functions + @{ +*/ +/*---------------------------------------------------------------------------------------------------------*/ +/* inline functions */ +/*---------------------------------------------------------------------------------------------------------*/ +/** + * @brief Enable zero cross detect function. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32ChMask is the mask for left or right channel. Valid values are: + * - \ref I2S_RIGHT + * - \ref I2S_LEFT + * @return none + * \hideinitializer + */ +static __INLINE void I2S_ENABLE_TX_ZCD(I2S_T *i2s, uint32_t u32ChMask) +{ + if(u32ChMask == I2S_RIGHT) + i2s->CTL |= I2S_CTL_RZCEN_Msk; + else + i2s->CTL |= I2S_CTL_LZCEN_Msk; +} + +/** + * @brief Disable zero cross detect function. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32ChMask is the mask for left or right channel. Valid values are: + * - \ref I2S_RIGHT + * - \ref I2S_LEFT + * @return none + * \hideinitializer + */ +static __INLINE void I2S_DISABLE_TX_ZCD(I2S_T *i2s, uint32_t u32ChMask) +{ + if(u32ChMask == I2S_RIGHT) + i2s->CTL &= ~I2S_CTL_RZCEN_Msk; + else + i2s->CTL &= ~I2S_CTL_LZCEN_Msk; +} + +/** + * @brief Enable I2S Tx DMA function. I2S requests DMA to transfer data to Tx FIFO. + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_ENABLE_TXDMA(i2s) ( (i2s)->CTL |= I2S_CTL_TXPDMAEN_Msk ) + +/** + * @brief Disable I2S Tx DMA function. I2S requests DMA to transfer data to Tx FIFO. + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_DISABLE_TXDMA(i2s) ( (i2s)->CTL &= ~I2S_CTL_TXPDMAEN_Msk ) + +/** + * @brief Enable I2S Rx DMA function. I2S requests DMA to transfer data from Rx FIFO. + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_ENABLE_RXDMA(i2s) ( (i2s)->CTL |= I2S_CTL_RXPDMAEN_Msk ) + +/** + * @brief Disable I2S Rx DMA function. I2S requests DMA to transfer data from Rx FIFO. + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_DISABLE_RXDMA(i2s) ( (i2s)->CTL &= ~I2S_CTL_RXPDMAEN_Msk ) + +/** + * @brief Enable I2S Tx function . + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_ENABLE_TX(i2s) ( (i2s)->CTL |= I2S_CTL_TXEN_Msk ) + +/** + * @brief Disable I2S Tx function . + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_DISABLE_TX(i2s) ( (i2s)->CTL &= ~I2S_CTL_TXEN_Msk ) + +/** + * @brief Enable I2S Rx function . + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_ENABLE_RX(i2s) ( (i2s)->CTL |= I2S_CTL_RXEN_Msk ) + +/** + * @brief Disable I2S Rx function . + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_DISABLE_RX(i2s) ( (i2s)->CTL &= ~I2S_CTL_RXEN_Msk ) + +/** + * @brief Enable Tx Mute function . + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_ENABLE_TX_MUTE(i2s) ( (i2s)->CTL |= I2S_CTL_MUTE_Msk ) + +/** + * @brief Disable Tx Mute function . + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_DISABLE_TX_MUTE(i2s) ( (i2s)->CTL &= ~I2S_CTL_MUTE_Msk ) + +/** + * @brief Clear Tx FIFO. Internal pointer is reset to FIFO start point. + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_CLR_TX_FIFO(i2s) ( (i2s)->CTL |= I2S_CTL_TXCLR_Msk ) + +/** + * @brief Clear Rx FIFO. Internal pointer is reset to FIFO start point. + * @param[in] i2s is the base address of I2S module. + * @return none + * \hideinitializer + */ +#define I2S_CLR_RX_FIFO(i2s) ( (i2s)->CTL |= I2S_CTL_RXCLR_Msk ) + +/** + * @brief This function sets the recording source channel when mono mode is used. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32Ch left or right channel. Valid values are: + * - \ref I2S_MONO_LEFT + * - \ref I2S_MONO_RIGHT + * @return none + * \hideinitializer + */ +static __INLINE void I2S_SET_MONO_RX_CHANNEL(I2S_T *i2s, uint32_t u32Ch) +{ + u32Ch == I2S_MONO_LEFT ? + (i2s->CTL |= I2S_CTL_RXLCH_Msk) : + (i2s->CTL &= ~I2S_CTL_RXLCH_Msk); +} + +/** + * @brief Write data to I2S Tx FIFO. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32Data: The data written to FIFO. + * @return none + * \hideinitializer + */ +#define I2S_WRITE_TX_FIFO(i2s, u32Data) ( (i2s)->TX = u32Data ) + +/** + * @brief Read Rx FIFO. + * @param[in] i2s is the base address of I2S module. + * @return Data in Rx FIFO. + * \hideinitializer + */ +#define I2S_READ_RX_FIFO(i2s) ( (i2s)->RX ) + +/** + * @brief This function gets the interrupt flag according to the mask parameter. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32Mask is the mask for the all interrupt flags. + * @return The masked bit value of interrupt flag. + * \hideinitializer + */ +#define I2S_GET_INT_FLAG(i2s, u32Mask) ( (i2s)->STATUS & (u32Mask) ) + +/** + * @brief This function clears the interrupt flag according to the mask parameter. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32Mask is the mask for the all interrupt flags. + * @return none + * \hideinitializer + */ +#define I2S_CLR_INT_FLAG(i2s, u32Mask) ( (i2s)->STATUS |= (u32Mask) ) + +/** + * @brief Get transmit FIFO level + * @param[in] i2s is the base address of I2S module. + * @return FIFO level + * \hideinitializer + */ +#define I2S_GET_TX_FIFO_LEVEL(i2s) ( (((i2s)->STATUS & I2S_STATUS_TXCNT_Msk) >> I2S_STATUS_TXCNT_Pos) & 0xF ) + +/** + * @brief Get receive FIFO level + * @param[in] i2s is the base address of I2S module. + * @return FIFO level + * \hideinitializer + */ +#define I2S_GET_RX_FIFO_LEVEL(i2s) ( (((i2s)->STATUS & I2S_STATUS_RXCNT_Msk) >> I2S_STATUS_RXCNT_Pos) & 0xF ) + +uint32_t I2S_Open(I2S_T *i2s, uint32_t u32MasterSlave, uint32_t u32SampleRate, uint32_t u32WordWidth, uint32_t u32Channels, uint32_t u32DataFormat, uint32_t u32AudioInterface); +void I2S_Close(I2S_T *i2s); +void I2S_EnableInt(I2S_T *i2s, uint32_t u32Mask); +void I2S_DisableInt(I2S_T *i2s, uint32_t u32Mask); +uint32_t I2S_EnableMCLK(I2S_T *i2s, uint32_t u32BusClock); +void I2S_DisableMCLK(I2S_T *i2s); +void I2S_SetFIFO(I2S_T *i2s, uint32_t u32TxThreshold, uint32_t u32RxThreshold); + +/*@}*/ /* end of group NUC472_442_I2S_EXPORTED_FUNCTIONS */ + + +/*@}*/ /* end of group NUC472_442_I2S_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + + +#endif + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/pdma.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/pdma.h new file mode 100644 index 0000000000000000000000000000000000000000..3ed42121129aa966c647c4399973f9d6078111ed --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/pdma.h @@ -0,0 +1,293 @@ +/**************************************************************************//** + * @file pdma.h + * @version V1.00 + * $Revision: 8 $ + * $Date: 14/06/05 5:16p $ + * @brief NUC472/NUC442 PDMA driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __PDMA_H__ +#define __PDMA_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_PDMA_Driver PDMA Driver + @{ +*/ + +/** @addtogroup NUC472_442_PDMA_EXPORTED_CONSTANTS PDMA Exported Constants + @{ +*/ +#define PDMA_CH_MAX 16 /*!< Specify Maximum Channels of PDMA \hideinitializer */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* operation Mode Constant Definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define PDMA_OP_STOP 0x00000000UL /*!INTSTS)) + +/** + * @brief Get Transfer Done Interrupt Status + * + * @param[in] None + * + * @return None + * + * @details Get the transfer done Interrupt status. + * \hideinitializer + */ +#define PDMA_GET_TD_STS() ((uint32_t)(PDMA->TDSTS)) + +/** + * @brief Clear Transfer Done Interrupt Status + * + * @param[in] u32Mask The channel mask + * + * @return None + * + * @details Clear the transfer done Interrupt status. + * \hideinitializer + */ +#define PDMA_CLR_TD_FLAG(u32Mask) ((uint32_t)(PDMA->TDSTS = u32Mask)) + +/** + * @brief Get Target Abort Interrupt Status + * + * @param[in] None + * + * @return None + * + * @details Get the target abort Interrupt status. + * \hideinitializer + */ +#define PDMA_GET_ABORT_STS() ((uint32_t)(PDMA->ABTSTS)) + +/** + * @brief Clear Target Abort Interrupt Status + * + * @param[in] u32Mask The channel mask + * + * @return None + * + * @details Clear the target abort Interrupt status. + * \hideinitializer + */ +#define PDMA_CLR_ABORT_FLAG(u32Mask) ((uint32_t)(PDMA->ABTSTS = u32Mask)) + +/** + * @brief Get Scatter-Gather Table Empty Interrupt Status + * + * @param[in] None + * + * @return None + * + * @details Get the scatter-gather table empty Interrupt status. + * \hideinitializer + */ +#define PDMA_GET_EMPTY_STS() ((uint32_t)(PDMA->SCATSTS)) + +/** + * @brief Clear Scatter-Gather Table Empty Interrupt Status + * + * @param[in] u32Mask The channel mask + * + * @return None + * + * @details Clear the scatter-gather table empty Interrupt status. + * \hideinitializer + */ +#define PDMA_CLR_EMPTY_FLAG(u32Mask) ((uint32_t)(PDMA->SCATSTS = u32Mask)) + + +/** + * @brief Check Channel Status + * + * @param[in] u32Ch The selected channel + * + * @return 0 = idle; 1 = busy + * + * @details Check the selected channel is busy or not. + * \hideinitializer + */ +#define PDMA_IS_CH_BUSY(u32Ch) ((uint32_t)(PDMA->TRGSTS & (1 << u32Ch))? 1 : 0) + +/** + * @brief Set Source Address + * + * @param[in] u32Ch The selected channel + * @param[in] u32Addr The selected address + * + * @return None + * + * @details This macro set the selected channel source address. + * \hideinitializer + */ +#define PDMA_SET_SRC_ADDR(u32Ch, u32Addr) ((uint32_t)(PDMA->DSCT[u32Ch].ENDSA = u32Addr)) + +/** + * @brief Set Destination Address + * + * @param[in] u32Ch The selected channel + * @param[in] u32Addr The selected address + * + * @return None + * + * @details This macro set the selected channel destination address. + * \hideinitializer + */ +#define PDMA_SET_DST_ADDR(u32Ch, u32Addr) ((uint32_t)(PDMA->DSCT[u32Ch].ENDDA = u32Addr)) + +/** + * @brief Set Transfer Count + * + * @param[in] u32Ch The selected channel + * @param[in] u32Count Transfer Count + * + * @return None + * + * @details This macro set the selected channel transfer count. + * \hideinitializer + */ +#define PDMA_SET_TRANS_CNT(u32Ch, u32Count) ((uint32_t)(PDMA->DSCT[u32Ch].CTL=(PDMA->DSCT[u32Ch].CTL&~PDMA_DSCT_CTL_TXCNT_Msk)|((u32Count-1) << PDMA_DSCT_CTL_TXCNT_Pos)) + +/** + * @brief Set Scatter-gather descriptor Address + * + * @param[in] u32Ch The selected channel + * @param[in] u32Addr The descriptor address + * + * @return None + * + * @details This macro set the selected channel scatter-gather descriptor address. + * \hideinitializer + */ +#define PDMA_SET_SCATTER_DESC(u32Ch, u32Addr) ((uint32_t)(PDMA->DSCT[u32Ch].NEXT = u32Addr - (PDMA->SCATBA))) + +/** + * @brief Stop the channel + * + * @param[in] u32Ch The selected channel + * + * @return None + * + * @details This macro stop the selected channel. + * \hideinitializer + */ +#define PDMA_STOP(u32Ch) ((uint32_t)(PDMA->STOP = (1 << u32Ch))) + + + +void PDMA_Open(uint32_t u32Mask); +void PDMA_Close(void); +void PDMA_SetTransferCnt(uint32_t u32Ch, uint32_t u32Width, uint32_t u32TransCount); +void PDMA_SetTransferAddr(uint32_t u32Ch, uint32_t u32SrcAddr, uint32_t u32SrcCtrl, uint32_t u32DstAddr, uint32_t u32DstCtrl); +void PDMA_SetTransferMode(uint32_t u32Ch, uint32_t u32Periphral, uint32_t u32ScatterEn, uint32_t u32DescAddr); +void PDMA_SetBurstType(uint32_t u32Ch, uint32_t u32BurstType, uint32_t u32BurstSize); +void PDMA_Trigger(uint32_t u32Ch); +void PDMA_EnableInt(uint32_t u32Ch, uint32_t u32Mask); +void PDMA_DisableInt(uint32_t u32Ch, uint32_t u32Mask); + + + +/*@}*/ /* end of group NUC472_442_PDMA_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_PDMA_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__PDMA_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/ps2.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/ps2.h new file mode 100644 index 0000000000000000000000000000000000000000..4ca07916c015f6c8d18a0ca1cfefc2fc6fd27759 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/ps2.h @@ -0,0 +1,231 @@ +/**************************************************************************//** + * @file PS2.h + * @version V0.10 + * $Revision: 6 $ + * $Date: 14/10/06 1:58p $ + * @brief NUC472/NUC442 PS2 Driver Header File + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + ******************************************************************************/ +#ifndef __PS2_H__ +#define __PS2_H__ + +/*---------------------------------------------------------------------------------------------------------*/ +/* Include related headers */ +/*---------------------------------------------------------------------------------------------------------*/ +#include "NUC472_442.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_PS2_Driver PS2 Driver + @{ +*/ + + +/** @addtogroup NUC472_442_PS2_EXPORTED_FUNCTIONS PS2 Exported Functions + @{ +*/ + + +/** + * @brief This function use to set TX FIFO length. + * + * @param[in] u32Count TX FIFO length + * + * @return None + * \hideinitializer + */ +#define PS2_SET_TX_BYTE_CNT(u32Count) (PS2->CTL = (PS2->CTL & ~PS2_CTL_TXFDEPTH_Msk) \ + | ((u32Count-1) << PS2_CTL_TXFDEPTH_Pos)) + +/** + * @brief This function use to get PS2 status. + * + * @param None + * + * @return PS2 status + * \hideinitializer + */ +#define PS2_GET_STATUS() (PS2->STATUS) + +/** + * @brief This function use to clear PS2 status. + * + * @param[in] u32Mask Clear the specified status of Ps2 module: + * \ref PS2_STATUS_FRAMEERR_Msk , \ref PS2_STATUS_RXOV_Msk + * + * @return None + */ +#define PS2_CLR_STATUS(u32Mask) (PS2D->PS2STATUS = u32Mask) + +/** + * @brief This function use to clear PS2 Tx FIFO. + * + * @param None + * + * @return None + * \hideinitializer + */ +__STATIC_INLINE void PS2_CLEAR_TX_FIFO(void) +{ + PS2->CTL |= PS2_CTL_CLRFIFO_Msk; + PS2->CTL &= ~PS2_CTL_CLRFIFO_Msk; +} + +/** + * @brief This function use to clear PS2 Rx interrupt. + * + * @param None + * + * @return None + * \hideinitializer + */ +#define PS2_CLR_RX_INT_FLAG() (PS2->INTSTS = PS2_INTSTS_RXIF_Msk) + +/** + * @brief This function use to clear PS2 Tx interrupt. + * + * @param None + * + * @return None + * \hideinitializer + */ +#define PS2_CLR_TX_INT_FLAG() (PS2->INTSTS = PS2_INTSTS_TXIF_Msk) + +/** + * @brief This function use to get PS2 interrupt. + * + * @param[in] u32IntFlag interrupt flag: \ref PS2_INTSTS_TXIF_Msk , \ref PS2_INTSTS_RXIF_Msk + * + * @return 1: interrupt occurs + * 0: interrupt not occurs + * \hideinitializer + */ +#define PS2_GET_INT_FLAG(u32IntFlag) ((PS2->INTSTS & u32IntFlag)?1:0) + +/** + * @brief This function use to set PS2CLK and PS2DATA pins are controlled by hardware. + * + * @param None + * + * @return None + * \hideinitializer + */ +#define PS2_DISABLE_OVERRIDE() (PS2->CTL &= ~PS2_CTL_PS2EN_Msk) + +/** + * @brief This function use to set PS2CLK and PS2DATA pins are controlled by software. + * + * @param None + * + * @return None + * \hideinitializer + */ +#define PS2_ENABLE_OVERRIDE() (PS2->CTL |= PS2_CTL_PS2EN_Msk) + +/** + * @brief This function use to get indicates which data byte in transmit data shift register. + * + * @param None + * + * @return The indicates which data byte in transmit data shift register. + * \hideinitializer + */ +#define PS2_GET_TX_BYTE_INDEX() ((PS2->STATUS & PS2_STATUS_BYTEIDX_Msk) >> PS2_STATUS_BYTEIDX_Pos) + +/** + * @brief This function use to set PS2DATA Pin low. + * + * @param None + * + * @return None. + * \hideinitializer + */ +#define PS2_SET_DATA_LOW() (PS2->CTL &= ~PS2_CTL_FPS2DAT_Msk) + +/** + * @brief This function use to set PS2DATA Pin high. + * + * @param None + * + * @return None. + * \hideinitializer + */ +#define PS2_SET_DATA_HIGH() (PS2->CTL |= PS2_CTL_FPS2DAT_Msk) + +/** + * @brief This function use to set PS2CLK Pin low. + * + * @param None + * + * @return None. + * \hideinitializer + */ +#define PS2_SET_CLK_LOW() (PS2->CTL &= ~PS2_CTL_FPS2CLK_Msk) + +/** + * @brief This function use to set PS2CLK Pin high. + * + * @param None + * + * @return None. + * \hideinitializer + */ +#define PS2_SET_CLK_HIGH() (PS2->CTL |= PS2_CTL_FPS2CLK_Msk) + +/** + * @brief If Parity error or Stop bit is Not Received Correctly, Acknowledge will Not be Sent to host at 12th clock. + * + * @param None + * + * @return None. + * \hideinitializer + */ +#define PS2_DISABLE_ACK_ALWAYS() (PS2->CTL |= PS2_CTL_ACK_Msk) + +/** + * @brief Always sends acknowledge to host at 12th clock for host to device communication. + * + * @param None + * + * @return None. + * \hideinitializer + */ +#define PS2_ENABLE_ACK_ALWAYS() (PS2->CTL &= ~PS2_CTL_ACK_Msk) + + +/*---------------------------------------------------------------------------------------------------------*/ +/* Define Function Prototypes */ +/*---------------------------------------------------------------------------------------------------------*/ + +void PS2_Open(void); +void PS2_Close(void); +uint8_t PS2_Read(void); +int32_t PS2_Write(uint32_t *pu32Buf, uint32_t u32ByteCount); +void PS2_EnableInt(uint32_t u32Mask); +void PS2_DisableInt(uint32_t u32Mask); + + +/*@}*/ /* end of group NUC472_442_PS2_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_PS2_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__PS2_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/pwm.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/pwm.h new file mode 100644 index 0000000000000000000000000000000000000000..7eeceb6f4f105de13730707c1d7ac37e0b9c5b31 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/pwm.h @@ -0,0 +1,296 @@ +/**************************************************************************//** + * @file pwm.h + * @version V1.00 + * $Revision: 22 $ + * $Date: 15/11/16 2:08p $ + * @brief NUC472/NUC442 PWM driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __PWM_H__ +#define __PWM_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_PWM_Driver PWM Driver + @{ +*/ + +/** @addtogroup NUC472_442_PWM_EXPORTED_CONSTANTS PWM Exported Constants + @{ +*/ +#define PWM_CHANNEL_NUM (6) /*!< PWM channel number \hideinitializer */ +#define PWM_CH0 (0UL) /*!< PWM channel 0 \hideinitializer */ +#define PWM_CH1 (1UL) /*!< PWM channel 1 \hideinitializer */ +#define PWM_CH2 (2UL) /*!< PWM channel 2 \hideinitializer */ +#define PWM_CH3 (3UL) /*!< PWM channel 3 \hideinitializer */ +#define PWM_CH4 (4UL) /*!< PWM channel 4 \hideinitializer */ +#define PWM_CH5 (5UL) /*!< PWM channel 5 \hideinitializer */ +#define PWM_CH_0_MASK (1UL) /*!< PWM channel 0 mask \hideinitializer */ +#define PWM_CH_1_MASK (2UL) /*!< PWM channel 1 mask \hideinitializer */ +#define PWM_CH_2_MASK (4UL) /*!< PWM channel 2 mask \hideinitializer */ +#define PWM_CH_3_MASK (8UL) /*!< PWM channel 3 mask \hideinitializer */ +#define PWM_CH_4_MASK (16UL) /*!< PWM channel 4 mask \hideinitializer */ +#define PWM_CH_5_MASK (32UL) /*!< PWM channel 5 mask \hideinitializer */ +#define PWM_CLK_DIV_1 (4UL) /*!< PWM clock divide by 1 \hideinitializer */ +#define PWM_CLK_DIV_2 (0UL) /*!< PWM clock divide by 2 \hideinitializer */ +#define PWM_CLK_DIV_4 (1UL) /*!< PWM clock divide by 4 \hideinitializer */ +#define PWM_CLK_DIV_8 (2UL) /*!< PWM clock divide by 8 \hideinitializer */ +#define PWM_CLK_DIV_16 (3UL) /*!< PWM clock divide by 16 \hideinitializer */ +#define PWM_EDGE_ALIGNED (0UL) /*!< PWM working in edge aligned type \hideinitializer */ +#define PWM_CENTER_ALIGNED (1UL) /*!< PWM working in center aligned type \hideinitializer */ +#define PWM_TRIGGER_ADC_RISING_EDGE_POINT (0x1000000UL) /*!< PWM trigger ADC while output rising edge is detected \hideinitializer */ +#define PWM_TRIGGER_ADC_FALLING_EDGE_POINT (0x10000UL) /*!< PWM trigger ADC while output falling edge is detected \hideinitializer */ +#define PWM_TRIGGER_ADC_CENTER_POINT (0x100UL) /*!< PWM trigger ADC while counter matches (CNR + 1) \hideinitializer */ +#define PWM_TRIGGER_ADC_PERIOD_POINT (0x1UL) /*!< PWM trigger ADC while counter down count to 0 \hideinitializer */ +#define PWM_BRK0_BKP0 (PWM_BRKCTL_BRK0EN_Msk) /*!< Brake0 signal source from external pin BKP0 \hideinitializer */ +#define PWM_BRK0_CPO0 (PWM_BRKCTL_CPO0BKEN_Msk) /*!< Brake0 signal source from analog comparator 0 output \hideinitializer */ +#define PWM_BRK0_CPO1 (PWM_BRKCTL_CPO1BKEN_Msk) /*!< Brake0 signal source from analog comparator 1 output \hideinitializer */ +#define PWM_BRK0_CPO2 (PWM_BRKCTL_CPO2BKEN_Msk) /*!< Brake0 signal source from analog comparator 2 output \hideinitializer */ +#define PWM_BRK1_LVDBK (PWM_BRKCTL_LVDBKEN_Msk) /*!< Brake1 signal source from level detect \hideinitializer */ +#define PWM_BK1SEL_BKP1 (0UL << PWM_BRKCTL_BK1SEL_Pos) /*!< Brake1 signal source from external pin BKP1 \hideinitializer */ +#define PWM_BK1SEL_CPO0 (1UL << PWM_BRKCTL_BK1SEL_Pos) /*!< Brake1 signal source from analog comparator 0 output \hideinitializer */ +#define PWM_BK1SEL_CPO1 (2UL << PWM_BRKCTL_BK1SEL_Pos) /*!< Brake1 signal source from analog comparator 1 output \hideinitializer */ +#define PWM_PERIOD_INT_UNDERFLOW (0) /*!< PWM period interrupt trigger if counter underflow \hideinitializer */ +#define PWM_PERIOD_INT_MATCH_CNR (1UL) /*!< PWM period interrupt trigger if counter match CNR \hideinitializer */ +#define PWM_DUTY_INT_MATCH_CMR_DN (0) /*!< PWM duty interrupt if counter match CNR during down counting \hideinitializer */ +#define PWM_DUTY_INT_MATCH_CMR_UP (0x100UL) /*!< PWM duty interrupt if counter match CNR during up counting \hideinitializer */ +#define PWM_FALLING_LATCH_INT_ENABLE (0x1000000UL) /*!< PWM falling latch interrupt enable \hideinitializer */ +#define PWM_RISING_LATCH_INT_ENABLE (0x10000UL) /*!< PWM rising latch interrupt enable \hideinitializer */ +#define PWM_RISING_FALLING_LATCH_INT_ENABLE (0x1010000UL) /*!< PWM rising latch interrupt enable \hideinitializer */ +#define PWM_FALLING_LATCH_INT_FLAG (PWM_FALLING_LATCH_INT_ENABLE) /*!< PWM falling latch condition happened \hideinitializer */ +#define PWM_RISING_LATCH_INT_FLAG (PWM_RISING_LATCH_INT_ENABLE) /*!< PWM rising latch condition happened \hideinitializer */ +#define PWM_RISING_FALLING_LATCH_INT_FLAG (PWM_RISING_FALLING_LATCH_INT_ENABLE) /*!< PWM rising latch condition happened \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_PWM_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_PWM_EXPORTED_FUNCTIONS PWM Exported Functions + @{ +*/ + +/** + * @brief This macro enable complementary mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define PWM_ENABLE_COMPLEMENTARY_MODE(pwm) ((pwm)->CTL = (pwm)->CTL | PWM_CTL_OUTMODE_Msk) + +/** + * @brief This macro disable complementary mode, and enable independent mode. + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define PWM_DISABLE_COMPLEMENTARY_MODE(pwm) ((pwm)->CTL = (pwm)->CTL & ~PWM_CTL_OUTMODE_Msk) + +/** + * @brief This macro enable group mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define PWM_ENABLE_GROUP_MODE(pwm) ((pwm)->CTL = (pwm)->CTL | PWM_CTL_GROUPEN_Msk) + +/** + * @brief This macro disable group mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define PWM_DISABLE_GROUP_MODE(pwm) ((pwm)->CTL = (pwm)->CTL & ~PWM_CTL_GROUPEN_Msk) + +/** + * @brief This macro enable synchronous mode + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define PWM_ENABLE_SYNC_MODE(pwm) ((pwm)->CTL = (pwm)->CTL | PWM_CTL_SYNCEN_Msk) + +/** + * @brief This macro disable synchronous mode, and enable independent mode. + * @param[in] pwm The base address of PWM module + * @return None + * \hideinitializer + */ +#define PWM_DISABLE_SYNC_MODE(pwm) ((pwm)->CTL = (pwm)->CTL & ~PWM_CTL_SYNCEN_Msk) + +/** + * @brief This macro enable output inverter of specified channel(s) + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel + * Bit 0 represents channel 0, bit 1 represents channel 1... + * @return None + * \hideinitializer + */ +#define PWM_ENABLE_OUTPUT_INVERTER(pwm, u32ChannelMask) ((pwm)->CTL = (((pwm)->CTL & ~PWM_CTL_PINV_Msk) | ((u32ChannelMask) << PWM_CTL_PINV_Pos))) + +/** + * @brief This macro get captured rising data + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + * \hideinitializer + */ +#define PWM_GET_CAPTURE_RISING_DATA(pwm, u32ChannelNum) (*(__IO uint32_t *) (&(pwm)->RCAPDAT0 + 2 * (u32ChannelNum))) + +/** + * @brief This macro get captured falling data + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + * \hideinitializer + */ +#define PWM_GET_CAPTURE_FALLING_DATA(pwm, u32ChannelNum) (*(__IO uint32_t *) (&(pwm)->FCAPDAT0 + 2 * (u32ChannelNum))) + +/** + * @brief This macro mask output output logic to high or low + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel + * Bit 0 represents channel 0, bit 1 represents channel 1... + * @param[in] u32LevelMask Output logic to high or low + * @return None + * \hideinitializer + */ +#define PWM_MASK_OUTPUT(pwm, u32ChannelMask, u32LevelMask) ((pwm)->MSKEN |= (u32ChannelMask)) + +/** + * @brief This macro set the prescaler of the selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Prescaler Clock prescaler of specified channel. Valid values are between 1 ~ 0xFF + * @return None + * @note Every even channel N, and channel (N + 1) share a prescaler. So if channel 0 prescaler changed, + * channel 1 will also be affected. + * \hideinitializer + */ +#define PWM_SET_PRESCALER(pwm, u32ChannelNum, u32Prescaler) \ + (pwm->CLKPSC = ((pwm)->CLKPSC & ~(PWM_CLKPSC_CLKPSC01_Msk << (((u32ChannelNum) >> 1) * 8))) | ((u32Prescaler) << (((u32ChannelNum) >> 1) * 8))) + +/** + * @brief This macro set the divider of the selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Divider Clock divider of specified channel. Valid values are + * - \ref PWM_CLK_DIV_1 + * - \ref PWM_CLK_DIV_2 + * - \ref PWM_CLK_DIV_4 + * - \ref PWM_CLK_DIV_8 + * - \ref PWM_CLK_DIV_16 + * @return None + * \hideinitializer + */ +#define PWM_SET_DIVIDER(pwm, u32ChannelNum, u32Divider) \ + ((pwm)->CLKDIV = ((pwm)->CLKDIV & ~(PWM_CLKDIV_CLKDIV0_Msk << ((u32ChannelNum) * 4))) | ((u32Divider) << ((u32ChannelNum) * 4))) + +/** + * @brief This macro set the duty of the selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32CMR Duty of specified channel. Valid values are between 0~0xFFFF + * @return None + * @note This new setting will take effect on next PWM period + * \hideinitializer + */ +#define PWM_SET_CMR(pwm, u32ChannelNum, u32CMR) ((pwm)->CMPDAT[(u32ChannelNum)] = (u32CMR)) + +/** + * @brief This macro set the period of the selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32CNR Period of specified channel. Valid values are between 0~0xFFFF + * @return None + * @note This new setting will take effect on next PWM period + * @note PWM counter will stop if period length set to 0 + * \hideinitializer + */ +#define PWM_SET_CNR(pwm, u32ChannelNum, u32CNR) ((pwm)->PERIOD[(u32ChannelNum)] = (u32CNR)) + +/** + * @brief This macro set the PWM aligned type + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel + * Bit 0 represents channel 0, bit 1 represents channel 1... + * @param[in] u32AlignedType PWM aligned type, valid values are: + * - \ref PWM_EDGE_ALIGNED + * - \ref PWM_CENTER_ALIGNED + * @return None + * \hideinitializer + */ +#define PWM_SET_ALIGNED_TYPE(pwm, u32ChannelMask, u32AlignedType) \ +do { \ + (pwm)->CTL = ((pwm)->CTL & ~PWM_CTL_CNTTYPE_Msk); \ + if ((u32AlignedType) == PWM_CENTER_ALIGNED) \ + (pwm)->CTL = ((pwm)->CTL | ((u32ChannelMask) << PWM_CTL_CNTTYPE_Pos)); \ +} while(0) + + +uint32_t PWM_ConfigOutputChannel(PWM_T *pwm, + uint32_t u32ChannelNum, + uint32_t u32Frequency, + uint32_t u32DutyCycle); +uint32_t PWM_ConfigCaptureChannel (PWM_T *pwm, + uint32_t u32ChannelNum, + uint32_t u32UnitTimeNsec, + uint32_t u32CaptureEdge); +void PWM_Start(PWM_T *pwm, uint32_t u32ChannelMask); +void PWM_Stop(PWM_T *pwm, uint32_t u32ChannelMask); +void PWM_ForceStop(PWM_T *pwm, uint32_t u32ChannelMask); +void PWM_EnableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition); +void PWM_DisableADCTrigger(PWM_T *pwm, uint32_t u32ChannelNum); +void PWM_ClearADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition); +uint32_t PWM_GetADCTriggerFlag(PWM_T *pwm, uint32_t u32ChannelNum); +void PWM_EnableFaultBrake(PWM_T *pwm, + uint32_t u32ChannelMask, + uint32_t u32LevelMask, + uint32_t u32BrakeSource); +void PWM_ClearFaultBrakeFlag(PWM_T *pwm, uint32_t u32BrakeSource); +void PWM_EnableCapture(PWM_T *pwm, uint32_t u32ChannelMask); +void PWM_DisableCapture(PWM_T *pwm, uint32_t u32ChannelMask); +void PWM_EnableOutput(PWM_T *pwm, uint32_t u32ChannelMask); +void PWM_DisableOutput(PWM_T *pwm, uint32_t u32ChannelMask); +void PWM_EnableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration); +void PWM_DisableDeadZone(PWM_T *pwm, uint32_t u32ChannelNum); +void PWM_EnableCaptureInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge); +void PWM_DisableCaptureInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge); +void PWM_ClearCaptureIntFlag(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge); +uint32_t PWM_GetCaptureIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); +void PWM_EnableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType); +void PWM_DisableDutyInt(PWM_T *pwm, uint32_t u32ChannelNum); +void PWM_ClearDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); +uint32_t PWM_GetDutyIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); +void PWM_EnableFaultBrakeInt(PWM_T *pwm, uint32_t u32BrakeSource); +void PWM_DisableFaultBrakeInt(PWM_T *pwm, uint32_t u32BrakeSource); +void PWM_ClearFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource); +uint32_t PWM_GetFaultBrakeIntFlag(PWM_T *pwm, uint32_t u32BrakeSource); +void PWM_EnablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType); +void PWM_DisablePeriodInt(PWM_T *pwm, uint32_t u32ChannelNum); +void PWM_ClearPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); +uint32_t PWM_GetPeriodIntFlag(PWM_T *pwm, uint32_t u32ChannelNum); + + + +/*@}*/ /* end of group NUC472_442_PWM_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_PWM_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__PWM_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/rtc.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/rtc.h new file mode 100644 index 0000000000000000000000000000000000000000..9a87f8a6bb33f4950a0482b531abb79d832b6d03 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/rtc.h @@ -0,0 +1,235 @@ +/**************************************************************************//** + * @file rtc.h + * @version V1.00 + * $Revision: 18 $ + * $Date: 14/10/01 2:43p $ + * @brief NUC472/NUC442 RTC driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#ifndef __RTC_H +#define __RTC_H + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_RTC_Driver RTC Driver + @{ +*/ + + +/** @addtogroup NUC472_442_RTC_EXPORTED_CONSTANTS RTC Exported Constants + @{ +*/ + + +#define RTC_INIT_KEY 0xA5EB1357UL /*!< RTC Access Key \hideinitializer */ +#define RTC_WRITE_KEY 0xA965 /*!< RTC Access Key \hideinitializer */ + +#define RTC_WAIT_COUNT 0xFFFFFFFF /*!< Initial Time Out Value \hideinitializer */ + +#define RTC_YEAR2000 2000 /*!< RTC Reference \hideinitializer */ +#define RTC_FCR_REFERENCE 32761 /*!< RTC Reference \hideinitializer */ + +#define RTC_CLOCK_12 0 /*!< RTC 12 Hour \hideinitializer */ +#define RTC_CLOCK_24 1 /*!< RTC 24 Hour \hideinitializer */ + +#define RTC_AM 1 /*!< RTC AM \hideinitializer */ +#define RTC_PM 2 /*!< RTC PM \hideinitializer */ + +#define RTC_TICK_1_SEC ((uint32_t) 0x00000000) /*!< Time tick is 1 second \hideinitializer */ +#define RTC_TICK_1_2_SEC ((uint32_t) 0x00000001) /*!< Time tick is 1/2 second \hideinitializer */ +#define RTC_TICK_1_4_SEC ((uint32_t) 0x00000002) /*!< Time tick is 1/4 second \hideinitializer */ +#define RTC_TICK_1_8_SEC ((uint32_t) 0x00000003) /*!< Time tick is 1/8 second \hideinitializer */ +#define RTC_TICK_1_16_SEC ((uint32_t) 0x00000004) /*!< Time tick is 1/16 second \hideinitializer */ +#define RTC_TICK_1_32_SEC ((uint32_t) 0x00000005) /*!< Time tick is 1/32 second \hideinitializer */ +#define RTC_TICK_1_64_SEC ((uint32_t) 0x00000006) /*!< Time tick is 1/64 second \hideinitializer */ +#define RTC_TICK_1_128_SEC ((uint32_t) 0x00000007) /*!< Time tick is 1/128 second \hideinitializer */ + +#define RTC_SUNDAY ((uint32_t) 0x00000000) /*!< Day of week is sunday \hideinitializer */ +#define RTC_MONDAY ((uint32_t) 0x00000001) /*!< Day of week is monday \hideinitializer */ +#define RTC_TUESDAY ((uint32_t) 0x00000002) /*!< Day of week is tuesday \hideinitializer */ +#define RTC_WEDNESDAY ((uint32_t) 0x00000003) /*!< Day of week is wednesday \hideinitializer */ +#define RTC_THURSDAY ((uint32_t) 0x00000004) /*!< Day of week is thuesday \hideinitializer */ +#define RTC_FRIDAY ((uint32_t) 0x00000005) /*!< Day of week is friday \hideinitializer */ +#define RTC_SATURDAY ((uint32_t) 0x00000006) /*!< Day of week is saturday \hideinitializer */ + +#define RTC_TAMPER_0 0 /*!< Select Tamper 0 pin \hideinitializer */ +#define RTC_TAMPER_1 1 /*!< Select Tamper 0 pin \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_RTC_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_RTC_EXPORTED_STRUCTS RTC Exported Structs + @{ +*/ + +/** + * @brief RTC define Time Data Struct + */ +typedef struct { + uint32_t u32Year; /*!< Year value */ + uint32_t u32Month; /*!< Month value */ + uint32_t u32Day; /*!< Day value */ + uint32_t u32DayOfWeek; /*!< Day of week value */ + uint32_t u32Hour; /*!< Hour value */ + uint32_t u32Minute; /*!< Minute value */ + uint32_t u32Second; /*!< Second value */ + uint32_t u32TimeScale; /*!< 12-Hour, 24-Hour */ + uint32_t u32AmPm; /*!< Only Time Scale select 12-hr used */ +} S_RTC_TIME_DATA_T; + +/*@}*/ /* end of group NUC472_442_RTC_EXPORTED_STRUCTS */ + + + + + +/** @addtogroup NUC472_442_RTC_EXPORTED_FUNCTIONS RTC Exported Functions + @{ +*/ + + +/** + * @brief Read spare register + * + * @param[in] u32RegNum The spare register number(0~23) + * + * @return Spare register content. + * \hideinitializer + */ +#define RTC_READ_SPARE_REGISTER(u32RegNum) (RTC->SPR[u32RegNum]) + +/** + * @brief Write spare register + * + * @param[in] u32RegNum The spare register number(0~23) + * @param[in] u32RegValue The spare register value + * + * @return None + * \hideinitializer + */ +#define RTC_WRITE_SPARE_REGISTER(u32RegNum, u32RegValue) (RTC->SPR[u32RegNum] = u32RegValue) + +/** + * @brief According to current time, return this year is leap year or not + * + * @param None + * + * @return 0 = This year is not a leap year. \n + * 1 = This year is a leap year. + * \hideinitializer + */ +#define RTC_IS_LEAP_YEAR ((RTC->LEAPYEAR & (RTC_LEAPYEAR_LEAPYEAR_Msk))?1:0) + +/** + * @brief Clear alarm interrupt status. + * + * @param None + * + * @return None + * \hideinitializer + */ +#define RTC_CLEAR_ALARM_INT_FLAG (RTC->INTSTS = RTC_INTSTS_ALMIF_Msk) + +/** + * @brief Clear tick interrupt status. + * + * @param None + * + * @return None + * \hideinitializer + */ +#define RTC_CLEAR_TICK_INT_FLAG (RTC->INTSTS = RTC_INTSTS_TICKIF_Msk) + +/** + * @brief Clear tamper detect pin status. + * + * @param[in] u32PinNum tamper detect pin number. [ \ref RTC_TAMPER_0 / \ref RTC_TAMPER_1] + * + * @return None + * \hideinitializer + */ +#define RTC_CLEAR_TAMPER_FLAG(u32PinNum) (RTC->TAMPSTS = (1 << u32PinNum)) + +/** + * @brief Get alarm interrupt status. + * + * @param None + * + * @return Alarm interrupt status + * \hideinitializer + */ +#define RTC_GET_ALARM_INT_FLAG ((RTC->INTSTS & RTC_INTSTS_ALMIF_Msk) >> RTC_INTSTS_ALMIF_Pos) + +/** + * @brief Get alarm interrupt status. + * + * @param None + * + * @return Alarm interrupt status + * \hideinitializer + */ +#define RTC_GET_TICK_INT_FLAG ((RTC->INTSTS & RTC_INTSTS_TICKIF_Msk) >> RTC_INTSTS_TICKIF_Pos) + +/** + * @brief Get tamper detect pin status. + * + * @param[in] u32PinNum tamper detect pin number. [ \ref RTC_TAMPER_0 / \ref RTC_TAMPER_1] + * + * @return Tamper detect pin status + * \hideinitializer + */ +#define RTC_GET_TAMPER_FLAG(u32PinNum) ( (RTC->TAMPSTS & (1 << u32PinNum)) >> u32PinNum) + + + +void RTC_Open(S_RTC_TIME_DATA_T *sPt); +void RTC_Close(void); +void RTC_32KCalibration(int32_t i32FrequencyX100); +void RTC_SetTickPeriod(uint32_t u32TickSelection); +void RTC_EnableInt(uint32_t u32IntFlagMask); +void RTC_DisableInt(uint32_t u32IntFlagMask); +uint32_t RTC_GetDayOfWeek(void); +void RTC_DisableTamperDetection(uint32_t u32PinNumber); +void RTC_EnableTamperDetection(uint32_t u32PinNumber, uint32_t u32PinCondition, uint32_t u32IntFlag, uint32_t u32ClearFlag, uint32_t u32DestroyEn); +void RTC_EnableSpareAccess(void); +void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm); +void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day); +void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm); +void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek); +void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt); +void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt); +void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt); +void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt); + + + +/*@}*/ /* end of group NUC472_442_RTC_EXPORTED_FUNCTIONS */ + + +/*@}*/ /* end of group NUC472_442_RTC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __RTC_H */ + + +/*** (C) COPYRIGHT 2012 Nuvoton Technology Corp. ***/ + + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sc.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sc.h new file mode 100644 index 0000000000000000000000000000000000000000..e4947f687983c83e70d0bc7ac5984f6748312be7 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sc.h @@ -0,0 +1,250 @@ +/**************************************************************************//** + * @file sc.h + * @version V1.00 + * $Revision: 11 $ + * $Date: 15/05/08 5:23p $ + * @brief NUC472/NUC442 Smartcard (SC) driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __SC_H__ +#define __SC_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SC_Driver SC Driver + @{ +*/ + +/** @addtogroup NUC472_442_SC_EXPORTED_CONSTANTS SC Exported Constants + @{ +*/ +#define SC_INTERFACE_NUM 6 /*!< Smartcard interface numbers \hideinitializer */ +#define SC_PIN_STATE_HIGH 1 /*!< Smartcard pin status high \hideinitializer */ +#define SC_PIN_STATE_LOW 0 /*!< Smartcard pin status low \hideinitializer */ +#define SC_PIN_STATE_IGNORE 0xFFFFFFFF /*!< Ignore pin status \hideinitializer */ +#define SC_CLK_ON 1 /*!< Smartcard clock on \hideinitializer */ +#define SC_CLK_OFF 0 /*!< Smartcard clock off \hideinitializer */ + +#define SC_TMR_MODE_0 (0ul << SC_TMRCTL0_OPMODE_Pos) /*!INTEN |= (u32Mask)) + +/** + * @brief This macro disable smartcard interrupt + * @param[in] sc Base address of smartcard module + * @param[in] u32Mask Interrupt mask to be disabled. A combination of + * - \ref SC_INTEN_ACERRIEN_Msk + * - \ref SC_INTEN_RXTOIF_Msk + * - \ref SC_INTEN_INITIEN_Msk + * - \ref SC_INTEN_CDIEN_Msk + * - \ref SC_INTEN_BGTIEN_Msk + * - \ref SC_INTEN_TMR2IEN_Msk + * - \ref SC_INTEN_TMR1IEN_Msk + * - \ref SC_INTEN_TMR0IEN_Msk + * - \ref SC_INTEN_TERRIEN_Msk + * - \ref SC_INTEN_TBEIEN_Msk + * - \ref SC_INTEN_RDAIEN_Msk + * @return None + * \hideinitializer + */ +#define SC_DISABLE_INT(sc, u32Mask) ((sc)->INTEN &= ~(u32Mask)) + +/** + * @brief This macro set VCC pin state of smartcard interface + * @param[in] sc Base address of smartcard module + * @param[in] u32State Pin state of VCC pin, valid parameters are \ref SC_PIN_STATE_HIGH and \ref SC_PIN_STATE_LOW + * @return None + * \hideinitializer + */ +#define SC_SET_VCC_PIN(sc, u32State) \ + do {\ + while(sc->PINCTL & SC_PINCTL_SYNC_Msk);\ + if(u32State)\ + (sc)->PINCTL |= SC_PINCTL_PWREN_Msk;\ + else\ + (sc)->PINCTL &= ~SC_PINCTL_PWREN_Msk;\ + }while(0) + + +/** + * @brief This macro turns CLK output on or off + * @param[in] sc Base address of smartcard module + * @param[in] u32OnOff Clock on or off for selected smartcard module, valid values are \ref SC_CLK_ON and \ref SC_CLK_OFF + * @return None + * \hideinitializer + */ +#define SC_SET_CLK_PIN(sc, u32OnOff)\ + do {\ + while(sc->PINCTL & SC_PINCTL_SYNC_Msk);\ + if(u32OnOff)\ + (sc)->PINCTL |= SC_PINCTL_CLKKEEP_Msk;\ + else\ + (sc)->PINCTL &= ~(SC_PINCTL_CLKKEEP_Msk);\ + }while(0) + +/** + * @brief This macro set I/O pin state of smartcard interface + * @param[in] sc Base address of smartcard module + * @param[in] u32State Pin state of I/O pin, valid parameters are \ref SC_PIN_STATE_HIGH and \ref SC_PIN_STATE_LOW + * @return None + * \hideinitializer + */ +#define SC_SET_IO_PIN(sc, u32State)\ + do {\ + while(sc->PINCTL & SC_PINCTL_SYNC_Msk);\ + if(u32State)\ + (sc)->PINCTL |= SC_PINCTL_SCDOUT_Msk;\ + else\ + (sc)->PINCTL &= ~SC_PINCTL_SCDOUT_Msk;\ + }while(0) + +/** + * @brief This macro set RST pin state of smartcard interface + * @param[in] sc Base address of smartcard module + * @param[in] u32State Pin state of RST pin, valid parameters are \ref SC_PIN_STATE_HIGH and \ref SC_PIN_STATE_LOW + * @return None + * \hideinitializer + */ +#define SC_SET_RST_PIN(sc, u32State)\ + do {\ + while(sc->PINCTL & SC_PINCTL_SYNC_Msk);\ + if(u32State)\ + (sc)->PINCTL |= SC_PINCTL_SCRST_Msk;\ + else\ + (sc)->PINCTL &= ~SC_PINCTL_SCRST_Msk;\ + }while(0) + +/** + * @brief This macro read one byte from smartcard module receive FIFO + * @param[in] sc Base address of smartcard module + * @return One byte read from receive FIFO + * \hideinitializer + */ +#define SC_READ(sc) ((char)((sc)->DAT)) + +/** + * @brief This macro write one byte to smartcard module transmit FIFO + * @param[in] sc Base address of smartcard module + * @param[in] u8Data Data to write to transmit FIFO + * @return None + * \hideinitializer + */ +#define SC_WRITE(sc, u8Data) ((sc)->DAT = (u8Data)) + +/** + * @brief This macro set smartcard stop bit length + * @param[in] sc Base address of smartcard module + * @param[in] u32Len Stop bit length, ether 1 or 2. + * @return None + * @details Stop bit length must be 1 for T = 1 protocol and 2 for T = 0 protocol. + * \hideinitializer + */ +#define SC_SET_STOP_BIT_LEN(sc, u32Len) ((sc)->CTL = ((sc)->CTL & ~SC_CTL_NSB_Msk) | (u32Len == 1 ? SC_CTL_NSB_Msk : 0)) + +/** + * @brief Enable/Disable Tx error retry, and set Tx error retry count + * @param[in] sc Base address of smartcard module + * @param[in] u32Count The number of times of Tx error retry count, between 0~8. 0 means disable Tx error retry + * @return None + */ +__STATIC_INLINE void SC_SetTxRetry(SC_T *sc, uint32_t u32Count) +{ + while(sc->CTL & SC_CTL_SYNC_Msk); + // Retry count must set while enable bit disabled, so disable it first + sc->CTL &= ~(SC_CTL_TXRTY_Msk | SC_CTL_TXRTYEN_Msk); + + if(u32Count != 0) { + while(sc->CTL & SC_CTL_SYNC_Msk); + sc->CTL |= ((u32Count - 1) << SC_CTL_TXRTY_Pos) | SC_CTL_TXRTYEN_Msk; + } +} + +/** + * @brief Enable/Disable Rx error retry, and set Rx error retry count + * @param[in] sc Base address of smartcard module + * @param[in] u32Count The number of times of Rx error retry count, between 0~8. 0 means disable Rx error retry + * @return None + */ +__STATIC_INLINE void SC_SetRxRetry(SC_T *sc, uint32_t u32Count) +{ + while(sc->CTL & SC_CTL_SYNC_Msk); + // Retry count must set while enable bit disabled, so disable it first + sc->CTL &= ~(SC_CTL_RXRTY_Msk | SC_CTL_RXRTYEN_Msk); + + if(u32Count != 0) { + while(sc->CTL & SC_CTL_SYNC_Msk); + sc->CTL = (sc->CTL & ~SC_CTL_RXRTY_Msk) | ((u32Count - 1) << SC_CTL_RXRTY_Pos) | SC_CTL_RXRTYEN_Msk; + } +} + + +uint32_t SC_IsCardInserted(SC_T *sc); +void SC_ClearFIFO(SC_T *sc); +void SC_Close(SC_T *sc); +void SC_Open(SC_T *sc, uint32_t u32CardDet, uint32_t u32PWR); +void SC_ResetReader(SC_T *sc); +void SC_SetBlockGuardTime(SC_T *sc, uint32_t u32BGT); +void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT); +void SC_StopAllTimer(SC_T *sc); +void SC_StartTimer(SC_T *sc, uint32_t u32TimerNum, uint32_t u32Mode, uint32_t u32ETUCount); +void SC_StopTimer(SC_T *sc, uint32_t u32TimerNum); + + +/*@}*/ /* end of group NUC472_442_SC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__SC_H__ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/scuart.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/scuart.h new file mode 100644 index 0000000000000000000000000000000000000000..bfbf2722abc36abfc61a3b848a0204b866ad5d8b --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/scuart.h @@ -0,0 +1,260 @@ +/**************************************************************************//** + * @file sc.h + * @version V1.00 + * $Revision: 9 $ + * $Date: 15/03/13 4:23p $ + * @brief NUC472/NUC442 Smartcard UART mode (SCUART) driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __SCUART_H__ +#define __SCUART_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SCUART_Driver SCUART Driver + @{ +*/ + +/** @addtogroup NUC472_442_SCUART_EXPORTED_CONSTANTS SCUART Exported Constants + @{ +*/ +#define SCUART_CHAR_LEN_5 (0x3ul << SC_UARTCTL_WLS_Pos) /*!< Set SCUART word length to 5 bits \hideinitializer */ +#define SCUART_CHAR_LEN_6 (0x2ul << SC_UARTCTL_WLS_Pos) /*!< Set SCUART word length to 6 bits \hideinitializer */ +#define SCUART_CHAR_LEN_7 (0x1ul << SC_UARTCTL_WLS_Pos) /*!< Set SCUART word length to 7 bits \hideinitializer */ +#define SCUART_CHAR_LEN_8 (0) /*!< Set SCUART word length to 8 bits \hideinitializer */ + +#define SCUART_PARITY_NONE (SC_UARTCTL_PBOFF_Msk) /*!< Set SCUART transfer with no parity \hideinitializer */ +#define SCUART_PARITY_ODD (SC_UARTCTL_OPE_Msk) /*!< Set SCUART transfer with odd parity \hideinitializer */ +#define SCUART_PARITY_EVEN (0) /*!< Set SCUART transfer with even parity \hideinitializer */ + +#define SCUART_STOP_BIT_1 (SC_CTL_NSB_Msk) /*!< Set SCUART transfer with one stop bit \hideinitializer */ +#define SCUART_STOP_BIT_2 (0) /*!< Set SCUART transfer with two stop bits \hideinitializer */ + + +/*@}*/ /* end of group NUC472_442_SCUART_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_SCUART_EXPORTED_FUNCTIONS SCUART Exported Functions + @{ +*/ + +/* TX Macros */ +/** + * @brief Write Data to Tx data register + * @param[in] sc The base address of smartcard module. + * @param[in] u8Data Data byte to transmit + * @return None + * \hideinitializer + */ +#define SCUART_WRITE(sc, u8Data) ((sc)->DAT = (u8Data)) + +/** + * @brief Get TX FIFO empty flag status from register + * @param[in] sc The base address of smartcard module + * @return Transmit FIFO empty status + * @retval 0 Transmit FIFO is not empty + * @retval SC_STATUS_TXEMPTY_Msk Transmit FIFO is empty + * \hideinitializer + */ +#define SCUART_GET_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXEMPTY_Msk) + +/** + * @brief Get TX FIFO full flag status from register + * @param[in] sc The base address of smartcard module + * @return Transmit FIFO full status + * @retval 0 Transmit FIFO is not full + * @retval SC_STATUS_TXFULL_Msk Transmit FIFO is full + * \hideinitializer + */ +#define SCUART_GET_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk) + +/** + * @brief Wait specified smartcard port transmission complete + * @param[in] sc The base address of smartcard module + * @return None + * @note This Macro blocks until transmit complete. + * \hideinitializer + */ +#define SCUART_WAIT_TX_EMPTY(sc) while((sc)->STATUS & SC_STATUS_TXACT_Msk) + +/** + * @brief Check specified smartcard port transmit FIFO is full or not + * @param[in] sc The base address of smartcard module + * @return Transmit FIFO full status + * @retval 0 Transmit FIFO is not full + * @retval 1 Transmit FIFO is full + * \hideinitializer + */ +#define SCUART_IS_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk ? 1 : 0) + +/** + * @brief Check specified smartcard port transmission is over + * @param[in] sc The base address of smartcard module + * @return Transmit complete status + * @retval 0 Transmit is not complete + * @retval 1 Transmit complete + * \hideinitializer + */ +#define SCUART_IS_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXACT_Msk ? 0 : 1) + + +/* RX Macros */ + +/** + * @brief Read Rx data register + * @param[in] sc The base address of smartcard module + * @return The oldest data byte in RX FIFO + * \hideinitializer + */ +#define SCUART_READ(sc) ((sc)->DAT) + +/** + * @brief Get RX FIFO empty flag status from register + * @param[in] sc The base address of smartcard module + * @return Receive FIFO empty status + * @retval 0 Receive FIFO is not empty + * @retval SC_STATUS_RXEMPTY_Msk Receive FIFO is empty + * \hideinitializer + */ +#define SCUART_GET_RX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_RXEMPTY_Msk) + + +/** + * @brief Get RX FIFO full flag status from register + * @param[in] sc The base address of smartcard module + * @return Receive FIFO full status + * @retval 0 Receive FIFO is not full + * @retval SC_STATUS_RXFULLF_Msk Receive FIFO is full + * \hideinitializer + */ +#define SCUART_GET_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk) + +/** + * @brief Check if receive data number in FIFO reach FIFO trigger level or not + * @param[in] sc The base address of smartcard module + * @return Receive FIFO data status + * @retval 0 The number of bytes in receive FIFO is less than trigger level + * @retval 1 The number of bytes in receive FIFO equals or larger than trigger level + * @note If receive trigger level is \b not 1 byte, this macro return 0 does not necessary indicates there is \b no data in FIFO + * \hideinitializer + */ +#define SCUART_IS_RX_READY(sc) ((sc)->INTSTS & SC_INTSTS_RDAIF_Msk ? 1 : 0) + +/** + * @brief Check specified smartcard port receive FIFO is full or not + * @param[in] sc The base address of smartcard module + * @return Receive FIFO full status + * @retval 0 Receive FIFO is not full + * @retval 1 Receive FIFO is full + * \hideinitializer + */ +#define SCUART_IS_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk ? 1 : 0) + +/* Interrupt Macros */ + +/** + * @brief Enable specified interrupts + * @param[in] sc The base address of smartcard module + * @param[in] u32Mask Interrupt masks to enable, a combination of following bits + * - \ref SC_INTEN_RXTOIF_Msk + * - \ref SC_INTEN_TERRIEN_Msk + * - \ref SC_INTEN_TBEIEN_Msk + * - \ref SC_INTEN_RDAIEN_Msk + * @return None + * \hideinitializer + */ +#define SCUART_ENABLE_INT(sc, u32Mask) ((sc)->INTEN |= (u32Mask)) + +/** + * @brief Disable specified interrupts + * @param[in] sc The base address of smartcard module + * @param[in] u32Mask Interrupt masks to disable, a combination of following bits + * - \ref SC_INTEN_RXTOIF_Msk + * - \ref SC_INTEN_TERRIEN_Msk + * - \ref SC_INTEN_TBEIEN_Msk + * - \ref SC_INTEN_RDAIEN_Msk + * @return None + * \hideinitializer + */ +#define SCUART_DISABLE_INT(sc, u32Mask) ((sc)->INTEN &= ~(u32Mask)) + +/** + * @brief Get specified interrupt flag/status + * @param[in] sc The base address of smartcard module + * @param[in] u32Type Interrupt flag/status to check, could be one of following value + * - \ref SC_INTSTS_RBTOIF_Msk + * - \ref SC_INTSTS_TERRIF_Msk + * - \ref SC_INTSTS_TBEIF_Msk + * - \ref SC_INTSTS_RDAIF_Msk + * @return The status of specified interrupt + * @retval 0 Specified interrupt does not happened + * @retval 1 Specified interrupt happened + * \hideinitializer + */ +#define SCUART_GET_INT_FLAG(sc, u32Type) ((sc)->INTSTS & u32Type ? 1 : 0) + +/** + * @brief Clear specified interrupt flag/status + * @param[in] sc The base address of smartcard module + * @param[in] u32Type Interrupt flag/status to clear, could be the combination of following values + * - \ref SC_INTSTS_RBTOIF_Msk + * - \ref SC_INTSTS_TERRIF_Msk + * - \ref SC_INTSTS_TBEIF_Msk + * @return None + * \hideinitializer + */ +#define SCUART_CLR_INT_FLAG(sc, u32Type) ((sc)->INTSTS = u32Type) + +/** + * @brief Get receive error flag/status + * @param[in] sc The base address of smartcard module + * @return Current receive error status, could one of following errors: + * @retval SC_STATUS_PEF_Msk Parity error + * @retval SC_STATUS_FEF_Msk Frame error + * @retval SC_STATUS_BEF_Msk Break error + * \hideinitializer + */ +#define SCUART_GET_ERR_FLAG(sc) ((sc)->STATUS & (SC_STATUS_PEF_Msk | SC_STATUS_FEF_Msk | SC_STATUS_BEF_Msk)) + +/** + * @brief Clear specified receive error flag/status + * @param[in] sc The base address of smartcard module + * @param[in] u32Mask Receive error flag/status to clear, combination following values + * - \ref SC_STATUS_PEF_Msk + * - \ref SC_STATUS_FEF_Msk + * - \ref SC_STATUS_BEF_Msk + * @return None + * \hideinitializer + */ +#define SCUART_CLR_ERR_FLAG(sc, u32Mask) ((sc)->STATUS = u32Mask) + +void SCUART_Close(SC_T* sc); +uint32_t SCUART_Open(SC_T* sc, uint32_t u32baudrate); +uint32_t SCUART_Read(SC_T* sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes); +uint32_t SCUART_SetLineConfig(SC_T* sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits); +void SCUART_SetTimeoutCnt(SC_T* sc, uint32_t u32TOC); +void SCUART_Write(SC_T* sc,uint8_t *pu8TxBuf, uint32_t u32WriteBytes); + +/*@}*/ /* end of group NUC472_442_SCUART_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SCUART_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__SCUART_H__ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sd.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sd.h new file mode 100644 index 0000000000000000000000000000000000000000..27a4c4978dde1cf17d6e5cb2bf2c3e890ccbfe50 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sd.h @@ -0,0 +1,201 @@ +/**************************************************************************//** + * @file sd.h + * @version V1.00 + * $Revision: 12 $ + * $Date: 14/11/04 10:10a $ + * @brief NUC472/NUC442 SD driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include + +#ifndef __SD_H__ +#define __SD_H__ + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SD_Driver SD Driver + @{ +*/ + + +/** @addtogroup NUC472_442_SD_EXPORTED_CONSTANTS SD Exported Constants + @{ +*/ + +#define SD_CARD 0 +#define SD_ERR_ID 0xFFFF0100 + +#define SD_TIMEOUT (SD_ERR_ID|0x01) +#define SD_NO_MEMORY (SD_ERR_ID|0x02) + +//-- function return value +#define Successful 0 +#define Fail 1 + +//--- define type of SD card or MMC +#define SD_TYPE_UNKNOWN 0 +#define SD_TYPE_SD_HIGH 1 +#define SD_TYPE_SD_LOW 2 +#define SD_TYPE_MMC 3 +#define SD_TYPE_EMMC 4 + +/* SD error */ +#define SD_NO_SD_CARD (SD_ERR_ID|0x10) +#define SD_ERR_DEVICE (SD_ERR_ID|0x11) +#define SD_INIT_TIMEOUT (SD_ERR_ID|0x12) +#define SD_SELECT_ERROR (SD_ERR_ID|0x13) +#define SD_WRITE_PROTECT (SD_ERR_ID|0x14) +#define SD_INIT_ERROR (SD_ERR_ID|0x15) +#define SD_CRC7_ERROR (SD_ERR_ID|0x16) +#define SD_CRC16_ERROR (SD_ERR_ID|0x17) +#define SD_CRC_ERROR (SD_ERR_ID|0x18) +#define SD_CMD8_ERROR (SD_ERR_ID|0x19) + +#define SD_FREQ 12000 +#define SDHC_FREQ 12000 + +#define STOR_STRING_LEN 32 + +#define SD_PORT0 (1 << 0) /*!< Card select SD0 \hideinitializer */ +#define SD_PORT1 (1 << 2) /*!< Card select SD1 \hideinitializer */ + +#define CardDetect_From_GPIO (1 << 8) /*!< Card detection pin is GPIO \hideinitializer */ +#define CardDetect_From_DAT3 (1 << 9) /*!< Card detection pin is DAT3 \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_SD_EXPORTED_CONSTANTS */ + +/** @addtogroup NUC472_442_SD_EXPORTED_TYPEDEF SD Exported Type Defines + @{ +*/ +typedef struct SD_info_t { + uint32_t CardType; /*!< SDHC, SD, or MMC */ + uint32_t RCA; /*!< relative card address */ + uint8_t IsCardInsert; /*!< card insert state */ +} SD_INFO_T; + +/* we allocate one of these for every device that we remember */ +typedef struct disk_data_t { + struct disk_data_t *next; /*!< next device */ + + /* information about the device -- always good */ + unsigned int totalSectorN; /*!< total sector number */ + unsigned int diskSize; /*!< disk size in Kbytes */ + int sectorSize; /*!< sector size in bytes */ + char vendor[STOR_STRING_LEN]; /*!< SD card vendor */ + char product[STOR_STRING_LEN]; /*!< *SD card product id */ + char serial[STOR_STRING_LEN]; /*!< SD card serial number */ +} DISK_DATA_T; + +/*@}*/ /* end of group NUC472_442_SD_EXPORTED_TYPEDEF */ + +/// @cond HIDDEN_SYMBOLS +extern SD_INFO_T SD0; +extern SD_INFO_T SD1; +/// @endcond HIDDEN_SYMBOLS + +/** @addtogroup NUC472_442_SD_EXPORTED_FUNCTIONS SD Exported Functions + @{ +*/ + + + + +/** + * @brief Enable specified interrupt. + * + * @param[in] u32IntMask Interrupt type mask: + * \ref SDH_INTEN_BLKDIEN_Msk / \ref SDH_INTEN_CRCIEN_Msk / \ref SDH_INTEN_CDIEN0_Msk / \ref SDH_INTEN_CDIEN1_Msk / + * \ref SDH_INTEN_CDSRC0_Msk / \ref SDH_INTEN_CDSRC1_Msk / \ref SDH_INTEN_RTOIEN_Msk / \ref SDH_INTEN_DITOIEN_Msk / + * \ref SDH_INTEN_WKIEN_Msk + * + * @return None. + * \hideinitializer + */ +#define SD_ENABLE_INT(u32IntMask) (SD->INTEN |= (u32IntMask)) + +/** + * @brief Disable specified interrupt. + * + * @param[in] u32IntMask Interrupt type mask: + * \ref SDH_INTEN_BLKDIEN_Msk / \ref SDH_INTEN_CRCIEN_Msk / \ref SDH_INTEN_CDIEN0_Msk / \ref SDH_INTEN_CDIEN1_Msk / + * \ref SDH_INTEN_SDHOST0IEN_Msk / \ref SDH_INTEN_SDHOST1IEN_Msk / \ref SDH_INTEN_RTOIEN_Msk / \ref SDH_INTEN_DITOIEN_Msk / + * \ref SDH_INTEN_WKIEN_Msk / \ref SDH_INTEN_CDSRC0_Msk / \ref SDH_INTEN_CDSRC1_Msk + * + * @return None. + * \hideinitializer + */ +#define SD_DISABLE_INT(u32IntMask) (SD->INTEN &= ~(u32IntMask)) + +/** + * @brief Get specified interrupt flag/status. + * + * @param[in] u32IntMask Interrupt type mask: + * \ref SDH_INTSTS_BLKDIF_Msk / \ref SDH_INTSTS_CRCIF_Msk / \ref SDH_INTSTS_CRC7_Msk / + * \ref SDH_INTSTS_CRC16_Msk / \ref SDH_INTSTS_CRCSTS_Msk / \ref SDH_INTSTS_DAT0STS_Msk / \ref SDH_INTSTS_CDIF0_Msk / + * \ref SDH_INTSTS_CDIF1_Msk / \ref SDH_INTSTS_SDHOST0IF_Msk / \ref SDH_INTSTS_SDHOST1IF_Msk / \ref SDH_INTSTS_RTOIF_Msk / + * \ref SDH_INTSTS_DINTOIF_Msk / \ref SDH_INTSTS_CDSTS0_Msk / \ref SDH_INTSTS_CDSTS1_Msk / \ref SDH_INTSTS_DAT1STS_Msk + * + * + * @return 0 = The specified interrupt is not happened. + * 1 = The specified interrupt is happened. + * \hideinitializer + */ +#define SD_GET_INT_FLAG(u32IntMask) ((SD->INTSTS & (u32IntMask))?1:0) + + +/** + * @brief Clear specified interrupt flag/status. + * + * @param[in] u32IntMask Interrupt type mask: + * \ref SDH_INTSTS_BLKDIF_Msk / \ref SDH_INTSTS_CRCIF_Msk / \ref SDH_INTSTS_CDIF0_Msk / + * \ref SDH_INTSTS_CDIF1_Msk / \ref SDH_INTSTS_SDHOST0IF_Msk / \ref SDH_INTSTS_SDHOST1IF_Msk / + * \ref SDH_INTSTS_RTOIF_Msk / \ref SDH_INTSTS_DINTOIF_Msk + * + * + * @return None. + * \hideinitializer + */ +#define SD_CLR_INT_FLAG(u32IntMask) (SD->INTSTS = u32IntMask) + + +/** + * @brief Check SD Card inserted or removed. + * + * @param[in] u32CardNum Select SD0 or SD1. ( \ref SD_PORT0 / \ref SD_PORT1) + * + * @return 1: Card inserted. + * 0: Card removed. + * \hideinitializer + */ +#define SD_IS_CARD_PRESENT(u32CardNum) ((u32CardNum & (SD_PORT0))?(SD0.IsCardInsert):(SD1.IsCardInsert)) + +/** + * @brief Get SD Card capacity. + * + * @param[in] u32CardNum Select SD0 or SD1. ( \ref SD_PORT0 / \ref SD_PORT1) + * + * @return SD Card capacity. (unit: KByte) + * \hideinitializer + */ +#define SD_GET_CARD_CAPACITY(u32CardNum) ((u32CardNum & (SD_PORT0))?(SD_DiskInfo0.diskSize):(SD_DiskInfo1.diskSize)) + + +void SD_Open(uint32_t u32CardDetSrc); +void SD_Probe(uint32_t u32CardNum); +uint32_t SD_Read(uint32_t u32CardNum, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount); +uint32_t SD_Write(uint32_t u32CardNum, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount); + + + +/*@}*/ /* end of group NUC472_442_ADC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_ADC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#endif //end of __SD_H__ +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/spi.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/spi.h new file mode 100644 index 0000000000000000000000000000000000000000..39d4a352564110134722f9bd6fb58049a7b22251 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/spi.h @@ -0,0 +1,461 @@ +/****************************************************************************//** + * @file spi.h + * @version V1.00 + * $Revision: 21 $ + * $Date: 15/06/18 4:12p $ + * @brief NUC472/NUC442 SPI driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#ifndef __SPI_H__ +#define __SPI_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SPI_Driver SPI Driver + @{ +*/ + +/** @addtogroup NUC472_442_SPI_EXPORTED_CONSTANTS SPI Exported Constants + @{ +*/ + +#define SPI_MODE_0 (SPI_CTL_TXNEG_Msk) /*!< CLKP=0; RX_NEG=0; TX_NEG=1 \hideinitializer */ +#define SPI_MODE_1 (SPI_CTL_RXNEG_Msk) /*!< CLKP=0; RX_NEG=1; TX_NEG=0 \hideinitializer */ +#define SPI_MODE_2 (SPI_CTL_CLKPOL_Msk | SPI_CTL_RXNEG_Msk) /*!< CLKP=1; RX_NEG=1; TX_NEG=0 \hideinitializer */ +#define SPI_MODE_3 (SPI_CTL_CLKPOL_Msk | SPI_CTL_TXNEG_Msk) /*!< CLKP=1; RX_NEG=0; TX_NEG=1 \hideinitializer */ + +#define SPI_SLAVE (SPI_CTL_SLAVE_Msk) /*!< Set as slave \hideinitializer */ +#define SPI_MASTER (0x0) /*!< Set as master \hideinitializer */ + +#define SPI_SS0 (0x1) /*!< Set SS0 \hideinitializer */ +#define SPI_SS1 (0x2) /*!< Set SS1 \hideinitializer */ +#define SPI_SS_ACTIVE_HIGH (SPI_SSCTL_SSACTPOL_Msk) /*!< SS active high \hideinitializer */ +#define SPI_SS_ACTIVE_LOW (0x0) /*!< SS active low \hideinitializer */ + +#define SPI_UNITIEN_MASK (0x001) /*!< Interrupt enable mask \hideinitializer */ +#define SPI_SSINAIEN_MASK (0x002) /*!< Slave Slave Inactive interrupt enable mask \hideinitializer */ +#define SPI_SSACTIEN_MASK (0x004) /*!< Slave Slave Active interrupt enable mask \hideinitializer */ +#define SPI_SLVURIEN_MASK (0x008) /*!< Slave Mode Error 1 interrupt enable mask \hideinitializer */ +#define SPI_SLVBEIEN_MASK (0x010) /*!< Slave Mode Error 0 interrupt enable mask \hideinitializer */ +#define SPI_SLVTOIEN_MASK (0x020) /*!< Slave Mode Time-out interrupt enable mask \hideinitializer */ +#define SPI_FIFO_TXTHIEN_MASK (0x040) /*!< Transmit FIFO Threshold interrupt enable mask \hideinitializer */ +#define SPI_FIFO_RXTHIEN_MASK (0x080) /*!< Receive FIFO Threshold interrupt enable mask \hideinitializer */ +#define SPI_FIFO_RXOVIEN_MASK (0x100) /*!< Receive FIFO Overrun interrupt enable mask \hideinitializer */ +#define SPI_FIFO_TXUFIEN_MASK (0x200) /*!< Slave Transmit Under Run interrupt enable mask \hideinitializer */ +#define SPI_FIFO_RXTOIEN_MASK (0x400) /*!< Slave Receive Time-out interrupt enable mask \hideinitializer */ + + +/*@}*/ /* end of group NUC472_442_SPI_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_SPI_EXPORTED_FUNCTIONS SPI Exported Functions + @{ +*/ + +/** + * @brief Set time out period for slave. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @param[in] u32TimeoutPeriod is the period of time out. + * @return none + * \hideinitializer + */ +#define SPI_SET_SLAVE_TIMEOUT_PERIOD(spi, u32TimeoutPeriod) ( (spi)->SSCTL = ((spi)->SSCTL & ~SPI_SSCTL_SLVTOCNT_Msk) | (((uint32_t)u32TimeoutPeriod & 0xFFFF) << SPI_SSCTL_SLVTOCNT_Pos) ) + +/** + * @brief Enable time out clear function for FIFO mode. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_TIMEOUT_FIFO_CLEAR(spi) ( (spi)->SSCTL |= SPI_SSCTL_SLVTORST_Msk ) + +/** + * @brief Disable time out clear function for FIFO mode. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_TIMEOUT_FIFO_CLEAR(spi) ( (spi)->SSCTL &= ~SPI_SSCTL_SLVTORST_Msk ) + +/** + * @brief Set data out signal to low (0) if transmit under-run occurs. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_SET_TX_UNDERRUN_DATA_LOW(spi) ( (spi)->FIFOCTL &= ~SPI_FIFOCTL_TXUFPOL_Msk ) + +/** + * @brief Set data out signal to high (1) if transmit under-run occurs. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_SET_TX_UNDERRUN_DATA_HIGH(spi) ( (spi)->FIFOCTL |= SPI_FIFOCTL_TXUFPOL_Msk ) + +/** + * @brief Get the status flags. + * @param spi is the base address of SPI module. + * @return status flags + * \hideinitializer + */ +#define SPI_GET_STATUS(spi) ( (spi)->STATUS ) + +/** + * @brief Clear the unit transfer interrupt flag. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_CLR_UNIT_TRANS_INT_FLAG(spi) ( (spi)->STATUS = SPI_STATUS_UNITIF_Msk ) + +/** + * @brief Disable slave 3-wire mode. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_3WIRE_MODE(spi) ( (spi)->SSCTL &= ~SPI_SSCTL_SLV3WIRE_Msk ) + +/** + * @brief Enable slave 3-wire mode. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_3WIRE_MODE(spi) ( (spi)->SSCTL |= SPI_SSCTL_SLV3WIRE_Msk ) + +/** + * @brief Get the count of available data in RX FIFO. + * @param[in] spi is the base address of SPI module. + * @return The count of available data in RX FIFO. + * \hideinitializer + */ +#define SPI_GET_RX_FIFO_COUNT(spi) ( (((spi)->STATUS & SPI_STATUS_RXCNT_Msk) >> SPI_STATUS_RXCNT_Pos) & 0xf ) + +/** + * @brief Get the Rx FIFO empty flag. + * @param[in] spi is the base address of SPI module. + * @return Rx FIFO flag + * @retval 0: Rx FIFO is not empty + * @retval 1: Rx FIFO is empty + * \hideinitializer + */ +#define SPI_GET_RX_FIFO_EMPTY_FLAG(spi) ( ((spi)->STATUS & SPI_STATUS_RXEMPTY_Msk) == SPI_STATUS_RXEMPTY_Msk ? 1:0 ) + +/** + * @brief Get the Tx FIFO empty flag. + * @param[in] spi is the base address of SPI module. + * @return Tx FIFO flag + * @retval 0: Tx FIFO is not empty + * @retval 1: Tx FIFO is empty + * \hideinitializer + */ +#define SPI_GET_TX_FIFO_EMPTY_FLAG(spi) ( ((spi)->STATUS & SPI_STATUS_TXEMPTY_Msk) == SPI_STATUS_TXEMPTY_Msk ? 1:0 ) + +/** + * @brief Get the Tx FIFO full flag. + * @param[in] spi is the base address of SPI module. + * @return Tx FIFO flag + * @retval 0: Tx FIFO is not full + * @retval 1: Tx FIFO is full + * \hideinitializer + */ +#define SPI_GET_TX_FIFO_FULL_FLAG(spi) ( ((spi)->STATUS & SPI_STATUS_TXFULL_Msk) == SPI_STATUS_TXFULL_Msk ? 1:0 ) + +/** + * @brief Get the datum read from R0 FIFO. + * @param[in] spi is the base address of SPI module. + * @return data in Rx register + * \hideinitializer + */ +#define SPI_READ_RX(spi) ((spi)->RX) + +/** + * @brief Write datum to TX register. + * @param[in] spi is the base address of SPI module. + * @param[in] u32TxData is the datum which user attempt to transfer through SPI bus. + * @return none + * \hideinitializer + */ +#define SPI_WRITE_TX(spi, u32TxData) ( (spi)->TX = u32TxData ) + +/** + * @brief Set SPIn_SS0 pin to high state. + * @param[in] spi The pointer of the specified SPI module. + * @return None. + * @details Disable automatic slave selection function and set SPIn_SS0 pin to high state. Only available in Master mode. + * \hideinitializer + */ +#define SPI_SET_SS0_HIGH(spi) ((spi)->SSCTL = ((spi)->SSCTL & ~(SPI_SSCTL_AUTOSS_Msk|SPI_SSCTL_SSACTPOL_Msk|SPI_SS0))) + +/** + * @brief Set SPIn_SS0 pin to low state. + * @param[in] spi The pointer of the specified SPI module. + * @return None. + * @details Disable automatic slave selection function and set SPIn_SS0 pin to low state. Only available in Master mode. + * \hideinitializer + */ +#define SPI_SET_SS0_LOW(spi) ((spi)->SSCTL = ((spi)->SSCTL & ~(SPI_SSCTL_AUTOSS_Msk|SPI_SSCTL_SSACTPOL_Msk|SPI_SS0)) | SPI_SS0) + +/** + * @brief Set SPIn_SS1 pin to high state. + * @param[in] spi The pointer of the specified SPI module. + * @return None. + * @details Disable automatic slave selection function and set SPIn_SS1 pin to high state. Only available in Master mode. + * \hideinitializer + */ +#define SPI_SET_SS1_HIGH(spi) ((spi)->SSCTL = ((spi)->SSCTL & ~(SPI_SSCTL_AUTOSS_Msk|SPI_SSCTL_SSACTPOL_Msk|SPI_SS1))) + +/** + * @brief Set SPIn_SS1 pin to low state. + * @param[in] spi The pointer of the specified SPI module. + * @return None. + * @details Disable automatic slave selection function and set SPIn_SS1 pin to low state. Only available in Master mode. + * \hideinitializer + */ +#define SPI_SET_SS1_LOW(spi) ((spi)->SSCTL = ((spi)->SSCTL & ~(SPI_SSCTL_AUTOSS_Msk|SPI_SSCTL_SSACTPOL_Msk|SPI_SS1)) | SPI_SS1) + + +/** + * @brief Enable byte reorder function. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_BYTE_REORDER(spi) ( (spi)->CTL |= SPI_CTL_REORDER_Msk ) + +/** + * @brief Disable byte reorder function. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param [in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_BYTE_REORDER(spi) ( (spi)->CTL &= ~SPI_CTL_REORDER_Msk ) + +/** + * @brief Set the length of suspend interval. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @param[in] u32SuspCycle decides the length of suspend interval. + * @return none + * \hideinitializer + */ +#define SPI_SET_SUSPEND_CYCLE(spi, u32SuspCycle) ( (spi)->CTL = ((spi)->CTL & ~SPI_CTL_SUSPITV_Msk) | (u32SuspCycle << SPI_CTL_SUSPITV_Pos) ) + +/** + * @brief Set the SPI transfer sequence with LSB first. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_SET_LSB_FIRST(spi) ( (spi)->CTL |= SPI_CTL_LSB_Msk ) + +/** + * @brief Set the SPI transfer sequence with MSB first. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_SET_MSB_FIRST(spi) ( (spi)->CTL &= ~SPI_CTL_LSB_Msk ) + +/** + * @brief Set the data width of a SPI transaction. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @param[in] u32Width data width + * @return none + * \hideinitializer + */ +static __INLINE void SPI_SET_DATA_WIDTH(SPI_T *spi, uint32_t u32Width) +{ + if(u32Width == 32) + u32Width = 0; + + spi->CTL = (spi->CTL & ~SPI_CTL_DWIDTH_Msk) | (u32Width << SPI_CTL_DWIDTH_Pos); +} + +/** + * @brief Get the SPI busy state. + * @param[in] spi is the base address of SPI module. + * @return SPI busy status + * @retval 0: SPI module is not busy + * @retval 1: SPI module is busy + * \hideinitializer + */ +#define SPI_IS_BUSY(spi) ( ((spi)->STATUS & SPI_STATUS_BUSY_Msk) == SPI_STATUS_BUSY_Msk ? 1:0 ) + +/** + * @brief Set the SPIEN bit to trigger SPI transfer. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_TRIGGER(spi) ( (spi)->CTL |= SPI_CTL_SPIEN_Msk ) + +/** + * @brief Set the SPIEN bit to trigger SPI transfer. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE(spi) ( (spi)->CTL |= SPI_CTL_SPIEN_Msk ) + +/** + * @brief Disable SPI function. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE(spi) ( (spi)->CTL &= ~SPI_CTL_SPIEN_Msk ) + +/** + * @brief Disable SPI Dual IO function. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_DUAL_MODE(spi) ( (spi)->CTL &= ~SPI_CTL_DUALIOEN_Msk ) + +/** + * @brief Enable Dual IO function and set SPI Dual IO direction to input. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_DUAL_INPUT_MODE(spi) ( (spi)->CTL = ((spi)->CTL & ~SPI_CTL_QDIODIR_Msk) | SPI_CTL_DUALIOEN_Msk ) + +/** + * @brief Enable Dual IO function and set SPI Dual IO direction to output. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_DUAL_OUTPUT_MODE(spi) ( (spi)->CTL |= SPI_CTL_QDIODIR_Msk | SPI_CTL_DUALIOEN_Msk ) + +/** + * @brief Disable SPI Dual IO function. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_QUAD_MODE(spi) ( (spi)->CTL &= ~SPI_CTL_QUADIOEN_Msk ) + +/** + * @brief Set SPI Quad IO direction to input. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_QUAD_INPUT_MODE(spi) ( (spi)->CTL = ((spi)->CTL & ~SPI_CTL_QDIODIR_Msk) | SPI_CTL_QUADIOEN_Msk ) + +/** + * @brief Set SPI Quad IO direction to output. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_QUAD_OUTPUT_MODE(spi) ( (spi)->CTL |= SPI_CTL_QDIODIR_Msk | SPI_CTL_QUADIOEN_Msk ) + +/** + * @brief Trigger RX PDMA transfer. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_TRIGGER_RX_PDMA(spi) ( (spi)->PDMACTL |= SPI_PDMACTL_RXPDMAEN_Msk ) + +/** + * @brief Trigger TX PDMA transfer. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_TRIGGER_TX_PDMA(spi) ( (spi)->PDMACTL |= SPI_PDMACTL_TXPDMAEN_Msk ) + +/** + * @brief Trigger TX/RX PDMA transfer at the same time. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_TRIGGER_TXRX_PDMA(spi) ( (spi)->PDMACTL |= (SPI_PDMACTL_TXPDMAEN_Msk | SPI_PDMACTL_RXPDMAEN_Msk) ) + +/** + * @brief Disable RX PDMA transfer. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_RX_PDMA(spi) ( (spi)->PDMACTL &= ~SPI_PDMACTL_RXPDMAEN_Msk ) + +/** + * @brief Trigger TX PDMA transfer. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_TX_PDMA(spi) ( (spi)->PDMACTL &= ~SPI_PDMACTL_TXPDMAEN_Msk ) + +/** + * @brief Enable 2-bit transfer mode. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_ENABLE_2BIT_MODE(spi) ( (spi)->CTL |= SPI_CTL_TWOBIT_Msk ) + +/** + * @brief Disable 2-bit transfer mode. + * @note Before calling this function, SPI must be stopped first. \ref SPI_DISABLE must be called. + * @param[in] spi is the base address of SPI module. + * @return none + * \hideinitializer + */ +#define SPI_DISABLE_2BIT_MODE(spi) ( (spi)->CTL &= ~SPI_CTL_TWOBIT_Msk ) + +uint32_t SPI_Open(SPI_T *spi,uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock); +void SPI_Close(SPI_T *spi); +void SPI_ClearRxFIFO(SPI_T *spi); +void SPI_ClearTxFIFO(SPI_T *spi); +void SPI_DisableAutoSS(SPI_T *spi); +void SPI_EnableAutoSS(SPI_T *spi, uint32_t u32SSPinMask, uint32_t u32ActiveLevel); +uint32_t SPI_SetBusClock(SPI_T *spi, uint32_t u32BusClock); +void SPI_SetFIFOThreshold(SPI_T *spi, uint32_t u32TxThreshold, uint32_t u32RxThreshold); +uint32_t SPI_GetBusClock(SPI_T *spi); +void SPI_EnableInt(SPI_T *spi, uint32_t u32Mask); +void SPI_DisableInt(SPI_T *spi, uint32_t u32Mask); + + +/*@}*/ /* end of group NUC472_442_SPI_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SPI_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__SPI_H__ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sys.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sys.h new file mode 100644 index 0000000000000000000000000000000000000000..bf6cc6995bf2a7569b00f58312db7eaa1b91fe1e --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/sys.h @@ -0,0 +1,1275 @@ +/**************************************************************************//** + * @file SYS.h + * @version V1.0 + * $Revision 1 $ + * $Date: 15/10/21 1:35p $ + * @brief NUC472/NUC442 SYS Header File + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + ******************************************************************************/ + +#ifndef __SYS_H__ +#define __SYS_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SYS_Driver SYS Driver + @{ +*/ + +/** @addtogroup NUC472_442_SYS_EXPORTED_CONSTANTS SYS Exported Constants + @{ +*/ + +/*---------------------------------------------------------------------------------------------------------*/ +/* Module Reset Control Resister constant definitions. */ +/*---------------------------------------------------------------------------------------------------------*/ +#define PDMA_RST ((0x0<<24)|SYS_IPRST0_PDMARST_Pos) /*!GPA_MFPL = (SYS->GPA_MFPL & (~SYS_GPA_MFPL_PA0MFP_Msk) ) | SYS_GPA_MFPL_PA0MFP_SC0_CD ; + +*/ +//GPA_MFPL_PA0MFP +#define SYS_GPA_MFPL_PA0MFP_GPIO (0x0UL<BODCTL |= SYS_BODCTL_BODINTF_Msk) + +/** + * @brief Set Brown-out detector function to normal mode + * @param None + * @return None + * @details This macro set Brown-out detector to normal mode. + */ +#define SYS_CLEAR_BOD_LPM() (SYS->BODCTL &= ~SYS_BODCTL_BODLPM_Msk) + +/** + * @brief Disable Brown-out detector function + * @param None + * @return None + * @details This macro disable Brown-out detector function. + */ +#define SYS_DISABLE_BOD() (SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk) + +/** + * @brief Enable Brown-out detector function + * @param None + * @return None + * @details This macro enable Brown-out detector function. + */ +#define SYS_ENABLE_BOD() (SYS->BODCTL |= SYS_BODCTL_BODEN_Msk) +/** + * @brief Get Brown-out detector interrupt flag + * @param None + * @retval 0 Brown-out detect interrupt flag is not set. + * @retval >=1 Brown-out detect interrupt flag is set. + * @details This macro get Brown-out detector interrupt flag. + */ +#define SYS_GET_BOD_INT_FLAG() (SYS->BODCTL & SYS_BODCTL_BODINTF_Msk) + +/** + * @brief Get Brown-out detector status + * @param None + * @retval 0 System voltage is higher than BOD_VL setting or BOD_EN is 0. + * @retval >=1 System voltage is lower than BOD_VL setting. + * @details This macro get Brown-out detector output status. + * If the BOD_EN is 0, this function always return 0. + */ +#define SYS_GET_BOD_OUTPUT() (SYS->BODCTL & SYS_BODCTL_BODOUT_Msk) + +/** + * @brief Disable Brown-out detector interrupt function + * @param None + * @return None + * @details This macro enable Brown-out detector interrupt function. + */ +#define SYS_DISABLE_BOD_RST() (SYS->BODCTL &= ~SYS_BODCTL_BODRSTEN_Msk) + +/** + * @brief Enable Brown-out detector reset function + * @param None + * @return None + * @details This macro enable Brown-out detect reset function. + */ +#define SYS_ENABLE_BOD_RST() (SYS->BODCTL |= SYS_BODCTL_BODRSTEN_Msk) + + +/** + * @brief Set Brown-out detector function low power mode + * @param None + * @return None + * @details This macro set Brown-out detector to low power mode. + */ +#define SYS_SET_BOD_LPM() (SYS->BODCTL |= SYS_BODCTL_BODLPM_Msk) + +/** + * @brief Set Brown-out detector voltage level + * @param[in] u32Level is Brown-out voltage level. Including : + * - \ref SYS_BODCTL_BODVL_4_5V + * - \ref SYS_BODCTL_BODVL_3_8V + * - \ref SYS_BODCTL_BODVL_2_7V + * - \ref SYS_BODCTL_BODVL_2_2V + * @return None + * @details This macro set Brown-out detector voltage level. + */ +#define SYS_SET_BOD_LEVEL(u32Level) (SYS->BODCTL = (SYS->BODCTL & ~SYS_BODCTL_BODVL_Msk) | u32Level) + +/** + * @brief Get reset source is from Brown-out detector reset + * @param None + * @retval 0 Previous reset source is not from Brown-out detector reset + * @retval >=1 Previous reset source is from Brown-out detector reset + * @details This macro get previous reset source is from Brown-out detect reset or not. + */ +#define SYS_IS_BOD_RST() (SYS->RSTSTS & SYS_RSTSTS_BODRF_Msk) + +/** + * @brief Get reset source is from CPU reset + * @param None + * @retval 0 Previous reset source is not from CPU reset + * @retval >=1 Previous reset source is from CPU reset + * @details This macro get previous reset source is from CPU reset. + */ +#define SYS_IS_CPU_RST() (SYS->RSTSTS & SYS_RSTSTS_CPURF_Msk) + +/** + * @brief Get reset source is from LVR Reset + * @param None + * @retval 0 Previous reset source is not from LVR Reset + * @retval >=1 Previous reset source is from LVR Reset + * @details This macro get previous reset source is from Power-on Reset. + */ +#define SYS_IS_LVR_RST() (SYS->RSTSTS & SYS_RSTSTS_LVRF_Msk) + +/** + * @brief Get reset source is from Power-on Reset + * @param None + * @retval 0 Previous reset source is not from Power-on Reset + * @retval >=1 Previous reset source is from Power-on Reset + * @details This macro get previous reset source is from Power-on Reset. + */ +#define SYS_IS_POR_RST() (SYS->RSTSTS & SYS_RSTSTS_PORF_Msk) + +/** + * @brief Get reset source is from reset pin reset + * @param None + * @retval 0 Previous reset source is not from reset pin reset + * @retval >=1 Previous reset source is from reset pin reset + * @details This macro get previous reset source is from reset pin reset. + */ +#define SYS_IS_RSTPIN_RST() (SYS->RSTSTS & SYS_RSTSTS_PINRF_Msk) + +/** + * @brief Get reset source is from system reset + * @param None + * @retval 0 Previous reset source is not from system reset + * @retval >=1 Previous reset source is from system reset + * @details This macro get previous reset source is from system reset. + */ +#define SYS_IS_SYSTEM_RST() (SYS->RSTSTS & SYS_RSTSTS_SYSRF_Msk) + +/** + * @brief Get reset source is from window watch dog reset + * @param None + * @retval 0 Previous reset source is not from window watch dog reset + * @retval >=1 Previous reset source is from window watch dog reset + * @details This macro get previous reset source is from window watch dog reset. + */ +#define SYS_IS_WDT_RST() (SYS->RSTSTS & SYS_RSTSTS_WDTRF_Msk) + +/** + * @brief Disable Low-Voltage-Reset function + * @param None + * @return None + * @details This macro disable Low-Voltage-Reset function. + */ +#define SYS_DISABLE_LVR() (SYS->BODCTL &= ~SYS_BODCTL_LVREN_Msk) + +/** + * @brief Enable Low-Voltage-Reset function + * @param None + * @return None + * @details This macro enable Low-Voltage-Reset function. + */ +#define SYS_ENABLE_LVR() (SYS->BODCTL |= SYS_BODCTL_LVREN_Msk) + +/** + * @brief Disable Power-on Reset function + * @param None + * @return None + * @details This macro disable Power-on Reset function. + */ +#define SYS_DISABLE_POR() (SYS->PORCTL = 0x5AA5) + +/** + * @brief Enable Power-on Reset function + * @param None + * @return None + * @details This macro enable Power-on Reset function. + */ +#define SYS_ENABLE_POR() (SYS->PORCTL = 0) + + +/** + * @brief Clear reset source flag + * @param[in] u32RstSrc is reset source. Including: + * - \ref SYS_RSTSTS_PORF_Msk + * - \ref SYS_RSTSTS_PINRF_Msk + * - \ref SYS_RSTSTS_WDTRF_Msk + * - \ref SYS_RSTSTS_LVRF_Msk + * - \ref SYS_RSTSTS_BODRF_Msk + * - \ref SYS_RSTSTS_SYSRF_Msk + * - \ref SYS_RSTSTS_CPURF_Msk + * @return None + * @details This macro clear reset source flag. + */ +#define SYS_CLEAR_RST_SOURCE(u32RstSrc) (SYS->RSTSTS = u32RstSrc ) + +void SYS_ClearResetSrc(uint32_t u32Src); +uint32_t SYS_GetBODStatus(void); +uint32_t SYS_GetResetSrc(void); +uint32_t SYS_IsRegLocked(void); +void SYS_LockReg(void); +void SYS_UnlockReg(void); +uint32_t SYS_ReadPDID(void); +void SYS_ResetChip(void); +void SYS_ResetCPU(void); +void SYS_ResetModule(uint32_t u32ModuleIndex); +void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel); +void SYS_DisableBOD(void); + +/*@}*/ /* end of group NUC472_442_SYS_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SYS_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__SYS_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/timer.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/timer.h new file mode 100644 index 0000000000000000000000000000000000000000..bceedacd494728ab4f6f4d9349f511572b5c486d --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/timer.h @@ -0,0 +1,324 @@ +/**************************************************************************//** + * @file timer.h + * @version V1.00 + * $Revision: 7 $ + * $Date: 15/11/12 9:55a $ + * @brief NUC472/NUC442 TIMER driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __TIMER_H__ +#define __TIMER_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_TIMER_Driver TIMER Driver + @{ +*/ + +/** @addtogroup NUC472_442_TIMER_EXPORTED_CONSTANTS TIMER Exported Constants + @{ +*/ + +#define TIMER_ONESHOT_MODE (0UL) /*!< Timer working in one shot mode \hideinitializer */ +#define TIMER_PERIODIC_MODE (1UL << TIMER_CTL_OPMODE_Pos) /*!< Timer working in periodic mode \hideinitializer */ +#define TIMER_TOGGLE_MODE (2UL << TIMER_CTL_OPMODE_Pos) /*!< Timer working in toggle mode \hideinitializer */ +#define TIMER_CONTINUOUS_MODE (3UL << TIMER_CTL_OPMODE_Pos) /*!< Timer working in continuous mode \hideinitializer */ +#define TIMER_CAPTURE_FREE_COUNTING_MODE (0UL) /*!< Free counting mode \hideinitializer */ +#define TIMER_CAPTURE_COUNTER_RESET_MODE (TIMER_EXTCTL_CAPFUNCS_Msk) /*!< Counter reset mode \hideinitializer */ +#define TIMER_CAPTURE_FALLING_EDGE (0UL) /*!< Falling edge trigger timer capture \hideinitializer */ +#define TIMER_CAPTURE_RISING_EDGE (1UL << TIMER_EXTCTL_CAPEDGE_Pos) /*!< Rising edge trigger timer capture \hideinitializer */ +#define TIMER_CAPTURE_FALLING_AND_RISING_EDGE (2UL << TIMER_EXTCTL_CAPEDGE_Pos) /*!< Both falling edge and rising edge trigger timer capture \hideinitializer */ +#define TIMER_COUNTER_RISING_EDGE (TIMER_EXTCTL_CNTPHASE_Msk) /*!< Counter increase on rising edge \hideinitializer */ +#define TIMER_COUNTER_FALLING_EDGE (0UL) /*!< Counter increase on falling edge \hideinitializer */ +#define TIMER_TOGGLE_OUT1 (TIMER_CTL_TOGDIS2_Msk) /*!< Select PB.4, PB.1, PC.6, PC.1 as timer toggle output pin \hideinitializer */ +#define TIMER_TOGGLE_OUT2 (TIMER_CTL_TOGDIS1_Msk) /*!< Select PD.1, PE.8, PE.1, PD.11 as timer toggle output pin \hideinitializer */ + +/*@}*/ /* end of group NUC472_442_TIMER_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_TIMER_EXPORTED_FUNCTIONS TIMER Exported Functions + @{ +*/ + +/** + * @brief This macro is used to set new Timer compared value + * @param[in] timer The base address of Timer module + * @param[in] u32Value Timer compare value. Valid values are between 2 to 0xFFFFFF + * @return None + * \hideinitializer + */ +#define TIMER_SET_CMP_VALUE(timer, u32Value) ((timer)->CMP = (u32Value)) + +/** + * @brief This macro is used to set new Timer prescale value + * @param[in] timer The base address of Timer module + * @param[in] u32Value Timer prescale value. Valid values are between 0 to 0xFF + * @return None + * @note Clock input is divided by (prescale + 1) before it is fed into timer + * \hideinitializer + */ +#define TIMER_SET_PRESCALE_VALUE(timer, u32Value) ((timer)->CTL = ((timer)->CTL & ~TIMER_CTL_PSC_Msk) | (u32Value)) + +/** + * @brief This macro is used to check if specify Timer is inactive or active + * @return timer is activate or inactivate + * @retval 0 Timer 24-bit up counter is inactive + * @retval 1 Timer 24-bit up counter is active + * \hideinitializer + */ +#define TIMER_IS_ACTIVE(timer) ((timer)->CTL & TIMER_CTL_ACTSTS_Msk ? 1 : 0) + +/** + * @brief This macro is used to select Timer toggle output pin + * @param[in] timer The base address of Timer module + * @param[in] u32ToutSel Toggle output pin selection, valid values are + * - \ref TIMER_TOGGLE_OUT1 + * - \ref TIMER_TOGGLE_OUT2 + * @return None + * \hideinitializer + */ +#define TIMER_SELECT_TOUT_PIN(timer, u32ToutSel) ((timer)->CTL = ((timer)->CTL & ~(TIMER_CTL_TOGDIS2_Msk | TIMER_CTL_TOGDIS1_Msk)) | (u32ToutSel)) + + +/** + * @brief This function is used to start Timer counting + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_Start(TIMER_T *timer) +{ + timer->CTL |= TIMER_CTL_CNTEN_Msk; +} + +/** + * @brief This function is used to stop Timer counting + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_Stop(TIMER_T *timer) +{ + timer->CTL &= ~TIMER_CTL_CNTEN_Msk; +} + +/** + * @brief This function is used to enable the Timer wake-up function + * @param[in] timer The base address of Timer module + * @return None + * @note To wake the system from power down mode, timer clock source must be ether LXT or LIRC + */ +__STATIC_INLINE void TIMER_EnableWakeup(TIMER_T *timer) +{ + timer->CTL |= TIMER_CTL_WKEN_Msk; +} + +/** + * @brief This function is used to disable the Timer wake-up function + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_DisableWakeup(TIMER_T *timer) +{ + timer->CTL &= ~TIMER_CTL_WKEN_Msk; +} + + +/** + * @brief This function is used to enable the capture pin detection de-bounce function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_EnableCaptureDebounce(TIMER_T *timer) +{ + timer->EXTCTL |= TIMER_EXTCTL_CAPDBEN_Msk; +} + +/** + * @brief This function is used to disable the capture pin detection de-bounce function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_DisableCaptureDebounce(TIMER_T *timer) +{ + timer->EXTCTL &= ~TIMER_EXTCTL_CAPDBEN_Msk; +} + + +/** + * @brief This function is used to enable the counter pin detection de-bounce function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_EnableEventCounterDebounce(TIMER_T *timer) +{ + timer->EXTCTL |= TIMER_EXTCTL_ECNTDBEN_Msk; +} + +/** + * @brief This function is used to disable the counter pin detection de-bounce function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_DisableEventCounterDebounce(TIMER_T *timer) +{ + timer->EXTCTL &= ~TIMER_EXTCTL_ECNTDBEN_Msk; +} + +/** + * @brief This function is used to enable the Timer time-out interrupt function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_EnableInt(TIMER_T *timer) +{ + timer->CTL |= TIMER_CTL_INTEN_Msk; +} + +/** + * @brief This function is used to disable the Timer time-out interrupt function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_DisableInt(TIMER_T *timer) +{ + timer->CTL &= ~TIMER_CTL_INTEN_Msk; +} + +/** + * @brief This function is used to enable the Timer capture trigger interrupt function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_EnableCaptureInt(TIMER_T *timer) +{ + timer->EXTCTL |= TIMER_EXTCTL_CAPIEN_Msk; +} + +/** + * @brief This function is used to disable the Timer capture trigger interrupt function. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_DisableCaptureInt(TIMER_T *timer) +{ + timer->EXTCTL &= ~TIMER_EXTCTL_CAPIEN_Msk; +} + +/** + * @brief This function indicates Timer time-out interrupt occurred or not. + * @param[in] timer The base address of Timer module + * @return Timer time-out interrupt occurred or not + * @retval 0 Timer time-out interrupt did not occur + * @retval 1 Timer time-out interrupt occurred + */ +__STATIC_INLINE uint32_t TIMER_GetIntFlag(TIMER_T *timer) +{ + return(timer->INTSTS & TIMER_INTSTS_TIF_Msk ? 1 : 0); +} + +/** + * @brief This function clears the Timer time-out interrupt flag. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_ClearIntFlag(TIMER_T *timer) +{ + timer->INTSTS = TIMER_INTSTS_TIF_Msk; +} + +/** + * @brief This function indicates Timer capture interrupt occurred or not. + * @param[in] timer The base address of Timer module + * @return Timer capture interrupt occurred or not + * @retval 0 Timer capture interrupt did not occur + * @retval 1 Timer capture interrupt occurred + */ +__STATIC_INLINE uint32_t TIMER_GetCaptureIntFlag(TIMER_T *timer) +{ + return timer->EINTSTS; +} + +/** + * @brief This function clears the Timer capture interrupt flag. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_ClearCaptureIntFlag(TIMER_T *timer) +{ + timer->EINTSTS = TIMER_EINTSTS_CAPIF_Msk; +} + +/** + * @brief This function indicates Timer has waked up system or not. + * @param[in] timer The base address of Timer module + * @return Timer has waked up system or not + * @retval 0 Timer did not wake up system + * @retval 1 Timer wake up system + */ +__STATIC_INLINE uint32_t TIMER_GetWakeupFlag(TIMER_T *timer) +{ + return (timer->INTSTS & TIMER_INTSTS_TWKF_Msk ? 1 : 0); +} + +/** + * @brief This function clears the Timer wakeup interrupt flag. + * @param[in] timer The base address of Timer module + * @return None + */ +__STATIC_INLINE void TIMER_ClearWakeupFlag(TIMER_T *timer) +{ + timer->INTSTS = TIMER_INTSTS_TWKF_Msk; +} + +/** + * @brief This function gets the Timer capture data. + * @param[in] timer The base address of Timer module + * @return Timer capture data value + */ +__STATIC_INLINE uint32_t TIMER_GetCaptureData(TIMER_T *timer) +{ + return timer->CAP; +} + +/** + * @brief This function reports the current timer counter value. + * @param[in] timer The base address of Timer module + * @return Timer counter value + */ +__STATIC_INLINE uint32_t TIMER_GetCounter(TIMER_T *timer) +{ + return timer->CNT; +} + +uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq); +void TIMER_Close(TIMER_T *timer); +void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec); +void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge); +void TIMER_DisableCapture(TIMER_T *timer); +void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge); +void TIMER_DisableEventCounter(TIMER_T *timer); +uint32_t TIMER_GetModuleClock(TIMER_T *timer); + + +/*@}*/ /* end of group NUC472_442_TIMER_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_TIMER_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__TIMER_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/uart.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/uart.h new file mode 100644 index 0000000000000000000000000000000000000000..e6e6f73bd7872e159dc371ef42f085ef795891c6 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/uart.h @@ -0,0 +1,400 @@ +/**************************************************************************//** + * @file uart.h + * @version V1.00 + * $Revision: 20 $ + * $Date: 15/11/30 1:35p $ + * @brief NUC472/NUC442 UART driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + + +#ifndef __UART_H__ +#define __UART_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_UART_Driver UART Driver + @{ +*/ + +/** @addtogroup NUC472_442_UART_EXPORTED_CONSTANTS UART Exported Constants + @{ +*/ + +/*---------------------------------------------------------------------------------------------------------*/ +/* UART_FCR constants definitions */ +/*---------------------------------------------------------------------------------------------------------*/ + +#define UART_FIFO_RFITL_1BYTE (0x0 << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 1 byte */ +#define UART_FIFO_RFITL_4BYTES (0x1 << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 4 bytes */ +#define UART_FIFO_RFITL_8BYTES (0x2 << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 8 bytes */ +#define UART_FIFO_RFITL_14BYTES (0x3 << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 14 bytes */ + +#define UART_FIFO_RTSTRGLV_1BYTE (0x0 << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 1 byte */ +#define UART_FIFO_RTSTRGLV_4BYTES (0x1 << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 4 bytes */ +#define UART_FIFO_RTSTRGLV_8BYTES (0x2 << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 8 bytes */ +#define UART_FIFO_RTSTRGLV_14BYTES (0x3 << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 14 bytes */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* UART_LCR constants definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define UART_WORD_LEN_5 (0) /*!< UART_LINE setting to set UART word length to 5 bits */ +#define UART_WORD_LEN_6 (1) /*!< UART_LINE setting to set UART word length to 6 bits */ +#define UART_WORD_LEN_7 (2) /*!< UART_LINE setting to set UART word length to 7 bits */ +#define UART_WORD_LEN_8 (3) /*!< UART_LINE setting to set UART word length to 8 bits */ + +#define UART_PARITY_NONE (0x0 << UART_LINE_PBE_Pos) /*!< UART_LINE setting to set UART as no parity */ +#define UART_PARITY_ODD (0x1 << UART_LINE_PBE_Pos) /*!< UART_LINE setting to set UART as odd parity */ +#define UART_PARITY_EVEN (0x3 << UART_LINE_PBE_Pos) /*!< UART_LINE setting to set UART as even parity */ +#define UART_PARITY_MARK (0x5 << UART_LINE_PBE_Pos) /*!< UART_LINE setting to keep parity bit as '1' */ +#define UART_PARITY_SPACE (0x7 << UART_LINE_PBE_Pos) /*!< UART_LINE setting to keep parity bit as '0' */ + +#define UART_STOP_BIT_1 (0x0 << UART_LINE_NSB_Pos) /*!< UART_LINE setting for one stop bit */ +#define UART_STOP_BIT_1_5 (0x1 << UART_LINE_NSB_Pos) /*!< UART_LINE setting for 1.5 stop bit when 5-bit word length */ +#define UART_STOP_BIT_2 (0x1 << UART_LINE_NSB_Pos) /*!< UART_LINE setting for two stop bit when 6, 7, 8-bit word length */ + + +/*---------------------------------------------------------------------------------------------------------*/ +/* UART RTS LEVEL TRIGGER constants definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define UART_RTS_IS_HIGH_LEV_TRG (0x1 << UART_MODEM_RTSACTLV_Pos) /*!< Set RTS is High Level Trigger */ +#define UART_RTS_IS_LOW_LEV_TRG (0x0 << UART_MODEM_RTSACTLV_Pos) /*!< Set RTS is Low Level Trigger */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* UART CTS LEVEL TRIGGER constants definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define UART_CTS_IS_HIGH_LEV_TRG (0x1 << UART_MODEMSTS_CTSACTLV_Pos) /*!< Set CTS is High Level Trigger */ +#define UART_CTS_IS_LOW_LEV_TRG (0x0 << UART_MODEMSTS_CTSACTLV_Pos) /*!< Set CTS is Low Level Trigger */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* UART_FUNC_SEL constants definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define UART_FUNCSEL_UART (0x0 << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set UART Function (Default) */ +#define UART_FUNCSEL_IrDA (0x2 << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set IrDA Function */ +#define UART_FUNCSEL_RS485 (0x3 << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set RS485 Function */ + +/*---------------------------------------------------------------------------------------------------------*/ +/* UART BAUDRATE MODE constants definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define UART_BAUD_MODE0 (0) /*!< Set UART Baudrate Mode is Mode0 */ +#define UART_BAUD_MODE2 (UART_BAUD_BAUDM1_Msk | UART_BAUD_BAUDM0_Msk) /*!< Set UART Baudrate Mode is Mode2 */ + + + +/*@}*/ /* end of group NUC472_442_UART_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_UART_EXPORTED_FUNCTIONS UART Exported Functions + @{ +*/ + + +/** + * @brief Calculate UART baudrate mode0 divider + * + * @param[in] u32SrcFreq UART clock frequency + * @param[in] u32BaudRate Baudrate of UART module + * + * @return UART baudrate mode0 divider + * \hideinitializer + * + */ +#define UART_BAUD_MODE0_DIVIDER(u32SrcFreq, u32BaudRate) (((u32SrcFreq + (u32BaudRate*8)) / u32BaudRate >> 4)-2) + +/** + * @brief Calculate UART baudrate mode2 divider + * + * @param[in] u32SrcFreq UART clock frequency + * @param[in] u32BaudRate Baudrate of UART module + * + * @return UART baudrate mode2 divider + * \hideinitializer + */ +#define UART_BAUD_MODE2_DIVIDER(u32SrcFreq, u32BaudRate) (((u32SrcFreq + (u32BaudRate/2)) / u32BaudRate)-2) + + +/** + * @brief Write Data to Tx data register + * + * @param[in] uart The base address of UART module. + * @param[in] u8Data Data byte to transmit + * + * @return None + * \hideinitializer + */ +#define UART_WRITE(uart, u8Data) (uart->DAT = (u8Data)) + +/** + * @brief Read Rx data register + * + * @param[in] uart The base address of UART module. + * + * @return The oldest data byte in RX FIFO + * \hideinitializer + */ +#define UART_READ(uart) (uart->DAT) + + +/** + * @brief Get Tx empty register value. + * + * @param[in] uart The base address of UART module + * + * @return Tx empty register value. + * \hideinitializer + */ +#define UART_GET_TX_EMPTY(uart) (uart->FIFOSTS & UART_FIFOSTS_TXEMPTY_Msk) + + +/** + * @brief Get Rx empty register value. + * + * @param[in] uart The base address of UART module + * + * @return Rx empty register value. + * \hideinitializer + */ +#define UART_GET_RX_EMPTY(uart) (uart->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk) + +/** + * @brief Check specified uart port transmission is over. + * + * @param[in] uart The base address of UART module + * + * @return TE_Flag. + * \hideinitializer + */ +#define UART_IS_TX_EMPTY(uart) ((uart->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos) + + +/** + * @brief Wait specified uart port transmission is over + * + * @param[in] uart The base address of UART module + * + * @return None + * \hideinitializer + */ +#define UART_WAIT_TX_EMPTY(uart) while(!(((uart->FIFOSTS) & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos)) + +/** + * @brief Check RDA_IF is set or not + * + * @param[in] uart The base address of UART module + * + * @return + * 0 : The number of bytes in the RX FIFO is less than the RFITL + * 1 : The number of bytes in the RX FIFO equals or larger than RFITL + * \hideinitializer + */ +#define UART_IS_RX_READY(uart) ((uart->INTSTS & UART_INTSTS_RDAIF_Msk)>>UART_INTSTS_RDAIF_Pos) + + +/** + * @brief Check TX FIFO is full or not + * + * @param[in] uart The base address of UART module + * + * @return + * 1 = TX FIFO is full + * 0 = TX FIFO is not full + * \hideinitializer + */ +#define UART_IS_TX_FULL(uart) ((uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)>>UART_FIFOSTS_TXFULL_Pos) + +/** + * @brief Check RX FIFO is full or not + * + * @param[in] uart The base address of UART module + * + * @return + * 1 = RX FIFO is full + * 0 = RX FIFO is not full + * \hideinitializer + * + */ +#define UART_IS_RX_FULL(uart) ((uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)>>UART_FIFOSTS_RXFULL_Pos) + + +/** + * @brief Get Tx full register value + * + * @param[in] uart The base address of UART module + * + * @return Tx full register value + * \hideinitializer + */ +#define UART_GET_TX_FULL(uart) (uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk) + + +/** + * @brief Get Rx full register value + * + * @param[in] uart The base address of UART module + * + * @return Rx full register value + * \hideinitializer + */ +#define UART_GET_RX_FULL(uart) (uart->FIFOSTS & UART_FIFOSTS_RXFULL_Msk) + + +/** + * @brief Enable specified interrupt + * + * @param[in] uart The base address of UART module + * @param[in] u32eIntSel Interrupt type select + * - \ref UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt + * - \ref UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt + * - \ref UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt + * - \ref UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt + * - \ref UART_INTEN_MODEMIEN_Msk : Modem interrupt + * - \ref UART_INTEN_RLSIEN_Msk : Rx Line status interrupt + * - \ref UART_INTEN_THREIEN_Msk : Tx empty interrupt + * - \ref UART_INTEN_RDAIEN_Msk : Rx ready interrupt + * + * @return None + * \hideinitializer + */ +#define UART_ENABLE_INT(uart, u32eIntSel) (uart->INTEN |= (u32eIntSel)) + + +/** + * @brief Disable specified interrupt + * + * @param[in] uart The base address of UART module + * @param[in] u32eIntSel Interrupt type select + * - \ref UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt + * - \ref UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt + * - \ref UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt + * - \ref UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt + * - \ref UART_INTEN_MODEMIEN_Msk : Modem interrupt + * - \ref UART_INTEN_RLSIEN_Msk : Rx Line status interrupt + * - \ref UART_INTEN_THREIEN_Msk : Tx empty interrupt + * - \ref UART_INTEN_RDAIEN_Msk : Rx ready interrupt + * @return None + * \hideinitializer + */ +#define UART_DISABLE_INT(uart, u32eIntSel) (uart->INTEN &= ~ (u32eIntSel)) + + +/** + * @brief Get specified interrupt flag/status + * + * @param[in] uart The base address of UART module + * @param[in] u32eIntTypeFlag Interrupt type select + * - \ref UART_INTSTS_HWBUFEINT_Msk : In DMA Mode, Buffer Error Interrupt Indicator. + * - \ref UART_INTSTS_HWTOINT_Msk : In DMA Mode, Time-out Interrupt Indicator. + * - \ref UART_INTSTS_HWMODINT_Msk : In DMA Mode, MODEM Status Interrupt Indicator. + * - \ref UART_INTSTS_HWRLSINT_Msk : In DMA Mode, Receive Line Status Interrupt Indicator. + * - \ref UART_INTSTS_HWBUFEIF_Msk : In DMA Mode, Buffer Error Interrupt Flag. + * - \ref UART_INTSTS_HWTOIF_Msk : In DMA Mode, Time-out Interrupt Flag. + * - \ref UART_INTSTS_HWMODIF_Msk : In DMA Mode, MODEM Interrupt Flag. + * - \ref UART_INTSTS_HWRLSIF_Msk : In DMA Mode, Receive Line Status Flag. + * - \ref UART_INTSTS_LININT_Msk : LIN Bus Interrupt Indicator. + * - \ref UART_INTSTS_BUFERRINT_Msk : Buffer Error Interrupt Indicator. + * - \ref UART_INTSTS_RXTOINT_Msk : Time-out Interrupt Indicator. + * - \ref UART_INTSTS_MODEMINT_Msk : Modem Status Interrupt Indicator. + * - \ref UART_INTSTS_RLSINT_Msk : Receive Line Status Interrupt Indicator. + * - \ref UART_INTSTS_THREINT_Msk : Transmit Holding Register Empty Interrupt Indicator. + * - \ref UART_INTSTS_RDAINT_Msk : Receive Data Available Interrupt Indicator. + * - \ref UART_INTSTS_LINIF_Msk : LIN Bus Flag. + * - \ref UART_INTSTS_BUFERRIF_Msk : Buffer Error Interrupt Flag + * - \ref UART_INTSTS_RXTOIF_Msk : Rx time-out interrupt Flag + * - \ref UART_INTSTS_MODEMIF_Msk : Modem interrupt Flag + * - \ref UART_INTSTS_RLSIF_Msk : Rx Line status interrupt Flag + * - \ref UART_INTSTS_THREIF_Msk : Tx empty interrupt Flag + * - \ref UART_INTSTS_RDAIF_Msk : Rx ready interrupt Flag + * + * @return + * 0 = The specified interrupt is not happened. + * 1 = The specified interrupt is happened. + * \hideinitializer + */ +#define UART_GET_INT_FLAG(uart,u32eIntTypeFlag) ((uart->INTSTS & (u32eIntTypeFlag))?1:0) + + +/** + * @brief Set RTS pin is low + * + * @param[in] uart The base address of UART module + * @return None + */ +__STATIC_INLINE void UART_CLEAR_RTS(UART_T* uart) +{ + uart->MODEM |= UART_MODEM_RTSACTLV_Msk; + uart->MODEM &= UART_MODEM_RTS_Msk; +} + +/** + * @brief Set RTS pin is high + * + * @param[in] uart The base address of UART module + * @return None + */ +__STATIC_INLINE void UART_SET_RTS(UART_T* uart) +{ + uart->MODEM |= UART_MODEM_RTSACTLV_Msk | UART_MODEM_RTS_Msk; +} + +/** + * @brief Clear RS-485 Address Byte Detection Flag + * + * @param[in] uart The base address of UART module + * @return None + * \hideinitializer + */ +#define UART_RS485_CLEAR_ADDR_FLAG(uart) (uart->FIFOSTS |= UART_FIFOSTS_ADDRDETF_Msk) + + +/** + * @brief Get RS-485 Address Byte Detection Flag + * + * @param[in] uart The base address of UART module + * @return RS-485 Address Byte Detection Flag + * \hideinitializer + */ +#define UART_RS485_GET_ADDR_FLAG(uart) ((uart->FIFOSTS & UART_FIFOSTS_ADDRDETF_Msk) >> UART_FIFOSTS_ADDRDETF_Pos) + + +void UART_ClearIntFlag(UART_T* uart , uint32_t u32InterruptFlag); +void UART_Close(UART_T* uart ); +void UART_DisableFlowCtrl(UART_T* uart ); +void UART_DisableInt(UART_T* uart, uint32_t u32InterruptFlag ); +void UART_EnableFlowCtrl(UART_T* uart ); +void UART_EnableInt(UART_T* uart, uint32_t u32InterruptFlag ); +void UART_Open(UART_T* uart, uint32_t u32baudrate); +uint32_t UART_Read(UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes); +void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits); +void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC); +void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction); +void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr); +uint32_t UART_Write(UART_T* uart,uint8_t *pu8TxBuf, uint32_t u32WriteBytes); + + +/*@}*/ /* end of group NUC472_442_UART_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_UART_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__UART_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/usbd.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/usbd.h new file mode 100644 index 0000000000000000000000000000000000000000..4d3d87c43ac405b011597edb1e625fcabbebf128 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/usbd.h @@ -0,0 +1,412 @@ +/**************************************************************************//** + * @file usbd.h + * @version V1.00 + * $Revision: 24 $ + * $Date: 15/12/01 10:14a $ + * @brief NUC472/NUC442 USBD driver header file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __USBD_H__ +#define __USBD_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_USBD_Driver USBD Driver + @{ +*/ + +/** @addtogroup NUC472_442_USBD_EXPORTED_CONSTANTS USBD Exported Constants + @{ +*/ +/// @cond HIDDEN_SYMBOLS +#define USBD_MAX_EP 12 + +#define Maximum(a,b) (a)>(b) ? (a) : (b) +#define Minimum(a,b) (a)<(b) ? (a) : (b) + + +#define CEP 0xff /*!< Control Endpoint \hideinitializer */ +#define EPA 0 /*!< Endpoint A \hideinitializer */ +#define EPB 1 /*!< Endpoint B \hideinitializer */ +#define EPC 2 /*!< Endpoint C \hideinitializer */ +#define EPD 3 /*!< Endpoint D \hideinitializer */ +#define EPE 4 /*!< Endpoint E \hideinitializer */ +#define EPF 5 /*!< Endpoint F \hideinitializer */ +#define EPG 6 /*!< Endpoint G \hideinitializer */ +#define EPH 7 /*!< Endpoint H \hideinitializer */ +#define EPI 8 /*!< Endpoint I \hideinitializer */ +#define EPJ 9 /*!< Endpoint J \hideinitializer */ +#define EPK 10 /*!< Endpoint K \hideinitializer */ +#define EPL 11 /*!< Endpoint L \hideinitializer */ + +/* USB Request Type */ +#define REQ_STANDARD 0x00 +#define REQ_CLASS 0x20 +#define REQ_VENDOR 0x40 + +/* USB Standard Request */ +#define GET_STATUS 0x00 +#define CLEAR_FEATURE 0x01 +#define SET_FEATURE 0x03 +#define SET_ADDRESS 0x05 +#define GET_DESCRIPTOR 0x06 +#define SET_DESCRIPTOR 0x07 +#define GET_CONFIGURATION 0x08 +#define SET_CONFIGURATION 0x09 +#define GET_INTERFACE 0x0A +#define SET_INTERFACE 0x0B +#define SYNC_FRAME 0x0C + +/* USB Descriptor Type */ +#define DESC_DEVICE 0x01 +#define DESC_CONFIG 0x02 +#define DESC_STRING 0x03 +#define DESC_INTERFACE 0x04 +#define DESC_ENDPOINT 0x05 +#define DESC_QUALIFIER 0x06 +#define DESC_OTHERSPEED 0x07 +#define DESC_IFPOWER 0x08 +#define DESC_OTG 0x09 + +/* USB HID Descriptor Type */ +#define DESC_HID 0x21 +#define DESC_HID_RPT 0x22 + +/* USB Descriptor Length */ +#define LEN_DEVICE 18 +#define LEN_QUALIFIER 10 +#define LEN_CONFIG 9 +#define LEN_INTERFACE 9 +#define LEN_ENDPOINT 7 +#define LEN_OTG 5 +#define LEN_HID 9 + +/* USB Endpoint Type */ +#define EP_ISO 0x01 +#define EP_BULK 0x02 +#define EP_INT 0x03 + +#define EP_INPUT 0x80 +#define EP_OUTPUT 0x00 + +/* USB Feature Selector */ +#define FEATURE_DEVICE_REMOTE_WAKEUP 0x01 +#define FEATURE_ENDPOINT_HALT 0x00 +/// @endcond HIDDEN_SYMBOLS +/********************* Bit definition of CEPCTL register **********************/ +#define USB_CEPCTL_NAKCLR ((uint32_t)0x00000000) /*!PHYCTL |= (USBD_PHYCTL_PHYEN_Msk|USBD_PHYCTL_DPPUEN_Msk))) /*!PHYCTL &= ~USBD_PHYCTL_DPPUEN_Msk)) /*!PHYCTL |= (USBD_PHYCTL_PHYEN_Msk|USBD_PHYCTL_DPPUEN_Msk))) /*!PHYCTL &= ~USBD_PHYCTL_PHYEN_Msk)) /*!PHYCTL &= ~USBD_PHYCTL_DPPUEN_Msk)) /*!PHYCTL |= USBD_PHYCTL_DPPUEN_Msk)) /*!FADDR = (addr)) /*!FADDR)) /*!GINTEN = (intr)) /*!BUSINTEN = (intr)) /*!BUSINTSTS) /*!BUSINTSTS = flag) /*!CEPINTEN = (intr)) /*!CEPINTSTS = flag) /*!CEPCTL = flag) /*!CEPTXCNT = size) /*!EP[ep].EPMPS = (size)) /*!EP[ep].EPINTEN = (intr)) /*!EP[ep].EPINTSTS) /*!EP[ep].EPINTSTS = (flag)) /*!DMACNT = len) /*!DMAADDR = addr) /*!DMACTL = (USBD->DMACTL & ~USBD_DMACTL_EPNUM_Msk) | USBD_DMACTL_DMARD_Msk | epnum) /*!DMACTL = (USBD->DMACTL & ~(USBD_DMACTL_EPNUM_Msk | USBD_DMACTL_DMARD_Msk)) | epnum) /*!DMACTL |= USBD_DMACTL_DMAEN_Msk) /*!PHYCTL & USBD_PHYCTL_VBUSDET_Msk)) /*!DMACNT = 0; + USBD->DMACTL = 0x80; + USBD->DMACTL = 0x00; +} +/** + * @brief USBD_SetEpBufAddr, Set Endpoint buffer address + * @param[in] u32Ep Endpoint Number + * @param[in] u32Base Buffer Start Address + * @param[in] u32Len Buffer length + * @retval None. + */ +static __INLINE void USBD_SetEpBufAddr(uint32_t u32Ep, uint32_t u32Base, uint32_t u32Len) +{ + if (u32Ep == CEP) { + USBD->CEPBUFSTART = u32Base; + USBD->CEPBUFEND = u32Base + u32Len - 1; + } else { + USBD->EP[u32Ep].EPBUFSTART = u32Base; + USBD->EP[u32Ep].EPBUFEND = u32Base + u32Len - 1; + } +} + +/** + * @brief USBD_ConfigEp, Config Endpoint + * @param[in] u32Ep USB endpoint + * @param[in] u32EpNum Endpoint number + * @param[in] u32EpType Endpoint type + * @param[in] u32EpDir Endpoint direction + * @retval None. + */ +static __INLINE void USBD_ConfigEp(uint32_t u32Ep, uint32_t u32EpNum, uint32_t u32EpType, uint32_t u32EpDir) +{ + if (u32EpType == USB_EP_CFG_TYPE_BULK) + USBD->EP[u32Ep].EPRSPCTL = (USB_EP_RSPCTL_FLUSH|USB_EP_RSPCTL_MODE_AUTO); + else if (u32EpType == USB_EP_CFG_TYPE_INT) + USBD->EP[u32Ep].EPRSPCTL = (USB_EP_RSPCTL_FLUSH|USB_EP_RSPCTL_MODE_MANUAL); + else if (u32EpType == USB_EP_CFG_TYPE_ISO) + USBD->EP[u32Ep].EPRSPCTL = (USB_EP_RSPCTL_FLUSH|USB_EP_RSPCTL_MODE_FLY); + + USBD->EP[u32Ep].EPCFG = (u32EpType|u32EpDir|USB_EP_CFG_VALID|(u32EpNum << 4)); +} + +/** + * @brief Set USB endpoint stall state + * @param[in] u32Ep The USB endpoint ID. + * @return None + * @details Set USB endpoint stall state for the specified endpoint ID. Endpoint will respond STALL token automatically. + */ +static __INLINE void USBD_SetEpStall(uint32_t u32Ep) +{ + if (u32Ep == CEP) + USBD_SET_CEP_STATE(USB_CEPCTL_STALL); + else { + USBD->EP[u32Ep].EPRSPCTL = USBD->EP[u32Ep].EPRSPCTL & 0xf7 | USB_EP_RSPCTL_HALT; + } +} + +/** + * @brief Set USB endpoint stall state + * + * @param[in] u32EpNum USB endpoint + * @return None + * + * @details Set USB endpoint stall state, endpoint will return STALL token. + */ +static __INLINE void USBD_SetStall(uint32_t u32EpNum) +{ + int i; + + if (u32EpNum == 0) + USBD_SET_CEP_STATE(USB_CEPCTL_STALL); + else { + for (i=0; iEP[i].EPCFG & 0xf0) >> 4) == u32EpNum) + { + USBD->EP[i].EPRSPCTL = USBD->EP[i].EPRSPCTL & 0xf7 | USB_EP_RSPCTL_HALT; + } + } + } +} + +/** + * @brief Clear USB endpoint stall state + * @param[in] u32Ep The USB endpoint ID. + * @return None + * @details Clear USB endpoint stall state for the specified endpoint ID. Endpoint will respond ACK/NAK token. + */ +static __INLINE void USBD_ClearEpStall(uint32_t u32Ep) +{ + USBD->EP[u32Ep].EPRSPCTL = USB_EP_RSPCTL_TOGGLE; +} + +/** + * @brief Clear USB endpoint stall state + * + * @param[in] u32EpNum USB endpoint + * @return None + * + * @details Clear USB endpoint stall state, endpoint will return ACK/NAK token. + */ +static __INLINE void USBD_ClearStall(uint32_t u32EpNum) +{ + int i; + + for (i=0; iEP[i].EPCFG & 0xf0) >> 4) == u32EpNum) + { + USBD->EP[i].EPRSPCTL = USB_EP_RSPCTL_TOGGLE; + } + } +} + +/** + * @brief Get USB endpoint stall state + * @param[in] u32Ep The USB endpoint ID. + * @retval 0 USB endpoint is not stalled. + * @retval Others USB endpoint is stalled. + * @details Get USB endpoint stall state of the specified endpoint ID. + */ +static __INLINE uint32_t USBD_GetEpStall(uint32_t u32Ep) +{ + return (USBD->EP[u32Ep].EPRSPCTL & USB_EP_RSPCTL_HALT); +} + +/** + * @brief Get USB endpoint stall state + * + * @param[in] u32EpNum USB endpoint + * @retval 0: USB endpoint is not stalled. + * @retval non-0: USB endpoint is stalled. + * + * @details Get USB endpoint stall state. + */ +static __INLINE uint32_t USBD_GetStall(uint32_t u32EpNum) +{ + int i; + + for (i=0; iEP[i].EPCFG & 0xf0) >> 4) == u32EpNum) + { + return (USBD->EP[i].EPRSPCTL & USB_EP_RSPCTL_HALT); + } + } + return 0; +} + + +/*-------------------------------------------------------------------------------------------*/ +typedef void (*VENDOR_REQ)(void); /*!CTL = (WDT->CTL & ~(WDT_CTL_IF_Msk | WDT_CTL_WKF_Msk)) | WDT_CTL_RSTF_Msk) + +/** + * @brief This macro clear WDT time-out interrupt flag. + * @param None + * @return None + * \hideinitializer + */ +#define WDT_CLEAR_TIMEOUT_INT_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_RSTF_Msk | WDT_CTL_WKF_Msk)) | WDT_CTL_IF_Msk) + +/** + * @brief This macro clear WDT time-out wake-up system flag. + * @param None + * @return None + * \hideinitializer + */ +#define WDT_CLEAR_TIMEOUT_WAKEUP_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_RSTF_Msk | WDT_CTL_IF_Msk)) | WDT_CTL_WKF_Msk) + +/** + * @brief This macro indicate WDT time-out to reset system or not. + * @return WDT reset system or not + * @retval 0 WDT did not cause system reset + * @retval 1 WDT caused system reset + * \hideinitializer + */ +#define WDT_GET_RESET_FLAG() (WDT->CTL & WDT_CTL_RSTF_Msk ? 1 : 0) + +/** + * @brief This macro indicate WDT time-out interrupt occurred or not. + * @return WDT time-out interrupt occurred or not + * @retval 0 WDT time-out interrupt did not occur + * @retval 1 WDT time-out interrupt occurred + * \hideinitializer + */ +#define WDT_GET_TIMEOUT_INT_FLAG() (WDT->CTL & WDT_CTL_IF_Msk ? 1 : 0) + +/** + * @brief This macro indicate WDT time-out waked system up or not + * @return WDT time-out waked system up or not + * @retval 0 WDT did not wake up system + * @retval 1 WDT waked up system + * \hideinitializer + */ +#define WDT_GET_TIMEOUT_WAKEUP_FLAG() (WDT->CTL & WDT_CTL_WKF_Msk ? 1 : 0) + +/** + * @brief This macro is used to reset 18-bit WDT counter. + * @details If WDT is activated and enabled to reset system, software must reset WDT counter + * before WDT time-out plus reset delay reached. Or WDT generate a reset signal. + * \hideinitializer + */ +#define WDT_RESET_COUNTER() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_IF_Msk | WDT_CTL_WKF_Msk | WDT_CTL_RSTF_Msk)) | WDT_CTL_RSTCNT_Msk) + +/** + * @brief This function stops WDT counting and disable WDT module + * @param None + * @return None + */ +__STATIC_INLINE void WDT_Close(void) +{ + WDT->CTL = 0; + return; +} + +/** + * @brief This function enables the WDT time-out interrupt + * @param None + * @return None + */ +__STATIC_INLINE void WDT_EnableInt(void) +{ + WDT->CTL |= WDT_CTL_INTEN_Msk; + return; +} + +/** + * @brief This function disables the WDT time-out interrupt + * @param None + * @return None + */ +__STATIC_INLINE void WDT_DisableInt(void) +{ + // Do not touch write 1 clear bits + WDT->CTL &= ~(WDT_CTL_INTEN_Msk | WDT_CTL_RSTF_Msk | WDT_CTL_IF_Msk) ; + return; +} + +void WDT_Open(uint32_t u32TimeoutInterval, + uint32_t u32ResetDelay, + uint32_t u32EnableReset, + uint32_t u32EnableWakeup); + +/*@}*/ /* end of group NUC472_442_WDT_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_WDT_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__WDT_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/wwdt.h b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/wwdt.h new file mode 100644 index 0000000000000000000000000000000000000000..cf3e543521ab5f96d534221ba79857ac5dcb4169 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/inc/wwdt.h @@ -0,0 +1,125 @@ +/**************************************************************************//** + * @file wwdt.h + * @version V1.00 + * $Revision: 9 $ + * $Date: 14/05/29 1:13p $ + * @brief NUC472/NUC442 WWDT driver header file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. + *****************************************************************************/ +#ifndef __WWDT_H__ +#define __WWDT_H__ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_WWDT_Driver WWDT Driver + @{ +*/ + +/** @addtogroup NUC472_442_WWDT_EXPORTED_CONSTANTS WWDT Exported Constants + @{ +*/ +#define WWDT_PRESCALER_1 (0UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 1 \hideinitializer +#define WWDT_PRESCALER_2 (1UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 2 \hideinitializer +#define WWDT_PRESCALER_4 (2UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 4 \hideinitializer +#define WWDT_PRESCALER_8 (3UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 8 \hideinitializer +#define WWDT_PRESCALER_16 (4UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 16 \hideinitializer +#define WWDT_PRESCALER_32 (5UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 32 \hideinitializer +#define WWDT_PRESCALER_64 (6UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 64 \hideinitializer +#define WWDT_PRESCALER_128 (7UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 128 \hideinitializer +#define WWDT_PRESCALER_192 (8UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 192 \hideinitializer +#define WWDT_PRESCALER_256 (9UL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 256 \hideinitializer +#define WWDT_PRESCALER_384 (0xAUL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 384 \hideinitializer +#define WWDT_PRESCALER_512 (0xBUL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 512 \hideinitializer +#define WWDT_PRESCALER_768 (0xCUL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 768 \hideinitializer +#define WWDT_PRESCALER_1024 (0xDUL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 1024 \hideinitializer +#define WWDT_PRESCALER_1536 (0xEUL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 1536 \hideinitializer +#define WWDT_PRESCALER_2048 (0xFUL << WWDT_CTL_PSCSEL_Pos) ///< WWDT setting prescaler to 2048 \hideinitializer + +#define WWDT_RELOAD_WORD (0x00005AA5) ///< Fill this value to RLD register to reload WWDT counter \hideinitializer +/*@}*/ /* end of group NUC472_442_WWDT_EXPORTED_CONSTANTS */ + + +/** @addtogroup NUC472_442_WWDT_EXPORTED_FUNCTIONS WWDT Exported Functions + @{ +*/ + +/** + * @brief This macro clear WWDT time-out reset system flag. + * @param None + * @return None + * \hideinitializer + */ +#define WWDT_CLEAR_RESET_FLAG() (WWDT->STATUS = WWDT_STATUS_WWDTRF_Msk) + +/** + * @brief This macro clear WWDT compare match interrupt flag. + * @param None + * @return None + * \hideinitializer + */ +#define WWDT_CLEAR_INT_FLAG() (WWDT->STATUS = WWDT_STATUS_WWDTIF_Msk) + +/** + * @brief This macro is use to get WWDT time-out reset system flag. + * @return WWDT reset system or not + * @retval 0 WWDT did not cause system reset + * @retval 1 WWDT caused system reset + * \hideinitializer + */ +#define WWDT_GET_RESET_FLAG() (WWDT->STATUS & WWDT_STATUS_WWDTRF_Msk ? 1 : 0) + +/** + * @brief This macro is used to indicate WWDT compare match interrupt flag. + * @return WWDT compare match interrupt occurred or not + * @retval 0 WWDT compare match interrupt did not occur + * @retval 1 WWDT compare match interrupt occurred + * \hideinitializer + */ +#define WWDT_GET_INT_FLAG() (WWDT->STATUS & WWDT_STATUS_WWDTIF_Msk ? 1 : 0) + +/** + * @brief This macro to reflects current WWDT counter value + * @param None + * @return Return current WWDT counter value + * \hideinitializer + */ +#define WWDT_GET_COUNTER() (WWDT->CNT) + +/** + * @brief This macro is used to reload the WWDT counter value to 0x3F. + * @param None + * @return None + * @details After WWDT enabled, application must reload WWDT counter while + * current counter is less than compare value and larger than 0, + * otherwise WWDT will cause system reset. + * \hideinitializer + */ +#define WWDT_RELOAD_COUNTER() (WWDT->RLDCNT = WWDT_RELOAD_WORD) + + +void WWDT_Open(uint32_t u32PreScale, uint32_t u32CmpValue, uint32_t u32EnableInt); + + +/*@}*/ /* end of group NUC472_442_WWDT_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_WWDT_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +#endif //__WWDT_H__ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/acmp.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/acmp.c new file mode 100644 index 0000000000000000000000000000000000000000..8736e1959581e498e6e27cf9b1000484fc0ed18e --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/acmp.c @@ -0,0 +1,113 @@ +/**************************************************************************//** + * @file acmp.c + * @version V1.00 + * $Revision: 4 $ + * $Date: 15/11/04 7:32p $ + * @brief NUC472/NUC442 Analog Comparator(ACMP) driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include "NUC472_442.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_ACMP_Driver ACMP Driver + @{ +*/ + + +/** @addtogroup NUC472_442_ACMP_EXPORTED_FUNCTIONS ACMP Exported Functions + @{ +*/ + + +/** + * @brief Configure the specified ACMP module + * + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum comparator number, could be 0, 1, 2 + * @param[in] u32NegSrc is comparator negative input selection. Including: + * - \ref ACMP_VNEG_PIN + * - \ref ACMP_VNEG_BANDGAP + * - \ref ACMP_VNEG_4_OVER_24_VDD + * - \ref ACMP_VNEG_5_OVER_24_VDD + * - \ref ACMP_VNEG_6_OVER_24_VDD + * - \ref ACMP_VNEG_7_OVER_24_VDD + * - \ref ACMP_VNEG_8_OVER_24_VDD + * - \ref ACMP_VNEG_9_OVER_24_VDD + * - \ref ACMP_VNEG_10_OVER_24_VDD + * - \ref ACMP_VNEG_11_OVER_24_VDD + * - \ref ACMP_VNEG_12_OVER_24_VDD + * - \ref ACMP_VNEG_13_OVER_24_VDD + * - \ref ACMP_VNEG_14_OVER_24_VDD + * - \ref ACMP_VNEG_15_OVER_24_VDD + * - \ref ACMP_VNEG_16_OVER_24_VDD + * - \ref ACMP_VNEG_17_OVER_24_VDD + * - \ref ACMP_VNEG_18_OVER_24_VDD + * - \ref ACMP_VNEG_19_OVER_24_VDD + * - \ref ACMP_VNEG_4_OVER_24_IREF + * - \ref ACMP_VNEG_5_OVER_24_IREF + * - \ref ACMP_VNEG_6_OVER_24_IREF + * - \ref ACMP_VNEG_7_OVER_24_IREF + * - \ref ACMP_VNEG_8_OVER_24_IREF + * - \ref ACMP_VNEG_9_OVER_24_IREF + * - \ref ACMP_VNEG_10_OVER_24_IREF + * - \ref ACMP_VNEG_11_OVER_24_IREF + * - \ref ACMP_VNEG_12_OVER_24_IREF + * - \ref ACMP_VNEG_13_OVER_24_IREF + * - \ref ACMP_VNEG_14_OVER_24_IREF + * - \ref ACMP_VNEG_15_OVER_24_IREF + * - \ref ACMP_VNEG_16_OVER_24_IREF + * - \ref ACMP_VNEG_17_OVER_24_IREF + * - \ref ACMP_VNEG_18_OVER_24_IREF + * - \ref ACMP_VNEG_19_OVER_24_IREF + * + * @param[in] u32HysteresisEn is the hysteresis function option. Including: + * - \ref ACMP_HYSTERESIS_ENABLE + * - \ref ACMP_HYSTERESIS_DISABLE + * @return None + */ +void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn) +{ + if((u32NegSrc != ACMP_VNEG_PIN) && (u32NegSrc != ACMP_VNEG_BANDGAP)) + ACMP->VREF = u32NegSrc | ACMP_VREF_IREFSEL_Msk; + ACMP->CTL[u32ChNum] = (ACMP->CTL[u32ChNum] & (~(ACMP_CTL_NEGSEL_Msk | ACMP_CTL_HYSEN_Msk))) | + ((u32NegSrc != ACMP_VNEG_PIN ? ACMP_CTL_NEGSEL_Msk : 0) | u32HysteresisEn | ACMP_CTL_ACMPEN_Msk); +} + +/** + * @brief This function close comparator + * + * @param[in] acmp The base address of ACMP module + * @param[in] u32ChNum comparator number. + * + * @return None + */ +void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum) +{ + ACMP->CTL[u32ChNum] &= (~ACMP_CTL_ACMPEN_Msk); +} + + + +/*@}*/ /* end of group NUC472_442_ACMP_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_ACMP_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +#ifdef __cplusplus +} +#endif + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/adc.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/adc.c new file mode 100644 index 0000000000000000000000000000000000000000..8c57095d3a77215d5da188df270dc0f569fe7079 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/adc.c @@ -0,0 +1,176 @@ +/**************************************************************************//** + * @file adc.c + * @version V1.00 + * $Revision: 13 $ + * $Date: 14/05/29 1:13p $ + * @brief NUC472/NUC442 ADC driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_ADC_Driver ADC Driver + @{ +*/ + + +/** @addtogroup NUC472_442_ADC_EXPORTED_FUNCTIONS ADC Exported Functions + @{ +*/ + +/** + * @brief This API configures ADC module to be ready for convert the input from selected channel + * @param[in] adc Base address of ADC module + * @param[in] u32InputMode Input mode (single-end/differential). Valid values are: + * - \ref ADC_INPUT_MODE_SINGLE_END + * - \ref ADC_INPUT_MODE_DIFFERENTIAL + * @param[in] u32OpMode Operation mode (single/single cycle/continuous). Valid values are: + * - \ref ADC_OPERATION_MODE_SINGLE + * - \ref ADC_OPERATION_MODE_SINGLE_CYCLE + * - \ref ADC_OPERATION_MODE_CONTINUOUS + * @param[in] u32ChMask Channel enable bit. Valid values are: + * - \ref ADC_CH_0_MASK + * - \ref ADC_CH_1_MASK + * - \ref ADC_CH_2_MASK + * - \ref ADC_CH_3_MASK + * - \ref ADC_CH_4_MASK + * - \ref ADC_CH_5_MASK + * - \ref ADC_CH_6_MASK + * - \ref ADC_CH_7_MASK + * - \ref ADC_CH_8_MASK + * - \ref ADC_CH_9_MASK + * - \ref ADC_CH_10_MASK + * - \ref ADC_CH_11_MASK + * - \ref ADC_CH_TS_MASK + * - \ref ADC_CH_BG_MASK + * @return None + * @note This API does not turn on ADC power nor does trigger ADC conversion + */ +void ADC_Open(ADC_T *adc, + uint32_t u32InputMode, + uint32_t u32OpMode, + uint32_t u32ChMask) +{ + + ADC->CTL |= u32InputMode; + ADC->CTL |= u32OpMode; + ADC->CHEN = (ADC->CHEN & ~(ADC_CHEN_CHEN_Msk | ADC_CHEN_ADBGEN_Msk | ADC_CHEN_ADTSEN_Msk)) | u32ChMask; + return; +} + +/** + * @brief Disable ADC module + * @param[in] adc Base address of ADC module + * @return None + */ +void ADC_Close(ADC_T *adc) +{ + SYS->IPRST1 |= SYS_IPRST1_ADCRST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_ADCRST_Msk; + return; + +} + +/** + * @brief Configure the hardware trigger condition and enable hardware trigger + * @param[in] adc Base address of ADC module + * @param[in] u32Source Decides the hardware trigger source. Valid values are: + * - \ref ADC_TRIGGER_BY_EXT_PIN + * - \ref ADC_TRIGGER_BY_PWM + * @param[in] u32Param While ADC trigger by PWM, this parameter is used to set the delay between PWM + * trigger and ADC conversion. Valid values are from 0 ~ 0xFF, and actual delay + * time is (4 * u32Param * HCLK). While ADC trigger by external pin, this parameter + * is used to set trigger condition. Valid values are: + * - \ref ADC_LOW_LEVEL_TRIGGER + * - \ref ADC_HIGH_LEVEL_TRIGGER + * - \ref ADC_FALLING_EDGE_TRIGGER + * - \ref ADC_RISING_EDGE_TRIGGER + * @return None + */ +void ADC_EnableHWTrigger(ADC_T *adc, + uint32_t u32Source, + uint32_t u32Param) +{ + ADC->CTL &= ~(ADC_TRIGGER_BY_PWM | ADC_RISING_EDGE_TRIGGER | ADC_CTL_HWTRGEN_Msk); + if(u32Source == ADC_TRIGGER_BY_EXT_PIN) { + ADC->CTL &= ~(ADC_CTL_HWTRGSEL_Msk | ADC_CTL_HWTRGCOND_Msk); + ADC->CTL |= u32Source | u32Param | ADC_CTL_HWTRGEN_Msk; + } else { + ADC->CTL &= ~(ADC_CTL_HWTRGSEL_Msk | ADC_CTL_PWMTRGDLY_Msk); + ADC->CTL |= u32Source | (u32Param << ADC_CTL_PWMTRGDLY_Pos) | ADC_CTL_HWTRGEN_Msk; + } + + return; +} + +/** + * @brief Disable hardware trigger ADC function. + * @param[in] adc Base address of ADC module + * @return None + */ +void ADC_DisableHWTrigger(ADC_T *adc) +{ + ADC->CTL &= ~(ADC_TRIGGER_BY_PWM | ADC_RISING_EDGE_TRIGGER | ADC_CTL_HWTRGEN_Msk); + return; +} + +/** + * @brief Enable the interrupt(s) selected by u32Mask parameter. + * @param[in] adc Base address of ADC module + * @param[in] u32Mask The combination of interrupt status bits listed below. Each bit + * corresponds to a interrupt status. This parameter decides which + * interrupts will be enabled. + * - \ref ADC_ADF_INT + * - \ref ADC_CMP0_INT + * - \ref ADC_CMP1_INT + * @return None + */ +void ADC_EnableInt(ADC_T *adc, uint32_t u32Mask) +{ + if(u32Mask & ADC_ADF_INT) + ADC->CTL |= ADC_CTL_ADCIEN_Msk; + if(u32Mask & ADC_CMP0_INT) + ADC->CMP[0] |= ADC_CMP0_ADCMPIE_Msk; + if(u32Mask & ADC_CMP1_INT) + ADC->CMP[1] |= ADC_CMP1_ADCMPIE_Msk; + + return; +} + +/** + * @brief Disable the interrupt(s) selected by u32Mask parameter. + * @param[in] adc Base address of ADC module + * @param[in] u32Mask The combination of interrupt status bits listed below. Each bit + * corresponds to a interrupt status. This parameter decides which + * interrupts will be disabled. + * - \ref ADC_ADF_INT + * - \ref ADC_CMP0_INT + * - \ref ADC_CMP1_INT + * @return None + */ +void ADC_DisableInt(ADC_T *adc, uint32_t u32Mask) +{ + if(u32Mask & ADC_ADF_INT) + ADC->CTL &= ~ADC_CTL_ADCIEN_Msk; + if(u32Mask & ADC_CMP0_INT) + ADC->CMP[0] &= ~ADC_CMP0_ADCMPIE_Msk; + if(u32Mask & ADC_CMP1_INT) + ADC->CMP[1] &= ~ADC_CMP1_ADCMPIE_Msk; + + return; +} + + + +/*@}*/ /* end of group NUC472_442_ADC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_ADC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/can.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/can.c new file mode 100644 index 0000000000000000000000000000000000000000..2c004dd0473779f23282e9504d22cea28fca0e34 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/can.c @@ -0,0 +1,807 @@ +/**************************************************************************//** + * @file CAN.c + * @version V1.00 + * $Revision: 15 $ + * $Date: 15/11/26 10:40a $ + * @brief NUC472/NUC442 CAN driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include "NUC472_442.h" +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CAN_Driver CAN Driver + @{ +*/ + + +/** @addtogroup NUC472_442_CAN_EXPORTED_FUNCTIONS CAN Exported Functions + @{ +*/ + +#include + + +/// @cond HIDDEN_SYMBOLS + +#define TSEG1_MIN 2 +#define TSEG1_MAX 16 +#define TSEG2_MIN 1 +#define TSEG2_MAX 8 +#define BRP_MIN 1 +#define BRP_MAX 1024 /* 6-bit BRP field + 4-bit BRPE field*/ +#define SJW_MAX 4 +#define BRP_INC 1 + +static uint32_t GetFreeIF(CAN_T *tCAN); + + +//#define DEBUG_PRINTF printf +#define DEBUG_PRINTF(...) + +/** + * @brief Check if SmartCard slot is presented. + * @param[in] tCAN The base address of can module. + * @retval 0 IF0 is free + * @retval 1 IF1 is free + * @retval 2 No IF is free + * @details Search the first free message interface, starting from 0. + */ +static uint32_t GetFreeIF(CAN_T *tCAN) +{ + if((tCAN->IF[0].CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) + return 0; + else if((tCAN->IF[1].CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) + return 1; + else + return 2; +} + +/** + * @brief Enter initialization mode + * @param[in] tCAN The base address of can module. + * @return None + * @details This function is used to set CAN to enter initialization mode and enable access bit timing + * register. After bit timing configuration ready, user must call CAN_LeaveInitMode() + * to leave initialization mode and lock bit timing register to let new configuration + * take effect. + */ +void CAN_EnterInitMode(CAN_T *tCAN) +{ + tCAN->CON |= CAN_CON_INIT_Msk; + tCAN->CON |= CAN_CON_CCE_Msk; +} + + +/** + * @brief Leave initialization mode + * @param[in] tCAN The base address of can module. + * @return None + * @details This function is used to set CAN to leave initialization mode to let + * bit timing configuration take effect after configuration ready. + */ +void CAN_LeaveInitMode(CAN_T *tCAN) +{ + tCAN->CON &= (~(CAN_CON_INIT_Msk | CAN_CON_CCE_Msk)); + + while(tCAN->CON & CAN_CON_INIT_Msk); /* Check INIT bit is released */ +} + +/** + * @brief Wait message into message buffer in basic mode. + * @param[in] tCAN The base address of can module. + * @return None + * @details This function is used to wait message into message buffer in basic mode. Please notice the + * function is polling NEWDAT bit of MCON register by while loop and it is used in basic mode. + */ +void CAN_WaitMsg(CAN_T *tCAN) +{ + tCAN->STATUS = 0x0; /* clr status */ + + while (1) { + if(tCAN->IF[1].MCON & CAN_IF_MCON_NEWDAT_Msk) { /* check new data */ + DEBUG_PRINTF("New Data IN\n"); + break; + } + if(tCAN->STATUS & CAN_STATUS_RXOK_Msk) + DEBUG_PRINTF("Rx OK\n"); + + if(tCAN->STATUS & CAN_STATUS_LEC_Msk) { + DEBUG_PRINTF("Error\n"); + } + } +} + +/** + * @brief Get current bit rate + * @param[in] tCAN The base address of can module. + * @return Current Bit-Rate (kilo bit per second) + * @details Return current CAN bit rate according to the user bit-timing parameter settings + */ +uint32_t CAN_GetCANBitRate(CAN_T *tCAN) +{ + uint8_t u8Tseg1,u8Tseg2; + uint32_t u32Bpr; + + u8Tseg1 = (tCAN->BTIME & CAN_BTIME_TSEG1_Msk) >> CAN_BTIME_TSEG1_Pos; + u8Tseg2 = (tCAN->BTIME & CAN_BTIME_TSEG2_Msk) >> CAN_BTIME_TSEG2_Pos; + u32Bpr = (tCAN->BTIME & CAN_BTIME_BRP_Msk) | (tCAN->BRPE << 6); + + return (SystemCoreClock/(u32Bpr+1)/(u8Tseg1 + u8Tseg2 + 3)); +} + +/** + * @brief Switch the CAN into test mode. + * @param[in] tCAN The base address of can module. + * @param[in] u8TestMask Specifies the configuration in test modes + * CAN_TEST_BASIC_Msk : Enable basic mode of test mode + * CAN_TESTR_SILENT_Msk : Enable silent mode of test mode + * CAN_TESTR_LBACK_Msk : Enable Loop Back Mode of test mode + * CAN_TESTR_TX0_Msk/CAN_TESTR_TX1_Msk: Control CAN_TX pin bit field + * @return None + * @details Switch the CAN into test mode. There are four test mode (BASIC/SILENT/LOOPBACK/ + * LOOPBACK combined SILENT/CONTROL_TX_PIN)could be selected. After setting test mode,user + * must call CAN_LeaveInitMode() to let the setting take effect. + */ +void CAN_EnterTestMode(CAN_T *tCAN, uint8_t u8TestMask) +{ + tCAN->CON |= CAN_CON_TEST_Msk; + tCAN->TEST = u8TestMask; +} + + +/** + * @brief Leave the test mode + * @param[in] tCAN The base address of can module. + * @return None + * @details This function is used to Leave the test mode (switch into normal mode). + */ +void CAN_LeaveTestMode(CAN_T *tCAN) +{ + tCAN->CON |= CAN_CON_TEST_Msk; + tCAN->TEST &= ~(CAN_TEST_LBACK_Msk | CAN_TEST_SILENT_Msk | CAN_TEST_BASIC_Msk); + tCAN->CON &= (~CAN_CON_TEST_Msk); +} + +/** + * @brief Get the waiting status of a received message. + * @param[in] tCAN The base address of can module. + * @param[in] u8MsgObj Specifies the Message object number, from 0 to 31. + * @retval non-zero The corresponding message object has a new data bit is set. + * @retval 0 No message object has new data. + * @details This function is used to get the waiting status of a received message. + */ +uint32_t CAN_IsNewDataReceived(CAN_T *tCAN, uint8_t u8MsgObj) +{ + return (u8MsgObj < 16 ? tCAN->NDAT1 & (1 << u8MsgObj) : tCAN->NDAT2 & (1 << (u8MsgObj-16))); +} + + +/** + * @brief Send CAN message in BASIC mode of test mode + * @param[in] tCAN The base address of can module. + * @param[in] pCanMsg Pointer to the message structure containing data to transmit. + * @return TRUE: Transmission OK + * FALSE: Check busy flag of interface 0 is timeout + * @details The function is used to send CAN message in BASIC mode of test mode. Before call the API, + * the user should be call CAN_EnterTestMode(CAN_TESTR_BASIC) and let CAN controller enter + * basic mode of test mode. Please notice IF1 Registers used as Tx Buffer in basic mode. + */ +int32_t CAN_BasicSendMsg(CAN_T *tCAN, STR_CANMSG_T* pCanMsg) +{ + uint32_t i=0; + while(tCAN->IF[0].CREQ & CAN_IF_CREQ_BUSY_Msk); + + tCAN->STATUS &= (~CAN_STATUS_TXOK_Msk); + + tCAN->IF[0].CMASK = CAN_IF_CMASK_WRRD_Msk; + + if (pCanMsg->IdType == CAN_STD_ID) { + /* standard ID*/ + tCAN->IF[0].ARB1 = 0; + tCAN->IF[0].ARB2 = (((pCanMsg->Id)&0x7FF)<<2) ; + } else { + /* extended ID*/ + tCAN->IF[0].ARB1 = (pCanMsg->Id)&0xFFFF; + tCAN->IF[0].ARB2 = ((pCanMsg->Id)&0x1FFF0000)>>16 | CAN_IF_ARB2_XTD_Msk; + + } + + if(pCanMsg->FrameType) + tCAN->IF[0].ARB2 |= CAN_IF_ARB2_DIR_Msk; + else + tCAN->IF[0].ARB2 &= (~CAN_IF_ARB2_DIR_Msk); + + tCAN->IF[0].MCON = (tCAN->IF[0].MCON & (~CAN_IF_MCON_DLC_Msk)) | pCanMsg->DLC; + tCAN->IF[0].DAT_A1 = ((uint16_t)pCanMsg->Data[1]<<8) | pCanMsg->Data[0]; + tCAN->IF[0].DAT_A2 = ((uint16_t)pCanMsg->Data[3]<<8) | pCanMsg->Data[2]; + tCAN->IF[0].DAT_B1 = ((uint16_t)pCanMsg->Data[5]<<8) | pCanMsg->Data[4]; + tCAN->IF[0].DAT_B2 = ((uint16_t)pCanMsg->Data[7]<<8) | pCanMsg->Data[6]; + + /* request transmission*/ + tCAN->IF[0].CREQ &= (~CAN_IF_CREQ_BUSY_Msk); + if(tCAN->IF[0].CREQ & CAN_IF_CREQ_BUSY_Msk) { + DEBUG_PRINTF("Cannot clear busy for sending ...\n"); + return FALSE; + } + + tCAN->IF[0].CREQ |= CAN_IF_CREQ_BUSY_Msk; // sending + + for ( i=0; i<0xFFFFF; i++) { + if((tCAN->IF[0].CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) break; + } + + if ( i >= 0xFFFFF ) { + DEBUG_PRINTF("Cannot send out...\n"); + return FALSE; + } + + return TRUE; +} + + +/** + * @brief Get a message information in BASIC mode. + * + * @param[in] tCAN The base address of can module. + * @param[out] pCanMsg Pointer to the message structure where received data is copied. + * + * @return FALSE No any message received. \n + * TRUE Receive a message success. + * + */ +int32_t CAN_BasicReceiveMsg(CAN_T *tCAN, STR_CANMSG_T* pCanMsg) +{ + if((tCAN->IF[1].MCON & CAN_IF_MCON_NEWDAT_Msk) == 0) { /* In basic mode, receive data always save in IF2 */ + return FALSE; + } + + tCAN->STATUS &= (~CAN_STATUS_RXOK_Msk); + + tCAN->IF[1].CMASK = CAN_IF_CMASK_ARB_Msk + | CAN_IF_CMASK_CONTROL_Msk + | CAN_IF_CMASK_DATAA_Msk + | CAN_IF_CMASK_DATAB_Msk; + + if((tCAN->IF[1].ARB2 & CAN_IF_ARB2_XTD_Msk) == 0) { + /* standard ID*/ + pCanMsg->IdType = CAN_STD_ID; + pCanMsg->Id = (tCAN->IF[1].ARB2 >> 2) & 0x07FF; + + } else { + /* extended ID*/ + pCanMsg->IdType = CAN_EXT_ID; + pCanMsg->Id = (tCAN->IF[1].ARB2 & 0x1FFF)<<16; + pCanMsg->Id |= (uint32_t)tCAN->IF[1].ARB1; + } + + pCanMsg->FrameType = !((tCAN->IF[1].ARB2 & CAN_IF_ARB2_DIR_Msk) >> CAN_IF_ARB2_DIR_Pos); + + pCanMsg->DLC = tCAN->IF[1].MCON & CAN_IF_MCON_DLC_Msk; + pCanMsg->Data[0] = tCAN->IF[1].DAT_A1 & CAN_IF_DAT_A1_DATA0_Msk; + pCanMsg->Data[1] = (tCAN->IF[1].DAT_A1 & CAN_IF_DAT_A1_DATA1_Msk) >> CAN_IF_DAT_A1_DATA1_Pos; + pCanMsg->Data[2] = tCAN->IF[1].DAT_A2 & CAN_IF_DAT_A2_DATA2_Msk; + pCanMsg->Data[3] = (tCAN->IF[1].DAT_A2 & CAN_IF_DAT_A2_DATA3_Msk) >> CAN_IF_DAT_A2_DATA3_Pos; + pCanMsg->Data[4] = tCAN->IF[1].DAT_B1 & CAN_IF_DAT_B1_DATA4_Msk; + pCanMsg->Data[5] = (tCAN->IF[1].DAT_B1 & CAN_IF_DAT_B1_DATA5_Msk) >> CAN_IF_DAT_B1_DATA5_Pos; + pCanMsg->Data[6] = tCAN->IF[1].DAT_B2 & CAN_IF_DAT_B2_DATA6_Msk; + pCanMsg->Data[7] = (tCAN->IF[1].DAT_B2 & CAN_IF_DAT_B2_DATA7_Msk) >> CAN_IF_DAT_B2_DATA7_Pos; + + return TRUE; +} + +/** + * @brief Set Rx message object + * @param[in] tCAN The base address of can module. + * @param[in] u8MsgObj Specifies the Message object number, from 0 to 31. + * @param[in] u8idType Specifies the identifier type of the frames that will be transmitted + * This parameter can be one of the following values: + * CAN_STD_ID (standard ID, 11-bit) + * CAN_EXT_ID (extended ID, 29-bit) + * @param[in] u32id Specifies the identifier used for acceptance filtering. + * @param[in] u8singleOrFifoLast Specifies the end-of-buffer indicator. + * This parameter can be one of the following values: + * TRUE: for a single receive object or a FIFO receive object that is the last one of the FIFO. + * FALSE: for a FIFO receive object that is not the last one. + * @retval TRUE SUCCESS + * @retval FALSE No useful interface + * @details The function is used to configure a receive message object. + */ +int32_t CAN_SetRxMsgObj(CAN_T *tCAN, uint8_t u8MsgObj, uint8_t u8idType, uint32_t u32id, uint8_t u8singleOrFifoLast) +{ + uint8_t u8MsgIfNum=0; + + if ((u8MsgIfNum = GetFreeIF(tCAN)) == 2) { /* Check Free Interface for configure */ + return FALSE; + } + /* Command Setting */ + tCAN->IF[u8MsgIfNum].CMASK = CAN_IF_CMASK_WRRD_Msk | CAN_IF_CMASK_MASK_Msk | CAN_IF_CMASK_ARB_Msk | + CAN_IF_CMASK_CONTROL_Msk | CAN_IF_CMASK_DATAA_Msk | CAN_IF_CMASK_DATAB_Msk; + + if (u8idType == CAN_STD_ID) { /* According STD/EXT ID format,Configure Mask and Arbitration register */ + tCAN->IF[u8MsgIfNum].ARB1 = 0; + tCAN->IF[u8MsgIfNum].ARB2 = CAN_IF_ARB2_MSGVAL_Msk | (u32id & 0x7FF)<< 2; + } else { + tCAN->IF[u8MsgIfNum].ARB1 = u32id & 0xFFFF; + tCAN->IF[u8MsgIfNum].ARB2 = CAN_IF_ARB2_MSGVAL_Msk | CAN_IF_ARB2_XTD_Msk | (u32id & 0x1FFF0000)>>16; + } + + tCAN->IF[u8MsgIfNum].MCON |= CAN_IF_MCON_UMASK_Msk | CAN_IF_MCON_RXIE_Msk; + if(u8singleOrFifoLast) + tCAN->IF[u8MsgIfNum].MCON |= CAN_IF_MCON_EOB_Msk; + else + tCAN->IF[u8MsgIfNum].MCON &= (~CAN_IF_MCON_EOB_Msk); + + tCAN->IF[u8MsgIfNum].DAT_A1 = 0; + tCAN->IF[u8MsgIfNum].DAT_A2 = 0; + tCAN->IF[u8MsgIfNum].DAT_B1 = 0; + tCAN->IF[u8MsgIfNum].DAT_B2 = 0; + + tCAN->IF[u8MsgIfNum].CREQ = 1 + u8MsgObj; + + return TRUE; +} + + +/** + * @brief Gets the message + * @param[in] tCAN The base address of can module. + * @param[in] u8MsgObj Specifies the Message object number, from 0 to 31. + * @param[in] u8Release Specifies the message release indicator. + * This parameter can be one of the following values: + * TRUE: the message object is released when getting the data. + * FALSE:the message object is not released. + * @param[out] pCanMsg Pointer to the message structure where received data is copied. + * @retval TRUE Success + * @retval FALSE No any message received + * @details Gets the message, if received. + */ +int32_t CAN_ReadMsgObj(CAN_T *tCAN, uint8_t u8MsgObj, uint8_t u8Release, STR_CANMSG_T* pCanMsg) +{ + if (!CAN_IsNewDataReceived(tCAN, u8MsgObj)) { + return FALSE; + } + + tCAN->STATUS &= (~CAN_STATUS_RXOK_Msk); + + /* read the message contents*/ + tCAN->IF[1].CMASK = CAN_IF_CMASK_MASK_Msk + | CAN_IF_CMASK_ARB_Msk + | CAN_IF_CMASK_CONTROL_Msk + | CAN_IF_CMASK_CLRINTPND_Msk + | (u8Release ? CAN_IF_CMASK_TXRQSTNEWDAT_Msk : 0) + | CAN_IF_CMASK_DATAA_Msk + | CAN_IF_CMASK_DATAB_Msk; + + tCAN->IF[1].CREQ = 1 + u8MsgObj; + + while (tCAN->IF[1].CREQ & CAN_IF_CREQ_BUSY_Msk) { + /*Wait*/ + } + + if ((tCAN->IF[1].ARB2 & CAN_IF_ARB2_XTD_Msk) == 0) { + /* standard ID*/ + pCanMsg->IdType = CAN_STD_ID; + pCanMsg->Id = (tCAN->IF[1].ARB2 & CAN_IF_ARB2_ID_Msk) >> 2; + } else { + /* extended ID*/ + pCanMsg->IdType = CAN_EXT_ID; + pCanMsg->Id = (((tCAN->IF[1].ARB2) & 0x1FFF)<<16) | tCAN->IF[1].ARB1; + } + + pCanMsg->DLC = tCAN->IF[1].MCON & CAN_IF_MCON_DLC_Msk; + pCanMsg->Data[0] = tCAN->IF[1].DAT_A1 & CAN_IF_DAT_A1_DATA0_Msk; + pCanMsg->Data[1] = (tCAN->IF[1].DAT_A1 & CAN_IF_DAT_A1_DATA1_Msk) >> CAN_IF_DAT_A1_DATA1_Pos; + pCanMsg->Data[2] = tCAN->IF[1].DAT_A2 & CAN_IF_DAT_A2_DATA2_Msk; + pCanMsg->Data[3] = (tCAN->IF[1].DAT_A2 & CAN_IF_DAT_A2_DATA3_Msk) >> CAN_IF_DAT_A2_DATA3_Pos; + pCanMsg->Data[4] = tCAN->IF[1].DAT_B1 & CAN_IF_DAT_B1_DATA4_Msk; + pCanMsg->Data[5] = (tCAN->IF[1].DAT_B1 & CAN_IF_DAT_B1_DATA5_Msk) >> CAN_IF_DAT_B1_DATA5_Pos; + pCanMsg->Data[6] = tCAN->IF[1].DAT_B2 & CAN_IF_DAT_B2_DATA6_Msk; + pCanMsg->Data[7] = (tCAN->IF[1].DAT_B2 & CAN_IF_DAT_B2_DATA7_Msk) >> CAN_IF_DAT_B2_DATA7_Pos; + + return TRUE; +} + +static int can_update_spt(int sampl_pt, int tseg, int *tseg1, int *tseg2) +{ + *tseg2 = tseg + 1 - (sampl_pt * (tseg + 1)) / 1000; + if (*tseg2 < TSEG2_MIN) + *tseg2 = TSEG2_MIN; + if (*tseg2 > TSEG2_MAX) + *tseg2 = TSEG2_MAX; + *tseg1 = tseg - *tseg2; + if (*tseg1 > TSEG1_MAX) { + *tseg1 = TSEG1_MAX; + *tseg2 = tseg - *tseg1; + } + return 1000 * (tseg + 1 - *tseg2) / (tseg + 1); +} + +/// @endcond HIDDEN_SYMBOLS + + +/** + * @brief The function is used to set bus timing parameter according current clock and target baud-rate. + * + * @param[in] tCAN The base address of can module + * @param[in] u32BaudRate The target CAN baud-rate. The range of u32BaudRate is 1~1000KHz + * + * @return u32CurrentBitRate Real baud-rate value + */ +uint32_t CAN_SetBaudRate(CAN_T *tCAN, uint32_t u32BaudRate) +{ + long rate; + long best_error = 1000000000, error = 0; + int best_tseg = 0, best_brp = 0, brp = 0; + int tsegall, tseg = 0, tseg1 = 0, tseg2 = 0; + int spt_error = 1000, spt = 0, sampl_pt; + uint64_t clock_freq = 0; + uint32_t sjw = 1; + + CAN_EnterInitMode(tCAN); + + SystemCoreClockUpdate(); + + clock_freq = SystemCoreClock; + + if(u32BaudRate >= 1000000) + u32BaudRate = 1000000; + + /* Use CIA recommended sample points */ + if (u32BaudRate > 800000) + sampl_pt = 750; + else if (u32BaudRate > 500000) + sampl_pt = 800; + else + sampl_pt = 875; + + /* tseg even = round down, odd = round up */ + for (tseg = (TSEG1_MAX + TSEG2_MAX) * 2 + 1; tseg >= (TSEG1_MIN + TSEG2_MIN) * 2; tseg--) { + tsegall = 1 + tseg / 2; + /* Compute all possible tseg choices (tseg=tseg1+tseg2) */ + brp = clock_freq / (tsegall * u32BaudRate) + tseg % 2; + /* chose brp step which is possible in system */ + brp = (brp / BRP_INC) * BRP_INC; + + if ((brp < BRP_MIN) || (brp > BRP_MAX)) + continue; + rate = clock_freq / (brp * tsegall); + + error = u32BaudRate - rate; + + /* tseg brp biterror */ + if (error < 0) + error = -error; + if (error > best_error) + continue; + best_error = error; + if (error == 0) { + spt = can_update_spt(sampl_pt, tseg / 2, &tseg1, &tseg2); + error = sampl_pt - spt; + if (error < 0) + error = -error; + if (error > spt_error) + continue; + spt_error = error; + } + best_tseg = tseg / 2; + best_brp = brp; + + if (error == 0) + break; + } + + spt = can_update_spt(sampl_pt, best_tseg, &tseg1, &tseg2); + + /* check for sjw user settings */ + /* bt->sjw is at least 1 -> sanitize upper bound to sjw_max */ + if (sjw > SJW_MAX) + sjw = SJW_MAX; + /* bt->sjw must not be higher than tseg2 */ + if (tseg2 < sjw) + sjw = tseg2; + + /* real bit-rate */ + u32BaudRate = clock_freq / (best_brp * (tseg1 + tseg2 + 1)); + + tCAN->BTIME = ((uint32_t)(tseg2 - 1) << CAN_BTIME_TSEG2_Pos) | ((uint32_t)(tseg1 - 1) << CAN_BTIME_TSEG1_Pos) | + ((best_brp - 1) & CAN_BTIME_BRP_Msk) | (sjw << CAN_BTIME_SJW_Pos); + tCAN->BRPE = ((best_brp - 1) >> 6) & 0x0F; + + //printf("\n bitrate = %d \n", CAN_GetCANBitRate(tCAN)); + + CAN_LeaveInitMode(tCAN); + + return u32BaudRate; +} + +/** + * @brief The function is used to disable all CAN interrupt. + * + * @param[in] tCAN The base address of can module + * + * @return None + */ +void CAN_Close(CAN_T *tCAN) +{ + CAN_DisableInt(tCAN, (CAN_CON_IE_Msk|CAN_CON_SIE_Msk|CAN_CON_EIE_Msk)); +} + +/** + * @brief The function is sets bus timing parameter according current clock and target baud-rate. And set CAN operation mode. + * + * @param[in] tCAN The base address of can module + * @param[in] u32BaudRate The target CAN baud-rate. The range of u32BaudRate is 1~1000KHz + * @param[in] u32Mode The CAN operation mode. ( \ref CAN_NORMAL_MODE / \ref CAN_BASIC_MODE) + * + * @return u32CurrentBitRate Real baud-rate value + */ +uint32_t CAN_Open(CAN_T *tCAN, uint32_t u32BaudRate, uint32_t u32Mode) +{ + uint32_t u32CurrentBitRate; + + u32CurrentBitRate = CAN_SetBaudRate(tCAN, u32BaudRate); + + if(u32Mode == CAN_BASIC_MODE) + CAN_EnterTestMode(tCAN, CAN_TEST_BASIC_Msk); + else + tCAN->CON &= ~CAN_CON_TEST_Msk; + + return u32CurrentBitRate; +} + +/** + * @brief The function is used to configure a transmit object. + * + * @param[in] tCAN The base address of can module. + * @param[in] u32MsgNum Specifies the Message object number, from 0 to 31 + * @param[in] pCanMsg Pointer to the message structure where received data is copied. + * + * @return FALSE: No useful interface. \n + * TRUE : Config message object success. + * + */ +int32_t CAN_SetTxMsg(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg) +{ + uint8_t u8MsgIfNum=0; + uint32_t i=0; + + while((u8MsgIfNum = GetFreeIF(tCAN)) == 2) { + i++; + if(i > 0x10000000) + return FALSE; + } + + /* update the contents needed for transmission*/ + tCAN->IF[u8MsgIfNum].CMASK = 0xF3; /*CAN_CMASK_WRRD_Msk | CAN_CMASK_MASK_Msk | CAN_CMASK_ARB_Msk + | CAN_CMASK_CONTROL_Msk | CAN_CMASK_DATAA_Msk | CAN_CMASK_DATAB_Msk ; */ + + if (pCanMsg->IdType == CAN_STD_ID) { + /* standard ID*/ + tCAN->IF[u8MsgIfNum].ARB1 = 0; + tCAN->IF[u8MsgIfNum].ARB2 = (((pCanMsg->Id)&0x7FF)<<2) | CAN_IF_ARB2_DIR_Msk | CAN_IF_ARB2_MSGVAL_Msk; + } else { + /* extended ID*/ + tCAN->IF[u8MsgIfNum].ARB1 = (pCanMsg->Id)&0xFFFF; + tCAN->IF[u8MsgIfNum].ARB2 = ((pCanMsg->Id)&0x1FFF0000)>>16 | CAN_IF_ARB2_DIR_Msk + | CAN_IF_ARB2_XTD_Msk | CAN_IF_ARB2_MSGVAL_Msk; + } + + if(pCanMsg->FrameType) + tCAN->IF[u8MsgIfNum].ARB2 |= CAN_IF_ARB2_DIR_Msk; + else + tCAN->IF[u8MsgIfNum].ARB2 &= (~CAN_IF_ARB2_DIR_Msk); + + tCAN->IF[u8MsgIfNum].DAT_A1 = ((uint16_t)pCanMsg->Data[1]<<8) | pCanMsg->Data[0]; + tCAN->IF[u8MsgIfNum].DAT_A2 = ((uint16_t)pCanMsg->Data[3]<<8) | pCanMsg->Data[2]; + tCAN->IF[u8MsgIfNum].DAT_B1 = ((uint16_t)pCanMsg->Data[5]<<8) | pCanMsg->Data[4]; + tCAN->IF[u8MsgIfNum].DAT_B2 = ((uint16_t)pCanMsg->Data[7]<<8) | pCanMsg->Data[6]; + + tCAN->IF[u8MsgIfNum].MCON = CAN_IF_MCON_NEWDAT_Msk | pCanMsg->DLC |CAN_IF_MCON_TXIE_Msk | CAN_IF_MCON_EOB_Msk; + tCAN->IF[u8MsgIfNum].CREQ = 1 + u32MsgNum; + + return TRUE; +} + +/** + * @brief Set transmit request bit + * + * @param[in] tCAN The base address of can module. + * @param[in] u32MsgNum Specifies the Message object number, from 0 to 31. + * + * @return TRUE: Start transmit message. + */ +int32_t CAN_TriggerTxMsg(CAN_T *tCAN, uint32_t u32MsgNum) +{ + STR_CANMSG_T rMsg; + CAN_ReadMsgObj(tCAN, u32MsgNum,TRUE, &rMsg); + tCAN->IF[0].CMASK = CAN_IF_CMASK_WRRD_Msk |CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + tCAN->IF[0].CREQ = 1 + u32MsgNum; + + return TRUE; +} + +/** + * @brief Enable CAN interrupt + * + * @param[in] tCAN The base address of can module. + * @param[in] u32Mask Interrupt Mask. ( \ref CAN_CON_IE_Msk / \ref CAN_CON_SIE_Msk / \ref CAN_CON_EIE_Msk) + * + * @return None + */ +void CAN_EnableInt(CAN_T *tCAN, uint32_t u32Mask) +{ + CAN_EnterInitMode(tCAN); + + tCAN->CON = (tCAN->CON & ~(CAN_CON_IE_Msk | CAN_CON_SIE_Msk | CAN_CON_EIE_Msk)) | + (u32Mask & (CAN_CON_IE_Msk | CAN_CON_SIE_Msk | CAN_CON_EIE_Msk)); + + + CAN_LeaveInitMode(tCAN); +} + +/** + * @brief Disable CAN interrupt + * + * @param[in] tCAN The base address of can module. + * @param[in] u32Mask Interrupt Mask. ( \ref CAN_CON_IE_Msk / \ref CAN_CON_SIE_Msk / \ref CAN_CON_EIE_Msk) + * + * @return None + */ +void CAN_DisableInt(CAN_T *tCAN, uint32_t u32Mask) +{ + CAN_EnterInitMode(tCAN); + + tCAN->CON = tCAN->CON & ~((u32Mask & (CAN_CON_IE_Msk | CAN_CON_SIE_Msk | CAN_CON_EIE_Msk))); + + CAN_LeaveInitMode(tCAN); +} + + +/** + * @brief The function is used to configure a receive message object + * + * @param[in] tCAN The base address of can module. + * @param[in] u32MsgNum Specifies the Message object number, from 0 to 31 + * @param[in] u32IDType Specifies the identifier type of the frames that will be transmitted. ( \ref CAN_STD_ID / \ref CAN_EXT_ID) + * @param[in] u32ID Specifies the identifier used for acceptance filtering. + * + * @return FALSE: No useful interface \n + * TRUE : Configure a receive message object success. + * + */ +int32_t CAN_SetRxMsg(CAN_T *tCAN, uint32_t u32MsgNum , uint32_t u32IDType, uint32_t u32ID) +{ + uint32_t u32TimeOutCount = 0; + + while(CAN_SetRxMsgObj(tCAN, u32MsgNum, u32IDType, u32ID, TRUE) == FALSE) { + u32TimeOutCount++; + + if(u32TimeOutCount >= 0x10000000) return FALSE; + } + + return TRUE; +} + +/** + * @brief The function is used to configure several receive message objects + * + * @param[in] tCAN The base address of can module. + * @param[in] u32MsgNum The starting MSG RAM number. (0 ~ 31) + * @param[in] u32MsgCount the number of MSG RAM of the FIFO. + * @param[in] u32IDType Specifies the identifier type of the frames that will be transmitted. ( \ref CAN_STD_ID / \ref CAN_EXT_ID) + * @param[in] u32ID Specifies the identifier used for acceptance filtering. + * + * @return FALSE: No useful interface \n + * TRUE : Configure receive message objects success. + * + */ +int32_t CAN_SetMultiRxMsg(CAN_T *tCAN, uint32_t u32MsgNum , uint32_t u32MsgCount, uint32_t u32IDType, uint32_t u32ID) +{ + uint32_t i = 0; + uint32_t u32TimeOutCount; + uint32_t u32EOB_Flag = 0; + + for(i= 1; i < u32MsgCount; i++) { + u32TimeOutCount = 0; + + u32MsgNum += (i - 1); + + if(i == u32MsgCount) u32EOB_Flag = 1; + + while(CAN_SetRxMsgObj(tCAN, u32MsgNum, u32IDType, u32ID, u32EOB_Flag) == FALSE) { + u32TimeOutCount++; + + if(u32TimeOutCount >= 0x10000000) return FALSE; + } + } + + return TRUE; +} + + +/** + * @brief Send CAN message. + * @param[in] tCAN The base address of can module. + * @param[in] u32MsgNum Specifies the Message object number, from 0 to 31 + * @param[in] pCanMsg Pointer to the message structure where received data is copied. + * + * @return FALSE: When operation in basic mode: Transmit message time out, or when operation in normal mode: No useful interface. \n + * TRUE : Transmit Message success. + */ +int32_t CAN_Transmit(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg) +{ + if((tCAN->CON & CAN_CON_TEST_Msk) && (tCAN->TEST & CAN_TEST_BASIC_Msk)) { + return (CAN_BasicSendMsg(tCAN, pCanMsg)); + } else { + if(CAN_SetTxMsg(tCAN, u32MsgNum, pCanMsg) == FALSE) + return FALSE; + CAN_TriggerTxMsg(tCAN, u32MsgNum); + } + + return TRUE; +} + + +/** + * @brief Gets the message, if received. + * @param[in] tCAN The base address of can module. + * @param[in] u32MsgNum Specifies the Message object number, from 0 to 31 + * @param[out] pCanMsg Pointer to the message structure where received data is copied. + * + * @return FALSE: No any message received. \n + * TRUE : Receive Message success. + */ +int32_t CAN_Receive(CAN_T *tCAN, uint32_t u32MsgNum , STR_CANMSG_T* pCanMsg) +{ + if((tCAN->CON & CAN_CON_TEST_Msk) && (tCAN->TEST & CAN_TEST_BASIC_Msk)) { + return (CAN_BasicReceiveMsg(tCAN, pCanMsg)); + } else { + return CAN_ReadMsgObj(tCAN, u32MsgNum, TRUE, pCanMsg); + } +} + +/** + * @brief Clear interrupt pending bit. + * @param[in] tCAN The base address of can module. + * @param[in] u32MsgNum Specifies the Message object number, from 0 to 31 + * + * @return None + * + */ +void CAN_CLR_INT_PENDING_BIT(CAN_T *tCAN, uint8_t u32MsgNum) +{ + uint32_t u32MsgIfNum = 0; + uint32_t u32IFBusyCount = 0; + + while(u32IFBusyCount < 0x10000000) { + if((tCAN->IF[0].CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) { + u32MsgIfNum = 0; + break; + } else if((tCAN->IF[1].CREQ & CAN_IF_CREQ_BUSY_Msk) == 0) { + u32MsgIfNum = 1; + break; + } + + u32IFBusyCount++; + } + + tCAN->IF[u32MsgIfNum].CMASK = CAN_IF_CMASK_CLRINTPND_Msk | CAN_IF_CMASK_TXRQSTNEWDAT_Msk; + tCAN->IF[u32MsgIfNum].CREQ = 1 + u32MsgNum; + +} + + +/*@}*/ /* end of group NUC472_442_CAN_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CAN_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/cap.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/cap.c new file mode 100644 index 0000000000000000000000000000000000000000..17c5e9e8105a3296e8c02c0e91c8e1e1c35065df --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/cap.c @@ -0,0 +1,370 @@ +/**************************************************************************//** + * @file cap.c + * @version V0.10 + * $Revision: 18 $ + * $Date: 15/10/22 10:02a $ + * @brief NUC472/NUC442 CAP driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include "NUC472_442.h" +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CAP_Driver CAP Driver + @{ +*/ + + +/** @addtogroup NUC472_442_CAP_EXPORTED_FUNCTIONS CAP Exported Functions + @{ +*/ + +/** + * @brief Open engine clock and sensor clock + * + * @param[in] u32InFormat The bits corresponding VSP, HSP, PCLK, INFMT, SNRTYPE, OUTFMT, PDORD and PNFMT configurations. + * - VSP should be ether \ref CAP_PAR_VSP_LOW or \ref CAP_PAR_VSP_HIGH + * - HSP should be ether \ref CAP_PAR_HSP_LOW or \ref CAP_PAR_HSP_HIGH + * - PCLK should be ether \ref CAP_PAR_PCLKP_LOW or \ref CAP_PAR_PCLKP_HIGH + * - INFMT should be ether \ref CAP_PAR_INFMT_YUV422 or \ref CAP_PAR_INFMT_RGB565 + * - SNRTYPE should be ether \ref CAP_PAR_SENTYPE_CCIR601 or \ref CAP_PAR_SENTYPE_CCIR656 + * - OUTFMT should be one of the following setting + * - \ref CAP_PAR_OUTFMT_YUV422 + * - \ref CAP_PAR_OUTFMT_ONLY_Y + * - \ref CAP_PAR_OUTFMT_RGB555 + * - \ref CAP_PAR_OUTFMT_RGB565 + * - PDORD should be one of the following setting + * - \ref CAP_PAR_INDATORD_YUYV + * - \ref CAP_PAR_INDATORD_YVYU + * - \ref CAP_PAR_INDATORD_UYVY + * - \ref CAP_PAR_INDATORD_VYUY + * - \ref CAP_PAR_INDATORD_RGGB + * - \ref CAP_PAR_INDATORD_BGGR + * - \ref CAP_PAR_INDATORD_GBRG + * - \ref CAP_PAR_INDATORD_GRBG + * - PNFMT should be one of the following setting + * - \ref CAP_PAR_PLNFMT_YUV422 + * - \ref CAP_PAR_PLNFMT_YUV420 + * + * @param[in] u32OutFormet Capture output format, should be one of following setting + * - \ref CAP_CTL_PKTEN + * - \ref CAP_CTL_PLNEN + * + * @return None + * + * @details Initialize the Image Capture Interface. Register a call back for driver internal using + */ +void CAP_Open(uint32_t u32InFormat, uint32_t u32OutFormet) +{ + ICAP->PAR = (ICAP->PAR & ~0x000007BF) | u32InFormat; + ICAP->CTL = (ICAP->CTL & ~0x00000060) | u32OutFormet; +} + +/** + * @brief Set Cropping Window Starting Address and Size + * + * @param[in] u32VStart: Cropping Window Vertical Starting Address. It should be 0 ~ 0x7FF. + * + * @param[in] u32HStart: Cropping Window Horizontal Starting Address. It should be 0 ~ 0x7FF. + * + * @param[in] u32Height: Cropping Window Height . It should be 0 ~ 0x7FF. + * + * @param[in] u32Width: Cropping Window Width. It should be 0 ~ 0x7FF. + * + * @return None + * + * @details Set Cropping Window Starting Address Register + */ +void CAP_SetCroppingWindow(uint32_t u32VStart,uint32_t u32HStart, uint32_t u32Height, uint32_t u32Width) +{ + ICAP->CWSP = (ICAP->CWSP & ~(CAP_CWSP_CWSADDRV_Msk | CAP_CWSP_CWSADDRH_Msk)) + | (((u32VStart << 16) | u32HStart)); + + ICAP->CWS = (ICAP->CWS & ~(CAP_CWS_CWH_Msk | CAP_CWS_CWW_Msk)) + | ((u32Height << 16)| u32Width); +} + + +/** + * @brief Set System Memory Packet Base Address0 Register + * + * @param[in] u32Address : set PKTBA0 register, It should be 0x0 ~ 0xFFFFFFFF + * + * @return None + * + * @details Set System Memory Packet Base Address Register + */ +void CAP_SetPacketBuf(uint32_t u32Address ) +{ + ICAP->PKTBA0 = u32Address; + ICAP->CTL |= CAP_CTL_UPDATE_Msk; +} + +/** + * @brief Set System Memory Planar Y, U and V Base Address Registers. + * + * @param[in] u32YAddr : set YBA register, It should be 0x0 ~ 0xFFFFFFFF + * + * @param[in] u32UAddr : set UBA register, It should be 0x0 ~ 0xFFFFFFFF + * + * @param[in] u32VAddr : set VBA register, It should be 0x0 ~ 0xFFFFFFFF + * + * @return None + * + * @details Set System Memory Planar Y,U and V Base Address Registers + */ +void CAP_SetPlanarBuf(uint32_t u32YAddr, uint32_t u32UAddr, uint32_t u32VAddr) +{ + ICAP->YBA = u32YAddr; + ICAP->UBA = u32UAddr; + ICAP->VBA = u32VAddr; + ICAP->CTL |= CAP_CTL_UPDATE_Msk; +} + + +/** + * @brief Close Image Capture Interface + * + * @return None + */ +void CAP_Close(void) +{ + ICAP->CTL &= ~CAP_CTL_CAPEN; +} + + +/** + * @brief Set CAP Interrupt + * + * @param[in] u32IntMask Interrupt settings. It could be + * - \ref CAP_INT_VIEN_Msk + * - \ref CAP_INT_MEIEN_Msk + * - \ref CAP_INT_ADDRMIEN_Msk + * - \ref CAP_INT_MDIEN_Msk + * @return None + * + * @details Set Video Frame End Interrupt Enable, + * System Memory Error Interrupt Enable, + * Address Match Interrupt Enable, + * Motion Detection Output Finish Interrupt Enable. + */ +void CAP_EnableInt(uint32_t u32IntMask) +{ + ICAP->INT = (ICAP->INT & ~(CAP_INT_VIEN_Msk | CAP_INT_MEIEN_Msk | CAP_INT_ADDRMIEN_Msk | CAP_INT_MDIEN_Msk ) ) + | u32IntMask; +} + +/** + * @brief Disable CAP Interrupt + * + * @param[in] u32IntMask Interrupt settings. It could be + * - \ref CAP_INT_VINTF_Msk + * - \ref CAP_INT_MEINTF_Msk + * - \ref CAP_INT_ADDRMINTF_Msk + * - \ref CAP_INT_MDINTF_Msk + * @return None + * + * @details Disable Video Frame End Interrupt , + * System Memory Error Interrupt , + * Address Match Interrupt and + * Motion Detection Output Finish Interrupt . + */ +void CAP_DisableInt(uint32_t u32IntMask) +{ + ICAP->INT = (ICAP->INT & ~(u32IntMask) ) ; +} + +/** + * @brief Start Image Capture Interface + * + * @return None + */ +void CAP_Start(void) +{ + ICAP->CTL |= CAP_CTL_CAPEN; +} + +/** + * @brief Stop Image Capture Interface + * + * @param[in] u32FrameComplete : + * TRUE: Capture module automatically disable the CAP module after a frame had been captured + * FALSE: Stop Capture module now + * @return None + * + * @details if u32FrameComplete is set to TRUE then get a new frame and disable CAP module + */ +void CAP_Stop(uint32_t u32FrameComplete) +{ + if(u32FrameComplete==FALSE) + ICAP->CTL &= ~CAP_CTL_CAPEN; + else { + ICAP->CTL |= CAP_CTL_SHUTTER_Msk; + while(CAP_IS_STOPPED()); + } +} + +/** + * @brief Set Packet Scaling Vertical and Horizontal Factor Register + * + * @param[in] u32VNumerator: Packet Scaling Vertical Factor N. It should be 0 ~ FFFF. + * + * @param[in] u32VDenominator: Packet Scaling Vertical Factor M. It should be 0 ~ FFFF. + * + * @param[in] u32HNumerator: Packet Scaling Vertical Factor N. It should be 0 ~ FFFF. + * + * @param[in] u32HDenominator: Packet Scaling Vertical Factor M. It should be 0 ~ FFFF. + * + * @return None + * + */ +void CAP_SetPacketScaling(uint32_t u32VNumerator, uint32_t u32VDenominator, uint32_t u32HNumerator, uint32_t u32HDenominator) +{ + uint32_t u32NumeratorL, u32NumeratorH; + uint32_t u32DenominatorL, u32DenominatorH; + + u32NumeratorL = u32VNumerator&0xFF; + u32NumeratorH=u32VNumerator>>8; + u32DenominatorL = u32VDenominator&0xFF; + u32DenominatorH = u32VDenominator>>8; + ICAP->PKTSL = (ICAP->PKTSL & ~(CAP_PKTSL_PKTSVNL_Msk | CAP_PKTSL_PKTSVML_Msk)) + | ((u32NumeratorL << 24)| (u32DenominatorL << 16)); + ICAP->PKTSM = (ICAP->PKTSM & ~(CAP_PKTSM_PKTSVNH_Msk | CAP_PKTSM_PKTSVMH_Msk)) + | ((u32NumeratorH << 24) | (u32DenominatorH << 16)); + + u32NumeratorL = u32HNumerator&0xFF; + u32NumeratorH=u32HNumerator>>8; + u32DenominatorL = u32HDenominator&0xFF; + u32DenominatorH = u32HDenominator>>8; + ICAP->PKTSL = (ICAP->PKTSL & ~(CAP_PKTSL_PKTSHNL_Msk | CAP_PKTSL_PKTSHML_Msk)) + | ((u32NumeratorL << 8)| u32DenominatorL); + ICAP->PKTSM = (ICAP->PKTSM & ~(CAP_PKTSM_PKTSHNH_Msk | CAP_PKTSM_PKTSHMH_Msk)) + | ((u32NumeratorH << 8) | u32DenominatorH); +} + +/** + * @brief Set Planar Scaling Vertical and Horizontal Factor Register + * + * @param[in] u32VNumerator: Planar Scaling Vertical Factor N. It should be 0 ~ FFFF. + * + * @param[in] u32VDenominator: Planar Scaling Vertical Factor M. It should be 0 ~ FFFF. + * + * @param[in] u32HNumerator: Planar Scaling Vertical Factor N. It should be 0 ~ FFFF. + * + * @param[in] u32HDenominator: Planar Scaling Vertical Factor M. It should be 0 ~ FFFF. + * + * @return None + * + */ +void CAP_SetPlanarScaling(uint32_t u32VNumerator, uint32_t u32VDenominator, uint32_t u32HNumerator, uint32_t u32HDenominator) +{ + uint32_t u32NumeratorL, u32NumeratorH; + uint32_t u32DenominatorL, u32DenominatorH; + + u32NumeratorL = u32VNumerator&0xFF; + u32NumeratorH = u32VNumerator>>8; + u32DenominatorL = u32VDenominator&0xFF; + u32DenominatorH = u32VDenominator>>8; + ICAP->PLNSL = (ICAP->PLNSL & ~(CAP_PLNSL_PLNSVNL_Msk | CAP_PLNSL_PLNSVML_Msk)) + | ((u32NumeratorL << 24)| (u32DenominatorL << 16)); + ICAP->PLNSM = (ICAP->PLNSM & ~(CAP_PLNSM_PLNSVNH_Msk | CAP_PLNSM_PLNSVMH_Msk)) + | ((u32NumeratorH << 24)| (u32DenominatorH << 16)); + + u32NumeratorL = u32HNumerator&0xFF; + u32NumeratorH = u32HNumerator>>8; + u32DenominatorL = u32HDenominator&0xFF; + u32DenominatorH = u32HDenominator>>8; + ICAP->PLNSL = (ICAP->PLNSL & ~(CAP_PLNSL_PLNSHNL_Msk | CAP_PLNSL_PLNSHML_Msk)) + | ((u32NumeratorL << 8)| u32DenominatorL); + ICAP->PLNSM = (ICAP->PLNSM & ~(CAP_PLNSM_PLNSHNH_Msk | CAP_PLNSM_PLNSHMH_Msk)) + | ((u32NumeratorH << 8)| u32DenominatorH); +} + +/** + * @brief Set Packet Frame Output Pixel Stride Width. + * + * @param[in] u32Stride : set PKTSTRIDE register, It should be 0x0 ~ 0x3FFF + * + * @return None + * + * @details Set Packet Frame Output Pixel Stride Width + */ +void CAP_SetPacketStride(uint32_t u32Stride ) +{ + ICAP->STRIDE = (ICAP->STRIDE & ~CAP_STRIDE_PKTSTRIDE_Msk) | u32Stride; +} + +/** + * @brief Set Planar Frame Output Pixel Stride Width. + * + * @param[in] u32Stride : set PLNSTRIDE register, It should be 0x0 ~ 0x3FFF + * + * @return None + * + * @details Set Planar Frame Output Pixel Stride Width + */ +void CAP_SetPlanarStride(uint32_t u32Stride ) +{ + ICAP->STRIDE = (ICAP->STRIDE & ~CAP_STRIDE_PLNSTRIDE_Msk) | u32Stride<MD = (ICAP->MD & ~(CAP_MD_MDSM_Msk | CAP_MD_MDBS_Msk | CAP_MD_MDEN_Msk)) | + ((CAP_MD_MDEN_Msk | (u32BlockSize?CAP_MD_MDBS_Msk:0)) | + (u32Format?CAP_MD_MDSM_Msk:0)); + + ICAP->MD = (ICAP->MD & ~CAP_MD_MDDF_Msk) | (u32Freq<MD = (ICAP->MD & ~CAP_MD_MDTHR_Msk) | (u32Threshold<MDYADDR = u32YDetAddr; + ICAP->MDADDR = u32DetAddr; +} + +/** + * @brief Enable Motion Detection Function + * + * @return None + * + * @details Set Planar Frame Output Pixel Stride Width + */ +void CAP_DisableMotionDet(void) +{ + ICAP->MD &= ~CAP_MD_MDEN_Msk; +} + +/*@}*/ /* end of group NUC472_442_CAP_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CAP_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/clk.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/clk.c new file mode 100644 index 0000000000000000000000000000000000000000..2262de8dfa9cd25a87d36b72644bfec74adde3f3 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/clk.c @@ -0,0 +1,868 @@ +/**************************************************************************//** + * @file clk.c + * @version V1.00 + * $Revision: 35 $ + * $Date: 16/03/04 3:42p $ + * @brief NUC472/NUC442 CLK driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include "NUC472_442.h" +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CLK_Driver CLK Driver + @{ +*/ + + +/** @addtogroup NUC472_442_CLK_EXPORTED_FUNCTIONS CLK Exported Functions + @{ +*/ + + +/** + * @brief Disable frequency output function + * @return None + * @details This function disable frequency output function. + */ +void CLK_DisableCKO(void) +{ + /* Disable CKO clock source */ + CLK->APBCLK0 &= (~CLK_APBCLK0_CLKOCKEN_Msk); +} + +/** + * @brief This function enable frequency divider module clock, + * enable frequency divider clock function and configure frequency divider. + * @param[in] u32ClkSrc is frequency divider function clock source + * - \ref CLK_CLKSEL1_CLKOSEL_HXT + * - \ref CLK_CLKSEL1_CLKOSEL_LXT + * - \ref CLK_CLKSEL1_CLKOSEL_HCLK + * - \ref CLK_CLKSEL1_CLKOSEL_HIRC + * @param[in] u32ClkDiv is system reset source + * @param[in] u32ClkDivBy1En is frequency divided by one enable. + * @return None + * + * @details Output selected clock to CKO. The output clock frequency is divided by u32ClkDiv. + * The formula is: + * CKO frequency = (Clock source frequency) / 2^(u32ClkDiv + 1) + * This function is just used to set CKO clock. + * User must enable I/O for CKO clock output pin by themselves. + */ +void CLK_EnableCKO(uint32_t u32ClkSrc, uint32_t u32ClkDiv, uint32_t u32ClkDivBy1En) +{ + /* CKO = clock source / 2^(u32ClkDiv + 1) */ + CLK->CLKOCTL = CLK_CLKOCTL_CLKOEN_Msk | u32ClkDiv | u32ClkDivBy1En<APBCLK0 |= CLK_APBCLK0_CLKOCKEN_Msk; + + /* Select CKO clock source */ + CLK->CLKSEL1 = (CLK->CLKSEL1 & (~CLK_CLKSEL1_CLKOSEL_Msk)) | u32ClkSrc; +} + +/** + * @brief Enter to Power-down mode + * @return None + * @details This function let system enter to Power-down mode. + */ +void CLK_PowerDown(void) +{ + SCB->SCR = SCB_SCR_SLEEPDEEP_Msk; + CLK->PWRCTL |= (CLK_PWRCTL_PDEN_Msk | CLK_PWRCTL_PDWKDLY_Msk ); + __WFI(); +} + +/** + * @brief Enter to Idle mode. + * @return None + * @details This function let system enter to Idle mode. + */ +void CLK_Idle(void) +{ + /* Set the processor uses sleep as its low power mode */ + SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; + + /* Set chip in idle mode because of WFI command */ + CLK->PWRCTL &= ~(CLK_PWRCTL_PDEN_Msk ); + + /* Chip enter idle mode after CPU run WFI instruction */ + __WFI(); +} + + +/** + * @brief This function get PCLK frequency. The frequency unit is Hz. + * @return PCLK frequency + */ +uint32_t CLK_GetPCLKFreq(void) +{ + SystemCoreClockUpdate(); + if(CLK->CLKSEL0 & CLK_CLKSEL0_PCLKSEL_Msk) + return SystemCoreClock/2; + else + return SystemCoreClock; +} + +/** + * @brief Get external high speed crystal clock frequency + * @return External high frequency crystal frequency + * @details This function get external high frequency crystal frequency. The frequency unit is Hz. + */ +uint32_t CLK_GetHXTFreq(void) +{ + if(CLK->PWRCTL & CLK_PWRCTL_HXTEN_Msk ) + return __HXT; + else + return 0; +} + +/** + * @brief Get external low speed crystal clock frequency + * @return External low speed crystal clock frequency + * @details This function get external low frequency crystal frequency. The frequency unit is Hz. + */ +uint32_t CLK_GetLXTFreq(void) +{ + if(CLK->PWRCTL & CLK_PWRCTL_LXTEN_Msk ) + return __LXT; + else + return 0; +} + + +/** + * @brief Get HCLK frequency + * @return HCLK frequency + * @details This function get HCLK frequency. The frequency unit is Hz. + */ +uint32_t CLK_GetHCLKFreq(void) +{ + SystemCoreClockUpdate(); + return SystemCoreClock; +} + +/** + * @brief Get CPU frequency + * @return CPU frequency + * @details This function get CPU frequency. The frequency unit is Hz. + */ +uint32_t CLK_GetCPUFreq(void) +{ + SystemCoreClockUpdate(); + return SystemCoreClock; +} + +/** + * @brief This function get PLL frequency. The frequency unit is Hz. + * @return PLL frequency + */ +uint32_t CLK_GetPLLClockFreq(void) +{ + uint32_t u32Freq =0, u32PLLSrc; + uint32_t u32NO,u32NF,u32NR,u32PllReg; + + u32PllReg = CLK->PLLCTL; + + if(u32PllReg & (CLK_PLLCTL_PD_Msk | CLK_PLLCTL_OE_Msk)) + return 0; /* PLL is in power down mode or fix low */ + + if(u32PllReg & CLK_PLLCTL_PLLSRC_Msk) + u32PLLSrc = __HIRC; + else + u32PLLSrc = __HXT; + + u32NO=(u32PllReg & CLK_PLLCTL_OUTDV_Msk)>>CLK_PLLCTL_OUTDV_Pos; + switch(u32NO) { + case 0: + u32NO=1; + break; + case 1: + case 2: + u32NO=2; + break; + case 3: + u32NO=4; + break; + } + + u32NF = (u32PllReg & CLK_PLLCTL_FBDIV_Msk) + 2; + u32NR = ( (u32PllReg & CLK_PLLCTL_INDIV_Msk)>>CLK_PLLCTL_INDIV_Pos ) + 2; + + /* u32PLLSrc is shifted 2 bits to avoid overflow */ + u32Freq = (((u32PLLSrc >> 2) * u32NF) / (u32NR * u32NO) << 2); + return u32Freq; +} + +/** + * @brief Set HCLK frequency + * @param[in] u32Hclk is HCLK frequency + * @return HCLK frequency + * @details This function set HCLK frequency. The frequency unit is Hz. The range of u32Hclk is 24 MHz ~ 96 MHz. + */ +uint32_t CLK_SetCoreClock(uint32_t u32Hclk) +{ + uint32_t u32ClkSrc,u32NR, u32NF,u32Register; + u32ClkSrc = CLK->CLKSEL0 & CLK_CLKSEL0_HCLKSEL_Msk; + + if(u32Hclk < FREQ_24MHZ) + u32Hclk =FREQ_24MHZ; + + if(CLK->PWRCTL & CLK_PWRCTL_HXTEN_Msk) { + u32Register = 0<(0xF+2) || u32NF>(0xFF+2) ) { + u32NR = u32NR>>1; + u32NF = u32NF>>1; + } + CLK->PLLCTL = u32Register | ((u32NR - 2)<<9) | (u32NF - 2) ; + CLK_WaitClockReady(CLK_STATUS_PLLSTB_Msk); + + CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_PLL,CLK_CLKDIV0_HCLK(1)); + + /* Update System Core Clock */ + SystemCoreClockUpdate(); + + return SystemCoreClock; +} + +/** + * @brief This function set HCLK clock source and HCLK clock divider + * @param[in] u32ClkSrc is HCLK clock source. Including : + * - \ref CLK_CLKSEL0_HCLKSEL_HXT + * - \ref CLK_CLKSEL0_HCLKSEL_LXT + * - \ref CLK_CLKSEL0_HCLKSEL_PLL + * - \ref CLK_CLKSEL0_HCLKSEL_LIRC + * - \ref CLK_CLKSEL0_HCLKSEL_HIRC + * @param[in] u32ClkDiv is HCLK clock divider. Including : + * - \ref CLK_CLKDIV0_HCLK(x) + * @return None + */ +void CLK_SetHCLK(uint32_t u32ClkSrc, uint32_t u32ClkDiv) +{ + CLK->CLKDIV0 = (CLK->CLKDIV0 & ~CLK_CLKDIV0_HCLKDIV_Msk) | u32ClkDiv; + CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_HCLKSEL_Msk) | u32ClkSrc; + SystemCoreClockUpdate(); +} + +/** + * @brief This function set selected module clock source and module clock divider + * @param[in] u32ModuleIdx is module index. + * @param[in] u32ClkSrc is module clock source. + * @param[in] u32ClkDiv is module clock divider. + * @return None + * @details Valid parameter combinations listed in following table: + * + * |Module index |Clock source |Divider | + * | :------------------- | :------------------------------- | :------------------------- | + * |\ref PDMA_MODULE | x | x | + * |\ref ISP_MODULE | x | x | + * |\ref EBI_MODULE | x | x | + * |\ref USBH_MODULE |\ref CLK_CLKSEL0_USBHSEL_PLL |\ref CLK_CLKDIV0_USB(x) | + * |\ref USBH_MODULE |\ref CLK_CLKSEL0_USBHSEL_PLL2 |\ref CLK_CLKDIV0_USB(x) | + * |\ref EMAC_MODULE | x |\ref CLK_CLKDIV3_EMAC(x) | + * |\ref SDH_MODULE |\ref CLK_CLKSEL0_SDHSEL_HXT |\ref CLK_CLKDIV0_SDH(x) | + * |\ref SDH_MODULE |\ref CLK_CLKSEL0_SDHSEL_PLL |\ref CLK_CLKDIV0_SDH(x) | + * |\ref SDH_MODULE |\ref CLK_CLKSEL0_SDHSEL_HCLK |\ref CLK_CLKDIV0_SDH(x) | + * |\ref SDH_MODULE |\ref CLK_CLKSEL0_SDHSEL_HIRC |\ref CLK_CLKDIV0_SDH(x) | + * |\ref CRC_MODULE | x | x | + * |\ref CAP_MODULE |\ref CLK_CLKSEL0_CAPSEL_HXT |\ref CLK_CLKDIV3_CAP(x) | + * |\ref CAP_MODULE |\ref CLK_CLKSEL0_CAPSEL_PLL2 |\ref CLK_CLKDIV3_CAP(x) | + * |\ref CAP_MODULE |\ref CLK_CLKSEL0_CAPSEL_HCLK |\ref CLK_CLKDIV3_CAP(x) | + * |\ref CAP_MODULE |\ref CLK_CLKSEL0_CAPSEL_HIRC |\ref CLK_CLKDIV3_CAP(x) | + * |\ref SEN_MODULE | x | x | + * |\ref USBD_MODULE | x | x | + * |\ref CRPT_MODULE | x | x | + * |\ref ECAP1_MODULE | x | x | + * |\ref ECAP0_MODULE | x | x | + * |\ref EADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_HXT |\ref CLK_CLKDIV0_ADC(x) | + * |\ref EADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_PLL |\ref CLK_CLKDIV0_ADC(x) | + * |\ref EADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_PCLK |\ref CLK_CLKDIV0_ADC(x) | + * |\ref EADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_HIRC |\ref CLK_CLKDIV0_ADC(x) | + * |\ref OPA_MODULE | x | x | + * |\ref QEI1_MODULE | x | x | + * |\ref QEI0_MODULE | x | x | + * |\ref PWM1CH45_MODULE |\ref CLK_CLKSEL2_PWM1CH45SEL_HXT | x | + * |\ref PWM1CH45_MODULE |\ref CLK_CLKSEL2_PWM1CH45SEL_LXT | x | + * |\ref PWM1CH45_MODULE |\ref CLK_CLKSEL2_PWM1CH45SEL_PCLK | x | + * |\ref PWM1CH45_MODULE |\ref CLK_CLKSEL2_PWM1CH45SEL_LIRC | x | + * |\ref PWM1CH45_MODULE |\ref CLK_CLKSEL2_PWM1CH45SEL_HIRC | x | + * |\ref PWM1CH23_MODULE |\ref CLK_CLKSEL2_PWM1CH23SEL_HXT | x | + * |\ref PWM1CH23_MODULE |\ref CLK_CLKSEL2_PWM1CH23SEL_LXT | x | + * |\ref PWM1CH23_MODULE |\ref CLK_CLKSEL2_PWM1CH23SEL_PCLK | x | + * |\ref PWM1CH23_MODULE |\ref CLK_CLKSEL2_PWM1CH23SEL_LIRC | x | + * |\ref PWM1CH23_MODULE |\ref CLK_CLKSEL2_PWM1CH23SEL_HIRC | x | + * |\ref PWM1CH01_MODULE |\ref CLK_CLKSEL2_PWM1CH01SEL_HXT | x | + * |\ref PWM1CH01_MODULE |\ref CLK_CLKSEL2_PWM1CH01SEL_LXT | x | + * |\ref PWM1CH01_MODULE |\ref CLK_CLKSEL2_PWM1CH01SEL_PCLK | x | + * |\ref PWM1CH01_MODULE |\ref CLK_CLKSEL2_PWM1CH01SEL_LIRC | x | + * |\ref PWM1CH01_MODULE |\ref CLK_CLKSEL2_PWM1CH01SEL_HIRC | x | + * |\ref PWM0CH45_MODULE |\ref CLK_CLKSEL2_PWM0CH45SEL_HXT | x | + * |\ref PWM0CH45_MODULE |\ref CLK_CLKSEL2_PWM0CH45SEL_LXT | x | + * |\ref PWM0CH45_MODULE |\ref CLK_CLKSEL2_PWM0CH45SEL_PCLK | x | + * |\ref PWM0CH45_MODULE |\ref CLK_CLKSEL2_PWM0CH45SEL_LIRC | x | + * |\ref PWM0CH45_MODULE |\ref CLK_CLKSEL2_PWM0CH45SEL_HIRC | x | + * |\ref PWM0CH23_MODULE |\ref CLK_CLKSEL2_PWM0CH23SEL_HXT | x | + * |\ref PWM0CH23_MODULE |\ref CLK_CLKSEL2_PWM0CH23SEL_LXT | x | + * |\ref PWM0CH23_MODULE |\ref CLK_CLKSEL2_PWM0CH23SEL_PCLK | x | + * |\ref PWM0CH23_MODULE |\ref CLK_CLKSEL2_PWM0CH23SEL_LIRC | x | + * |\ref PWM0CH23_MODULE |\ref CLK_CLKSEL2_PWM0CH23SEL_HIRC | x | + * |\ref PWM0CH01_MODULE |\ref CLK_CLKSEL2_PWM0CH01SEL_HXT | x | + * |\ref PWM0CH01_MODULE |\ref CLK_CLKSEL2_PWM0CH01SEL_LXT | x | + * |\ref PWM0CH01_MODULE |\ref CLK_CLKSEL2_PWM0CH01SEL_PCLK | x | + * |\ref PWM0CH01_MODULE |\ref CLK_CLKSEL2_PWM0CH01SEL_LIRC | x | + * |\ref PWM0CH01_MODULE |\ref CLK_CLKSEL2_PWM0CH01SEL_HIRC | x | + * |\ref I2C4_MODULE | x | x | + * |\ref SC5_MODULE | x | x | + * |\ref SC4_MODULE | x | x | + * |\ref SC3_MODULE | x | x | + * |\ref SC2_MODULE | x | x | + * |\ref SC5_MODULE |\ref CLK_CLKSEL3_SC5SEL_HXT |\ref CLK_CLKDIV2_SC5(x) | + * |\ref SC5_MODULE |\ref CLK_CLKSEL3_SC5SEL_PLL |\ref CLK_CLKDIV2_SC5(x) | + * |\ref SC5_MODULE |\ref CLK_CLKSEL3_SC5SEL_PCLK |\ref CLK_CLKDIV2_SC5(x) | + * |\ref SC5_MODULE |\ref CLK_CLKSEL3_SC5SEL_HIRC |\ref CLK_CLKDIV2_SC5(x) | + * |\ref SC4_MODULE |\ref CLK_CLKSEL3_SC4SEL_HXT |\ref CLK_CLKDIV2_SC4(x) | + * |\ref SC4_MODULE |\ref CLK_CLKSEL3_SC4SEL_PLL |\ref CLK_CLKDIV2_SC4(x) | + * |\ref SC4_MODULE |\ref CLK_CLKSEL3_SC4SEL_PCLK |\ref CLK_CLKDIV2_SC4(x) | + * |\ref SC4_MODULE |\ref CLK_CLKSEL3_SC4SEL_HIRC |\ref CLK_CLKDIV2_SC4(x) | + * |\ref SC3_MODULE |\ref CLK_CLKSEL3_SC3SEL_HXT |\ref CLK_CLKDIV1_SC3(x) | + * |\ref SC3_MODULE |\ref CLK_CLKSEL3_SC3SEL_PLL |\ref CLK_CLKDIV1_SC3(x) | + * |\ref SC3_MODULE |\ref CLK_CLKSEL3_SC3SEL_PCLK |\ref CLK_CLKDIV1_SC3(x) | + * |\ref SC3_MODULE |\ref CLK_CLKSEL3_SC3SEL_HIRC |\ref CLK_CLKDIV1_SC3(x) | + * |\ref SC2_MODULE |\ref CLK_CLKSEL3_SC2SEL_HXT |\ref CLK_CLKDIV1_SC2(x) | + * |\ref SC2_MODULE |\ref CLK_CLKSEL3_SC2SEL_PLL |\ref CLK_CLKDIV1_SC2(x) | + * |\ref SC2_MODULE |\ref CLK_CLKSEL3_SC2SEL_PCLK |\ref CLK_CLKDIV1_SC2(x) | + * |\ref SC2_MODULE |\ref CLK_CLKSEL3_SC2SEL_HIRC |\ref CLK_CLKDIV1_SC2(x) | + * |\ref SC1_MODULE |\ref CLK_CLKSEL3_SC1SEL_HXT |\ref CLK_CLKDIV1_SC1(x) | + * |\ref SC1_MODULE |\ref CLK_CLKSEL3_SC1SEL_PLL |\ref CLK_CLKDIV1_SC1(x) | + * |\ref SC1_MODULE |\ref CLK_CLKSEL3_SC1SEL_PCLK |\ref CLK_CLKDIV1_SC1(x) | + * |\ref SC1_MODULE |\ref CLK_CLKSEL3_SC1SEL_HIRC |\ref CLK_CLKDIV1_SC1(x) | + * |\ref SC0_MODULE |\ref CLK_CLKSEL3_SC0SEL_HXT |\ref CLK_CLKDIV1_SC0(x) | + * |\ref SC0_MODULE |\ref CLK_CLKSEL3_SC0SEL_PLL |\ref CLK_CLKDIV1_SC0(x) | + * |\ref SC0_MODULE |\ref CLK_CLKSEL3_SC0SEL_PCLK |\ref CLK_CLKDIV1_SC0(x) | + * |\ref SC0_MODULE |\ref CLK_CLKSEL3_SC0SEL_HIRC |\ref CLK_CLKDIV1_SC0(x) | + * |\ref PS2_MODULE |\ref CLK_CLKSEL3_I2S1SEL_HXT | x | + * |\ref I2S1_MODULE |\ref CLK_CLKSEL3_I2S1SEL_HXT | x | + * |\ref I2S1_MODULE |\ref CLK_CLKSEL3_I2S1SEL_PLL | x | + * |\ref I2S1_MODULE |\ref CLK_CLKSEL3_I2S1SEL_PCLK | x | + * |\ref I2S1_MODULE |\ref CLK_CLKSEL3_I2S1SEL_HIRC | x | + * |\ref I2S0_MODULE |\ref CLK_CLKSEL3_I2S0SEL_HXT | x | + * |\ref I2S0_MODULE |\ref CLK_CLKSEL3_I2S0SEL_PLL | x | + * |\ref I2S0_MODULE |\ref CLK_CLKSEL3_I2S0SEL_PCLK | x | + * |\ref I2S0_MODULE |\ref CLK_CLKSEL3_I2S0SEL_HIRC | x | + * |\ref ADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_HXT |\ref CLK_CLKDIV0_ADC(x) | + * |\ref ADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_PLL |\ref CLK_CLKDIV0_ADC(x) | + * |\ref ADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_PCLK |\ref CLK_CLKDIV0_ADC(x) | + * |\ref ADC_MODULE |\ref CLK_CLKSEL1_ADCSEL_HIRC |\ref CLK_CLKDIV0_ADC(x) | + * |\ref OTG_MODULE | x | x | + * |\ref CAN1_MODULE | x | x | + * |\ref CAN0_MODULE | x | x | + * |\ref UART5_MODULE |\ref CLK_CLKSEL1_UARTSEL_HXT |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART5_MODULE |\ref CLK_CLKSEL1_UARTSEL_PLL |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART5_MODULE |\ref CLK_CLKSEL1_UARTSEL_HIRC |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART4_MODULE |\ref CLK_CLKSEL1_UARTSEL_HXT |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART4_MODULE |\ref CLK_CLKSEL1_UARTSEL_PLL |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART4_MODULE |\ref CLK_CLKSEL1_UARTSEL_HIRC |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART3_MODULE |\ref CLK_CLKSEL1_UARTSEL_HXT |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART3_MODULE |\ref CLK_CLKSEL1_UARTSEL_PLL |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART3_MODULE |\ref CLK_CLKSEL1_UARTSEL_HIRC |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART2_MODULE |\ref CLK_CLKSEL1_UARTSEL_HXT |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART2_MODULE |\ref CLK_CLKSEL1_UARTSEL_PLL |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART2_MODULE |\ref CLK_CLKSEL1_UARTSEL_HIRC |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART1_MODULE |\ref CLK_CLKSEL1_UARTSEL_HXT |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART1_MODULE |\ref CLK_CLKSEL1_UARTSEL_PLL |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART1_MODULE |\ref CLK_CLKSEL1_UARTSEL_HIRC |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART0_MODULE |\ref CLK_CLKSEL1_UARTSEL_HXT |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART0_MODULE |\ref CLK_CLKSEL1_UARTSEL_PLL |\ref CLK_CLKDIV0_UART(x) | + * |\ref UART0_MODULE |\ref CLK_CLKSEL1_UARTSEL_HIRC |\ref CLK_CLKDIV0_UART(x) | + * |\ref SPI3_MODULE |\ref CLK_CLKSEL1_SPI3SEL_PLL | x | + * |\ref SPI3_MODULE |\ref CLK_CLKSEL1_SPI3SEL_PCLK | x | + * |\ref SPI2_MODULE |\ref CLK_CLKSEL1_SPI2SEL_PLL | x | + * |\ref SPI2_MODULE |\ref CLK_CLKSEL1_SPI2SEL_PCLK | x | + * |\ref SPI1_MODULE |\ref CLK_CLKSEL1_SPI1SEL_PLL | x | + * |\ref SPI1_MODULE |\ref CLK_CLKSEL1_SPI1SEL_PCLK | x | + * |\ref SPI0_MODULE |\ref CLK_CLKSEL1_SPI0SEL_PLL | x | + * |\ref SPI0_MODULE |\ref CLK_CLKSEL1_SPI0SEL_PCLK | x | + * |\ref I2C3_MODULE | x | x | + * |\ref I2C2_MODULE | x | x | + * |\ref I2C1_MODULE | x | x | + * |\ref I2C0_MODULE | x | x | + * |\ref ACMP_MODULE | x | x | + * |\ref CLKO_MODULE |\ref CLK_CLKSEL1_CLKOSEL_HXT | x | + * |\ref CLKO_MODULE |\ref CLK_CLKSEL1_CLKOSEL_LXT | x | + * |\ref CLKO_MODULE |\ref CLK_CLKSEL1_CLKOSEL_HCLK | x | + * |\ref CLKO_MODULE |\ref CLK_CLKSEL1_CLKOSEL_HIRC | x | + * |\ref TMR3_MODULE |\ref CLK_CLKSEL1_TMR3SEL_HXT | x | + * |\ref TMR3_MODULE |\ref CLK_CLKSEL1_TMR3SEL_LXT | x | + * |\ref TMR3_MODULE |\ref CLK_CLKSEL1_TMR3SEL_PCLK | x | + * |\ref TMR3_MODULE |\ref CLK_CLKSEL1_TMR3SEL_LIRC | x | + * |\ref TMR3_MODULE |\ref CLK_CLKSEL1_TMR3SEL_EXT | x | + * |\ref TMR3_MODULE |\ref CLK_CLKSEL1_TMR3SEL_HIRC | x | + * |\ref TMR2_MODULE |\ref CLK_CLKSEL1_TMR2SEL_HXT | x | + * |\ref TMR2_MODULE |\ref CLK_CLKSEL1_TMR2SEL_LXT | x | + * |\ref TMR2_MODULE |\ref CLK_CLKSEL1_TMR2SEL_PCLK | x | + * |\ref TMR2_MODULE |\ref CLK_CLKSEL1_TMR2SEL_LIRC | x | + * |\ref TMR2_MODULE |\ref CLK_CLKSEL1_TMR2SEL_EXT | x | + * |\ref TMR2_MODULE |\ref CLK_CLKSEL1_TMR2SEL_HIRC | x | + * |\ref TMR1_MODULE |\ref CLK_CLKSEL1_TMR1SEL_HXT | x | + * |\ref TMR1_MODULE |\ref CLK_CLKSEL1_TMR1SEL_LXT | x | + * |\ref TMR1_MODULE |\ref CLK_CLKSEL1_TMR1SEL_PCLK | x | + * |\ref TMR1_MODULE |\ref CLK_CLKSEL1_TMR1SEL_LIRC | x | + * |\ref TMR1_MODULE |\ref CLK_CLKSEL1_TMR1SEL_EXT | x | + * |\ref TMR1_MODULE |\ref CLK_CLKSEL1_TMR1SEL_HIRC | x | + * |\ref TMR0_MODULE |\ref CLK_CLKSEL1_TMR0SEL_HXT | x | + * |\ref TMR0_MODULE |\ref CLK_CLKSEL1_TMR0SEL_LXT | x | + * |\ref TMR0_MODULE |\ref CLK_CLKSEL1_TMR0SEL_PCLK | x | + * |\ref TMR0_MODULE |\ref CLK_CLKSEL1_TMR0SEL_LIRC | x | + * |\ref TMR0_MODULE |\ref CLK_CLKSEL1_TMR0SEL_EXT | x | + * |\ref TMR0_MODULE |\ref CLK_CLKSEL1_TMR0SEL_HIRC | x | + * |\ref RTC_MODULE | x | x | + * |\ref WWDT_MODULE |\ref CLK_CLKSEL1_WWDTSEL_HCLK_DIV2048 | x | + * |\ref WWDT_MODULE |\ref CLK_CLKSEL1_WWDTSEL_LIRC | x | + * |\ref WDT_MODULE |\ref CLK_CLKSEL1_WDTSEL_LXT | x | + * |\ref WDT_MODULE |\ref CLK_CLKSEL1_WDTSEL_HCLK_DIV2048 | x | + * |\ref WDT_MODULE |\ref CLK_CLKSEL1_WDTSEL_LIRC | x | + * + */ + +void CLK_SetModuleClock(uint32_t u32ModuleIdx, uint32_t u32ClkSrc, uint32_t u32ClkDiv) +{ + uint32_t u32tmp=0,u32sel=0,u32div=0; + + if(MODULE_CLKDIV_Msk(u32ModuleIdx)!=MODULE_NoMsk) { + u32div =(uint32_t)&CLK->CLKDIV0+((MODULE_CLKDIV(u32ModuleIdx))*4); + u32tmp = *(volatile uint32_t *)(u32div); + u32tmp = ( u32tmp & ~(MODULE_CLKDIV_Msk(u32ModuleIdx)<CLKSEL0+((MODULE_CLKSEL(u32ModuleIdx))*4); + u32tmp = *(volatile uint32_t *)(u32sel); + u32tmp = ( u32tmp & ~(MODULE_CLKSEL_Msk(u32ModuleIdx)<PWRCTL |= u32ClkMask; +} + +/** + * @brief This function disable clock source + * @param u32ClkMask is clock source mask. Including: + * - \ref CLK_PWRCTL_HXTEN_Msk + * - \ref CLK_PWRCTL_LXTEN_Msk + * - \ref CLK_PWRCTL_HIRCEN_Msk + * - \ref CLK_PWRCTL_LIRCEN_Msk + * @return None + */ +void CLK_DisableXtalRC(uint32_t u32ClkMask) +{ + CLK->PWRCTL &= ~u32ClkMask; +} + +/** + * @brief This function enable module clock + * @param[in] u32ModuleIdx is module index. Including : + * - \ref PDMA_MODULE + * - \ref ISP_MODULE + * - \ref EBI_MODULE + * - \ref USBH_MODULE + * - \ref EMAC_MODULE + * - \ref SDH_MODULE + * - \ref CRC_MODULE + * - \ref CAP_MODULE + * - \ref USBD_MODULE + * - \ref CRPT_MODULE + * - \ref WDT_MODULE + * - \ref WWDT_MODULE + * - \ref RTC_MODULE + * - \ref TMR0_MODULE + * - \ref TMR1_MODULE + * - \ref TMR2_MODULE + * - \ref TMR3_MODULE + * - \ref CLKO_MODULE + * - \ref ACMP_MODULE + * - \ref I2C0_MODULE + * - \ref I2C1_MODULE + * - \ref I2C2_MODULE + * - \ref I2C3_MODULE + * - \ref SPI0_MODULE + * - \ref SPI1_MODULE + * - \ref SPI2_MODULE + * - \ref SPI3_MODULE + * - \ref UART0_MODULE + * - \ref UART1_MODULE + * - \ref UART2_MODULE + * - \ref UART3_MODULE + * - \ref UART4_MODULE + * - \ref UART5_MODULE + * - \ref CAN0_MODULE + * - \ref CAN1_MODULE + * - \ref OTG_MODULE + * - \ref ADC_MODULE + * - \ref I2S0_MODULE + * - \ref I2S1_MODULE + * - \ref PS2_MODULE + * - \ref SC0_MODULE + * - \ref SC1_MODULE + * - \ref SC2_MODULE + * - \ref SC3_MODULE + * - \ref SC4_MODULE + * - \ref SC5_MODULE + * - \ref I2C4_MODULE + * - \ref PWM0CH01_MODULE + * - \ref PWM0CH23_MODULE + * - \ref PWM0CH45_MODULE + * - \ref PWM1CH01_MODULE + * - \ref PWM1CH23_MODULE + * - \ref PWM1CH45_MODULE + * - \ref QEI0_MODULE + * - \ref QEI1_MODULE + * - \ref ECAP0_MODULE + * - \ref ECAP1_MODULE + * - \ref EPWM0_MODULE + * - \ref EPWM1_MODULE + * - \ref OPA_MODULE + * - \ref EADC_MODULE + * @return None + */ +void CLK_EnableModuleClock(uint32_t u32ModuleIdx) +{ + *(volatile uint32_t *)((uint32_t)&CLK->AHBCLK+(MODULE_APBCLK(u32ModuleIdx)*4)) |= 1<AHBCLK+(MODULE_APBCLK(u32ModuleIdx)*4)) &= ~(1<PWRCTL |= CLK_PWRCTL_HXTEN_Msk; + + /* Wait for HXT clock ready */ + CLK_WaitClockReady(CLK_STATUS_HXTSTB_Msk); + + /* Select PLL source clock from HXT */ + u32CLK_SRC = CLK_PLLCTL_PLLSRC_HXT; + u32PllSrcClk = __HXT; + + /* u32NR start from 2 */ + u32NR = 2; + } + + /* PLL source clock is from HIRC */ + else { + /* Enable HIRC clock */ + CLK->PWRCTL |= CLK_PWRCTL_HIRCEN_Msk; + + /* Wait for HIRC clock ready */ + CLK_WaitClockReady(CLK_STATUS_HIRCSTB_Msk); + + /* Select PLL source clock from HIRC */ + u32CLK_SRC = CLK_PLLCTL_PLLSRC_HIRC; + u32PllSrcClk = __HIRC; + + /* u32NR start from 4 when FIN = 22.1184MHz to avoid calculation overflow */ + u32NR = 4; + } + + /* Select "NO" according to request frequency */ + if((u32PllFreq <= FREQ_500MHZ) && (u32PllFreq > FREQ_250MHZ)) { + u32NO = 0; + } else if((u32PllFreq <= FREQ_250MHZ) && (u32PllFreq > FREQ_125MHZ)) { + u32NO = 1; + u32PllFreq = u32PllFreq << 1; + } else if((u32PllFreq <= FREQ_125MHZ) && (u32PllFreq >= FREQ_50MHZ)) { + u32NO = 3; + u32PllFreq = u32PllFreq << 2; + } else { + /* Wrong frequency request. Just return default setting. */ + goto lexit; + } + + /* Find best solution */ + u32Min = (uint32_t) - 1; + u32MinNR = 0; + u32MinNF = 0; + for(; u32NR <= 33; u32NR++) { + u32Tmp = u32PllSrcClk / u32NR; + if((u32Tmp > 1600000) && (u32Tmp < 16000000)) { + for(u32NF = 2; u32NF <= 513; u32NF++) { + u32Tmp2 = u32Tmp * u32NF; + if((u32Tmp2 >= 200000000) && (u32Tmp2 <= 500000000)) { + u32Tmp3 = (u32Tmp2 > u32PllFreq) ? u32Tmp2 - u32PllFreq : u32PllFreq - u32Tmp2; + if(u32Tmp3 < u32Min) { + u32Min = u32Tmp3; + u32MinNR = u32NR; + u32MinNF = u32NF; + + /* Break when get good results */ + if(u32Min == 0) + break; + } + } + } + } + } + + /* Enable and apply new PLL setting. */ + CLK->PLLCTL = u32CLK_SRC | (u32NO << 14) | ((u32MinNR - 2) << 9) | (u32MinNF - 2); + + /* Wait for PLL clock stable */ + CLK_WaitClockReady(CLK_STATUS_PLLSTB_Msk); + + /* Return actual PLL output clock frequency */ + return u32PllSrcClk / ((u32NO + 1) * u32MinNR) * u32MinNF; + +lexit: + + /* Apply default PLL setting and return */ + if(u32PllClkSrc == CLK_PLLCTL_PLLSRC_HXT) + CLK->PLLCTL = CLK_PLLCTL_84MHz_HXT; /* 84MHz */ + else + CLK->PLLCTL = CLK_PLLCTL_50MHz_HIRC; /* 50MHz */ + + /* Wait for PLL clock stable */ + CLK_WaitClockReady(CLK_STATUS_PLLSTB_Msk); + + return CLK_GetPLLClockFreq(); +} + +/** + * @brief This function disable PLL + * @return None + */ +void CLK_DisablePLL(void) +{ + CLK->PLLCTL |= CLK_PLLCTL_PD_Msk; +} + +/** + * @brief This function set SysTick clock source + * @param[in] u32ClkSrc is SysTick clock source. Including : + * - \ref CLK_CLKSEL0_STCLKSEL_HXT + * - \ref CLK_CLKSEL0_STCLKSEL_LXT + * - \ref CLK_CLKSEL0_STCLKSEL_HXT_DIV2 + * - \ref CLK_CLKSEL0_STCLKSEL_HCLK_DIV2 + * - \ref CLK_CLKSEL0_STCLKSEL_HIRC_DIV2 + * @return None + */ +void CLK_SetSysTickClockSrc(uint32_t u32ClkSrc) +{ + CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_STCLKSEL_Msk) | u32ClkSrc ; +} +/** + * @brief This function execute delay function. + * @param[in] us Delay time. The Max value is 2^24 / CPU Clock(MHz). Ex: + * 50MHz => 335544us, 48MHz => 349525us, 28MHz => 699050us ... + * @return None + * @details Use the SysTick to generate the delay time and the UNIT is in us. + * The SysTick clock source is from HCLK, i.e the same as system core clock. + */ +void CLK_SysTickDelay(uint32_t us) +{ + SysTick->LOAD = us * CyclesPerUs; + SysTick->VAL = (0x00); + SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk; + + /* Waiting for down-count to zero */ + while((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == 0); + SysTick->CTRL = 0 ; +} + +/** + * @brief This function check selected clock source status + * @param[in] u32ClkMask is selected clock source. Including + * - \ref CLK_STATUS_CLKSFAIL_Msk + * - \ref CLK_STATUS_HIRCSTB_Msk + * - \ref CLK_STATUS_LIRCSTB_Msk + * - \ref CLK_STATUS_PLLSTB_Msk + * - \ref CLK_STATUS_LXTSTB_Msk + * - \ref CLK_STATUS_HXTSTB_Msk + * + * @return 0 clock is not stable + * 1 clock is stable + * + * @details To wait for clock ready by specified CLKSTATUS bit or timeout (~300ms) + */ +uint32_t CLK_WaitClockReady(uint32_t u32ClkMask) +{ + int32_t i32TimeOutCnt = 2160000; + + while((CLK->STATUS & u32ClkMask) != u32ClkMask) { + if(i32TimeOutCnt-- <= 0) + return 0; + } + + return 1; +} + +/** + * @brief Enable System Tick counter + * @param[in] u32ClkSrc is System Tick clock source. Including: + * - \ref CLK_CLKSEL0_STCLKSEL_HXT + * - \ref CLK_CLKSEL0_STCLKSEL_LXT + * - \ref CLK_CLKSEL0_STCLKSEL_HXT_DIV2 + * - \ref CLK_CLKSEL0_STCLKSEL_HCLK_DIV2 + * - \ref CLK_CLKSEL0_STCLKSEL_HIRC_DIV2 + * - \ref CLK_CLKSEL0_STCLKSEL_HCLK + * @param[in] u32Count is System Tick reload value. It could be 0~0xFFFFFF. + * @return None + * @details This function set System Tick clock source, reload value, enable System Tick counter and interrupt. \n + * The register write-protection function should be disabled before using this function. + */ +void CLK_EnableSysTick(uint32_t u32ClkSrc, uint32_t u32Count) +{ + /* Set System Tick counter disabled */ + SysTick->CTRL = 0; + + /* Set System Tick clock source */ + if( u32ClkSrc == CLK_CLKSEL0_STCLKSEL_HCLK ) + SysTick->CTRL |= SysTick_CTRL_CLKSOURCE_Msk; + else + CLK->CLKSEL0 = (CLK->CLKSEL0 & ~CLK_CLKSEL0_STCLKSEL_Msk) | u32ClkSrc; + + /* Set System Tick reload value */ + SysTick->LOAD = u32Count; + + /* Clear System Tick current value and counter flag */ + SysTick->VAL = 0; + + /* Set System Tick interrupt enabled and counter enabled */ + SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; +} + +/** + * @brief Disable System Tick counter + * @param None + * @return None + * @details This function disable System Tick counter. + */ +void CLK_DisableSysTick(void) +{ + /* Set System Tick counter disabled */ + SysTick->CTRL = 0; +} + +/*@}*/ /* end of group NUC472_442_CLK_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CLK_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/crc.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/crc.c new file mode 100644 index 0000000000000000000000000000000000000000..cc289d75ac773762d5208a399b1d4f6ede0feaca --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/crc.c @@ -0,0 +1,91 @@ +/**************************************************************************//** + * @file crc.c + * @version V1.00 + * $Revision: 2 $ + * $Date: 15/12/01 9:57a $ + * @brief NUC472/NUC442 CRC driver source file + * + * @note + * Copyright (C) 2015 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include "NUC472_442.h" +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CRC_Driver CRC Driver + @{ +*/ + +/** @addtogroup NUC472_442_CRC_EXPORTED_FUNCTIONS CRC Exported Functions + @{ +*/ + +/** + * @brief CRC Open + * + * @param[in] u32Mode CRC operation polynomial mode. Valid values are: + * - \ref CRC_CCITT + * - \ref CRC_8 + * - \ref CRC_16 + * - \ref CRC_32 + * @param[in] u32Attribute CRC operation data attribute. Valid values are combined with: + * - \ref CRC_CHECKSUM_COM + * - \ref CRC_CHECKSUM_RVS + * - \ref CRC_WDATA_COM + * - \ref CRC_WDATA_RVS + * @param[in] u32Seed Seed value. + * @param[in] u32DataLen CPU Write Data Length. Valid values are: + * - \ref CRC_CPU_WDATA_8 + * - \ref CRC_CPU_WDATA_16 + * - \ref CRC_CPU_WDATA_32 + * + * @return None + * + * @details This function will enable the CRC controller by specify CRC operation mode, attribute, initial seed and write data length. \n + * After that, user can start to perform CRC calculate by calling CRC_WRITE_DATA macro or CRC_DAT register directly. + */ +void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen) +{ + CRC->SEED = u32Seed; + CRC->CTL = u32Mode | u32Attribute | u32DataLen | CRC_CTL_CRCEN_Msk; + + /* Setting CRCRST bit will reload the initial seed value(CRC_SEED register) to CRC controller */ + CRC->CTL |= CRC_CTL_CRCRST_Msk; +} + +/** + * @brief Get CRC Checksum + * + * @param[in] None + * + * @return Checksum Result + * + * @details This macro gets the CRC checksum result by current CRC polynomial mode. + */ +uint32_t CRC_GetChecksum(void) +{ + switch(CRC->CTL & CRC_CTL_CRCMODE_Msk) { + case CRC_CCITT: + case CRC_16: + return (CRC->CHECKSUM & 0xFFFF); + + case CRC_32: + return (CRC->CHECKSUM); + + case CRC_8: + return (CRC->CHECKSUM & 0xFF); + + default: + return 0; + } +} + +/*@}*/ /* end of group NUC472_442_CRC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CRC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/crypto.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/crypto.c new file mode 100644 index 0000000000000000000000000000000000000000..49a99b03834276ef6cc0a5552b7e778e786dbb9f --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/crypto.c @@ -0,0 +1,348 @@ +/**************************************************************************//** + * @file crypto.c + * @version V1.10 + * $Revision: 12 $ + * $Date: 15/11/06 2:17p $ + * @brief Cryptographic Accelerator driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_CRYPTO_Driver CRYPTO Driver + @{ +*/ + + +/** @addtogroup NUC472_442_CRYPTO_EXPORTED_FUNCTIONS CRYPTO Exported Functions + @{ +*/ + +/// @cond HIDDEN_SYMBOLS + +static uint32_t g_AES_CTL[4]; +static uint32_t g_TDES_CTL[4]; + +/// @endcond HIDDEN_SYMBOLS + +/** + * @brief Open PRNG function + * @param[in] u32KeySize is PRNG key size, including: + * - \ref PRNG_KEY_SIZE_64 + * - \ref PRNG_KEY_SIZE_128 + * - \ref PRNG_KEY_SIZE_192 + * - \ref PRNG_KEY_SIZE_256 + * @param[in] u32SeedReload is PRNG seed reload or not, including: + * - \ref PRNG_SEED_CONT + * - \ref PRNG_SEED_RELOAD + * @param[in] u32Seed The new seed. Only valid when u32SeedReload is PRNG_SEED_RELOAD. + * @return None + */ +void PRNG_Open(uint32_t u32KeySize, uint32_t u32SeedReload, uint32_t u32Seed) +{ + if (u32SeedReload) + CRPT->PRNG_SEED = u32Seed; + + CRPT->PRNG_CTL = (u32KeySize << CRPT_PRNG_CTL_KEYSZ_Pos) | + (u32SeedReload << CRPT_PRNG_CTL_SEEDRLD_Pos); +} + +/** + * @brief Start to generate one PRNG key. + * @param None + * @return None + */ +void PRNG_Start(void) +{ + CRPT->PRNG_CTL |= CRPT_PRNG_CTL_START_Msk; +} + +/** + * @brief Read the PRNG key. + * @param[out] u32RandKey The key buffer to store newly generated PRNG key. + * @return None + */ +void PRNG_Read(uint32_t u32RandKey[]) +{ + int i, wcnt; + + wcnt = (((CRPT->PRNG_CTL & CRPT_PRNG_CTL_KEYSZ_Msk)>>CRPT_PRNG_CTL_KEYSZ_Pos)+1)*2; + for (i = 0; i < wcnt; i++) + u32RandKey[i] = *(uint32_t *)((uint32_t)&(CRPT->PRNG_KEY0) + (i * 4)); +} + + +/** + * @brief Open AES encrypt/decrypt function. + * @param[in] u32Channel AES channel. Must be 0~3. + * @param[in] u32EncDec 1: AES encode; 0: AES decode + * @param[in] u32OpMode AES operation mode, including: + * - \ref AES_MODE_ECB + * - \ref AES_MODE_CBC + * - \ref AES_MODE_CFB + * - \ref AES_MODE_OFB + * - \ref AES_MODE_CTR + * - \ref AES_MODE_CBC_CS1 + * - \ref AES_MODE_CBC_CS2 + * - \ref AES_MODE_CBC_CS3 + * @param[in] u32KeySize is AES key size, including: + * - \ref AES_KEY_SIZE_128 + * - \ref AES_KEY_SIZE_192 + * - \ref AES_KEY_SIZE_256 + * @param[in] u32SwapType is AES input/output data swap control, including: + * - \ref AES_NO_SWAP + * - \ref AES_OUT_SWAP + * - \ref AES_IN_SWAP + * - \ref AES_IN_OUT_SWAP + * @return None + */ +void AES_Open(uint32_t u32Channel, uint32_t u32EncDec, + uint32_t u32OpMode, uint32_t u32KeySize, uint32_t u32SwapType) +{ + CRPT->AES_CTL = (u32Channel << CRPT_AES_CTL_CHANNEL_Pos) | + (u32EncDec << CRPT_AES_CTL_ENCRPT_Pos) | + (u32OpMode << CRPT_AES_CTL_OPMODE_Pos) | + (u32KeySize << CRPT_AES_CTL_KEYSZ_Pos) | + (u32SwapType << CRPT_AES_CTL_OUTSWAP_Pos); + g_AES_CTL[u32Channel] = CRPT->AES_CTL; +} + +/** + * @brief Start AES encrypt/decrypt + * @param[in] u32Channel AES channel. Must be 0~3. + * @param[in] u32DMAMode AES DMA control, including: + * - \ref CRYPTO_DMA_ONE_SHOT One shop AES encrypt/decrypt. + * - \ref CRYPTO_DMA_CONTINUE Continuous AES encrypt/decrypt. + * - \ref CRYPTO_DMA_LAST Last AES encrypt/decrypt of a series of AES_Start. + * @return None + */ +void AES_Start(int32_t u32Channel, uint32_t u32DMAMode) +{ + CRPT->AES_CTL = g_AES_CTL[u32Channel]; + CRPT->AES_CTL |= CRPT_AES_CTL_START_Msk | (u32DMAMode << CRPT_AES_CTL_DMALAST_Pos); +} + +/** + * @brief Set AES keys + * @param[in] u32Channel AES channel. Must be 0~3. + * @param[in] au32Keys An word array contains AES keys. + * @param[in] u32KeySize is AES key size, including: + * - \ref AES_KEY_SIZE_128 + * - \ref AES_KEY_SIZE_192 + * - \ref AES_KEY_SIZE_256 + * @return None + */ +void AES_SetKey(uint32_t u32Channel, uint32_t au32Keys[], uint32_t u32KeySize) +{ + int i, wcnt; + uint32_t *key_ptr; + + key_ptr = (uint32_t *)((uint32_t)&CRPT->AES0_KEY0 + (u32Channel * 0x3C)); + wcnt = 4 + u32KeySize*2; + for (i = 0; i < wcnt; i++, key_ptr++) + *key_ptr = au32Keys[i]; +} + +/** + * @brief Set AES initial vectors + * @param[in] u32Channel AES channel. Must be 0~3. + * @param[in] au32IV A four entry word array contains AES initial vectors. + * @return None + */ +void AES_SetInitVect(uint32_t u32Channel, uint32_t au32IV[]) +{ + int i; + uint32_t *key_ptr; + + key_ptr = (uint32_t *)((uint32_t)&CRPT->AES0_IV0 + (u32Channel * 0x3C)); + for (i = 0; i < 4; i++, key_ptr++) + *key_ptr = au32IV[i]; +} + +/** + * @brief Set AES DMA transfer configuration. + * @param[in] u32Channel AES channel. Must be 0~3. + * @param[in] u32SrcAddr AES DMA source address + * @param[in] u32DstAddr AES DMA destination address + * @param[in] u32TransCnt AES DMA transfer byte count + * @return None + */ +void AES_SetDMATransfer(uint32_t u32Channel, uint32_t u32SrcAddr, + uint32_t u32DstAddr, uint32_t u32TransCnt) +{ + *(uint32_t *)((uint32_t)&CRPT->AES0_SADDR + (u32Channel * 0x3C)) = u32SrcAddr; + *(uint32_t *)((uint32_t)&CRPT->AES0_DADDR + (u32Channel * 0x3C)) = u32DstAddr; + *(uint32_t *)((uint32_t)&CRPT->AES0_CNT + (u32Channel * 0x3C)) = u32TransCnt; +} + +/** + * @brief Open TDES encrypt/decrypt function. + * @param[in] u32Channel TDES channel. Must be 0~3. + * @param[in] u32EncDec 1: TDES encode; 0: TDES decode + * @param[in] u32OpMode TDES operation mode, including: + * - \ref TDES_MODE_ECB + * - \ref TDES_MODE_CBC + * - \ref TDES_MODE_CFB + * - \ref TDES_MODE_OFB + * - \ref TDES_MODE_CTR + * @param[in] u32SwapType is TDES input/output data swap control and word swap control, including: + * - \ref TDES_NO_SWAP + * - \ref TDES_WHL_SWAP + * - \ref TDES_OUT_SWAP + * - \ref TDES_OUT_WHL_SWAP + * - \ref TDES_IN_SWAP + * - \ref TDES_IN_WHL_SWAP + * - \ref TDES_IN_OUT_SWAP + * - \ref TDES_IN_OUT_WHL_SWAP + * @return None + */ +void TDES_Open(uint32_t u32Channel, uint32_t u32EncDec, uint32_t u32OpMode, uint32_t u32SwapType) +{ + g_TDES_CTL[u32Channel] = (u32Channel << CRPT_TDES_CTL_CHANNEL_Pos) | + (u32EncDec << CRPT_TDES_CTL_ENCRPT_Pos) | + u32OpMode | CRPT_TDES_CTL_3KEYS_Msk | + (u32SwapType << CRPT_TDES_CTL_BLKSWAP_Pos); +} + +/** + * @brief Start TDES encrypt/decrypt + * @param[in] u32Channel TDES channel. Must be 0~3. + * @param[in] u32DMAMode TDES DMA control, including: + * - \ref CRYPTO_DMA_ONE_SHOT One shop TDES encrypt/decrypt. + * - \ref CRYPTO_DMA_CONTINUE Continuous TDES encrypt/decrypt. + * - \ref CRYPTO_DMA_LAST Last TDES encrypt/decrypt of a series of TDES_Start. + * @return None + */ +void TDES_Start(int32_t u32Channel, uint32_t u32DMAMode) +{ + g_TDES_CTL[u32Channel] |= CRPT_TDES_CTL_START_Msk | (u32DMAMode << CRPT_TDES_CTL_DMALAST_Pos); + CRPT->TDES_CTL = g_TDES_CTL[u32Channel]; +} + +/** + * @brief Set TDES keys + * @param[in] u32Channel TDES channel. Must be 0~3. + * @param[in] au8Keys The TDES keys. + * @return None + */ +void TDES_SetKey(uint32_t u32Channel, uint8_t au8Keys[3][8]) +{ + int i; + uint8_t *pu8TKey; + + pu8TKey = (uint8_t *)((uint32_t)&CRPT->TDES0_KEY1H + (0x40 * u32Channel)); + for (i = 0; i < 3; i++, pu8TKey+=8) + memcpy(pu8TKey, &au8Keys[i][0], 8); +} + +/** + * @brief Set TDES initial vectors + * @param[in] u32Channel TDES channel. Must be 0~3. + * @param[in] u32IVH TDES initial vector high word. + * @param[in] u32IVL TDES initial vector low word. + * @return None + */ +void TDES_SetInitVect(uint32_t u32Channel, uint32_t u32IVH, uint32_t u32IVL) +{ + *(uint32_t *)((uint32_t)&CRPT->TDES0_IVH + 0x40 * u32Channel) = u32IVH; + *(uint32_t *)((uint32_t)&CRPT->TDES0_IVL + 0x40 * u32Channel) = u32IVL; +} + +/** + * @brief Set TDES DMA transfer configuration. + * @param[in] u32Channel TDES channel. Must be 0~3. + * @param[in] u32SrcAddr TDES DMA source address + * @param[in] u32DstAddr TDES DMA destination address + * @param[in] u32TransCnt TDES DMA transfer byte count + * @return None + */ +void TDES_SetDMATransfer(uint32_t u32Channel, uint32_t u32SrcAddr, + uint32_t u32DstAddr, uint32_t u32TransCnt) +{ + *(uint32_t *)((uint32_t)&CRPT->TDES0_SADDR + (u32Channel * 0x40)) = u32SrcAddr; + *(uint32_t *)((uint32_t)&CRPT->TDES0_DADDR + (u32Channel * 0x40)) = u32DstAddr; + *(uint32_t *)((uint32_t)&CRPT->TDES0_CNT + (u32Channel * 0x40)) = u32TransCnt; +} + +/** + * @brief Open SHA encrypt function. + * @param[in] u32OpMode SHA operation mode, including: + * - \ref SHA_MODE_SHA1 + * - \ref SHA_MODE_SHA224 + * - \ref SHA_MODE_SHA256 + * @param[in] u32SwapType is SHA input/output data swap control, including: + * - \ref SHA_NO_SWAP + * - \ref SHA_OUT_SWAP + * - \ref SHA_IN_SWAP + * - \ref SHA_IN_OUT_SWAP + * @return None + */ +void SHA_Open(uint32_t u32OpMode, uint32_t u32SwapType) +{ + CRPT->SHA_CTL = (u32OpMode << CRPT_SHA_CTL_OPMODE_Pos) | + (u32SwapType << CRPT_SHA_CTL_OUTSWAP_Pos); +} + +/** + * @brief Start SHA encrypt + * @param[in] u32DMAMode TDES DMA control, including: + * - \ref CRYPTO_DMA_ONE_SHOT One shop SHA encrypt. + * - \ref CRYPTO_DMA_CONTINUE Continuous SHA encrypt. + * - \ref CRYPTO_DMA_LAST Last SHA encrypt of a series of SHA_Start. + * @return None + */ +void SHA_Start(uint32_t u32DMAMode) +{ + CRPT->SHA_CTL &= ~(0x7 << CRPT_SHA_CTL_DMALAST_Pos); + CRPT->SHA_CTL |= CRPT_SHA_CTL_START_Msk | (u32DMAMode << CRPT_SHA_CTL_DMALAST_Pos); +} + +/** + * @brief Set SHA DMA transfer + * @param[in] u32SrcAddr SHA DMA source address + * @param[in] u32TransCnt SHA DMA transfer byte count + * @return None + */ +void SHA_SetDMATransfer(uint32_t u32SrcAddr, uint32_t u32TransCnt) +{ + CRPT->SHA_SADDR = u32SrcAddr; + CRPT->SHA_DMACNT = u32TransCnt; +} + +/** + * @brief Read the SHA digest. + * @param[out] u32Digest The SHA encrypt output digest. + * @return None + */ +void SHA_Read(uint32_t u32Digest[]) +{ + uint32_t i, wcnt; + + i = (CRPT->SHA_CTL & CRPT_SHA_CTL_OPMODE_Msk) >> CRPT_SHA_CTL_OPMODE_Pos; + if (i == SHA_MODE_SHA1) + wcnt = 5; + else if (i == SHA_MODE_SHA224) + wcnt = 7; + else + wcnt = 8; + + for (i = 0; i < wcnt; i++) + u32Digest[i] = *(uint32_t *)((uint32_t)&(CRPT->SHA_DGST0) + (i * 4)); +} + + +/*@}*/ /* end of group NUC472_442_CRYPTO_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_CRYPTO_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/eadc.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/eadc.c new file mode 100644 index 0000000000000000000000000000000000000000..c316728e751383e36e40aed1cdf9fb4c4a477e5c --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/eadc.c @@ -0,0 +1,208 @@ +/**************************************************************************//** + * @file eadc.c + * @version V1.00 + * $Revision: 7 $ + * $Date: 15/12/01 10:12a $ + * @brief NUC472/NUC442 EADC driver source file + * + * @note + * Copyright (C) 2015 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_EADC_Driver EADC Driver + @{ +*/ + + +/** @addtogroup NUC472_442_EADC_EXPORTED_FUNCTIONS EADC Exported Functions + @{ +*/ + +/** + * @brief This function make EADC_module be ready to convert. + * @param[in] eadc Base address of EADC module. + * @param[in] u32InputMode This parameter is not used. + * @return None + * @details This function is used to set analog input mode and enable A/D Converter. + * Before starting A/D conversion function, ADCEN bit (EADC_CTL[0]) should be set to 1. + * @note + */ +void EADC_Open(EADC_T *eadc, uint32_t u32InputMode) +{ + eadc->CTL |= EADC_CTL_ADCEN_Msk; +} + +/** + * @brief Disable EADC_module. + * @param[in] eadc Base address of EADC module.. + * @return None + * @details Clear ADCEN bit (EADC_CTL[0]) to disable A/D converter analog circuit power consumption. + */ +void EADC_Close(EADC_T *eadc) +{ + eadc->CTL &= ~EADC_CTL_ADCEN_Msk; +} + +/** + * @brief Configure the sample control logic module. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref EADC0_SAMPLE_MODULE4 : EADC0 SAMPLE module 4 + * - \ref EADC0_SAMPLE_MODULE5 : EADC0 SAMPLE module 5 + * - \ref EADC0_SAMPLE_MODULE6 : EADC0 SAMPLE module 6 + * - \ref EADC0_SAMPLE_MODULE7 : EADC0 SAMPLE module 7 + * - \ref EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * - \ref EADC1_SAMPLE_MODULE4 : EADC1 SAMPLE module 4 + * - \ref EADC1_SAMPLE_MODULE5 : EADC1 SAMPLE module 5 + * - \ref EADC1_SAMPLE_MODULE6 : EADC1 SAMPLE module 6 + * - \ref EADC1_SAMPLE_MODULE7 : EADC1 SAMPLE module 7 + * @param[in] u32TriggerSrc Decides the trigger source. Valid values are: + * - \ref EADC_SOFTWARE_TRIGGER : Disable trigger + * - \ref EADC_STADC_TRIGGER : STADC pin trigger + * - \ref EADC_ADINT0_TRIGGER : EADC ADINT0 interrupt EOC pulse trigger + * - \ref EADC_ADINT1_TRIGGER : EADC ADINT1 interrupt EOC pulse trigger + * - \ref EADC_TIMER0_TRIGGER : Timer0 overflow pulse trigger + * - \ref EADC_TIMER1_TRIGGER : Timer1 overflow pulse trigger + * - \ref EADC_TIMER2_TRIGGER : Timer2 overflow pulse trigger + * - \ref EADC_TIMER3_TRIGGER : Timer3 overflow pulse trigger + * - \ref EADC_EPWM0CH0_TRIGGER : EPWM0CH0 trigger + * - \ref EADC_EPWM0CH2_TRIGGER : EPWM0CH2 trigger + * - \ref EADC_EPWM0CH4_TRIGGER : EPWM0CH4 trigger + * - \ref EADC_EPWM1CH0_TRIGGER : EPWM0CH0 trigger + * - \ref EADC_EPWM1CH2_TRIGGER : EPWM0CH2 trigger + * - \ref EADC_EPWM1CH4_TRIGGER : EPWM0CH4 trigger + * - \ref EADC_PWM0CH0_TRIGGER : PWM0CH0 trigger + * - \ref EADC_PWM0CH1_TRIGGER : PWM0CH1 trigger + * @param[in] u32Channel Specifies the sample module channel, valid value are: + * - \ref EADC0_CH0 : EADC0 channel 0 + * - \ref EADC0_CH1 : EADC0 channel 1 + * - \ref EADC0_CH2 : EADC0 channel 2 + * - \ref EADC0_CH3 : EADC0 channel 3 + * - \ref EADC0_CH4 : EADC0 channel 4 + * - \ref EADC0_CH5 : EADC0 channel 5 + * - \ref EADC0_CH6 : EADC0 channel 6 + * - \ref EADC0_CH7 : EADC0 channel 7 + * - \ref EADC0_VBG : EADC0 VBG + * - \ref EADC0_VTEMP : EADC0 VTEMP + * - \ref EADC0_AVSS : EADC0 AVSS + * - \ref EADC0_OP0 : EADC0 OP0 + * - \ref EADC1_CH0 : EADC1 channel 0 + * - \ref EADC1_CH1 : EADC1 channel 1 + * - \ref EADC1_CH2 : EADC1 channel 2 + * - \ref EADC1_CH3 : EADC1 channel 3 + * - \ref EADC1_CH4 : EADC1 channel 4 + * - \ref EADC1_CH5 : EADC1 channel 5 + * - \ref EADC1_CH6 : EADC1 channel 6 + * - \ref EADC1_CH7 : EADC1 channel 7 + * - \ref EADC1_OP1 : EADC1 OP1 + * @return None + * @details Each of EADC control logic modules 0~15 which is configurable for EADC converter channel and trigger source. + */ +void EADC_ConfigSampleModule(EADC_T *eadc, \ + uint32_t u32ModuleNum, \ + uint32_t u32TriggerSrc, \ + uint32_t u32Channel) +{ + *(__IO uint32_t *)(&eadc->AD0SPCTL0 + u32ModuleNum) &= ~(EADC_AD0SPCTL0_TRGSEL_Msk | EADC_AD0SPCTL0_CHSEL_Msk); + *(__IO uint32_t *)(&eadc->AD0SPCTL0 + u32ModuleNum) |= (u32TriggerSrc | u32Channel); + if (u32TriggerSrc == EADC_STADC_TRIGGER) + *(__IO uint32_t *)(&eadc->AD0SPCTL0 + u32ModuleNum) |= (EADC_AD0SPCTL0_EXTREN_Msk | EADC_AD0SPCTL0_EXTFEN_Msk); + +} + + +/** + * @brief Set trigger delay time. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref EADC0_SAMPLE_MODULE4 : EADC0 SAMPLE module 4 + * - \ref EADC0_SAMPLE_MODULE5 : EADC0 SAMPLE module 5 + * - \ref EADC0_SAMPLE_MODULE6 : EADC0 SAMPLE module 6 + * - \ref EADC0_SAMPLE_MODULE7 : EADC0 SAMPLE module 7 + * - \ref EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * - \ref EADC1_SAMPLE_MODULE4 : EADC1 SAMPLE module 4 + * - \ref EADC1_SAMPLE_MODULE5 : EADC1 SAMPLE module 5 + * - \ref EADC1_SAMPLE_MODULE6 : EADC1 SAMPLE module 6 + * - \ref EADC1_SAMPLE_MODULE7 : EADC1 SAMPLE module 7 + * @param[in] u32TriggerDelayTime Decides the trigger delay time, valid range are between 0~0xFF. + * @param[in] u32DelayClockDivider Decides the trigger delay clock divider. Valid values are: + * - \ref EADC_SPCTL_TRGDLYDIV_DIVIDER_1 : Trigger delay clock frequency is ADC_CLK/1 + * - \ref EADC_SPCTL_TRGDLYDIV_DIVIDER_2 : Trigger delay clock frequency is ADC_CLK/2 + * - \ref EADC_SPCTL_TRGDLYDIV_DIVIDER_4 : Trigger delay clock frequency is ADC_CLK/4 + * - \ref EADC_SPCTL_TRGDLYDIV_DIVIDER_16 : Trigger delay clock frequency is ADC_CLK/16 + * @return None + * @details User can configure the trigger delay time by setting TRGDLYCNT (EADC_ADxSPCTLn[15:8], x=0~1, n=0~7) and TRGDLYDIV (EADC_ADxSPCTLn[17:16], x=0~1, n=0~7). + * Trigger delay time = (u32TriggerDelayTime) x Trigger delay clock period. + */ +void EADC_SetTriggerDelayTime(EADC_T *eadc, \ + uint32_t u32ModuleNum, \ + uint32_t u32TriggerDelayTime, \ + uint32_t u32DelayClockDivider) +{ + *(__IO uint32_t *)(&eadc->AD0SPCTL0 + u32ModuleNum) &= ~(EADC_AD0SPCTL0_TRGDLYDIV_Msk | EADC_AD0SPCTL0_TRGDLYCNT_Msk); + *(__IO uint32_t *)(&eadc->AD0SPCTL0 + u32ModuleNum) |= ((u32TriggerDelayTime << EADC_AD0SPCTL0_TRGDLYCNT_Pos) | u32DelayClockDivider); +} + + +/** + * @brief Set EADC extend sample time. + * @param[in] eadc Base address of EADC module. + * @param[in] u32ModuleNum Decides the sample module number, valid values are: + * - \ref EADC0_SAMPLE_MODULE0 : EADC0 SAMPLE module 0 + * - \ref EADC0_SAMPLE_MODULE1 : EADC0 SAMPLE module 1 + * - \ref EADC0_SAMPLE_MODULE2 : EADC0 SAMPLE module 2 + * - \ref EADC0_SAMPLE_MODULE3 : EADC0 SAMPLE module 3 + * - \ref EADC0_SAMPLE_MODULE4 : EADC0 SAMPLE module 4 + * - \ref EADC0_SAMPLE_MODULE5 : EADC0 SAMPLE module 5 + * - \ref EADC0_SAMPLE_MODULE6 : EADC0 SAMPLE module 6 + * - \ref EADC0_SAMPLE_MODULE7 : EADC0 SAMPLE module 7 + * - \ref EADC1_SAMPLE_MODULE0 : EADC1 SAMPLE module 0 + * - \ref EADC1_SAMPLE_MODULE1 : EADC1 SAMPLE module 1 + * - \ref EADC1_SAMPLE_MODULE2 : EADC1 SAMPLE module 2 + * - \ref EADC1_SAMPLE_MODULE3 : EADC1 SAMPLE module 3 + * - \ref EADC1_SAMPLE_MODULE4 : EADC1 SAMPLE module 4 + * - \ref EADC1_SAMPLE_MODULE5 : EADC1 SAMPLE module 5 + * - \ref EADC1_SAMPLE_MODULE6 : EADC1 SAMPLE module 6 + * - \ref EADC1_SAMPLE_MODULE7 : EADC1 SAMPLE module 7 + * @param[in] u32ExtendSampleTime Decides the extend sampling time, the range is from 0~255 EADC clock. Valid value are from 0 to 0xFF. + * @return None + * @details When A/D converting at high conversion rate, the sampling time of analog input voltage may not enough if input channel loading is heavy, + * user can extend A/D sampling time after trigger source is coming to get enough sampling time. + */ +void EADC_SetExtendSampleTime(EADC_T *eadc, uint32_t u32ModuleNum, uint32_t u32ExtendSampleTime) +{ + if (u32ModuleNum < EADC1_SAMPLE_MODULE0) { + eadc->EXTSMPT &= ~EADC_EXTSMPT_EXTSMPT0_Msk; + eadc->EXTSMPT |= u32ExtendSampleTime; + } else { + eadc->EXTSMPT &= ~EADC_EXTSMPT_EXTSMPT1_Msk; + eadc->EXTSMPT |= (u32ExtendSampleTime << EADC_EXTSMPT_EXTSMPT1_Pos); + } +} + +/*@}*/ /* end of group NUC472_442_EADC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_EADC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/ebi.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/ebi.c new file mode 100644 index 0000000000000000000000000000000000000000..83fabaebcf3a15feeed56993cb578aee2ba40e9f --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/ebi.c @@ -0,0 +1,245 @@ +/****************************************************************************//** + * @file ebi.c + * @version V0.10 + * $Revision: 8 $ + * $Date: 15/06/23 5:40p $ + * @brief NUC472/NUC442 EBI driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" +#include "ebi.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_EBI_Driver EBI Driver + @{ +*/ + + +/** @addtogroup NUC472_442_EBI_EXPORTED_FUNCTIONS EBI Exported Functions + @{ +*/ + +/** + * @brief Initialize EBI for Bank 0~3 + * @param[in] u32Bank Bank number for EBI. Valid values are: + * - \ref EBI_BANK0 + * - \ref EBI_BANK1 + * - \ref EBI_BANK2 + * - \ref EBI_BANK3 + * @param[in] u32DataWidth Data bus width. Valid values are: + * - \ref EBI_BUSWIDTH_8BIT + * - \ref EBI_BUSWIDTH_16BIT + * @param[in] u32TimingClass Default timing configuration. Valid values are: + * - \ref EBI_TIMING_FASTEST + * - \ref EBI_TIMING_VERYFAST + * - \ref EBI_TIMING_FAST + * - \ref EBI_TIMING_NORMAL + * - \ref EBI_TIMING_SLOW + * - \ref EBI_TIMING_VERYSLOW + * - \ref EBI_TIMING_SLOWEST + * @param[in] u32BusMode Enable EBI separate mode. Valid values are: + * - \ref EBI_SEPARATEMODE_ENABLE + * - \ref EBI_SEPARATEMODE_DISABLE + * @param[in] u32CSActiveLevel CS is active High/Low. Valid values are: + * - \ref EBI_CS_ACTIVE_HIGH + * - \ref EBI_CS_ACTIVE_LOW + * @return none + */ +void EBI_Open(uint32_t u32Bank, uint32_t u32DataWidth, uint32_t u32TimingClass, uint32_t u32BusMode, uint32_t u32CSActiveLevel) +{ + /* Enable EBI channel */ + EBI->TCTL[u32Bank] |= EBI_TCTL_CSEN_Msk; + + /* Configure data bus to 8 or 16bit */ + if(u32DataWidth == EBI_BUSWIDTH_8BIT) + EBI->TCTL[u32Bank] &= ~EBI_TCTL_DW16_Msk; + else + EBI->TCTL[u32Bank] |= EBI_TCTL_DW16_Msk; + + /* Enable separate mode */ + if(u32BusMode) + EBI->TCTL[u32Bank] |= EBI_TCTL_SEPEN_Msk; + else + EBI->TCTL[u32Bank] &= ~EBI_TCTL_SEPEN_Msk; + + /* Setup active level of chip select */ + switch(u32Bank) { + case EBI_BANK0: + if(u32CSActiveLevel) + EBI->CTL |= (0x1ul << EBI_CTL_CSPOLINV_Pos); + else + EBI->CTL &= ~(0x1ul << EBI_CTL_CSPOLINV_Pos); + break; + + case EBI_BANK1: + if(u32CSActiveLevel) + EBI->CTL |= (0x2ul << EBI_CTL_CSPOLINV_Pos); + else + EBI->CTL &= ~(0x2ul << EBI_CTL_CSPOLINV_Pos); + break; + + case EBI_BANK2: + if(u32CSActiveLevel) + EBI->CTL |= (0x4ul << EBI_CTL_CSPOLINV_Pos); + else + EBI->CTL &= ~(0x4ul << EBI_CTL_CSPOLINV_Pos); + break; + + case EBI_BANK3: + if(u32CSActiveLevel) + EBI->CTL |= (0x8ul << EBI_CTL_CSPOLINV_Pos); + else + EBI->CTL &= ~(0x8ul << EBI_CTL_CSPOLINV_Pos); + break; + } + + /* Clear R2R/R2W/R2X/TAHD/TACC/TALE entries for safety */ + EBI->TCTL[u32Bank] &= ~0x0F0FF7FF; + + /* Setup EBI timing */ + switch(u32TimingClass) { + case EBI_TIMING_FASTEST: + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | ( EBI_MCLKDIV_1 << 8); + break; + + case EBI_TIMING_VERYFAST: + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | ( EBI_MCLKDIV_1 << 8); + EBI->TCTL[u32Bank] |= 0x0303331B; + break; + + case EBI_TIMING_FAST: + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | ( EBI_MCLKDIV_2 << 8); + break; + + case EBI_TIMING_NORMAL: + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | ( EBI_MCLKDIV_2 << 8); + EBI->TCTL[u32Bank] |= 0x0303331B; + break; + + case EBI_TIMING_SLOW: + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | ( EBI_MCLKDIV_2 << 8); + EBI->TCTL[u32Bank] |= 0x0707773F; + break; + + case EBI_TIMING_VERYSLOW: + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | ( EBI_MCLKDIV_4 << 8); + EBI->TCTL[u32Bank] |= 0x0707773F; + break; + + case EBI_TIMING_SLOWEST: + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | ( EBI_MCLKDIV_8 << 8); + EBI->TCTL[u32Bank] |= 0x0707773F; + break; + } +} + +/** + * @brief Disable EBI for bank 0~3. + * @param[in] u32Bank Bank number for EBI. Valid values are: + * - \ref EBI_BANK0 + * - \ref EBI_BANK1 + * - \ref EBI_BANK2 + * - \ref EBI_BANK3 + * @return none + */ +void EBI_Close(uint32_t u32Bank) +{ + EBI->TCTL[u32Bank] &= ~EBI_TCTL_CSEN_Msk; +} + +/** + * @brief Set EBI bus timings + * @param[in] u32Bank Bank number for EBI. Valid values are: + * - \ref EBI_BANK0 + * - \ref EBI_BANK1 + * - \ref EBI_BANK2 + * - \ref EBI_BANK3 + * @param[in] u32TimingConfig The new EBI timing settings. + * @param[in] u32MclkDiv Divider for MCLK. Valid values are: + * - \ref EBI_MCLKDIV_1 + * - \ref EBI_MCLKDIV_2 + * - \ref EBI_MCLKDIV_4 + * - \ref EBI_MCLKDIV_8 + * - \ref EBI_MCLKDIV_16 + * - \ref EBI_MCLKDIV_32 + * @return none + */ +void EBI_SetBusTiming(uint32_t u32Bank, uint32_t u32TimingConfig, uint32_t u32MclkDiv) +{ + EBI->CTL = (EBI->CTL & ~EBI_CTL_MCLKDIV_Msk) | (u32MclkDiv << EBI_CTL_MCLKDIV_Pos); + EBI->TCTL[u32Bank] |= (u32TimingConfig & 0x0F0FF7FF); +} + +/** + * @brief Enable encrypt/decrypt function and set key for EBI bank 0~3. + * @param[in] u32Bank Bank number for EBI. Valid values are: + * - \ref EBI_BANK0 + * - \ref EBI_BANK1 + * - \ref EBI_BANK2 + * - \ref EBI_BANK3 + * @param[in] *u32Key 128-bits encrypt/decrypt key array. + * @return none + */ +void EBI_EnableCrypto(uint32_t u32Bank, uint32_t *u32Key) +{ + switch(u32Bank) { + case EBI_BANK0: + EBI->CTL |= (0x1ul << EBI_CTL_CRYPTOEN_Pos); + break; + case EBI_BANK1: + EBI->CTL |= (0x2ul << EBI_CTL_CRYPTOEN_Pos); + break; + case EBI_BANK2: + EBI->CTL |= (0x4ul << EBI_CTL_CRYPTOEN_Pos); + break; + case EBI_BANK3: + EBI->CTL |= (0x8ul << EBI_CTL_CRYPTOEN_Pos); + break; + } + + /* Setup 128-bits key */ + EBI->KEY0 = u32Key[0]; + EBI->KEY1 = u32Key[1]; + EBI->KEY2 = u32Key[2]; + EBI->KEY3 = u32Key[3]; +} + +/** + * @brief Disable encrypt/decrypt function for EBI bank 0~3. + * @param[in] u32Bank Bank number for EBI. Valid values are: + * - \ref EBI_BANK0 + * - \ref EBI_BANK1 + * - \ref EBI_BANK2 + * - \ref EBI_BANK3 + * @return none + */ +void EBI_DisbleCrypto(uint32_t u32Bank) +{ + switch(u32Bank) { + case EBI_BANK0: + EBI->CTL &= ~(0x1ul << EBI_CTL_CRYPTOEN_Pos); + break; + case EBI_BANK1: + EBI->CTL &= ~(0x2ul << EBI_CTL_CRYPTOEN_Pos); + break; + case EBI_BANK2: + EBI->CTL &= ~(0x4ul << EBI_CTL_CRYPTOEN_Pos); + break; + case EBI_BANK3: + EBI->CTL &= ~(0x8ul << EBI_CTL_CRYPTOEN_Pos); + break; + } +} + +/*@}*/ /* end of group NUC472_442_EBI_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_EBI_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/emac.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/emac.c new file mode 100644 index 0000000000000000000000000000000000000000..92e7c40e5c333c640a52831af674cbb15e27f74b --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/emac.c @@ -0,0 +1,876 @@ +/**************************************************************************//** + * @file emac.c + * @version V1.00 + * $Revision: 17 $ + * $Date: 15/11/19 6:57p $ + * @brief NUC472/NUC442 EMAC driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include +#include +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_EMAC_Driver EMAC Driver + @{ +*/ + + +// Below are structure, definitions, static variables used locally by EMAC driver and does not want to parse by doxygen unless HIDDEN_SYMBOLS is defined +/// @cond HIDDEN_SYMBOLS + +/** @addtogroup NUC472_442_EMAC_EXPORTED_CONSTANTS EMAC Exported Constants + @{ +*/ +// Un-comment to print EMAC debug message +#define EMAC_DBG +#ifndef EMAC_DBG +#define printf(...) +#endif + +// PHY Register Description +#define PHY_CNTL_REG 0x00 ///< PHY control register address +#define PHY_STATUS_REG 0x01 ///< PHY status register address +#define PHY_ID1_REG 0x02 ///< PHY ID1 register +#define PHY_ID2_REG 0x03 ///< PHY ID2 register +#define PHY_ANA_REG 0x04 ///< PHY auto-negotiation advertisement register +#define PHY_ANLPA_REG 0x05 ///< PHY auto-negotiation link partner availability register +#define PHY_ANE_REG 0x06 ///< PHY auto-negotiation expansion register + +//PHY Control Register +#define PHY_CNTL_RESET_PHY (1 << 15) +#define PHY_CNTL_DR_100MB (1 << 13) +#define PHY_CNTL_ENABLE_AN (1 << 12) +#define PHY_CNTL_POWER_DOWN (1 << 11) +#define PHY_CNTL_RESTART_AN (1 << 9) +#define PHY_CNTL_FULLDUPLEX (1 << 8) + +// PHY Status Register +#define PHY_STATUS_AN_COMPLETE (1 << 5) +#define PHY_STATUS_LINK_VALID (1 << 2) + +// PHY Auto-negotiation Advertisement Register +#define PHY_ANA_DR100_TX_FULL (1 << 8) +#define PHY_ANA_DR100_TX_HALF (1 << 7) +#define PHY_ANA_DR10_TX_FULL (1 << 6) +#define PHY_ANA_DR10_TX_HALF (1 << 5) +#define PHY_ANA_IEEE_802_3_CSMA_CD (1 << 0) + +// PHY Auto-negotiation Link Partner Advertisement Register +#define PHY_ANLPA_DR100_TX_FULL (1 << 8) +#define PHY_ANLPA_DR100_TX_HALF (1 << 7) +#define PHY_ANLPA_DR10_TX_FULL (1 << 6) +#define PHY_ANLPA_DR10_TX_HALF (1 << 5) + +// EMAC Tx/Rx descriptor's owner bit +#define EMAC_DESC_OWN_EMAC 0x80000000 ///< Set owner to EMAC +#define EMAC_DESC_OWN_CPU 0x00000000 ///< Set owner to CPU + +// Rx Frame Descriptor Status +#define EMAC_RXFD_RTSAS 0x0080 ///< Time Stamp Available +#define EMAC_RXFD_RP 0x0040 ///< Runt Packet +#define EMAC_RXFD_ALIE 0x0020 ///< Alignment Error +#define EMAC_RXFD_RXGD 0x0010 ///< Receiving Good packet received +#define EMAC_RXFD_PTLE 0x0008 ///< Packet Too Long Error +#define EMAC_RXFD_CRCE 0x0002 ///< CRC Error +#define EMAC_RXFD_RXINTR 0x0001 ///< Interrupt on receive + +// Tx Frame Descriptor's Control bits +#define EMAC_TXFD_TTSEN 0x08 ///< Tx time stamp enable +#define EMAC_TXFD_INTEN 0x04 ///< Tx interrupt enable +#define EMAC_TXFD_CRCAPP 0x02 ///< Append CRC +#define EMAC_TXFD_PADEN 0x01 ///< Padding mode enable + +// Tx Frame Descriptor Status +#define EMAC_TXFD_TXINTR 0x0001 ///< Interrupt on Transmit +#define EMAC_TXFD_DEF 0x0002 ///< Transmit deferred +#define EMAC_TXFD_TXCP 0x0008 ///< Transmission Completion +#define EMAC_TXFD_EXDEF 0x0010 ///< Exceed Deferral +#define EMAC_TXFD_NCS 0x0020 ///< No Carrier Sense Error +#define EMAC_TXFD_TXABT 0x0040 ///< Transmission Abort +#define EMAC_TXFD_LC 0x0080 ///< Late Collision +#define EMAC_TXFD_TXHA 0x0100 ///< Transmission halted +#define EMAC_TXFD_PAU 0x0200 ///< Paused +#define EMAC_TXFD_SQE 0x0400 ///< SQE error +#define EMAC_TXFD_TTSAS 0x0800 ///< Time Stamp available + +/*@}*/ /* end of group NUC472_442_EMAC_EXPORTED_CONSTANTS */ + +/** @addtogroup NUC472_442_EMAC_EXPORTED_TYPEDEF EMAC Exported Type Defines + @{ +*/ + +/** Tx/Rx buffer descriptor structure */ +typedef struct { + uint32_t u32Status1; ///< Status word 1 + uint32_t u32Data; ///< Pointer to data buffer + uint32_t u32Status2; ///< Status word 2 + uint32_t u32Next; ///< Pointer to next descriptor + uint32_t u32Backup1; ///< For backup descriptor fields over written by time stamp + uint32_t u32Backup2; ///< For backup descriptor fields over written by time stamp +} EMAC_DESCRIPTOR_T; + +/** Tx/Rx buffer structure */ +typedef struct { + uint8_t au8Buf[1520]; +} EMAC_FRAME_T; + +/*@}*/ /* end of group NUC472_442_EMAC_EXPORTED_TYPEDEF */ + +// local variables +static volatile EMAC_DESCRIPTOR_T rx_desc[EMAC_RX_DESC_SIZE]; +static volatile EMAC_FRAME_T rx_buf[EMAC_RX_DESC_SIZE]; +static volatile EMAC_DESCRIPTOR_T tx_desc[EMAC_TX_DESC_SIZE]; +static volatile EMAC_FRAME_T tx_buf[EMAC_TX_DESC_SIZE]; + + +static uint32_t u32CurrentTxDesc, u32NextTxDesc, u32CurrentRxDesc; +static uint32_t s_u32EnableTs = 0; + +/** @addtogroup NUC472_442_EMAC_EXPORTED_FUNCTIONS EMAC Exported Functions + @{ +*/ + +/** + * @brief Trigger EMAC Rx function + * @param None + * @return None + */ +#define EMAC_TRIGGER_RX() do{EMAC->RXST = 0;}while(0) + +/** + * @brief Trigger EMAC Tx function + * @param None + * @return None + */ +#define EMAC_TRIGGER_TX() do{EMAC->TXST = 0;}while(0) + +/** + * @brief Write PHY register + * @param[in] u32Reg PHY register number + * @param[in] u32Addr PHY address, this address is board dependent + * @param[in] u32Data data to write to PHY register + * @return None + */ +static void EMAC_MdioWrite(uint32_t u32Reg, uint32_t u32Addr, uint32_t u32Data) +{ + // Set data register + EMAC->MIIMDAT = u32Data ; + // Set PHY address, PHY register address, busy bit and write bit + EMAC->MIIMCTL = u32Reg | (u32Addr << 8) | EMAC_MIIMCTL_BUSY_Msk | EMAC_MIIMCTL_WRITE_Msk | EMAC_MIIMCTL_MDCON_Msk; + // Wait write complete by polling busy bit. + while(EMAC->MIIMCTL & EMAC_MIIMCTL_BUSY_Msk); + +} + +/** + * @brief Read PHY register + * @param[in] u32Reg PHY register number + * @param[in] u32Addr PHY address, this address is board dependent + * @return Value read from PHY register + */ +static uint32_t EMAC_MdioRead(uint32_t u32Reg, uint32_t u32Addr) +{ + // Set PHY address, PHY register address, busy bit + EMAC->MIIMCTL = u32Reg | (u32Addr << EMAC_MIIMCTL_PHYADDR_Pos) | EMAC_MIIMCTL_BUSY_Msk | EMAC_MIIMCTL_MDCON_Msk; + // Wait read complete by polling busy bit + while(EMAC->MIIMCTL & EMAC_MIIMCTL_BUSY_Msk); + // Get return data + return EMAC->MIIMDAT; +} + + +/** + * @brief Initialize PHY chip, check for the auto-negotiation result. + * @param None + * @return None + */ +static void EMAC_PhyInit(void) +{ + uint32_t reg; + uint32_t i = 0; + + // Reset Phy Chip + EMAC_MdioWrite(PHY_CNTL_REG, EMAC_PHY_ADDR, PHY_CNTL_RESET_PHY); + + // Wait until reset complete + while (1) { + reg = EMAC_MdioRead(PHY_CNTL_REG, EMAC_PHY_ADDR) ; + if ((reg & PHY_CNTL_RESET_PHY)==0) + break; + } + while(!(EMAC_MdioRead(PHY_STATUS_REG, EMAC_PHY_ADDR) & PHY_STATUS_LINK_VALID)) { + if(i++ > 80000) { // Cable not connected + printf("Unplugged..\n"); + EMAC->CTL &= ~EMAC_CTL_OPMODE_Msk; + EMAC->CTL &= ~EMAC_CTL_FUDUP_Msk; + return; + } + } + // Configure auto negotiation capability + EMAC_MdioWrite(PHY_ANA_REG, EMAC_PHY_ADDR, PHY_ANA_DR100_TX_FULL | + PHY_ANA_DR100_TX_HALF | + PHY_ANA_DR10_TX_FULL | + PHY_ANA_DR10_TX_HALF | + PHY_ANA_IEEE_802_3_CSMA_CD); + // Restart auto negotiation + EMAC_MdioWrite(PHY_CNTL_REG, EMAC_PHY_ADDR, EMAC_MdioRead(PHY_CNTL_REG, EMAC_PHY_ADDR) | PHY_CNTL_RESTART_AN); + + // Wait for auto-negotiation complete + while(!(EMAC_MdioRead(PHY_STATUS_REG, EMAC_PHY_ADDR) & PHY_STATUS_AN_COMPLETE)); + + // Check link valid again. Some PHYs needs to check result after link valid bit set + while(!(EMAC_MdioRead(PHY_STATUS_REG, EMAC_PHY_ADDR) & PHY_STATUS_LINK_VALID)); + + // Check link partner capability + reg = EMAC_MdioRead(PHY_ANLPA_REG, EMAC_PHY_ADDR) ; + if (reg & PHY_ANLPA_DR100_TX_FULL) { + printf("100F\n"); + EMAC->CTL |= EMAC_CTL_OPMODE_Msk; + EMAC->CTL |= EMAC_CTL_FUDUP_Msk; + } else if (reg & PHY_ANLPA_DR100_TX_HALF) { + printf("100H\n"); + EMAC->CTL |= EMAC_CTL_OPMODE_Msk; + EMAC->CTL &= ~EMAC_CTL_FUDUP_Msk; + } else if (reg & PHY_ANLPA_DR10_TX_FULL) { + printf("10F\n"); + EMAC->CTL &= ~EMAC_CTL_OPMODE_Msk; + EMAC->CTL |= EMAC_CTL_FUDUP_Msk; + } else { + printf("10H\n"); + EMAC->CTL &= ~EMAC_CTL_OPMODE_Msk; + EMAC->CTL &= ~EMAC_CTL_FUDUP_Msk; + } +} + +/** + * @brief Initial EMAC Tx descriptors and get Tx descriptor base address + * @param None + * @return None + */ +static void EMAC_TxDescInit(void) +{ + uint32_t i; + + // Get Frame descriptor's base address. + EMAC->TXDSA = (uint32_t)&tx_desc[0]; + u32NextTxDesc = u32CurrentTxDesc = (uint32_t)&tx_desc[0]; + + for(i = 0; i < EMAC_TX_DESC_SIZE; i++) { + + if(s_u32EnableTs) + tx_desc[i].u32Status1 = EMAC_TXFD_PADEN | EMAC_TXFD_CRCAPP | EMAC_TXFD_INTEN; + else + tx_desc[i].u32Status1 = EMAC_TXFD_PADEN | EMAC_TXFD_CRCAPP | EMAC_TXFD_INTEN | EMAC_TXFD_TTSEN; + + tx_desc[i].u32Data = (uint32_t)((uint32_t)&tx_buf[i]); + tx_desc[i].u32Backup1 = tx_desc[i].u32Data; + tx_desc[i].u32Status2 = 0; + tx_desc[i].u32Next = (uint32_t)&tx_desc[(i + 1) % EMAC_TX_DESC_SIZE]; + tx_desc[i].u32Backup2 = tx_desc[i].u32Next; + + } + +} + + +/** + * @brief Initial EMAC Rx descriptors and get Rx descriptor base address + * @param None + * @return None + */ +static void EMAC_RxDescInit(void) +{ + + uint32_t i; + + // Get Frame descriptor's base address. + EMAC->RXDSA = (uint32_t)&rx_desc[0]; + u32CurrentRxDesc = (uint32_t)&rx_desc[0]; + + for(i=0; i < EMAC_RX_DESC_SIZE; i++) { + rx_desc[i].u32Status1 = EMAC_DESC_OWN_EMAC; + rx_desc[i].u32Data = (uint32_t)((uint32_t)&rx_buf[i]); + rx_desc[i].u32Backup1 = rx_desc[i].u32Data; + rx_desc[i].u32Status2 = 0; + rx_desc[i].u32Next = (uint32_t)&rx_desc[(i + 1) % EMAC_RX_DESC_SIZE]; + rx_desc[i].u32Backup2 = rx_desc[i].u32Next; + } + +} + +/** + * @brief Convert subsecond value to nano second + * @param[in] subsec Subsecond value to be convert + * @return Nano second + */ +static uint32_t EMAC_Subsec2Nsec(uint32_t subsec) +{ + // 2^31 subsec == 10^9 ns + uint64_t i; + i = 1000000000ll * subsec; + i >>= 31; + return(i); +} + +/** + * @brief Convert nano second to subsecond value + * @param[in] nsec Nano second to be convert + * @return Subsecond + */ +static uint32_t EMAC_Nsec2Subsec(uint32_t nsec) +{ + // 10^9 ns = 2^31 subsec + uint64_t i; + i = (1ll << 31) * nsec; + i /= 1000000000; + return(i); +} + + +/*@}*/ /* end of group NUC472_442_EMAC_EXPORTED_FUNCTIONS */ + + + +/// @endcond HIDDEN_SYMBOLS + + +/** @addtogroup NUC472_442_EMAC_EXPORTED_FUNCTIONS EMAC Exported Functions + @{ +*/ + + +// Basic configuration functions +/** + * @brief Initialize EMAC interface, including descriptors, MAC address, and PHY. + * @param[in] pu8MacAddr Pointer to uint8_t array holds MAC address + * @return None + * @note This API sets EMAC to work in RMII mode, but could configure to MII mode later with \ref EMAC_ENABLE_MII_INTF macro + * @note This API configures EMAC to receive all broadcast and multicast packets, but could configure to other settings with + * \ref EMAC_ENABLE_RECV_BCASTPKT, \ref EMAC_DISABLE_RECV_BCASTPKT, \ref EMAC_ENABLE_RECV_MCASTPKT, and \ref EMAC_DISABLE_RECV_MCASTPKT + * @note Receive(RX) and transmit(TX) are not enabled yet, application must call \ref EMAC_ENABLE_RX and \ref EMAC_ENABLE_TX to + * enable receive and transmit function. + */ +void EMAC_Open(uint8_t *pu8MacAddr) +{ + // Enable transmit and receive descriptor + EMAC_TxDescInit(); + EMAC_RxDescInit(); + + // Set the CAM Control register and the MAC address value + EMAC_SetMacAddr(pu8MacAddr); + + // Configure the MAC interrupt enable register. + EMAC->INTEN = EMAC_INTEN_RXIEN_Msk | + EMAC_INTEN_TXIEN_Msk | + EMAC_INTEN_RXGDIEN_Msk | + EMAC_INTEN_TXCPIEN_Msk | + EMAC_INTEN_RXBEIEN_Msk | + EMAC_INTEN_TXBEIEN_Msk | + EMAC_INTEN_RDUIEN_Msk | + EMAC_INTEN_TSALMIEN_Msk | + EMAC_INTEN_WOLIEN_Msk; + + // Configure the MAC control register. + EMAC->CTL = EMAC_CTL_STRIPCRC_Msk | + EMAC_CTL_RMIIEN_Msk | + EMAC_CTL_RMIIRXCTL_Msk; + + //Accept packets for us and all broadcast and multicast packets + EMAC->CAMCTL = EMAC_CAMCTL_CMPEN_Msk | + EMAC_CAMCTL_AMP_Msk | + EMAC_CAMCTL_ABP_Msk; + + EMAC_PhyInit(); +} + +/** + * @brief This function stop all receive and transmit activity and disable MAC interface + * @param None + * @return None + */ + +void EMAC_Close(void) +{ + EMAC->CTL |= EMAC_CTL_RST_Msk; +} + +/** + * @brief Set the device MAC address + * @param[in] pu8MacAddr Pointer to uint8_t array holds MAC address + * @return None + */ +void EMAC_SetMacAddr(uint8_t *pu8MacAddr) +{ + EMAC_EnableCamEntry(0, pu8MacAddr); + +} + +/** + * @brief Fill a CAM entry for MAC address comparison. + * @param[in] u32Entry MAC entry to fill. Entry 0 is used to store device MAC address, do not overwrite the setting in it. + * @param[in] pu8MacAddr Pointer to uint8_t array holds MAC address + * @return None + */ +void EMAC_EnableCamEntry(uint32_t u32Entry, uint8_t *pu8MacAddr) +{ + uint32_t u32Lsw, u32Msw; + + u32Lsw = (pu8MacAddr[4] << 24) | + (pu8MacAddr[5] << 16); + u32Msw = (pu8MacAddr[0] << 24)| + (pu8MacAddr[1] << 16)| + (pu8MacAddr[2] << 8)| + pu8MacAddr[3]; + + *(uint32_t volatile *)(&EMAC->CAM0M + u32Entry * 2) = u32Msw; + *(uint32_t volatile *)(&EMAC->CAM0L + u32Entry * 2) = u32Lsw; + + EMAC->CAMEN |= (1 << u32Entry); +} + +/** + * @brief Disable a specified CAM entry + * @param[in] u32Entry CAM entry to be disabled + * @return None + */ +void EMAC_DisableCamEntry(uint32_t u32Entry) +{ + EMAC->CAMEN &= ~(1 << u32Entry); +} + +// Receive functions +/** + * @brief Receive an Ethernet packet + * @param[in] pu8Data Pointer to a buffer to store received packet (4 byte CRC removed) + * @param[in] pu32Size Received packet size (without 4 byte CRC). + * @return Packet receive success or not + * @retval 0 No packet available for receive + * @retval 1 A packet is received + * @note Return 0 doesn't guarantee the packet will be sent and received successfully. + */ +uint32_t EMAC_RecvPkt(uint8_t *pu8Data, uint32_t *pu32Size) +{ + EMAC_DESCRIPTOR_T *desc; + uint32_t status, reg; + uint32_t u32Count = 0; + + // Clear Rx interrupt flags + reg = EMAC->INTSTS; + EMAC->INTSTS = reg & 0xFFFF; // Clear all RX related interrupt status + + if (reg & EMAC_INTSTS_RXBEIF_Msk) { + // Bus error occurred, this is usually a bad sign about software bug and will occur again... + printf("RX bus error\n"); + } else { + + // Get Rx Frame Descriptor + desc = (EMAC_DESCRIPTOR_T *)u32CurrentRxDesc; + + // If we reach last recv Rx descriptor, leave the loop + //if(EMAC->CRXDSA == (uint32_t)desc) + // return(0); + if ((desc->u32Status1 & EMAC_DESC_OWN_EMAC) != EMAC_DESC_OWN_EMAC) { // ownership=CPU + + status = desc->u32Status1 >> 16; + + // If Rx frame is good, process received frame + if(status & EMAC_RXFD_RXGD) { + // lower 16 bit in descriptor status1 stores the Rx packet length + *pu32Size = desc->u32Status1 & 0xffff; + memcpy(pu8Data, (uint8_t *)desc->u32Backup1, *pu32Size); + u32Count = 1; + } else { + // Save Error status if necessary + if (status & EMAC_RXFD_RP); + if (status & EMAC_RXFD_ALIE); + if (status & EMAC_RXFD_PTLE); + if (status & EMAC_RXFD_CRCE); + } + } + } + return(u32Count); +} + +/** + * @brief Receive an Ethernet packet and the time stamp while it's received + * @param[out] pu8Data Pointer to a buffer to store received packet (4 byte CRC removed) + * @param[out] pu32Size Received packet size (without 4 byte CRC). + * @param[out] pu32Sec Second value while packet sent + * @param[out] pu32Nsec Nano second value while packet sent + * @return Packet receive success or not + * @retval 0 No packet available for receive + * @retval 1 A packet is received + * @note Return 0 doesn't guarantee the packet will be sent and received successfully. + * @note Largest Ethernet packet is 1514 bytes after stripped CRC, application must give + * a buffer large enough to store such packet + */ +uint32_t EMAC_RecvPktTS(uint8_t *pu8Data, uint32_t *pu32Size, uint32_t *pu32Sec, uint32_t *pu32Nsec) +{ + EMAC_DESCRIPTOR_T *desc; + uint32_t status, reg; + uint32_t u32Count = 0; + + // Clear Rx interrupt flags + reg = EMAC->INTSTS; + EMAC->INTSTS = reg & 0xFFFF; // Clear all Rx related interrupt status + + if (reg & EMAC_INTSTS_RXBEIF_Msk) { + // Bus error occurred, this is usually a bad sign about software bug and will occur again... + printf("RX bus error\n"); + } else { + + // Get Rx Frame Descriptor + desc = (EMAC_DESCRIPTOR_T *)u32CurrentRxDesc; + + // If we reach last recv Rx descriptor, leave the loop + if(EMAC->CRXDSA == (uint32_t)desc) + return(0); + if ((desc->u32Status1 | EMAC_DESC_OWN_EMAC) != EMAC_DESC_OWN_EMAC) { // ownership=CPU + + status = desc->u32Status1 >> 16; + + // If Rx frame is good, process received frame + if(status & EMAC_RXFD_RXGD) { + // lower 16 bit in descriptor status1 stores the Rx packet length + *pu32Size = desc->u32Status1 & 0xffff; + memcpy(pu8Data, (uint8_t *)desc->u32Backup1, *pu32Size); + + *pu32Sec = desc->u32Next; // second stores in descriptor's NEXT field + *pu32Nsec = EMAC_Subsec2Nsec(desc->u32Data); // Sub nano second store in DATA field + + u32Count = 1; + } else { + // Save Error status if necessary + if (status & EMAC_RXFD_RP); + if (status & EMAC_RXFD_ALIE); + if (status & EMAC_RXFD_PTLE); + if (status & EMAC_RXFD_CRCE); + } + } + } + return(u32Count); +} + +/** + * @brief Clean up process after a packet is received + * @param None + * @return None + * @details EMAC Rx interrupt service routine \b must call this API to release the resource use by receive process + * @note Application can only call this function once every time \ref EMAC_RecvPkt or \ref EMAC_RecvPktTS returns 1 + */ +void EMAC_RecvPktDone(void) +{ + EMAC_DESCRIPTOR_T *desc; + // Get Rx Frame Descriptor + desc = (EMAC_DESCRIPTOR_T *)u32CurrentRxDesc; + + // restore descriptor link list and data pointer they will be overwrite if time stamp enabled + desc->u32Data = desc->u32Backup1; + desc->u32Next = desc->u32Backup2; + + // Change ownership to DMA for next use + desc->u32Status1 |= EMAC_DESC_OWN_EMAC; + + // Get Next Frame Descriptor pointer to process + desc = (EMAC_DESCRIPTOR_T *)desc->u32Next; + + // Save last processed Rx descriptor + u32CurrentRxDesc = (uint32_t)desc; + + EMAC_TRIGGER_RX(); +} + +// Transmit functions + +/** + * @brief Send an Ethernet packet + * @param[in] pu8Data Pointer to a buffer holds the packet to transmit + * @param[in] u32Size Packet size (without 4 byte CRC). + * @return Packet transmit success or not + * @retval 0 Transmit failed due to descriptor unavailable. + * @retval 1 Packet is copied to descriptor and triggered to transmit. + * @note Return 1 doesn't guarantee the packet will be sent and received successfully. + */ +uint32_t EMAC_SendPkt(uint8_t *pu8Data, uint32_t u32Size) +{ + EMAC_DESCRIPTOR_T *desc; + uint32_t status; + + // Get Tx frame descriptor & data pointer + desc = (EMAC_DESCRIPTOR_T *)u32NextTxDesc; + + status = desc->u32Status1; + + // Check descriptor ownership + if((status & EMAC_DESC_OWN_EMAC)) + return(0); + + memcpy((uint8_t *)desc->u32Data, pu8Data, u32Size); + + // Set Tx descriptor transmit byte count + desc->u32Status2 = u32Size; + + // Change descriptor ownership to EMAC + desc->u32Status1 |= EMAC_DESC_OWN_EMAC; + + // Get next Tx descriptor + u32NextTxDesc = (uint32_t)(desc->u32Next); + + // Trigger EMAC to send the packet + EMAC_TRIGGER_TX(); + + return(1); +} + + +/** + * @brief Clean up process after packet(s) are sent + * @param None + * @return Number of packet sent between two function calls + * @details EMAC Tx interrupt service routine \b must call this API or \ref EMAC_SendPktDoneTS to + * release the resource use by transmit process + */ +uint32_t EMAC_SendPktDone(void) +{ + EMAC_DESCRIPTOR_T *desc; + uint32_t status, reg; + uint32_t last_tx_desc; + uint32_t u32Count = 0; + + reg = EMAC->INTSTS; + // Clear Tx interrupt flags + EMAC->INTSTS = reg & (0xFFFF0000 & ~EMAC_INTSTS_TSALMIF_Msk); + + + if (reg & EMAC_INTSTS_TXBEIF_Msk) { + // Bus error occurred, this is usually a bad sign about software bug and will occur again... + printf("TX bus error\n"); + } else { + // Process the descriptor(s). + last_tx_desc = EMAC->CTXDSA ; + // Get our first descriptor to process + desc = (EMAC_DESCRIPTOR_T *) u32CurrentTxDesc; + do { + // Descriptor ownership is still EMAC, so this packet haven't been send. + if(desc->u32Status1 & EMAC_DESC_OWN_EMAC) + break; + // Get Tx status stored in descriptor + status = desc->u32Status2 >> 16; + if (status & EMAC_TXFD_TXCP) { + u32Count++; + } else { + // Do nothing here on error. + if (status & EMAC_TXFD_TXABT); + if (status & EMAC_TXFD_DEF); + if (status & EMAC_TXFD_PAU); + if (status & EMAC_TXFD_EXDEF); + if (status & EMAC_TXFD_NCS); + if (status & EMAC_TXFD_SQE); + if (status & EMAC_TXFD_LC); + if (status & EMAC_TXFD_TXHA); + } + + // restore descriptor link list and data pointer they will be overwrite if time stamp enabled + desc->u32Data = desc->u32Backup1; + desc->u32Next = desc->u32Backup2; + // go to next descriptor in link + desc = (EMAC_DESCRIPTOR_T *)desc->u32Next; + } while (last_tx_desc != (uint32_t)desc); // If we reach last sent Tx descriptor, leave the loop + // Save last processed Tx descriptor + u32CurrentTxDesc = (uint32_t)desc; + } + return(u32Count); +} + +/** + * @brief Clean up process after a packet is sent, and get the time stamp while packet is sent + * @param[in] pu32Sec Second value while packet sent + * @param[in] pu32Nsec Nano second value while packet sent + * @return If a packet sent successfully + * @retval 0 No packet sent successfully, and the value in *pu32Sec and *pu32Nsec are meaningless + * @retval 1 A packet sent successfully, and the value in *pu32Sec and *pu32Nsec is the time stamp while packet sent + * @details EMAC Tx interrupt service routine \b must call this API or \ref EMAC_SendPktDone to + * release the resource use by transmit process + */ +uint32_t EMAC_SendPktDoneTS(uint32_t *pu32Sec, uint32_t *pu32Nsec) +{ + + EMAC_DESCRIPTOR_T *desc; + uint32_t status, reg; + uint32_t u32Count = 0; + + reg = EMAC->INTSTS; + // Clear Tx interrupt flags + EMAC->INTSTS = reg & (0xFFFF0000 & ~EMAC_INTSTS_TSALMIF_Msk); + + + if (reg & EMAC_INTSTS_TXBEIF_Msk) { + // Bus error occurred, this is usually a bad sign about software bug and will occur again... + printf("TX bus error\n"); + } else { + // Process the descriptor. + // Get our first descriptor to process + desc = (EMAC_DESCRIPTOR_T *) u32CurrentTxDesc; + + // Descriptor ownership is still EMAC, so this packet haven't been send. + if(desc->u32Status1 & EMAC_DESC_OWN_EMAC) + return(0); + // Get Tx status stored in descriptor + status = desc->u32Status2 >> 16; + if (status & EMAC_TXFD_TXCP) { + u32Count = 1; + *pu32Sec = desc->u32Next; // second stores in descriptor's NEXT field + *pu32Nsec = EMAC_Subsec2Nsec(desc->u32Data); // Sub nano second store in DATA field + } else { + // Do nothing here on error. + if (status & EMAC_TXFD_TXABT); + if (status & EMAC_TXFD_DEF); + if (status & EMAC_TXFD_PAU); + if (status & EMAC_TXFD_EXDEF); + if (status & EMAC_TXFD_NCS); + if (status & EMAC_TXFD_SQE); + if (status & EMAC_TXFD_LC); + if (status & EMAC_TXFD_TXHA); + } + + // restore descriptor link list and data pointer they will be overwrite if time stamp enabled + desc->u32Data = desc->u32Backup1; + desc->u32Next = desc->u32Backup2; + // go to next descriptor in link + desc = (EMAC_DESCRIPTOR_T *)desc->u32Next; + + // Save last processed Tx descriptor + u32CurrentTxDesc = (uint32_t)desc; + } + + return(u32Count); +} + +// IEEE 1588 functions +/** + * @brief Enable IEEE1588 time stamp function and set current time + * @param[in] u32Sec Second value + * @param[in] u32Nsec Nano second value + * @return None + */ +void EMAC_EnableTS(uint32_t u32Sec, uint32_t u32Nsec) +{ + double f; + uint32_t reg; + EMAC->TSCTL = EMAC_TSCTL_TSEN_Msk; + EMAC->UPDSEC = u32Sec; // Assume current time is 0 sec + 0 nano sec + EMAC->UPDSUBSEC = EMAC_Nsec2Subsec(u32Nsec); + + // PTP source clock is 84MHz (Real chip using PLL). Each tick is 11.90ns + // Assume we want to set each tick to 100ns. + // Increase register = (100 * 2^31) / (10^9) = 214.71 =~ 215 = 0xD7 + // Addend register = 2^32 * tick_freq / (84MHz), where tick_freq = (2^31 / 215) MHz + // From above equation, addend register = 2^63 / (84M * 215) ~= 510707200 = 0x1E70C600 + // So: + // EMAC->TSIR = 0xD7; + // EMAC->TSAR = 0x1E70C600; + f = (100.0 * 2147483648.0) / (1000000000.0) + 0.5; + EMAC->TSINC = (reg = (uint32_t)f); + f = (double)9223372036854775808.0 / ((double)(CLK_GetHCLKFreq()) * (double)reg); + EMAC->TSADDEND = (uint32_t)f; + EMAC->TSCTL |= (EMAC_TSCTL_TSUPDATE_Msk | EMAC_TSCTL_TSIEN_Msk | EMAC_TSCTL_TSMODE_Msk); // Fine update +} + +/** + * @brief Disable IEEE1588 time stamp function + * @param None + * @return None + */ +void EMAC_DisableTS(void) +{ + EMAC->TSCTL = 0; +} + +/** + * @brief Get current time stamp + * @param[out] pu32Sec Current second value + * @param[out] pu32Nsec Current nano second value + * @return None + */ +void EMAC_GetTime(uint32_t *pu32Sec, uint32_t *pu32Nsec) +{ + // Must read TSLSR firstly. Hardware will preserve TSMSR value at the time TSLSR read. + *pu32Nsec = EMAC_Subsec2Nsec(EMAC->TSSUBSEC); + *pu32Sec = EMAC->TSSEC; +} + +/** + * @brief Set current time stamp + * @param[in] u32Sec Second value + * @param[in] u32Nsec Nano second value + * @return None + */ +void EMAC_SetTime(uint32_t u32Sec, uint32_t u32Nsec) +{ + // Disable time stamp counter before update time value (clear EMAC_TSCTL_TSIEN_Msk) + EMAC->TSCTL = EMAC_TSCTL_TSEN_Msk; + EMAC->UPDSEC = u32Sec; + EMAC->UPDSUBSEC = EMAC_Nsec2Subsec(u32Nsec); + EMAC->TSCTL |= (EMAC_TSCTL_TSIEN_Msk | EMAC_TSCTL_TSMODE_Msk); + +} + +/** + * @brief Enable alarm function and set alarm time + * @param[in] u32Sec Second value to trigger alarm + * @param[in] u32Nsec Nano second value to trigger alarm + * @return None + */ +void EMAC_EnableAlarm(uint32_t u32Sec, uint32_t u32Nsec) +{ + + EMAC->ALMSEC = u32Sec; + EMAC->ALMSUBSEC = EMAC_Nsec2Subsec(u32Nsec); + EMAC->TSCTL |= EMAC_TSCTL_TSALMEN_Msk; + +} + +/** + * @brief Disable alarm function + * @param None + * @return None + */ +void EMAC_DisableAlarm(void) +{ + + EMAC->TSCTL &= ~EMAC_TSCTL_TSALMEN_Msk; + +} + +/** + * @brief Add a offset to current time + * @param[in] u32Neg Offset is negative value (u32Neg == 1) or positive value (u32Neg == 0). + * @param[in] u32Sec Second value to add to current time + * @param[in] u32Nsec Nano second value to add to current time + * @return None + */ +void EMAC_UpdateTime(uint32_t u32Neg, uint32_t u32Sec, uint32_t u32Nsec) +{ + EMAC->UPDSEC = u32Sec; + EMAC->UPDSUBSEC = EMAC_Nsec2Subsec(u32Nsec); + if(u32Neg) + EMAC->UPDSUBSEC |= BIT31; // Set bit 31 indicates this is a negative value + + EMAC->TSCTL |= EMAC_TSCTL_TSUPDATE_Msk; + +} + + +/*@}*/ /* end of group NUC472_442_EMAC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_EMAC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/epwm.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/epwm.c new file mode 100644 index 0000000000000000000000000000000000000000..c112c09b3d08da8e8dc07581ca8689c1a96c2be6 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/epwm.c @@ -0,0 +1,404 @@ +/**************************************************************************//** + * @file EPWM.c + * @version V1.00 + * $Revision: 3 $ + * $Date: 15/11/18 2:33p $ + * @brief NUC472/NUC442 EPWM driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_EPWM_Driver EPWM Driver + @{ +*/ + + +/** @addtogroup NUC472_442_EPWM_EXPORTED_FUNCTIONS EPWM Exported Functions + @{ +*/ + +/** + * @brief This function config PWM generator and get the nearest frequency in edge aligned auto-reload mode + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Frequency Target generator frequency + * @param[in] u32DutyCycle Target generator duty cycle percentage. Valid range are between 0 ~ 100. 10 means 10%, 20 means 20%... + * @return Nearest frequency clock in nano second + */ +uint32_t EPWM_ConfigOutputChannel (EPWM_T *pwm, + uint32_t u32ChannelNum, + uint32_t u32Frequency, + uint32_t u32DutyCycle) +{ + uint32_t i; + uint32_t u32PWM_CLock; + uint8_t u8Divider = 1; + uint16_t u16CNR = 0xFFFF; + + u32PWM_CLock = SystemCoreClock; + + for(; u8Divider < 17; u8Divider <<= 1) { // clk divider could only be 1, 2, 4, 16 + // clk divider not support 8 + if (u8Divider == 8) + continue; + + i = (u32PWM_CLock / u32Frequency) / u8Divider; + // If target value is larger than CNR, need to use a larger divider + if(i > 0x10000) + continue; + + // CNR = 0xFFFF + 1, get a prescaler that CNR value is below 0xFFFF + + if(i <= 0x10000) { + if(i == 1) + u16CNR = 1; // Too fast, and PWM cannot generate expected frequency... + else + u16CNR = i; + break; + } + + } + // Store return value here 'cos we're gonna change u8Divider & u16CNR to the real value to fill into register + i = u32PWM_CLock / (u8Divider * u16CNR); + + u16CNR -= 1; + // convert to real register value + if(u8Divider == 1) + u8Divider = 0; + else if (u8Divider == 2) + u8Divider = 1; + else if (u8Divider == 4) + u8Divider = 2; + else // 16 + u8Divider = 3; + + pwm->CTL = (pwm->CTL & ~EPWM_CTL_CLKDIV_Msk) | ( u8Divider << EPWM_CTL_CLKDIV_Pos); + + if(u32DutyCycle == 0) + pwm->CMPDAT[u32ChannelNum >> 1] = 0; + else + pwm->CMPDAT[u32ChannelNum >> 1] = u32DutyCycle * (u16CNR + 1) / 100 - 1; + + pwm->PERIOD = u16CNR; + + return(i); +} + + +/** + * @brief This function start PWM module + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask This parameter is not used + * @note All channels share one counter + * @return None + */ +void EPWM_Start (EPWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->CTL |= EPWM_CTL_CNTEN_Msk; +} + +/** + * @brief This function stop PWM module + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask This parameter is not used + * @note All channels share one counter + * @return None + */ +void EPWM_Stop (EPWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->CTL &= ~EPWM_CTL_CNTEN_Msk; +} + +/** + * @brief This function stop PWM generation immediately by clear channel enable bit + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask This parameter is not used + * @note All channels share one counter + * @return None + */ +void EPWM_ForceStop (EPWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->CTL &= ~EPWM_CTL_CNTEN_Msk; +} + +/** + * @brief This function enable fault brake of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask This parameter is not used + * @param[in] u32LevelMask Output high or low while fault brake occurs, each bit represent the level of a channel + * while fault brake occurs. Bit 0 represents channel 0, bit 1 represents channel 1... + * , bit 5 represent channel 5 + * @param[in] u32BrakeSource Fault brake source, could be one of following source + * - \ref EPWM_BRK0_BKP0 + * - \ref EPWM_BRK0_CPO0 + * - \ref EPWM_BRK0_CPO1 + * - \ref EPWM_BRK0_CPO2 + * - \ref EPWM_BRK1_LVDBKEN + * - \ref EPWM_BK1SEL_BKP1 + * - \ref EPWM_BK1SEL_CPO0 + * - \ref EPWM_BK1SEL_CPO1 + * - \ref EPWM_BK1SEL_CPO2 + * @return None + */ +void EPWM_EnableFaultBrake (EPWM_T *pwm, + uint32_t u32ChannelMask, + uint32_t u32LevelMask, + uint32_t u32BrakeSource) +{ + if ((u32BrakeSource == EPWM_BRK0_BKP0)||(u32BrakeSource == EPWM_BRK0_CPO0)||(u32BrakeSource == EPWM_BRK0_CPO1)||(u32BrakeSource == EPWM_BRK0_CPO2)) + pwm->CTL |= (u32BrakeSource | EPWM_CTL_BRKP0EN_Msk); + else if (u32BrakeSource == EPWM_BRK1_LVDBKEN) + pwm->CTL |= EPWM_BRK1_LVDBKEN; + else + pwm->CTL = (pwm->CTL & ~EPWM_CTL_BRK1SEL_Msk) | u32BrakeSource | EPWM_CTL_BRKP1EN_Msk; + + pwm->BRKOUT = (pwm->BRKOUT & ~EPWM_BRKOUT_BRKOUT_Msk) | u32LevelMask; +} + +/** + * @brief This function clear fault brake flag + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource This parameter is not used + * @return None + * @note After fault brake occurred, application must clear fault brake source before re-enable PWM output + */ +void EPWM_ClearFaultBrakeFlag (EPWM_T *pwm, uint32_t u32BrakeSource) +{ + pwm->STATUS = EPWM_STATUS_BRK0LOCK_Msk | EPWM_STATUS_BRKIF0_Msk; +} + + +/** + * @brief This function enables PWM output generation of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel. + * Set bit 0 to 1 enables channel 0 output, set bit 1 to 1 enables channel 1 output... + * @return None + */ +void EPWM_EnableOutput (EPWM_T *pwm, uint32_t u32ChannelMask) +{ + if (u32ChannelMask & 0x15) + pwm->OUTEN0 |= EPWM_OUTEN0_EVENOUTEN_Msk; + if (u32ChannelMask & 0x2A) + pwm->OUTEN0 |= EPWM_OUTEN0_ODDOUTEN_Msk; +} + +/** + * @brief This function disables PWM output generation of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel + * Set bit 0 to 1 disables channel 0 output, set bit 1 to 1 disables channel 1 output... + * @return None + */ +void EPWM_DisableOutput (EPWM_T *pwm, uint32_t u32ChannelMask) +{ + if (u32ChannelMask & 0x15) + pwm->OUTEN0 &= ~EPWM_OUTEN0_EVENOUTEN_Msk; + if (u32ChannelMask & 0x2A) + pwm->OUTEN0 &= ~EPWM_OUTEN0_ODDOUTEN_Msk; + +} + +/** + * @brief This function enable Dead zone of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Duration Dead Zone length in PWM clock count, valid values are between 0~0x7FF + * @return None + */ +void EPWM_EnableDeadZone (EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration) +{ + // every two channels shares the same setting + u32ChannelNum >>= 1; + // set duration + pwm->DTCTL = (pwm->DTCTL & ~EPWM_DTCTL_DTCNT_Msk) | u32Duration; + // enable dead zone + pwm->DTCTL |= (EPWM_DTCTL_DTEN0_Msk << u32ChannelNum); +} + +/** + * @brief This function disable Dead zone of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void EPWM_DisableDeadZone (EPWM_T *pwm, uint32_t u32ChannelNum) +{ + // every two channels shares the same setting + u32ChannelNum >>= 1; + // enable dead zone + pwm->DTCTL &= ~(EPWM_DTCTL_DTEN0_Msk << u32ChannelNum); +} + +/** + * @brief This function enable duty interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32IntDutyType This parameter is not used + * @return None + */ +void EPWM_EnableDutyInt (EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType) +{ + // every two channels shares the same setting + u32ChannelNum >>= 1; + // set duty interrupt type + pwm->CTL = (pwm->CTL & ~EPWM_CTL_INTTYPE_Msk) | EPWM_CTL_PWMIEN_Msk; + + pwm->EINTCTL |= ((EPWM_EINTCTL_EINTTYPE0_Msk << u32ChannelNum) | (EPWM_EINTCTL_EDGEIEN0_Msk << u32ChannelNum)); +} + +/** + * @brief This function disable duty interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void EPWM_DisableDutyInt (EPWM_T *pwm, uint32_t u32ChannelNum) +{ + // every two channels shares the same setting + u32ChannelNum >>= 1; + pwm->CTL &= ~(EPWM_EINTCTL_EDGEIEN0_Msk << u32ChannelNum); +} + +/** + * @brief This function clears duty interrupt flag of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void EPWM_ClearDutyIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum) +{ + // every two channels shares the same setting + u32ChannelNum >>= 1; + // write 1 clear + pwm->STATUS = (EPWM_STATUS_EIF0_Msk << u32ChannelNum); +} + +/** + * @brief This function get duty interrupt flag of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return Duty interrupt flag of specified channel + * @retval 0 Duty interrupt did not occurred + * @retval 1 Duty interrupt occurred + */ +uint32_t EPWM_GetDutyIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum) +{ + return((pwm->STATUS & (EPWM_STATUS_EIF0_Msk << u32ChannelNum)) ? 1 : 0); +} + +/** + * @brief This function enable fault brake interrupt + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource This parameter is not used + * @return None + */ +void EPWM_EnableFaultBrakeInt (EPWM_T *pwm, uint32_t u32BrakeSource) +{ + pwm->CTL |= EPWM_CTL_BRKIEN_Msk; +} + +/** + * @brief This function disable fault brake interrupt + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource This parameter is not used + * @return None + */ +void EPWM_DisableFaultBrakeInt (EPWM_T *pwm, uint32_t u32BrakeSource) +{ + pwm->CTL &= ~EPWM_CTL_BRKIEN_Msk; +} + +/** + * @brief This function clear fault brake interrupt of selected source + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource Fault brake source, could be either + * - \ref EPWM_STATUS_BRKIF0_Msk, or + * - \ref EPWM_STATUS_BRKIF1_Msk + * @return None + */ +void EPWM_ClearFaultBrakeIntFlag (EPWM_T *pwm, uint32_t u32BrakeSource) +{ + pwm->STATUS = u32BrakeSource; +} + +/** + * @brief This function get fault brake interrupt of selected source + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource Fault brake source, could be either + * - \ref EPWM_STATUS_BRKIF0_Msk, or + * - \ref EPWM_STATUS_BRKIF1_Msk + * @return Fault brake interrupt flag of specified source + * @retval 0 Fault brake interrupt did not occurred + * @retval 1 Fault brake interrupt occurred + */ +uint32_t EPWM_GetFaultBrakeIntFlag (EPWM_T *pwm, uint32_t u32BrakeSource) +{ + return (pwm->STATUS & u32BrakeSource ? 1 : 0); +} + +/** + * @brief This function enable period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum This parameter is not used + * @param[in] u32IntPeriodType This parameter is not used + * @return None + * @note All channels share the same period interrupt type setting. + */ +void EPWM_EnablePeriodInt (EPWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType) +{ + // set period interrupt type and enable period interrupt + pwm->CTL |= (EPWM_CTL_INTTYPE_Msk | EPWM_CTL_PWMIEN_Msk); +} + +/** + * @brief This function disable period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum This parameter is not used + * @return None + */ +void EPWM_DisablePeriodInt (EPWM_T *pwm, uint32_t u32ChannelNum) +{ + pwm->CTL &= ~EPWM_CTL_PWMIEN_Msk; +} + +/** + * @brief This function clear period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void EPWM_ClearPeriodIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum) +{ + // write 1 clear + pwm->STATUS = EPWM_STATUS_PIF_Msk; +} + +/** + * @brief This function get period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return Period interrupt flag of specified channel + * @retval 0 Period interrupt did not occurred + * @retval 1 Period interrupt occurred + */ +uint32_t EPWM_GetPeriodIntFlag (EPWM_T *pwm, uint32_t u32ChannelNum) +{ + return(pwm->STATUS & EPWM_STATUS_PIF_Msk ? 1 : 0); +} + + + +/*@}*/ /* end of group NUC472_442_EPWM_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_EPWM_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/fmc.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/fmc.c new file mode 100644 index 0000000000000000000000000000000000000000..e8a6662ad7ea8e4086bab1615fc8c6d1d13e3170 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/fmc.c @@ -0,0 +1,355 @@ +/**************************************************************************//** + * @file fmc.c + * @version V1.10 + * $Revision: 20 $ + * $Date: 15/11/20 9:55a $ + * @brief NUC472/NUC442 FMC driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +//* Includes ------------------------------------------------------------------*/ +#include +#include "NUC472_442.h" + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_FMC_Driver FMC Driver + @{ +*/ + + +/** @addtogroup NUC472_442_FMC_EXPORTED_FUNCTIONS FMC Exported Functions + @{ +*/ + + +/** + * @brief Disable FMC ISP function. + * @return None + */ +void FMC_Close(void) +{ + FMC->ISPCTL &= ~FMC_ISPCTL_ISPEN_Msk; +} + + +/** + * @brief Erase a page. The page size is 2048 bytes. + * @param[in] u32PageAddr Flash page address. Must be a 2048-byte aligned address. + * @return Success or not. + * @retval 0 Success + * @retval -1 Erase failed + */ +int32_t FMC_Erase(uint32_t u32PageAddr) +{ + FMC->ISPCMD = FMC_ISPCMD_PAGE_ERASE; + FMC->ISPADDR = u32PageAddr; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; + + if (FMC->ISPCTL & FMC_ISPCTL_ISPFF_Msk) { + FMC->ISPCTL |= FMC_ISPCTL_ISPFF_Msk; + return -1; + } + return 0; +} + + +/** + * @brief Get the current boot source. + * @return The current boot source. + * @retval 0 Is boot from APROM. + * @retval 1 Is boot from LDROM. + */ +int32_t FMC_GetBootSource (void) +{ + if (FMC->ISPCTL & FMC_ISPCTL_BS_Msk) + return 1; + else + return 0; +} + + +/** + * @brief Enable FMC ISP function + * @return None + */ +void FMC_Open(void) +{ + FMC->ISPCTL |= FMC_ISPCTL_ISPEN_Msk; +} + + +/** + * @brief Execute ISP command to read a word from flash. + * @param[in] u32Addr Address of the flash location to be read. + * It must be a word aligned address. + * @return The word data read from specified flash address. + */ +uint32_t FMC_Read(uint32_t u32Addr) +{ + FMC->ISPCMD = FMC_ISPCMD_READ; + FMC->ISPADDR = u32Addr; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; + + return FMC->ISPDAT; +} + + +/** + * @brief Execute ISP 64-bits read command to read two words from flash. + * @param[in] u32Addr Flash word address. Must be a double word aligned address. + * @param[out] u32Data0 The first word read from flash. + * @param[out] u32Data1 The second word read from flash. + * @return None + */ +void FMC_Read_64(uint32_t u32Addr, uint32_t *u32Data0, uint32_t *u32Data1) +{ + FMC->ISPCMD = FMC_ISPCMD_READ_64; + FMC->ISPADDR = u32Addr; + FMC->ISPDAT = 0x0; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; + + *u32Data0 = FMC->MPDAT0; + *u32Data1 = FMC->MPDAT1; +} + + +/** + * @brief Read company ID. + * @return The company ID. + */ +uint32_t FMC_ReadCID(void) +{ + FMC->ISPCMD = FMC_ISPCMD_READ_CID; + FMC->ISPADDR = 0x0; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; + return FMC->ISPDAT; +} + + +/** + * @brief Read product ID. + * @return The product ID. + */ +uint32_t FMC_ReadPID(void) +{ + FMC->ISPCMD = FMC_ISPCMD_READ_PID; + FMC->ISPADDR = 0x04; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; + return FMC->ISPDAT; +} + + +/** + * @brief This function reads one of the four UCID. + * @param[in] u32Index Index of the UCID to read. u32Index must be 0, 1, 2, or 3. + * @return The UCID. + */ +uint32_t FMC_ReadUCID(uint32_t u32Index) +{ + FMC->ISPCMD = FMC_ISPCMD_READ_UID; + FMC->ISPADDR = (0x04 * u32Index) + 0x10; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; + + return FMC->ISPDAT; +} + + +/** + * @brief This function reads one of the three UID. + * @param[in] u32Index Index of the UID to read. u32Index must be 0, 1, or 2. + * @return The UID. + */ +uint32_t FMC_ReadUID(uint32_t u32Index) +{ + FMC->ISPCMD = FMC_ISPCMD_READ_UID; + FMC->ISPADDR = 0x04 * u32Index; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; + + return FMC->ISPDAT; +} + + +/** + * @brief Get the base address of Data Flash if enabled. + * @return Base address of Data Flash + */ +uint32_t FMC_ReadDataFlashBaseAddr(void) +{ + return FMC->DFBA; +} + + +/** + * @brief This function will force re-map assigned flash page to CPU address 0x0. + * @param[in] u32PageAddr Address of the page to be mapped to CPU address 0x0. + * @return None + */ +void FMC_SetVectorPageAddr(uint32_t u32PageAddr) +{ + FMC->ISPCMD = FMC_ISPCMD_VECMAP; + FMC->ISPADDR = u32PageAddr; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; +} + + +/** + * @brief Obtain the current vector page address setting. + * @return The vector page address. + */ +uint32_t FMC_GetVectorPageAddr(void) +{ + return (FMC->ISPSTS & 0x0FFFFF00ul); +} + + +/** + * @brief Execute ISP command to program a word to flash. + * @param[in] u32Addr Address of the flash location to be programmed. + * It must be a word aligned address. + * @param[out] u32Data The word data to be programmed. + * @return None + */ +void FMC_Write(uint32_t u32Addr, uint32_t u32Data) +{ + FMC->ISPCMD = FMC_ISPCMD_WRITE; + FMC->ISPADDR = u32Addr; + FMC->ISPDAT = u32Data; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; +} + + +/** + * @brief Execute ISP 64-bits write command to program two words to flash. + * @param[in] u32Addr Destination address. It must be double word aligned. + * @param[in] u32Data0 First word data to be written. + * @param[in] u32Data1 Second word data to be written. + * @return None + */ +void FMC_Write_64(uint32_t u32Addr, uint32_t u32Data0, uint32_t u32Data1) +{ + FMC->ISPCMD = FMC_ISPCMD_WRITE_64; + FMC->ISPADDR = u32Addr; + FMC->MPDAT0 = u32Data0; + FMC->MPDAT1 = u32Data1; + FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; + while (FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) ; +} + + +/** + * @brief CRC8 Calculator + * @param[in] au32Data CRC8 input data words. + * @param[in] i32Count Number of words in au32Data[]. + * @return The CRC8 value. + */ +uint32_t FMC_CRC8(uint32_t au32Data[], int i32Count) +{ + int i32ByteIdx; + uint8_t i, u8Cnt, u8InData; + uint8_t au8CRC[4] = { 0xff, 0xff, 0xff, 0xff }; + + for (i32ByteIdx = 0; i32ByteIdx < 4; i32ByteIdx++) { + for (u8Cnt = 0; u8Cnt < i32Count; u8Cnt++) { + for (i = 0x80; i != 0; i /= 2) { + if ((au8CRC[i32ByteIdx] & 0x80)!=0) { + au8CRC[i32ByteIdx] *= 2; + au8CRC[i32ByteIdx] ^= 7; + } else + au8CRC[i32ByteIdx] *= 2; + + u8InData = (au32Data[u8Cnt] >> (i32ByteIdx * 8)) & 0xff; + + if ((u8InData & i) != 0) + au8CRC[i32ByteIdx]^=0x7; + } + } + } + return (au8CRC[0] | au8CRC[1] << 8 | au8CRC[2] << 16 | au8CRC[3] << 24); +} + + +/** + * @brief Read the User Configuration words. + * @param[out] u32Config: The word array to store words read from flash. + * @param[in] u32Count: Maximum length of u32Config. + * @return Success or not. + * @retval 0 Success + * @retval -1 User Configuration CRC check error + */ +int32_t FMC_ReadConfig(uint32_t *u32Config, uint32_t u32Count) +{ + int i; + + for (i = 0; i < u32Count; i++) { + u32Config[i] = FMC_Read(FMC_CONFIG_BASE + i*4); + } + + if (FMC->ISPSTS & FMC_ISPSTS_CFGCRCF_Msk) + return -1; + + return 0; +} + + +/** + * @brief Write User Configuration + * @param[in] u32Config The word array to store data. MUST be a four word array. + * @param[in] u32Count MUST be 4. + * @return Success or not. + * @retval 0 Success + * @retval -1 Failed + */ +int32_t FMC_WriteConfig(uint32_t *u32Config, uint32_t u32Count) +{ + uint32_t i, u32CRC, u32Data; + + if (u32Count != 4) + return -1; + + FMC_Erase(FMC_CONFIG_BASE); + + u32CRC = FMC_CRC8(u32Config, 3); + + for (i = 0; i < 4; i++) { + FMC_Write(FMC_CONFIG_BASE + i * 4, (i < 3) ? u32Config[i] : u32CRC); + } + + for (i = 0; i < 4; i++) { + u32Data = FMC_Read(FMC_CONFIG_BASE + i * 4); + + if (u32Data != ((i < 3) ? u32Config[i] : u32CRC)) + return -1; + } + return 0; +} + + +/*@}*/ /* end of group NUC472_442_FMC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_FMC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/gpio.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/gpio.c new file mode 100644 index 0000000000000000000000000000000000000000..946c9633da154399af8e11e77eb8119cf575641d --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/gpio.c @@ -0,0 +1,93 @@ +/**************************************************************************//** + * @file gpio.c + * @version V1.00 + * $Revision: 9 $ + * $Date: 14/10/06 11:47a $ + * @brief NUC472/NUC442 GPIO driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_GPIO_Driver GPIO Driver + @{ +*/ + + +/** @addtogroup NUC472_442_GPIO_EXPORTED_FUNCTIONS GPIO Exported Functions + @{ +*/ + +/** + * @brief Set GPIO operation mode + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32PinMask The single or multiple pins of specified GPIO port. + * @param[in] u32Mode Operation mode. \ref GPIO_MODE_INPUT, \ref GPIO_MODE_OUTPUT, \ref GPIO_MODE_OPEN_DRAIN, \ref GPIO_MODE_QUASI + * + * @return None + * + * @details This function is used to set specified GPIO operation mode. + */ +void GPIO_SetMode(GPIO_T *gpio, uint32_t u32PinMask, uint32_t u32Mode) +{ + uint32_t i; + + for (i=0; iMODE = (gpio->MODE & ~(0x3 << (i << 1))) | (u32Mode << (i << 1)); + } + } +} + +/** + * @brief Enable GPIO interrupt + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. It could be 0 ~ 15. + * @param[in] u32IntAttribs The interrupt attribute of specified GPIO pin. It could be \n + * \ref GPIO_INT_RISING, \ref GPIO_INT_FALLING, \ref GPIO_INT_BOTH_EDGE, \ref GPIO_INT_HIGH, GPIO_INT_LOW + * + * @return None + * + * @details This function is used to enable specified GPIO pin interrupt. + */ +void GPIO_EnableInt(GPIO_T *gpio, uint32_t u32Pin, uint32_t u32IntAttribs) +{ + gpio->INTTYPE |= (((u32IntAttribs >> 24) & 0xFFUL) << u32Pin); + gpio->INTEN |= ((u32IntAttribs & 0xFFFFFFUL) << u32Pin); +} + + +/** + * @brief Disable GPIO interrupt + * + * @param[in] gpio GPIO port. It could be \ref PA, \ref PB, ... or \ref GPI + * @param[in] u32Pin The pin of specified GPIO port. It could be 0 ~ 15. + * + * @return None + * + * @details This function is used to disable specified GPIO pin interrupt. + */ +void GPIO_DisableInt(GPIO_T *gpio, uint32_t u32Pin) +{ + gpio->INTTYPE &= ~(1UL << u32Pin); + gpio->INTEN &= ~((0x00010001UL) << u32Pin); +} + + + +/*@}*/ /* end of group NUC472_442_GPIO_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_GPIO_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/i2c.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/i2c.c new file mode 100644 index 0000000000000000000000000000000000000000..a2b0948d7e498c7dc26764f01f96818713e8e16b --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/i2c.c @@ -0,0 +1,310 @@ +/****************************************************************************//** + * @file i2c.c + * @version V0.10 + * $Revision: 13 $ + * $Date: 14/09/30 1:10p $ + * @brief NUC472/NUC442 I2C driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_I2C_Driver I2C Driver + @{ +*/ + + +/** @addtogroup NUC472_442_I2C_EXPORTED_FUNCTIONS I2C Exported Functions + @{ +*/ + +/** + * @brief This function make I2C module be ready and set the wanted bus clock. + * @param[in] i2c is the base address of I2C module. + * @param[in] u32BusClock is the target bus speed of I2C module. + * @return Actual I2C bus clock frequency. + */ +uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock) +{ + uint32_t u32Div; + uint32_t u32Pclk = CLK_GetPCLKFreq(); + + u32Div = (uint32_t) ((( u32Pclk * 10)/(u32BusClock * 4) + 5) / 10 - 1); /* Compute proper divider for I2C clock */ + i2c->CLKDIV = u32Div; + + /* Enable I2C */ + i2c->CTL |= I2C_CTL_I2CEN_Msk; + + return ( u32Pclk / ((u32Div+1)<<2) ); +} + +/** + * @brief This function closes the I2C module. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +void I2C_Close(I2C_T *i2c) +{ + /* Reset SPI */ + if((uint32_t)i2c == I2C0_BASE) { + SYS->IPRST1 |= SYS_IPRST1_I2C0RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_I2C0RST_Msk; + } else if((uint32_t)i2c == I2C1_BASE) { + SYS->IPRST1 |= SYS_IPRST1_I2C1RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_I2C1RST_Msk; + } else if((uint32_t)i2c == I2C2_BASE) { + SYS->IPRST1 |= SYS_IPRST1_I2C2RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_I2C2RST_Msk; + } else { + SYS->IPRST1 |= SYS_IPRST1_I2C3RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_I2C3RST_Msk; + } + + /* Disable I2C */ + i2c->CTL &= ~I2C_CTL_I2CEN_Msk; +} + +/** + * @brief This function clears the time-out flag. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +void I2C_ClearTimeoutFlag(I2C_T *i2c) +{ + i2c->TOCTL |= I2C_TOCTL_TOIF_Msk; +} + +/** + * @brief This function sets the control bit of the I2C module. + * @param[in] i2c is the base address of I2C module. + * @param[in] u8Start sets START bit to I2C module. + * @param[in] u8Stop sets STOP bit to I2C module. + * @param[in] u8Si sets SI bit to I2C module. + * @param[in] u8Ack sets ACK bit to I2C module. + * @return none + */ +void I2C_Trigger(I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack) +{ + uint32_t u32Reg = 0; + uint32_t u32Val = i2c->CTL & ~(I2C_STA | I2C_STO | I2C_AA); + + if (u8Start) + u32Reg |= I2C_STA; + if (u8Stop) + u32Reg |= I2C_STO; + if (u8Si) + u32Reg |= I2C_SI; + if (u8Ack) + u32Reg |= I2C_AA; + + i2c->CTL = u32Val | u32Reg; +} + +/** + * @brief This function disables the interrupt of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +void I2C_DisableInt(I2C_T *i2c) +{ + i2c->CTL &= ~I2C_CTL_INTEN_Msk; +} + +/** + * @brief This function enables the interrupt (EI bit) of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +void I2C_EnableInt(I2C_T *i2c) +{ + i2c->CTL |= I2C_CTL_INTEN_Msk; +} + +/** + * @brief This function returns the real bus clock of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return Actual I2C bus clock frequency. + */ +uint32_t I2C_GetBusClockFreq(I2C_T *i2c) +{ + uint32_t u32Divider = i2c->CLKDIV; + + return ( CLK_GetPCLKFreq() / ((u32Divider+1)<<2) ); +} + +/** + * @brief This function sets bus frequency of I2C module. + * @param[in] i2c is the base address of I2C module. + * @param[in] u32BusClock is the target bus speed of I2C module. + * @return Actual I2C bus clock frequency. + */ +uint32_t I2C_SetBusClockFreq(I2C_T *i2c, uint32_t u32BusClock) +{ + uint32_t u32Div; + uint32_t u32Pclk = CLK_GetPCLKFreq(); + + u32Div = (uint32_t) (((u32Pclk * 10)/(u32BusClock * 4) + 5) / 10 - 1); /* Compute proper divider for I2C clock */ + i2c->CLKDIV = u32Div; + + return ( u32Pclk / ((u32Div+1)<<2) ); +} + +/** + * @brief This function gets the interrupt flag of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return Interrupt flag. + * @retval 0 Flag is not set. + * @retval 1 Flag is set. + */ +uint32_t I2C_GetIntFlag(I2C_T *i2c) +{ + return ( (i2c->CTL & I2C_CTL_SI_Msk) == I2C_CTL_SI_Msk ? 1:0 ); +} + +/** + * @brief This function returns the status of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return I2C status + */ +uint32_t I2C_GetStatus(I2C_T *i2c) +{ + return ( i2c->STATUS ); +} + +/** + * @brief This function returns the data stored in data register of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return I2C data. + */ +uint32_t I2C_GetData(I2C_T *i2c) +{ + return ( i2c->DAT ); +} + +/** + * @brief This function writes the data to data register of I2C module. + * @param[in] i2c is the base address of I2C module. + * @param[in] u8Data is the data which will be write to data register of I2C module. + * @return none + */ +void I2C_SetData(I2C_T *i2c, uint8_t u8Data) +{ + i2c->DAT = u8Data; +} + +/** + * @brief Configure slave address and enable GC mode. + * @param[in] i2c is the base address of I2C module. + * @param[in] u8SlaveNo is the set number of salve address. + * @param[in] u8SlaveAddr is the slave address. + * @param[in] u8GCMode GC mode enable or not. Valid values are: + * - \ref I2C_GCMODE_ENABLE + * - \ref I2C_GCMODE_DISABLE + * @return none + */ +void I2C_SetSlaveAddr(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddr, uint8_t u8GCMode) +{ + switch (u8SlaveNo) { + case 0: + i2c->ADDR0 = (u8SlaveAddr << 1) | u8GCMode; + break; + case 1: + i2c->ADDR1 = (u8SlaveAddr << 1) | u8GCMode; + break; + case 2: + i2c->ADDR2 = (u8SlaveAddr << 1) | u8GCMode; + break; + case 3: + i2c->ADDR3 = (u8SlaveAddr << 1) | u8GCMode; + break; + default: + i2c->ADDR0 = (u8SlaveAddr << 1) | u8GCMode; + } +} + +/** + * @brief Configure the mask of slave address. The corresponding address bit is "Don't Care". + * @param[in] i2c is the base address of I2C module. + * @param[in] u8SlaveNo is the set number of salve address. + * @param[in] u8SlaveAddrMask is the slave address mask. + * @return none + */ +void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask) +{ + switch (u8SlaveNo) { + case 0: + i2c->ADDRMSK0 = u8SlaveAddrMask << 1; + break; + case 1: + i2c->ADDRMSK1 = u8SlaveAddrMask << 1; + break; + case 2: + i2c->ADDRMSK2 = u8SlaveAddrMask << 1; + break; + case 3: + i2c->ADDRMSK3 = u8SlaveAddrMask << 1; + break; + default: + i2c->ADDRMSK0 = u8SlaveAddrMask << 1; + } +} + +/** + * @brief This function enables timeout function and configures DIV4 function to support long timeout. + * @param[in] i2c is the base address of I2C module. + * @param[in] u8LongTimeout Enable timeout counter input clock is divide by 4. + * @return none + */ +void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout) +{ + if(u8LongTimeout) + i2c->TOCTL |= I2C_TOCTL_TOCDIV4_Msk; + else + i2c->TOCTL &= ~I2C_TOCTL_TOCDIV4_Msk; + + i2c->TOCTL |= I2C_TOCTL_TOCEN_Msk; +} + +/** + * @brief This function disables time-out function. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +void I2C_DisableTimeout(I2C_T *i2c) +{ + i2c->TOCTL &= ~I2C_TOCTL_TOCEN_Msk; +} + +/** + * @brief This function enables the wakeup function of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +void I2C_EnableWakeup(I2C_T *i2c) +{ + i2c->WKCTL |= I2C_WKCTL_WKEN_Msk; +} + +/** + * @brief This function disables the wakeup function of I2C module. + * @param[in] i2c is the base address of I2C module. + * @return none + */ +void I2C_DisableWakeup(I2C_T *i2c) +{ + i2c->WKCTL &= ~I2C_WKCTL_WKEN_Msk; +} + +/*@}*/ /* end of group NUC472_442_I2C_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_I2C_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/i2s.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/i2s.c new file mode 100644 index 0000000000000000000000000000000000000000..24cff340fdcc3b502b469fc20cac25166582278e --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/i2s.c @@ -0,0 +1,220 @@ +/****************************************************************************** + * @file i2s.c + * @version V0.10 + * $Revision: 15 $ + * $Date: 15/06/23 5:56p $ + * @brief NUC472/NUC442 I2S driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_I2S_Driver I2S Driver + @{ +*/ + +/** @addtogroup NUC472_442_I2S_EXPORTED_FUNCTIONS I2S Exported Functions + @{ +*/ + +/** + * @brief This function is used to get I2S source clock frequency. + * @param[in] i2s is the base address of I2S module. + * @return I2S source clock frequency (Hz). + */ +static uint32_t I2S_GetSourceClockFreq(I2S_T *i2s) +{ + uint32_t u32Freq, u32ClkSrcSel; + + // get I2S selection clock source + if((uint32_t)i2s == I2S0_BASE) + u32ClkSrcSel = CLK->CLKSEL3 & CLK_CLKSEL3_I2S0SEL_Msk; + else + u32ClkSrcSel = CLK->CLKSEL3 & CLK_CLKSEL3_I2S1SEL_Msk; + + switch (u32ClkSrcSel) { + case CLK_CLKSEL3_I2S0SEL_HXT: + u32Freq = __HXT; + break; + + case CLK_CLKSEL3_I2S0SEL_PLL: + case CLK_CLKSEL3_I2S1SEL_PLL: + u32Freq = CLK_GetPLLClockFreq(); + break; + + case CLK_CLKSEL3_I2S0SEL_HIRC: + case CLK_CLKSEL3_I2S1SEL_HIRC: + u32Freq = __HIRC; + break; + + case CLK_CLKSEL3_I2S0SEL_PCLK: + case CLK_CLKSEL3_I2S1SEL_PCLK: + u32Freq = SystemCoreClock; + break; + + default: + u32Freq = __HIRC; + break; + } + + return u32Freq; +} + +/** + * @brief This function configures some parameters of I2S interface for general purpose use. + * The sample rate may not be used from the parameter, it depends on system's clock settings, + * but real sample rate used by system will be returned for reference. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32MasterSlave I2S operation mode. Valid values are: + * - \ref I2S_MODE_MASTER + * - \ref I2S_MODE_SLAVE + * @param[in] u32SampleRate Sample rate + * @param[in] u32WordWidth Data length. Valid values are: + * - \ref I2S_DATABIT_8 + * - \ref I2S_DATABIT_16 + * - \ref I2S_DATABIT_24 + * - \ref I2S_DATABIT_32 + * @param[in] u32Channels: Audio format. Valid values are: + * - \ref I2S_MONO + * - \ref I2S_STEREO + * @param[in] u32DataFormat: Data format. Valid values are: + * - \ref I2S_FORMAT_I2S + * - \ref I2S_FORMAT_MSB + * - \ref I2S_FORMAT_PCMA + * - \ref I2S_FORMAT_PCMB + * @param[in] u32AudioInterface: Audio interface. Valid values are: + * - \ref I2S_I2S + * - \ref I2S_PCM + * @return Real sample rate. + */ +uint32_t I2S_Open(I2S_T *i2s, uint32_t u32MasterSlave, uint32_t u32SampleRate, uint32_t u32WordWidth, uint32_t u32Channels, uint32_t u32DataFormat, uint32_t u32AudioInterface) +{ + uint16_t u16Divider; + uint32_t u32BitRate, u32SrcClk; + + if((uint32_t)i2s == I2S0_BASE) { + SYS->IPRST1 |= SYS_IPRST1_I2S0RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_I2S0RST_Msk; + } else { + SYS->IPRST1 |= SYS_IPRST1_I2S1RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_I2S1RST_Msk; + } + + i2s->CTL = u32MasterSlave | u32WordWidth | u32Channels | u32DataFormat | u32AudioInterface | I2S_FIFO_TX_LEVEL_WORD_4 | I2S_FIFO_RX_LEVEL_WORD_4; + + u32SrcClk = I2S_GetSourceClockFreq(i2s); + + u32BitRate = u32SampleRate * (((u32WordWidth>>4) & 0x3) + 1) * 16; + u16Divider = ((u32SrcClk/u32BitRate) >> 1) - 1; + i2s->CLKDIV = (i2s->CLKDIV & ~I2S_CLKDIV_BCLKDIV_Msk) | (u16Divider << 8); + + //calculate real sample rate + u32BitRate = u32SrcClk / (2*(u16Divider+1)); + u32SampleRate = u32BitRate / ((((u32WordWidth>>4) & 0x3) + 1) * 16); + + i2s->CTL |= I2S_CTL_I2SEN_Msk; + + return u32SampleRate; +} + +/** + * @brief Disable I2S function and I2S clock. + * @param[in] i2s is the base address of I2S module. + * @return none + */ +void I2S_Close(I2S_T *i2s) +{ + i2s->CTL &= ~I2S_CTL_I2SEN_Msk; +} + +/** + * @brief This function enables the interrupt according to the mask parameter. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32Mask is the combination of all related interrupt enable bits. + * Each bit corresponds to a interrupt bit. + * @return none + */ +void I2S_EnableInt(I2S_T *i2s, uint32_t u32Mask) +{ + i2s->IEN |= u32Mask; +} + +/** + * @brief This function disables the interrupt according to the mask parameter. + * @param[in] i2s is the base address of I2S module. + * @param[in] u32Mask is the combination of all related interrupt enable bits. + * Each bit corresponds to a interrupt bit. + * @return none + */ +void I2S_DisableInt(I2S_T *i2s, uint32_t u32Mask) +{ + i2s->IEN &= ~u32Mask; +} + +/** + * @brief Enable MCLK . + * @param[in] i2s is the base address of I2S module. + * @param[in] u32BusClock is the target MCLK clock + * @return Actual MCLK clock + */ +uint32_t I2S_EnableMCLK(I2S_T *i2s, uint32_t u32BusClock) +{ + uint8_t u8Divider; + uint32_t u32SrcClk, u32Reg; + + u32SrcClk = I2S_GetSourceClockFreq(i2s); + if (u32BusClock == u32SrcClk) + u8Divider = 0; + else + u8Divider = (u32SrcClk/u32BusClock) >> 1; + + i2s->CLKDIV = (i2s->CLKDIV & ~I2S_CLKDIV_MCLKDIV_Msk) | u8Divider; + + i2s->CTL |= I2S_CTL_MCLKEN_Msk; + + u32Reg = i2s->CLKDIV & I2S_CLKDIV_MCLKDIV_Msk; + + if (u32Reg == 0) + return u32SrcClk; + else + return ((u32SrcClk >> 1) / u32Reg); +} + +/** + * @brief Disable MCLK . + * @param[in] i2s is the base address of I2S module. + * @return none + */ +void I2S_DisableMCLK(I2S_T *i2s) +{ + i2s->CTL &= ~I2S_CTL_MCLKEN_Msk; +} + +/** + * @brief Configure FIFO threshold setting. + * @param[in] i2s The pointer of the specified I2S module. + * @param[in] u32TxThreshold Decides the TX FIFO threshold. It could be 0 ~ 7. + * @param[in] u32RxThreshold Decides the RX FIFO threshold. It could be 0 ~ 7. + * @return None + * @details Set TX FIFO threshold and RX FIFO threshold configurations. + */ +void I2S_SetFIFO(I2S_T *i2s, uint32_t u32TxThreshold, uint32_t u32RxThreshold) +{ + i2s->CTL = (i2s->CTL & ~(I2S_CTL_TXTH_Msk | I2S_CTL_RXTH_Msk) | + (u32TxThreshold << I2S_CTL_TXTH_Pos) | + (u32RxThreshold << I2S_CTL_RXTH_Pos)); +} +/*@}*/ /* end of group NUC472_442_I2S_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_I2S_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/pdma.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/pdma.c new file mode 100644 index 0000000000000000000000000000000000000000..3d7e8139674e04b64537e5f62b680996c8cdc84a --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/pdma.c @@ -0,0 +1,246 @@ +/**************************************************************************//** + * @file pdma.c + * @version V1.00 + * $Revision: 8 $ + * $Date: 15/03/16 3:17p $ + * @brief NUC472/NUC442 PDMA driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + + +static uint8_t u32ChSelect[PDMA_CH_MAX]; + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_PDMA_Driver PDMA Driver + @{ +*/ + + +/** @addtogroup NUC472_442_PDMA_EXPORTED_FUNCTIONS PDMA Exported Functions + @{ +*/ + +/** + * @brief PDMA Open + * + * @param[in] u32Mask Channel enable bits. + * + * @return None + * + * @details This function enable the PDMA channels. + */ +void PDMA_Open(uint32_t u32Mask) +{ + int volatile i; + + for (i=0; iDSCT[i].CTL = 0; + u32ChSelect[i] = 0x1f; + } + + PDMA->CHCTL |= u32Mask; +} + +/** + * @brief PDMA Close + * + * @param[in] None + * + * @return None + * + * @details This function disable all PDMA channels. + */ +void PDMA_Close(void) +{ + PDMA->CHCTL = 0; +} + +/** + * @brief Set PDMA Transfer Count + * + * @param[in] u32Ch The selected channel + * @param[in] u32Width Data width. PDMA_WIDTH_8, PDMA_WIDTH_16, or PDMA_WIDTH_32 + * @param[in] u32TransCount Transfer count + * + * @return None + * + * @details This function set the selected channel data width and transfer count. + */ +void PDMA_SetTransferCnt(uint32_t u32Ch, uint32_t u32Width, uint32_t u32TransCount) +{ + PDMA->DSCT[u32Ch].CTL &= ~(PDMA_DSCT_CTL_TXCNT_Msk | PDMA_DSCT_CTL_TXWIDTH_Msk); + PDMA->DSCT[u32Ch].CTL |= (u32Width | ((u32TransCount-1) << PDMA_DSCT_CTL_TXCNT_Pos)); +} + +/** + * @brief Set PDMA Transfer Address + * + * @param[in] u32Ch The selected channel + * @param[in] u32SrcAddr Source address + * @param[in] u32SrcCtrl Source control attribute. PDMA_SAR_INC or PDMA_SAR_FIX + * @param[in] u32DstAddr destination address + * @param[in] u32DstCtrl destination control attribute. PDMA_DAR_INC or PDMA_DAR_FIX + * + * @return None + * + * @details This function set the selected channel source/destination address and attribute. + */ +void PDMA_SetTransferAddr(uint32_t u32Ch, uint32_t u32SrcAddr, uint32_t u32SrcCtrl, uint32_t u32DstAddr, uint32_t u32DstCtrl) +{ + PDMA->DSCT[u32Ch].ENDSA = u32SrcAddr; + PDMA->DSCT[u32Ch].ENDDA = u32DstAddr; + PDMA->DSCT[u32Ch].CTL &= ~(PDMA_DSCT_CTL_SAINC_Msk | PDMA_DSCT_CTL_DAINC_Msk); + PDMA->DSCT[u32Ch].CTL |= (u32SrcCtrl | u32DstCtrl); +} + +/** + * @brief Set PDMA Transfer Mode + * + * @param[in] u32Ch The selected channel + * @param[in] u32Peripheral The selected peripheral. PDMA_SPI0_TX, PDMA_UART0_TX, PDMA_I2S_TX,...PDMA_MEM + * @param[in] u32ScatterEn Scatter-gather mode enable + * @param[in] u32DescAddr Scatter-gather descriptor address + * + * @return None + * + * @details This function set the selected channel transfer mode. Include peripheral setting. + */ +void PDMA_SetTransferMode(uint32_t u32Ch, uint32_t u32Peripheral, uint32_t u32ScatterEn, uint32_t u32DescAddr) +{ + u32ChSelect[u32Ch] = u32Peripheral; + switch (u32Ch) { + case 0: + PDMA->REQSEL0_3 = (PDMA->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC0_Msk) | u32Peripheral; + break; + case 1: + PDMA->REQSEL0_3 = (PDMA->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC1_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC1_Pos); + break; + case 2: + PDMA->REQSEL0_3 = (PDMA->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC2_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC2_Pos); + break; + case 3: + PDMA->REQSEL0_3 = (PDMA->REQSEL0_3 & ~PDMA_REQSEL0_3_REQSRC3_Msk) | (u32Peripheral << PDMA_REQSEL0_3_REQSRC3_Pos); + break; + case 4: + PDMA->REQSEL4_7 = (PDMA->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC4_Msk) | u32Peripheral; + break; + case 5: + PDMA->REQSEL4_7 = (PDMA->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC5_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC5_Pos); + break; + case 6: + PDMA->REQSEL4_7 = (PDMA->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC6_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC6_Pos); + break; + case 7: + PDMA->REQSEL4_7 = (PDMA->REQSEL4_7 & ~PDMA_REQSEL4_7_REQSRC7_Msk) | (u32Peripheral << PDMA_REQSEL4_7_REQSRC7_Pos); + break; + case 8: + PDMA->REQSEL8_11 = (PDMA->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC8_Msk) | u32Peripheral; + break; + case 9: + PDMA->REQSEL8_11 = (PDMA->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC9_Msk) | (u32Peripheral << PDMA_REQSEL8_11_REQSRC9_Pos); + break; + case 10: + PDMA->REQSEL8_11 = (PDMA->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC10_Msk) | (u32Peripheral << PDMA_REQSEL8_11_REQSRC10_Pos); + break; + case 11: + PDMA->REQSEL8_11 = (PDMA->REQSEL8_11 & ~PDMA_REQSEL8_11_REQSRC11_Msk) | (u32Peripheral << PDMA_REQSEL8_11_REQSRC11_Pos); + break; + case 12: + PDMA->REQSEL12_15 = (PDMA->REQSEL12_15 & ~PDMA_REQSEL12_15_REQSRC12_Msk) | u32Peripheral; + break; + case 13: + PDMA->REQSEL12_15 = (PDMA->REQSEL12_15 & ~PDMA_REQSEL12_15_REQSRC13_Msk) | (u32Peripheral << PDMA_REQSEL12_15_REQSRC13_Pos); + break; + case 14: + PDMA->REQSEL12_15 = (PDMA->REQSEL12_15 & ~PDMA_REQSEL12_15_REQSRC14_Msk) | (u32Peripheral << PDMA_REQSEL12_15_REQSRC14_Pos); + break; + case 15: + PDMA->REQSEL12_15 = (PDMA->REQSEL12_15 & ~PDMA_REQSEL12_15_REQSRC15_Msk) | (u32Peripheral << PDMA_REQSEL12_15_REQSRC15_Pos); + break; + default: + ; + } + + if (u32ScatterEn) { + PDMA->DSCT[u32Ch].CTL = (PDMA->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_SCATTER; + PDMA->DSCT[u32Ch].NEXT = u32DescAddr - (PDMA->SCATBA); + } else + PDMA->DSCT[u32Ch].CTL = (PDMA->DSCT[u32Ch].CTL & ~PDMA_DSCT_CTL_OPMODE_Msk) | PDMA_OP_BASIC; +} + +/** + * @brief Set PDMA Burst Type + * + * @param[in] u32Ch The selected channel + * @param[in] u32BurstType Burst mode or single mode + * @param[in] u32BurstSize Set the size of burst mode + * + * @return None + * + * @details This function set the selected channel burst type and size. + */ +void PDMA_SetBurstType(uint32_t u32Ch, uint32_t u32BurstType, uint32_t u32BurstSize) +{ + PDMA->DSCT[u32Ch].CTL &= ~(PDMA_DSCT_CTL_TXTYPE_Msk | PDMA_DSCT_CTL_BURSIZE_Msk); + PDMA->DSCT[u32Ch].CTL |= (u32BurstType | u32BurstSize); +} + + +/** + * @brief Trigger PDMA + * + * @param[in] u32Ch The selected channel + * + * @return None + * + * @details This function trigger the selected channel. + */ +void PDMA_Trigger(uint32_t u32Ch) +{ + if (u32ChSelect[u32Ch] == PDMA_MEM) + PDMA->SWREQ = (1 << u32Ch); +} + +/** + * @brief Enable Interrupt + * + * @param[in] u32Ch The selected channel + * @param[in] u32Mask The Interrupt Type + * + * @return None + * + * @details This function enable the selected channel interrupt. + */ +void PDMA_EnableInt(uint32_t u32Ch, uint32_t u32Mask) +{ + PDMA->INTEN |= (1 << u32Ch); +} + +/** + * @brief Disable Interrupt + * + * @param[in] u32Ch The selected channel + * @param[in] u32Mask The Interrupt Type + * + * @return None + * + * @details This function disable the selected channel interrupt. + */ +void PDMA_DisableInt(uint32_t u32Ch, uint32_t u32Mask) +{ + PDMA->INTEN &= ~(1 << u32Ch); +} + +/*@}*/ /* end of group NUC472_442_PDMA_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_PDMA_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/ps2.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/ps2.c new file mode 100644 index 0000000000000000000000000000000000000000..aea04dab526e0eaac97ecd15ccac28babf9a09e1 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/ps2.c @@ -0,0 +1,183 @@ +/****************************************************************************** + * @file ps2.c + * @version V1.00 + * $Revision: 5 $ + * $Date: 14/10/03 11:59a $ + * @brief NUC472/NUC442 PS2 driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include +#include "NUC472_442.h" + +/*---------------------------------------------------------------------------------------------------------*/ +/* Includes of local headers */ +/*---------------------------------------------------------------------------------------------------------*/ +#include "ps2.h" + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_PS2_Driver PS2 Driver + @{ +*/ + + +/** @addtogroup NUC472_442_PS2_EXPORTED_FUNCTIONS PS2 Exported Functions + @{ +*/ + + +/** + * @brief The function is used to enable PS2 specified interrupt. + * + * @param[in] u32Mask The specified interrupt of PS2 module: + * - \ref PS2_CTL_TXIEN_Msk : PS2 Tx interrupt + * - \ref PS2_CTL_RXIEN_Msk : PS2 Rx interrupt + * + * @return None + */ +void PS2_EnableInt(uint32_t u32Mask) +{ + PS2->CTL |= u32Mask; +} + +/** + * @brief The function is used to disable PS2 specified interrupt. + * + * @param[in] u32Mask The specified interrupt of PS2 module: + * - \ref PS2_CTL_TXIEN_Msk : PS2 Tx interrupt + * - \ref PS2_CTL_RXIEN_Msk : PS2 Rx interrupt + * + * @return None + */ +void PS2_DisableInt(uint32_t u32Mask) +{ + PS2->CTL &= ~u32Mask; +} + +/** + * @brief This function use to enable PS2 function and set one byte per trnasfer. + * + * @param None + * + * @return None + */ +void PS2_Open(void) +{ + /* Reset PS2 device */ + SYS->IPRST1 |= SYS_IPRST1_PS2RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_PS2RST_Msk; + + /* Enable PS2 module */ + PS2->CTL |= PS2_CTL_PS2EN_Msk; + + /* Set One byte per trnasfer */ + PS2->CTL &= ~PS2_CTL_TXFDEPTH_Msk; + + /* Clear Tx FIFO */ + PS2->CTL |= PS2_CTL_CLRFIFO_Msk; + PS2->CTL &= (~PS2_CTL_CLRFIFO_Msk); +} + +/** + * @brief This function use to disable PS2 function. + * + * @param None + * + * @return None + */ +void PS2_Close(void) +{ + /* Enable PS2 module */ + PS2->CTL &= ~PS2_CTL_PS2EN_Msk; +} + +/** + * @brief This function use to read PS2 Rx data. + * + * @param None + * + * @return Rx data + */ +uint8_t PS2_Read(void) +{ + return (uint8_t)(PS2->RXDAT & PS2_RXDAT_DAT_Msk); +} + +/** + * @brief This function use to transmit PS2 data. + * + * @param[in] pu32Buf The buffer to send the data to PS2 transmission FIFO. + * @param[in] u32ByteCount The byte number of data. + * + * @return FALSE: transmit data time-out + * TRUE: transmit data successful + */ +int32_t PS2_Write(uint32_t *pu32Buf, uint32_t u32ByteCount) +{ + uint32_t u32TxFIFO_Depth = 16; + uint32_t u32delayno, txcnt, remainder; + uint8_t i=0; + + txcnt = u32ByteCount / u32TxFIFO_Depth; + + remainder = u32ByteCount % u32TxFIFO_Depth; + if(remainder) txcnt++; + + u32delayno = 0; + while (!(PS2->STATUS & PS2_STATUS_TXEMPTY_Msk)) { + u32delayno++; + if (u32delayno >= 0xF0000000) + return FALSE; // Time Out + } + + if(u32ByteCount >= u32TxFIFO_Depth)//Tx fifo is 16 bytes + PS2_SET_TX_BYTE_CNT(u32TxFIFO_Depth); + + do { + u32delayno = 0; + while (!(PS2->STATUS & PS2_STATUS_TXEMPTY_Msk)) { + u32delayno++; + if(u32delayno >= 0xF0000000) + return FALSE; // Time Out + } + + if((txcnt == 1) && (remainder != 0)) + PS2_SET_TX_BYTE_CNT(u32ByteCount); + + PS2->TXDAT0 = pu32Buf[i]; + PS2->TXDAT1 = pu32Buf[i+1]; + PS2->TXDAT2 = pu32Buf[i+2]; + PS2->TXDAT3 = pu32Buf[i+3]; + + i = i + 4; + + } while(--txcnt); + + u32delayno = 0; + while(!(PS2->STATUS & PS2_STATUS_TXEMPTY_Msk)) { + u32delayno++; + if(u32delayno >= 0xF0000000) + return FALSE; // Time Out + } + + return TRUE; + +} + + +/*@}*/ /* end of group NUC472_442_PS2_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_PS2_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/pwm.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/pwm.c new file mode 100644 index 0000000000000000000000000000000000000000..640ac96201572cc5fa38d4046d15066073c6c319 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/pwm.c @@ -0,0 +1,782 @@ +/**************************************************************************//** + * @file PWM.c + * @version V1.00 + * $Revision: 26 $ + * $Date: 15/11/18 2:34p $ + * @brief NUC472/NUC442 PWM driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_PWM_Driver PWM Driver + @{ +*/ + + +/** @addtogroup NUC472_442_PWM_EXPORTED_FUNCTIONS PWM Exported Functions + @{ +*/ + +/** + * @brief This function config PWM generator and get the nearest frequency in edge aligned auto-reload mode + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Frequency Target generator frequency + * @param[in] u32DutyCycle Target generator duty cycle percentage. Valid range are between 0 ~ 100. 10 means 10%, 20 means 20%... + * @return Nearest frequency clock in nano second + * @note Since every two channels, (0 & 1), (2 & 3), (4 & 5), shares a prescaler. Call this API to configure PWM frequency may affect + * existing frequency of other channel. + */ +uint32_t PWM_ConfigOutputChannel (PWM_T *pwm, + uint32_t u32ChannelNum, + uint32_t u32Frequency, + uint32_t u32DutyCycle) +{ + uint32_t i; + uint32_t u32PWM_CLock = __HIRC; + uint8_t u8Divider = 1, u8Prescale = 0xFF; + uint16_t u16CNR = 0xFFFF; + + if (pwm == PWM0) { + if (u32ChannelNum < 2) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 0) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 1) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 2) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 3) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 4) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 4) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (0 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (1 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (2 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (3 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (4 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 6) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (0 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (1 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (2 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (3 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (4 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __LIRC; + } + } else if (pwm == PWM1) { + if (u32ChannelNum < 2) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (0 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (1 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (2 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (3 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (4 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 4) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (0 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (1 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (2 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (3 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (4 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 6) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (0 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (1 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (2 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (3 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (4 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __LIRC; + } + } + + for(; u8Divider < 17; u8Divider <<= 1) { // clk divider could only be 1, 2, 4, 8, 16 + i = (u32PWM_CLock / u32Frequency) / u8Divider; + // If target value is larger than CNR * prescale, need to use a larger divider + if(i > (0x10000 * 0x100)) + continue; + + // CNR = 0xFFFF + 1, get a prescaler that CNR value is below 0xFFFF + u8Prescale = (i + 0xFFFF)/ 0x10000; + + // u8Prescale must at least be 2, otherwise the output stop + if(u8Prescale < 3) + u8Prescale = 2; + + i /= u8Prescale; + + if(i <= 0x10000) { + if(i == 1) + u16CNR = 1; // Too fast, and PWM cannot generate expected frequency... + else + u16CNR = i; + break; + } + + } + // Store return value here 'cos we're gonna change u8Divider & u8Prescale & u16CNR to the real value to fill into register + i = u32PWM_CLock / (u8Prescale * u8Divider * u16CNR); + + u8Prescale -= 1; + u16CNR -= 1; + // convert to real register value + if(u8Divider == 1) + u8Divider = 4; + else if (u8Divider == 2) + u8Divider = 0; + else if (u8Divider == 4) + u8Divider = 1; + else if (u8Divider == 8) + u8Divider = 2; + else // 16 + u8Divider = 3; + + // every two channels share a prescaler + while((pwm->SBS[u32ChannelNum] & 1) == 1); + pwm->CLKPSC = (pwm->CLKPSC & ~(PWM_CLKPSC_CLKPSC01_Msk << ((u32ChannelNum >> 1) * 8))) | (u8Prescale << ((u32ChannelNum >> 1) * 8)); + pwm->CLKDIV = (pwm->CLKDIV & ~(PWM_CLKDIV_CLKDIV0_Msk << (4 * u32ChannelNum))) | (u8Divider << (4 * u32ChannelNum)); + pwm->CTL |= 1 << (PWM_CTL_CNTMODE_Pos + u32ChannelNum); + if(u32DutyCycle == 0) + pwm->CMPDAT[u32ChannelNum] = 0; + else + pwm->CMPDAT[u32ChannelNum] = u32DutyCycle * (u16CNR + 1) / 100 - 1; + pwm->PERIOD[u32ChannelNum] = u16CNR; + + return(i); +} + +/** + * @brief This function config PWM capture and get the nearest unit time + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32UnitTimeNsec Unit time of counter + * @param[in] u32CaptureEdge Condition to latch the counter + * @return Nearest unit time in nano second + * @note Since every two channels, (0 & 1), (2 & 3), (4 & 5), shares a prescaler. Call this API to configure PWM frequency may affect + * existing frequency of other channel. + */ +uint32_t PWM_ConfigCaptureChannel (PWM_T *pwm, + uint32_t u32ChannelNum, + uint32_t u32UnitTimeNsec, + uint32_t u32CaptureEdge) +{ + uint32_t i; + uint32_t u32PWM_CLock = __HIRC; + uint8_t u8Divider = 1, u8Prescale = 0xFF; + uint16_t u16CNR = 0xFFFF; + + if (pwm == PWM0) { + if (u32ChannelNum < 2) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 0) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 1) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 2) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 3) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH01SEL_Msk) == 4) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 4) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (0 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (1 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (2 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (3 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH23SEL_Msk) == (4 << CLK_CLKSEL2_PWM0CH23SEL_Pos)) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 6) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (0 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (1 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (2 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (3 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM0CH45SEL_Msk) == (4 << CLK_CLKSEL2_PWM0CH45SEL_Pos)) + u32PWM_CLock = __LIRC; + } + } else if (pwm == PWM1) { + if (u32ChannelNum < 2) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (0 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (1 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (2 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (3 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH01SEL_Msk) == (4 << CLK_CLKSEL2_PWM1CH01SEL_Pos)) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 4) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (0 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (1 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (2 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (3 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH23SEL_Msk) == (4 << CLK_CLKSEL2_PWM1CH23SEL_Pos)) + u32PWM_CLock = __LIRC; + } else if (u32ChannelNum < 6) { + if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (0 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __HXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (1 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __LXT; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (2 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = SystemCoreClock; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (3 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __HIRC; + else if ((CLK->CLKSEL2 & CLK_CLKSEL2_PWM1CH45SEL_Msk) == (4 << CLK_CLKSEL2_PWM1CH45SEL_Pos)) + u32PWM_CLock = __LIRC; + } + } + + for(; u8Divider < 17; u8Divider <<= 1) { // clk divider could only be 1, 2, 4, 8, 16 + i = ((u32PWM_CLock / u8Divider) * u32UnitTimeNsec) / 1000000000; + + // If target value is larger than 0xFF, need to use a larger divider + if(i > (0xFF)) + continue; + + u8Prescale = i; + + // u8Prescale must at least be 2, otherwise the output stop + if(u8Prescale < 3) + u8Prescale = 2; + + break; + } + + // Store return value here 'cos we're gonna change u8Divider & u8Prescale & u16CNR to the real value to fill into register + i = (u8Prescale * u8Divider) * 1000000000/ u32PWM_CLock; + + u8Prescale -= 1; + u16CNR -= 1; + // convert to real register value + if(u8Divider == 1) + u8Divider = 4; + else if (u8Divider == 2) + u8Divider = 0; + else if (u8Divider == 4) + u8Divider = 1; + else if (u8Divider == 8) + u8Divider = 2; + else // 16 + u8Divider = 3; + + // every two channels share a prescaler + while((pwm->SBS[u32ChannelNum] & 1) == 1); + pwm->CLKPSC = (pwm->CLKPSC & ~(PWM_CLKPSC_CLKPSC01_Msk << ((u32ChannelNum >> 1) * 8))) | (u8Prescale << ((u32ChannelNum >> 1) * 8)); + pwm->CLKDIV = (pwm->CLKDIV & ~(PWM_CLKDIV_CLKDIV0_Msk << (4 * u32ChannelNum))) | (u8Divider << (4 * u32ChannelNum)); + pwm->CTL |= 1 << (PWM_CTL_CNTMODE_Pos + u32ChannelNum); + pwm->PERIOD[u32ChannelNum] = u16CNR; + + return(i); +} + +/** + * @brief This function start PWM module + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel. + * Bit 0 is channel 0, bit 1 is channel 1... + * @return None + */ +void PWM_Start (PWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->CNTEN |= u32ChannelMask; +} + +/** + * @brief This function stop PWM module + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel. + * Bit 0 is channel 0, bit 1 is channel 1... + * @return None + */ +void PWM_Stop (PWM_T *pwm, uint32_t u32ChannelMask) +{ + uint32_t i; + for(i = 0; i < PWM_CHANNEL_NUM; i ++) { + if(u32ChannelMask & (1 << i)) { + *(__IO uint32_t *) (&pwm->CNTEN + 1 * i) = 0; + } + } + +} + +/** + * @brief This function stop PWM generation immediately by clear channel enable bit + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel. + * Bit 0 is channel 0, bit 1 is channel 1... + * @return None + */ +void PWM_ForceStop (PWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->CNTEN &= ~u32ChannelMask; +} + +/** + * @brief This function enable selected channel to trigger ADC + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Condition The condition to trigger ADC. Combination of following conditions: + * - \ref PWM_TRIGGER_ADC_PERIOD_POINT + * - \ref PWM_TRIGGER_ADC_CENTER_POINT + * - \ref PWM_TRIGGER_ADC_FALLING_EDGE_POINT + * - \ref PWM_TRIGGER_ADC_RISING_EDGE_POINT + * @return None + */ +void PWM_EnableADCTrigger (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition) +{ + pwm->TRGADCTL = (pwm->TRGADCTL & ~((PWM_TRIGGER_ADC_PERIOD_POINT | + PWM_TRIGGER_ADC_CENTER_POINT | + PWM_TRIGGER_ADC_FALLING_EDGE_POINT | + PWM_TRIGGER_ADC_RISING_EDGE_POINT ) << (1 * u32ChannelNum))) | (u32Condition << (1 * u32ChannelNum)); +} + +/** + * @brief This function disable selected channel to trigger ADC + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void PWM_DisableADCTrigger (PWM_T *pwm, uint32_t u32ChannelNum) +{ + pwm->TRGADCTL = (pwm->TRGADCTL & ~((PWM_TRIGGER_ADC_PERIOD_POINT | + PWM_TRIGGER_ADC_CENTER_POINT | + PWM_TRIGGER_ADC_FALLING_EDGE_POINT | + PWM_TRIGGER_ADC_RISING_EDGE_POINT ) << (1 * u32ChannelNum))); +} + +/** + * @brief This function clear selected channel trigger ADC flag + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Condition PWM triggered ADC flag to be cleared. A combination of following flags: + * - \ref PWM_TRIGGER_ADC_PERIOD_POINT + * - \ref PWM_TRIGGER_ADC_CENTER_POINT + * - \ref PWM_TRIGGER_ADC_FALLING_EDGE_POINT + * - \ref PWM_TRIGGER_ADC_RISING_EDGE_POINT + * @return None + */ +void PWM_ClearADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Condition) +{ + pwm->TRGADCSTS |= (u32Condition << (1 * u32ChannelNum)); +} + +/** + * @brief This function get selected channel trigger ADC flag + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return Combination of following trigger conditions which triggered ADC + * - \ref PWM_TRIGGER_ADC_PERIOD_POINT + * - \ref PWM_TRIGGER_ADC_CENTER_POINT + * - \ref PWM_TRIGGER_ADC_FALLING_EDGE_POINT + * - \ref PWM_TRIGGER_ADC_FALLING_EDGE_POINT + */ +uint32_t PWM_GetADCTriggerFlag (PWM_T *pwm, uint32_t u32ChannelNum) +{ + uint32_t u32Ret; + + u32Ret = pwm->TRGADCSTS >> u32ChannelNum; + + return (u32Ret & (PWM_TRIGGER_ADC_PERIOD_POINT | + PWM_TRIGGER_ADC_CENTER_POINT | + PWM_TRIGGER_ADC_FALLING_EDGE_POINT | + PWM_TRIGGER_ADC_FALLING_EDGE_POINT)); +} + +/** + * @brief This function enable fault brake of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask This parameter is not used + * @param[in] u32LevelMask Output high or low while fault brake occurs, each bit represent the level of a channel + * while fault brake occurs. Bit 0 represents channel 0, bit 1 represents channel 1... + * , bit 6 represent D6, and bit 7 represents D7 + * @param[in] u32BrakeSource Fault brake source, could be one of following source + * - \ref PWM_BRK0_BKP0 + * - \ref PWM_BRK0_CPO0 + * - \ref PWM_BRK0_CPO1 + * - \ref PWM_BRK0_CPO2 + * - \ref PWM_BRK1_LVDBK + * - \ref PWM_BK1SEL_BKP1 + * - \ref PWM_BK1SEL_CPO0 + * - \ref PWM_BK1SEL_CPO1 + * @return None + */ +void PWM_EnableFaultBrake (PWM_T *pwm, + uint32_t u32ChannelMask, + uint32_t u32LevelMask, + uint32_t u32BrakeSource) +{ + if ((u32BrakeSource == PWM_BRK0_BKP0)||(u32BrakeSource == PWM_BRK0_CPO0)||(u32BrakeSource == PWM_BRK0_CPO1)||(u32BrakeSource == PWM_BRK0_CPO2)) + pwm->BRKCTL |= (u32BrakeSource | PWM_BRKCTL_BRK0EN_Msk); + else if (u32BrakeSource == PWM_BRK1_LVDBK) + pwm->BRKCTL |= PWM_BRKCTL_LVDBKEN_Msk; + else + pwm->BRKCTL = (pwm->BRKCTL & ~PWM_BRKCTL_BK1SEL_Msk) | u32BrakeSource | PWM_BRKCTL_BRK1EN_Msk; + + pwm->BRKCTL = (pwm->BRKCTL & ~PWM_BRKCTL_BKOD_Msk) | (u32LevelMask << PWM_BRKCTL_BKOD_Pos); + +} + +/** + * @brief This function clear fault brake flag + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource Fault brake source 0 or 1 + * 0: brake 0, 1: brake 1 + * @return None + * @note After fault brake occurred, application must clear fault brake source before re-enable PWM output + */ +void PWM_ClearFaultBrakeFlag (PWM_T *pwm, uint32_t u32BrakeSource) +{ + if (u32BrakeSource == 0) + pwm->INTSTS = (PWM_INTSTS_BRKLK0_Msk | PWM_INTSTS_BRKIF0_Msk); + else + pwm->INTSTS = PWM_INTSTS_BRKIF1_Msk; +} + +/** + * @brief This function enables PWM capture of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel. + * Set bit 0 to 1 enables channel 0 output, set bit 1 to 1 enables channel 1 output... + * @return None + */ +void PWM_EnableCapture (PWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->CAPCTL |= u32ChannelMask; + pwm->CAPINEN |= u32ChannelMask; + pwm->CTL |= (u32ChannelMask << PWM_CTL_CNTMODE_Pos); +} + +/** + * @brief This function disables PWM capture of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel. + * Set bit 0 to 1 enables channel 0 output, set bit 1 to 1 enables channel 1 output... + * @return None + */ +void PWM_DisableCapture (PWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->CAPCTL &= ~u32ChannelMask; + pwm->CAPINEN &= ~u32ChannelMask; +} + +/** + * @brief This function enables PWM output generation of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel. + * Set bit 0 to 1 enables channel 0 output, set bit 1 to 1 enables channel 1 output... + * @return None + */ +void PWM_EnableOutput (PWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->POEN |= u32ChannelMask; +} + +/** + * @brief This function disables PWM output generation of selected channels + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel + * Set bit 0 to 1 disables channel 0 output, set bit 1 to 1 disables channel 1 output... + * @return None + */ +void PWM_DisableOutput (PWM_T *pwm, uint32_t u32ChannelMask) +{ + pwm->POEN &= ~u32ChannelMask; +} + +/** + * @brief This function enable Dead zone of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Duration Dead Zone length in PWM clock count, valid values are between 0~0xFF, but 0 means there is no + * dead zone. + * @return None + */ +void PWM_EnableDeadZone (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Duration) +{ + // every two channels shares the same setting + u32ChannelNum >>= 1; + // set duration + pwm->DTCTL = (pwm->DTCTL & ~(PWM_DTCTL_DTCNT01_Msk << (8 * u32ChannelNum))) | (u32Duration << (8 * u32ChannelNum)); + // enable dead zone + pwm->DTCTL |= (PWM_DTCTL_DTEN01_Msk << u32ChannelNum); +} + +/** + * @brief This function disable Dead zone of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void PWM_DisableDeadZone (PWM_T *pwm, uint32_t u32ChannelNum) +{ + // every two channels shares the same setting + u32ChannelNum >>= 1; + // enable dead zone + pwm->DTCTL &= ~(PWM_DTCTL_DTEN01_Msk << u32ChannelNum); +} + +/** + * @brief This function enable capture interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Edge Capture interrupt type. It could be either + * - \ref PWM_FALLING_LATCH_INT_ENABLE + * - \ref PWM_RISING_LATCH_INT_ENABLE + * - \ref PWM_RISING_FALLING_LATCH_INT_ENABLE + * @return None + */ +void PWM_EnableCaptureInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge) +{ + // enable capture interrupt + pwm->INTEN |= (u32Edge << u32ChannelNum); +} + +/** + * @brief This function disable capture interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Edge Capture interrupt type. It could be either + * - \ref PWM_FALLING_LATCH_INT_ENABLE + * - \ref PWM_RISING_LATCH_INT_ENABLE + * - \ref PWM_RISING_FALLING_LATCH_INT_ENABLE + * @return None + */ +void PWM_DisableCaptureInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge) +{ + // disable capture interrupt + pwm->INTEN &= ~(u32Edge << u32ChannelNum); +} + +/** + * @brief This function clear capture interrupt flag of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32Edge Capture interrupt type. It could be either + * - \ref PWM_FALLING_LATCH_INT_ENABLE + * - \ref PWM_RISING_LATCH_INT_ENABLE + * - \ref PWM_RISING_FALLING_LATCH_INT_ENABLE + * @return None + */ +void PWM_ClearCaptureIntFlag (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge) +{ + // disable capture interrupt flag + pwm->INTSTS = (u32Edge << u32ChannelNum); +} + +/** + * @brief This function get capture interrupt flag of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return Capture interrupt flag of specified channel + * @retval 0 Capture interrupt did not occurred + * @retval PWM_RISING_LATCH_INT_FLAG Rising edge latch interrupt occurred + * @retval PWM_FALLING_LATCH_INT_FLAG Falling edge latch interrupt occurred + * @retval PWM_RISING_FALLING_LATCH_INT_FLAG Rising and falling edge latch interrupt occurred + */ +uint32_t PWM_GetCaptureIntFlag (PWM_T *pwm, uint32_t u32ChannelNum) +{ + return ((pwm->INTSTS >> u32ChannelNum) & PWM_RISING_FALLING_LATCH_INT_FLAG); +} + +/** + * @brief This function enable duty interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32IntDutyType Duty interrupt type. It could be either + * - \ref PWM_DUTY_INT_MATCH_CMR_UP + * - \ref PWM_DUTY_INT_MATCH_CMR_DN + * @return None + */ +void PWM_EnableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntDutyType) +{ + // set duty interrupt type + pwm->INTCTL = (pwm->INTCTL & ~(PWM_DUTY_INT_MATCH_CMR_UP << u32ChannelNum)) | (u32IntDutyType << u32ChannelNum); + // enable duty interrupt + pwm->INTEN |= ((1 << PWM_INTEN_DIEN_Pos) << u32ChannelNum); +} + +/** + * @brief This function disable duty interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void PWM_DisableDutyInt (PWM_T *pwm, uint32_t u32ChannelNum) +{ + pwm->INTEN &= ~((1 << PWM_INTEN_DIEN_Pos) << u32ChannelNum); +} + +/** + * @brief This function clears duty interrupt flag of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void PWM_ClearDutyIntFlag (PWM_T *pwm, uint32_t u32ChannelNum) +{ + // write 1 clear + pwm->INTSTS = (1 << PWM_INTSTS_DIF_Pos) << u32ChannelNum; +} + +/** + * @brief This function get duty interrupt flag of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return Duty interrupt flag of specified channel + * @retval 0 Duty interrupt did not occurred + * @retval 1 Duty interrupt occurred + */ +uint32_t PWM_GetDutyIntFlag (PWM_T *pwm, uint32_t u32ChannelNum) +{ + return(pwm->INTSTS & ((1 << PWM_INTSTS_DIF_Pos) << u32ChannelNum) ? 1 : 0); +} + +/** + * @brief This function enable fault brake interrupt + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource This parameter is not used + * @return None + */ +void PWM_EnableFaultBrakeInt (PWM_T *pwm, uint32_t u32BrakeSource) +{ + pwm->INTEN |= PWM_INTEN_BRKIEN_Msk; +} + +/** + * @brief This function disable fault brake interrupt + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource This parameter is not used + * @return None + */ +void PWM_DisableFaultBrakeInt (PWM_T *pwm, uint32_t u32BrakeSource) +{ + pwm->INTEN &= ~PWM_INTEN_BRKIEN_Msk; +} + +/** + * @brief This function clear fault brake interrupt of selected source + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource Fault brake source, could be either + * - \ref PWM_INTSTS_BRKIF0_Msk, or + * - \ref PWM_INTSTS_BRKIF1_Msk + * @return None + */ +void PWM_ClearFaultBrakeIntFlag (PWM_T *pwm, uint32_t u32BrakeSource) +{ + pwm->INTSTS = u32BrakeSource; +} + +/** + * @brief This function get fault brake interrupt of selected source + * @param[in] pwm The base address of PWM module + * @param[in] u32BrakeSource Fault brake source, could be either + * - \ref PWM_INTSTS_BRKIF0_Msk, or + * - \ref PWM_INTSTS_BRKIF1_Msk + * @return Fault brake interrupt flag of specified source + * @retval 0 Fault brake interrupt did not occurred + * @retval 1 Fault brake interrupt occurred + */ +uint32_t PWM_GetFaultBrakeIntFlag (PWM_T *pwm, uint32_t u32BrakeSource) +{ + return (pwm->INTSTS & u32BrakeSource ? 1 : 0); +} + +/** + * @brief This function enable period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @param[in] u32IntPeriodType Period interrupt type, could be either + * - \ref PWM_PERIOD_INT_UNDERFLOW + * - \ref PWM_PERIOD_INT_MATCH_CNR + * @return None + * @note All channels share the same period interrupt type setting. + */ +void PWM_EnablePeriodInt (PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32IntPeriodType) +{ + // set period interrupt type + pwm->INTCTL = (pwm->INTCTL & ~(PWM_PERIOD_INT_MATCH_CNR << u32ChannelNum)) | (u32IntPeriodType << u32ChannelNum); + // enable period interrupt + pwm->INTEN |= ((1 << PWM_INTEN_PIEN_Pos) << u32ChannelNum); +} + +/** + * @brief This function disable period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void PWM_DisablePeriodInt (PWM_T *pwm, uint32_t u32ChannelNum) +{ + pwm->INTEN &= ~((1 << PWM_INTEN_PIEN_Pos) << u32ChannelNum); +} + +/** + * @brief This function clear period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return None + */ +void PWM_ClearPeriodIntFlag (PWM_T *pwm, uint32_t u32ChannelNum) +{ + // write 1 clear + pwm->INTSTS = ((1 << PWM_INTSTS_PIF_Pos) << u32ChannelNum); +} + +/** + * @brief This function get period interrupt of selected channel + * @param[in] pwm The base address of PWM module + * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5 + * @return Period interrupt flag of specified channel + * @retval 0 Period interrupt did not occurred + * @retval 1 Period interrupt occurred + */ +uint32_t PWM_GetPeriodIntFlag (PWM_T *pwm, uint32_t u32ChannelNum) +{ + return(pwm->INTSTS & ((1 << PWM_INTSTS_PIF_Pos) << u32ChannelNum) ? 1 : 0); +} + + + +/*@}*/ /* end of group NUC472_442_PWM_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_PWM_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/rtc.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/rtc.c new file mode 100644 index 0000000000000000000000000000000000000000..cb2533906e3624b3d384b028ccc9cabd09b14ae2 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/rtc.c @@ -0,0 +1,876 @@ +/**************************************************************************//** + * @file rtc.c + * @version V1.00 + * $Revision: 18 $ + * $Date: 15/11/26 10:43a $ + * @brief NUC472/NUC442 RTC driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + + +#include +#include "NUC472_442.h" + +/*---------------------------------------------------------------------------------------------------------*/ +/* Includes of local headers */ +/*---------------------------------------------------------------------------------------------------------*/ + + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_RTC_Driver RTC Driver + @{ +*/ +/// @cond HIDDEN_SYMBOLS + +/*---------------------------------------------------------------------------------------------------------*/ +/* Macro, type and constant definitions */ +/*---------------------------------------------------------------------------------------------------------*/ +#define RTC_GLOBALS + +/*---------------------------------------------------------------------------------------------------------*/ +/* Global file scope (static) variables */ +/*---------------------------------------------------------------------------------------------------------*/ +static volatile uint32_t g_u32Reg, g_u32Reg1,g_u32hiYear,g_u32loYear,g_u32hiMonth,g_u32loMonth,g_u32hiDay,g_u32loDay; +static volatile uint32_t g_u32hiHour,g_u32loHour,g_u32hiMin,g_u32loMin,g_u32hiSec,g_u32loSec; + +/// @endcond HIDDEN_SYMBOLS + +/** @addtogroup NUC472_442_RTC_EXPORTED_FUNCTIONS RTC Exported Functions + @{ +*/ + + +/** + * @brief Set Frequency Compensation Data + * + * @param[in] i32FrequencyX100 Specify the RTC clock X100, ex: 3277365 means 32773.65. + * + * @return None + * + */ +void RTC_32KCalibration(int32_t i32FrequencyX100) +{ + int32_t i32RegInt,i32RegFra ; + + /* Compute Integer and Fraction for RTC register*/ + i32RegInt = (i32FrequencyX100/100) - RTC_FCR_REFERENCE; + i32RegFra = (((i32FrequencyX100%100)) * 60) / 100; + + /* Judge Integer part is reasonable */ + if ( (i32RegInt < 0) | (i32RegInt > 15) ) { + return; + } + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->FREQADJ = (uint32_t)((i32RegInt<<8) | i32RegFra); + +} + +/** + * @brief This function is used to: + * 1. Write initial key to let RTC start count. \n + * 2. Input parameter indicates start time. \n + * Null pointer for using default starting time. \n + * + * @param[in] sPt \n + * Specify the time property and current time. It includes: \n + * u32Year: Year value. \n + * u32Month: Month value. \n + * u32Day: Day value. \n + * u32DayOfWeek: Day of week. [ \ref RTC_SUNDAY / \ref RTC_MONDAY / \ref RTC_TUESDAY / + * \ref RTC_WEDNESDAY / \ref RTC_THURSDAY / \ref RTC_FRIDAY / + * \ref RTC_SATURDAY] \n + * u32Hour: Hour value. \n + * u32Minute: Minute value. \n + * u32Second: Second value. \n + * u32TimeScale: [ \ref RTC_CLOCK_12 / \ref RTC_CLOCK_24] \n + * u8AmPm: [ \ref RTC_AM / \ref RTC_PM] \n + * + * @return None + * + */ +void RTC_Open (S_RTC_TIME_DATA_T *sPt) +{ + uint32_t u32Reg; + + volatile int32_t i32delay=1000; + + if(RTC->INIT != 0x1) { + RTC->INIT = RTC_INIT_KEY; + + while(RTC->INIT != 0x1); + } + + if(sPt == NULL) + return; + + /*-----------------------------------------------------------------------------------------------------*/ + /* Second, set RTC 24/12 hour setting */ + /*-----------------------------------------------------------------------------------------------------*/ + if (sPt->u32TimeScale == RTC_CLOCK_12) { + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk; + + /*-------------------------------------------------------------------------------------------------*/ + /* important, range of 12-hour PM mode is 21 up to 32 */ + /*-------------------------------------------------------------------------------------------------*/ + if (sPt->u32AmPm == RTC_PM) + sPt->u32Hour += 20; + } else { /* RTC_CLOCK_24 */ + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk; + } + + /*-----------------------------------------------------------------------------------------------------*/ + /* Set RTC Calender Loading */ + /*-----------------------------------------------------------------------------------------------------*/ + u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20; + u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16); + u32Reg |= ((sPt->u32Month / 10) << 12); + u32Reg |= ((sPt->u32Month % 10) << 8); + u32Reg |= ((sPt->u32Day / 10) << 4); + u32Reg |= (sPt->u32Day % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->CAL = (uint32_t)g_u32Reg; + + /*-----------------------------------------------------------------------------------------------------*/ + /* Set RTC Time Loading */ + /*-----------------------------------------------------------------------------------------------------*/ + u32Reg = ((sPt->u32Hour / 10) << 20); + u32Reg |= ((sPt->u32Hour % 10) << 16); + u32Reg |= ((sPt->u32Minute / 10) << 12); + u32Reg |= ((sPt->u32Minute % 10) << 8); + u32Reg |= ((sPt->u32Second / 10) << 4); + u32Reg |= (sPt->u32Second % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->TIME = (uint32_t)g_u32Reg; + + RTC->WEEKDAY = sPt->u32DayOfWeek; + + /* Waiting for RTC settings stable */ + while(i32delay--); + +} + +/** + * @brief Read current date/time from RTC setting + * + * @param[out] sPt \n + * Specify the time property and current time. It includes: \n + * u32Year: Year value \n + * u32Month: Month value \n + * u32Day: Day value \n + * u32DayOfWeek: Day of week \n + * u32Hour: Hour value \n + * u32Minute: Minute value \n + * u32Second: Second value \n + * u32TimeScale: \ref RTC_CLOCK_12 / \ref RTC_CLOCK_24 \n + * u8AmPm: \ref RTC_AM / \ref RTC_PM \n + * + * @return None + * + */ +void RTC_GetDateAndTime(S_RTC_TIME_DATA_T *sPt) +{ + uint32_t u32Tmp; + + sPt->u32TimeScale = RTC->CLKFMT & RTC_CLKFMT_24HEN_Msk; /* 12/24-hour */ + sPt->u32DayOfWeek = RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk; /* Day of week */ + + g_u32hiYear = (RTC->CAL & RTC_CAL_TENYEAR_Msk) >> RTC_CAL_TENYEAR_Pos; + g_u32loYear = (RTC->CAL & RTC_CAL_YEAR_Msk) >> RTC_CAL_YEAR_Pos; + g_u32hiMonth = (RTC->CAL & RTC_CAL_TENMON_Msk) >> RTC_CAL_TENMON_Pos; + g_u32loMonth = (RTC->CAL & RTC_CAL_MON_Msk) >> RTC_CAL_MON_Pos; + g_u32hiDay = (RTC->CAL & RTC_CAL_TENDAY_Msk) >> RTC_CAL_TENDAY_Pos; + g_u32loDay = (RTC->CAL & RTC_CAL_DAY_Msk); + + g_u32hiHour = (RTC->TIME & RTC_TIME_TENHR_Msk) >> RTC_TIME_TENHR_Pos; + g_u32loHour = (RTC->TIME & RTC_TIME_HR_Msk) >> RTC_TIME_HR_Pos; + g_u32hiMin = (RTC->TIME & RTC_TIME_TENMIN_Msk) >> RTC_TIME_TENMIN_Pos; + g_u32loMin = (RTC->TIME & RTC_TIME_MIN_Msk) >> RTC_TIME_MIN_Pos; + g_u32hiSec = (RTC->TIME & RTC_TIME_TENSEC_Msk) >> RTC_TIME_TENSEC_Pos; + g_u32loSec = (RTC->TIME & RTC_TIME_SEC_Msk); + + u32Tmp = (g_u32hiYear * 10); /* Compute to 20XX year */ + u32Tmp += g_u32loYear; + sPt->u32Year = u32Tmp + RTC_YEAR2000; + + u32Tmp = (g_u32hiMonth * 10); /* Compute 0~12 month */ + sPt->u32Month = u32Tmp + g_u32loMonth; + + u32Tmp = (g_u32hiDay * 10); /* Compute 0~31 day */ + sPt->u32Day = u32Tmp + g_u32loDay; + + if (sPt->u32TimeScale == RTC_CLOCK_12) { /* Compute12/24 hour */ + u32Tmp = (g_u32hiHour * 10); + u32Tmp+= g_u32loHour; + sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */ + + if (sPt->u32Hour >= 21) { + sPt->u32AmPm = RTC_PM; + sPt->u32Hour -= 20; + } else { + sPt->u32AmPm = RTC_AM; + } + + u32Tmp = (g_u32hiMin * 10); + u32Tmp+= g_u32loMin; + sPt->u32Minute = u32Tmp; + + u32Tmp = (g_u32hiSec * 10); + u32Tmp+= g_u32loSec; + sPt->u32Second = u32Tmp; + + } else { + /* RTC_CLOCK_24 */ + u32Tmp = (g_u32hiHour * 10); + u32Tmp += g_u32loHour; + sPt->u32Hour = u32Tmp; + + u32Tmp = (g_u32hiMin * 10); + u32Tmp += g_u32loMin; + sPt->u32Minute = u32Tmp; + + u32Tmp = (g_u32hiSec * 10); + u32Tmp += g_u32loSec; + sPt->u32Second = u32Tmp; + } + +} + + + +/** + * @brief Read alarm date/time from RTC setting + * + * @param[out] sPt \n + * Specify the time property and current time. It includes: \n + * u32Year: Year value \n + * u32Month: Month value \n + * u32Day: Day value \n + * u32DayOfWeek: Day of week \n + * u32Hour: Hour value \n + * u32Minute: Minute value \n + * u32Second: Second value \n + * u32TimeScale: \ref RTC_CLOCK_12 / \ref RTC_CLOCK_24 \n + * u8AmPm: \ref RTC_AM / \ref RTC_PM \n + * + * @return None + * + */ +void RTC_GetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt) +{ + uint32_t u32Tmp; + + sPt->u32TimeScale = RTC->CLKFMT & RTC_CLKFMT_24HEN_Msk; /* 12/24-hour */ + sPt->u32DayOfWeek = RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk; /* Day of week */ + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + g_u32hiYear = (RTC->CALM & RTC_CALM_TENYEAR_Msk) >> RTC_CALM_TENYEAR_Pos; + g_u32loYear = (RTC->CALM & RTC_CALM_YEAR_Msk) >> RTC_CALM_YEAR_Pos; + g_u32hiMonth = (RTC->CALM & RTC_CALM_TENMON_Msk) >> RTC_CALM_TENMON_Pos; + g_u32loMonth = (RTC->CALM & RTC_CALM_MON_Msk) >> RTC_CALM_MON_Pos; + g_u32hiDay = (RTC->CALM & RTC_CALM_TENDAY_Msk) >> RTC_CALM_TENDAY_Pos; + g_u32loDay = (RTC->CALM & RTC_CALM_DAY_Msk); + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + g_u32hiHour = (RTC->TALM & RTC_TALM_TENHR_Msk) >> RTC_TALM_TENHR_Pos; + g_u32loHour = (RTC->TALM & RTC_TALM_HR_Msk) >> RTC_TALM_HR_Pos; + g_u32hiMin = (RTC->TALM & RTC_TALM_TENMIN_Msk) >> RTC_TALM_TENMIN_Pos; + g_u32loMin = (RTC->TALM & RTC_TALM_MIN_Msk) >> RTC_TALM_MIN_Pos; + g_u32hiSec = (RTC->TALM & RTC_TALM_TENSEC_Msk) >> RTC_TALM_TENSEC_Pos; + g_u32loSec = (RTC->TALM & RTC_TALM_SEC_Msk); + + u32Tmp = (g_u32hiYear * 10); /* Compute to 20XX year */ + u32Tmp += g_u32loYear; + sPt->u32Year = u32Tmp + RTC_YEAR2000; + + u32Tmp = (g_u32hiMonth * 10); /* Compute 0~12 month */ + sPt->u32Month = u32Tmp + g_u32loMonth; + + u32Tmp = (g_u32hiDay * 10); /* Compute 0~31 day */ + sPt->u32Day = u32Tmp + g_u32loDay; + + if (sPt->u32TimeScale == RTC_CLOCK_12) { /* Compute12/24 hour */ + u32Tmp = (g_u32hiHour * 10); + u32Tmp += g_u32loHour; + sPt->u32Hour = u32Tmp; /* AM: 1~12. PM: 21~32. */ + + if (sPt->u32Hour >= 21) { + sPt->u32AmPm = RTC_PM; + sPt->u32Hour -= 20; + } else { + sPt->u32AmPm = RTC_AM; + } + + u32Tmp = (g_u32hiMin * 10); + u32Tmp += g_u32loMin; + sPt->u32Minute = u32Tmp; + + u32Tmp = (g_u32hiSec * 10); + u32Tmp += g_u32loSec; + sPt->u32Second = u32Tmp; + + } else { + /* RTC_CLOCK_24 */ + u32Tmp = (g_u32hiHour * 10); + u32Tmp += g_u32loHour; + sPt->u32Hour = u32Tmp; + + u32Tmp = (g_u32hiMin * 10); + u32Tmp+= g_u32loMin; + sPt->u32Minute = u32Tmp; + + u32Tmp = (g_u32hiSec * 10); + u32Tmp += g_u32loSec; + sPt->u32Second = u32Tmp; + } + +} + + + +/** + * @brief This function is used to update date/time to RTC. + * + * @param[in] sPt \n + * Specify the time property and current time. It includes: \n + * u32Year: Year value. \n + * u32Month: Month value. \n + * u32Day: Day value. \n + * u32DayOfWeek: Day of week. [ \ref RTC_SUNDAY / \ref RTC_MONDAY / \ref RTC_TUESDAY / + * \ref RTC_WEDNESDAY / \ref RTC_THURSDAY / \ref RTC_FRIDAY / + * \ref RTC_SATURDAY] \n + * u32Hour: Hour value. \n + * u32Minute: Minute value. \n + * u32Second: Second value. \n + * u32TimeScale: [ \ref RTC_CLOCK_12 / \ref RTC_CLOCK_24] \n + * u8AmPm: [ \ref RTC_AM / \ref RTC_PM] \n + * + * + * @return None + * + * + */ +void RTC_SetDateAndTime(S_RTC_TIME_DATA_T *sPt) +{ + uint32_t u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + if (sPt->u32TimeScale == RTC_CLOCK_12) { + RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk; + + /*-----------------------------------------------------------------------------------------*/ + /* important, range of 12-hour PM mode is 21 up to 32 */ + /*-----------------------------------------------------------------------------------------*/ + if (sPt->u32AmPm == RTC_PM) + sPt->u32Hour += 20; + } else { /* RTC_CLOCK_24 */ + RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk; + } + + RTC->WEEKDAY = sPt->u32DayOfWeek & RTC_WEEKDAY_WEEKDAY_Msk; + + u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20; + u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16); + u32Reg |= ((sPt->u32Month / 10) << 12); + u32Reg |= ((sPt->u32Month % 10) << 8); + u32Reg |= ((sPt->u32Day / 10) << 4); + u32Reg |= (sPt->u32Day % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->CAL = (uint32_t)g_u32Reg; + + u32Reg = ((sPt->u32Hour / 10) << 20); + u32Reg |= ((sPt->u32Hour % 10) << 16); + u32Reg |= ((sPt->u32Minute / 10) << 12); + u32Reg |= ((sPt->u32Minute % 10) << 8); + u32Reg |= ((sPt->u32Second / 10) << 4); + u32Reg |= (sPt->u32Second % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->TIME = (uint32_t)g_u32Reg; + +} + +/** + * @brief This function is used to set alarm date/time to RTC. + * + * @param[in] sPt \n + * Specify the time property and current time. It includes: \n + * u32Year: Year value. \n + * u32Month: Month value. \n + * u32Day: Day value. \n + * u32DayOfWeek: Day of week. [ \ref RTC_SUNDAY / \ref RTC_MONDAY / \ref RTC_TUESDAY / + * \ref RTC_WEDNESDAY / \ref RTC_THURSDAY / \ref RTC_FRIDAY / + * \ref RTC_SATURDAY] \n + * u32Hour: Hour value. \n + * u32Minute: Minute value. \n + * u32Second: Second value. \n + * u32TimeScale: [ \ref RTC_CLOCK_12 / \ref RTC_CLOCK_24] \n + * u8AmPm: [ \ref RTC_AM / \ref RTC_PM] \n + * + * @return None + * + */ +void RTC_SetAlarmDateAndTime(S_RTC_TIME_DATA_T *sPt) +{ + uint32_t u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + if (sPt->u32TimeScale == RTC_CLOCK_12) { + RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk; + + /*-----------------------------------------------------------------------------------------*/ + /* important, range of 12-hour PM mode is 21 up to 32 */ + /*-----------------------------------------------------------------------------------------*/ + if (sPt->u32AmPm == RTC_PM) + sPt->u32Hour += 20; + } else { /* RTC_CLOCK_24 */ + RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk; + } + + RTC->WEEKDAY = sPt->u32DayOfWeek & RTC_WEEKDAY_WEEKDAY_Msk; + + + u32Reg = ((sPt->u32Year - RTC_YEAR2000) / 10) << 20; + u32Reg |= (((sPt->u32Year - RTC_YEAR2000) % 10) << 16); + u32Reg |= ((sPt->u32Month / 10) << 12); + u32Reg |= ((sPt->u32Month % 10) << 8); + u32Reg |= ((sPt->u32Day / 10) << 4); + u32Reg |= (sPt->u32Day % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->CALM = (uint32_t)g_u32Reg; + + u32Reg = ((sPt->u32Hour / 10) << 20); + u32Reg |= ((sPt->u32Hour % 10) << 16); + u32Reg |= ((sPt->u32Minute / 10) << 12); + u32Reg |= ((sPt->u32Minute % 10) << 8); + u32Reg |= ((sPt->u32Second / 10) << 4); + u32Reg |= (sPt->u32Second % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->TALM = (uint32_t)g_u32Reg; + +} + + +/** + * @brief This function is used to update date to RTC + * + * @param[in] u32Year The Year Calendar Digit of Alarm Setting + * @param[in] u32Month The Month Calendar Digit of Alarm Setting + * @param[in] u32Day The Day Calendar Digit of Alarm Setting + * @param[in] u32DayOfWeek The Day of Week. [ \ref RTC_SUNDAY / \ref RTC_MONDAY / \ref RTC_TUESDAY / + * \ref RTC_WEDNESDAY / \ref RTC_THURSDAY / \ref RTC_FRIDAY / + * \ref RTC_SATURDAY] + * + * @return None + * + */ +void RTC_SetDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day, uint32_t u32DayOfWeek) +{ + __IO uint32_t u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->WEEKDAY = u32DayOfWeek & RTC_WEEKDAY_WEEKDAY_Msk; + + u32Reg = ((u32Year - RTC_YEAR2000) / 10) << 20; + u32Reg |= (((u32Year - RTC_YEAR2000) % 10) << 16); + u32Reg |= ((u32Month / 10) << 12); + u32Reg |= ((u32Month % 10) << 8); + u32Reg |= ((u32Day / 10) << 4); + u32Reg |= (u32Day % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->CAL = (uint32_t)g_u32Reg; + +} + +/** + * @brief This function is used to update time to RTC. + * + * @param[in] u32Hour The Hour Time Digit of Alarm Setting. + * @param[in] u32Minute The Month Calendar Digit of Alarm Setting + * @param[in] u32Second The Day Calendar Digit of Alarm Setting + * @param[in] u32TimeMode The 24-Hour / 12-Hour Time Scale Selection. [ \ref RTC_CLOCK_12 / \ref RTC_CLOCK_24] + * @param[in] u32AmPm 12-hour time scale with AM and PM indication. Only Time Scale select 12-hour used. [ \ref RTC_AM / \ref RTC_PM] + * + * @return None + * + */ +void RTC_SetTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm) +{ + __IO uint32_t u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + if (u32TimeMode == RTC_CLOCK_12) { + RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk; + + if (u32AmPm == RTC_PM) /* important, range of 12-hour PM mode is 21 up to 32 */ + u32Hour += 20; + } else if(u32TimeMode == RTC_CLOCK_24) { + RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk; + } + + u32Reg = ((u32Hour / 10) << 20); + u32Reg |= ((u32Hour % 10) << 16); + u32Reg |= ((u32Minute / 10) << 12); + u32Reg |= ((u32Minute % 10) << 8); + u32Reg |= ((u32Second / 10) << 4); + u32Reg |= (u32Second % 10); + + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->TIME = (uint32_t)g_u32Reg; + +} + +/** + * @brief This function is used to set alarm date to RTC + * + * @param[in] u32Year The Year Calendar Digit of Alarm Setting + * @param[in] u32Month The Month Calendar Digit of Alarm Setting + * @param[in] u32Day The Day Calendar Digit of Alarm Setting + * + * @return None + * + */ +void RTC_SetAlarmDate(uint32_t u32Year, uint32_t u32Month, uint32_t u32Day) +{ + __IO uint32_t u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + u32Reg = ((u32Year - RTC_YEAR2000) / 10) << 20; + u32Reg |= (((u32Year - RTC_YEAR2000) % 10) << 16); + u32Reg |= ((u32Month / 10) << 12); + u32Reg |= ((u32Month % 10) << 8); + u32Reg |= ((u32Day / 10) << 4); + u32Reg |= (u32Day % 10); + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->CALM = (uint32_t)g_u32Reg; + +} + +/** + * @brief This function is used to set alarm date to RTC + * + * @param[in] u32Hour The Hour Time Digit of Alarm Setting. + * @param[in] u32Minute The Minute Time Digit of Alarm Setting + * @param[in] u32Second The Second Time Digit of Alarm Setting + * @param[in] u32TimeMode The 24-Hour / 12-Hour Time Scale Selection. [ \ref RTC_CLOCK_12 / \ref RTC_CLOCK_24] + * @param[in] u32AmPm 12-hour time scale with AM and PM indication. Only Time Scale select 12-hour used. [ \ref RTC_AM / \ref RTC_PM] + * + * @return None + * + */ +void RTC_SetAlarmTime(uint32_t u32Hour, uint32_t u32Minute, uint32_t u32Second, uint32_t u32TimeMode, uint32_t u32AmPm) +{ + __IO uint32_t u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + if (u32TimeMode == RTC_CLOCK_12) { + RTC->CLKFMT &= ~RTC_CLKFMT_24HEN_Msk; + + if (u32AmPm == RTC_PM) /* important, range of 12-hour PM mode is 21 up to 32 */ + u32Hour += 20; + } else if(u32TimeMode == RTC_CLOCK_24) { + RTC->CLKFMT |= RTC_CLKFMT_24HEN_Msk; + } + + u32Reg = ((u32Hour / 10) << 20); + u32Reg |= ((u32Hour % 10) << 16); + u32Reg |= ((u32Minute / 10) << 12); + u32Reg |= ((u32Minute % 10) << 8); + u32Reg |= ((u32Second / 10) << 4); + u32Reg |= (u32Second % 10); + + g_u32Reg = u32Reg; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->TALM = (uint32_t)g_u32Reg; + +} + + +/** + * @brief The spare registers access enable + * + * @return None + * + */ +void RTC_EnableSpareAccess(void) +{ + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->SPRCTL |= RTC_SPRCTL_SPRRWEN_Msk; + + while(!(RTC->SPRCTL & RTC_SPRCTL_SPRRWRDY_Msk)); +} + + +/** + * @brief This function is used to: + * 1. Enable tamper detection function. \n + * 2. Set tamper detect pin number. \n + * 3. Set tamper control register, interrupt. \n + * 4. Clear tamper status. \n + * 5. Destroy Spare Register when tamper detected \n + * + * @param[in] u32PinNumber tamper detect pin number. [ \ref RTC_TAMPER_0 / \ref RTC_TAMPER_1] + * @param[in] u32PinCondition set tamper detection condition: 1=High level detect, 0=Low level detect + * @param[in] u32IntFlag Enable/Disable tamper interrupt: 1=Enable, 0=Disable + * @param[in] u32ClearFlag Clear tamper status + * @param[in] u32DestroyEn Enable/Disable Destroy Spare Register when tamper detected: 1=Enable, 0=Disable + * + * @return None + * + */ +void RTC_EnableTamperDetection(uint32_t u32PinNumber, uint32_t u32PinCondition, uint32_t u32IntFlag, uint32_t u32ClearFlag, uint32_t u32DestroyEn) +{ + uint32_t u32Tmp; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + u32Tmp = RTC->TAMPCTL; + + if(u32PinNumber == RTC_TAMPER_0) { + //if(u32ClearFlag) + // RTC->TAMPSTS = RTC_TAMPSTS_TAMPSTS0_Msk; + + if(u32PinCondition) + u32Tmp |= RTC_TAMPCTL_TAMPLV0_Msk; + else + u32Tmp &= ~RTC_TAMPCTL_TAMPLV0_Msk; + + u32Tmp |= RTC_TAMPCTL_TAMPDBEN0_Msk; + u32Tmp |= RTC_TAMPCTL_TAMPEN0_Msk; + } else if(u32PinNumber == RTC_TAMPER_1) { + //if(u32ClearFlag) + // RTC->TAMPSTS = RTC_TAMPSTS_TAMPSTS1_Msk; + + if(u32PinCondition) + u32Tmp |= RTC_TAMPCTL_TAMPLV1_Msk; + else + u32Tmp &= ~RTC_TAMPCTL_TAMPLV1_Msk; + + u32Tmp |= RTC_TAMPCTL_TAMPDBEN1_Msk; + u32Tmp |= RTC_TAMPCTL_TAMPEN1_Msk; + } + + if(u32IntFlag) + u32Tmp |= RTC_TAMPCTL_TIEN_Msk; + else + u32Tmp &= ~RTC_TAMPCTL_TIEN_Msk; + + if(u32DestroyEn) + u32Tmp |= RTC_TAMPCTL_DESTROYEN_Msk; + else + u32Tmp &= ~RTC_TAMPCTL_DESTROYEN_Msk; + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->TAMPCTL = u32Tmp; + + while(RTC->RWEN & RTC_RWEN_RWENF_Msk); + + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + if(u32PinNumber == RTC_TAMPER_0) { + if(u32ClearFlag) + RTC->TAMPSTS = RTC_TAMPSTS_TAMPSTS0_Msk; + } else if(u32PinNumber == RTC_TAMPER_1) { + if(u32ClearFlag) + RTC->TAMPSTS = RTC_TAMPSTS_TAMPSTS1_Msk; + } +} + +/** + * @brief This function is used to disable tamper detection function. + * + * @param[in] u32PinNumber tamper detect pin number: \ref RTC_TAMPER_0, \ref RTC_TAMPER_1 + * + * @return None + * + */ +void RTC_DisableTamperDetection(uint32_t u32PinNumber) +{ + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + if(u32PinNumber == RTC_TAMPER_0) { + RTC->TAMPCTL &= ~RTC_TAMPCTL_TAMPEN0_Msk; + } else if(u32PinNumber == RTC_TAMPER_1) { + RTC->TAMPCTL &= ~RTC_TAMPCTL_TAMPEN1_Msk; + } + +} + +/** + * @brief This function is used to get day of week. + * + * @param None + * + * @return Day of week + * + */ +uint32_t RTC_GetDayOfWeek(void) +{ + return (RTC->WEEKDAY & RTC_WEEKDAY_WEEKDAY_Msk); +} + +/** + * @brief The function is used to set time tick period for periodic time tick Interrupt. + * + * @param[in] u32TickSelection + * It is used to set the RTC time tick period for Periodic Time Tick Interrupt request. + * It consists of: \n + * - \ref RTC_TICK_1_SEC : Time tick is 1 second \n + * - \ref RTC_TICK_1_2_SEC : Time tick is 1/2 second \n + * - \ref RTC_TICK_1_4_SEC : Time tick is 1/4 second \n + * - \ref RTC_TICK_1_8_SEC : Time tick is 1/8 second \n + * - \ref RTC_TICK_1_16_SEC : Time tick is 1/16 second \n + * - \ref RTC_TICK_1_32_SEC : Time tick is 1/32 second \n + * - \ref RTC_TICK_1_64_SEC : Time tick is 1/64 second \n + * - \ref RTC_TICK_1_128_SEC : Time tick is 1/128 second + * + * @return None + * + */ +void RTC_SetTickPeriod(uint32_t u32TickSelection) +{ + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->TICK = RTC->TICK & ~RTC_TICK_TICKSEL_Msk | u32TickSelection; +} + +/** + * @brief The function is used to enable specified interrupt. + * + * @param[in] u32IntFlagMask The structure of interrupt source. It consists of: \n + * \ref RTC_INTEN_ALMIEN_Msk : Alarm interrupt \n + * \ref RTC_INTEN_TICKIEN_Msk : Tick interrupt \n + * + * @return None + * + */ +void RTC_EnableInt(uint32_t u32IntFlagMask) +{ + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + RTC->INTEN |= u32IntFlagMask; +} + +/** + * @brief The function is used to disable specified interrupt. + * + * @param[in] u32IntFlagMask The structure of interrupt source. It consists of: \n + * \ref RTC_INTEN_ALMIEN_Msk : Alarm interrupt \n + * \ref RTC_INTEN_TICKIEN_Msk : Tick interrupt \n + * + * @return None + * + */ +void RTC_DisableInt(uint32_t u32IntFlagMask) +{ + RTC->RWEN = RTC_WRITE_KEY; + while(!(RTC->RWEN & RTC_RWEN_RWENF_Msk)); + + if(u32IntFlagMask & RTC_INTEN_TICKIEN_Msk) { + RTC->INTEN &= ~RTC_INTEN_TICKIEN_Msk; + RTC->INTSTS |= RTC_INTSTS_TICKIF_Msk; + } + + if(u32IntFlagMask & RTC_INTEN_ALMIEN_Msk) { + RTC->INTEN &= ~RTC_INTEN_ALMIEN_Msk; + RTC->INTSTS |= RTC_INTSTS_ALMIF_Msk; + } + +} + +/** + * @brief Disable RTC clock. + * + * @return None + * + */ +void RTC_Close (void) +{ + CLK->APBCLK0 &= ~CLK_APBCLK0_RTCCKEN_Msk; +} + + +/*@}*/ /* end of group NUC472_442_RTC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_RTC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sc.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sc.c new file mode 100644 index 0000000000000000000000000000000000000000..dea6c763acd69b3ba803706ea68dfdb693148fc7 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sc.c @@ -0,0 +1,287 @@ +/**************************************************************************//** + * @file sc.c + * @version V1.00 + * $Revision: 6 $ + * $Date: 14/08/12 7:25p $ + * @brief NUC472/NUC442 Smartcard(SC) driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +// Below are variables used locally by SC driver and does not want to parse by doxygen unless HIDDEN_SYMBOLS is defined +/// @cond HIDDEN_SYMBOLS +static uint32_t u32CardStateIgnore[SC_INTERFACE_NUM] = {0, 0, 0, 0, 0, 0}; + +/// @endcond HIDDEN_SYMBOLS + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SC_Driver SC Driver + @{ +*/ + + +/** @addtogroup NUC472_442_SC_EXPORTED_FUNCTIONS SC Exported Functions + @{ +*/ + +/** + * @brief This function indicates specified smartcard slot status + * @param[in] sc Base address of smartcard module + * @return Card insert status + * @retval TRUE Card insert + * @retval FALSE Card remove + */ +uint32_t SC_IsCardInserted(SC_T *sc) +{ + // put conditions into two variable to remove IAR compilation warning + uint32_t cond1 = ((sc->STATUS & SC_STATUS_CDPINSTS_Msk) >> SC_STATUS_CDPINSTS_Pos); + uint32_t cond2 = ((sc->CTL & SC_CTL_CDLV_Msk) >> SC_CTL_CDLV_Pos); + + if(sc == SC0 && u32CardStateIgnore[0] == 1) + return TRUE; + else if(sc == SC1 && u32CardStateIgnore[1] == 1) + return TRUE; + else if(sc == SC2 && u32CardStateIgnore[2] == 1) + return TRUE; + else if(sc == SC3 && u32CardStateIgnore[3] == 1) + return TRUE; + else if(sc == SC4 && u32CardStateIgnore[4] == 1) + return TRUE; + else if(sc == SC5 && u32CardStateIgnore[5] == 1) + return TRUE; + else if(cond1 != cond2) + return FALSE; + else + return TRUE; +} + +/** + * @brief This function reset both transmit and receive FIFO of specified smartcard module + * @param[in] sc Base address of smartcard module + * @return None + */ +void SC_ClearFIFO(SC_T *sc) +{ + sc->ALTCTL |= (SC_ALTCTL_TXRST_Msk | SC_ALTCTL_RXRST_Msk); +} + +/** + * @brief This function disable specified smartcard module + * @param[in] sc Base address of smartcard module + * @return None + */ +void SC_Close(SC_T *sc) +{ + sc->INTEN = 0; + while(sc->PINCTL & SC_PINCTL_SYNC_Msk); + sc->PINCTL = 0; + sc->ALTCTL = 0; + while(sc->CTL & SC_CTL_SYNC_Msk); + sc->CTL = 0; +} + +/** + * @brief This function initialized smartcard module + * @param[in] sc Base address of smartcard module + * @param[in] u32CD Card detect polarity, select the CD pin state which indicates card insert. Could be + * -\ref SC_PIN_STATE_HIGH + * -\ref SC_PIN_STATE_LOW + * -\ref SC_PIN_STATE_IGNORE, no card detect pin, always assumes card present + * @param[in] u32PWR Power on polarity, select the PWR pin state which could set smartcard VCC to high level. Could be + * -\ref SC_PIN_STATE_HIGH + * -\ref SC_PIN_STATE_LOW + * @return None + */ +void SC_Open(SC_T *sc, uint32_t u32CD, uint32_t u32PWR) +{ + uint32_t u32Reg = 0, u32Intf; + + if(sc == SC0) + u32Intf = 0; + else if(sc == SC1) + u32Intf = 1; + else if(sc == SC2) + u32Intf = 2; + else if(sc == SC3) + u32Intf = 3; + else if(sc == SC4) + u32Intf = 4; + else + u32Intf = 5; + + if(u32CD != SC_PIN_STATE_IGNORE) { + u32Reg = u32CD ? 0: SC_CTL_CDLV_Msk; + u32CardStateIgnore[u32Intf] = 0; + } else { + u32CardStateIgnore[u32Intf] = 1; + } + sc->PINCTL = u32PWR ? 0 : SC_PINCTL_PWRINV_Msk; + while(sc->CTL & SC_CTL_SYNC_Msk); + sc->CTL = SC_CTL_SCEN_Msk | u32Reg; +} + +/** + * @brief This function reset specified smartcard module to its default state for activate smartcard + * @param[in] sc Base address of smartcard module + * @return None + */ +void SC_ResetReader(SC_T *sc) +{ + uint32_t u32Intf; + + if(sc == SC0) + u32Intf = 0; + else if(sc == SC1) + u32Intf = 1; + else if(sc == SC2) + u32Intf = 2; + else if(sc == SC3) + u32Intf = 3; + else if(sc == SC4) + u32Intf = 4; + else + u32Intf = 5; + + // Reset FIFO, enable auto de-activation while card removal + sc->ALTCTL |= (SC_ALTCTL_TXRST_Msk | SC_ALTCTL_RXRST_Msk | SC_ALTCTL_ADACEN_Msk); + // Set Rx trigger level to 1 character, longest card detect debounce period, disable error retry (EMV ATR does not use error retry) + while(sc->CTL & SC_CTL_SYNC_Msk); + sc->CTL &= ~(SC_CTL_RXTRGLV_Msk | + SC_CTL_CDDBSEL_Msk | + SC_CTL_TXRTY_Msk | + SC_CTL_TXRTYEN_Msk | + SC_CTL_RXRTY_Msk | + SC_CTL_RXRTYEN_Msk); + while(sc->CTL & SC_CTL_SYNC_Msk); + // Enable auto convention, and all three smartcard internal timers + sc->CTL |= SC_CTL_AUTOCEN_Msk | SC_CTL_TMRSEL_Msk; + // Disable Rx timeout + sc->RXTOUT = 0; + // 372 clocks per ETU by default + sc->ETUCTL= 371; + + + /* Enable necessary interrupt for smartcard operation */ + if(u32CardStateIgnore[u32Intf]) // Do not enable card detect interrupt if card present state ignore + sc->INTEN = (SC_INTEN_RDAIEN_Msk | + SC_INTEN_TERRIEN_Msk | + SC_INTEN_TMR0IEN_Msk | + SC_INTEN_TMR1IEN_Msk | + SC_INTEN_TMR2IEN_Msk | + SC_INTEN_BGTIEN_Msk | + SC_INTEN_ACERRIEN_Msk); + else + sc->INTEN = (SC_INTEN_RDAIEN_Msk | + SC_INTEN_TERRIEN_Msk | + SC_INTEN_TMR0IEN_Msk | + SC_INTEN_TMR1IEN_Msk | + SC_INTEN_TMR2IEN_Msk | + SC_INTEN_BGTIEN_Msk | + SC_INTEN_CDIEN_Msk | + SC_INTEN_ACERRIEN_Msk); + + return; +} + +/** + * @brief This function block guard time (BGT) of specified smartcard module + * @param[in] sc Base address of smartcard module + * @param[in] u32BGT Block guard time using ETU as unit, valid range are between 1 ~ 32 + * @return None + */ +void SC_SetBlockGuardTime(SC_T *sc, uint32_t u32BGT) +{ + sc->CTL = (sc->CTL & ~SC_CTL_BGT_Msk) | ((u32BGT - 1) << SC_CTL_BGT_Pos); +} + +/** + * @brief This function character guard time (CGT) of specified smartcard module + * @param[in] sc Base address of smartcard module + * @param[in] u32CGT Character guard time using ETU as unit, valid range are between 11 ~ 267 + * @return None + */ +void SC_SetCharGuardTime(SC_T *sc, uint32_t u32CGT) +{ + u32CGT -= sc->CTL & SC_CTL_NSB_Msk ? 11: 12; + sc->EGT = u32CGT; +} + +/** + * @brief This function stop all smartcard timer of specified smartcard module + * @param[in] sc Base address of smartcard module + * @return None + * @note This function stop the timers within smartcard module, \b not timer module + */ +void SC_StopAllTimer(SC_T *sc) +{ + sc->ALTCTL &= ~(SC_ALTCTL_CNTEN0_Msk | SC_ALTCTL_CNTEN1_Msk | SC_ALTCTL_CNTEN2_Msk); +} + +/** + * @brief This function configure and start a smartcard timer of specified smartcard module + * @param[in] sc Base address of smartcard module + * @param[in] u32TimerNum Timer(s) to start. Valid values are 0, 1, 2. + * @param[in] u32Mode Timer operating mode, valid values are: + * - \ref SC_TMR_MODE_0 + * - \ref SC_TMR_MODE_1 + * - \ref SC_TMR_MODE_2 + * - \ref SC_TMR_MODE_3 + * - \ref SC_TMR_MODE_4 + * - \ref SC_TMR_MODE_5 + * - \ref SC_TMR_MODE_6 + * - \ref SC_TMR_MODE_7 + * - \ref SC_TMR_MODE_8 + * - \ref SC_TMR_MODE_F + * @param[in] u32ETUCount Timer timeout duration, ETU based. For timer 0, valid range are between 1~0x1000000ETUs. + * For timer 1 and timer 2, valid range are between 1 ~ 0x100 ETUs + * @return None + * @note This function start the timer within smartcard module, \b not timer module + * @note Depend on the timer operating mode, timer may not start counting immediately + */ +void SC_StartTimer(SC_T *sc, uint32_t u32TimerNum, uint32_t u32Mode, uint32_t u32ETUCount) +{ + uint32_t reg = u32Mode | (SC_TMRCTL0_CNT_Msk & (u32ETUCount - 1)); + + if(u32TimerNum == 0) { + sc->TMRCTL0 = reg; + sc->ALTCTL |= SC_ALTCTL_CNTEN0_Msk; + } else if(u32TimerNum == 1) { + sc->TMRCTL1 = reg; + sc->ALTCTL |= SC_ALTCTL_CNTEN1_Msk; + } else { // timer 2 + sc->TMRCTL2 = reg; + sc->ALTCTL |= SC_ALTCTL_CNTEN2_Msk; + } +} + +/** + * @brief This function stop a smartcard timer of specified smartcard module + * @param[in] sc Base address of smartcard module + * @param[in] u32TimerNum Timer(s) to stop. Valid values are 0, 1, 2. + * @return None + * @note This function stop the timer within smartcard module, \b not timer module + */ +void SC_StopTimer(SC_T *sc, uint32_t u32TimerNum) +{ + if(u32TimerNum == 0) + sc->ALTCTL &= ~SC_ALTCTL_CNTEN0_Msk; + else if(u32TimerNum == 1) + sc->ALTCTL &= ~SC_ALTCTL_CNTEN1_Msk; + else // timer 2 + sc->ALTCTL &= ~SC_ALTCTL_CNTEN2_Msk; +} + + + +/*@}*/ /* end of group NUC472_442_SC_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SC_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/scuart.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/scuart.c new file mode 100644 index 0000000000000000000000000000000000000000..6e254baac04211c6eb4c9bffe5dc864954801e42 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/scuart.c @@ -0,0 +1,218 @@ +/**************************************************************************//** + * @file scuart.c + * @version V1.00 + * $Revision: 7 $ + * $Date: 15/11/09 7:18p $ + * @brief NUC472/NUC442 Smartcard UART mode (SCUART) driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SCUART_Driver SCUART Driver + @{ +*/ + + +/** @addtogroup NUC472_442_SCUART_EXPORTED_FUNCTIONS SCUART Exported Functions + @{ +*/ + +/** + * @brief The function is used to disable smartcard interface UART mode. + * @param sc The base address of smartcard module. + * @return None + */ +void SCUART_Close(SC_T* sc) +{ + sc->INTEN = 0; + sc->UARTCTL = 0; + sc->CTL = 0; + +} +/// @cond HIDDEN_SYMBOLS +/** + * @brief This function returns module clock of specified SC interface + * @param[in] sc The base address of smartcard module. + * @return Module clock of specified SC interface + */ +static uint32_t SCUART_GetClock(SC_T *sc) +{ + uint32_t u32ClkSrc, u32Num, u32Clk; + + if(sc == SC0) + u32Num = 0; + else if(sc == SC1) + u32Num = 1; + else if(sc == SC2) + u32Num = 2; + else if(sc == SC3) + u32Num = 3; + else if(sc == SC4) + u32Num = 4; + else + u32Num = 5; + + u32ClkSrc = (CLK->CLKSEL3 >> (2 * u32Num)) & CLK_CLKSEL3_SC0SEL_Msk; + + // Get smartcard module clock + if(u32ClkSrc == 0) + u32Clk = __HXT; + else if(u32ClkSrc == 1) + u32Clk = CLK_GetPLLClockFreq(); + else if(u32ClkSrc == 2) + u32Clk = CLK_GetPCLKFreq(); + else + u32Clk = __HIRC; + + if(u32Num < 4) { + u32Clk /= (((CLK->CLKDIV1 >> (8 * u32Num)) & CLK_CLKDIV1_SC0DIV_Msk) + 1); + } else { + u32Clk /= (((CLK->CLKDIV2 >> (8 * (u32Num - 4))) & CLK_CLKDIV2_SC4DIV_Msk) + 1); + } + + return u32Clk; +} + +/// @endcond HIDDEN_SYMBOLS + +/** + * @brief This function use to enable smartcard module UART mode and set baudrate. + * @param[in] sc The base address of smartcard module. + * @param[in] u32baudrate Target baudrate of smartcard module. + * @return Actual baudrate of smartcard mode + * @details This function configures character width to 8 bits, 1 stop bit, and no parity. + * And can use \ref SCUART_SetLineConfig function to update these settings + * The baudrate clock source comes from SC_CLK/SC_DIV, where SC_CLK is controlled + * by SCxSEL in CLKSEL3 register, SC_DIV is controlled by SCxDIV in + * CLKDIV1 and CLKDIV2 register. Since the baudrate divider is + * 12-bit wide and must be larger than 4, (clock source / baudrate) must be + * larger or equal to 5 and smaller or equal to 4096. Otherwise this function + * cannot configure SCUART to work with target baudrate. + */ +uint32_t SCUART_Open(SC_T* sc, uint32_t u32baudrate) +{ + uint32_t u32Clk = SCUART_GetClock(sc), u32Div; + + // Calculate divider for target baudrate + u32Div = (u32Clk + (u32baudrate >> 1) - 1) / u32baudrate - 1; + + sc->CTL = SC_CTL_SCEN_Msk | SC_CTL_NSB_Msk; // Enable smartcard interface and stop bit = 1 + sc->UARTCTL = SCUART_CHAR_LEN_8 | SCUART_PARITY_NONE | SC_UARTCTL_UARTEN_Msk; // Enable UART mode, disable parity and 8 bit per character + sc->ETUCTL = u32Div; + + return(u32Clk / u32Div); +} + +/** + * @brief The function is used to read Rx data from RX FIFO. + * @param[in] sc The base address of smartcard module. + * @param[in] pu8RxBuf The buffer to store receive the data + * @param[in] u32ReadBytes Target number of characters to receive + * @return Actual character number reads to buffer + * @note This function does not block and return immediately if there's no data available + */ +uint32_t SCUART_Read(SC_T* sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes) +{ + uint32_t u32Count; + + for(u32Count = 0; u32Count < u32ReadBytes; u32Count++) { + if(SCUART_GET_RX_EMPTY(sc)) { // no data available + break; + } + pu8RxBuf[u32Count] = SCUART_READ(sc); // get data from FIFO + } + + return u32Count; +} + +/** + * @brief This function use to config smartcard UART mode line setting. + * @param[in] sc The base address of smartcard module. + * @param[in] u32Baudrate Target baudrate of smartcard module. If this value is 0, UART baudrate will not change. + * @param[in] u32DataWidth The data length, could be + * - \ref SCUART_CHAR_LEN_5 + * - \ref SCUART_CHAR_LEN_6 + * - \ref SCUART_CHAR_LEN_7 + * - \ref SCUART_CHAR_LEN_8 + * @param[in] u32Parity The parity setting, could be + * - \ref SCUART_PARITY_NONE + * - \ref SCUART_PARITY_ODD + * - \ref SCUART_PARITY_EVEN + * @param[in] u32StopBits The stop bit length, could be + * - \ref SCUART_STOP_BIT_1 + * - \ref SCUART_STOP_BIT_2 + * @return Actual baudrate of smartcard + * @details The baudrate clock source comes from SC_CLK/SC_DIV, where SC_CLK is controlled + * by SCxSEL in CLKSEL3 register, SC_DIV is controlled by SCxDIV in + * CLKDIV1 and CLKDIV2 register. Since the baudrate divider is + * 12-bit wide and must be larger than 4, (clock source / baudrate) must be + * larger or equal to 5 and smaller or equal to 4096. Otherwise this function + * cannot configure SCUART to work with target baudrate. + */ +uint32_t SCUART_SetLineConfig(SC_T* sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits) +{ + + uint32_t u32Clk = SCUART_GetClock(sc), u32Div; + + if(u32Baudrate == 0) { // keep original baudrate setting + u32Div = sc->ETUCTL & SC_ETUCTL_ETURDIV_Msk; + } else { + // Calculate divider for target baudrate + u32Div = (u32Clk + (u32Baudrate >> 1) - 1)/ u32Baudrate - 1; + sc->ETUCTL = u32Div; + } + + sc->CTL = u32StopBits | SC_CTL_SCEN_Msk; // Set stop bit + sc->UARTCTL = u32Parity | u32DataWidth | SC_UARTCTL_UARTEN_Msk; // Set character width and parity + + return(u32Clk / u32Div); +} + +/** + * @brief This function use to set receive timeout count. + * @param[in] sc The base address of smartcard module. + * @param[in] u32TOC Rx timeout counter, using baudrate as counter unit. Valid range are 0~0x1FF, + * set this value to 0 will disable timeout counter + * @return None + * @details The time-out counter resets and starts counting whenever the RX buffer received a + * new data word. Once the counter decrease to 1 and no new data is received or CPU + * does not read any data from FIFO, a receiver time-out interrupt will be generated. + */ +void SCUART_SetTimeoutCnt(SC_T* sc, uint32_t u32TOC) +{ + sc->RXTOUT= u32TOC; +} + + +/** + * @brief This function is to write data into transmit FIFO to send data out. + * @param[in] sc The base address of smartcard module. + * @param[in] pu8TxBuf The buffer containing data to send to transmit FIFO. + * @param[in] u32WriteBytes Number of data to send. + * @return None + * @note This function blocks until all data write into FIFO + */ +void SCUART_Write(SC_T* sc,uint8_t *pu8TxBuf, uint32_t u32WriteBytes) +{ + uint32_t u32Count; + + for(u32Count = 0; u32Count != u32WriteBytes; u32Count++) { + while(SCUART_GET_TX_FULL(sc)); // Wait 'til FIFO not full + sc->DAT = pu8TxBuf[u32Count]; // Write 1 byte to FIFO + } +} + + +/*@}*/ /* end of group NUC472_442_SCUART_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SCUART_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sd.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sd.c new file mode 100644 index 0000000000000000000000000000000000000000..6f189446a4f2faefc8bc60f14f80b0d6930a954a --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sd.c @@ -0,0 +1,1045 @@ +/**************************************************************************//** + * @file SD.c + * @version V1.00 + * $Revision: 16 $ + * $Date: 15/11/26 10:45a $ + * @brief NUC472/NUC442 SD driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include +#include +#include +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SD_Driver SD Driver + @{ +*/ + + +/** @addtogroup NUC472_442_SD_EXPORTED_FUNCTIONS SD Exported Functions + @{ +*/ +#define SD_BLOCK_SIZE 512 + +/// @cond HIDDEN_SYMBOLS + +// global variables +// For response R3 (such as ACMD41, CRC-7 is invalid; but SD controller will still +// calculate CRC-7 and get an error result, software should ignore this error and clear SDISR [CRC_IF] flag +// _sd_uR3_CMD is the flag for it. 1 means software should ignore CRC-7 error +uint32_t _sd_uR3_CMD=0; +uint32_t _sd_uR7_CMD=0; +uint8_t volatile _sd_SDDataReady = FALSE; + +uint8_t *_sd_pSDHCBuffer; +uint32_t _sd_ReferenceClock; + +#if defined (__CC_ARM) +__align(4096) uint8_t _sd_ucSDHCBuffer[512]; +#elif defined ( __ICCARM__ ) /*!< IAR Compiler */ +#pragma data_alignment = 4096 +uint8_t _sd_ucSDHCBuffer[512]; +#elif defined(__GNUC__) +__attribute__((aligned(4096))) +uint8_t _sd_ucSDHCBuffer[512]; +#endif + + +int sd0_ok = 0; +int sd1_ok = 0; + +uint8_t pSD0_offset = 0; +uint8_t pSD1_offset = 0; + +DISK_DATA_T SD_DiskInfo0; +DISK_DATA_T SD_DiskInfo1; + +SD_INFO_T SD0; +SD_INFO_T SD1; + +void SD_CheckRB() +{ + while(1) { + SD->CTL |= SDH_CTL_CLK8OEN_Msk; + while(SD->CTL & SDH_CTL_CLK8OEN_Msk); + if (SD->INTSTS & SDH_INTSTS_DAT0STS_Msk) + break; + } +} + + +int SD_SDCommand(SD_INFO_T *pSD, uint8_t ucCmd, uint32_t uArg) +{ + volatile int buf; + + SD->CMDARG = uArg; + buf = (SD->CTL&(~SDH_CTL_CMDCODE_Msk))|(ucCmd << 8)|(SDH_CTL_COEN_Msk); + SD->CTL = buf; + + while(SD->CTL & SDH_CTL_COEN_Msk) { + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + return Successful; +} + + +int SD_SDCmdAndRsp(SD_INFO_T *pSD, uint8_t ucCmd, uint32_t uArg, int ntickCount) +{ + volatile int buf; + + SD->CMDARG = uArg; + buf = (SD->CTL&(~SDH_CTL_CMDCODE_Msk))|(ucCmd << 8)|(SDH_CTL_COEN_Msk | SDH_CTL_RIEN_Msk); + SD->CTL = buf; + + if (ntickCount > 0) { + while(SD->CTL & SDH_CTL_RIEN_Msk) { + if(ntickCount-- == 0) { + SD->CTL |= SDH_CTL_CTLRST_Msk; // reset SD engine + return 2; + } + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + } else { + while(SD->CTL & SDH_CTL_RIEN_Msk) { + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + } + + if (_sd_uR7_CMD) { + if (((SD->RESP1 & 0xff) != 0x55) && ((SD->RESP0 & 0xf) != 0x01)) { + _sd_uR7_CMD = 0; + return SD_CMD8_ERROR; + } + } + + if (!_sd_uR3_CMD) { + if (SD->INTSTS & SDH_INTSTS_CRC7_Msk) // check CRC7 + return Successful; + else { + return SD_CRC7_ERROR; + } + } else { // ignore CRC error for R3 case + _sd_uR3_CMD = 0; + SD->INTSTS = SDH_INTSTS_CRCIF_Msk; + return Successful; + } +} + + +int SD_Swap32(int val) +{ +#if 1 + int buf; + + buf = val; + val <<= 24; + val |= (buf<<8)&0xff0000; + val |= (buf>>8)&0xff00; + val |= (buf>>24)&0xff; + return val; + +#else + return ((val<<24) | ((val<<8)&0xff0000) | ((val>>8)&0xff00) | (val>>24)); +#endif +} + +// Get 16 bytes CID or CSD +int SD_SDCmdAndRsp2(SD_INFO_T *pSD, uint8_t ucCmd, uint32_t uArg, uint32_t *puR2ptr) +{ + unsigned int i, buf; + unsigned int tmpBuf[5]; + + SD->CMDARG = uArg; + buf = (SD->CTL&(~SDH_CTL_CMDCODE_Msk))|(ucCmd << 8)|(SDH_CTL_COEN_Msk | SDH_CTL_R2EN_Msk); + SD->CTL = buf; + + while(SD->CTL & SDH_CTL_R2EN_Msk) { + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + if (SD->INTSTS & SDH_INTSTS_CRC7_Msk) { + for (i=0; i<5; i++) { + tmpBuf[i] = SD_Swap32(*(int*)(SD_BASE+i*4)); + } + for (i=0; i<4; i++) + *puR2ptr++ = ((tmpBuf[i] & 0x00ffffff)<<8) | ((tmpBuf[i+1] & 0xff000000)>>24); + return Successful; + } else + return SD_CRC7_ERROR; +} + + +int SD_SDCmdAndRspDataIn(SD_INFO_T *pSD, uint8_t ucCmd, uint32_t uArg) +{ + volatile int buf; + + SD->CMDARG = uArg; + buf = (SD->CTL&(~SDH_CTL_CMDCODE_Msk))|(ucCmd << 8)| + (SDH_CTL_COEN_Msk | SDH_CTL_RIEN_Msk | SDH_CTL_DIEN_Msk); + + SD->CTL = buf; + + while (SD->CTL & SDH_CTL_RIEN_Msk) { + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + while (SD->CTL & SDH_CTL_DIEN_Msk) { + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + if (!(SD->INTSTS & SDH_INTSTS_CRC7_Msk)) { // check CRC7 + return SD_CRC7_ERROR; + } + + if (!(SD->INTSTS & SDH_INTSTS_CRC16_Msk)) { // check CRC16 + return SD_CRC16_ERROR; + } + return Successful; +} + +// there are 8 bits for divider0, maximum is 256 +#define SD_CLK_DIV0_MAX 256 + +void SD_Set_clock(uint32_t sd_clock_khz) +{ + uint32_t rate, div1, i; + uint32_t u32SD_ClkSrc; + + if(sd_clock_khz >= 24000) { + sd_clock_khz = 24000; + } + + u32SD_ClkSrc = (CLK->CLKSEL0 & CLK_CLKSEL0_SDHSEL_Msk); + + if(u32SD_ClkSrc == CLK_CLKSEL0_SDHSEL_HXT) + _sd_ReferenceClock = (CLK_GetHXTFreq() / 1000); + else if(u32SD_ClkSrc == CLK_CLKSEL0_SDHSEL_HIRC) + _sd_ReferenceClock = (__HIRC / 1000); + else if(u32SD_ClkSrc == CLK_CLKSEL0_SDHSEL_PLL) + _sd_ReferenceClock = (CLK_GetPLLClockFreq() / 1000); + else if(u32SD_ClkSrc == CLK_CLKSEL0_SDHSEL_HCLK) + _sd_ReferenceClock = (CLK_GetHCLKFreq() / 1000); + + rate = _sd_ReferenceClock / sd_clock_khz; + + // choose slower clock if system clock cannot divisible by wanted clock + if (_sd_ReferenceClock % sd_clock_khz != 0) + rate++; + + if(rate >= SD_CLK_DIV0_MAX) { + rate = SD_CLK_DIV0_MAX; + } + + //--- calculate the second divider CLKDIV0[SDHOST_N] + div1 = ((rate -1) & 0xFF); + + //--- setup register + CLK->CLKDIV0 &= ~CLK_CLKDIV0_SDHDIV_Msk; + CLK->CLKDIV0 |= (div1 << CLK_CLKDIV0_SDHDIV_Pos); + + for(i=0; i<1000; i++); // waiting for clock become stable + return; +} + +void SD_CardSelect(int cardSel) +{ + if(cardSel == 0) { + SD->CTL |= (SD->CTL & ~SDH_CTL_SDPORT_Msk); + } else if(cardSel == 1) { + SD->CTL |= ((SD->CTL & ~SDH_CTL_SDPORT_Msk) | (1 << SDH_CTL_SDPORT_Pos)); + } +} + +uint32_t SD_CardDetection(uint32_t u32CardNum) +{ + uint32_t i; + + if (u32CardNum == SD_PORT0) { + if(SD->INTEN & SDH_INTEN_CDSRC0_Msk) { // Card detect pin from GPIO + if(SD->INTSTS & SDH_INTSTS_CDSTS0_Msk) { // Card remove + SD0.IsCardInsert = FALSE; + return FALSE; + } else + SD0.IsCardInsert = TRUE; + } else if(!(SD->INTEN & SDH_INTEN_CDSRC0_Msk)) { + SD->CTL |= SDH_CTL_CLKKEEP0_Msk; + for(i= 0; i < 5000; i++); + + if(SD->INTSTS & SDH_INTSTS_CDSTS0_Msk) // Card insert + SD0.IsCardInsert = TRUE; + else { + SD0.IsCardInsert = FALSE; + return FALSE; + } + + SD->CTL &= ~SDH_CTL_CLKKEEP0_Msk; + } + + } else if (u32CardNum == SD_PORT1) { + if(SD->INTEN & SDH_INTEN_CDSRC1_Msk) { // Card detect pin from GPIO + if(SD->INTSTS & SDH_INTSTS_CDSTS1_Msk) { // Card remove + SD1.IsCardInsert = FALSE; + return FALSE; + } else + SD1.IsCardInsert = TRUE; + } else if(!(SD->INTEN & SDH_INTEN_CDSRC1_Msk)) { + SD->CTL |= SDH_CTL_CLKKEEP1_Msk; + for(i= 0; i < 5000; i++); + + if(SD->INTSTS & SDH_INTSTS_CDSTS1_Msk) // Card insert + SD1.IsCardInsert = TRUE; + else { + SD1.IsCardInsert = FALSE; + return FALSE; + } + + SD->CTL &= ~SDH_CTL_CLKKEEP1_Msk; + } + + } + + return TRUE; +} + + +// Initial +int SD_Init(SD_INFO_T *pSD) +{ + int volatile i, status; + unsigned int resp; + unsigned int CIDBuffer[4]; + unsigned int volatile u32CmdTimeOut; + + // set the clock to 200KHz + //SD_Set_clock(200); + SD_Set_clock(100); + + // power ON 74 clock + SD->CTL |= SDH_CTL_CLK74OEN_Msk; + + while(SD->CTL & SDH_CTL_CLK74OEN_Msk) { + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + SD_SDCommand(pSD, 0, 0); // reset all cards + for (i=0x1000; i>0; i--); + + // initial SDHC + _sd_uR7_CMD = 1; + //u32CmdTimeOut = 5000; + u32CmdTimeOut = 0xFFFFF; + //u32CmdTimeOut = 0; + + i = SD_SDCmdAndRsp(pSD, 8, 0x00000155, u32CmdTimeOut); + if (i == Successful) { + // SD 2.0 + SD_SDCmdAndRsp(pSD, 55, 0x00, u32CmdTimeOut); + _sd_uR3_CMD = 1; + SD_SDCmdAndRsp(pSD, 41, 0x40ff8000, u32CmdTimeOut); // 2.7v-3.6v + resp = SD->RESP0; + + while (!(resp & 0x00800000)) { // check if card is ready + SD_SDCmdAndRsp(pSD, 55, 0x00, u32CmdTimeOut); + _sd_uR3_CMD = 1; + SD_SDCmdAndRsp(pSD, 41, 0x40ff8000, u32CmdTimeOut); // 3.0v-3.4v + resp = SD->RESP0; + } + if (resp & 0x00400000) + pSD->CardType = SD_TYPE_SD_HIGH; + else + pSD->CardType = SD_TYPE_SD_LOW; + } else { + // SD 1.1 + SD_SDCommand(pSD, 0, 0); // reset all cards + for (i=0x100; i>0; i--); + + i = SD_SDCmdAndRsp(pSD, 55, 0x00, u32CmdTimeOut); + if (i == 2) { // MMC memory + + SD_SDCommand(pSD, 0, 0); // reset + for (i=0x100; i>0; i--); + + _sd_uR3_CMD = 1; + + if (SD_SDCmdAndRsp(pSD, 1, 0x40ff8000, u32CmdTimeOut) != 2) { // eMMC memory + resp = SD->RESP0; + while (!(resp & 0x00800000)) { // check if card is ready + _sd_uR3_CMD = 1; + + SD_SDCmdAndRsp(pSD, 1, 0x40ff8000, u32CmdTimeOut); // high voltage + resp = SD->RESP0; + } + + if(resp & 0x00400000) + pSD->CardType = SD_TYPE_EMMC; + else + pSD->CardType = SD_TYPE_MMC; + } else { + pSD->CardType = SD_TYPE_UNKNOWN; + return SD_ERR_DEVICE; + } + } else if (i == 0) { // SD Memory + _sd_uR3_CMD = 1; + SD_SDCmdAndRsp(pSD, 41, 0x00ff8000, u32CmdTimeOut); // 3.0v-3.4v + resp = SD->RESP0; + while (!(resp & 0x00800000)) { // check if card is ready + SD_SDCmdAndRsp(pSD, 55, 0x00,u32CmdTimeOut); + _sd_uR3_CMD = 1; + SD_SDCmdAndRsp(pSD, 41, 0x00ff8000, u32CmdTimeOut); // 3.0v-3.4v + resp = SD->RESP0; + } + pSD->CardType = SD_TYPE_SD_LOW; + } else { + pSD->CardType = SD_TYPE_UNKNOWN; + return SD_INIT_ERROR; + } + } + + // CMD2, CMD3 + if (pSD->CardType != SD_TYPE_UNKNOWN) { + SD_SDCmdAndRsp2(pSD, 2, 0x00, CIDBuffer); + if ((pSD->CardType == SD_TYPE_MMC) || (pSD->CardType == SD_TYPE_EMMC)) { + if ((status = SD_SDCmdAndRsp(pSD, 3, 0x10000, 0)) != Successful) // set RCA + return status; + pSD->RCA = 0x10000; + } else { + if ((status = SD_SDCmdAndRsp(pSD, 3, 0x00, 0)) != Successful) // get RCA + return status; + else + pSD->RCA = (SD->RESP0 << 8) & 0xffff0000; + } + } + + return Successful; +} + + +int SD_SwitchToHighSpeed(SD_INFO_T *pSD) +{ + int volatile status=0; + uint16_t current_comsumption, busy_status0; + + SD->DMASA = (uint32_t)_sd_pSDHCBuffer; // set DMA transfer starting address + SD->BLEN = 63; // 512 bit + + if ((status = SD_SDCmdAndRspDataIn(pSD, 6, 0x00ffff01)) != Successful) + return Fail; + + current_comsumption = _sd_pSDHCBuffer[0]<<8 | _sd_pSDHCBuffer[1]; + if (!current_comsumption) + return Fail; + + busy_status0 = _sd_pSDHCBuffer[28]<<8 | _sd_pSDHCBuffer[29]; + + if (!busy_status0) { // function ready + SD->DMASA = (uint32_t)_sd_pSDHCBuffer; // set DMA transfer starting address + SD->BLEN = 63; // 512 bit + + if ((status = SD_SDCmdAndRspDataIn(pSD, 6, 0x80ffff01)) != Successful) + return Fail; + + // function change timing: 8 clocks + SD->CTL |= SDH_CTL_CLK8OEN_Msk; + while(SD->CTL & SDH_CTL_CLK8OEN_Msk); + + current_comsumption = _sd_pSDHCBuffer[0]<<8 | _sd_pSDHCBuffer[1]; + if (!current_comsumption) + return Fail; + + return Successful; + } else + return Fail; +} + + +int SD_SelectCardType(SD_INFO_T *pSD) +{ + int volatile status=0; + unsigned int arg; + + if ((status = SD_SDCmdAndRsp(pSD, 7, pSD->RCA, 0)) != Successful) + return status; + + SD_CheckRB(); + + // if SD card set 4bit + if (pSD->CardType == SD_TYPE_SD_HIGH) { + _sd_pSDHCBuffer = (uint8_t *)((uint32_t)_sd_ucSDHCBuffer); + SD->DMASA = (uint32_t)_sd_pSDHCBuffer; // set DMA transfer starting address + SD->BLEN = 0x07; // 64 bit + + if ((status = SD_SDCmdAndRsp(pSD, 55, pSD->RCA, 0)) != Successful) + return status; + if ((status = SD_SDCmdAndRspDataIn(pSD, 51, 0x00)) != Successful) + return status; + + if ((_sd_ucSDHCBuffer[0] & 0xf) == 0x2) { + status = SD_SwitchToHighSpeed(pSD); + if (status == Successful) { + /* divider */ + SD_Set_clock(SDHC_FREQ); + } + } + + if ((status = SD_SDCmdAndRsp(pSD, 55, pSD->RCA, 0)) != Successful) + return status; + if ((status = SD_SDCmdAndRsp(pSD, 6, 0x02, 0)) != Successful) // set bus width + return status; + + SD->CTL |= SDH_CTL_DBW_Msk; + } else if (pSD->CardType == SD_TYPE_SD_LOW) { + _sd_pSDHCBuffer = (uint8_t *)((uint32_t)_sd_ucSDHCBuffer); + SD->DMASA = (uint32_t) _sd_pSDHCBuffer; // set DMA transfer starting address + SD->BLEN = 0x07; // 64 bit + + if ((status = SD_SDCmdAndRsp(pSD, 55, pSD->RCA, 0)) != Successful) + return status; + if ((status = SD_SDCmdAndRspDataIn(pSD, 51, 0x00)) != Successful) + return status; + + // set data bus width. ACMD6 for SD card, SDCR_DBW for host. + if ((status = SD_SDCmdAndRsp(pSD, 55, pSD->RCA, 0)) != Successful) + return status; + + if ((status = SD_SDCmdAndRsp(pSD, 6, 0x02, 0)) != Successful) // set bus width + return status; + + SD->CTL |= SDH_CTL_DBW_Msk; + } else if ((pSD->CardType == SD_TYPE_MMC) ||(pSD->CardType == SD_TYPE_EMMC)) { + + if(pSD->CardType == SD_TYPE_MMC) + SD->CTL &= ~SDH_CTL_DBW_Msk; + + //--- sent CMD6 to MMC card to set bus width to 4 bits mode + // set CMD6 argument Access field to 3, Index to 183, Value to 1 (4-bit mode) + arg = (3 << 24) | (183 << 16) | (1 << 8); + if ((status = SD_SDCmdAndRsp(pSD, 6, arg, 0)) != Successful) + return status; + SD_CheckRB(); + + SD->CTL |= SDH_CTL_DBW_Msk;; // set bus width to 4-bit mode for SD host controller + + } + + if ((status = SD_SDCmdAndRsp(pSD, 16, SD_BLOCK_SIZE, 0)) != Successful) // set block length + return status; + SD->BLEN = SD_BLOCK_SIZE - 1; // set the block size + + SD_SDCommand(pSD, 7, 0); + SD->CTL |= SDH_CTL_CLK8OEN_Msk; + while(SD->CTL & SDH_CTL_CLK8OEN_Msk); + +#ifdef _SD_USE_INT_ + SD->INTEN |= SDH_INTEN_BLKDIEN_Msk; +#endif //_SD_USE_INT_ + + return Successful; +} + +void SD_Get_SD_info(SD_INFO_T *pSD, DISK_DATA_T *_info) +{ + unsigned int R_LEN, C_Size, MULT, size; + unsigned int Buffer[4]; + unsigned char *ptr; + + SD_SDCmdAndRsp2(pSD, 9, pSD->RCA, Buffer); + + if ((pSD->CardType == SD_TYPE_MMC) || (pSD->CardType == SD_TYPE_EMMC)) { + // for MMC/eMMC card + if ((Buffer[0] & 0xc0000000) == 0xc0000000) { + // CSD_STRUCTURE [127:126] is 3 + // CSD version depend on EXT_CSD register in eMMC v4.4 for card size > 2GB + SD_SDCmdAndRsp(pSD, 7, pSD->RCA, 0); + + ptr = (uint8_t *)((uint32_t)_sd_ucSDHCBuffer ); + SD->DMASA = (uint32_t)ptr; // set DMA transfer starting address + SD->BLEN = 511; // read 512 bytes for EXT_CSD + + if (SD_SDCmdAndRspDataIn(pSD, 8, 0x00) != Successful) + return; + + SD_SDCommand(pSD, 7, 0); + SD->CTL |= SDH_CTL_CLK8OEN_Msk; + while(SD->CTL & SDH_CTL_CLK8OEN_Msk); + + _info->totalSectorN = (*(uint32_t *)(ptr+212)); + _info->diskSize = _info->totalSectorN / 2; + } else { + // CSD version v1.0/1.1/1.2 in eMMC v4.4 spec for card size <= 2GB + R_LEN = (Buffer[1] & 0x000f0000) >> 16; + C_Size = ((Buffer[1] & 0x000003ff) << 2) | ((Buffer[2] & 0xc0000000) >> 30); + MULT = (Buffer[2] & 0x00038000) >> 15; + size = (C_Size+1) * (1<<(MULT+2)) * (1<diskSize = size / 1024; + _info->totalSectorN = size / 512; + } + } else { + if (Buffer[0] & 0xc0000000) { + C_Size = ((Buffer[1] & 0x0000003f) << 16) | ((Buffer[2] & 0xffff0000) >> 16); + size = (C_Size+1) * 512; // Kbytes + + _info->diskSize = size; + _info->totalSectorN = size << 1; + } else { + R_LEN = (Buffer[1] & 0x000f0000) >> 16; + C_Size = ((Buffer[1] & 0x000003ff) << 2) | ((Buffer[2] & 0xc0000000) >> 30); + MULT = (Buffer[2] & 0x00038000) >> 15; + size = (C_Size+1) * (1<<(MULT+2)) * (1<diskSize = size / 1024; + _info->totalSectorN = size / 512; + } + } + + _info->sectorSize = 512; +} + +int SD_ChipErase(SD_INFO_T *pSD, DISK_DATA_T *_info) +{ + int status=0; + + status = SD_SDCmdAndRsp(pSD, 32, 512, 6000); + if (status < 0) { + return status; + } + status = SD_SDCmdAndRsp(pSD, 33, _info->totalSectorN*512, 6000); + if (status < 0) { + return status; + } + status = SD_SDCmdAndRsp(pSD, 38, 0, 6000); + if (status < 0) { + return status; + } + SD_CheckRB(); + + return 0; +} + +/// @endcond HIDDEN_SYMBOLS + + +/** + * @brief This function use to reset SD function and select card detection source and pin. + * + * @param[in] u32CardDetSrc Select card detection source from SD0 or SD1. ( \ref SD_PORT0 / \ref SD_PORT1) \n + * And also select card detection pin from GPIO or DAT3 pin. ( \ref CardDetect_From_GPIO / \ref CardDetect_From_DAT3) + * + * @return None + */ +void SD_Open(uint32_t u32CardDetSrc) +{ + // Enable SD Card Host Controller operation. + //CLK->AHBCLK |= CLK_AHBCLK_SDHCKEN_Msk; + + // enable DMAC + SD->DMACTL = SDH_DMACTL_DMARST_Msk; + while(SD->DMACTL & SDH_DMACTL_DMARST_Msk); + + SD->DMACTL = SDH_DMACTL_DMAEN_Msk; + + //Reset FMI + SD->GCTL = SDH_GCTL_GCTLRST_Msk; // Start reset FMI controller. + while(SD->GCTL & SDH_GCTL_GCTLRST_Msk); + + +//#ifdef _SD_USE_INT_ +// NVIC_EnableIRQ(SD_IRQn); +//#endif //_SD_USE_INT_ + + // enable SD + SD->GCTL = SDH_GCTL_SDEN_Msk; + + if(u32CardDetSrc & SD_PORT0) { + SD->CTL |= (SD->CTL & ~SDH_CTL_SDPORT_Msk); + + if(u32CardDetSrc & CardDetect_From_DAT3) { + SD->INTEN &= ~SDH_INTEN_CDSRC0_Msk; + } else { + SD->INTEN |= SDH_INTEN_CDSRC0_Msk; + } + } else if(u32CardDetSrc & SD_PORT1) { + SD->CTL |= ((SD->CTL & ~SDH_CTL_SDPORT_Msk) | (1 << SDH_CTL_SDPORT_Pos)); + + if(u32CardDetSrc & CardDetect_From_DAT3) { + SD->INTEN &= ~SDH_INTEN_CDSRC1_Msk; + } else { + SD->INTEN |= SDH_INTEN_CDSRC1_Msk; + } + } + + SD->CTL |= SDH_CTL_CTLRST_Msk; // SD software reset + while(SD->CTL & SDH_CTL_CTLRST_Msk); + + SD->CTL &= ~((0xFF) | (SDH_CTL_CLKKEEP1_Msk)); // disable SD clock output + + if(u32CardDetSrc & SD_PORT0) { + memset(&SD0, 0, sizeof(SD_INFO_T)); + } else if(u32CardDetSrc & SD_PORT1) { + memset(&SD1, 0, sizeof(SD_INFO_T)); + } + +} + +/** + * @brief This function use to initial SD card. + * + * @param[in] u32CardNum Select initial SD0 or SD1. ( \ref SD_PORT0 / \ref SD_PORT1) + * + * @return None + */ +void SD_Probe(uint32_t u32CardNum) +{ + // Disable FMI/SD host interrupt + SD->GINTEN = 0; + + SD->CTL &= ~SDH_CTL_SDNWR_Msk; + SD->CTL |= 0x09 << SDH_CTL_SDNWR_Pos; // set SDNWR = 9 + SD->CTL &= ~SDH_CTL_BLKCNT_Msk; + SD->CTL |= 0x01 << SDH_CTL_BLKCNT_Pos; // set BLKCNT = 1 + SD->CTL &= ~SDH_CTL_DBW_Msk; // SD 1-bit data bus + + if(!(SD_CardDetection(u32CardNum))) + return; + + if (u32CardNum == SD_PORT0) { + if (SD_Init(&SD0) < 0) + return; + + /* divider */ + if (SD0.CardType == SD_TYPE_MMC) + SD_Set_clock(20000); + else + SD_Set_clock(SD_FREQ); + + SD_Get_SD_info(&SD0, &SD_DiskInfo0); + + if (SD_SelectCardType(&SD0)) + return; + + sd0_ok = 1; + } else if (u32CardNum == SD_PORT1) { + if (SD_Init(&SD1) < 0) + return; + + /* divider */ + if (SD1.CardType == SD_TYPE_MMC) + SD_Set_clock(20000); + else + SD_Set_clock(SD_FREQ); + + SD_Get_SD_info(&SD1, &SD_DiskInfo1); + + if (SD_SelectCardType(&SD1)) + return; + + sd1_ok = 1; + } + + +} + +/** + * @brief This function use to read data from SD card. + * + * @param[in] u32CardNum Select card: SD0 or SD1. ( \ref SD_PORT0 / \ref SD_PORT1) + * @param[out] pu8BufAddr The buffer to receive the data from SD card. + * @param[in] u32StartSec The start read sector address. + * @param[in] u32SecCount The the read sector number of data + * + * @return None + */ +uint32_t SD_Read(uint32_t u32CardNum, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount) +{ + char volatile bIsSendCmd = FALSE, buf; + unsigned int volatile reg; + int volatile i, loop, status; + uint32_t blksize = SD_BLOCK_SIZE; + + SD_INFO_T *pSD; + + if(u32CardNum == SD_PORT0) + pSD = &SD0; + else + pSD = &SD1; + + //--- check input parameters + if (u32SecCount == 0) { + return SD_SELECT_ERROR; + } + + if ((status = SD_SDCmdAndRsp(pSD, 7, pSD->RCA, 0)) != Successful) + return status; + SD_CheckRB(); + + SD->BLEN = blksize - 1; // the actual byte count is equal to (SDBLEN+1) + + if ( (pSD->CardType == SD_TYPE_SD_HIGH) || (pSD->CardType == SD_TYPE_EMMC) ) + SD->CMDARG = u32StartSec; + else + SD->CMDARG = u32StartSec * blksize; + + SD->DMASA = (uint32_t)pu8BufAddr; + + loop = u32SecCount / 255; + for (i=0; iCTL & ~SDH_CTL_CMDCODE_Msk; + reg = reg | 0xff0000; // set BLK_CNT to 255 + if (bIsSendCmd == FALSE) { + SD->CTL = reg|(18<<8)|(SDH_CTL_COEN_Msk | SDH_CTL_RIEN_Msk | SDH_CTL_DIEN_Msk); + bIsSendCmd = TRUE; + } else + SD->CTL = reg | SDH_CTL_DIEN_Msk; + +#ifdef _SD_USE_INT_ + while(!_sd_SDDataReady) +#else + while(1) +#endif //_SD_USE_INT_ + { + if(_sd_SDDataReady) break; + +#ifndef _SD_USE_INT_ + if ((SD->INTSTS & SDH_INTSTS_BLKDIF_Msk) && (!(SD->CTL & SDH_CTL_DIEN_Msk))) { + SD->INTSTS = SDH_INTSTS_BLKDIF_Msk; + break; + } +#endif + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + if (!(SD->INTSTS & SDH_INTSTS_CRC7_Msk)) { // check CRC7 + //printf("sdioSD_Read_in_blksize(): response error!\n"); + return SD_CRC7_ERROR; + } + + if (!(SD->INTSTS & SDH_INTSTS_CRC16_Msk)) { // check CRC16 + //printf("sdioSD_Read_in_blksize() :read data error!\n"); + return SD_CRC16_ERROR; + } + } + + loop = u32SecCount % 255; + if (loop != 0) { +#ifdef _SD_USE_INT_ + _sd_SDDataReady = FALSE; +#endif //_SD_USE_INT_ + + reg = SD->CTL & (~SDH_CTL_CMDCODE_Msk); + reg = reg & (~SDH_CTL_BLKCNT_Msk); + reg |= (loop << 16); // setup SDCR_BLKCNT + + if (bIsSendCmd == FALSE) { + SD->CTL = reg|(18<<8)|(SDH_CTL_COEN_Msk | SDH_CTL_RIEN_Msk | SDH_CTL_DIEN_Msk); + bIsSendCmd = TRUE; + } else + SD->CTL = reg | SDH_CTL_DIEN_Msk; + +#ifdef _SD_USE_INT_ + while(!_sd_SDDataReady) +#else + while(1) +#endif //_SD_USE_INT_ + { + +#ifndef _SD_USE_INT_ + if ((SD->INTSTS & SDH_INTSTS_BLKDIF_Msk) && (!(SD->CTL & SDH_CTL_DIEN_Msk))) { + SD->INTSTS = SDH_INTSTS_BLKDIF_Msk; + break; + } +#endif + + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + if (!(SD->INTSTS & SDH_INTSTS_CRC7_Msk)) { // check CRC7 + //printf("sdioSD_Read_in_blksize(): response error!\n"); + return SD_CRC7_ERROR; + } + + if (!(SD->INTSTS & SDH_INTSTS_CRC16_Msk)) { // check CRC16 + //printf("sdioSD_Read_in_blksize(): read data error!\n"); + return SD_CRC16_ERROR; + } + } + + if (SD_SDCmdAndRsp(pSD, 12, 0, 0)) { // stop command + //printf("stop command fail !!\n"); + return SD_CRC7_ERROR; + } + SD_CheckRB(); + + SD_SDCommand(pSD, 7, 0); + SD->CTL |= SDH_CTL_CLK8OEN_Msk; + while(SD->CTL & SDH_CTL_CLK8OEN_Msk); + + return Successful; +} + + +/** + * @brief This function use to write data to SD card. + * + * @param[in] u32CardNum Select card: SD0 or SD1. ( \ref SD_PORT0 / \ref SD_PORT1) + * @param[in] pu8BufAddr The buffer to send the data to SD card. + * @param[in] u32StartSec The start write sector address. + * @param[in] u32SecCount The the write sector number of data. + * + * @return \ref SD_SELECT_ERROR : u32SecCount is zero. \n + * \ref SD_NO_SD_CARD : SD card be removed. \n + * \ref SD_CRC_ERROR : CRC error happen. \n + * \ref SD_CRC7_ERROR : CRC7 error happen. \n + * \ref Successful : Write data to SD card success. + */ +uint32_t SD_Write(uint32_t u32CardNum, uint8_t *pu8BufAddr, uint32_t u32StartSec, uint32_t u32SecCount) +{ + char volatile bIsSendCmd = FALSE; + unsigned int volatile reg; + int volatile i, loop, status; + + SD_INFO_T *pSD; + + if(u32CardNum == SD_PORT0) + pSD = &SD0; + else + pSD = &SD1; + + + //--- check input parameters + if (u32SecCount == 0) { + return SD_SELECT_ERROR; + } + + if ((status = SD_SDCmdAndRsp(pSD, 7, pSD->RCA, 0)) != Successful) + return status; + + SD_CheckRB(); + + // According to SD Spec v2.0, the write CMD block size MUST be 512, and the start address MUST be 512*n. + SD->BLEN = SD_BLOCK_SIZE - 1; // set the block size + + if ((pSD->CardType == SD_TYPE_SD_HIGH) || (pSD->CardType == SD_TYPE_EMMC)) + SD->CMDARG = u32StartSec; + else + SD->CMDARG = u32StartSec * SD_BLOCK_SIZE; // set start address for SD CMD + + SD->DMASA = (uint32_t)pu8BufAddr; + loop = u32SecCount / 255; // the maximum block count is 0xFF=255 for register SDCR[BLK_CNT] + for (i=0; iCTL & 0xff00c080; + reg = reg | 0xff0000; // set BLK_CNT to 0xFF=255 + if (!bIsSendCmd) { + SD->CTL = reg|(25<<8)|(SDH_CTL_COEN_Msk | SDH_CTL_RIEN_Msk | SDH_CTL_DOEN_Msk); + bIsSendCmd = TRUE; + } else + SD->CTL = reg | SDH_CTL_DOEN_Msk; + +#ifdef _SD_USE_INT_ + while(!_sd_SDDataReady) +#else + while(1) +#endif //_SD_USE_INT_ + { +#ifndef _SD_USE_INT_ + if ((SD->INTSTS & SDH_INTSTS_BLKDIF_Msk) && (!(SD->CTL & SDH_CTL_DOEN_Msk))) { + SD->INTSTS = SDH_INTSTS_BLKDIF_Msk; + break; + } +#endif + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + if ((SD->INTSTS & SDH_INTSTS_CRCIF_Msk) != 0) { // check CRC + SD->INTSTS = SDH_INTSTS_CRCIF_Msk; + return SD_CRC_ERROR; + } + } + + loop = u32SecCount % 255; + if (loop != 0) { +#ifdef _SD_USE_INT_ + _sd_SDDataReady = FALSE; +#endif //_SD_USE_INT_ + + reg = (SD->CTL & 0xff00c080) | (loop << 16); + if (!bIsSendCmd) { + SD->CTL = reg|(25<<8)|(SDH_CTL_COEN_Msk | SDH_CTL_RIEN_Msk | SDH_CTL_DOEN_Msk); + bIsSendCmd = TRUE; + } else + SD->CTL = reg | SDH_CTL_DOEN_Msk; + +#ifdef _SD_USE_INT_ + while(!_sd_SDDataReady) +#else + while(1) +#endif //_SD_USE_INT_ + { +#ifndef _SD_USE_INT_ + if ((SD->INTSTS & SDH_INTSTS_BLKDIF_Msk) && (!(SD->CTL & SDH_CTL_DOEN_Msk))) { + SD->INTSTS = SDH_INTSTS_BLKDIF_Msk; + break; + } +#endif + if (pSD->IsCardInsert == FALSE) + return SD_NO_SD_CARD; + } + + if ((SD->INTSTS & SDH_INTSTS_CRCIF_Msk) != 0) { // check CRC + SD->INTSTS = SDH_INTSTS_CRCIF_Msk; + return SD_CRC_ERROR; + } + } + SD->INTSTS = SDH_INTSTS_CRCIF_Msk; + + if (SD_SDCmdAndRsp(pSD, 12, 0, 0)) { // stop command + return SD_CRC7_ERROR; + } + SD_CheckRB(); + + SD_SDCommand(pSD, 7, 0); + SD->CTL |= SDH_CTL_CLK8OEN_Msk; + while(SD->CTL & SDH_CTL_CLK8OEN_Msk); + + return Successful; +} + + +/*@}*/ /* end of group NUC472_442_SD_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SD_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + + + + + + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/spi.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/spi.c new file mode 100644 index 0000000000000000000000000000000000000000..a5bda85503b9d9f48880c9b8fdc2381b72cdf25a --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/spi.c @@ -0,0 +1,337 @@ +/****************************************************************************//** + * @file spi.c + * @version V0.10 + * $Revision: 16 $ + * $Date: 15/06/18 4:00p $ + * @brief NUC472/NUC442 SPI driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SPI_Driver SPI Driver + @{ +*/ + + +/** @addtogroup NUC472_442_SPI_EXPORTED_FUNCTIONS SPI Exported Functions + @{ +*/ + +/** + * @brief This function make SPI module be ready to transfer. + * By default, the SPI transfer sequence is MSB first and + * the automatic slave select function is disabled. In + * Slave mode, the u32BusClock must be NULL and the SPI clock + * divider setting will be 0. + * @param[in] spi is the base address of SPI module. + * @param[in] u32MasterSlave decides the SPI module is operating in master mode or in slave mode. Valid values are: + * - \ref SPI_SLAVE + * - \ref SPI_MASTER + * @param[in] u32SPIMode decides the transfer timing. Valid values are: + * - \ref SPI_MODE_0 + * - \ref SPI_MODE_1 + * - \ref SPI_MODE_2 + * - \ref SPI_MODE_3 + * @param[in] u32DataWidth decides the data width of a SPI transaction. + * @param[in] u32BusClock is the expected frequency of SPI bus clock in Hz. + * @return Actual frequency of SPI peripheral clock. + */ +uint32_t SPI_Open(SPI_T *spi, uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock) +{ + if(u32DataWidth == 32) + u32DataWidth = 0; + + spi->CTL = u32MasterSlave | (u32DataWidth << SPI_CTL_DWIDTH_Pos) | (u32SPIMode); + + return ( SPI_SetBusClock(spi, u32BusClock) ); +} + +/** + * @brief Reset SPI module and disable SPI peripheral clock. + * @param[in] spi is the base address of SPI module. + * @return none + */ +void SPI_Close(SPI_T *spi) +{ + /* Reset SPI */ + if((uint32_t)spi == SPI0_BASE) { + SYS->IPRST1 |= SYS_IPRST1_SPI0RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_SPI0RST_Msk; + } else if((uint32_t)spi == SPI1_BASE) { + SYS->IPRST1 |= SYS_IPRST1_SPI1RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_SPI1RST_Msk; + } else if((uint32_t)spi == SPI2_BASE) { + SYS->IPRST1 |= SYS_IPRST1_SPI2RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_SPI2RST_Msk; + } else { + SYS->IPRST1 |= SYS_IPRST1_SPI3RST_Msk; + SYS->IPRST1 &= ~SYS_IPRST1_SPI3RST_Msk; + } +} + +/** + * @brief Clear Rx FIFO buffer. + * @param[in] spi is the base address of SPI module. + * @return none + */ +void SPI_ClearRxFIFO(SPI_T *spi) +{ + spi->FIFOCTL |= SPI_FIFOCTL_RXRST_Msk; +} + +/** + * @brief Clear Tx FIFO buffer. + * @param[in] spi is the base address of SPI module. + * @return none + */ +void SPI_ClearTxFIFO(SPI_T *spi) +{ + spi->FIFOCTL |= SPI_FIFOCTL_TXRST_Msk; +} + +/** + * @brief Disable the automatic slave select function. + * @param[in] spi is the base address of SPI module. + * @return none + */ +void SPI_DisableAutoSS(SPI_T *spi) +{ + spi->SSCTL &= ~(SPI_SSCTL_AUTOSS_Msk | SPI_SSCTL_SS_Msk); +} + +/** + * @brief Enable the automatic slave select function. Only available in Master mode. + * @param[in] spi is the base address of SPI module. + * @param[in] u32SSPinMask specifies slave select pins. Valid values are: + * - \ref SPI_SS0 + * - \ref SPI_SS1 + * @param[in] u32ActiveLevel specifies the active level of slave select signal. Valid values are: + * - \ref SPI_SS_ACTIVE_HIGH + * - \ref SPI_SS_ACTIVE_LOW + * @return none + */ +void SPI_EnableAutoSS(SPI_T *spi, uint32_t u32SSPinMask, uint32_t u32ActiveLevel) +{ + spi->SSCTL = (spi->SSCTL & ~(SPI_SSCTL_SSACTPOL_Msk | SPI_SSCTL_SS_Msk)) | (u32SSPinMask | u32ActiveLevel) | SPI_SSCTL_AUTOSS_Msk; +} + +/** + * @brief Set the SPI bus clock. Only available in Master mode. + * @param[in] spi is the base address of SPI module. + * @param[in] u32BusClock is the expected frequency of SPI bus clock. + * @return Actual frequency of SPI peripheral clock. + */ +uint32_t SPI_SetBusClock(SPI_T *spi, uint32_t u32BusClock) +{ + uint32_t u32ClkSrc, u32Div = 0; + + if(spi == SPI0) { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI0SEL_Msk) == CLK_CLKSEL1_SPI0SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } else if(spi == SPI1) { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI1SEL_Msk) == CLK_CLKSEL1_SPI1SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } else if(spi == SPI2) { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI1SEL_Msk) == CLK_CLKSEL1_SPI2SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } else { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI3SEL_Msk) == CLK_CLKSEL1_SPI3SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } + + if(u32BusClock > u32ClkSrc) + u32BusClock = u32ClkSrc; + + if(u32BusClock != 0 ) { + u32Div = (u32ClkSrc / u32BusClock) - 1; + if(u32Div > SPI_CLKDIV_DIVIDER_Msk) + u32Div = SPI_CLKDIV_DIVIDER_Msk; + } else + return 0; + + spi->CLKDIV = (spi->CLKDIV & ~SPI_CLKDIV_DIVIDER_Msk) | u32Div; + + return ( u32ClkSrc / (u32Div+1) ); +} + +/** + * @brief Set Tx FIFO threshold and Rx FIFO threshold configurations. + * @param[in] spi is the base address of SPI module. + * @param[in] u32TxThreshold decides the Tx FIFO threshold. + * @param[in] u32RxThreshold decides the Rx FIFO threshold. + * @return none + */ +void SPI_SetFIFOThreshold(SPI_T *spi, uint32_t u32TxThreshold, uint32_t u32RxThreshold) +{ + spi->FIFOCTL = (spi->FIFOCTL & ~(SPI_FIFOCTL_TXTH_Msk | SPI_FIFOCTL_RXTH_Msk) | + (u32TxThreshold << SPI_FIFOCTL_TXTH_Pos) | + (u32RxThreshold << SPI_FIFOCTL_RXTH_Pos)); +} + +/** + * @brief Get the actual frequency of SPI bus clock. Only available in Master mode. + * @param[in] spi is the base address of SPI module. + * @return Actual SPI bus clock frequency. + */ +uint32_t SPI_GetBusClock(SPI_T *spi) +{ + uint32_t u32Div; + uint32_t u32ClkSrc; + + if(spi == SPI0) { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI0SEL_Msk) == CLK_CLKSEL1_SPI0SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } else if(spi == SPI1) { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI1SEL_Msk) == CLK_CLKSEL1_SPI1SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } else if(spi == SPI2) { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI2SEL_Msk) == CLK_CLKSEL1_SPI2SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } else { + if((CLK->CLKSEL1 & CLK_CLKSEL1_SPI3SEL_Msk) == CLK_CLKSEL1_SPI3SEL_PCLK) + u32ClkSrc = CLK_GetPCLKFreq(); + else + u32ClkSrc = CLK_GetPLLClockFreq(); + } + + u32Div = spi->CLKDIV & SPI_CLKDIV_DIVIDER_Msk; + return (u32ClkSrc / (u32Div + 1)); +} + +/** + * @brief Enable FIFO related interrupts specified by u32Mask parameter. + * @param[in] spi is the base address of SPI module. + * @param[in] u32Mask is the combination of all related interrupt enable bits. + * Each bit corresponds to a interrupt bit. + * This parameter decides which interrupts will be enabled. Valid values are: + * - \ref SPI_UNITIEN_MASK + * - \ref SPI_SSINAIEN_MASK + * - \ref SPI_SSACTIEN_MASK + * - \ref SPI_SLVURIEN_MASK + * - \ref SPI_SLVBEIEN_MASK + * - \ref SPI_SLVTOIEN_MASK + * - \ref SPI_FIFO_TXTHIEN_MASK + * - \ref SPI_FIFO_RXTHIEN_MASK + * - \ref SPI_FIFO_RXOVIEN_MASK + * - \ref SPI_FIFO_TXUFIEN_MASK + * - \ref SPI_FIFO_RXTOIEN_MASK + * @return none + */ +void SPI_EnableInt(SPI_T *spi, uint32_t u32Mask) +{ + if((u32Mask & SPI_UNITIEN_MASK) == SPI_UNITIEN_MASK) + spi->CTL |= SPI_CTL_UNITIEN_Msk; + + if((u32Mask & SPI_SSINAIEN_MASK) == SPI_SSINAIEN_MASK) + spi->SSCTL |= SPI_SSCTL_SSINAIEN_Msk; + + if((u32Mask & SPI_SSACTIEN_MASK) == SPI_SSACTIEN_MASK) + spi->SSCTL |= SPI_SSCTL_SSACTIEN_Msk; + + if((u32Mask & SPI_SLVURIEN_MASK) == SPI_SLVURIEN_MASK) + spi->SSCTL |= SPI_SSCTL_SLVURIEN_Msk; + + if((u32Mask & SPI_SLVBEIEN_MASK) == SPI_SLVBEIEN_MASK) + spi->SSCTL |= SPI_SSCTL_SLVBEIEN_Msk; + + if((u32Mask & SPI_SLVTOIEN_MASK) == SPI_SLVTOIEN_MASK) + spi->SSCTL |= SPI_SSCTL_SLVTOIEN_Msk; + + if((u32Mask & SPI_FIFO_TXTHIEN_MASK) == SPI_FIFO_TXTHIEN_MASK) + spi->FIFOCTL |= SPI_FIFOCTL_TXTHIEN_Msk; + + if((u32Mask & SPI_FIFO_RXTHIEN_MASK) == SPI_FIFO_RXTHIEN_MASK) + spi->FIFOCTL |= SPI_FIFOCTL_RXTHIEN_Msk; + + if((u32Mask & SPI_FIFO_RXOVIEN_MASK) == SPI_FIFO_RXOVIEN_MASK) + spi->FIFOCTL |= SPI_FIFOCTL_RXOVIEN_Msk; + + if((u32Mask & SPI_FIFO_TXUFIEN_MASK) == SPI_FIFO_TXUFIEN_MASK) + spi->FIFOCTL |= SPI_FIFOCTL_TXUFIEN_Msk; + + if((u32Mask & SPI_FIFO_RXTOIEN_MASK) == SPI_FIFO_RXTOIEN_MASK) + spi->FIFOCTL |= SPI_FIFOCTL_RXTOIEN_Msk; +} + +/** + * @brief Disable FIFO related interrupts specified by u32Mask parameter. + * @param[in] spi is the base address of SPI module. + * @param[in] u32Mask is the combination of all related interrupt enable bits. + * Each bit corresponds to a interrupt bit. + * This parameter decides which interrupts will be enabled. Valid values are: + * - \ref SPI_UNITIEN_MASK + * - \ref SPI_SSINAIEN_MASK + * - \ref SPI_SSACTIEN_MASK + * - \ref SPI_SLVURIEN_MASK + * - \ref SPI_SLVBEIEN_MASK + * - \ref SPI_SLVTOIEN_MASK + * - \ref SPI_FIFO_TXTHIEN_MASK + * - \ref SPI_FIFO_RXTHIEN_MASK + * - \ref SPI_FIFO_RXOVIEN_MASK + * - \ref SPI_FIFO_TXUFIEN_MASK + * - \ref SPI_FIFO_RXTOIEN_MASK + * @return none + */ +void SPI_DisableInt(SPI_T *spi, uint32_t u32Mask) +{ + if((u32Mask & SPI_UNITIEN_MASK) == SPI_UNITIEN_MASK) + spi->CTL &= ~SPI_CTL_UNITIEN_Msk; + + if((u32Mask & SPI_SSINAIEN_MASK) == SPI_SSINAIEN_MASK) + spi->SSCTL &= ~SPI_SSCTL_SSINAIEN_Msk; + + if((u32Mask & SPI_SSACTIEN_MASK) == SPI_SSACTIEN_MASK) + spi->SSCTL &= ~SPI_SSCTL_SSACTIEN_Msk; + + if((u32Mask & SPI_SLVURIEN_MASK) == SPI_SLVURIEN_MASK) + spi->SSCTL &= ~SPI_SSCTL_SLVURIEN_Msk; + + if((u32Mask & SPI_SLVBEIEN_MASK) == SPI_SLVBEIEN_MASK) + spi->SSCTL &= ~SPI_SSCTL_SLVBEIEN_Msk; + + if((u32Mask & SPI_SLVTOIEN_MASK) == SPI_SLVTOIEN_MASK) + spi->SSCTL &= ~SPI_SSCTL_SLVTOIEN_Msk; + + if((u32Mask & SPI_FIFO_TXTHIEN_MASK) == SPI_FIFO_TXTHIEN_MASK) + spi->FIFOCTL &= ~SPI_FIFOCTL_TXTHIEN_Msk; + + if((u32Mask & SPI_FIFO_RXTHIEN_MASK) == SPI_FIFO_RXTHIEN_MASK) + spi->FIFOCTL &= ~SPI_FIFOCTL_RXTHIEN_Msk; + + if((u32Mask & SPI_FIFO_RXOVIEN_MASK) == SPI_FIFO_RXOVIEN_MASK) + spi->FIFOCTL &= ~SPI_FIFOCTL_RXOVIEN_Msk; + + if((u32Mask & SPI_FIFO_TXUFIEN_MASK) == SPI_FIFO_TXUFIEN_MASK) + spi->FIFOCTL &= ~SPI_FIFOCTL_TXUFIEN_Msk; + + if((u32Mask & SPI_FIFO_RXTOIEN_MASK) == SPI_FIFO_RXTOIEN_MASK) + spi->FIFOCTL &= ~SPI_FIFOCTL_RXTOIEN_Msk; +} + +/*@}*/ /* end of group NUC472_442_SPI_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SPI_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sys.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sys.c new file mode 100644 index 0000000000000000000000000000000000000000..ec6c2410f43d282599870b5d80950c43f62b968d --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/sys.c @@ -0,0 +1,222 @@ +/*************************************************************************//** + * @file sys.c + * @version V1.00 + * $Revision: 16 $ + * $Date: 15/10/21 1:39p $ + * @brief NUC472/NUC442 SYS driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include "NUC472_442.h" +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_SYS_Driver SYS Driver + @{ +*/ + + +/** @addtogroup NUC472_442_SYS_EXPORTED_FUNCTIONS SYS Exported Functions + @{ +*/ + +/** + * @brief This function clear the selected system reset source + * @param[in] u32RstSrc is system reset source. Including: + * - \ref SYS_RSTSTS_PORF_Msk + * - \ref SYS_RSTSTS_PINRF_Msk + * - \ref SYS_RSTSTS_WDTRF_Msk + * - \ref SYS_RSTSTS_LVRF_Msk + * - \ref SYS_RSTSTS_BODRF_Msk + * - \ref SYS_RSTSTS_SYSRF_Msk + * - \ref SYS_RSTSTS_CPURF_Msk + * @return None + */ +void SYS_ClearResetSrc(uint32_t u32RstSrc) +{ + SYS->RSTSTS |= u32RstSrc; +} + +/** + * @brief This function get Brown-out detector output status + * @return 0: System voltage is higher than BODVL setting or BODEN is 0. + * 1: System voltage is lower than BODVL setting. + * Note : If the BOD_EN is 0, this function always return 0. + */ +uint32_t SYS_GetBODStatus() +{ + return (SYS->BODCTL & SYS_BODCTL_BODOUT_Msk); +} + +/** + * @brief This function get the system reset source register value + * @return Reset source + */ +uint32_t SYS_GetResetSrc(void) +{ + return (SYS->RSTSTS); +} + +/** + * @brief This function check register write-protection bit setting + * @return 0: Write-protection function is disabled. + * 1: Write-protection function is enabled. + */ +uint32_t SYS_IsRegLocked(void) +{ + return !(SYS->REGLCTL & SYS_REGLCTL_REGLCTL_Msk); +} + +/** + * @brief This function enable register write-protection function + * @return None + * @details To lock the protected register to forbid write access + */ +void SYS_LockReg(void) +{ + SYS->REGLCTL = 0; +} + + +/** + * @brief This function disable register write-protection function + * @return None + * @details To unlock the protected register to allow write access + */ +void SYS_UnlockReg(void) +{ + while(SYS->REGLCTL != SYS_REGLCTL_REGLCTL_Msk) { + SYS->REGLCTL = 0x59; + SYS->REGLCTL = 0x16; + SYS->REGLCTL = 0x88; + } +} + +/** + * @brief This function get product ID. + * @return Product ID + */ +uint32_t SYS_ReadPDID(void) +{ + return SYS->PDID; +} + +/** + * @brief This function reset chip. + * @return None + */ +void SYS_ResetChip(void) +{ + SYS->IPRST0 |= SYS_IPRST0_CHIPRST_Msk; +} + +/** + * @brief This function reset CPU. + * @return None + */ +void SYS_ResetCPU(void) +{ + SYS->IPRST0 |= SYS_IPRST0_CPURST_Msk; +} + +/** + * @brief This function reset selected modules. + * @param[in] u32ModuleIndex is module index. Including : + * - \ref PDMA_RST + * - \ref EBI_RST + * - \ref USBH_RST + * - \ref EMAC_RST + * - \ref SDH_RST + * - \ref CRC_RST + * - \ref CAP_RST + * - \ref CRYPTO_RST + * - \ref GPIO_RST + * - \ref TMR0_RST + * - \ref TMR1_RST + * - \ref TMR2_RST + * - \ref TMR3_RST + * - \ref ACMP_RST + * - \ref I2C0_RST + * - \ref I2C1_RST + * - \ref I2C2_RST + * - \ref I2C3_RST + * - \ref SPI0_RST + * - \ref SPI1_RST + * - \ref SPI2_RST + * - \ref SPI3_RST + * - \ref UART0_RST + * - \ref UART1_RST + * - \ref UART2_RST + * - \ref UART3_RST + * - \ref UART4_RST + * - \ref UART5_RST + * - \ref CAN0_RST + * - \ref CAN1_RST + * - \ref OTG_RST + * - \ref USBD_RST + * - \ref ADC_RST + * - \ref I2S0_RST + * - \ref I2S1_RST + * - \ref PS2_RST + * - \ref SC0_RST + * - \ref SC1_RST + * - \ref SC2_RST + * - \ref SC3_RST + * - \ref SC4_RST + * - \ref SC5_RST + * - \ref I2C4_RST + * - \ref PWM0_RST + * - \ref PWM1_RST + * - \ref QEI0_RST + * - \ref QEI1_RST + * @return None + */ +void SYS_ResetModule(uint32_t u32ModuleIndex) +{ + *(volatile uint32_t *)((uint32_t)&(SYS->IPRST0) + (u32ModuleIndex>>24)) |= 1<<(u32ModuleIndex & 0x00ffffff); + *(volatile uint32_t *)((uint32_t)&(SYS->IPRST0) + (u32ModuleIndex>>24)) &= ~(1<<(u32ModuleIndex & 0x00ffffff)); +} + +/** + * @brief This function configure BOD function. + * Configure BOD reset or interrupt mode and set Brown-out voltage level. + * Enable Brown-out function + * @param[in] i32Mode is reset or interrupt mode. Including : + * - \ref SYS_BODCTL_BODRSTEN + * - \ref SYS_BODCTL_BODINTEN + * @param[in] u32BODLevel is Brown-out voltage level. Including : + * - \ref SYS_BODCTL_BODVL_2_2V + * - \ref SYS_BODCTL_BODVL_2_7V + * - \ref SYS_BODCTL_BODVL_3_8V + * - \ref SYS_BODCTL_BODVL_4_5V + * + * @return None + */ +void SYS_EnableBOD(int32_t i32Mode, uint32_t u32BODLevel) +{ + SYS->BODCTL &= ~(SYS_BODCTL_BODVL_Msk|SYS_BODCTL_BODRSTEN_Msk); + SYS->BODCTL |=(i32Mode|u32BODLevel|SYS_BODCTL_BODEN_Msk); +} + +/** + * @brief This function disable BOD function. + * @return None + */ +void SYS_DisableBOD(void) +{ + SYS->BODCTL &= ~SYS_BODCTL_BODEN_Msk; +} + + + +/*@}*/ /* end of group NUC472_442_SYS_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_SYS_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/timer_.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/timer_.c new file mode 100644 index 0000000000000000000000000000000000000000..7da82f219f8fd8f6edc18c1ec24c9d8955277aac --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/timer_.c @@ -0,0 +1,228 @@ +/**************************************************************************//** + * @file timer.c + * @version V1.00 + * $Revision: 7 $ + * $Date: 15/11/12 9:55a $ + * @brief NUC472/NUC442 TIMER driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_TIMER_Driver TIMER Driver + @{ +*/ + + +/** @addtogroup NUC472_442_TIMER_EXPORTED_FUNCTIONS TIMER Exported Functions + @{ +*/ + +/** + * @brief This API is used to configure timer to operate in specified mode + * and frequency. If timer cannot work in target frequency, a closest + * frequency will be chose and returned. + * @param[in] timer The base address of Timer module + * @param[in] u32Mode Operation mode. Possible options are + * - \ref TIMER_ONESHOT_MODE + * - \ref TIMER_PERIODIC_MODE + * - \ref TIMER_TOGGLE_MODE + * - \ref TIMER_CONTINUOUS_MODE + * @param[in] u32Freq Target working frequency + * @return Real Timer working frequency + * @note After calling this API, Timer is \b NOT running yet. But could start timer running be calling + * \ref TIMER_Start macro or program registers directly + */ +uint32_t TIMER_Open(TIMER_T *timer, uint32_t u32Mode, uint32_t u32Freq) +{ + uint32_t u32Clk = TIMER_GetModuleClock(timer); + uint32_t u32Cmpr = 0, u32Prescale = 0; + + // Fastest possible timer working freq is u32Clk / 2. While cmpr = 2, pre-scale = 0 + if(u32Freq > (u32Clk / 2)) { + u32Cmpr = 2; + } else { + if(u32Clk >= 0x4000000) { + u32Prescale = 7; // real prescaler value is 8 + u32Clk >>= 3; + } else if(u32Clk >= 0x2000000) { + u32Prescale = 3; // real prescaler value is 4 + u32Clk >>= 2; + } else if(u32Clk >= 0x1000000) { + u32Prescale = 1; // real prescaler value is 2 + u32Clk >>= 1; + } + + u32Cmpr = u32Clk / u32Freq; + } + + timer->CTL = u32Mode | u32Prescale; + timer->CMP = u32Cmpr; + + return(u32Clk / (u32Cmpr * (u32Prescale + 1))); +} + +/** + * @brief This API stops Timer counting and disable the Timer interrupt function + * @param[in] timer The base address of Timer module + * @return None + */ +void TIMER_Close(TIMER_T *timer) +{ + timer->CTL = 0; + timer->EXTCTL = 0; + +} + +/** + * @brief This API is used to create a delay loop for u32usec micro seconds + * @param[in] timer The base address of Timer module + * @param[in] u32Usec Delay period in micro seconds with 10 usec every step. Valid values are between 10~1000000 (10 micro second ~ 1 second) + * @return None + * @note This API overwrites the register setting of the timer used to count the delay time. + * @note This API use polling mode. So there is no need to enable interrupt for the timer module used to generate delay + */ +void TIMER_Delay(TIMER_T *timer, uint32_t u32Usec) +{ + uint32_t u32Clk = TIMER_GetModuleClock(timer); + uint32_t u32Prescale = 0, delay = SystemCoreClock / u32Clk + 1; + double fCmpr; + + // Clear current timer configuration + timer->CTL = 0; + timer->EXTCTL = 0; + + if(u32Clk == 10000) { // min delay is 100us if timer clock source is LIRC 10k + u32Usec = ((u32Usec + 99) / 100) * 100; + } else { // 10 usec every step + u32Usec = ((u32Usec + 9) / 10) * 10; + } + + if(u32Clk >= 0x4000000) { + u32Prescale = 7; // real prescaler value is 8 + u32Clk >>= 3; + } else if(u32Clk >= 0x2000000) { + u32Prescale = 3; // real prescaler value is 4 + u32Clk >>= 2; + } else if(u32Clk >= 0x1000000) { + u32Prescale = 1; // real prescaler value is 2 + u32Clk >>= 1; + } + + // u32Usec * u32Clk might overflow if using uint32_t + fCmpr = ((double)u32Usec * (double)u32Clk) / 1000000.0; + + timer->CMP = (uint32_t)fCmpr; + timer->CTL = TIMER_CTL_CNTEN_Msk | u32Prescale; // one shot mode + + // When system clock is faster than timer clock, it is possible timer active bit cannot set in time while we check it. + // And the while loop below return immediately, so put a tiny delay here allowing timer start counting and raise active flag. + for(; delay > 0; delay--) { + __NOP(); + } + + while(timer->CTL & TIMER_CTL_ACTSTS_Msk); + +} + +/** + * @brief This API is used to enable timer capture function with specified mode and capture edge + * @param[in] timer The base address of Timer module + * @param[in] u32CapMode Timer capture mode. Could be + * - \ref TIMER_CAPTURE_FREE_COUNTING_MODE + * - \ref TIMER_CAPTURE_COUNTER_RESET_MODE + * @param[in] u32Edge Timer capture edge. Possible values are + * - \ref TIMER_CAPTURE_FALLING_EDGE + * - \ref TIMER_CAPTURE_RISING_EDGE + * - \ref TIMER_CAPTURE_FALLING_AND_RISING_EDGE + * @return None + * @note Timer frequency should be configured separately by using \ref TIMER_Open API, or program registers directly + */ +void TIMER_EnableCapture(TIMER_T *timer, uint32_t u32CapMode, uint32_t u32Edge) +{ + + timer->EXTCTL = (timer->EXTCTL & ~(TIMER_EXTCTL_CAPFUNCS_Msk | + TIMER_EXTCTL_CAPEDGE_Msk)) | + u32CapMode | u32Edge | TIMER_EXTCTL_CAPEN_Msk; +} + +/** + * @brief This API is used to disable the Timer capture function + * @param[in] timer The base address of Timer module + * @return None + */ +void TIMER_DisableCapture(TIMER_T *timer) +{ + timer->EXTCTL &= ~TIMER_EXTCTL_CAPEN_Msk; + +} + +/** + * @brief This function is used to enable the Timer counter function with specify detection edge + * @param[in] timer The base address of Timer module + * @param[in] u32Edge Detection edge of counter pin. Could be ether + * - \ref TIMER_COUNTER_RISING_EDGE, or + * - \ref TIMER_COUNTER_FALLING_EDGE + * @return None + * @note Timer compare value should be configured separately by using \ref TIMER_SET_CMP_VALUE macro or program registers directly. + * @note While using event counter function, \ref TIMER_TOGGLE_MODE cannot set as timer operation mode. + */ +void TIMER_EnableEventCounter(TIMER_T *timer, uint32_t u32Edge) +{ + timer->EXTCTL = (timer->EXTCTL & ~TIMER_EXTCTL_CNTPHASE_Msk) | u32Edge; + timer->CTL |= TIMER_CTL_EXTCNTEN_Msk; +} + +/** + * @brief This API is used to disable the Timer event counter function. + * @param[in] timer The base address of Timer module + * @return None + */ +void TIMER_DisableEventCounter(TIMER_T *timer) +{ + timer->CTL &= ~TIMER_CTL_EXTCNTEN_Msk; +} + +/** + * @brief This API is used to get the clock frequency of Timer + * @param[in] timer The base address of Timer module + * @return Timer clock frequency + * @note This API cannot return correct clock rate if timer source is external clock input. + */ +uint32_t TIMER_GetModuleClock(TIMER_T *timer) +{ + uint32_t u32Src; + const uint32_t au32Clk[] = {__HXT, __LXT, 0, 0, 0, __LIRC, 0, __HIRC}; + + if(timer == TIMER0) + u32Src = (CLK->CLKSEL1 & CLK_CLKSEL1_TMR0SEL_Msk) >> CLK_CLKSEL1_TMR0SEL_Pos; + else if(timer == TIMER1) + u32Src = (CLK->CLKSEL1 & CLK_CLKSEL1_TMR1SEL_Msk) >> CLK_CLKSEL1_TMR1SEL_Pos; + else if(timer == TIMER2) + u32Src = (CLK->CLKSEL1 & CLK_CLKSEL1_TMR2SEL_Msk) >> CLK_CLKSEL1_TMR2SEL_Pos; + else // Timer 3 + u32Src = (CLK->CLKSEL1 & CLK_CLKSEL1_TMR3SEL_Msk) >> CLK_CLKSEL1_TMR3SEL_Pos; + + if(u32Src == 2) { + if(CLK->CLKSEL0 & CLK_CLKSEL0_PCLKSEL_Msk) + return(SystemCoreClock / 2); + else + return(SystemCoreClock); + } + + return(au32Clk[u32Src]); + +} + +/*@}*/ /* end of group NUC472_442_TIMER_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_TIMER_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/uart.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/uart.c new file mode 100644 index 0000000000000000000000000000000000000000..84b6c0a30c6bdb48380c2f20e9c9c520d3fad05c --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/uart.c @@ -0,0 +1,343 @@ +/**************************************************************************//** + * @file uart.c + * @version V1.00 + * $Revision: 14 $ + * $Date: 15/11/26 10:47a $ + * @brief NUC472/NUC442 UART driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ + +#include +#include "NUC472_442.h" + +/*---------------------------------------------------------------------------------------------------------*/ +/* Includes of local headers */ +/*---------------------------------------------------------------------------------------------------------*/ + + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_UART_Driver UART Driver + @{ +*/ + + +/** @addtogroup NUC472_442_UART_EXPORTED_FUNCTIONS UART Exported Functions + @{ +*/ + + +/** + * @brief The function is used to clear UART specified interrupt flag. + * + * @param[in] uart The base address of UART module. + * @param[in] u32InterruptFlag The specified interrupt of UART module.. + * + * @return None + */ +void UART_ClearIntFlag(UART_T* uart , uint32_t u32InterruptFlag) +{ + if(u32InterruptFlag & UART_INTSTS_RLSINT_Msk) { /* clear Receive Line Status Interrupt */ + uart->FIFOSTS |= UART_FIFOSTS_BIF_Msk | UART_FIFOSTS_FEF_Msk | UART_FIFOSTS_PEF_Msk; + uart->FIFOSTS |= UART_FIFOSTS_ADDRDETF_Msk; + } + + if(u32InterruptFlag & UART_INTSTS_MODEMINT_Msk) /* clear Modem Interrupt */ + uart->MODEMSTS |= UART_MODEMSTS_CTSDETF_Msk; + + if(u32InterruptFlag & UART_INTSTS_BUFERRINT_Msk) { /* clear Buffer Error Interrupt */ + uart->FIFOSTS |= UART_FIFOSTS_RXOVIF_Msk | UART_FIFOSTS_TXOVIF_Msk; + } + + if(u32InterruptFlag & UART_INTSTS_RXTOINT_Msk) /* clear Modem Interrupt */ + uart->INTSTS |= UART_INTSTS_RXTOIF_Msk; + +} + + +/** + * @brief The function is used to disable UART. + * + * @param[in] uart The base address of UART module. + * + * @return None + */ +void UART_Close(UART_T* uart) +{ + uart->INTEN = 0; +} + + +/** + * @brief The function is used to disable UART auto flow control. + * + * @param[in] uart The base address of UART module. + * + * @return None + */ +void UART_DisableFlowCtrl(UART_T* uart) +{ + uart->INTEN &= ~(UART_INTEN_ATORTSEN_Msk | UART_INTEN_ATOCTSEN_Msk); +} + + +/** + * @brief The function is used to disable UART specified interrupt and disable NVIC UART IRQ. + * + * @param[in] uart The base address of UART module. + * @param[in] u32InterruptFlag The specified interrupt of UART module. + * - \ref UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt + * - \ref UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt + * - \ref UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt + * - \ref UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt + * - \ref UART_INTEN_MODEMIEN_Msk : Modem interrupt + * - \ref UART_INTEN_RLSIEN_Msk : Rx Line status interrupt + * - \ref UART_INTEN_THREIEN_Msk : Tx empty interrupt + * - \ref UART_INTEN_RDAIEN_Msk : Rx ready interrupt + * + * @return None + */ +void UART_DisableInt(UART_T* uart, uint32_t u32InterruptFlag ) +{ + uart->INTEN &= ~ u32InterruptFlag; +} + + + +/** + * @brief The function is used to Enable UART auto flow control. + * + * @param[in] uart The base address of UART module. + * + * @return None + */ +void UART_EnableFlowCtrl(UART_T* uart ) +{ + uart->MODEM |= UART_MODEM_RTSACTLV_Msk; + uart->MODEM &= ~UART_MODEM_RTS_Msk; + uart->MODEMSTS |= UART_MODEMSTS_CTSACTLV_Msk; + uart->INTEN |= UART_INTEN_ATORTSEN_Msk | UART_INTEN_ATOCTSEN_Msk; +} + + +/** + * @brief The function is used to enable UART specified interrupt and disable NVIC UART IRQ. + * + * @param[in] uart The base address of UART module. + * @param[in] u32InterruptFlag The specified interrupt of UART module: + * - \ref UART_INTEN_TOCNTEN_Msk : Rx Time Out interrupt + * - \ref UART_INTEN_WKCTSIEN_Msk : Wakeup interrupt + * - \ref UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt + * - \ref UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt + * - \ref UART_INTEN_MODEMIEN_Msk : Modem interrupt + * - \ref UART_INTEN_RLSIEN_Msk : Rx Line status interrupt + * - \ref UART_INTEN_THREIEN_Msk : Tx empty interrupt + * - \ref UART_INTEN_RDAIEN_Msk : Rx ready interrupt + * + * @return None + */ +void UART_EnableInt(UART_T* uart, uint32_t u32InterruptFlag ) +{ + uart->INTEN |= u32InterruptFlag; +} + + +/** + * @brief This function use to enable UART function and set baud-rate. + * + * @param[in] uart The base address of UART module. + * @param[in] u32baudrate The baudrate of UART module. + * + * @return None + */ +void UART_Open(UART_T* uart, uint32_t u32baudrate) +{ + uint8_t u8UartClkSrcSel; + uint32_t u32ClkTbl[4] = {__HXT, 0, __HIRC, __HIRC}; + uint32_t u32Clk; + uint32_t u32Baud_Div; + + u32ClkTbl[1] = CLK_GetPLLClockFreq(); + + u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos; + + uart->FUNCSEL = UART_FUNCSEL_UART; + uart->LINE = UART_WORD_LEN_8 | UART_PARITY_NONE | UART_STOP_BIT_1; + uart->FIFO = UART_FIFO_RFITL_1BYTE | UART_FIFO_RTSTRGLV_1BYTE; + + u32Clk = (u32ClkTbl[u8UartClkSrcSel]) / (((CLK->CLKDIV0 & CLK_CLKDIV0_UARTDIV_Msk) >> CLK_CLKDIV0_UARTDIV_Pos) + 1); + + if(u32baudrate != 0) { + u32Baud_Div = UART_BAUD_MODE2_DIVIDER(u32Clk, u32baudrate); + + if(u32Baud_Div > 0xFFFF) + uart->BAUD = (UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32baudrate)); + else + uart->BAUD = (UART_BAUD_MODE2 | u32Baud_Div); + } +} + + +/** + * @brief The function is used to read Rx data from RX FIFO and the data will be stored in pu8RxBuf. + * + * @param[in] uart The base address of UART module. + * @param[out] pu8RxBuf The buffer to receive the data of receive FIFO. + * @param[in] u32ReadBytes The the read bytes number of data. + * + * @return u32Count: Receive byte count + * + */ +uint32_t UART_Read(UART_T* uart, uint8_t *pu8RxBuf, uint32_t u32ReadBytes) +{ + uint32_t u32Count; + + for(u32Count=0; u32Count < u32ReadBytes; u32Count++) { + if(uart->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk) { /* Check RX empty => failed */ + return u32Count; + } + pu8RxBuf[u32Count] = uart->DAT; /* Get Data from UART RX */ + } + + return u32Count; +} + + +/** + * @brief This function use to config UART line setting. + * + * @param[in] uart The base address of UART module. + * @param[in] u32baudrate The register value of baudrate of UART module. + * if u32baudrate = 0, UART baudrate will not change. + * @param[in] u32data_width The data length of UART module. [ \ref UART_WORD_LEN_5 / \ref UART_WORD_LEN_6 / \ref UART_WORD_LEN_7 / \ref UART_WORD_LEN_8] + * @param[in] u32parity The parity setting (odd/even/none) of UART module. [ \ref UART_PARITY_NONE / \ref UART_PARITY_ODD / + * \ref UART_PARITY_EVEN / \ref UART_PARITY_MARK / \ref UART_PARITY_SPACE] + * @param[in] u32stop_bits The stop bit length (1/1.5/2 bit) of UART module. [ \ref UART_STOP_BIT_1 / \ref UART_STOP_BIT_1_5 / \ref UART_STOP_BIT_2] + * + * @return None + */ +void UART_SetLine_Config(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits) +{ + uint8_t u8UartClkSrcSel; + uint32_t u32ClkTbl[4] = {__HXT, 0, __HIRC, __HIRC}; + uint32_t u32Clk; + uint32_t u32Baud_Div = 0; + + u32ClkTbl[1] = CLK_GetPLLClockFreq(); + + u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos; + + u32Clk = (u32ClkTbl[u8UartClkSrcSel]) / (((CLK->CLKDIV0 & CLK_CLKDIV0_UARTDIV_Msk) >> CLK_CLKDIV0_UARTDIV_Pos) + 1); + + if(u32baudrate != 0) { + u32Baud_Div = UART_BAUD_MODE2_DIVIDER(u32Clk, u32baudrate); + + if(u32Baud_Div > 0xFFFF) + uart->BAUD = (UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32baudrate)); + else + uart->BAUD = (UART_BAUD_MODE2 | u32Baud_Div); + } + + uart->LINE = u32data_width | u32parity | u32stop_bits; +} + + +/** + * @brief This function use to set Rx timeout count. + * + * @param[in] uart The base address of UART module. + * @param[in] u32TOC Rx timeout counter. + * + * @return None + */ +void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC) +{ + uart->TOUT = (uart->TOUT & ~UART_TOUT_TOIC_Msk)| (u32TOC); + uart->INTEN |= UART_INTEN_TOCNTEN_Msk; +} + + +/** + * @brief The function is used to configure IrDA relative settings. It consists of TX or RX mode and baudrate. + * + * @param[in] uart The base address of UART module. + * @param[in] u32Buadrate The baudrate of UART module. + * @param[in] u32Direction The direction(transmit:1/receive:0) of UART module in IrDA mode. + * + * @return None + */ +void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction) +{ + uint8_t u8UartClkSrcSel; + uint32_t u32ClkTbl[4] = {__HXT, 0, __HIRC, __HIRC}; + uint32_t u32Clk; + + u32ClkTbl[1] = CLK_GetPLLClockFreq(); + + u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos; + + u32Clk = (u32ClkTbl[u8UartClkSrcSel]) / (((CLK->CLKDIV0 & CLK_CLKDIV0_UARTDIV_Msk) >> CLK_CLKDIV0_UARTDIV_Pos) + 1); + + uart->BAUD = UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, u32Buadrate); + + uart->IRDA &= ~UART_IRDA_TXINV_Msk; + uart->IRDA |= UART_IRDA_RXINV_Msk; + uart->IRDA = u32Direction ? uart->IRDA | UART_IRDA_TXEN_Msk : uart->IRDA &~ UART_IRDA_TXEN_Msk; + uart->FUNCSEL = (0x2 << UART_FUNCSEL_FUNCSEL_Pos); +} + + +/** + * @brief The function is used to set RS485 relative setting. + * + * @param[in] uart The base address of UART module. + * @param[in] u32Mode The operation mode( \ref UART_ALTCTL_RS485NMM_Msk / \ref UART_ALTCTL_RS485AUD_Msk / \ref UART_ALTCTL_RS485AAD_Msk). + * @param[in] u32Addr The RS485 address. + * + * @return None + */ +void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr) +{ + uart->FUNCSEL = UART_FUNCSEL_RS485; + uart->ALTCTL = 0; + uart->ALTCTL |= u32Mode | (u32Addr << UART_ALTCTL_ADDRMV_Pos); +} + + +/** + * @brief The function is to write data into TX buffer to transmit data by UART. + * + * @param[in] uart The base address of UART module. + * @param[in] pu8TxBuf The buffer to send the data to UART transmission FIFO. + * @param[in] u32WriteBytes The byte number of data. + * + * @return u32Count: transfer byte count + */ +uint32_t UART_Write(UART_T* uart,uint8_t *pu8TxBuf, uint32_t u32WriteBytes) +{ + uint32_t u32Count; + + for(u32Count=0; u32Count != u32WriteBytes; u32Count++) { + if(uart->FIFOSTS & UART_FIFOSTS_TXFULL_Msk) { /* Wait Tx empty and Time-out manner */ + return u32Count; + } + uart->DAT = pu8TxBuf[u32Count]; /* Send UART Data from buffer */ + } + + return u32Count; +} + + +/*@}*/ /* end of group NUC472_442_UART_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_UART_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ + + diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/usbd.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/usbd.c new file mode 100644 index 0000000000000000000000000000000000000000..439bb64d33c90dcb1b0cb6528ad08caedece16fa --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/usbd.c @@ -0,0 +1,574 @@ +/**************************************************************************//** + * @file usbd.c + * @version V1.00 + * $Revision: 18 $ + * $Date: 15/11/30 1:41p $ + * @brief NUC472/NUC442 USBD driver source file + * + * @note + * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_USBD_Driver USBD Driver + @{ +*/ + + +/** @addtogroup NUC472_442_USBD_EXPORTED_FUNCTIONS USBD Exported Functions + @{ +*/ +/// @cond HIDDEN_SYMBOLS +/*--------------------------------------------------------------------------*/ +/*!< Global variables for Control Pipe */ +S_USBD_CMD_T gUsbCmd; +S_USBD_INFO_T *g_usbd_sInfo; + +VENDOR_REQ g_usbd_pfnVendorRequest = NULL; +CLASS_REQ g_usbd_pfnClassRequest = NULL; +SET_INTERFACE_REQ g_usbd_pfnSetInterface = NULL; +uint32_t g_u32EpStallLock = 0; /*!< Bit map flag to lock specified EP when SET_FEATURE */ + +static uint8_t *g_usbd_CtrlInPointer = 0; +static uint32_t g_usbd_CtrlMaxPktSize = 64; +static uint8_t g_usbd_UsbConfig = 0; +static uint8_t g_usbd_UsbAltInterface = 0; +static uint8_t g_usbd_EnableTestMode = 0; +static uint8_t g_usbd_TestSelector = 0; + +#ifdef __ICCARM__ +#pragma data_alignment=4 +static uint8_t g_usbd_buf[12]; +#elif defined __CC_ARM +__align(4) static uint8_t g_usbd_buf[12]; +#elif defined __GNUC__ +__attribute__((aligned(4))) +static uint8_t g_usbd_buf[12]; +#endif + + +uint8_t g_usbd_Configured = 0; +uint8_t g_usbd_CtrlZero = 0; +uint8_t g_usbd_UsbAddr = 0; +uint8_t g_usbd_ShortPacket = 0; +uint32_t volatile g_usbd_DmaDone = 0; +uint32_t g_usbd_CtrlInSize = 0; +/// @endcond /* HIDDEN_SYMBOLS*/ +/** + * @brief USBD Initial + * + * @param[in] param Descriptor + * @param[in] pfnClassReq Class Request Callback Function + * @param[in] pfnSetInterface SetInterface Request Callback Function + * + * @return None + * + * @details This function is used to initial USBD. + */ +void USBD_Open(S_USBD_INFO_T *param, CLASS_REQ pfnClassReq, SET_INTERFACE_REQ pfnSetInterface) +{ + g_usbd_sInfo = param; + g_usbd_pfnClassRequest = pfnClassReq; + g_usbd_pfnSetInterface = pfnSetInterface; + + /* get EP0 maximum packet size */ + g_usbd_CtrlMaxPktSize = g_usbd_sInfo->gu8DevDesc[7]; + + /* Initial USB engine */ + /* Enable PHY */ + USBD_ENABLE_PHY(); + /* wait PHY clock ready */ + while (1) { + USBD->EP[EPA].EPMPS = 0x20; + if (USBD->EP[EPA].EPMPS == 0x20) + break; + } + /* Force SE0, and then clear it to connect*/ + USBD_SET_SE0(); +} + +/** + * @brief USBD Start + * + * @param[in] None + * + * @return None + * + * @details This function is used to start transfer + */ +void USBD_Start(void) +{ + USBD_CLR_SE0(); +} + +/** + * @brief Process Setup Packet + * + * @param[in] None + * + * @return None + * + * @details This function is used to process Setup packet. + */ +void USBD_ProcessSetupPacket(void) +{ + // Setup packet process + gUsbCmd.bmRequestType = (uint8_t)(USBD->SETUP1_0 & 0xff); + gUsbCmd.bRequest = (int8_t)(USBD->SETUP1_0 >> 8) & 0xff; + gUsbCmd.wValue = (uint16_t)USBD->SETUP3_2; + gUsbCmd.wIndex = (uint16_t)USBD->SETUP5_4; + gUsbCmd.wLength = (uint16_t)USBD->SETUP7_6; + + /* USB device request in setup packet: offset 0, D[6..5]: 0=Standard, 1=Class, 2=Vendor, 3=Reserved */ + switch (gUsbCmd.bmRequestType & 0x60) { + case REQ_STANDARD: { // Standard + USBD_StandardRequest(); + break; + } + case REQ_CLASS: { // Class + if (g_usbd_pfnClassRequest != NULL) { + g_usbd_pfnClassRequest(); + } + break; + } + case REQ_VENDOR: { // Vendor + if (g_usbd_pfnVendorRequest != NULL) { + g_usbd_pfnVendorRequest(); + } + break; + } + default: { // reserved + /* Setup error, stall the device */ + USBD_SET_CEP_STATE(USBD_CEPCTL_STALLEN_Msk); + break; + } + } +} + +/** + * @brief Get Descriptor request + * + * @param[in] None + * + * @return None + * + * @details This function is used to process GetDescriptor request. + */ +int USBD_GetDescriptor(void) +{ + uint32_t u32Len; + + u32Len = gUsbCmd.wLength; + g_usbd_CtrlZero = 0; + + switch ((gUsbCmd.wValue & 0xff00) >> 8) { + // Get Device Descriptor + case DESC_DEVICE: { + u32Len = Minimum(u32Len, LEN_DEVICE); + USBD_PrepareCtrlIn((uint8_t *)g_usbd_sInfo->gu8DevDesc, u32Len); + break; + } + // Get Configuration Descriptor + case DESC_CONFIG: { + uint32_t u32TotalLen; + + u32TotalLen = g_usbd_sInfo->gu8ConfigDesc[3]; + u32TotalLen = g_usbd_sInfo->gu8ConfigDesc[2] + (u32TotalLen << 8); + + u32Len = Minimum(u32Len, u32TotalLen); + if ((u32Len % g_usbd_CtrlMaxPktSize) == 0) + g_usbd_CtrlZero = 1; + + USBD_PrepareCtrlIn((uint8_t *)g_usbd_sInfo->gu8ConfigDesc, u32Len); + break; + } + // Get Qualifier Descriptor + case DESC_QUALIFIER: { + u32Len = Minimum(u32Len, LEN_QUALIFIER); + USBD_PrepareCtrlIn((uint8_t *)g_usbd_sInfo->gu8QualDesc, u32Len); + break; + } + // Get Other Speed Descriptor - Full speed + case DESC_OTHERSPEED: { + uint32_t u32TotalLen; + + u32TotalLen = g_usbd_sInfo->gu8OtherConfigDesc[3]; + u32TotalLen = g_usbd_sInfo->gu8OtherConfigDesc[2] + (u32TotalLen << 8); + + u32Len = Minimum(u32Len, u32TotalLen); + if ((u32Len % g_usbd_CtrlMaxPktSize) == 0) + g_usbd_CtrlZero = 1; + + USBD_PrepareCtrlIn((uint8_t *)g_usbd_sInfo->gu8OtherConfigDesc, u32Len); + break; + } + // Get HID Descriptor + case DESC_HID: { + u32Len = Minimum(u32Len, LEN_HID); + USBD_MemCopy(g_usbd_buf, (uint8_t *)&g_usbd_sInfo->gu8ConfigDesc[LEN_CONFIG+LEN_INTERFACE], u32Len); + USBD_PrepareCtrlIn(g_usbd_buf, u32Len); + break; + } + // Get Report Descriptor + case DESC_HID_RPT: { + if ((u32Len % g_usbd_CtrlMaxPktSize) == 0) + g_usbd_CtrlZero = 1; + + u32Len = Minimum(u32Len, g_usbd_sInfo->gu32HidReportSize[gUsbCmd.wIndex & 0xff]); + USBD_PrepareCtrlIn((uint8_t *)g_usbd_sInfo->gu8HidReportDesc[gUsbCmd.wIndex & 0xff], u32Len); + break; + } + // Get String Descriptor + case DESC_STRING: { + // Get String Descriptor + if((gUsbCmd.wValue & 0xff) < 4) { + u32Len = Minimum(u32Len, g_usbd_sInfo->gu8StringDesc[gUsbCmd.wValue & 0xff][0]); + if ((u32Len % g_usbd_CtrlMaxPktSize) == 0) + g_usbd_CtrlZero = 1; + USBD_PrepareCtrlIn((uint8_t *)g_usbd_sInfo->gu8StringDesc[gUsbCmd.wValue & 0xff], u32Len); + } else { + USBD_SET_CEP_STATE(USBD_CEPCTL_STALLEN_Msk); + return 1; + } + break; + } + default: + // Not support. Reply STALL. + USBD_SET_CEP_STATE(USBD_CEPCTL_STALLEN_Msk); + return 1; + } + return 0; +} + + +/** + * @brief Process USB standard request + * + * @param[in] None + * + * @return None + * + * @details This function is used to process USB Standard Request. + */ +void USBD_StandardRequest(void) +{ + /* clear global variables for new request */ + g_usbd_CtrlInPointer = 0; + g_usbd_CtrlInSize = 0; + + if (gUsbCmd.bmRequestType & 0x80) { /* request data transfer direction */ + // Device to host + switch (gUsbCmd.bRequest) { + case GET_CONFIGURATION: { + // Return current configuration setting + USBD_PrepareCtrlIn((uint8_t *)&g_usbd_UsbConfig, 1); + + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_INTKIF_Msk); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_INTKIEN_Msk); + break; + } + case GET_DESCRIPTOR: { + if (!USBD_GetDescriptor()) { + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_INTKIF_Msk); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_INTKIEN_Msk); + } + break; + } + case GET_INTERFACE: { + // Return current interface setting + USBD_PrepareCtrlIn((uint8_t *)&g_usbd_UsbAltInterface, 1); + + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_INTKIF_Msk); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_INTKIEN_Msk); + break; + } + case GET_STATUS: { + // Device + if (gUsbCmd.bmRequestType == 0x80) { + if (g_usbd_sInfo->gu8ConfigDesc[7] & 0x40) + g_usbd_buf[0] = 1; // Self-Powered + else + g_usbd_buf[0] = 0; // bus-Powered + } + // Interface + else if (gUsbCmd.bmRequestType == 0x81) + g_usbd_buf[0] = 0; + // Endpoint + else if (gUsbCmd.bmRequestType == 0x82) { + uint8_t ep = gUsbCmd.wIndex & 0xF; + g_usbd_buf[0] = USBD_GetStall(ep)? 1 : 0; + } + g_usbd_buf[1] = 0; + USBD_PrepareCtrlIn(g_usbd_buf, 2); + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_INTKIF_Msk); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_INTKIEN_Msk); + break; + } + default: { + /* Setup error, stall the device */ + USBD_SET_CEP_STATE(USBD_CEPCTL_STALLEN_Msk); + break; + } + } + } else { + // Host to device + switch (gUsbCmd.bRequest) { + case CLEAR_FEATURE: { + if((gUsbCmd.wValue & 0xff) == FEATURE_ENDPOINT_HALT) { + + int32_t epNum, i; + + /* EP number stall is not allow to be clear in MSC class "Error Recovery Test". + a flag: g_u32EpStallLock is added to support it */ + epNum = gUsbCmd.wIndex & 0xF; + for (i=0; iEP[i].EPCFG & 0xf0) >> 4) == epNum) && ((g_u32EpStallLock & (1 << i)) == 0)) { + USBD->EP[i].EPRSPCTL = (USBD->EP[i].EPRSPCTL & 0xef) | USB_EP_RSPCTL_TOGGLE; + } + } + } + /* Status stage */ + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_STSDONEIF_Msk); + USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk); + break; + } + case SET_ADDRESS: { + g_usbd_UsbAddr = (uint8_t)gUsbCmd.wValue; + + // DATA IN for end of setup + /* Status Stage */ + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_STSDONEIF_Msk); + USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk); + break; + } + case SET_CONFIGURATION: { + g_usbd_UsbConfig = (uint8_t)gUsbCmd.wValue; + g_usbd_Configured = 1; + // DATA IN for end of setup + /* Status stage */ + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_STSDONEIF_Msk); + USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk); + break; + } + case SET_FEATURE: { + if ((gUsbCmd.wValue & 0x3) == 2) { /* TEST_MODE*/ + g_usbd_EnableTestMode = 1; + g_usbd_TestSelector = gUsbCmd.wIndex >> 8; + } + /* Status stage */ + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_STSDONEIF_Msk); + USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk); + break; + } + case SET_INTERFACE: { + g_usbd_UsbAltInterface = (uint8_t)gUsbCmd.wValue; + if (g_usbd_pfnSetInterface != NULL) + g_usbd_pfnSetInterface(g_usbd_UsbAltInterface); + /* Status stage */ + USBD_CLR_CEP_INT_FLAG(USBD_CEPINTSTS_STSDONEIF_Msk); + USBD_SET_CEP_STATE(USB_CEPCTL_NAKCLR); + USBD_ENABLE_CEP_INT(USBD_CEPINTEN_STSDONEIEN_Msk); + break; + } + default: { + /* Setup error, stall the device */ + USBD_SET_CEP_STATE(USBD_CEPCTL_STALLEN_Msk); + break; + } + } + } +} + +/** + * @brief Update Device State + * + * @param[in] None + * + * @return None + * + * @details This function is used to update Device state when Setup packet complete + */ +/// @cond HIDDEN_SYMBOLS +#define TEST_J 0x01 +#define TEST_K 0x02 +#define TEST_SE0_NAK 0x03 +#define TEST_PACKET 0x04 +#define TEST_FORCE_ENABLE 0x05 +/// @endcond /* HIDDEN_SYMBOLS*/ +void USBD_UpdateDeviceState(void) +{ + switch (gUsbCmd.bRequest) { + case SET_ADDRESS: { + USBD_SET_ADDR(g_usbd_UsbAddr); + break; + } + case SET_CONFIGURATION: { + if (g_usbd_UsbConfig == 0) { + int volatile i; + /* Reset PID DATA0 */ + for (i=0; iEP[i].EPCFG & 0x1) { + USBD->EP[i].EPRSPCTL = USB_EP_RSPCTL_TOGGLE; + } + } + } + break; + } + case SET_FEATURE: { + if(gUsbCmd.wValue == FEATURE_ENDPOINT_HALT) + USBD_SetStall(gUsbCmd.wIndex & 0xF); + else if (g_usbd_EnableTestMode) { + g_usbd_EnableTestMode = 0; + if (g_usbd_TestSelector == TEST_J) + USBD->TEST = TEST_J; + else if (g_usbd_TestSelector == TEST_K) + USBD->TEST = TEST_K; + else if (g_usbd_TestSelector == TEST_SE0_NAK) + USBD->TEST = TEST_SE0_NAK; + else if (g_usbd_TestSelector == TEST_PACKET) + USBD->TEST = TEST_PACKET; + else if (g_usbd_TestSelector == TEST_FORCE_ENABLE) + USBD->TEST = TEST_FORCE_ENABLE; + } + break; + } + case CLEAR_FEATURE: { + if(gUsbCmd.wValue == FEATURE_ENDPOINT_HALT) + USBD_ClearStall(gUsbCmd.wIndex & 0xF); + break; + } + default: + ; + } +} + + +/** + * @brief Prepare Control IN transaction + * + * @param[in] pu8Buf Control IN data pointer + * @param[in] u32Size IN transfer size + * + * @return None + * + * @details This function is used to prepare Control IN transfer + */ +void USBD_PrepareCtrlIn(uint8_t *pu8Buf, uint32_t u32Size) +{ + g_usbd_CtrlInPointer = pu8Buf; + g_usbd_CtrlInSize = u32Size; +} + + + +/** + * @brief Start Control IN transfer + * + * @param[in] None + * + * @return None + * + * @details This function is used to start Control IN + */ +void USBD_CtrlIn(void) +{ + int volatile i; + uint32_t volatile count; + + // Process remained data + if(g_usbd_CtrlInSize >= g_usbd_CtrlMaxPktSize) { + // Data size > MXPLD + for (i=0; i<(g_usbd_CtrlMaxPktSize >> 2); i++, g_usbd_CtrlInPointer+=4) + USBD->CEPDAT = *(uint32_t *)g_usbd_CtrlInPointer; + USBD_START_CEP_IN(g_usbd_CtrlMaxPktSize); + g_usbd_CtrlInSize -= g_usbd_CtrlMaxPktSize; + } else { + // Data size <= MXPLD + for (i=0; i<(g_usbd_CtrlInSize >> 2); i++, g_usbd_CtrlInPointer+=4) + USBD->CEPDAT = *(uint32_t *)g_usbd_CtrlInPointer; + + count = g_usbd_CtrlInSize % 4; + for (i=0; iCEPDAT_BYTE = *(uint8_t *)(g_usbd_CtrlInPointer + i); + + USBD_START_CEP_IN(g_usbd_CtrlInSize); + g_usbd_CtrlInPointer = 0; + g_usbd_CtrlInSize = 0; + } +} + +/** + * @brief Start Control OUT transaction + * + * @param[in] pu8Buf Control OUT data pointer + * @param[in] u32Size OUT transfer size + * + * @return None + * + * @details This function is used to start Control OUT transfer + */ +void USBD_CtrlOut(uint8_t *pu8Buf, uint32_t u32Size) +{ + int volatile i; + + while(1) { + if (USBD->CEPINTSTS & USBD_CEPINTSTS_RXPKIF_Msk) { + for (i=0; iCEPDAT_BYTE; + USBD->CEPINTSTS = USBD_CEPINTSTS_RXPKIF_Msk; + break; + } + } +} + +/** + * @brief Clear all software flags + * + * @param[in] None + * + * @return None + * + * @details This function is used to clear all software control flag + */ +void USBD_SwReset(void) +{ + // Reset all variables for protocol + g_usbd_UsbAddr = 0; + g_usbd_DmaDone = 0; + g_usbd_ShortPacket = 0; + g_usbd_Configured = 0; + + // Reset USB device address + USBD_SET_ADDR(0); +} + +/** + * @brief USBD Set Vendor Request + * + * @param[in] pfnVendorReq Vendor Request Callback Function + * + * @return None + * + * @details This function is used to set USBD vendor request callback function + */ +void USBD_SetVendorRequest(VENDOR_REQ pfnVendorReq) +{ + g_usbd_pfnVendorRequest = pfnVendorReq; +} + + +/*@}*/ /* end of group NUC472_442_GPIO_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_GPIO_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/wdt.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/wdt.c new file mode 100644 index 0000000000000000000000000000000000000000..4a9c34ac67efda08a7090bd9df26c3407f914184 --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/wdt.c @@ -0,0 +1,66 @@ +/**************************************************************************//** + * @file wdt.c + * @version V1.00 + * $Revision: 9 $ + * $Date: 15/11/12 9:49a $ + * @brief NUC472/NUC442 WDT driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_WDT_Driver WDT Driver + @{ +*/ + + +/** @addtogroup NUC472_442_WDT_EXPORTED_FUNCTIONS WDT Exported Functions + @{ +*/ + +/** + * @brief This function make WDT module start counting with different time-out interval + * @param[in] u32TimeoutInterval Time-out interval period of WDT module. Valid values are: + * - \ref WDT_TIMEOUT_2POW4 + * - \ref WDT_TIMEOUT_2POW6 + * - \ref WDT_TIMEOUT_2POW8 + * - \ref WDT_TIMEOUT_2POW10 + * - \ref WDT_TIMEOUT_2POW12 + * - \ref WDT_TIMEOUT_2POW14 + * - \ref WDT_TIMEOUT_2POW16 + * - \ref WDT_TIMEOUT_2POW18 + * @param[in] u32ResetDelay Reset delay period while WDT time-out happened. Valid values are: + * - \ref WDT_RESET_DELAY_3CLK + * - \ref WDT_RESET_DELAY_18CLK + * - \ref WDT_RESET_DELAY_130CLK + * - \ref WDT_RESET_DELAY_1026CLK + * @param[in] u32EnableReset Enable WDT rest system function. Valid values are \ref TRUE and \ref FALSE + * @param[in] u32EnableWakeup Enable WDT wake-up system function. Valid values are \ref TRUE and \ref FALSE + * @return None + */ +void WDT_Open(uint32_t u32TimeoutInterval, + uint32_t u32ResetDelay, + uint32_t u32EnableReset, + uint32_t u32EnableWakeup) +{ + + WDT->CTL = u32TimeoutInterval | WDT_CTL_WDTEN_Msk | + (u32EnableReset << WDT_CTL_RSTEN_Pos) | + (u32EnableWakeup << WDT_CTL_WKEN_Pos); + WDT->ALTCTL = u32ResetDelay; + return; +} + + +/*@}*/ /* end of group NUC472_442_WDT_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_WDT_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/Libraries/StdDriver/src/wwdt.c b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/wwdt.c new file mode 100644 index 0000000000000000000000000000000000000000..5359baaccf204b2add236b88ab58a2e047bd6e0b --- /dev/null +++ b/bsp/nuvoton_nuc472/Libraries/StdDriver/src/wwdt.c @@ -0,0 +1,68 @@ +/**************************************************************************//** + * @file wwdt.c + * @version V1.00 + * $Revision: 6 $ + * $Date: 14/10/02 7:19p $ + * @brief NUC472/NUC442 WWDT driver source file + * + * @note + * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. +*****************************************************************************/ +#include "NUC472_442.h" + +/** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver + @{ +*/ + +/** @addtogroup NUC472_442_WWDT_Driver WWDT Driver + @{ +*/ + + +/** @addtogroup NUC472_442_WWDT_EXPORTED_FUNCTIONS WWDT Exported Functions + @{ +*/ + +/** + * @brief This function make WWDT module start counting with different counter period and compared window value + * @param[in] u32PreScale Prescale period for the WWDT counter period. Valid values are: + * - \ref WWDT_PRESCALER_1 + * - \ref WWDT_PRESCALER_2 + * - \ref WWDT_PRESCALER_4 + * - \ref WWDT_PRESCALER_8 + * - \ref WWDT_PRESCALER_16 + * - \ref WWDT_PRESCALER_32 + * - \ref WWDT_PRESCALER_64 + * - \ref WWDT_PRESCALER_128 + * - \ref WWDT_PRESCALER_192 + * - \ref WWDT_PRESCALER_256 + * - \ref WWDT_PRESCALER_384 + * - \ref WWDT_PRESCALER_512 + * - \ref WWDT_PRESCALER_768 + * - \ref WWDT_PRESCALER_1024 + * - \ref WWDT_PRESCALER_1536 + * - \ref WWDT_PRESCALER_2048 + * @param[in] u32CmpValue Window compared value. Valid values are between 0x0 to 0x3F + * @param[in] u32EnableInt Enable WWDT interrupt or not. Valid values are \ref TRUE and \ref FALSE + * @return None + * @note Application can call this function can only once after boot up + */ +void WWDT_Open(uint32_t u32PreScale, uint32_t u32CmpValue, uint32_t u32EnableInt) +{ + WWDT->CTL = u32PreScale | + (u32CmpValue << WWDT_CTL_CMPDAT_Pos)| + WWDT_CTL_WWDTEN_Msk | + (u32EnableInt ? WWDT_CTL_INTEN_Msk : 0); + return; +} + + + + +/*@}*/ /* end of group NUC472_442_WWDT_EXPORTED_FUNCTIONS */ + +/*@}*/ /* end of group NUC472_442_WWDT_Driver */ + +/*@}*/ /* end of group NUC472_442_Device_Driver */ + +/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ diff --git a/bsp/nuvoton_nuc472/README.md b/bsp/nuvoton_nuc472/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a3febd4e3639412441071c051b39fc063be4b543 --- /dev/null +++ b/bsp/nuvoton_nuc472/README.md @@ -0,0 +1,9 @@ +## board info: + + NuTiny-EVB-NUC472 + +## note: + support the GCC MDK5 IAR + +**TODO** + diff --git a/bsp/nuvoton_nuc472/SConscript b/bsp/nuvoton_nuc472/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..fe0ae941ae9a759ae478de901caec1c961e56af8 --- /dev/null +++ b/bsp/nuvoton_nuc472/SConscript @@ -0,0 +1,14 @@ +# for module compiling +import os +Import('RTT_ROOT') + +cwd = str(Dir('#')) +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/nuvoton_nuc472/SConstruct b/bsp/nuvoton_nuc472/SConstruct new file mode 100644 index 0000000000000000000000000000000000000000..ece15e2a05a08dd315e73b4351a603494951fff2 --- /dev/null +++ b/bsp/nuvoton_nuc472/SConstruct @@ -0,0 +1,35 @@ +import os +import sys +import rtconfig + +if os.getenv('RTT_ROOT'): + RTT_ROOT = os.getenv('RTT_ROOT') +else: + RTT_ROOT = os.path.normpath(os.getcwd() + '/../..') + +sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] +from building import * + +TARGET = 'rtthread-nuc472.' + rtconfig.TARGET_EXT + +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 = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map project.map']) + +Export('RTT_ROOT') +Export('rtconfig') + +# prepare building environment +objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False) + + +# make a building +DoBuilding(TARGET, objs) diff --git a/bsp/nuvoton_nuc472/applications/SConscript b/bsp/nuvoton_nuc472/applications/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..9ffdbcd0f9f63b6274eef8adca91f951a1e0fe5f --- /dev/null +++ b/bsp/nuvoton_nuc472/applications/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +CPPPATH = [cwd, str(Dir('#'))] + +group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/nuvoton_nuc472/applications/application.c b/bsp/nuvoton_nuc472/applications/application.c new file mode 100644 index 0000000000000000000000000000000000000000..f7948001c783b96586faa37864a022651af34643 --- /dev/null +++ b/bsp/nuvoton_nuc472/applications/application.c @@ -0,0 +1,22 @@ +/* + * File : main.c + * This file is part of RT-Thread RTOS + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2017-12-12 Bluebear233 first implementation + */ +#include +#include + +int main(void) +{ + while(1){ + rt_thread_delay(RT_TICK_PER_SECOND); + } +} + diff --git a/bsp/nuvoton_nuc472/drivers/SConscript b/bsp/nuvoton_nuc472/drivers/SConscript new file mode 100644 index 0000000000000000000000000000000000000000..ab7ef2c2b05de77f4324a514849df11ebb5ef115 --- /dev/null +++ b/bsp/nuvoton_nuc472/drivers/SConscript @@ -0,0 +1,11 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +CPPPATH = [cwd] + +group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) + +Return('group') diff --git a/bsp/nuvoton_nuc472/drivers/board.c b/bsp/nuvoton_nuc472/drivers/board.c new file mode 100644 index 0000000000000000000000000000000000000000..f8135a795e9503fce02660ff2fd7ae0931e5cb0e --- /dev/null +++ b/bsp/nuvoton_nuc472/drivers/board.c @@ -0,0 +1,108 @@ +/* + * File : board.c + * This file is part of RT-Thread RTOS + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2017-12-12 Bluebear233 first implementation + */ + +#include +#include +#include +#include +#include + +#ifdef __CC_ARM +extern int Image$$RW_IRAM1$$ZI$$Limit; +#elif __ICCARM__ +#pragma section="HEAP" +#else +extern int __bss_end__; +#endif + +/** + * This function will initial Clock tree. + */ +void clock_init(void) +{ + + /*---------------------------------------------------------------------------------------------------------*/ + /* Init System Clock */ + /*---------------------------------------------------------------------------------------------------------*/ + /* Unlock protected registers */ + SYS_UnlockReg(); + + /* Enable External XTAL (4~24 MHz) */ + CLK_EnableXtalRC(CLK_PWRCTL_HXTEN_Msk); + + /* Waiting for 12MHz clock ready */ + CLK_WaitClockReady( CLK_STATUS_HXTSTB_Msk); + + /* Switch HCLK clock source to HXT */ + CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HXT,CLK_CLKDIV0_HCLK(1)); + + /* Set PLL to power down mode and PLL_STB bit in CLKSTATUS register will be cleared by hardware.*/ + CLK->PLLCTL |= CLK_PLLCTL_PD_Msk; + + /* Set PLL frequency */ + CLK->PLLCTL = CLK_PLLCTL_84MHz_HXT; + + /* Waiting for clock ready */ + CLK_WaitClockReady(CLK_STATUS_PLLSTB_Msk); + + /* Switch HCLK clock source to PLL */ + CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_PLL,CLK_CLKDIV0_HCLK(1)); + + /* Update System Core Clock */ + /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */ + SystemCoreClockUpdate(); + + /* Lock protected registers */ + SYS_LockReg(); +} + +/** + * This function will initial NUC472 board. + */ +void rt_hw_board_init(void) +{ + clock_init(); + +#ifdef RT_USING_HEAP +#ifdef __CC_ARM + rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)SRAM_END); +#elif __ICCARM__ + rt_system_heap_init(__segment_end("HEAP"), (void*)SRAM_END); +#else + /* init memory system */ + rt_system_heap_init((void*)&__bss_end__, (void*)SRAM_END); +#endif +#endif /* RT_USING_HEAP */ + + rt_hw_usart_init(); + + rt_console_set_device(RT_CONSOLE_DEVICE_NAME); + + SysTick_Config(SystemCoreClock / RT_TICK_PER_SECOND); +} + +/** + * This is the timer interrupt service routine. + * + */ +void SysTick_Handler(void) +{ + /* enter interrupt */ + rt_interrupt_enter(); + + rt_tick_increase(); + + /* leave interrupt */ + rt_interrupt_leave(); +} + diff --git a/bsp/nuvoton_nuc472/drivers/board.h b/bsp/nuvoton_nuc472/drivers/board.h new file mode 100644 index 0000000000000000000000000000000000000000..60df15ab848c64db38c964c5ff0c8d57bfc5115a --- /dev/null +++ b/bsp/nuvoton_nuc472/drivers/board.h @@ -0,0 +1,24 @@ +/* + * File : board.h + * This file is part of RT-Thread RTOS + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2017-12-12 Bluebear233 first implementation + */ + + +#ifndef __BOARD_H__ +#define __BOARD_H__ + +// Internal SRAM memory size[Kbytes] <8-64> +#define SRAM_SIZE 64 +#define SRAM_END (0x20000000 + SRAM_SIZE * 1024) + + + +#endif /* BOARD_H_ */ diff --git a/bsp/nuvoton_nuc472/drivers/usart.c b/bsp/nuvoton_nuc472/drivers/usart.c new file mode 100644 index 0000000000000000000000000000000000000000..ba85be659ee17b718adda3747256c34b0933cae7 --- /dev/null +++ b/bsp/nuvoton_nuc472/drivers/usart.c @@ -0,0 +1,358 @@ +/* + * File : usart.c + * This file is part of RT-Thread RTOS + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2017-12-12 Bluebear233 first implementation + */ + +#include +#include +#include +#include + +/* Private Define ---------------------------------------------------------------*/ +#define USEING_UART0 //Tx:PG2 Rx:PG1 + +/* Private Typedef --------------------------------------------------------------*/ +struct usart +{ + rt_serial_t dev; + UART_T *usart_base; +}; +typedef struct usart* usart_t; + +/* Private functions ------------------------------------------------------------*/ + + +static rt_err_t usart_gpio_configure(struct rt_serial_device *serial); +static rt_err_t usart_configure(struct rt_serial_device *serial, struct serial_configure *cfg); +static rt_err_t usart_control(struct rt_serial_device *serial, int cmd, void *arg); +static int usart_send(struct rt_serial_device *serial, char c); +static int usart_receive(struct rt_serial_device *serial); +static void rt_hw_uart_register(usart_t uart, UART_T *uart_base, + char *name); +static void uart_isr(usart_t serial); +//static rt_err_t stm32_uart_tx_dma_configure(rt_stm32_uart_t *serial, rt_bool_t bool); +//static rt_err_t stm32_uart_tx_dma_nvic(rt_stm32_uart_t *serial, rt_bool_t bool); + + +/* Private Variables ------------------------------------------------------------*/ +static const struct rt_uart_ops stm32_uart_ops = +{ usart_configure, usart_control, usart_send, usart_receive, + RT_NULL }; + +static const struct serial_configure stm32_uart_default_config = +RT_SERIAL_CONFIG_DEFAULT; + +#ifdef USEING_UART0 +struct usart uart0; +#endif + +/* Interrupt Handle Funtion ----------------------------------------------------*/ +#ifdef USEING_UART0 +/* 串å£0 ä¸­æ–­å…¥å£ */ +void UART0_IRQHandler(void) +{ + uart_isr(&uart0); +} +#endif + +/** + * 中断处ç†å‡½æ•° + */ +static void uart_isr(usart_t serial) +{ + // 获å–串å£åŸºåœ°å€ + UART_T *uart_base = ((usart_t)serial)->usart_base; + + // 获å–中断事件 + uint32_t u32IntSts= uart_base->INTSTS; + + // 接收中断 + if(u32IntSts & (UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk)) + { + rt_hw_serial_isr(&serial->dev, RT_SERIAL_EVENT_RX_IND); + } + +} + +/** + * 串å£ç«¯å£é…ç½® + */ +static rt_err_t usart_gpio_configure(struct rt_serial_device *serial) +{ + // 获å–串å£åŸºåœ°å€ + UART_T *uart_base = ((usart_t)serial)->usart_base; + + switch((uint32_t)uart_base) + { + case UART0_BASE: + SYS->GPG_MFPL = SYS_GPG_MFPL_PG1MFP_UART0_RXD | SYS_GPG_MFPL_PG2MFP_UART0_TXD; + break; + + default: + rt_kprintf("unknow uart module\n"); + RT_ASSERT(0); + } + + return RT_EOK; +} + +/** + * 串å£é…ç½® + */ +static rt_err_t usart_configure(struct rt_serial_device *serial, + struct serial_configure *cfg) +{ + // 获å–串å£åŸºåœ°å€ + UART_T *uart_base = ((usart_t)serial)->usart_base; + + uint32_t uart_module = 0; + uint32_t uart_word_len = 0; + uint32_t uart_stop_bit = 0; + uint32_t uart_parity = 0; + uint32_t uart_irq_channel = 0; + + switch((uint32_t)uart_base) + { + case UART0_BASE: + uart_module = UART0_MODULE; + uart_irq_channel = UART0_IRQn; + break; + + default: + rt_kprintf("unknow uart module\n"); + RT_ASSERT(0); + } + + /* Enable IP clock */ + CLK_EnableModuleClock(uart_module); + + /* Select IP clock source */ + CLK_SetModuleClock(uart_module, CLK_CLKSEL1_UARTSEL_HXT, CLK_CLKDIV0_UART(1)); + + /* check baudrate */ + RT_ASSERT(cfg->baud_rate != 0); + + /* check word len */ + switch(cfg->data_bits) + { + case DATA_BITS_5: + uart_word_len = UART_WORD_LEN_5; + break; + + case DATA_BITS_6: + uart_word_len = UART_WORD_LEN_6; + break; + + case DATA_BITS_7: + uart_word_len = UART_WORD_LEN_7; + break; + + case DATA_BITS_8: + uart_word_len = UART_WORD_LEN_8; + break; + + default: + rt_kprintf("unsupose data len"); + RT_ASSERT(0); + } + + /* check stop bit */ + switch(cfg->stop_bits) + { + case STOP_BITS_1: + uart_stop_bit = UART_STOP_BIT_1; + break; + + case STOP_BITS_2: + uart_stop_bit = UART_STOP_BIT_2; + break; + + default: + rt_kprintf("unsupose stop bit"); + RT_ASSERT(0); + } + + /* check stop bit */ + switch(cfg->parity) + { + case PARITY_NONE: + uart_parity = UART_PARITY_NONE; + break; + + case PARITY_ODD: + uart_parity = UART_PARITY_ODD; + break; + + case PARITY_EVEN: + uart_parity = UART_PARITY_EVEN; + break; + + default: + rt_kprintf("unsupose parity"); + RT_ASSERT(0); + } + + /* Open uart */ + { + uint8_t u8UartClkSrcSel; + uint32_t u32ClkTbl[4] = {__HXT, 0, __HIRC, __HIRC}; + uint32_t u32Clk; + uint32_t u32Baud_Div; + + u32ClkTbl[1] = CLK_GetPLLClockFreq(); + + u8UartClkSrcSel = (CLK->CLKSEL1 & CLK_CLKSEL1_UARTSEL_Msk) >> CLK_CLKSEL1_UARTSEL_Pos; + + uart_base->FUNCSEL = UART_FUNCSEL_UART; + uart_base->LINE = uart_word_len | uart_stop_bit | uart_parity; + uart_base->FIFO = 6 << UART_FIFO_RFITL_Pos; + uart_base->TOUT = (1 << UART_TOUT_DLY_Pos) | (40 << UART_TOUT_TOIC_Pos); + + u32Clk = (u32ClkTbl[u8UartClkSrcSel]) / (((CLK->CLKDIV0 & CLK_CLKDIV0_UARTDIV_Msk) >> CLK_CLKDIV0_UARTDIV_Pos) + 1); + + u32Baud_Div = UART_BAUD_MODE2_DIVIDER(u32Clk, cfg->baud_rate); + + if (u32Baud_Div > 0xFFFF) + uart_base->BAUD = (UART_BAUD_MODE0 | UART_BAUD_MODE0_DIVIDER(u32Clk, cfg->baud_rate)); + else + uart_base->BAUD = (UART_BAUD_MODE2 | u32Baud_Div); + } + + + /* config nvic */ + NVIC_EnableIRQ(uart_irq_channel); + + /* config gpio */ + usart_gpio_configure(serial); + + return RT_EOK; +} + +/** + * 串å£ä¸­æ–­æŽ§åˆ¶ + */ +static rt_err_t usart_control(struct rt_serial_device *serial, + int cmd, void *arg) +{ + rt_err_t result = RT_EOK; + rt_uint32_t flag; + + // 获å–串å£åŸºåœ°å€ + UART_T *uart_base = ((usart_t)serial)->usart_base; + + switch ((uint32_t) arg) + { + case RT_DEVICE_FLAG_INT_RX: + flag = UART_INTEN_RDAIEN_Msk | UART_INTEN_RXTOIEN_Msk | UART_INTEN_TOCNTEN_Msk; + + switch (cmd) + { + case RT_DEVICE_CTRL_CLR_INT: + UART_DISABLE_INT(uart_base, flag); + break; + case RT_DEVICE_CTRL_SET_INT: + UART_ENABLE_INT(uart_base, flag); + break; + default: + RT_ASSERT(0); + } + break; +// TODO 完善DMAæŽ¥å£ +// case RT_DEVICE_FLAG_DMA_TX: +// USART_DMACmd(dev->usart_base, USART_DMAReq_Tx, ENABLE); +// stm32_uart_tx_dma_configure(dev, RT_TRUE); +// stm32_uart_tx_dma_nvic(dev, RT_TRUE); +// break; + default: + RT_ASSERT(0) + ; + } + + return result; + + + + return RT_EOK; +} + +/** + * 串å£å‘é€å‡½æ•° + */ +static int usart_send(struct rt_serial_device *serial, char c) +{ + // 获å–串å£åŸºåœ°å€ + UART_T *uart_base = ((usart_t)serial)->usart_base; + + // 等待FIFO å‘é€ + while(uart_base->FIFOSTS & UART_FIFOSTS_TXFULL_Msk); + + // å‘é€å­—符 + uart_base->DAT = c; + + return 1; +} + +/** + * 串å£æŽ¥æ”¶å‡½æ•° + */ +static int usart_receive(struct rt_serial_device *serial) +{ + // 获å–串å£åŸºåœ°å€ + UART_T *uart_base = ((usart_t)serial)->usart_base; + + // 如果FIFO 为空返回 + if(uart_base->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk) + { + return -1; + } + + return UART_READ(uart_base); +} + +/** + * @brief 串å£è®¾å¤‡æ³¨å†Œ + * @param uart : UART设备结构体 + * @param uart_base : STM32 UARTå¤–è®¾åŸºåœ°å€ + * @param name : STM32 UART设备å + * @param tx_dma_channel : STM32 UART TXçš„DMA通é“基地å€(å¯é€‰) + */ +static void rt_hw_uart_register(usart_t usart, UART_T * uart_base, char *name) +{ + rt_uint32_t flag; + RT_ASSERT(usart != RT_NULL); + RT_ASSERT(uart_base != RT_NULL); + + // 没有定义对应的硬件I2C + if (!(uart_base == UART0 || uart_base == UART1 || uart_base == UART2 + || uart_base == UART3 || uart_base == UART4 || uart_base == UART5)) + { + RT_ASSERT(0); + } + + usart->usart_base = uart_base; + usart->dev.ops = &stm32_uart_ops; + usart->dev.config = stm32_uart_default_config; + + flag = RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX; + + rt_hw_serial_register(&usart->dev, name, + flag, RT_NULL); +} + +/** + * 硬件串å£æ³¨å†Œ + */ +void rt_hw_usart_init(void) +{ +#ifdef USEING_UART0 + rt_hw_uart_register(&uart0, UART0, "uart0"); +#endif +} diff --git a/bsp/nuvoton_nuc472/drivers/usart.h b/bsp/nuvoton_nuc472/drivers/usart.h new file mode 100644 index 0000000000000000000000000000000000000000..310ef187ad498eaa1d6b926c6343ab6557974235 --- /dev/null +++ b/bsp/nuvoton_nuc472/drivers/usart.h @@ -0,0 +1,23 @@ +/* + * File : usart.h + * This file is part of RT-Thread RTOS + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rt-thread.org/license/LICENSE + * + * Change Logs: + * Date Author Notes + * 2017-12-12 Bluebear233 first implementation + */ + +#ifndef __USART_H__ +#define __USART_H__ + +/** + * 硬件串å£æ³¨å†Œ + */ +void rt_hw_usart_init(void); + + +#endif /* __USART_H__ */ diff --git a/bsp/nuvoton_nuc472/ldscripts/libs.ld b/bsp/nuvoton_nuc472/ldscripts/libs.ld new file mode 100644 index 0000000000000000000000000000000000000000..70fea89265163dda4e042a4c19f4cdf460168aa8 --- /dev/null +++ b/bsp/nuvoton_nuc472/ldscripts/libs.ld @@ -0,0 +1,8 @@ + +/* + * Placeholder to list other libraries required by the application. + +GROUP( +) + + */ diff --git a/bsp/nuvoton_nuc472/ldscripts/mem.ld b/bsp/nuvoton_nuc472/ldscripts/mem.ld new file mode 100644 index 0000000000000000000000000000000000000000..351c8f767acb6727d423e556667d110762205a19 --- /dev/null +++ b/bsp/nuvoton_nuc472/ldscripts/mem.ld @@ -0,0 +1,25 @@ +/* + * Memory Spaces Definitions. + * + * Need modifying for a specific board. + * FLASH.ORIGIN: starting address of flash + * FLASH.LENGTH: length of flash + * RAM.ORIGIN: starting address of RAM bank 0 + * RAM.LENGTH: length of RAM bank 0 + * + * The values below can be addressed in further linker scripts + * using functions like 'ORIGIN(RAM)' or 'LENGTH(RAM)'. + */ + +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K + FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 512K /*4K*/ +} + +/* + * For external ram use something like: + + RAM (xrw) : ORIGIN = 0x68000000, LENGTH = 8K + + */ diff --git a/bsp/nuvoton_nuc472/ldscripts/sections.ld b/bsp/nuvoton_nuc472/ldscripts/sections.ld new file mode 100644 index 0000000000000000000000000000000000000000..d7989ad7f95515dcdba99bd5e2e8d0e83ba2680f --- /dev/null +++ b/bsp/nuvoton_nuc472/ldscripts/sections.ld @@ -0,0 +1,387 @@ +/* + * Default linker script for Cortex-M + * + * To make use of the multi-region initialisations, define + * OS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS for the _startup.c file. + */ + +/* + * The '__stack' definition is required by crt0, do not remove it. + */ +__stack = ORIGIN(RAM) + LENGTH(RAM); + +_estack = __stack; /* STM specific definition */ + +/* + * Default stack sizes. + * These are used by the startup in order to allocate stacks + * for the different modes. + */ + +__Main_Stack_Size = 1024 ; + +PROVIDE ( _Main_Stack_Size = __Main_Stack_Size ) ; + +__Main_Stack_Limit = __stack - __Main_Stack_Size ; + +/* "PROVIDE" allows to easily override these values from an + * object file or the command line. */ +PROVIDE ( _Main_Stack_Limit = __Main_Stack_Limit ) ; + +/* + * There will be a link error if there is not this amount of + * RAM free at the end. + */ +_Minimum_Stack_Size = 256 ; + +/* + * Default heap definitions. + * The heap start immediately after the last statically allocated + * .sbss/.noinit section, and extends up to the main stack limit. + */ +PROVIDE ( _Heap_Begin = _end_noinit ) ; +PROVIDE ( _Heap_Limit = __stack - __Main_Stack_Size ) ; + +/* + * The entry point is informative, for debuggers and simulators, + * since the Cortex-M vector points to it anyway. + */ +ENTRY(_start) + + +/* Sections Definitions */ + +SECTIONS +{ + /* + * For Cortex-M devices, the beginning of the startup code is stored in + * the .isr_vector section, which goes to FLASH. + */ + .isr_vector : ALIGN(4) + { + FILL(0xFF) + + __vectors_start = ABSOLUTE(.) ; + __vectors_start__ = ABSOLUTE(.) ; /* STM specific definition */ + KEEP(*(.isr_vector)) /* Interrupt vectors */ + + KEEP(*(.cfmconfig)) /* Freescale configuration words */ + + /* + * This section is here for convenience, to store the + * startup code at the beginning of the flash area, hoping that + * this will increase the readability of the listing. + */ + *(.after_vectors .after_vectors.*) /* Startup code and ISR */ + + } >FLASH + + .inits : ALIGN(4) + { + /* + * Memory regions initialisation arrays. + * + * Thee are two kinds of arrays for each RAM region, one for + * data and one for bss. Each is iterrated at startup and the + * region initialisation is performed. + * + * The data array includes: + * - from (LOADADDR()) + * - region_begin (ADDR()) + * - region_end (ADDR()+SIZEOF()) + * + * The bss array includes: + * - region_begin (ADDR()) + * - region_end (ADDR()+SIZEOF()) + * + * WARNING: It is mandatory that the regions are word aligned, + * since the initialisation code works only on words. + */ + + __data_regions_array_start = .; + + LONG(LOADADDR(.data)); + LONG(ADDR(.data)); + LONG(ADDR(.data)+SIZEOF(.data)); + + __data_regions_array_end = .; + + __bss_regions_array_start = .; + + LONG(ADDR(.bss)); + LONG(ADDR(.bss)+SIZEOF(.bss)); + + + __bss_regions_array_end = .; + + /* End of memory regions initialisation arrays. */ + + /* + * These are the old initialisation sections, intended to contain + * naked code, with the prologue/epilogue added by crti.o/crtn.o + * when linking with startup files. The standalone startup code + * currently does not run these, better use the init arrays below. + */ + KEEP(*(.init)) + KEEP(*(.fini)) + + /* section information for finsh shell */ + . = ALIGN(4); + __fsymtab_start = .; + KEEP(*(FSymTab)) + __fsymtab_end = .; + . = ALIGN(4); + __vsymtab_start = .; + KEEP(*(VSymTab)) + __vsymtab_end = .; + . = ALIGN(4); + + /* section information for initial. */ + . = ALIGN(4); + __rt_init_start = .; + KEEP(*(SORT(.rti_fn*))) + __rt_init_end = .; + . = ALIGN(4); + + + /* + * The preinit code, i.e. an array of pointers to initialisation + * functions to be performed before constructors. + */ + PROVIDE_HIDDEN (__preinit_array_start = .); + + /* + * Used to run the SystemInit() before anything else. + */ + KEEP(*(.preinit_array_sysinit .preinit_array_sysinit.*)) + + /* + * Used for other platform inits. + */ + KEEP(*(.preinit_array_platform .preinit_array_platform.*)) + + /* + * The application inits. If you need to enforce some order in + * execution, create new sections, as before. + */ + KEEP(*(.preinit_array .preinit_array.*)) + + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + + /* + * The init code, i.e. an array of pointers to static constructors. + */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + + /* + * The fini code, i.e. an array of pointers to static destructors. + */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + } >FLASH + + /* + * For some STRx devices, the beginning of the startup code + * is stored in the .flashtext section, which goes to FLASH. + */ + .flashtext : ALIGN(4) + { + *(.flashtext .flashtext.*) /* Startup code */ + } >FLASH + + + /* + * The program code is stored in the .text section, + * which goes to FLASH. + */ + .text : ALIGN(4) + { + *(.text .text.*) /* all remaining code */ + + /* read-only data (constants) */ + *(.rodata .rodata.* .constdata .constdata.*) + + *(vtable) /* C++ virtual tables */ + + KEEP(*(.eh_frame*)) + + /* + * Stub sections generated by the linker, to glue together + * ARM and Thumb code. .glue_7 is used for ARM code calling + * Thumb code, and .glue_7t is used for Thumb code calling + * ARM code. Apparently always generated by the linker, for some + * architectures, so better leave them here. + */ + *(.glue_7) + *(.glue_7t) + + KEEP (*(.init)) + KEEP (*(.fini)) + + } >FLASH + + /* ARM magic sections */ + .ARM.extab : ALIGN(4) + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + . = ALIGN(4); + __exidx_start = .; + .ARM.exidx : ALIGN(4) + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + . = ALIGN(4); + _etext = .; + __etext = .; + + /* MEMORY_ARRAY */ + /* + .ROarraySection : + { + *(.ROarraySection .ROarraySection.*) + } >MEMORY_ARRAY + */ + + /* + * This address is used by the startup code to + * initialise the .data section. + */ + _sidata = LOADADDR(.data); + + /* + * The initialised data section. + * + * The program executes knowing that the data is in the RAM + * but the loader puts the initial values in the FLASH (inidata). + * It is one task of the startup to copy the initial values from + * FLASH to RAM. + */ + .data : ALIGN(4) + { + FILL(0xFF) + /* This is used by the startup code to initialise the .data section */ + _sdata = . ; /* STM specific definition */ + __data_start__ = . ; + *(.data_begin .data_begin.*) + + *(.data .data.*) + + *(.data_end .data_end.*) + . = ALIGN(4); + + /* This is used by the startup code to initialise the .data section */ + _edata = . ; /* STM specific definition */ + __data_end__ = . ; + + } >RAM AT>FLASH + + /* + * The uninitialised data sections. NOLOAD is used to avoid + * the "section `.bss' type changed to PROGBITS" warning + */ + + /* The primary uninitialised data section. */ + .bss (NOLOAD) : ALIGN(4) + { + __bss_start__ = .; /* standard newlib definition */ + _sbss = .; /* STM specific definition */ + *(.bss_begin .bss_begin.*) + + *(.bss .bss.*) + *(COMMON) + + *(.bss_end .bss_end.*) + . = ALIGN(4); + __bss_end__ = .; /* standard newlib definition */ + _ebss = . ; /* STM specific definition */ + } >RAM + + .noinit (NOLOAD) : ALIGN(4) + { + _noinit = .; + + *(.noinit .noinit.*) + + . = ALIGN(4) ; + _end_noinit = .; + } > RAM + + /* Mandatory to be word aligned, _sbrk assumes this */ + PROVIDE ( end = _end_noinit ); /* was _ebss */ + PROVIDE ( _end = _end_noinit ); + PROVIDE ( __end = _end_noinit ); + PROVIDE ( __end__ = _end_noinit ); + + /* + * Used for validation only, do not allocate anything here! + * + * This is just to check that there is enough RAM left for the Main + * stack. It should generate an error if it's full. + */ + ._check_stack : ALIGN(4) + { + . = . + _Minimum_Stack_Size ; + } >RAM + + /* After that there are only debugging sections. */ + + /* This can remove the debugging information from the standard libraries */ + /* + DISCARD : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + */ + + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* + * DWARF debug sections. + * Symbols in the DWARF debugging sections are relative to the beginning + * of the section so we begin them at 0. + */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } +} diff --git a/bsp/nuvoton_nuc472/nuc472_flash.icf b/bsp/nuvoton_nuc472/nuc472_flash.icf new file mode 100644 index 0000000000000000000000000000000000000000..66f94a37d72dd9e0feac450617643fc510ccf68b --- /dev/null +++ b/bsp/nuvoton_nuc472/nuc472_flash.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_1.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x00000000; +define symbol __ICFEDIT_region_IROM1_end__ = 0x0007FFFF; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +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__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x2000FFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x0; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x60000000; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x6FFFFFFF; +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; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x400; +define symbol __ICFEDIT_size_heap__ = 0x0; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region IROM_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 EROM_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__] + | mem:[from __ICFEDIT_region_EROM2_start__ to __ICFEDIT_region_EROM2_end__] + | mem:[from __ICFEDIT_region_EROM3_start__ to __ICFEDIT_region_EROM3_end__]; +define region IRAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__] + | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; +define region ERAM_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__] + | mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__] + | mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; + + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; +define block RTT_INIT_FUNC with fixed order { readonly section .rti_fn* }; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +keep { section FSymTab }; +keep { section VSymTab }; +keep { section .rti_fn* }; +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +place in IROM_region { readonly, block RTT_INIT_FUNC }; +place in EROM_region { readonly section application_specific_ro }; +place in IRAM_region { readwrite, block CSTACK, block HEAP }; +place in ERAM_region { readwrite section application_specific_rw }; diff --git a/bsp/nuvoton_nuc472/nuc472_flash.sct b/bsp/nuvoton_nuc472/nuc472_flash.sct new file mode 100644 index 0000000000000000000000000000000000000000..4db4359d4c6b7fbe3d4c79bd0b992f08f3326b1d --- /dev/null +++ b/bsp/nuvoton_nuc472/nuc472_flash.sct @@ -0,0 +1,15 @@ +; ************************************************************* +; *** Scatter-Loading Description File generated by uVision *** +; ************************************************************* + +LR_IROM1 0x00000000 0x00080000 { ; load region size_region + ER_IROM1 0x00000000 0x00080000 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + } + RW_IRAM1 0x20000000 0x00010000 { ; RW data + .ANY (+RW +ZI) + } +} + diff --git a/bsp/nuvoton_nuc472/project.ewp b/bsp/nuvoton_nuc472/project.ewp new file mode 100644 index 0000000000000000000000000000000000000000..366030b1663b307bd09695763313c5a5255a45a9 --- /dev/null +++ b/bsp/nuvoton_nuc472/project.ewp @@ -0,0 +1,2059 @@ + + 2 + + Debug + + ARM + + 1 + + General + 3 + + 21 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 14 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + ARM + + 0 + + General + 3 + + 21 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 14 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + Applications + + $PROJ_DIR$\applications\application.c + + + + Drivers + + $PROJ_DIR$\drivers\board.c + + + $PROJ_DIR$\drivers\usart.c + + + + CMSIS + + $PROJ_DIR$\Libraries\Device\Nuvoton\NUC472_442\Source\system_NUC472_442.c + + + $PROJ_DIR$\Libraries\Device\Nuvoton\NUC472_442\Source\IAR\startup_NUC472_442.s + + + + NUC472_StdPeriph + + $PROJ_DIR$\Libraries\StdDriver\src\acmp.c + + + $PROJ_DIR$\Libraries\StdDriver\src\adc.c + + + $PROJ_DIR$\Libraries\StdDriver\src\can.c + + + $PROJ_DIR$\Libraries\StdDriver\src\cap.c + + + $PROJ_DIR$\Libraries\StdDriver\src\clk.c + + + $PROJ_DIR$\Libraries\StdDriver\src\crc.c + + + $PROJ_DIR$\Libraries\StdDriver\src\crypto.c + + + $PROJ_DIR$\Libraries\StdDriver\src\eadc.c + + + $PROJ_DIR$\Libraries\StdDriver\src\ebi.c + + + $PROJ_DIR$\Libraries\StdDriver\src\emac.c + + + $PROJ_DIR$\Libraries\StdDriver\src\epwm.c + + + $PROJ_DIR$\Libraries\StdDriver\src\fmc.c + + + $PROJ_DIR$\Libraries\StdDriver\src\gpio.c + + + $PROJ_DIR$\Libraries\StdDriver\src\i2c.c + + + $PROJ_DIR$\Libraries\StdDriver\src\i2s.c + + + $PROJ_DIR$\Libraries\StdDriver\src\pdma.c + + + $PROJ_DIR$\Libraries\StdDriver\src\ps2.c + + + $PROJ_DIR$\Libraries\StdDriver\src\pwm.c + + + $PROJ_DIR$\Libraries\StdDriver\src\rtc.c + + + $PROJ_DIR$\Libraries\StdDriver\src\sc.c + + + $PROJ_DIR$\Libraries\StdDriver\src\scuart.c + + + $PROJ_DIR$\Libraries\StdDriver\src\sd.c + + + $PROJ_DIR$\Libraries\StdDriver\src\spi.c + + + $PROJ_DIR$\Libraries\StdDriver\src\sys.c + + + $PROJ_DIR$\Libraries\StdDriver\src\timer_.c + + + $PROJ_DIR$\Libraries\StdDriver\src\uart.c + + + $PROJ_DIR$\Libraries\StdDriver\src\usbd.c + + + $PROJ_DIR$\Libraries\StdDriver\src\wdt.c + + + $PROJ_DIR$\Libraries\StdDriver\src\wwdt.c + + + + Kernel + + $PROJ_DIR$\..\..\src\clock.c + + + $PROJ_DIR$\..\..\src\components.c + + + $PROJ_DIR$\..\..\src\device.c + + + $PROJ_DIR$\..\..\src\idle.c + + + $PROJ_DIR$\..\..\src\ipc.c + + + $PROJ_DIR$\..\..\src\irq.c + + + $PROJ_DIR$\..\..\src\kservice.c + + + $PROJ_DIR$\..\..\src\mem.c + + + $PROJ_DIR$\..\..\src\mempool.c + + + $PROJ_DIR$\..\..\src\object.c + + + $PROJ_DIR$\..\..\src\scheduler.c + + + $PROJ_DIR$\..\..\src\signal.c + + + $PROJ_DIR$\..\..\src\thread.c + + + $PROJ_DIR$\..\..\src\timer.c + + + + CORTEX-M4 + + $PROJ_DIR$\..\..\libcpu\arm\cortex-m4\cpuport.c + + + $PROJ_DIR$\..\..\libcpu\arm\cortex-m4\context_iar.S + + + $PROJ_DIR$\..\..\libcpu\arm\common\backtrace.c + + + $PROJ_DIR$\..\..\libcpu\arm\common\div0.c + + + $PROJ_DIR$\..\..\libcpu\arm\common\showmem.c + + + + DeviceDrivers + + $PROJ_DIR$\..\..\components\drivers\serial\serial.c + + + $PROJ_DIR$\..\..\components\drivers\src\completion.c + + + $PROJ_DIR$\..\..\components\drivers\src\dataqueue.c + + + $PROJ_DIR$\..\..\components\drivers\src\pipe.c + + + $PROJ_DIR$\..\..\components\drivers\src\ringbuffer.c + + + $PROJ_DIR$\..\..\components\drivers\src\waitqueue.c + + + $PROJ_DIR$\..\..\components\drivers\src\workqueue.c + + + + finsh + + $PROJ_DIR$\..\..\components\finsh\shell.c + + + $PROJ_DIR$\..\..\components\finsh\symbol.c + + + $PROJ_DIR$\..\..\components\finsh\cmd.c + + + $PROJ_DIR$\..\..\components\finsh\msh.c + + + $PROJ_DIR$\..\..\components\finsh\msh_cmd.c + + + $PROJ_DIR$\..\..\components\finsh\msh_file.c + + + diff --git a/bsp/nuvoton_nuc472/project.eww b/bsp/nuvoton_nuc472/project.eww new file mode 100644 index 0000000000000000000000000000000000000000..faa93f37cdf824efd53c15b77e75dc1f03727d9a --- /dev/null +++ b/bsp/nuvoton_nuc472/project.eww @@ -0,0 +1,10 @@ + + + + + $WS_DIR$\project.ewp + + + + + diff --git a/bsp/nuvoton_nuc472/project.uvprojx b/bsp/nuvoton_nuc472/project.uvprojx new file mode 100644 index 0000000000000000000000000000000000000000..90f1e12a5414e76d7b40970250003448368bb8cd --- /dev/null +++ b/bsp/nuvoton_nuc472/project.uvprojx @@ -0,0 +1,862 @@ + + + 2.1 +
### uVision Project, (C) Keil Software
+ + + Target 1 + 0x4 + ARM-ADS + + + NUC472HI8AE + Nuvoton + Nuvoton.NuMicro_DFP.1.1.0 + http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack + IRAM(0x20000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NUC400_AP_512 -FS00 -FL080000 -FP0($$Device:NUC472HI8AE$Flash\NUC400_AP_512.FLM)) + 0 + $$Device:NUC472HI8AE$Device\NUC472\Include\NUC472_442.h + + + + + + + + + + $$Device:NUC472HI8AE$SVD\Nuvoton\NUC400_v1.svd + 0 + 0 + + + + + + + 0 + 0 + 0 + 0 + 1 + + .\Objects\ + template + 1 + 0 + 1 + 1 + 1 + .\Listings\ + 1 + 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 + 1 + 0 + 0 + 0 + 0 + 3 + + + 1 + + + SARMCM3.DLL + + DCM.DLL + -pCM4 + SARMCM3.DLL + + TCM.DLL + -pCM4 + + + + 1 + 0 + 0 + 0 + 16 + + + + + 1 + 0 + 0 + 1 + 0 + -1 + + 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-M4" + + 0 + 0 + 0 + 1 + 1 + 0 + 0 + 2 + 0 + 0 + 8 + 0 + 0 + 0 + 0 + 3 + 3 + 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 + 0x10000 + + + 1 + 0x0 + 0x80000 + + + 0 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x0 + + + 1 + 0x0 + 0x80000 + + + 1 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x0 + 0x0 + + + 0 + 0x20000000 + 0x10000 + + + 0 + 0x0 + 0x0 + + + + + + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 2 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + + + + + applications;.;drivers;Libraries\CMSIS\Include;Libraries\Device\Nuvoton\NUC472_442\Include;Libraries\StdDriver\inc;..\..\include;..\..\libcpu\arm\cortex-m4;..\..\libcpu\arm\common;..\..\components\drivers\include;..\..\components\drivers\include;..\..\components\finsh + + + + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + 1 + 0 + 0 + 0 + 1 + 0 + 0x00000000 + 0x20000000 + + + + + --keep *.o(.rti_fn.*) --keep *.o(FSymTab) + + + + + + + + Applications + + + application.c + 1 + applications\application.c + + + + + Drivers + + + board.c + 1 + drivers\board.c + + + + + usart.c + 1 + drivers\usart.c + + + + + CMSIS + + + system_NUC472_442.c + 1 + Libraries\Device\Nuvoton\NUC472_442\Source\system_NUC472_442.c + + + + + startup_NUC472_442.s + 2 + Libraries\Device\Nuvoton\NUC472_442\Source\ARM\startup_NUC472_442.s + + + + + NUC472_StdPeriph + + + acmp.c + 1 + Libraries\StdDriver\src\acmp.c + + + + + adc.c + 1 + Libraries\StdDriver\src\adc.c + + + + + can.c + 1 + Libraries\StdDriver\src\can.c + + + + + cap.c + 1 + Libraries\StdDriver\src\cap.c + + + + + clk.c + 1 + Libraries\StdDriver\src\clk.c + + + + + crc.c + 1 + Libraries\StdDriver\src\crc.c + + + + + crypto.c + 1 + Libraries\StdDriver\src\crypto.c + + + + + eadc.c + 1 + Libraries\StdDriver\src\eadc.c + + + + + ebi.c + 1 + Libraries\StdDriver\src\ebi.c + + + + + emac.c + 1 + Libraries\StdDriver\src\emac.c + + + + + epwm.c + 1 + Libraries\StdDriver\src\epwm.c + + + + + fmc.c + 1 + Libraries\StdDriver\src\fmc.c + + + + + gpio.c + 1 + Libraries\StdDriver\src\gpio.c + + + + + i2c.c + 1 + Libraries\StdDriver\src\i2c.c + + + + + i2s.c + 1 + Libraries\StdDriver\src\i2s.c + + + + + pdma.c + 1 + Libraries\StdDriver\src\pdma.c + + + + + ps2.c + 1 + Libraries\StdDriver\src\ps2.c + + + + + pwm.c + 1 + Libraries\StdDriver\src\pwm.c + + + + + rtc.c + 1 + Libraries\StdDriver\src\rtc.c + + + + + sc.c + 1 + Libraries\StdDriver\src\sc.c + + + + + scuart.c + 1 + Libraries\StdDriver\src\scuart.c + + + + + sd.c + 1 + Libraries\StdDriver\src\sd.c + + + + + spi.c + 1 + Libraries\StdDriver\src\spi.c + + + + + sys.c + 1 + Libraries\StdDriver\src\sys.c + + + + + timer_.c + 1 + Libraries\StdDriver\src\timer_.c + + + + + uart.c + 1 + Libraries\StdDriver\src\uart.c + + + + + usbd.c + 1 + Libraries\StdDriver\src\usbd.c + + + + + wdt.c + 1 + Libraries\StdDriver\src\wdt.c + + + + + wwdt.c + 1 + Libraries\StdDriver\src\wwdt.c + + + + + Kernel + + + clock.c + 1 + ..\..\src\clock.c + + + + + components.c + 1 + ..\..\src\components.c + + + + + device.c + 1 + ..\..\src\device.c + + + + + idle.c + 1 + ..\..\src\idle.c + + + + + ipc.c + 1 + ..\..\src\ipc.c + + + + + irq.c + 1 + ..\..\src\irq.c + + + + + kservice.c + 1 + ..\..\src\kservice.c + + + + + mem.c + 1 + ..\..\src\mem.c + + + + + mempool.c + 1 + ..\..\src\mempool.c + + + + + object.c + 1 + ..\..\src\object.c + + + + + scheduler.c + 1 + ..\..\src\scheduler.c + + + + + signal.c + 1 + ..\..\src\signal.c + + + + + thread.c + 1 + ..\..\src\thread.c + + + + + timer.c + 1 + ..\..\src\timer.c + + + + + CORTEX-M4 + + + cpuport.c + 1 + ..\..\libcpu\arm\cortex-m4\cpuport.c + + + + + context_rvds.S + 2 + ..\..\libcpu\arm\cortex-m4\context_rvds.S + + + + + backtrace.c + 1 + ..\..\libcpu\arm\common\backtrace.c + + + + + div0.c + 1 + ..\..\libcpu\arm\common\div0.c + + + + + showmem.c + 1 + ..\..\libcpu\arm\common\showmem.c + + + + + DeviceDrivers + + + serial.c + 1 + ..\..\components\drivers\serial\serial.c + + + + + completion.c + 1 + ..\..\components\drivers\src\completion.c + + + + + dataqueue.c + 1 + ..\..\components\drivers\src\dataqueue.c + + + + + pipe.c + 1 + ..\..\components\drivers\src\pipe.c + + + + + ringbuffer.c + 1 + ..\..\components\drivers\src\ringbuffer.c + + + + + waitqueue.c + 1 + ..\..\components\drivers\src\waitqueue.c + + + + + workqueue.c + 1 + ..\..\components\drivers\src\workqueue.c + + + + + finsh + + + shell.c + 1 + ..\..\components\finsh\shell.c + + + + + symbol.c + 1 + ..\..\components\finsh\symbol.c + + + + + cmd.c + 1 + ..\..\components\finsh\cmd.c + + + + + msh.c + 1 + ..\..\components\finsh\msh.c + + + + + msh_cmd.c + 1 + ..\..\components\finsh\msh_cmd.c + + + + + msh_file.c + 1 + ..\..\components\finsh\msh_file.c + + + + + + +
diff --git a/bsp/nuvoton_nuc472/rtconfig.h b/bsp/nuvoton_nuc472/rtconfig.h new file mode 100644 index 0000000000000000000000000000000000000000..579edf73c91b28c0153780608b3ff34cc218b0a1 --- /dev/null +++ b/bsp/nuvoton_nuc472/rtconfig.h @@ -0,0 +1,206 @@ +/* RT-Thread config file */ +#ifndef __RTTHREAD_CFG_H__ +#define __RTTHREAD_CFG_H__ + +/* RT_NAME_MAX*/ +#define RT_NAME_MAX 8 + +/* RT_ALIGN_SIZE*/ +#define RT_ALIGN_SIZE 4 + +/* PRIORITY_MAX */ +#define RT_THREAD_PRIORITY_MAX 32 + +/* Tick per Second */ +#define RT_TICK_PER_SECOND 100 + +/* SECTION: RT_DEBUG */ +/* Thread Debug */ +#define RT_DEBUG +#define RT_THREAD_DEBUG + +#define RT_USING_OVERFLOW_CHECK + +/* Using Hook */ +#define RT_USING_HOOK + +/* Using Software Timer */ +/* #define RT_USING_TIMER_SOFT */ +#define RT_TIMER_THREAD_PRIO 4 +#define RT_TIMER_THREAD_STACK_SIZE 512 +#define RT_TIMER_TICK_PER_SECOND 10 + +/* SECTION: IPC */ +/* Using Semaphore*/ +#define RT_USING_SEMAPHORE + +/* Using Mutex */ +#define RT_USING_MUTEX + +/* Using Event */ +#define RT_USING_EVENT + +/* Using MailBox */ +#define RT_USING_MAILBOX + +/* Using Message Queue */ +#define RT_USING_MESSAGEQUEUE + +/* SECTION: Memory Management */ +/* Using Memory Pool Management*/ +#define RT_USING_MEMPOOL + +/* Using Dynamic Heap Management */ +#define RT_USING_HEAP + +/* Using Small MM */ +#define RT_USING_SMALL_MEM + +// +#define RT_USING_COMPONENTS_INIT + +/* SECTION: Device System */ +/* Using Device System */ +#define RT_USING_DEVICE +// +#define RT_USING_DEVICE_IPC +// +#define RT_USING_SERIAL + +/* SECTION: Console options */ +#define RT_USING_CONSOLE +/* the buffer size of console*/ +#define RT_CONSOLEBUF_SIZE 128 +// +#define RT_CONSOLE_DEVICE_NAME "uart0" + +/* SECTION: finsh, a C-Express shell */ +#define RT_USING_FINSH +/* Using symbol table */ +#define FINSH_USING_SYMTAB +#define FINSH_USING_DESCRIPTION +/* Using finsh msh model */ +#define FINSH_USING_MSH +#define FINSH_USING_MSH_ONLY + +//#define RT_USING_PIN + +//#define RT_USING_CAN + +//#define RT_CAN_USING_BUS_HOOK + +//#define RT_CAN_USING_HDR +/* SECTION: device filesystem */ +/* #define RT_USING_DFS */ + +//#define RT_USING_DFS_ELMFAT +/* Reentrancy (thread safe) of the FatFs module. */ +#define RT_DFS_ELM_REENTRANT +/* Number of volumes (logical drives) to be used. */ +#define RT_DFS_ELM_DRIVES 2 +/* #define RT_DFS_ELM_USE_LFN 1 */ +/* #define RT_DFS_ELM_CODE_PAGE 936 */ +#define RT_DFS_ELM_MAX_LFN 255 +/* Maximum sector size to be handled. */ +#define RT_DFS_ELM_MAX_SECTOR_SIZE 512 + +/* the max number of mounted filesystem */ +#define DFS_FILESYSTEMS_MAX 2 +/* the max number of opened files */ +#define DFS_FD_MAX 4 + +/* SECTION: lwip, a lighwight TCP/IP protocol stack */ +/* #define RT_USING_LWIP */ +/* Enable ICMP protocol*/ +#define RT_LWIP_ICMP +/* Enable UDP protocol*/ +#define RT_LWIP_UDP +/* Enable TCP protocol*/ +#define RT_LWIP_TCP +/* Enable DNS */ +#define RT_LWIP_DNS + +/* the number of simulatenously active TCP connections*/ +#define RT_LWIP_TCP_PCB_NUM 5 + +/* Using DHCP */ +/* #define RT_LWIP_DHCP */ + +/* ip address of target*/ +#define RT_LWIP_IPADDR0 192 +#define RT_LWIP_IPADDR1 168 +#define RT_LWIP_IPADDR2 1 +#define RT_LWIP_IPADDR3 30 + +/* gateway address of target*/ +#define RT_LWIP_GWADDR0 192 +#define RT_LWIP_GWADDR1 168 +#define RT_LWIP_GWADDR2 1 +#define RT_LWIP_GWADDR3 1 + +/* mask address of target*/ +#define RT_LWIP_MSKADDR0 255 +#define RT_LWIP_MSKADDR1 255 +#define RT_LWIP_MSKADDR2 255 +#define RT_LWIP_MSKADDR3 0 + +/* tcp thread options */ +#define RT_LWIP_TCPTHREAD_PRIORITY 12 +#define RT_LWIP_TCPTHREAD_MBOX_SIZE 10 +#define RT_LWIP_TCPTHREAD_STACKSIZE 1024 + +/* ethernet if thread options */ +#define RT_LWIP_ETHTHREAD_PRIORITY 15 +#define RT_LWIP_ETHTHREAD_MBOX_SIZE 10 +#define RT_LWIP_ETHTHREAD_STACKSIZE 512 + +/* TCP sender buffer space */ +#define RT_LWIP_TCP_SND_BUF 8192 +/* TCP receive window. */ +#define RT_LWIP_TCP_WND 8192 + +/* SECTION: RT-Thread/GUI */ +/* #define RT_USING_RTGUI */ + +/* name length of RTGUI object */ +#define RTGUI_NAME_MAX 12 +/* support 16 weight font */ +#define RTGUI_USING_FONT16 +/* support Chinese font */ +#define RTGUI_USING_FONTHZ +/* use DFS as file interface */ +#define RTGUI_USING_DFS_FILERW +/* use font file as Chinese font */ +#define RTGUI_USING_HZ_FILE +/* use Chinese bitmap font */ +#define RTGUI_USING_HZ_BMP +/* use small size in RTGUI */ +#define RTGUI_USING_SMALL_SIZE +/* use mouse cursor */ +/* #define RTGUI_USING_MOUSE_CURSOR */ +/* default font size in RTGUI */ +#define RTGUI_DEFAULT_FONT_SIZE 16 + +/* image support */ +/* #define RTGUI_IMAGE_XPM */ +/* #define RTGUI_IMAGE_BMP */ + +// +// #define RT_USING_CMSIS_OS +// +// #define RT_USING_RTT_CMSIS +// +// #define RT_USING_BSP_CMSIS + +/* nanopb support */ +/* #define RT_USING_NANOPB */ + +#define RT_USING_CPU_FFS + +//#define RT_USING_NEWLIB + +#define RT_USING_USER_MAIN + +#define RT_USING_UART0 + +#endif diff --git a/bsp/nuvoton_nuc472/rtconfig.py b/bsp/nuvoton_nuc472/rtconfig.py new file mode 100644 index 0000000000000000000000000000000000000000..c827b105fac9dfd7dc6c567ed3b909e60ec6116e --- /dev/null +++ b/bsp/nuvoton_nuc472/rtconfig.py @@ -0,0 +1,125 @@ +import os + +# toolchains options +ARCH='arm' +CPU='cortex-m4' +CROSS_TOOL='keil' + +if os.getenv('RTT_CC'): + CROSS_TOOL = os.getenv('RTT_CC') + +# cross_tool provides the cross compiler +# EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR + +if CROSS_TOOL == 'gcc': + PLATFORM = 'gcc' + EXEC_PATH = 'C:/Program Files (x86)/GNU Tools ARM Embedded/6 2017-q2-update/bin' +elif CROSS_TOOL == 'keil': + PLATFORM = 'armcc' + EXEC_PATH = 'C:\Keil_v5' +elif CROSS_TOOL == 'iar': + PLATFORM = 'iar' + IAR_PATH = 'C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.5' + +if os.getenv('RTT_EXEC_PATH'): + EXEC_PATH = os.getenv('RTT_EXEC_PATH') + +BUILD = 'debug' + +if PLATFORM == 'gcc': + # toolchains + PREFIX = 'arm-none-eabi-' + CC = PREFIX + 'gcc' + AS = PREFIX + 'gcc' + AR = PREFIX + 'ar' + LINK = PREFIX + 'g++' + TARGET_EXT = 'axf' + SIZE = PREFIX + 'size' + OBJDUMP = PREFIX + 'objdump' + OBJCPY = PREFIX + 'objcopy' + + DEVICE = ' -mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections' + CFLAGS = DEVICE + AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp' + LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread-nuc472.map -T ldscripts/mem.ld -T ldscripts/libs.ld -T ldscripts/sections.ld ' + + CPATH = '' + LPATH = '' + + if BUILD == 'debug': + CFLAGS += ' -O0 -gdwarf-2' + AFLAGS += ' -gdwarf-2' + else: + CFLAGS += ' -O2' + + POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n' + +elif PLATFORM == 'armcc': + # toolchains + CC = 'armcc' + AS = 'armasm' + AR = 'armar' + LINK = 'armlink' + TARGET_EXT = 'axf' + + DEVICE = ' --cpu=cortex-m4.fp' + CFLAGS = DEVICE + ' --apcs=interwork' + AFLAGS = DEVICE + LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-nuc472.map --scatter nuc472_flash.sct' + + CFLAGS += ' --c99' + CFLAGS += ' -I' + EXEC_PATH + '/ARM/RV31/INC' + LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/RV31/LIB' + + EXEC_PATH += '/arm/bin40/' + + if BUILD == 'debug': + CFLAGS += ' -g -O0' + AFLAGS += ' -g' + else: + CFLAGS += ' -O2' + + POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET' + +elif PLATFORM == 'iar': + # toolchains + CC = 'iccarm' + AS = 'iasmarm' + AR = 'iarchive' + LINK = 'ilinkarm' + TARGET_EXT = 'out' + + DEVICE = ' ' + + CFLAGS = DEVICE + CFLAGS += ' --diag_suppress Pa050' + CFLAGS += ' --no_cse' + CFLAGS += ' --no_unroll' + CFLAGS += ' --no_inline' + CFLAGS += ' --no_code_motion' + CFLAGS += ' --no_tbaa' + CFLAGS += ' --no_clustering' + CFLAGS += ' --no_scheduling' + CFLAGS += ' --debug' + CFLAGS += ' --endian=little' + CFLAGS += ' --cpu=Cortex-M4' + CFLAGS += ' -e' + CFLAGS += ' --fpu=None' + CFLAGS += ' --dlib_config "' + IAR_PATH + '/arm/INC/c/DLib_Config_Normal.h"' + CFLAGS += ' -Ol' + CFLAGS += ' --use_c++_inline' + + AFLAGS = '' + AFLAGS += ' -s+' + AFLAGS += ' -w+' + AFLAGS += ' -r' + AFLAGS += ' --cpu Cortex-M4' + AFLAGS += ' --fpu None' + + LFLAGS = ' --config nuc472_flash.icf' + LFLAGS += ' --redirect _Printf=_PrintfTiny' + LFLAGS += ' --redirect _Scanf=_ScanfSmall' + LFLAGS += ' --entry __iar_program_start' + + EXEC_PATH = IAR_PATH + '/arm/bin/' + POST_ACTION = '' diff --git a/bsp/nuvoton_nuc472/template.ewp b/bsp/nuvoton_nuc472/template.ewp new file mode 100644 index 0000000000000000000000000000000000000000..0b9f3eefc27e175fe8d046270955d7442021f8b2 --- /dev/null +++ b/bsp/nuvoton_nuc472/template.ewp @@ -0,0 +1,1819 @@ + + + + 2 + + Debug + + ARM + + 1 + + General + 3 + + 21 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 1 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 14 + 1 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 1 + + + + + + + BILINK + 0 + + + + + Release + + ARM + + 0 + + General + 3 + + 21 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ICCARM + 2 + + 28 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AARM + 2 + + 8 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + OBJCOPY + 0 + + 1 + 1 + 0 + + + + + + + + + CUSTOM + 3 + + + + + + + BICOMP + 0 + + + + BUILDACTION + 1 + + + + + + + ILINK + 0 + + 14 + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + IARCHIVE + 0 + + 0 + 1 + 0 + + + + + + + BILINK + 0 + + + + + + diff --git a/bsp/nuvoton_m451/template.uvprojx b/bsp/nuvoton_nuc472/template.uvprojx similarity index 92% rename from bsp/nuvoton_m451/template.uvprojx rename to bsp/nuvoton_nuc472/template.uvprojx index 95a182e35b5faa2873ae6294b815f6160f6224ff..8c75eb0c0122fbaf5844b406f97d4269b2586ae6 100644 --- a/bsp/nuvoton_m451/template.uvprojx +++ b/bsp/nuvoton_nuc472/template.uvprojx @@ -7,21 +7,21 @@ - template + Target 1 0x4 ARM-ADS - M451VG6AE + NUC472HI8AE Nuvoton - Nuvoton.NuMicro_DFP.1.0.5 + Nuvoton.NuMicro_DFP.1.1.0 http://www.nuvoton.com/hq/enu/Documents/KEILSoftwarePack - IROM(0x00000000,0x40000) IRAM(0x20000000,0x8000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) + IRAM(0x20000000,0x10000) IROM(0x00000000,0x80000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) - UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0M451_AP_256 -FS00 -FL040000 -FP0($$Device:M451VG6AE$Flash\M451_AP_256.FLM)) + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0NUC400_AP_512 -FS00 -FL080000 -FP0($$Device:NUC472HI8AE$Flash\NUC400_AP_512.FLM)) 0 - $$Device:M451VG6AE$Device\M451\Include\M451Series.h + $$Device:NUC472HI8AE$Device\NUC472\Include\NUC472_442.h @@ -31,7 +31,7 @@ - $$Device:M451VG6AE$SVD\Nuvoton\M451_v1.SVD + $$Device:NUC472HI8AE$SVD\Nuvoton\NUC400_v1.svd 0 0 @@ -50,7 +50,7 @@ template 1 0 - 0 + 1 1 1 .\Listings\ @@ -131,12 +131,12 @@ 0 0 1 - 1 - 4096 + 0 + -1 1 BIN\UL2CM3.DLL - "" () + @@ -242,12 +242,12 @@ 0 0x20000000 - 0x8000 + 0x10000 1 0x0 - 0x40000 + 0x80000 0 @@ -272,7 +272,7 @@ 1 0x0 - 0x40000 + 0x80000 1 @@ -297,7 +297,7 @@ 0 0x20000000 - 0x8000 + 0x10000 0 @@ -327,6 +327,8 @@ 1 1 1 + 0 + 0 @@ -370,6 +372,11 @@ + + + Source Group 1 + +