4. SDK Directory Structure
This chapter describes the directories and files of Nsing.N32G41x_Library.1.1.0 from its actual file tree, and lists only directories and files that are present in the package. All paths are relative to the SDK root. Device support packs, production tools and other support files outside the package are covered in the Documentation and Tool Navigation chapter.
4.1 Top-Level Layout
- ๐ Entries ending in
/are directories - ๐ All other entries are files
Nsing.N32G41x_Library.1.1.0/
โโโ .vscode/
โ โโโ launch.json
โ โโโ settings.json
โ โโโ tasks.json
โโโ firmware/
โ โโโ CMSIS/
โ โโโ n32g41x_std_periph_driver/
โโโ jlink/
โ โโโ flash.jlink
โโโ Middlewares/
โ โโโ FreeRTOSv202604.01-LTS/
โโโ projects/
โ โโโ n32g41x_EVAL/
โโโ readme.txt
| Relative path | Purpose |
|---|---|
firmware/ |
Firmware library: CMSIS core and device support files, and the standard peripheral driver library |
Middlewares/ |
FreeRTOS kernel sources, referenced by the FreeRTOS example project |
projects/n32g41x_EVAL/ |
Evaluation board projects: board support, peripheral examples and application projects |
jlink/flash.jlink |
J-Link Commander download script called by the download target of the GCC project |
.vscode/ |
VS Code GDB debugging, build task and editor configuration |
readme.txt |
SDK version record and change notes for each version |
4.2 Firmware Library
๐ firmware/CMSIS
core/ holds the Arm CMSIS-Core headers; a Cortex-M4 project uses core_cm4.h from it. device/ holds the N32G41x device support files and the three startup files.
CMSIS/
โโโ core/
โ โโโ cmsis_armcc.h
โ โโโ cmsis_armclang.h
โ โโโ cmsis_armclang_ltm.h
โ โโโ cmsis_compiler.h
โ โโโ cmsis_gcc.h
โ โโโ cmsis_iccarm.h
โ โโโ cmsis_version.h
โ โโโ core_armv81mml.h
โ โโโ core_armv8mbl.h
โ โโโ core_armv8mml.h
โ โโโ core_cm0.h
โ โโโ core_cm0plus.h
โ โโโ core_cm1.h
โ โโโ core_cm23.h
โ โโโ core_cm3.h
โ โโโ core_cm33.h
โ โโโ core_cm35p.h
โ โโโ core_cm4.h
โ โโโ core_cm7.h
โ โโโ core_sc000.h
โ โโโ core_sc300.h
โ โโโ mpu_armv7.h
โ โโโ mpu_armv8.h
โ โโโ tz_context.h
โโโ device/
โโโ startup/
โ โโโ startup_n32g41x.s
โ โโโ startup_n32g41x_EWARM.S
โ โโโ startup_n32g41x_gcc.s
โโโ n32g41x.h
โโโ n32g41x_conf.h
โโโ n32g41x_flash.ld
โโโ system_n32g41x.c
โโโ system_n32g41x.h
๐ firmware/n32g41x_std_periph_driver
The standard peripheral driver library: inc/ holds the driver headers and src/ the implementation files of the same name, one pair per driver module.
n32g41x_std_periph_driver/
โโโ inc/
โ โโโ misc.h
โ โโโ n32g41x_adc.h
โ โโโ n32g41x_can.h
โ โโโ n32g41x_comp.h
โ โโโ n32g41x_crc.h
โ โโโ n32g41x_dbg.h
โ โโโ n32g41x_dma.h
โ โโโ n32g41x_exti.h
โ โโโ n32g41x_flash.h
โ โโโ n32g41x_gpio.h
โ โโโ n32g41x_i2c.h
โ โโโ n32g41x_iwdg.h
โ โโโ n32g41x_opamp.h
โ โโโ n32g41x_pwr.h
โ โโโ n32g41x_rcc.h
โ โโโ n32g41x_rtc.h
โ โโโ n32g41x_spi.h
โ โโโ n32g41x_tim.h
โ โโโ n32g41x_usart.h
โ โโโ n32g41x_wwdg.h
โโโ src/
โโโ misc.c
โโโ n32g41x_adc.c
โโโ n32g41x_can.c
โโโ n32g41x_comp.c
โโโ n32g41x_crc.c
โโโ n32g41x_dbg.c
โโโ n32g41x_dma.c
โโโ n32g41x_exti.c
โโโ n32g41x_flash.c
โโโ n32g41x_gpio.c
โโโ n32g41x_i2c.c
โโโ n32g41x_iwdg.c
โโโ n32g41x_opamp.c
โโโ n32g41x_pwr.c
โโโ n32g41x_rcc.c
โโโ n32g41x_rtc.c
โโโ n32g41x_spi.c
โโโ n32g41x_tim.c
โโโ n32g41x_usart.c
โโโ n32g41x_wwdg.c
| Relative path | Purpose |
|---|---|
firmware/CMSIS/device/n32g41x.h |
Device header: peripheral register structures, base addresses and interrupt numbers |
firmware/CMSIS/device/system_n32g41x.c |
System clock initialisation; requires exactly one of N32G412 or N32G415 to be defined, and defaults to HSI multiplied by the PLL at 80 MHz (N32G412) or 96 MHz (N32G415) |
firmware/CMSIS/device/system_n32g41x.h |
System clock configuration macros such as SYSCLK_SRC and SYSCLK_FREQ, and the available frequency options |
firmware/CMSIS/device/n32g41x_conf.h |
Includes all driver headers in one place and defines assert_param |
firmware/CMSIS/device/startup/startup_n32g41x.s |
Keil MDK-ARM startup file |
firmware/CMSIS/device/startup/startup_n32g41x_EWARM.S |
IAR EWARM startup file |
firmware/CMSIS/device/startup/startup_n32g41x_gcc.s |
GCC startup file |
firmware/CMSIS/device/n32g41x_flash.ld |
GCC linker script |
firmware/n32g41x_std_periph_driver/inc/misc.h |
NVIC and SysTick configuration functions, documented as the NVIC module in Chapter 5 |
firmware/n32g41x_std_periph_driver/inc/n32g41x_spi.h |
Driver header shared by SPI and I2S |
4.3 Projects Directory
projects/ contains only the evaluation board project directory n32g41x_EVAL/, made up of board support, peripheral examples and application projects.
๐ projects/n32g41x_EVAL/bsp
Board support code, referenced by the example projects through the bsp/inc header path.
bsp/
โโโ inc/
โ โโโ delay.h
โ โโโ log.h
โ โโโ n32g41x_stb.h
โโโ src/
โโโ delay.c
โโโ log.c
โโโ print_remap.c
๐ projects/n32g41x_EVAL/examples
Peripheral examples, organised by peripheral category with a number of example projects in each.
examples/
โโโ ADC/
โโโ bxCAN/
โโโ COMP/
โโโ Cortex-M4/
โโโ CRC/
โโโ DMA/
โโโ EXTI/
โโโ Flash/
โโโ FreeRTOS/
โโโ GPIO/
โโโ I2C/
โโโ I2S/
โโโ IWDG/
โโโ NVIC/
โโโ OPAMP/
โโโ PWR/
โโโ RCC/
โโโ RTC/
โโโ SPI/
โโโ TIM/
โโโ USART/
โโโ WWDG/
๐ projects/n32g41x_EVAL/applications
Application projects demonstrating complete use cases beyond the example directory.
applications/
โโโ BOOT_As_ExtFLASH/
โ โโโ inc/
โ โ โโโ main.h
โ โ โโโ n32g41x_it.h
โ โโโ MDK-ARM/
โ โ โโโ BOOT_As_ExtFLASH.uvoptx
โ โ โโโ BOOT_As_ExtFLASH.uvprojx
โ โโโ src/
โ โโโ main.c
โ โโโ n32g41x_it.c
โโโ GCC_demo/
โ โโโ GCC/
โ โ โโโ Makefile
โ โโโ inc/
โ โ โโโ main.h
โ โ โโโ n32g41x_it.h
โ โโโ src/
โ โโโ main.c
โ โโโ n32g41x_it.c
โโโ JumpToBOOT/
โโโ inc/
โ โโโ main.h
โ โโโ n32g41x_it.h
โโโ MDK-ARM/
โ โโโ project.uvoptx
โ โโโ project.uvprojx
โโโ src/
โโโ main.c
โโโ n32g41x_it.c
| Relative path | Purpose |
|---|---|
projects/n32g41x_EVAL/bsp/inc/n32g41x_stb.h |
Port, pin, clock and active-level macros for LED1 to LED3, KEY1 to KEY3 and the WKUP key |
projects/n32g41x_EVAL/bsp/src/log.c |
Log UART initialisation log_init: USART1 with PA9 as TX and PA10 as RX, 115200 bps |
projects/n32g41x_EVAL/bsp/inc/log.h |
log_info, log_warning, log_error and log_debug macros, controlled by LOG_ENABLE and LOG_LEVEL |
projects/n32g41x_EVAL/bsp/inc/delay.h |
SysTick delay functions SysTick_Delay_Us and SysTick_Delay_Ms |
projects/n32g41x_EVAL/bsp/src/print_remap.c |
Standard input and output redirection functions _write and _read |
projects/n32g41x_EVAL/applications/BOOT_As_ExtFLASH/ |
Programs the BOOT area as extended Flash: when the BOOT area is write-protected, pressing the PA4 key removes the write protection through the option bytes and resets; otherwise it erases one page starting at 0x1FFF0000, writes data and verifies it word by word, reporting the result on the log UART.A Keil project only |
projects/n32g41x_EVAL/applications/GCC_demo/ |
A GCC project that blinks the LEDs: the Makefile defines N32G412 and uses startup_n32g41x_gcc.s and n32g41x_flash.ld, with the all, clean, download and debug targets |
projects/n32g41x_EVAL/applications/JumpToBOOT/ |
Jumps from the application to the BOOT: after the WKUP key is pressed it reads the stack top at 0x1FFF0000 and the reset vector at 0x1FFF0004 and jumps there.A Keil project only |
4.4 Standard Structure of an Example
Every example directory contains sources, headers, a Keil and an IAR project, and a description file. Take examples/GPIO/LedBlink/ as an example:
LedBlink/
โโโ EWARM/
โ โโโ project.ewd
โ โโโ project.ewp
โ โโโ project.eww
โโโ inc/
โ โโโ main.h
โ โโโ n32g41x_it.h
โโโ MDK-ARM/
โ โโโ project.uvoptx
โ โโโ project.uvprojx
โโโ src/
โ โโโ main.c
โ โโโ n32g41x_it.c
โโโ readme.txt
| Relative path | Purpose |
|---|---|
src/main.c |
Example main program: peripheral initialisation and the main loop |
src/n32g41x_it.c |
Interrupt service routines |
inc/main.h, inc/n32g41x_it.h |
Example header and interrupt function declarations |
MDK-ARM/project.uvprojx |
Keil project with two targets, N32G412 (device N32G412RBL7) and N32G415 (device N32G415RBL7), each defining the matching compile macro and USE_STDPERIPH_DRIVER |
EWARM/project.eww |
IAR workspace with two configurations, N32G412 and N32G415 |
readme.txt |
Chinese and English notes: function description, development environment (tools and supported chips), usage (system configuration and how to run) and cautions |
Project files in the example directories are consistently named project.uvprojx / project.uvoptx and project.eww / project.ewp / project.ewd, and no example directory contains a GCC project. The following cases differ from the standard structure:
| Case | Example | Structure |
|---|---|---|
| Paired sub-projects sharing one description file | SPI/SPI_9Bit/ |
The parent directory holds readme.txt, and SPI_9Bit_Master/ and SPI_9Bit_Slave/ each contain a complete src/, inc/, MDK-ARM/ and EWARM/ |
| Shared code directory | RTC/Common/ |
Only inc/User_RTC_Config.h and src/User_RTC_Config.c, with no project files |
| Helper sources | bxCAN/CAN_LoopBack/, I2C/EEPROM_Polling/, SPI/SPI_FLASH/ |
src/ and inc/ also contain helper drivers such as can_config.c, i2c_eeprom.c and spi_flash.c |
Example projects reference firmware/ and bsp/ through relative paths. When copying an example, keep it at the same level under projects/n32g41x_EVAL/examples/<category>/, otherwise the header 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 |
The gdb-arm debug configuration: connects arm-none-eabi-gdb to a GDB server on localhost:2331, loads the program, resets and sets a breakpoint at main |
.vscode/tasks.json |
The make_debug build task, which runs make debug in the GCC project directory |
.vscode/settings.json |
Editor settings and file associations |
projects/n32g41x_EVAL/applications/GCC_demo/GCC/Makefile |
GCC build script: all produces build/output.elf, .hex and .bin;download calls JLink.exe with jlink/flash.jlink;debug starts JLinkGDBServer.exe |
The working directory in .vscode/tasks.json is written as projects/n32h41x_EVAL/applications/GCC_demo/GCC but the actual directory is projects/n32g41x_EVAL, so running that task directly fails to find the project. .vscode/launch.json loads the ELF file and the GDB program through fixed paths, and the GCC toolchain and J-Link installation paths in the Makefile are fixed values too. Adjust these paths for your own machine before use.
The following support resources are not inside the SDK root and must be obtained from the official download centre; their names and versions are listed in the Documentation and Tool Navigation chapter:
| Resource | Purpose |
|---|---|
Nsingtech.N32G41x_DFP |
Keil device support pack: the .pack installer, the .pdsc device description, the Flash/N32G41x_64.FLM and Flash/N32G41x_128.FLM programming algorithms, and the device register description file |
N32G41x_Keil_FLASH_Programming_Algorithm |
Keil Flash programming algorithm source project, which builds the two programming algorithms above |
Nations_Device_PACK_Add_To_IAR_Tool |
IAR device patch installer, which adds the N32G41x device models to IAR |
JLink_tool_adds_Nations_chip |
J-Link device patch, which adds the N32G41x device models to J-Link |