4. SDK Directory Structure

This chapter describes the directories and files of Nsing.N32G033_Library.1.3.0 based on its actual file tree. All paths are relative to the SDK root.

4.1 Top-Level Layout

  • ๐Ÿ“ Names ending in / are directories
  • ๐Ÿ“„ All other names are files
Nsing.N32G033_Library.1.3.0/
โ”œโ”€โ”€ .vscode/
โ”‚   โ”œโ”€โ”€ launch.json
โ”‚   โ”œโ”€โ”€ settings.json
โ”‚   โ””โ”€โ”€ tasks.json
โ”œโ”€โ”€ firmware/
โ”‚   โ”œโ”€โ”€ CMSIS/
โ”‚   โ””โ”€โ”€ n32g033_std_periph_driver/
โ”œโ”€โ”€ jlink/
โ”‚   โ””โ”€โ”€ flash.jlink
โ”œโ”€โ”€ Middlewares/
โ”‚   โ”œโ”€โ”€ freertos/
โ”‚   โ””โ”€โ”€ N32_SelfTest_Library/
โ”œโ”€โ”€ projects/
โ”‚   โ””โ”€โ”€ n32g033_EVAL/
โ””โ”€โ”€ N32G033 version history.txt
Relative path Purpose
firmware/ Firmware library: CMSIS core and device support files, standard peripheral driver library
Middlewares/ Middleware: FreeRTOS kernel and the N32 self-test library
projects/n32g033_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 debug, build task, and editor settings
N32G033 version history.txt SDK version history

4.2 Firmware Library

๐Ÿ“ firmware/CMSIS

core/ holds the Arm CMSIS-Core headers, of which Cortex-M0 projects use core_cm0.h; device/ holds the N32G033 device support 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_n32g033.s
    โ”‚   โ”œโ”€โ”€ startup_n32g033_EWARM.S
    โ”‚   โ”œโ”€โ”€ startup_n32g033_EWARM_ClassB.S
    โ”‚   โ””โ”€โ”€ startup_n32g033_gcc.s
    โ”œโ”€โ”€ n32g033.h
    โ”œโ”€โ”€ n32g033_conf.h
    โ”œโ”€โ”€ n32g033_flash.ld
    โ”œโ”€โ”€ system_n32g033.c
    โ””โ”€โ”€ system_n32g033.h
๐Ÿ“ firmware/n32g033_std_periph_driver

Standard peripheral driver library: inc/ holds the driver headers and src/ the implementations of the same name, one pair per driver module.

n32g033_std_periph_driver/
โ”œโ”€โ”€ inc/
โ”‚   โ”œโ”€โ”€ misc.h
โ”‚   โ”œโ”€โ”€ n32g033_adc.h
โ”‚   โ”œโ”€โ”€ n32g033_comp.h
โ”‚   โ”œโ”€โ”€ n32g033_dbg.h
โ”‚   โ”œโ”€โ”€ n32g033_dma.h
โ”‚   โ”œโ”€โ”€ n32g033_exti.h
โ”‚   โ”œโ”€โ”€ n32g033_flash.h
โ”‚   โ”œโ”€โ”€ n32g033_gpio.h
โ”‚   โ”œโ”€โ”€ n32g033_hdiv.h
โ”‚   โ”œโ”€โ”€ n32g033_i2c.h
โ”‚   โ”œโ”€โ”€ n32g033_iwdg.h
โ”‚   โ”œโ”€โ”€ n32g033_opamp.h
โ”‚   โ”œโ”€โ”€ n32g033_pwr.h
โ”‚   โ”œโ”€โ”€ n32g033_rcc.h
โ”‚   โ”œโ”€โ”€ n32g033_spi.h
โ”‚   โ”œโ”€โ”€ n32g033_sqrt.h
โ”‚   โ”œโ”€โ”€ n32g033_tim.h
โ”‚   โ””โ”€โ”€ n32g033_uart.h
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ misc.c
    โ”œโ”€โ”€ n32g033_adc.c
    โ”œโ”€โ”€ n32g033_comp.c
    โ”œโ”€โ”€ n32g033_dbg.c
    โ”œโ”€โ”€ n32g033_dma.c
    โ”œโ”€โ”€ n32g033_exti.c
    โ”œโ”€โ”€ n32g033_flash.c
    โ”œโ”€โ”€ n32g033_gpio.c
    โ”œโ”€โ”€ n32g033_hdiv.c
    โ”œโ”€โ”€ n32g033_i2c.c
    โ”œโ”€โ”€ n32g033_iwdg.c
    โ”œโ”€โ”€ n32g033_opamp.c
    โ”œโ”€โ”€ n32g033_pwr.c
    โ”œโ”€โ”€ n32g033_rcc.c
    โ”œโ”€โ”€ n32g033_spi.c
    โ”œโ”€โ”€ n32g033_sqrt.c
    โ”œโ”€โ”€ n32g033_tim.c
    โ””โ”€โ”€ n32g033_uart.c
