mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-02 14:23:19 +08:00
[n32] 增加多个BSP支持 (#6543)
add bsp n32g43xcl-stb,n32g45xcl-stb,n32g45xml-stb,n32g45xrl-stb,n32g457qel-stb,n32l40xcl-stb,n32l43xml-stb,n32l43xrl-stb,n32l436_evb,n32wb45xl-evb
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_common_tables.h
|
||||
* Description: Extern declaration for common tables
|
||||
*
|
||||
* $Date: 27. January 2017
|
||||
* $Revision: V.1.5.1
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_COMMON_TABLES_H
|
||||
#define _ARM_COMMON_TABLES_H
|
||||
|
||||
#include "arm_math.h"
|
||||
|
||||
extern const uint16_t armBitRevTable[1024];
|
||||
extern const q15_t armRecipTableQ15[64];
|
||||
extern const q31_t armRecipTableQ31[64];
|
||||
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 ARMBITREVINDEXTABLE_1024_TABLE_LENGTH ((uint16_t)1800)
|
||||
#define ARMBITREVINDEXTABLE_2048_TABLE_LENGTH ((uint16_t)3808)
|
||||
#define ARMBITREVINDEXTABLE_4096_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[ARMBITREVINDEXTABLE_1024_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE_2048_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE_4096_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 */
|
||||
@@ -0,0 +1,66 @@
|
||||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_const_structs.h
|
||||
* Description: Constant structs that are initialized for user convenience.
|
||||
* For example, some can be given as arguments to the arm_cfft_f32() function.
|
||||
*
|
||||
* $Date: 27. January 2017
|
||||
* $Revision: V.1.5.1
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_CONST_STRUCTS_H
|
||||
#define _ARM_CONST_STRUCTS_H
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
extern const arm_cfft_instance_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
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
/**************************************************************************//**
|
||||
* @file cmsis_version.h
|
||||
* @brief CMSIS Core(M) Version definitions
|
||||
* @version V5.0.2
|
||||
* @date 19. April 2017
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_VERSION_H
|
||||
#define __CMSIS_VERSION_H
|
||||
|
||||
/* CMSIS Version definitions */
|
||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||
#define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file n32g43x_conf.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __N32G43X_CONF_H__
|
||||
#define __N32G43X_CONF_H__
|
||||
|
||||
/* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */
|
||||
|
||||
#include "n32g43x_adc.h"
|
||||
#include "n32g43x_can.h"
|
||||
#include "n32g43x_comp.h"
|
||||
#include "n32g43x_crc.h"
|
||||
#include "n32g43x_dac.h"
|
||||
#include "n32g43x_dbg.h"
|
||||
#include "n32g43x_dma.h"
|
||||
#include "n32g43x_exti.h"
|
||||
#include "n32g43x_flash.h"
|
||||
#include "n32g43x_gpio.h"
|
||||
#include "n32g43x_i2c.h"
|
||||
#include "n32g43x_iwdg.h"
|
||||
#include "n32g43x_opamp.h"
|
||||
#include "n32g43x_pwr.h"
|
||||
#include "n32g43x_rcc.h"
|
||||
#include "n32g43x_rtc.h"
|
||||
#include "n32g43x_spi.h"
|
||||
#include "n32g43x_tim.h"
|
||||
#include "n32g43x_usart.h"
|
||||
#include "n32g43x_lpuart.h"
|
||||
#include "n32g43x_wwdg.h"
|
||||
#include "n32g43x_tsc.h"
|
||||
|
||||
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
|
||||
|
||||
/* Uncomment the line below to expanse the "assert_param" macro in the
|
||||
Standard Peripheral Library drivers code */
|
||||
/* #define USE_FULL_ASSERT 1 */
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
|
||||
/**
|
||||
* @brief The assert_param macro is used for function's parameters check.
|
||||
* @param expr If expr is false, it calls assert_failed function which reports
|
||||
* the name of the source file and the source line number of the call
|
||||
* that failed. If expr is true, it returns no value.
|
||||
*/
|
||||
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((const uint8_t*)#expr, (const uint8_t*)__FILE__, __LINE__))
|
||||
|
||||
void assert_failed(const uint8_t* expr, const uint8_t* file, uint32_t line);
|
||||
#else
|
||||
#define assert_param(expr) ((void)0)
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
#endif /* __N32G43X_CONF_H__ */
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
****************************************************************************
|
||||
Copyright (c) 2019, Nations Technologies Inc.
|
||||
|
||||
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 disclaimer below.
|
||||
|
||||
Nations' name may not be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
****************************************************************************
|
||||
**/
|
||||
|
||||
/* Entry Point */
|
||||
ENTRY(Reset_Handler)
|
||||
|
||||
/* Highest address of the user mode stack */
|
||||
_estack = 0x20008000; /* end of RAM */
|
||||
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_Min_Heap_Size = 0x200; /* required amount of heap */
|
||||
_Min_Stack_Size = 0x800; /* required amount of stack */
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 128K
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
SECTIONS
|
||||
{
|
||||
/* The startup code goes first into FLASH */
|
||||
.isr_vector :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
KEEP(*(.isr_vector)) /* Startup code */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
/* The program code and other data goes into FLASH */
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.text) /* .text sections (code) */
|
||||
*(.text*) /* .text* sections (code) */
|
||||
*(.glue_7) /* glue arm to thumb code */
|
||||
*(.glue_7t) /* glue thumb to arm code */
|
||||
*(.eh_frame)
|
||||
|
||||
KEEP (*(.init))
|
||||
KEEP (*(.fini))
|
||||
|
||||
/* section information for finsh shell */
|
||||
. = ALIGN(4);
|
||||
__fsymtab_start = .;
|
||||
KEEP(*(FSymTab))
|
||||
__fsymtab_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
__vsymtab_start = .;
|
||||
KEEP(*(VSymTab))
|
||||
__vsymtab_end = .;
|
||||
|
||||
/* section information for initial. */
|
||||
. = ALIGN(4);
|
||||
__rt_init_start = .;
|
||||
KEEP(*(SORT(.rti_fn*)))
|
||||
__rt_init_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
_etext = .; /* define a global symbols at end of code */
|
||||
} >FLASH
|
||||
|
||||
/* Constant data goes into FLASH */
|
||||
.rodata :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*(.rodata) /* .rodata sections (constants, strings, etc.) */
|
||||
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
|
||||
. = ALIGN(4);
|
||||
} >FLASH
|
||||
|
||||
.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
|
||||
.ARM : {
|
||||
__exidx_start = .;
|
||||
*(.ARM.exidx*)
|
||||
__exidx_end = .;
|
||||
} >FLASH
|
||||
|
||||
.preinit_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP (*(.preinit_array*))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
} >FLASH
|
||||
.init_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP (*(SORT(.init_array.*)))
|
||||
KEEP (*(.init_array*))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
} >FLASH
|
||||
.fini_array :
|
||||
{
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP (*(SORT(.fini_array.*)))
|
||||
KEEP (*(.fini_array*))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
} >FLASH
|
||||
|
||||
/* used by the startup to initialize data */
|
||||
_sidata = LOADADDR(.data);
|
||||
|
||||
/* Initialized data sections goes into RAM, load LMA copy after code */
|
||||
.data :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_sdata = .; /* create a global symbol at data start */
|
||||
*(.data) /* .data sections */
|
||||
*(.data*) /* .data* sections */
|
||||
|
||||
. = ALIGN(4);
|
||||
_edata = .; /* define a global symbol at data end */
|
||||
} >RAM AT> FLASH
|
||||
|
||||
/* Uninitialized data section */
|
||||
. = ALIGN(4);
|
||||
.bss :
|
||||
{
|
||||
/* This is used by the startup in order to initialize the .bss secion */
|
||||
_sbss = .; /* define a global symbol at bss start */
|
||||
__bss_start__ = _sbss;
|
||||
*(.bss)
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
|
||||
. = ALIGN(4);
|
||||
_ebss = .; /* define a global symbol at bss end */
|
||||
__bss_end__ = _ebss;
|
||||
} >RAM
|
||||
|
||||
/* User_heap_stack section, used to check that there is enough RAM left */
|
||||
._user_heap_stack :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
PROVIDE ( end = . );
|
||||
PROVIDE ( _end = . );
|
||||
. = . + _Min_Heap_Size;
|
||||
. = . + _Min_Stack_Size;
|
||||
. = ALIGN(4);
|
||||
} >RAM
|
||||
|
||||
|
||||
|
||||
/* Remove information from the standard libraries */
|
||||
/DISCARD/ :
|
||||
{
|
||||
libc.a ( * )
|
||||
libm.a ( * )
|
||||
libgcc.a ( * )
|
||||
}
|
||||
|
||||
.ARM.attributes 0 : { *(.ARM.attributes) }
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+523
File diff suppressed because it is too large
Load Diff
+450
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file system_n32g43x.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __SYSTEM_N32G43X_H__
|
||||
#define __SYSTEM_N32G43X_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup N32G43X_System
|
||||
* @{
|
||||
*/
|
||||
|
||||
extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
|
||||
|
||||
extern void SystemInit(void);
|
||||
extern void SystemCoreClockUpdate(void);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__SYSTEM_N32G43X_H__ */
|
||||
@@ -0,0 +1,63 @@
|
||||
import rtconfig
|
||||
Import('RTT_ROOT')
|
||||
from building import *
|
||||
|
||||
# get current directory
|
||||
cwd = GetCurrentDir()
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
|
||||
src = Split('''
|
||||
CMSIS/device/system_n32g43x.c
|
||||
n32g43x_std_periph_driver/src/n32g43x_gpio.c
|
||||
n32g43x_std_periph_driver/src/n32g43x_rcc.c
|
||||
n32g43x_std_periph_driver/src/n32g43x_exti.c
|
||||
n32g43x_std_periph_driver/src/misc.c
|
||||
''')
|
||||
|
||||
if GetDepend(['RT_USING_SERIAL']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_usart.c']
|
||||
|
||||
if GetDepend(['RT_USING_I2C']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_i2c.c']
|
||||
|
||||
if GetDepend(['RT_USING_SPI']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_spi.c']
|
||||
|
||||
if GetDepend(['RT_USING_CAN']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_can.c']
|
||||
|
||||
if GetDepend(['RT_USING_ADC']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_adc.c']
|
||||
|
||||
if GetDepend(['RT_USING_DAC']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_dac.c']
|
||||
|
||||
if GetDepend(['RT_USING_HWTIMER']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_tim.c']
|
||||
|
||||
if GetDepend(['RT_USING_RTC']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_rtc.c']
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_pwr.c']
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_flash.c']
|
||||
|
||||
if GetDepend(['RT_USING_WDT']):
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_iwdg.c']
|
||||
src += ['n32g43x_std_periph_driver/src/n32g43x_wwdg.c']
|
||||
|
||||
if GetDepend(['RT_USING_BSP_USB']):
|
||||
path += [cwd + '/n32g43x_usbfs_driver/inc']
|
||||
src += [cwd + '/n32g43x_usbfs_driver/src']
|
||||
|
||||
path = [
|
||||
cwd + '/CMSIS/device',
|
||||
cwd + '/CMSIS/core',
|
||||
cwd + '/n32g43x_std_periph_driver/inc',]
|
||||
|
||||
CPPDEFINES = ['USE_STDPERIPH_DRIVER']
|
||||
|
||||
|
||||
|
||||
group = DefineGroup('Libraries', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,119 @@
|
||||
/*****************************************************************************
|
||||
* NationS Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2020, NationS Corporation
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* NationS's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
/*****************************************************************************
|
||||
* File Name: n32g43x_aes.h
|
||||
* Function: Declaring AES algorithm library API
|
||||
* version: V1.2.0
|
||||
* Author: zhang.zhenshan
|
||||
* date: 2020-4-8
|
||||
* ****************************************************************************/
|
||||
|
||||
#ifndef __N32G43X_AES_H__
|
||||
#define __N32G43X_AES_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define AES_ECB (0x11111111)
|
||||
#define AES_CBC (0x22222222)
|
||||
#define AES_CTR (0x33333333)
|
||||
|
||||
#define AES_ENC (0x44444444)
|
||||
#define AES_DEC (0x55555555)
|
||||
|
||||
enum
|
||||
{
|
||||
AES_Crypto_OK = 0x0, //AES opreation success
|
||||
AES_Init_OK = 0x0, //AES Init opreation success
|
||||
AES_Crypto_ModeError = 0x5a5a5a5a, //Working mode error(Neither ECB nor CBC nor CTR)
|
||||
AES_Crypto_EnOrDeError, //En&De error(Neither encryption nor decryption)
|
||||
AES_Crypto_ParaNull, // the part of input(output/iv) Null
|
||||
AES_Crypto_LengthError, // if Working mode is ECB or CBC,the length of input message must be 4 times and cannot be zero;
|
||||
//if Working mode is CTR,the length of input message cannot be zero; othets: return AES_Crypto_LengthError
|
||||
|
||||
AES_Crypto_KeyLengthError, //the keyWordLen must be 4 or 6 or 8; othets:return AES_Crypto_KeyLengthError
|
||||
AES_Crypto_UnInitError, //AES uninitialized
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *in; // the part of input to be encrypted or decrypted
|
||||
uint32_t *iv; // the part of initial vector
|
||||
uint32_t *out; // the part of out
|
||||
uint32_t *key; // the part of key
|
||||
uint32_t keyWordLen; // the length(by word) of key
|
||||
uint32_t inWordLen; // the length(by word) of plaintext or cipher
|
||||
uint32_t En_De; // 0x44444444- encrypt, 0x55555555 - decrypt
|
||||
uint32_t Mode; // 0x11111111 - ECB, 0x22222222 - CBC, 0x33333333 - CTR
|
||||
}AES_PARM;
|
||||
|
||||
/**
|
||||
* @brief AES_Init
|
||||
* @return AES_Init_OK, AES Init success; othets: AES Init fail
|
||||
* @note
|
||||
*/
|
||||
|
||||
uint32_t AES_Init(AES_PARM *parm);
|
||||
|
||||
/**
|
||||
* @brief AES crypto
|
||||
* @param[in] parm pointer to AES context and the detail please refer to struct AES_PARM in AES.h
|
||||
* @return AES_Crypto_OK, AES crypto success; othets: AES crypto fail(reference to the definition by enum variation)
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.Input and output can be the same buffer
|
||||
* 3. IV can be NULL when ECB mode
|
||||
* 4. If Working mode is ECB or CBC,the length of input message must be 4 times and cannot be zero;
|
||||
* if Working mode is CTR,the length of input message cannot be zero;
|
||||
* 5. If the input is in byte, make sure align by word.
|
||||
*/
|
||||
uint32_t AES_Crypto(AES_PARM *parm);
|
||||
|
||||
/**
|
||||
* @brief AES close
|
||||
* @return none
|
||||
* @note if you want to close AES algorithm, this function can be recalled.
|
||||
*/
|
||||
void AES_Close(void);
|
||||
|
||||
/**
|
||||
* @brief Get AES lib version
|
||||
* @param[out] type pointer one byte type information represents the type of the lib, like Commercial version.\
|
||||
* @Bits 0~4 stands for Commercial (C), Security (S), Normal (N), Evaluation (E), Test (T), Bits 5~7 are reserved. e.g. 0x09 stands for CE version.
|
||||
* @param[out] customer pointer one byte customer information represents customer ID. for example, 0x00 stands for standard version, 0x01 is for Tianyu customized version...
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] version pointer one byte version information represents develop version of the lib. e.g. 0x12 denotes version 1.2.
|
||||
* @return none
|
||||
* @1.You can recall this function to get AES lib information
|
||||
*/
|
||||
void AES_Version(uint8_t *type, uint8_t *customer, uint8_t date[3], uint8_t *version);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*****************************************************************************
|
||||
* NationS Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2020, NationS Corporation
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* NationS's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONZ "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONZ 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.
|
||||
* ****************************************************************************/
|
||||
/*****************************************************************************
|
||||
* File Name: Common.h
|
||||
* Function: Defining the public functions used by other algorithm lib
|
||||
* version: V1.2.0
|
||||
* Author: huang.jinshang
|
||||
* date: 2020-01-06
|
||||
* ****************************************************************************/
|
||||
|
||||
#ifndef _N32G43X_ALGO_COMMON_H_
|
||||
#define _N32G43X_ALGO_COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
enum{
|
||||
Cpy_OK=0,//copy success
|
||||
SetZero_OK = 0,//set zero success
|
||||
XOR_OK = 0, //XOR success
|
||||
Reverse_OK = 0, //Reverse success
|
||||
Cmp_EQUAL = 0, //Two big number are equal
|
||||
Cmp_UNEQUAL = 1, //Two big number are not equal
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief disturb the sequence order
|
||||
* @param[in] order pointer to the sequence to be disturbed
|
||||
* @param[in] rand pointer to random number
|
||||
* @param[in] the length of order
|
||||
* @return RandomSort_OK: disturb order success; Others: disturb order fail;
|
||||
* @note
|
||||
*/
|
||||
uint32_t RandomSort(uint8_t *order, const uint8_t *rand, uint32_t len);
|
||||
|
||||
/**
|
||||
* @brief Copy data by byte
|
||||
* @param[in] dst pointer to destination data
|
||||
* @param[in] src pointer to source data
|
||||
* @param[in] byte length
|
||||
* @return Cpy_OK: success; others: fail.
|
||||
* @note 1. dst and src cannot be same
|
||||
*/
|
||||
uint32_t Cpy_U8( uint8_t *dst, uint8_t *src, uint32_t byteLen);
|
||||
|
||||
/**
|
||||
* @brief Copy data by word
|
||||
* @param[in] dst pointer to destination data
|
||||
* @param[in] src pointer to source data
|
||||
* @param[in] word length
|
||||
* @return Cpy_OK: success; others: fail.
|
||||
* @note 1. dst and src must be aligned by word
|
||||
*/
|
||||
uint32_t Cpy_U32( uint32_t *dst, const uint32_t *src, uint32_t wordLen);
|
||||
|
||||
/**
|
||||
* @brief XOR
|
||||
* @param[in] a pointer to one data to be XORed
|
||||
* @param[in] b pointer to another data to be XORed
|
||||
* @param[in] the length of order
|
||||
* @return XOR_OK: operation success; Others: operation fail;
|
||||
* @note
|
||||
*/
|
||||
uint32_t XOR_U8(uint8_t *a, uint8_t *b, uint8_t *c, uint32_t byteLen);
|
||||
|
||||
/**
|
||||
* @brief XORed two u32 arrays
|
||||
* @param[in] a pointer to one data to be XORed
|
||||
* @param[in] b pointer to another data to be XORed
|
||||
* @param[in] the length of order
|
||||
* @return XOR_OK: operation success; Others: operation fail;
|
||||
* @note
|
||||
*/
|
||||
uint32_t XOR_U32(uint32_t *a,uint32_t *b,uint32_t *c,uint32_t wordLen);
|
||||
|
||||
/**
|
||||
* @brief set zero by byte
|
||||
* @param[in] dst pointer to the address to be set zero
|
||||
* @param[in] byte length
|
||||
* @return SetZero_OK: success; others: fail.
|
||||
* @note
|
||||
*/
|
||||
uint32_t SetZero_U8(uint8_t *dst, uint32_t byteLen);
|
||||
|
||||
/**
|
||||
* @brief set zero by word
|
||||
* @param[in] dst pointer to the address to be set zero
|
||||
* @param[in] word length
|
||||
* @return SetZero_OK: success; others: fail.
|
||||
* @note
|
||||
*/
|
||||
uint32_t SetZero_U32(uint32_t *dst, uint32_t wordLen);
|
||||
|
||||
/**
|
||||
* @brief reverse byte order of every word, the words stay the same
|
||||
* @param[in] dst pointer to the destination address
|
||||
* @param[in] src pointer to the source address
|
||||
* @param[in] word length
|
||||
* @return Reverse_OK: success; others: fail.
|
||||
* @note 1.dst and src can be same
|
||||
*/
|
||||
uint32_t ReverseBytesInWord_U32(uint32_t *dst, const uint32_t *src, uint32_t wordLen);
|
||||
|
||||
/**
|
||||
* @brief compare two big number
|
||||
* @param[in] a pointer to one big number
|
||||
* @param[in] word length of a
|
||||
* @param[in] b pointer to another big number
|
||||
* @param[in] word length of b
|
||||
* @return Cmp_UNEQUAL:a!=b;Cmp_EQUAL: a==b.
|
||||
*
|
||||
*/
|
||||
int32_t Cmp_U32(const uint32_t *a, uint32_t aWordLen, const uint32_t *b, uint32_t bWordLen);
|
||||
|
||||
/**
|
||||
* @brief compare two big number
|
||||
* @param[in] a pointer to one big number
|
||||
* @param[in] word length of a
|
||||
* @param[in] b pointer to another big number
|
||||
* @param[in] word length of b
|
||||
* @return Cmp_UNEQUAL:a!=b;Cmp_EQUAL: a==b.
|
||||
*
|
||||
*/
|
||||
int32_t Cmp_U8(const uint8_t *a, uint32_t aByteLen, const uint8_t *b, uint32_t bByteLen);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/*****************************************************************************
|
||||
* Nations Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2020, Nations Corporation
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY Nations "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL Nations 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.
|
||||
* ****************************************************************************/
|
||||
/*****************************************************************************
|
||||
* File Name: Dn32g43x_des.h
|
||||
* Function: Declaring DES algorithm library API
|
||||
* version: V1.2.0
|
||||
* Author: zhang.zhenshan
|
||||
* date: 2020-4-8
|
||||
* ****************************************************************************/
|
||||
|
||||
|
||||
#ifndef _N32G43X_DES_H_
|
||||
#define _N32G43X_DES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DES_ECB (0x11111111)
|
||||
#define DES_CBC (0x22222222)
|
||||
|
||||
|
||||
#define DES_ENC (0x33333333)
|
||||
#define DES_DEC (0x44444444)
|
||||
|
||||
#define DES_KEY (0x55555555)
|
||||
#define TDES_2KEY (0x66666666)
|
||||
#define TDES_3KEY (0x77777777)
|
||||
|
||||
enum DES
|
||||
{
|
||||
DES_Crypto_OK = 0x0, //DES/TDES opreation success
|
||||
DES_Init_OK = 0x0, //DES/TDES Init opreation success
|
||||
DES_Crypto_ModeError = 0x5a5a5a5a, //Working mode error(Neither ECB nor CBC)
|
||||
DES_Crypto_EnOrDeError, //En&De error(Neither encryption nor decryption)
|
||||
DES_Crypto_ParaNull, // the part of input(output/iv) Null
|
||||
DES_Crypto_LengthError, //the length of input message must be 2 times and cannot be zero
|
||||
DES_Crypto_KeyError, //keyMode error(Neither DES_KEY nor TDES_2KEY nor TDES_3KEY)
|
||||
DES_Crypto_UnInitError, //DES/TDES uninitialized
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t *in; // the part of input to be encrypted or decrypted
|
||||
uint32_t *iv; // the part of initial vector
|
||||
uint32_t *out; // the part of out
|
||||
uint32_t *key; // the part of key
|
||||
uint32_t inWordLen; // the length(by word) of plaintext or cipher
|
||||
uint32_t En_De; // 0x33333333- encrypt, 0x44444444 - decrypt
|
||||
uint32_t Mode; // 0x11111111 - ECB, 0x22222222 - CBC
|
||||
uint32_t keyMode; //TDES key mode: 0x55555555-key,0x66666666-2key, 0x77777777-3key
|
||||
}DES_PARM;
|
||||
|
||||
/**
|
||||
* @brief DES_Init
|
||||
* @return DES_Init_OK, DES/TDES Init success; othets: DES/TDES Init fail
|
||||
* @note
|
||||
*/
|
||||
uint32_t DES_Init(DES_PARM *parm);
|
||||
|
||||
/**
|
||||
* @brief DES crypto
|
||||
* @param[in] parm pointer to DES/TDES context and the detail please refer to struct DES_PARM in DES.h
|
||||
* @return DES_Crypto_OK, DES/TDES crypto success; othets: DES/TDES crypto fail(reference to the definition by enum variation)
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.Input and output can be the same buffer
|
||||
* 3. IV can be NULL when ECB mode
|
||||
* 4. The word lengrh of message must be as times as 2.
|
||||
* 5. If the input is in byte, make sure align by word.
|
||||
*/
|
||||
uint32_t DES_Crypto(DES_PARM *parm);
|
||||
|
||||
/**
|
||||
* @brief DES close
|
||||
* @return none
|
||||
* @note if you want to close DES algorithm, this function can be recalled.
|
||||
*/
|
||||
void DES_Close(void);
|
||||
|
||||
/**
|
||||
* @brief Get DES/TDES lib version
|
||||
* @param[out] type pointer one byte type information represents the type of the lib, like Commercial version.\
|
||||
* @Bits 0~4 stands for Commercial (C), Security (S), Normal (N), Evaluation (E), Test (T), Bits 5~7 are reserved. e.g. 0x09 stands for CE version.
|
||||
* @param[out] customer pointer one byte customer information represents customer ID. for example, 0x00 stands for standard version, 0x01 is for Tianyu customized version...
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] version pointer one byte version information represents develop version of the lib. e.g. 0x12 denotes version 1.2.
|
||||
* @return none
|
||||
* @1.You can recall this function to get DES/TDES lib information
|
||||
*/
|
||||
void DES_Version(uint8_t *type, uint8_t *customer, uint8_t date[3], uint8_t *version);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
/*****************************************************************************
|
||||
* NationS Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2020, NationS Corporation
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* NationS's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONZ "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONZ 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.
|
||||
* ****************************************************************************/
|
||||
/*****************************************************************************
|
||||
* File Name: n32g43x_rng.h
|
||||
* Function: Declaring RNG algorithm library API
|
||||
* version: V1.2.0
|
||||
* Author: zhang.zhenshan
|
||||
* date: 2020-4-8
|
||||
* ****************************************************************************/
|
||||
|
||||
#ifndef _N32G43X_RNG_H_
|
||||
#define _N32G43X_RNG_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum{
|
||||
RNG_OK = 0x5a5a5a5a,
|
||||
LENError = 0x311ECF50, //RNG generation of key length error
|
||||
ADDRNULL = 0x7A9DB86C, // This address is empty
|
||||
};
|
||||
|
||||
|
||||
//u32 RNG_init(void);
|
||||
/**
|
||||
* @brief Get pseudo random number
|
||||
* @param[out] rand pointer to random number
|
||||
* @param[in] the wordlen of random number
|
||||
* @param[in] the seed, can be NULL
|
||||
* @return RNG_OK:get random number success; othets: get random number fail
|
||||
* @note
|
||||
*/
|
||||
uint32_t GetPseudoRand_U32(uint32_t *rand, uint32_t wordLen,uint32_t seed[2]);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get true random number
|
||||
* @param[out] rand pointer to random number
|
||||
* @param[in] the wordlen of random number
|
||||
* @return RNG_OK:get random number success; othets: get random number fail
|
||||
* @note
|
||||
*/
|
||||
uint32_t GetTrueRand_U32(uint32_t *rand, uint32_t wordLen);
|
||||
|
||||
/**
|
||||
* @brief Get RNG lib version
|
||||
* @param[out] type pointer one byte type information represents the type of the lib, like Commercial version.\
|
||||
* @Bits 0~4 stands for Commercial (C), Security (S), Normal (N), Evaluation (E), Test (T), Bits 5~7 are reserved. e.g. 0x09 stands for CE version.
|
||||
* @param[out] customer pointer one byte customer information represents customer ID. for example, 0x00 stands for standard version, 0x01 is for Tianyu customized version...
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] version pointer one byte version information represents develop version of the lib. e.g. 0x12 denotes version 1.2.
|
||||
* @return none
|
||||
* @1.You can recall this function to get RSA lib information
|
||||
*/
|
||||
void RNG_Version(uint8_t *type, uint8_t *customer, uint8_t date[3], uint8_t *version);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+545
File diff suppressed because it is too large
Load Diff
+670
File diff suppressed because it is too large
Load Diff
+282
File diff suppressed because it is too large
Load Diff
+105
@@ -0,0 +1,105 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file n32g43x_crc.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __N32G43X_CRC_H__
|
||||
#define __N32G43X_CRC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "n32g43x.h"
|
||||
|
||||
/** @addtogroup N32G43x_StdPeriph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup CRC_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
void CRC32_ResetCrc(void);
|
||||
uint32_t CRC32_CalcCrc(uint32_t Data);
|
||||
uint32_t CRC32_CalcBufCrc(uint32_t pBuffer[], uint32_t BufferLength);
|
||||
uint32_t CRC32_GetCrc(void);
|
||||
void CRC32_SetIDat(uint8_t IDValue);
|
||||
uint8_t CRC32_GetIDat(void);
|
||||
|
||||
uint16_t CRC16_CalcBufCrc(uint8_t pBuffer[], uint32_t BufferLength);
|
||||
uint16_t CRC16_CalcCRC(uint8_t Data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __N32G43X_CRC_H__ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
+293
File diff suppressed because it is too large
Load Diff
+124
@@ -0,0 +1,124 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file n32g43x_dbg.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __N32G43x_DBG_H__
|
||||
#define __N32G43x_DBG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "n32g43x.h"
|
||||
|
||||
/** @addtogroup N32G43x_StdPeriph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup DBG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup DBGMCU_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup DBGMCU_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define DBG_SLEEP ((uint32_t)0x00000001)
|
||||
#define DBG_STOP ((uint32_t)0x00000002)
|
||||
#define DBG_STDBY ((uint32_t)0x00000004)
|
||||
#define DBG_IWDG_STOP ((uint32_t)0x00000100)
|
||||
#define DBG_WWDG_STOP ((uint32_t)0x00000200)
|
||||
#define DBG_TIM1_STOP ((uint32_t)0x00000400)
|
||||
#define DBG_TIM2_STOP ((uint32_t)0x00000800)
|
||||
#define DBG_TIM3_STOP ((uint32_t)0x00001000)
|
||||
#define DBG_TIM4_STOP ((uint32_t)0x00002000)
|
||||
#define DBG_CAN_STOP ((uint32_t)0x00004000)
|
||||
#define DBG_I2C1SMBUS_TIMEOUT ((uint32_t)0x00008000)
|
||||
#define DBG_I2C2SMBUS_TIMEOUT ((uint32_t)0x00010000)
|
||||
#define DBG_TIM8_STOP ((uint32_t)0x00020000)
|
||||
#define DBG_TIM5_STOP ((uint32_t)0x00040000)
|
||||
#define DBG_TIM6_STOP ((uint32_t)0x00080000)
|
||||
#define DBG_TIM7_STOP ((uint32_t)0x00100000)
|
||||
#define DBG_TIM9_STOP ((uint32_t)0x00200000)
|
||||
|
||||
#define IS_DBGMCU_PERIPH(PERIPH) ((((PERIPH)&0xFFC000F8) == 0x00) && ((PERIPH) != 0x00))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup DBGMCU_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup DBGMCU_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
void GetUCID(uint8_t *UCIDbuf);
|
||||
void GetUID(uint8_t *UIDbuf);
|
||||
void GetDBGMCU_ID(uint8_t *DBGMCU_IDbuf);
|
||||
uint32_t DBG_GetRevNum(void);
|
||||
uint32_t DBG_GetDevNum(void);
|
||||
void DBG_ConfigPeriph(uint32_t DBG_Periph, FunctionalState Cmd);
|
||||
|
||||
uint32_t DBG_GetFlashSize(void);
|
||||
uint32_t DBG_GetSramSize(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __N32G43x_DBG_H__ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
+469
File diff suppressed because it is too large
Load Diff
+232
File diff suppressed because it is too large
Load Diff
+513
File diff suppressed because it is too large
Load Diff
+660
File diff suppressed because it is too large
Load Diff
+672
File diff suppressed because it is too large
Load Diff
+145
@@ -0,0 +1,145 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file n32g43x_iwdg.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __N32G43X_IWDG_H__
|
||||
#define __N32G43X_IWDG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "n32g43x.h"
|
||||
|
||||
/** @addtogroup N32G43x_StdPeriph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_WriteAccess
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define IWDG_WRITE_ENABLE ((uint16_t)0x5555)
|
||||
#define IWDG_WRITE_DISABLE ((uint16_t)0x0000)
|
||||
#define IS_IWDG_WRITE(ACCESS) (((ACCESS) == IWDG_WRITE_ENABLE) || ((ACCESS) == IWDG_WRITE_DISABLE))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_prescaler
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define IWDG_PRESCALER_DIV4 ((uint8_t)0x00)
|
||||
#define IWDG_PRESCALER_DIV8 ((uint8_t)0x01)
|
||||
#define IWDG_PRESCALER_DIV16 ((uint8_t)0x02)
|
||||
#define IWDG_PRESCALER_DIV32 ((uint8_t)0x03)
|
||||
#define IWDG_PRESCALER_DIV64 ((uint8_t)0x04)
|
||||
#define IWDG_PRESCALER_DIV128 ((uint8_t)0x05)
|
||||
#define IWDG_PRESCALER_DIV256 ((uint8_t)0x06)
|
||||
#define IS_IWDG_PRESCALER_DIV(PRESCALER) \
|
||||
(((PRESCALER) == IWDG_PRESCALER_DIV4) || ((PRESCALER) == IWDG_PRESCALER_DIV8) \
|
||||
|| ((PRESCALER) == IWDG_PRESCALER_DIV16) || ((PRESCALER) == IWDG_PRESCALER_DIV32) \
|
||||
|| ((PRESCALER) == IWDG_PRESCALER_DIV64) || ((PRESCALER) == IWDG_PRESCALER_DIV128) \
|
||||
|| ((PRESCALER) == IWDG_PRESCALER_DIV256))
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Flag
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define IWDG_PVU_FLAG ((uint16_t)0x0001)
|
||||
#define IWDG_CRVU_FLAG ((uint16_t)0x0002)
|
||||
#define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_PVU_FLAG) || ((FLAG) == IWDG_CRVU_FLAG))
|
||||
#define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
void IWDG_WriteConfig(uint16_t IWDG_WriteAccess);
|
||||
void IWDG_SetPrescalerDiv(uint8_t IWDG_Prescaler);
|
||||
void IWDG_CntReload(uint16_t Reload);
|
||||
void IWDG_ReloadKey(void);
|
||||
void IWDG_Enable(void);
|
||||
FlagStatus IWDG_GetStatus(uint16_t IWDG_FLAG);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __N32G43X_IWDG_H__ */
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
+427
File diff suppressed because it is too large
Load Diff
+280
File diff suppressed because it is too large
Load Diff
+209
File diff suppressed because it is too large
Load Diff
+222
File diff suppressed because it is too large
Load Diff
+911
File diff suppressed because it is too large
Load Diff
+789
File diff suppressed because it is too large
Load Diff
+470
File diff suppressed because it is too large
Load Diff
+1101
File diff suppressed because it is too large
Load Diff
+485
File diff suppressed because it is too large
Load Diff
+397
File diff suppressed because it is too large
Load Diff
+122
@@ -0,0 +1,122 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file n32g43x_wwdg.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __N32G43X_WWDG_H__
|
||||
#define __N32G43X_WWDG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "n32g43x.h"
|
||||
|
||||
/** @addtogroup N32G43x_StdPeriph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG_Prescaler
|
||||
* @{
|
||||
*/
|
||||
|
||||
#define WWDG_PRESCALER_DIV1 ((uint32_t)0x00000000)
|
||||
#define WWDG_PRESCALER_DIV2 ((uint32_t)0x00000080)
|
||||
#define WWDG_PRESCALER_DIV4 ((uint32_t)0x00000100)
|
||||
#define WWDG_PRESCALER_DIV8 ((uint32_t)0x00000180)
|
||||
#define IS_WWDG_PRESCALER_DIV(PRESCALER) \
|
||||
(((PRESCALER) == WWDG_PRESCALER_DIV1) || ((PRESCALER) == WWDG_PRESCALER_DIV2) \
|
||||
|| ((PRESCALER) == WWDG_PRESCALER_DIV4) || ((PRESCALER) == WWDG_PRESCALER_DIV8))
|
||||
#define IS_WWDG_WVALUE(VALUE) ((VALUE) <= 0x7F)
|
||||
#define IS_WWDG_CNT(COUNTER) (((COUNTER) >= 0x40) && ((COUNTER) <= 0x7F))
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG_Exported_Macros
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup WWDG_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
void WWDG_DeInit(void);
|
||||
void WWDG_SetPrescalerDiv(uint32_t WWDG_Prescaler);
|
||||
void WWDG_SetWValue(uint8_t WindowValue);
|
||||
void WWDG_EnableInt(void);
|
||||
void WWDG_SetCnt(uint8_t Counter);
|
||||
void WWDG_Enable(uint8_t Counter);
|
||||
FlagStatus WWDG_GetEWINTF(void);
|
||||
void WWDG_ClrEWINTF(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __N32G43X__WWDG_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
+1411
File diff suppressed because it is too large
Load Diff
+1372
File diff suppressed because it is too large
Load Diff
+385
File diff suppressed because it is too large
Load Diff
+227
File diff suppressed because it is too large
Load Diff
+357
File diff suppressed because it is too large
Load Diff
+246
File diff suppressed because it is too large
Load Diff
+686
File diff suppressed because it is too large
Load Diff
+286
File diff suppressed because it is too large
Load Diff
+1565
File diff suppressed because it is too large
Load Diff
+768
File diff suppressed because it is too large
Load Diff
+1301
File diff suppressed because it is too large
Load Diff
+193
@@ -0,0 +1,193 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file n32g43x_iwdg.c
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#include "n32g43x_iwdg.h"
|
||||
|
||||
/** @addtogroup N32G43x_StdPeriph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG
|
||||
* @brief IWDG driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* ---------------------- IWDG registers bit mask ----------------------------*/
|
||||
|
||||
/* KEY register bit mask */
|
||||
#define KEY_ReloadKey ((uint16_t)0xAAAA)
|
||||
#define KEY_EnableKey ((uint16_t)0xCCCC)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup IWDG_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers.
|
||||
* @param IWDG_WriteAccess new state of write access to IWDG_PR and IWDG_RLR registers.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IWDG_WRITE_ENABLE Enable write access to IWDG_PR and IWDG_RLR registers
|
||||
* @arg IWDG_WRITE_DISABLE Disable write access to IWDG_PR and IWDG_RLR registers
|
||||
*/
|
||||
void IWDG_WriteConfig(uint16_t IWDG_WriteAccess)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_IWDG_WRITE(IWDG_WriteAccess));
|
||||
IWDG->KEY = IWDG_WriteAccess;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets IWDG Prescaler value.
|
||||
* @param IWDG_Prescaler specifies the IWDG Prescaler value.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IWDG_PRESCALER_DIV4 IWDG prescaler set to 4
|
||||
* @arg IWDG_PRESCALER_DIV8 IWDG prescaler set to 8
|
||||
* @arg IWDG_PRESCALER_DIV16 IWDG prescaler set to 16
|
||||
* @arg IWDG_PRESCALER_DIV32 IWDG prescaler set to 32
|
||||
* @arg IWDG_PRESCALER_DIV64 IWDG prescaler set to 64
|
||||
* @arg IWDG_PRESCALER_DIV128 IWDG prescaler set to 128
|
||||
* @arg IWDG_PRESCALER_DIV256 IWDG prescaler set to 256
|
||||
*/
|
||||
void IWDG_SetPrescalerDiv(uint8_t IWDG_Prescaler)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_IWDG_PRESCALER_DIV(IWDG_Prescaler));
|
||||
IWDG->PREDIV = IWDG_Prescaler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets IWDG Reload value.
|
||||
* @param Reload specifies the IWDG Reload value.
|
||||
* This parameter must be a number between 0 and 0x0FFF.
|
||||
*/
|
||||
void IWDG_CntReload(uint16_t Reload)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_IWDG_RELOAD(Reload));
|
||||
IWDG->RELV = Reload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reloads IWDG counter with value defined in the reload register
|
||||
* (write access to IWDG_PR and IWDG_RLR registers disabled).
|
||||
*/
|
||||
void IWDG_ReloadKey(void)
|
||||
{
|
||||
IWDG->KEY = KEY_ReloadKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled).
|
||||
*/
|
||||
void IWDG_Enable(void)
|
||||
{
|
||||
IWDG->KEY = KEY_EnableKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether the specified IWDG flag is set or not.
|
||||
* @param IWDG_FLAG specifies the flag to check.
|
||||
* This parameter can be one of the following values:
|
||||
* @arg IWDG_PVU_FLAG Prescaler Value Update on going
|
||||
* @arg IWDG_CRVU_FLAG Reload Value Update on going
|
||||
* @return The new state of IWDG_FLAG (SET or RESET).
|
||||
*/
|
||||
FlagStatus IWDG_GetStatus(uint16_t IWDG_FLAG)
|
||||
{
|
||||
FlagStatus bitstatus = RESET;
|
||||
/* Check the parameters */
|
||||
assert_param(IS_IWDG_FLAG(IWDG_FLAG));
|
||||
if ((IWDG->STS & IWDG_FLAG) != (uint32_t)RESET)
|
||||
{
|
||||
bitstatus = SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
bitstatus = RESET;
|
||||
}
|
||||
/* Return the flag status */
|
||||
return bitstatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
+1258
File diff suppressed because it is too large
Load Diff
+532
File diff suppressed because it is too large
Load Diff
+198
@@ -0,0 +1,198 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file n32g43x_opamp.c
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#include "n32g43x_opamp.h"
|
||||
#include "n32g43x_rcc.h"
|
||||
|
||||
/** @addtogroup N32G43x_StdPeriph_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup OPAMP
|
||||
* @brief OPAMP driver modules
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup OPAMP_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup OPAMP_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup OPAMP_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup OPAMP_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup OPAMP_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup OPAMP_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
#define SetBitMsk(reg, bit, msk) ((reg) = (((reg) & ~(msk)) | (bit)))
|
||||
#define ClrBit(reg, bit) ((reg) &= ~(bit))
|
||||
#define SetBit(reg, bit) ((reg) |= (bit))
|
||||
#define GetBit(reg, bit) ((reg) & (bit))
|
||||
/**
|
||||
* @brief Deinitializes the OPAMP peripheral registers to their default reset values.
|
||||
*/
|
||||
void OPAMP_DeInit(void)
|
||||
{
|
||||
RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_OPAMP, ENABLE);
|
||||
RCC_EnableAPB1PeriphReset(RCC_APB1_PERIPH_OPAMP, DISABLE);
|
||||
}
|
||||
void OPAMP_StructInit(OPAMP_InitType* OPAMP_InitStruct)
|
||||
{
|
||||
OPAMP_InitStruct->Opa2SrcSel = OPAMP2_CS_TIMSRCSEL_TIM1CC6;
|
||||
OPAMP_InitStruct->Gain = OPAMP_CS_PGA_GAIN_2;
|
||||
OPAMP_InitStruct->HighVolRangeEn = ENABLE;
|
||||
OPAMP_InitStruct->TimeAutoMuxEn = DISABLE;
|
||||
OPAMP_InitStruct->Mod = OPAMP_CS_PGA_EN;
|
||||
}
|
||||
void OPAMP_Init(OPAMPX OPAMPx, OPAMP_InitType* OPAMP_InitStruct)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
__IO uint32_t tmp = *pCs;
|
||||
if (OPAMPx == OPAMP2)
|
||||
SetBitMsk(tmp, OPAMP_InitStruct->Opa2SrcSel, OPAMP_CS_OPAMP2_TIMSRCSEL);
|
||||
SetBitMsk(tmp, OPAMP_InitStruct->Gain, OPAMP_CS_PGA_GAIN_MASK);
|
||||
if (OPAMP_InitStruct->HighVolRangeEn==ENABLE)
|
||||
SetBitMsk(tmp, OPAMP_CS_RANGE_MASK, OPAMP_CS_RANGE_MASK);
|
||||
else
|
||||
ClrBit(tmp,OPAMP_CS_RANGE_MASK);
|
||||
if (OPAMP_InitStruct->TimeAutoMuxEn==ENABLE)
|
||||
SetBitMsk(tmp,OPAMP_CS_TCMEN_MASK, OPAMP_CS_TCMEN_MASK);
|
||||
else
|
||||
ClrBit(tmp,OPAMP_CS_TCMEN_MASK);
|
||||
SetBitMsk(tmp, OPAMP_InitStruct->Mod, OPAMP_CS_MOD_MASK);
|
||||
*pCs = tmp;
|
||||
}
|
||||
void OPAMP_Enable(OPAMPX OPAMPx, FunctionalState en)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
if (en)
|
||||
SetBit(*pCs, OPAMP_CS_EN_MASK);
|
||||
else
|
||||
ClrBit(*pCs, OPAMP_CS_EN_MASK);
|
||||
}
|
||||
|
||||
void OPAMP_SetPgaGain(OPAMPX OPAMPx, OPAMP_CS_PGA_GAIN Gain)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
__IO uint32_t tmp = *pCs;
|
||||
SetBitMsk(tmp, Gain, OPAMP_CS_PGA_GAIN_MASK);
|
||||
*pCs = tmp;
|
||||
}
|
||||
void OPAMP_SetVpSecondSel(OPAMPX OPAMPx, OPAMP_CS_VPSSEL VpSSel)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
__IO uint32_t tmp = *pCs;
|
||||
SetBitMsk(tmp, VpSSel, OPAMP_CS_VPSEL_SECOND_MASK);
|
||||
*pCs = tmp;
|
||||
}
|
||||
void OPAMP_SetVmSecondSel(OPAMPX OPAMPx, OPAMP_CS_VMSSEL VmSSel)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
__IO uint32_t tmp = *pCs;
|
||||
SetBitMsk(tmp, VmSSel, OPAMP_CS_VMSEL_SECOND_MASK);
|
||||
*pCs = tmp;
|
||||
}
|
||||
void OPAMP_SetVpSel(OPAMPX OPAMPx, OPAMP_CS_VPSEL VpSel)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
__IO uint32_t tmp = *pCs;
|
||||
SetBitMsk(tmp, VpSel, OPAMP_CS_VPSEL_MASK);
|
||||
*pCs = tmp;
|
||||
}
|
||||
void OPAMP_SetVmSel(OPAMPX OPAMPx, OPAMP_CS_VMSEL VmSel)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
__IO uint32_t tmp = *pCs;
|
||||
SetBitMsk(tmp, VmSel, OPAMP_CS_VMSEL_MASK);
|
||||
*pCs = tmp;
|
||||
}
|
||||
bool OPAMP_IsCalOutHigh(OPAMPX OPAMPx)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
return (GetBit(*pCs, OPAMP_CS_CALOUT_MASK)) ? true : false;
|
||||
}
|
||||
void OPAMP_CalibrationEnable(OPAMPX OPAMPx, FunctionalState en)
|
||||
{
|
||||
__IO uint32_t* pCs = &OPAMP->CS1 + OPAMPx;
|
||||
if (en)
|
||||
SetBit(*pCs, OPAMP_CS_CALON_MASK);
|
||||
else
|
||||
ClrBit(*pCs, OPAMP_CS_CALON_MASK);
|
||||
}
|
||||
// Lock see @OPAMP_LOCK
|
||||
void OPAMP_SetLock(uint32_t Lock)
|
||||
{
|
||||
OPAMP->LOCK = Lock;
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
+576
File diff suppressed because it is too large
Load Diff
+1940
File diff suppressed because it is too large
Load Diff
+2327
File diff suppressed because it is too large
Load Diff
+853
File diff suppressed because it is too large
Load Diff
+3290
File diff suppressed because it is too large
Load Diff
+279
File diff suppressed because it is too large
Load Diff
+956
File diff suppressed because it is too large
Load Diff
+223
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,98 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_def.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __USB_DEF_H__
|
||||
#define __USB_DEF_H__
|
||||
|
||||
/**
|
||||
* @addtogroup N32G43X_USB_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
typedef enum _RECIPIENT_TYPE
|
||||
{
|
||||
DEVICE_RECIPIENT, /* Recipient device */
|
||||
INTERFACE_RECIPIENT, /* Recipient interface */
|
||||
ENDPOINT_RECIPIENT, /* Recipient endpoint */
|
||||
OTHER_RECIPIENT
|
||||
} RECIPIENT_TYPE;
|
||||
|
||||
typedef enum _STANDARD_REQUESTS
|
||||
{
|
||||
GET_STATUS = 0,
|
||||
CLR_FEATURE,
|
||||
RESERVED1,
|
||||
SET_FEATURE,
|
||||
RESERVED2,
|
||||
SET_ADDRESS,
|
||||
GET_DESCRIPTOR,
|
||||
SET_DESCRIPTOR,
|
||||
GET_CONFIGURATION,
|
||||
SET_CONFIGURATION,
|
||||
GET_INTERFACE,
|
||||
SET_INTERFACE,
|
||||
TOTAL_SREQUEST, /* Total number of Standard request */
|
||||
SYNCH_FRAME = 12
|
||||
} STANDARD_REQUESTS;
|
||||
|
||||
/* Definition of "USBwValue" */
|
||||
typedef enum _DESCRIPTOR_TYPE
|
||||
{
|
||||
DEVICE_DESCRIPTOR = 1,
|
||||
CONFIG_DESCRIPTOR,
|
||||
STRING_DESCRIPTOR,
|
||||
INTERFACE_DESCRIPTOR,
|
||||
ENDPOINT_DESCRIPTOR
|
||||
} DESCRIPTOR_TYPE;
|
||||
|
||||
/* Feature selector of a SET_FEATURE or CLR_FEATURE */
|
||||
typedef enum _FEATURE_SELECTOR
|
||||
{
|
||||
ENDPOINT_STALL,
|
||||
DEVICE_REMOTE_WAKEUP
|
||||
} FEATURE_SELECTOR;
|
||||
|
||||
/* Definition of "bmRequestType" */
|
||||
#define REQUEST_TYPE 0x60 /* Mask to get request type */
|
||||
#define STANDARD_REQUEST 0x00 /* Standard request */
|
||||
#define CLASS_REQUEST 0x20 /* Class request */
|
||||
#define VENDOR_REQUEST 0x40 /* Vendor request */
|
||||
|
||||
#define RECIPIENT 0x1F /* Mask to get recipient */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USB_DEF_H__ */
|
||||
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_init.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __USB_INIT_H__
|
||||
#define __USB_INIT_H__
|
||||
|
||||
#include "n32g43x.h"
|
||||
#include "usb_core.h"
|
||||
|
||||
/**
|
||||
* @addtogroup N32G43X_USB_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
void USB_Init(void);
|
||||
|
||||
/* The number of current endpoint, it will be used to specify an endpoint */
|
||||
extern uint8_t EPindex;
|
||||
/* The number of current device, it is an index to the Device_Table */
|
||||
/*extern uint8_t Device_no; */
|
||||
/* Points to the USB_DeviceMess structure of current device */
|
||||
/* The purpose of this register is to speed up the execution */
|
||||
extern USB_DeviceMess* pInformation;
|
||||
/* Points to the DEVICE_PROP structure of current device */
|
||||
/* The purpose of this register is to speed up the execution */
|
||||
extern DEVICE_PROP* pProperty;
|
||||
/* Temporary save the state of Rx & Tx status. */
|
||||
/* Whenever the Rx or Tx state is changed, its value is saved */
|
||||
/* in this variable first and will be set to the EPRB or EPRA */
|
||||
/* at the end of interrupt process */
|
||||
extern USER_STANDARD_REQUESTS* pUser_Standard_Requests;
|
||||
|
||||
extern uint16_t SaveState;
|
||||
extern uint16_t wInterrupt_Mask;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USB_INIT_H__ */
|
||||
@@ -0,0 +1,50 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_int.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __USB_INT_H__
|
||||
#define __USB_INT_H__
|
||||
|
||||
/**
|
||||
* @addtogroup N32G43X_USB_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
void USB_CorrectTransferLp(void);
|
||||
void USB_CorrectTransferHp(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USB_INT_H__ */
|
||||
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_lib.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __USB_LIB_H__
|
||||
#define __USB_LIB_H__
|
||||
|
||||
#include "usb_type.h"
|
||||
#include "usb_regs.h"
|
||||
#include "usb_def.h"
|
||||
#include "usb_core.h"
|
||||
#include "usb_init.h"
|
||||
#include "usb_sil.h"
|
||||
#include "usb_mem.h"
|
||||
#include "usb_int.h"
|
||||
|
||||
#endif /* __USB_LIB_H__ */
|
||||
@@ -0,0 +1,52 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_mem.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __USB_MEM_H__
|
||||
#define __USB_MEM_H__
|
||||
|
||||
#include "n32g43x.h"
|
||||
|
||||
/**
|
||||
* @addtogroup N32G43X_USB_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
void USB_CopyUserToPMABuf(uint8_t* pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
|
||||
void USB_CopyPMAToUserBuf(uint8_t* pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /*__USB_MEM_H__*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,53 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_sil.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __USB_SIL_H__
|
||||
#define __USB_SIL_H__
|
||||
|
||||
#include "n32g43x.h"
|
||||
|
||||
/**
|
||||
* @addtogroup N32G43X_USB_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
uint32_t USB_SilInit(void);
|
||||
uint32_t USB_SilWrite(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize);
|
||||
uint32_t USB_SilRead(uint8_t bEpAddr, uint8_t* pBufferPointer);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USB_SIL_H__ */
|
||||
@@ -0,0 +1,54 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_type.h
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#ifndef __USB_TYPE_H__
|
||||
#define __USB_TYPE_H__
|
||||
|
||||
#include "usb_conf.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @addtogroup N32G43X_USB_Driver
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* __USB_TYPE_H__ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_init.c
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#include "usb_lib.h"
|
||||
|
||||
/* The number of current endpoint, it will be used to specify an endpoint */
|
||||
uint8_t EPindex;
|
||||
/* The number of current device, it is an index to the Device_Table */
|
||||
/* uint8_t Device_no; */
|
||||
/* Points to the USB_DeviceMess structure of current device */
|
||||
/* The purpose of this register is to speed up the execution */
|
||||
USB_DeviceMess* pInformation;
|
||||
/* Points to the DEVICE_PROP structure of current device */
|
||||
/* The purpose of this register is to speed up the execution */
|
||||
DEVICE_PROP* pProperty;
|
||||
/* Temporary save the state of Rx & Tx status. */
|
||||
/* Whenever the Rx or Tx state is changed, its value is saved */
|
||||
/* in this variable first and will be set to the EPRB or EPRA */
|
||||
/* at the end of interrupt process */
|
||||
uint16_t SaveState;
|
||||
uint16_t wInterrupt_Mask;
|
||||
USB_DeviceMess Device_Info;
|
||||
USER_STANDARD_REQUESTS* pUser_Standard_Requests;
|
||||
|
||||
/**
|
||||
* @brief USB system initialization
|
||||
*/
|
||||
void USB_Init(void)
|
||||
{
|
||||
pInformation = &Device_Info;
|
||||
pInformation->CtrlState = 2;
|
||||
pProperty = &Device_Property;
|
||||
pUser_Standard_Requests = &User_Standard_Requests;
|
||||
/* Initialize devices one by one */
|
||||
pProperty->Init();
|
||||
/*Pull up DP*/
|
||||
// _ClrDPCtrl();
|
||||
_EnPortPullup();
|
||||
// printf("DP_CTRL=%x\r\n", (*DP_CTRL));
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_int.c
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#include "usb_lib.h"
|
||||
|
||||
__IO uint16_t SaveRState;
|
||||
__IO uint16_t SaveTState;
|
||||
|
||||
extern void (*pEpInt_IN[7])(void); /* Handles IN interrupts */
|
||||
extern void (*pEpInt_OUT[7])(void); /* Handles OUT interrupts */
|
||||
|
||||
/**
|
||||
* @brief Low priority Endpoint Correct Transfer interrupt's service routine.
|
||||
*/
|
||||
void USB_CorrectTransferLp(void)
|
||||
{
|
||||
__IO uint16_t wEPVal = 0;
|
||||
/* stay in loop while pending interrupts */
|
||||
while (((wIstr = _GetISTR()) & STS_CTRS) != 0)
|
||||
{
|
||||
/* extract highest priority endpoint number */
|
||||
EPindex = (uint8_t)(wIstr & STS_EP_ID);
|
||||
if (EPindex == 0)
|
||||
{
|
||||
/* Decode and service control endpoint interrupt */
|
||||
/* calling related service routine */
|
||||
/* (USB_ProcessSetup0, USB_ProcessIn0, USB_ProcessOut0) */
|
||||
|
||||
/* save RX & TX status */
|
||||
/* and set both to NAK */
|
||||
|
||||
SaveRState = _GetENDPOINT(ENDP0);
|
||||
SaveTState = SaveRState & EPTX_STS;
|
||||
SaveRState &= EPRX_STS;
|
||||
_SetEPRxTxStatus(ENDP0, EP_RX_NAK, EP_TX_NAK);
|
||||
|
||||
/* DIR bit = origin of the interrupt */
|
||||
|
||||
if ((wIstr & STS_DIR) == 0)
|
||||
{
|
||||
/* DIR = 0 */
|
||||
|
||||
/* DIR = 0 => IN int */
|
||||
/* DIR = 0 implies that (EP_CTRS_TX = 1) always */
|
||||
|
||||
_ClearEP_CTR_TX(ENDP0);
|
||||
USB_ProcessIn0();
|
||||
|
||||
/* before terminate set Tx & Rx status */
|
||||
|
||||
_SetEPRxTxStatus(ENDP0, SaveRState, SaveTState);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* DIR = 1 */
|
||||
|
||||
/* DIR = 1 & CTR_RX => SETUP or OUT int */
|
||||
/* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */
|
||||
|
||||
wEPVal = _GetENDPOINT(ENDP0);
|
||||
|
||||
if ((wEPVal & EP_SETUP) != 0)
|
||||
{
|
||||
_ClearEP_CTR_RX(ENDP0); /* SETUP bit kept frozen while CTR_RX = 1 */
|
||||
USB_ProcessSetup0();
|
||||
/* before terminate set Tx & Rx status */
|
||||
|
||||
_SetEPRxTxStatus(ENDP0, SaveRState, SaveTState);
|
||||
return;
|
||||
}
|
||||
|
||||
else if ((wEPVal & EP_CTRS_RX) != 0)
|
||||
{
|
||||
_ClearEP_CTR_RX(ENDP0);
|
||||
USB_ProcessOut0();
|
||||
/* before terminate set Tx & Rx status */
|
||||
|
||||
_SetEPRxTxStatus(ENDP0, SaveRState, SaveTState);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} /* if (EPindex == 0) */
|
||||
else
|
||||
{
|
||||
/* Decode and service non control endpoints interrupt */
|
||||
|
||||
/* process related endpoint register */
|
||||
wEPVal = _GetENDPOINT(EPindex);
|
||||
if ((wEPVal & EP_CTRS_RX) != 0)
|
||||
{
|
||||
/* clear int flag */
|
||||
_ClearEP_CTR_RX(EPindex);
|
||||
|
||||
/* call OUT service function */
|
||||
(*pEpInt_OUT[EPindex - 1])();
|
||||
|
||||
} /* if ((wEPVal & EP_CTRS_RX) */
|
||||
|
||||
if ((wEPVal & EP_CTRS_TX) != 0)
|
||||
{
|
||||
/* clear int flag */
|
||||
_ClearEP_CTR_TX(EPindex);
|
||||
|
||||
/* call IN service function */
|
||||
(*pEpInt_IN[EPindex - 1])();
|
||||
} /* if ((wEPVal & EP_CTRS_TX) != 0) */
|
||||
|
||||
} /* if (EPindex == 0) else */
|
||||
|
||||
} /* while (...) */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief High Priority Endpoint Correct Transfer interrupt's service routine.
|
||||
*/
|
||||
void USB_CorrectTransferHp(void)
|
||||
{
|
||||
uint32_t wEPVal = 0;
|
||||
|
||||
while (((wIstr = _GetISTR()) & STS_CTRS) != 0)
|
||||
{
|
||||
_SetISTR((uint16_t)CLR_CTRS); /* clear CTR flag */
|
||||
/* extract highest priority endpoint number */
|
||||
EPindex = (uint8_t)(wIstr & STS_EP_ID);
|
||||
/* process related endpoint register */
|
||||
wEPVal = _GetENDPOINT(EPindex);
|
||||
if ((wEPVal & EP_CTRS_RX) != 0)
|
||||
{
|
||||
/* clear int flag */
|
||||
_ClearEP_CTR_RX(EPindex);
|
||||
|
||||
/* call OUT service function */
|
||||
(*pEpInt_OUT[EPindex - 1])();
|
||||
|
||||
} /* if ((wEPVal & EP_CTRS_RX) */
|
||||
else if ((wEPVal & EP_CTRS_TX) != 0)
|
||||
{
|
||||
/* clear int flag */
|
||||
_ClearEP_CTR_TX(EPindex);
|
||||
|
||||
/* call IN service function */
|
||||
(*pEpInt_IN[EPindex - 1])();
|
||||
|
||||
} /* if ((wEPVal & EP_CTRS_TX) != 0) */
|
||||
|
||||
} /* while (...) */
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_mem.c
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#include "usb_lib.h"
|
||||
u8* EpOutDataPtrTmp;
|
||||
u8* EpInDataPtrTmp;
|
||||
|
||||
/**
|
||||
* @brief Copy a buffer from user memory area to packet memory area (PMA)
|
||||
* @param pbUsrBuf pointer to user memory area.
|
||||
* @param wPMABufAddr address into PMA.
|
||||
* @param wNBytes no. of bytes to be copied.
|
||||
*/
|
||||
void USB_CopyUserToPMABuf(uint8_t* pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
|
||||
{
|
||||
uint32_t n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */
|
||||
uint32_t i, temp1, temp2;
|
||||
uint16_t* pdwVal;
|
||||
pdwVal = (uint16_t*)(wPMABufAddr * 2 + PMAAddr);
|
||||
for (i = n; i != 0; i--)
|
||||
{
|
||||
temp1 = (uint16_t)*pbUsrBuf;
|
||||
pbUsrBuf++;
|
||||
temp2 = temp1 | (uint16_t)*pbUsrBuf << 8;
|
||||
*pdwVal++ = temp2;
|
||||
pdwVal++;
|
||||
pbUsrBuf++;
|
||||
EpInDataPtrTmp = pbUsrBuf;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Copy a buffer from user memory area to packet memory area (PMA)
|
||||
* @param pbUsrBuf pointer to user memory area.
|
||||
* @param wPMABufAddr address into PMA.
|
||||
* @param wNBytes no. of bytes to be copied.
|
||||
*/
|
||||
void USB_CopyPMAToUserBuf(uint8_t* pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes)
|
||||
{
|
||||
uint32_t n = (wNBytes + 1) >> 1; /* /2*/
|
||||
uint32_t i;
|
||||
uint32_t* pdwVal;
|
||||
pdwVal = (uint32_t*)(wPMABufAddr * 2 + PMAAddr);
|
||||
for (i = n; i != 0; i--)
|
||||
{
|
||||
*(uint16_t*)pbUsrBuf++ = *pdwVal++;
|
||||
pbUsrBuf++;
|
||||
EpOutDataPtrTmp = pbUsrBuf;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2022, Nations Technologies Inc.
|
||||
*
|
||||
* 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 disclaimer below.
|
||||
*
|
||||
* Nations' name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL NATIONS 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.
|
||||
* ****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file usb_sil.c
|
||||
* @author Nations
|
||||
* @version v1.2.0
|
||||
*
|
||||
* @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved.
|
||||
*/
|
||||
#include "usb_lib.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the USB Device IP and the Endpoint 0.
|
||||
* @return Status.
|
||||
*/
|
||||
uint32_t USB_SilInit(void)
|
||||
{
|
||||
/* USB interrupts initialization */
|
||||
/* clear pending interrupts */
|
||||
_SetISTR(0);
|
||||
wInterrupt_Mask = IMR_MSK;
|
||||
/* set interrupts mask */
|
||||
_SetCNTR(wInterrupt_Mask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a buffer of data to a selected endpoint.
|
||||
* @param bEpAddr The address of the non control endpoint.
|
||||
* @param pBufferPointer The pointer to the buffer of data to be written to the endpoint.
|
||||
* @param wBufferSize Number of data to be written (in bytes).
|
||||
* @return Status.
|
||||
*/
|
||||
uint32_t USB_SilWrite(uint8_t bEpAddr, uint8_t* pBufferPointer, uint32_t wBufferSize)
|
||||
{
|
||||
/* Use the memory interface function to write to the selected endpoint */
|
||||
USB_CopyUserToPMABuf(pBufferPointer, USB_GetEpTxAddr(bEpAddr & 0x7F), wBufferSize);
|
||||
/* Update the data length in the control register */
|
||||
USB_SetEpTxCnt((bEpAddr & 0x7F), wBufferSize);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Write a buffer of data to a selected endpoint.
|
||||
* @param bEpAddr The address of the non control endpoint.
|
||||
* @param pBufferPointer The pointer to which will be saved the received data buffer.
|
||||
* @return Number of received data (in Bytes).
|
||||
*/
|
||||
uint32_t USB_SilRead(uint8_t bEpAddr, uint8_t* pBufferPointer)
|
||||
{
|
||||
uint32_t DataLength = 0;
|
||||
/* Get the number of received data on the selected Endpoint */
|
||||
DataLength = USB_GetEpRxCnt(bEpAddr & 0x7F);
|
||||
/* Use the memory interface function to write to the selected endpoint */
|
||||
USB_CopyPMAToUserBuf(pBufferPointer, USB_GetEpRxAddr(bEpAddr & 0x7F), DataLength);
|
||||
/* Return the number of received data */
|
||||
return DataLength;
|
||||
}
|
||||
@@ -77,7 +77,7 @@
|
||||
* ARM_MATH_CM0 or ARM_MATH_CM0PLUS depending on the target processor in the application.
|
||||
* For Armv8-M cores define preprocessor macro ARM_MATH_ARMV8MBL or ARM_MATH_ARMV8MML.
|
||||
* Set preprocessor macro __DSP_PRESENT if Armv8-M Mainline core supports DSP instructions.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Examples
|
||||
* --------
|
||||
|
||||
@@ -58,9 +58,9 @@
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static __inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE static __forceinline
|
||||
#endif
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __declspec(noreturn)
|
||||
#endif
|
||||
@@ -443,7 +443,7 @@ __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||
__schedule_barrier();\
|
||||
} while (0U)
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (32 bit)
|
||||
\details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
|
||||
|
||||
@@ -43,9 +43,9 @@
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static __inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __attribute__((always_inline)) static __inline
|
||||
#endif
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((__noreturn__))
|
||||
#endif
|
||||
@@ -570,7 +570,7 @@ __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
|
||||
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
|
||||
Stack Pointer Limit register hence zero is returned always in non-secure
|
||||
mode.
|
||||
|
||||
|
||||
\details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
|
||||
\return PSPLIM Register value
|
||||
*/
|
||||
@@ -616,7 +616,7 @@ __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
|
||||
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
|
||||
Stack Pointer Limit register hence the write is silently ignored in non-secure
|
||||
mode.
|
||||
|
||||
|
||||
\details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
|
||||
\param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
|
||||
*/
|
||||
|
||||
@@ -46,9 +46,9 @@
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
|
||||
#endif
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((__noreturn__))
|
||||
#endif
|
||||
@@ -585,7 +585,7 @@ __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
|
||||
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
|
||||
Stack Pointer Limit register hence zero is returned always in non-secure
|
||||
mode.
|
||||
|
||||
|
||||
\details Returns the current value of the Process Stack Pointer Limit (PSPLIM).
|
||||
\return PSPLIM Register value
|
||||
*/
|
||||
@@ -630,7 +630,7 @@ __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
|
||||
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
|
||||
Stack Pointer Limit register hence the write is silently ignored in non-secure
|
||||
mode.
|
||||
|
||||
|
||||
\details Assigns the given value to the Process Stack Pointer Limit (PSPLIM).
|
||||
\param [in] ProcStackPtrLimit Process Stack Pointer Limit value to set
|
||||
*/
|
||||
@@ -767,7 +767,7 @@ __STATIC_FORCEINLINE uint32_t __get_FPSCR(void)
|
||||
{
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
#if __has_builtin(__builtin_arm_get_fpscr)
|
||||
#if __has_builtin(__builtin_arm_get_fpscr)
|
||||
// Re-enable using built-in when GCC has been fixed
|
||||
// || (__GNUC__ > 7) || (__GNUC__ == 7 && __GNUC_MINOR__ >= 2)
|
||||
/* see https://gcc.gnu.org/ml/gcc-patches/2017-04/msg00443.html */
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ARM_MPU_ARMV7_H
|
||||
#define ARM_MPU_ARMV7_H
|
||||
|
||||
@@ -79,12 +79,12 @@
|
||||
|
||||
/**
|
||||
* MPU Memory Access Attributes
|
||||
*
|
||||
*
|
||||
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
||||
* \param IsShareable Region is shareable between multiple bus masters.
|
||||
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
|
||||
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
||||
*/
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable) \
|
||||
((((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
|
||||
(((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
|
||||
@@ -93,7 +93,7 @@
|
||||
|
||||
/**
|
||||
* MPU Region Attribute and Size Register Value
|
||||
*
|
||||
*
|
||||
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
||||
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
||||
* \param AccessAttributes Memory access attribution, see \ref ARM_MPU_ACCESS_.
|
||||
@@ -104,10 +104,10 @@
|
||||
((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
|
||||
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
|
||||
(((AccessAttributes) ) & (MPU_RASR_TEX_Msk | MPU_RASR_S_Msk | MPU_RASR_C_Msk | MPU_RASR_B_Msk)))
|
||||
|
||||
|
||||
/**
|
||||
* MPU Region Attribute and Size Register Value
|
||||
*
|
||||
*
|
||||
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
||||
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
||||
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
||||
@@ -116,7 +116,7 @@
|
||||
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
||||
* \param SubRegionDisable Sub-region disable field.
|
||||
* \param Size Region size of the region to be configured, for example 4K, 8K.
|
||||
*/
|
||||
*/
|
||||
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
|
||||
ARM_MPU_RASR_EX(DisableExec, AccessPermission, ARM_MPU_ACCESS_(TypeExtField, IsShareable, IsCacheable, IsBufferable), SubRegionDisable, Size)
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
* - Shareable
|
||||
* - Non-cacheable
|
||||
* - Non-bufferable
|
||||
*/
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_ORDERED ARM_MPU_ACCESS_(0U, 1U, 0U, 0U)
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@
|
||||
* - Bufferable (if shareable) or non-bufferable (if non-shareable)
|
||||
*
|
||||
* \param IsShareable Configures the device memory as shareable or non-shareable.
|
||||
*/
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_DEVICE(IsShareable) ((IsShareable) ? ARM_MPU_ACCESS_(0U, 1U, 0U, 1U) : ARM_MPU_ACCESS_(2U, 0U, 0U, 0U))
|
||||
|
||||
/**
|
||||
@@ -150,7 +150,7 @@
|
||||
* \param OuterCp Configures the outer cache policy.
|
||||
* \param InnerCp Configures the inner cache policy.
|
||||
* \param IsShareable Configures the memory as shareable or non-shareable.
|
||||
*/
|
||||
*/
|
||||
#define ARM_MPU_ACCESS_NORMAL(OuterCp, InnerCp, IsShareable) ARM_MPU_ACCESS_((4U | (OuterCp)), IsShareable, ((InnerCp) & 2U), ((InnerCp) & 1U))
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ typedef struct {
|
||||
uint32_t RBAR; //!< The region base address register value (RBAR)
|
||||
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
|
||||
} ARM_MPU_Region_t;
|
||||
|
||||
|
||||
/** Enable the MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
@@ -219,7 +219,7 @@ __STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
|
||||
/** Configure an MPU region.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rsar Value for RSAR register.
|
||||
*/
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RBAR = rbar;
|
||||
@@ -230,7 +230,7 @@ __STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rsar Value for RSAR register.
|
||||
*/
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RNR = rnr;
|
||||
@@ -246,7 +246,7 @@ __STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t r
|
||||
__STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0U; i < len; ++i)
|
||||
for (i = 0U; i < len; ++i)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
}
|
||||
@@ -256,7 +256,7 @@ __STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRI
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
||||
while (cnt > MPU_TYPE_RALIASES) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -57,7 +57,7 @@ defined in linker script */
|
||||
* @retval : None
|
||||
*/
|
||||
|
||||
.section .text.Reset_Handler
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
|
||||
@@ -171,10 +171,10 @@ void SystemInit(void)
|
||||
RCC->CFG &= (uint32_t)0xF700FFFF;
|
||||
|
||||
/* Reset CFG2 register */
|
||||
RCC->CFG2 = 0x00000000;
|
||||
RCC->CFG2 = 0x00003800;
|
||||
|
||||
/* Reset CFG3 register */
|
||||
RCC->CFG3 = 0x00000000;
|
||||
RCC->CFG3 = 0x00003840;
|
||||
|
||||
/* Disable all interrupts and clear pending bits */
|
||||
RCC->CLKINT = 0x009F0000;
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
* @brief AES symmetrical cipher algorithm
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#define AES_ECB (0x11111111)
|
||||
#define AES_CBC (0x22222222)
|
||||
#define AES_CTR (0x33333333)
|
||||
@@ -58,7 +58,7 @@ enum
|
||||
AES_Init_OK = 0x0, //AES Init opreation success
|
||||
AES_Crypto_ModeError = 0x5a5a5a5a, //Working mode error(Neither ECB nor CBC nor CTR)
|
||||
AES_Crypto_EnOrDeError, //En&De error(Neither encryption nor decryption)
|
||||
AES_Crypto_ParaNull, // the part of input(output/iv) Null
|
||||
AES_Crypto_ParaNull, // the part of input(output/iv) Null
|
||||
AES_Crypto_LengthError, // if Working mode is ECB or CBC,the length of input message must be 4 times and cannot be zero;
|
||||
//if Working mode is CTR,the length of input message cannot be zero; othets: return AES_Crypto_LengthError
|
||||
|
||||
@@ -81,7 +81,7 @@ typedef struct
|
||||
/**
|
||||
* @brief AES_Init
|
||||
* @return AES_Init_OK, AES Init success; othets: AES Init fail
|
||||
* @note
|
||||
* @note
|
||||
*/
|
||||
|
||||
uint32_t AES_Init(AES_PARM *parm);
|
||||
@@ -89,8 +89,8 @@ uint32_t AES_Init(AES_PARM *parm);
|
||||
/**
|
||||
* @brief AES crypto
|
||||
* @param[in] parm pointer to AES context and the detail please refer to struct AES_PARM in AES.h
|
||||
* @return AES_Crypto_OK, AES crypto success; othets: AES crypto fail(reference to the definition by enum variation)
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @return AES_Crypto_OK, AES crypto success; othets: AES crypto fail(reference to the definition by enum variation)
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.Input and output can be the same buffer
|
||||
* 3. IV can be NULL when ECB mode
|
||||
* 4. If Working mode is ECB or CBC,the length of input message must be 4 times and cannot be zero;
|
||||
@@ -111,7 +111,7 @@ void AES_Close(void);
|
||||
* @param[out] type pointer one byte type information represents the type of the lib, like Commercial version.\
|
||||
* @Bits 0~4 stands for Commercial (C), Security (S), Normal (N), Evaluation (E), Test (T), Bits 5~7 are reserved. e.g. 0x09 stands for CE version.
|
||||
* @param[out] customer pointer one byte customer information represents customer ID. for example, 0x00 stands for standard version, 0x01 is for Tianyu customized version...
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] version pointer one byte version information represents develop version of the lib. e.g. 0x12 denotes version 1.2.
|
||||
* @return none
|
||||
* @1.You can recall this function to get AES lib information
|
||||
|
||||
+15
-15
@@ -55,7 +55,7 @@ enum{
|
||||
* @param[in] rand pointer to random number
|
||||
* @param[in] the length of order
|
||||
* @return RandomSort_OK: disturb order success; Others: disturb order fail;
|
||||
* @note
|
||||
* @note
|
||||
*/
|
||||
uint32_t RandomSort(uint8_t *order, const uint8_t *rand, uint32_t len);
|
||||
|
||||
@@ -63,7 +63,7 @@ uint32_t RandomSort(uint8_t *order, const uint8_t *rand, uint32_t len);
|
||||
* @brief Copy data by byte
|
||||
* @param[in] dst pointer to destination data
|
||||
* @param[in] src pointer to source data
|
||||
* @param[in] byte length
|
||||
* @param[in] byte length
|
||||
* @return Cpy_OK: success; others: fail.
|
||||
* @note 1. dst and src cannot be same
|
||||
*/
|
||||
@@ -73,7 +73,7 @@ uint32_t Cpy_U8(uint8_t *dst, uint8_t *src, uint32_t byteLen);
|
||||
* @brief Copy data by word
|
||||
* @param[in] dst pointer to destination data
|
||||
* @param[in] src pointer to source data
|
||||
* @param[in] word length
|
||||
* @param[in] word length
|
||||
* @return Cpy_OK: success; others: fail.
|
||||
* @note 1. dst and src must be aligned by word
|
||||
*/
|
||||
@@ -85,7 +85,7 @@ uint32_t Cpy_U32(uint32_t *dst, const uint32_t *src, uint32_t wordLen);
|
||||
* @param[in] b pointer to another data to be XORed
|
||||
* @param[in] the length of order
|
||||
* @return XOR_OK: operation success; Others: operation fail;
|
||||
* @note
|
||||
* @note
|
||||
*/
|
||||
uint32_t XOR_U8(uint8_t *a, uint8_t *b, uint8_t *c, uint32_t byteLen);
|
||||
|
||||
@@ -95,33 +95,33 @@ uint32_t XOR_U8(uint8_t *a, uint8_t *b, uint8_t *c, uint32_t byteLen);
|
||||
* @param[in] b pointer to another data to be XORed
|
||||
* @param[in] the length of order
|
||||
* @return XOR_OK: operation success; Others: operation fail;
|
||||
* @note
|
||||
* @note
|
||||
*/
|
||||
uint32_t XOR_U32(uint32_t *a,uint32_t *b,uint32_t *c,uint32_t wordLen);
|
||||
|
||||
/**
|
||||
* @brief set zero by byte
|
||||
* @param[in] dst pointer to the address to be set zero
|
||||
* @param[in] byte length
|
||||
* @param[in] dst pointer to the address to be set zero
|
||||
* @param[in] byte length
|
||||
* @return SetZero_OK: success; others: fail.
|
||||
* @note
|
||||
* @note
|
||||
*/
|
||||
uint32_t SetZero_U8(uint8_t *dst, uint32_t byteLen);
|
||||
|
||||
/**
|
||||
* @brief set zero by word
|
||||
* @param[in] dst pointer to the address to be set zero
|
||||
* @param[in] word length
|
||||
* @param[in] dst pointer to the address to be set zero
|
||||
* @param[in] word length
|
||||
* @return SetZero_OK: success; others: fail.
|
||||
* @note
|
||||
* @note
|
||||
*/
|
||||
uint32_t SetZero_U32(uint32_t *dst, uint32_t wordLen);
|
||||
|
||||
/**
|
||||
* @brief reverse byte order of every word, the words stay the same
|
||||
* @param[in] dst pointer to the destination address
|
||||
* @param[in] src pointer to the source address
|
||||
* @param[in] word length
|
||||
* @param[in] src pointer to the source address
|
||||
* @param[in] word length
|
||||
* @return Reverse_OK: success; others: fail.
|
||||
* @note 1.dst and src can be same
|
||||
*/
|
||||
@@ -134,7 +134,7 @@ uint32_t ReverseBytesInWord_U32(uint32_t *dst, const uint32_t *src, uint32_t wor
|
||||
* @param[in] b pointer to another big number
|
||||
* @param[in] word length of b
|
||||
* @return Cmp_UNEQUAL:a!=b;Cmp_EQUAL: a==b.
|
||||
*
|
||||
*
|
||||
*/
|
||||
int32_t Cmp_U32(const uint32_t *a, uint32_t aWordLen, const uint32_t *b, uint32_t bWordLen);
|
||||
|
||||
@@ -145,7 +145,7 @@ int32_t Cmp_U32(const uint32_t *a, uint32_t aWordLen, const uint32_t *b, uint32_
|
||||
* @param[in] b pointer to another big number
|
||||
* @param[in] word length of b
|
||||
* @return Cmp_UNEQUAL:a!=b;Cmp_EQUAL: a==b.
|
||||
*
|
||||
*
|
||||
*/
|
||||
int32_t Cmp_U8(const uint8_t *a, uint32_t aByteLen, const uint8_t *b, uint32_t bByteLen);
|
||||
|
||||
|
||||
@@ -83,15 +83,15 @@ typedef struct
|
||||
/**
|
||||
* @brief DES_Init
|
||||
* @return DES_Init_OK, DES/TDES Init success; othets: DES/TDES Init fail
|
||||
* @note
|
||||
* @note
|
||||
*/
|
||||
uint32_t DES_Init(DES_PARM* parm);
|
||||
|
||||
/**
|
||||
* @brief DES crypto
|
||||
* @param[in] parm pointer to DES/TDES context and the detail please refer to struct DES_PARM in DES.h
|
||||
* @return DES_Crypto_OK, DES/TDES crypto success; othets: DES/TDES crypto fail(reference to the definition by enum variation)
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @return DES_Crypto_OK, DES/TDES crypto success; othets: DES/TDES crypto fail(reference to the definition by enum variation)
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.Input and output can be the same buffer
|
||||
* 3. IV can be NULL when ECB mode
|
||||
* 4. The word lengrh of message must be as times as 2.
|
||||
@@ -111,7 +111,7 @@ void DES_Close(void);
|
||||
* @param[out] type pointer one byte type information represents the type of the lib, like Commercial version.\
|
||||
* @Bits 0~4 stands for Commercial (C), Security (S), Normal (N), Evaluation (E), Test (T), Bits 5~7 are reserved. e.g. 0x09 stands for CE version.
|
||||
* @param[out] customer pointer one byte customer information represents customer ID. for example, 0x00 stands for standard version, 0x01 is for Tianyu customized version...
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] version pointer one byte version information represents develop version of the lib. e.g. 0x12 denotes version 1.2.
|
||||
* @return none
|
||||
* @1.You can recall this function to get DES/TDES lib information
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
enum
|
||||
{
|
||||
HASH_SEQUENCE_TRUE = 0x0105A5A5,//save IV
|
||||
HASH_SEQUENCE_FALSE = 0x010A5A5A, //not save IV
|
||||
HASH_SEQUENCE_FALSE = 0x010A5A5A, //not save IV
|
||||
HASH_Init_OK = 0,//hash init success
|
||||
HASH_Start_OK = 0,//hash update success
|
||||
HASH_Update_OK = 0,//hash update success
|
||||
@@ -67,7 +67,7 @@ enum
|
||||
SHA224_Hash_OK = 0,//sha224 operation success
|
||||
SHA256_Hash_OK = 0,//sha256 operation success
|
||||
MD5_Hash_OK = 0,//MD5 operation success
|
||||
|
||||
|
||||
HASH_Init_ERROR = 0x01044400,//hash init error
|
||||
HASH_Start_ERROR, //hash start error
|
||||
HASH_Update_ERROR, //hash update error
|
||||
@@ -93,7 +93,7 @@ typedef struct _HASH_CTX_
|
||||
{
|
||||
const HASH_ALG *hashAlg;//pointer to HASH_ALG
|
||||
uint32_t sequence; // TRUE if the IV should be saved
|
||||
uint32_t IV[16];
|
||||
uint32_t IV[16];
|
||||
uint32_t msgByteLen[4];
|
||||
uint8_t msgBuf[128+4];
|
||||
uint32_t msgIdx;
|
||||
@@ -109,7 +109,7 @@ extern const HASH_ALG HASH_ALG_SM3[1];
|
||||
* @brief Hash init
|
||||
* @param[in] ctx pointer to HASH_CTX struct
|
||||
* @return HASH_Init_OK, Hash init success; othets: Hash init fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
*/
|
||||
uint32_t HASH_Init(HASH_CTX *ctx);
|
||||
|
||||
@@ -117,8 +117,8 @@ uint32_t HASH_Init(HASH_CTX *ctx);
|
||||
* @brief Hash start
|
||||
* @param[in] ctx pointer to HASH_CTX struct
|
||||
* @return HASH_Start_OK, Hash start success; othets: Hash start fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.HASH_Init() should be recalled before use this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.HASH_Init() should be recalled before use this function
|
||||
*/
|
||||
uint32_t HASH_Start(HASH_CTX *ctx);
|
||||
|
||||
@@ -128,8 +128,8 @@ uint32_t HASH_Start(HASH_CTX *ctx);
|
||||
* @param[in] in pointer to message
|
||||
* @param[out] out pointer tohash result,digest
|
||||
* @return HASH_Update_OK, Hash update success; othets: Hash update fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.HASH_Init() and HASH_Start() should be recalled before use this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.HASH_Init() and HASH_Start() should be recalled before use this function
|
||||
*/
|
||||
uint32_t HASH_Update(HASH_CTX *ctx, uint8_t *in, uint32_t byteLen);
|
||||
|
||||
@@ -138,15 +138,15 @@ uint32_t HASH_Update(HASH_CTX *ctx, uint8_t *in, uint32_t byteLen);
|
||||
* @param[in] ctx pointer to HASH_CTX struct
|
||||
* @param[out] out pointer tohash result,digest
|
||||
* @return HASH_Complete_OK, Hash complete success; othets: Hash complete fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.HASH_Init(), HASH_Start() and HASH_Update() should be recalled before use this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* 2.HASH_Init(), HASH_Start() and HASH_Update() should be recalled before use this function
|
||||
*/
|
||||
uint32_t HASH_Complete(HASH_CTX *ctx, uint8_t *out);
|
||||
|
||||
/**
|
||||
* @brief Hash close
|
||||
* @return HASH_Close_OK, Hash close success; othets: Hash close fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
*/
|
||||
uint32_t HASH_Close(void);
|
||||
|
||||
@@ -156,7 +156,7 @@ uint32_t HASH_Close(void);
|
||||
* @param[in] byte length of in
|
||||
* @param[out] out pointer tohash result,digest
|
||||
* @return SM3_Hash_OK, SM3 hash success; othets: SM3 hash fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
*/
|
||||
uint32_t SM3_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
|
||||
@@ -167,7 +167,7 @@ uint32_t SM3_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
* @param[in] byte length of in
|
||||
* @param[out] out pointer tohash result,digest
|
||||
* @return SHA1_Hash_OK, SHA1 hash success; othets: SHA1 hash fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
*/
|
||||
uint32_t SHA1_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
|
||||
@@ -177,7 +177,7 @@ uint32_t SHA1_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
* @param[in] byte length of in
|
||||
* @param[out] out pointer tohash result,digest
|
||||
* @return SHA224_Hash_OK, SHA224 hash success; othets: SHA224 hash fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
*/
|
||||
uint32_t SHA224_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
|
||||
@@ -188,7 +188,7 @@ uint32_t SHA224_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
* @param[in] byte length of in
|
||||
* @param[out] out pointer tohash result,digest
|
||||
* @return SHA256_Hash_OK, SHA256 hash success; othets: SHA256 hash fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
*/
|
||||
uint32_t SHA256_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
|
||||
@@ -198,7 +198,7 @@ uint32_t SHA256_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
* @param[in] byte length of in
|
||||
* @param[in] out pointer tohash result,digest
|
||||
* @return MD5_Hash_OK, MD5 hash success; othets: MD5 hash fail
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
* @note 1.Please refer to the demo in user guidance before using this function
|
||||
*/
|
||||
uint32_t MD5_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
|
||||
@@ -207,7 +207,7 @@ uint32_t MD5_Hash(uint8_t* in,uint32_t byteLen, uint8_t* out);
|
||||
* @param[out] type pointer one byte type information represents the type of the lib, like Commercial version.\
|
||||
* @Bits 0~4 stands for Commercial (C), Security (S), Normal (N), Evaluation (E), Test (T), Bits 5~7 are reserved. e.g. 0x09 stands for CE version.
|
||||
* @param[out] customer pointer one byte customer information represents customer ID. for example, 0x00 stands for standard version, 0x01 is for Tianyu customized version...
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] date pointer array which include three bytes date information. If the returned bytes are 18,9,13,this denotes September 13,2018
|
||||
* @param[out] version pointer one byte version information represents develop version of the lib. e.g. 0x12 denotes version 1.2.
|
||||
* @return none
|
||||
* @1.You can recall this function to get RSA lib information
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user