4. SDK Directory Structure
This chapter describes each directory and file according to the real file tree of Nsing.N32H49x_Library.1.2.0. All paths are relative to the SDK root.
4.1 Top-Level Structure
- ๐ Entries ending with
/are directories - ๐ All other entries are files
Nsing.N32H49x_Library.1.2.0/
โโโ .vscode/
โ โโโ launch.json
โ โโโ settings.json
โ โโโ tasks.json
โโโ firmware/
โ โโโ CMSIS/
โ โโโ n32h49x_algo_lib/
โ โโโ n32h49x_std_periph_driver/
โ โโโ n32h49x_usbfsd_driver/
โ โโโ n32h49x_usbhs_driver/
โโโ jlink/
โ โโโ flash.jlink
โโโ middlewares/
โ โโโ fat_fs/
โ โโโ FreeRTOSv202212.01/
โ โโโ lwip-2.2.0/
โโโ projects/
โ โโโ n32h49x_EVAL/
โโโ N32H49x Version History.txt
| Relative path | Purpose |
|---|---|
firmware/ |
Firmware library: CMSIS core and device support files, the standard peripheral driver library, the algorithm library, and the USB drivers |
projects/n32h49x_EVAL/ |
Evaluation board project: board support, peripheral examples, and application projects |
middlewares/ |
Middleware sources: the FatFs file system, the FreeRTOS kernel, and the lwIP stack |
jlink/flash.jlink |
J-Link Commander download script, called by the download target of the GCC project |
.vscode/ |
VS Code GDB debug, build task, and editor configuration |
N32H49x Version History.txt |
SDK version record, listing additions and fixes version by version |
4.2 Firmware Library
๐ firmware/CMSIS
core/ holds the Arm CMSIS-Core headers, and a Cortex-M4F project uses core_cm4.h and arm_math.h from it;device/ holds the N32H49x device support files.
CMSIS/
โโโ core/
โ โโโ arm_common_tables.h
โ โโโ arm_const_structs.h
โ โโโ arm_math.h
โ โโโ cmsis_armcc.h
โ โโโ cmsis_armclang.h
โ โโโ cmsis_compiler.h
โ โโโ cmsis_gcc.h
โ โโโ cmsis_iccarm.h
โ โโโ cmsis_version.h
โ โโโ core_cm4.h
โ โโโ mpu_armv7.h
โโโ device/
โโโ startup/
โ โโโ startup_n32h49x.s
โ โโโ startup_n32h49x_EWARM.s
โ โโโ startup_n32h49x_gcc.s
โโโ n32h49x.h
โโโ n32h49x_conf.h
โโโ n32h49x_flash.ld
โโโ system_n32h49x.c
โโโ system_n32h49x.h
๐ firmware/n32h49x_std_periph_driver
The standard peripheral driver library: inc/ holds the driver headers and src/ holds the same-named implementations, one pair per driver module.
n32h49x_std_periph_driver/
โโโ inc/
โ โโโ misc.h
โ โโโ n32h49x_adc.h
โ โโโ n32h49x_cordic.h
โ โโโ n32h49x_crc.h
โ โโโ n32h49x_dac.h
โ โโโ n32h49x_dbg.h
โ โโโ n32h49x_dma.h
โ โโโ n32h49x_dsmu.h
โ โโโ n32h49x_dvp.h
โ โโโ n32h49x_eth.h
โ โโโ n32h49x_exti.h
โ โโโ n32h49x_fdcan.h
โ โโโ n32h49x_femc.h
โ โโโ n32h49x_flash.h
โ โโโ n32h49x_gpio.h
โ โโโ n32h49x_i2c.h
โ โโโ n32h49x_iwdg.h
โ โโโ n32h49x_lptim.h
โ โโโ n32h49x_pwr.h
โ โโโ n32h49x_rcc.h
โ โโโ n32h49x_rtc.h
โ โโโ n32h49x_sdio.h
โ โโโ n32h49x_sdram.h
โ โโโ n32h49x_spi.h
โ โโโ n32h49x_tim.h
โ โโโ n32h49x_usart.h
โ โโโ n32h49x_vrefbuf.h
โ โโโ n32h49x_wwdg.h
โ โโโ n32h49x_xspi.h
โ โโโ n32h49x_xspi_v2.h
โโโ src/
โโโ misc.c
โโโ n32h49x_adc.c
โโโ n32h49x_cordic.c
โโโ n32h49x_crc.c
โโโ n32h49x_dac.c
โโโ n32h49x_dbg.c
โโโ n32h49x_dma.c
โโโ n32h49x_dsmu.c
โโโ n32h49x_dvp.c
โโโ n32h49x_eth.c
โโโ n32h49x_exti.c
โโโ n32h49x_fdcan.c
โโโ n32h49x_femc.c
โโโ n32h49x_flash.c
โโโ n32h49x_gpio.c
โโโ n32h49x_i2c.c
โโโ n32h49x_iwdg.c
โโโ n32h49x_lptim.c
โโโ n32h49x_pwr.c
โโโ n32h49x_rcc.c
โโโ n32h49x_rtc.c
โโโ n32h49x_sdio.c
โโโ n32h49x_sdram.c
โโโ n32h49x_spi.c
โโโ n32h49x_tim.c
โโโ n32h49x_usart.c
โโโ n32h49x_vrefbuf.c
โโโ n32h49x_wwdg.c
โโโ n32h49x_xspi.c
โโโ n32h49x_xspi_v2.c
๐ firmware/n32h49x_algo_lib
The algorithm library in two sets, Keil and GCC, with the same header names and interfaces and the implementations in .lib and .a respectively.
n32h49x_algo_lib/
โโโ gcc/
โ โโโ inc/
โ โ โโโ n32h49x_aes.h
โ โ โโโ n32h49x_algo_common.h
โ โ โโโ n32h49x_des.h
โ โ โโโ n32h49x_hash.h
โ โ โโโ n32h49x_rng.h
โ โ โโโ n32h49x_sm4.h
โ โโโ lib/
โ โโโ AES.a
โ โโโ Common.a
โ โโโ DES.a
โ โโโ HASH.a
โ โโโ RNG.a
โ โโโ SM4.a
โโโ keil/
โโโ inc/
โ โโโ n32h49x_aes.h
โ โโโ n32h49x_algo_common.h
โ โโโ n32h49x_des.h
โ โโโ n32h49x_hash.h
โ โโโ n32h49x_rng.h
โ โโโ n32h49x_sm4.h
โโโ lib/
โโโ n32h49x_aes.lib
โโโ n32h49x_common.lib
โโโ n32h49x_des.lib
โโโ n32h49x_hash.lib
โโโ n32h49x_rng.lib
โโโ n32h49x_sm4.lib
๐ firmware/n32h49x_usbfsd_driver
The full-speed device driver, with nine headers in inc/ and six implementation files in src/.
n32h49x_usbfsd_driver/
โโโ inc/
โ โโโ usbfsd_core.h
โ โโโ usbfsd_def.h
โ โโโ usbfsd_init.h
โ โโโ usbfsd_int.h
โ โโโ usbfsd_lib.h
โ โโโ usbfsd_mem.h
โ โโโ usbfsd_regs.h
โ โโโ usbfsd_sil.h
โ โโโ usbfsd_type.h
โโโ src/
โโโ usbfsd_core.c
โโโ usbfsd_init.c
โโโ usbfsd_int.c
โโโ usbfsd_mem.c
โโโ usbfsd_regs.c
โโโ usbfsd_sil.c
๐ firmware/n32h49x_usbhs_driver
The high-speed host/device driver, organized in three layers: driver/ (controller driver), device/ (device stack and device classes), and host/ (host stack and host classes).
n32h49x_usbhs_driver/
โโโ driver/
โ โโโ inc/
โ โโโ src/
โโโ device/
โ โโโ core/
โ โโโ class/
โ โโโ audio/
โ โโโ cdc/
โ โโโ customhid/
โ โโโ hid_cdc_composite/
โ โโโ hid_keyboard/
โ โโโ hid_msc_composite/
โ โโโ mouse/
โ โโโ msc/
โ โโโ msc_cdc_composite/
โโโ host/
โโโ core/
โโโ class/
โโโ CDC/
โโโ HID/
โโโ MSC/
| Relative path | Purpose |
|---|---|
firmware/CMSIS/device/n32h49x.h |
Device header: peripheral register structures, base addresses, and interrupt numbers |
firmware/CMSIS/device/system_n32h49x.c |
System clock initialization; HSI through the PLL gives 240 MHz by default, and the PLL multiplier must be an even number between 8 and 76 |
firmware/CMSIS/device/n32h49x_conf.h |
Includes all driver headers in one place and defines assert_param |
firmware/CMSIS/device/startup/startup_n32h49x.s |
Keil MDK-ARM startup file |
firmware/CMSIS/device/startup/startup_n32h49x_EWARM.s |
IAR EWARM startup file |
firmware/CMSIS/device/startup/startup_n32h49x_gcc.s |
GCC startup file |
firmware/CMSIS/device/n32h49x_flash.ld |
GCC linker script |
firmware/n32h49x_std_periph_driver/inc/misc.h |
NVIC and SysTick configuration functions, corresponding to the NVIC module in chapter 5 |
firmware/n32h49x_std_periph_driver/inc/n32h49x_spi.h |
Driver header shared by SPI and I2S |
firmware/n32h49x_algo_lib/keil/lib/n32h49x_common.lib |
Common algorithm functions; the Keil library file name differs from that of the header n32h49x_algo_common.h |
4.3 Projects Directory
projects/ contains only the n32h49x_EVAL/ evaluation board project directory, with board support, peripheral examples, and application projects.
๐ projects/n32h49x_EVAL/bsp
Board support code, referenced by the example projects through the bsp/inc header path.
bsp/
โโโ inc/
โ โโโ bsp_eval.h
โ โโโ delay.h
โ โโโ log.h
โโโ src/
โโโ bsp_eval.c
โโโ delay.c
โโโ log.c
โโโ print_remap.c
๐ projects/n32h49x_EVAL/examples
Peripheral examples, grouped by peripheral category: 34 categories and 184 example projects in total.
examples/
โโโ ADC/
โโโ ALGO/
โโโ CORDIC/
โโโ Cortex-M4F/
โโโ CRC/
โโโ DAC/
โโโ DMA/
โโโ DSMU/
โโโ DVP/
โโโ ETH/
โโโ EXTI/
โโโ FDCAN/
โโโ FEMC/
โโโ Flash/
โโโ GPIO/
โโโ I2C/
โโโ I2S/
โโโ IWDG/
โโโ LPTIM/
โโโ NVIC/
โโโ PWR/
โโโ RCC/
โโโ RTC/
โโโ SDIO/
โโโ SDRAM/
โโโ SPI/
โโโ TIM/
โโโ USART/
โโโ USBFSD/
โโโ USBHS/
โโโ VREFBUF/
โโโ WWDG/
โโโ XSPI/
โโโ XSPI_V2/
๐ projects/n32h49x_EVAL/applications
Application projects;
currently only GCC_demo, which provides a GCC Makefile build.
applications/
โโโ GCC_demo/
โโโ GCC/
โ โโโ Makefile
โโโ inc/
โ โโโ main.h
โ โโโ n32h49x_it.h
โโโ src/
โ โโโ main.c
โ โโโ n32h49x_it.c
โโโ readme.txt
| Relative path | Purpose |
|---|---|
projects/n32h49x_EVAL/bsp/inc/bsp_eval.h |
Port, pin, clock, and active-level macros for LED1 to LED3, KEY1 to KEY3, the WKUP button, and USB VBUS on both boards, selected by DEMO_BOARD |
projects/n32h49x_EVAL/bsp/src/log.c |
Log UART initialization log_init: USART1, TX on PA9 and RX on PA10, 115200-8-N-1 |
projects/n32h49x_EVAL/bsp/inc/log.h |
The log_info, log_warning, log_error, and log_debug macros, controlled by LOG_ENABLE and LOG_LEVEL |
projects/n32h49x_EVAL/bsp/inc/delay.h |
SysTick delay functions SysTick_Delay_Us and SysTick_Delay_Ms |
projects/n32h49x_EVAL/bsp/src/print_remap.c |
Standard I/O redirection functions _write and _read |
projects/n32h49x_EVAL/bsp/src/bsp_eval.c |
Board-level helpers such as reading the button state and driving the LEDs |
projects/n32h49x_EVAL/examples/ |
Example projects of the 34 peripheral categories, each with both a Keil and an IAR project |
projects/n32h49x_EVAL/applications/GCC_demo/ |
LED blink GCC project: the Makefile sets the target platform to n32h49x and uses startup_n32h49x_gcc.s and n32h49x_flash.ld, with the all, clean, download, and debug targets |
4.4 Standard Example Structure
Each example directory contains sources, headers, a Keil and an IAR project, and a description file. Take examples/GPIO/LedBlink/ as an example:
LedBlink/
โโโ EWARM/
โ โโโ LedBlink.ewd
โ โโโ LedBlink.ewp
โ โโโ LedBlink.eww
โโโ inc/
โ โโโ main.h
โ โโโ n32h49x_it.h
โโโ MDK-ARM/
โ โโโ LedBlink.uvoptx
โ โโโ LedBlink.uvprojx
โโโ src/
โ โโโ main.c
โ โโโ n32h49x_it.c
โโโ readme.txt
| Relative path | Purpose |
|---|---|
src/main.c |
Example main program: peripheral initialization and the main loop |
src/n32h49x_it.c |
Interrupt service functions |
inc/main.h, inc/n32h49x_it.h |
Example header and interrupt function declarations |
MDK-ARM/LedBlink.uvprojx |
Keil project: target name N32H49X, device N32H497xG, compile macros N32H49X and USE_STDPERIPH_DRIVER, ROM from 0x08000000 with length 0x100000, RAM from 0x20000000 with length 0x90000 |
EWARM/LedBlink.eww |
IAR workspace: configuration name also N32H49X, the linker file is N32H497xG.icf from the toolchain directory, and the startup file is startup_n32h49x_EWARM.s |
readme.txt |
Bilingual notes: function description, use environment, instructions (system clock and I/O configuration, test steps and phenomena), and attention items |
Every example names its MDK-ARM project files <example>.uvprojx / <example>.uvoptx and its EWARM project <example>.eww / <example>.ewp / <example>.ewd;
no example directory contains a GCC project. The following cases differ from the standard structure:
| Case | Examples | Structure |
|---|---|---|
| Grouped sub-projects | USART/485/, USART/LIN/, USART/IrDA_Tx&Rx/, USBHS/USBHS_Device/, USBHS/USBHS_Host/, USBHS/USBHS_Dual_Role/ |
The parent directory only groups and has no project; each sub-project carries its own readme.txt, src/, inc/, MDK-ARM/, and EWARM/ and is counted separately |
| Project naming inside groups | Sub-projects of USBHS/USBHS_Device/ and USBHS/USBHS_Host/ |
The project files are uniformly named project.uvprojx and project.eww, differing from the directory name |
| Auxiliary sources | USART/LIN/LIN_Master/, USART/IrDA_Tx&Rx/Transmit_Receive/, USBHS/USBHS_Device/CDC/ |
src/ and inc/ hold additional helper implementations and configuration headers such as lin_master.c, bsp_Tim_38K.c, and usbd_cdc_core.c |
Example projects reference firmware/ and bsp/ through relative paths. When copying an example, keep its directory level under projects/n32h49x_EVAL/examples/<category>/, otherwise the header paths and source paths in the project must be updated as well.
4.5 Development Aids
| Relative path | Purpose |
|---|---|
jlink/flash.jlink |
J-Link Commander script: reset, load build/output.hex, reset, run, quit |
.vscode/launch.json |
gdb-arm debug configuration: connects arm-none-eabi-gdb to the GDB server at localhost:2331, loads the program, resets, and sets a breakpoint at main |
.vscode/tasks.json |
make_debug build task, running make debug in the working directory projects/n32h49x_EVAL/applications/GCC_demo/GCC |
.vscode/settings.json |
Editor settings and file associations (n32h49x.h and n32h49x_flash.h associated with C) |
projects/n32h49x_EVAL/applications/GCC_demo/GCC/Makefile |
GCC build script: all produces build/output.elf, .hex, and .bin;download calls JLink.exe with -device N32H497xG -if SWD to run jlink/flash.jlink;debug starts JLinkGDBServer.exe |
The toolchain paths and the J-Link installation path in .vscode/launch.json and GCC_demo/GCC/Makefile are fixed values, and the ELF file loaded by launch.json is hard-coded to an absolute path under the Nsing.N32H49x_Library.1.0.0 directory. Before use, change these paths to match your local installation and the actual SDK directory.
Outside the SDK root, the SDK package also provides the following development support files, whose official versions are listed in the โDocumentation and Tool Navigationโ chapter:
| Resource | Purpose |
|---|---|
| KEIL PACK package | Keil support package: the .pack installer, the .pdsc device description, Flash programming algorithms, and .svd files |
| IAR model patch | Adds the Nations device descriptions to the IAR toolchain; after installation, linker files such as N32H497xG.icf reside in the config/linker/Nsing/N32H49x/ directory of the toolchain |
| J-Link model patch package | J-Link device description files that make J-Link recognize parts such as N32H497xG |
| Flash programming algorithm source projects | Keil and IAR Flash programming algorithm source projects, for building your own .FLM files |
| NSLink and production tools | Online and offline production programming tools |