Relative path Purpose
firmware/CMSIS/device/n32g033.h Device header: peripheral register structures, base addresses, and interrupt numbers
firmware/CMSIS/device/system_n32g033.c System clock initialization;
requires the N32G033 macro, defaults to HSI at 64 MHz, and can be set to 32 MHz or 32 kHz through SYSCLK_FREQ
firmware/CMSIS/device/n32g033_conf.h Includes all driver headers and defines assert_param
firmware/CMSIS/device/startup/startup_n32g033.s Keil MDK-ARM startup file
firmware/CMSIS/device/startup/startup_n32g033_EWARM.S IAR EWARM startup file
firmware/CMSIS/device/startup/startup_n32g033_EWARM_ClassB.S IAR EWARM startup file for the ClassB self-test, used by applications/ClassB_demo
firmware/CMSIS/device/startup/startup_n32g033_gcc.s GCC startup file
firmware/CMSIS/device/n32g033_flash.ld GCC linker script
firmware/n32g033_std_periph_driver/inc/misc.h NVIC and SysTick configuration functions, corresponding to the NVIC module in chapter 5
firmware/n32g033_std_periph_driver/inc/n32g033_hdiv.h Hardware divider driver header
firmware/n32g033_std_periph_driver/inc/n32g033_sqrt.h Square-root accelerator driver header

4.3 Projects Directory

projects/ contains only the n32g033_EVAL/ evaluation board directory, with board support, peripheral examples, and application projects.

๐Ÿ“ projects/n32g033_EVAL/bsp

Board support code, referenced by the examples through the bsp/inc include path.

bsp/
โ”œโ”€โ”€ inc/
โ”‚   โ”œโ”€โ”€ delay.h
โ”‚   โ””โ”€โ”€ log.h
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ delay.c
    โ”œโ”€โ”€ log.c
    โ””โ”€โ”€ print_remap.c
๐Ÿ“ projects/n32g033_EVAL/examples

Peripheral examples, organized into peripheral categories, each holding several example projects.

examples/
โ”œโ”€โ”€ ADC/
โ”œโ”€โ”€ COMP/
โ”œโ”€โ”€ Cortex-M0/
โ”œโ”€โ”€ DMA/
โ”œโ”€โ”€ EXTI/
โ”œโ”€โ”€ FLASH/
โ”œโ”€โ”€ FreeRTOS/
โ”œโ”€โ”€ GPIO/
โ”œโ”€โ”€ HDIV/
โ”œโ”€โ”€ I2C/
โ”œโ”€โ”€ IWDG/
โ”œโ”€โ”€ NVIC/
โ”œโ”€โ”€ OPAMP/
โ”œโ”€โ”€ PWR/
โ”œโ”€โ”€ RCC/
โ”œโ”€โ”€ SPI/
โ”œโ”€โ”€ SQRT/
โ”œโ”€โ”€ TIM/
โ””โ”€โ”€ UART/
๐Ÿ“ projects/n32g033_EVAL/applications

Application projects that demonstrate complete usage scenarios beyond the example directories.

applications/
โ”œโ”€โ”€ ClassB_demo/
โ”‚   โ”œโ”€โ”€ EWARM/
โ”‚   โ”œโ”€โ”€ MDK-ARM/
โ”‚   โ”œโ”€โ”€ crc32_software.c
โ”‚   โ”œโ”€โ”€ crc32_software.h
โ”‚   โ”œโ”€โ”€ main.c
โ”‚   โ”œโ”€โ”€ main.h
โ”‚   โ”œโ”€โ”€ n32_cm0_it.c
โ”‚   โ””โ”€โ”€ n32_cm0_it.h
โ”œโ”€โ”€ GCC_demo/
โ”‚   โ”œโ”€โ”€ GCC/
โ”‚   โ”‚   โ””โ”€โ”€ Makefile
โ”‚   โ”œโ”€โ”€ inc/
โ”‚   โ”‚   โ”œโ”€โ”€ main.h
โ”‚   โ”‚   โ””โ”€โ”€ n32g033_it.h
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ main.c
โ”‚   โ”‚   โ””โ”€โ”€ n32g033_it.c
โ”‚   โ””โ”€โ”€ readme.txt
โ””โ”€โ”€ JumpToBOOT/
    โ”œโ”€โ”€ MDK-ARM/
    โ”‚   โ”œโ”€โ”€ JumpToBOOT.uvoptx
    โ”‚   โ””โ”€โ”€ JumpToBOOT.uvprojx
    โ”œโ”€โ”€ inc/
    โ”‚   โ”œโ”€โ”€ main.h
    โ”‚   โ””โ”€โ”€ n32g033_it.h
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ main.c
    โ”‚   โ””โ”€โ”€ n32g033_it.c
    โ””โ”€โ”€ readme.txt
Relative path Purpose
projects/n32g033_EVAL/bsp/src/log.c Log UART initialization log_init: UART1, PA9 as TX and PA10 as RX, 115200 bps
projects/n32g033_EVAL/bsp/inc/log.h log_info, log_warning, log_error, and log_debug macros, controlled by LOG_ENABLE and LOG_LEVEL
projects/n32g033_EVAL/bsp/inc/delay.h SysTick delay functions SysTick_Delay_Us and SysTick_Delay_Ms
projects/n32g033_EVAL/bsp/src/print_remap.c Standard I/O retarget functions _write and _read, which route printf output to the log UART
projects/n32g033_EVAL/applications/ClassB_demo/ ClassB self-test routine: runs STL_InitRunTimeChecks and STL_DoRunTimeChecks with static resources from Middlewares/N32_SelfTest_Library;
provides Keil and IAR projects, and the Keil project includes srecord_crc32.bat and the srecord tools under SREC/
projects/n32g033_EVAL/applications/JumpToBOOT/ Jump from the user program to SYSTEM BOOT: after reset it prints a notice and stays in the user program, and a press on the PA4 key jumps to system memory;
provides a Keil project only
projects/n32g033_EVAL/applications/GCC_demo/ LED blink GCC project: the Makefile defines N32G033 and uses startup_n32g033_gcc.s and n32g033_flash.ld, with all, clean, download, and debug targets

4.4 Standard Structure of an Example

Every example directory contains source files, headers, a Keil project, an IAR project, and a readme. Take examples/GPIO/LedBlink/ as an example:

LedBlink/
โ”œโ”€โ”€ EWARM/
โ”‚   โ”œโ”€โ”€ LedBlink.ewd
โ”‚   โ”œโ”€โ”€ LedBlink.ewp
โ”‚   โ””โ”€โ”€ LedBlink.eww
โ”œโ”€โ”€ inc/
โ”‚   โ”œโ”€โ”€ main.h
โ”‚   โ””โ”€โ”€ n32g033_it.h
โ”œโ”€โ”€ MDK-ARM/
โ”‚   โ”œโ”€โ”€ LedBlink.uvoptx
โ”‚   โ””โ”€โ”€ LedBlink.uvprojx
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.c
โ”‚   โ””โ”€โ”€ n32g033_it.c
โ””โ”€โ”€ readme.txt
Relative path Purpose
src/main.c Example main program: peripheral initialization and the main loop
src/n32g033_it.c Interrupt service functions
inc/main.h, inc/n32g033_it.h Example header and interrupt function declarations
MDK-ARM/LedBlink.uvprojx Keil project, defining the N32G033 and USE_STDPERIPH_DRIVER compile macros
EWARM/LedBlink.eww IAR workspace
readme.txt Chinese and English notes: function description, development environment (toolchain and supported parts), how to use (system configuration and usage), and cautions

Every example names its project files after the example itself (such as LedBlink.uvprojx and LedBlink.eww), and no example directory contains a GCC project. The following cases differ from the standard structure:

Case Example Structure
Paired sub-projects that each carry a readme UART/LIN/, UART/IrDA_Tx&Rx/ The LIN/ parent holds LIN_Master/ and LIN_Slave/, and the IrDA_Tx&Rx/ parent holds LP_Transmit_Receive/ and Transmit_Receive/;
each sub-project carries its own src/, inc/, MDK-ARM/, EWARM/, and readme.txt
Extra helper sources FreeRTOS/LED_Blink/, I2C/EEPROM/, SPI/SPI_FLASH/, UART/IrDA_Tx&Rx/, UART/LIN/, UART/MultiProcessor/ Their src/ also holds helper drivers such as led.c, timer.c, i2c_eeprom.c, spi_flash.c, bsp_Tim_38K.c, lin_master.c, lin_slave.c, bsp_key.c, and bsp_led.c

Examples reference firmware/ and bsp/ through relative paths. When you copy an example, keep it at its original level under projects/n32g033_EVAL/examples/<category>/, otherwise you must also update the header and source paths in the project.

4.5 Development Aids

Relative path Purpose
jlink/flash.jlink J-Link Commander script: reset, load build/output.hex, reset, run, and quit
.vscode/launch.json gdb-arm debug configuration: connects arm-none-eabi-gdb to the GDB server on localhost:2331, loads the program, resets, and sets a breakpoint at main
.vscode/tasks.json make_debug build task, running make debug in the GCC project directory
.vscode/settings.json Editor settings and file associations
projects/n32g033_EVAL/applications/GCC_demo/GCC/Makefile GCC build script: all produces build/output.elf, .hex, and .bin;
download calls JLink.exe with device N32G033x8 to run jlink/flash.jlink;
debug starts JLinkGDBServer.exe

Beyond the SDK, Nations Technologies also provides the Keil support pack, the IAR and J-Link device patches, the Flash programming algorithm package, and the initialization code generation tool; their names and versions are listed in the Documentation and Tool Navigation chapter.