5.8 GPIO Guide
This chapter describes the file layout, the 25 public functions, and the single LedBlink example of the GPIO and AFIO support in the N32G033 standard peripheral library. Read the “GPIO and AFIO” chapter of the user manual for pin modes, alternate functions, remap, and EXTI line assignment, and the errata sheet for known chip issues.
5.8.1 Related files
| Relative path | Purpose |
|---|---|
firmware/n32g033_std_periph_driver/inc/n32g033_gpio.h |
Defines the GPIO_InitType structure and the input/output mode, pull, and alternate-function macros, and declares the 25 GPIO and AFIO configuration and read/write functions |
firmware/n32g033_std_periph_driver/src/n32g033_gpio.c |
Implements those 25 functions: reset and initialization, input and output reads, bit operations and toggle, pin lock, EXTI line selection and clear, alternate-function and remap configuration, and GPIOB drive strength and slew rate |
projects/n32g033_EVAL/examples/GPIO/ |
GPIO example root directory, with 1 example: LedBlink |
projects/n32g033_EVAL/examples/GPIO/LedBlink/ |
Project layout of this example: MDK-ARM/, EWARM/, inc/, src/, and readme.txt |
projects/n32g033_EVAL/bsp/ |
Board support files shared by the examples: the SysTick delay interface in delay.h |
5.8.2 API reference
The following 25 public functions are listed in the declaration order of n32g033_gpio.h in 6 groups; each entry gives a summary and the original comment above the function in n32g033_gpio.c.
Reset and initialization
GPIO_DeInit, GPIO_DeInitPin, GPIO_InitPeripheral, GPIO_InitStruct
Input and output reads
GPIO_ReadInputDataBit, GPIO_ReadInputData, GPIO_ReadOutputDataBit, GPIO_ReadOutputData
Bit operations and writes
GPIO_SetBits, GPIO_WritePBSC, GPIO_ResetBits, GPIO_WriteBit, GPIO_Write, GPIO_TogglePin
Pin lock and EXTI line configuration
GPIO_ConfigPinLock, GPIO_ConfigEXTILine, GPIO_ClearEXTILine
Alternate function and remap configuration
AFIO_ConfigEXTIFlitEN, GPIO_ConfigPinRemap, AFIO_ConfigADCExternalTrigRemap, AFIO_ConfigSPINSSMode, AFIO_ConfigIOFlitNum, AFIO_DIGEFTEnable
GPIOB drive strength and slew rate
GPIOB_Driver_Set, GPIOB_SlewRate_Set
void GPIO_DeInit(void)Reset the GPIOx peripheral registers to their default reset values.
name GPIO_DeInit.
fun Reset the GPIOx peripheral registers to their default reset values.
param none
return none
void GPIO_DeInitPin(GPIO_Module* GPIOx, uint32_t GPIO_Pin)Deinitializes the GPIOx peripheral registers to their default reset values.
name GPIO_DeInitPin.
fun Deinitializes the GPIOx peripheral registers to their default reset values.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
- GPIO_PIN_ALL
return none
note If IO involves EXTI configuration, the corresponding EXTI line needs to be reset.
void GPIO_InitPeripheral(GPIO_Module* GPIOx, GPIO_InitType* GPIO_InitStruct)Initialize the GPIOx peripheral with the value of the GPIO_InitStruct structure.
name GPIO_InitPeripheral.
fun Initialize the GPIOx peripheral with the value of the GPIO_InitStruct structure.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param GPIO_InitStructure :
- pin
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
- GPIO_PIN_ALL
- GPIO_Mode
- GPIO_MODE_INPUT
- GPIO_MODE_OUTPUT_PP
- GPIO_MODE_AF_PP
- GPIO_MODE_AF_OD
- GPIO_MODE_ANALOG
- GPIO_Pull
- GPIO_NO_PULL
- GPIO_PULL_UP
- GPIO_PULL_DOWN
- GPIO_Alternate
- GPIO_AF0
- GPIO_AF1
- GPIO_AF2
- GPIO_AF3
- GPIO_AF4
- GPIO_AF5
- GPIO_AF6
- GPIO_AF7
- GPIO_AF8
- GPIO_AF9
- GPIO_AF10
- GPIO_AF11
- GPIO_AF12
- GPIO_NO_AF NO alternate Function mapping
return none
note PB3/PB4/PB5 can be configured with IO toggle rate and drive capability,
requiring the call of GPIOB_Driver_Set and GPIOB_SlewRate_Set function.
void GPIO_InitStruct(GPIO_InitType* GPIO_InitStruct)Assign default values to each GPIO_InitType member.
name GPIO_InitStruct.
fun Assign default values to each GPIO_InitType member.
param GPIO_InitStructure :
pointer to GPIO_InitType structure.
return none
uint8_t GPIO_ReadInputDataBit(GPIO_Module* GPIOx, uint16_t Pin)Get the pin status on the specified input port.
name GPIO_ReadInputDataBit.
fun Get the pin status on the specified input port.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
return the pin state on the input port.
uint16_t GPIO_ReadInputData(GPIO_Module* GPIOx)Get the input data on the designated GPIO port.
name GPIO_ReadInputData.
fun Get the input data on the designated GPIO port.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
return the data value on the GPIO input port.
uint8_t GPIO_ReadOutputDataBit(GPIO_Module* GPIOx, uint16_t Pin)Get the pin status on the specified output port.
name GPIO_ReadOutputDataBit.
fun Get the pin status on the specified output port.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
return the pin state on the output port.
uint16_t GPIO_ReadOutputData(GPIO_Module* GPIOx)Get the output data on the designated GPIO port.
name GPIO_ReadOutputData.
fun Get the output data on the designated GPIO port.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
return the data value on the GPIO output port.
void GPIO_SetBits(GPIO_Module* GPIOx, uint16_t Pin)Sets the selected data port bits.
name GPIO_SetBits.
fun Sets the selected data port bits.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
return none
void GPIO_WritePBSC(GPIO_Module* GPIOx, uint16_t Pin,uint8_t bitstatus)Sets the selected data port bits using PBSC.
name GPIO_WritePBSC.
fun Sets the selected data port bits using PBSC.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
param bitstatus :
- Bit_SET
- Bit_RESET
return none
void GPIO_ResetBits(GPIO_Module* GPIOx, uint16_t Pin)Reset the selected data port bits.
name GPIO_ResetBits.
fun Reset the selected data port bits.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
return none
void GPIO_WriteBit(GPIO_Module* GPIOx, uint16_t Pin, Bit_OperateType BitCmd)Reset the selected data port bits.
name GPIO_WriteBit.
fun Reset the selected data port bits.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
param BitCmd :
- Bit_RESET
- Bit_SET
return none
Use note: The fun field in this comment is written as “Reset the selected data port bits.”, which does not match the implementation: the selected pin is set when BitCmd is Bit_SET and reset when it is Bit_RESET; the declaration is on line 235 of n32g033_gpio.h.
void GPIO_Write(GPIO_Module* GPIOx, uint16_t PortVal)Write data on the designated GPIO data port.
name GPIO_Write.
fun Write data on the designated GPIO data port.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param data_value :
the value to be written to the port output data register.
- 0~0xFFFF
return none
void GPIO_TogglePin(GPIO_Module* GPIOx, uint16_t Pin)Toggle the specified port pin level.
name GPIO_TogglePin.
fun Toggle the specified port pin level.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
return none
void GPIO_ConfigPinLock(GPIO_Module* GPIOx, uint16_t Pin)GPIO port lock register configuration.
name GPIO_ConfigPinLock.
fun GPIO port lock register configuration.
param GPIOx :
- GPIOA
- GPIOB
- GPIOF
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
return none
void GPIO_ConfigEXTILine(uint8_t PortSource, uint8_t PinSource)Selects the GPIO pin used as EXTI Line. A single EXTI line can only be configured with a single pin.
name GPIO_ConfigEXTILine.
fun Selects the GPIO pin used as EXTI Line. A single EXTI line can only be configured with a single pin.
param PortSource :
- GPIOA_PORT_SOURCE
- GPIOB_PORT_SOURCE
- GPIOF_PORT_SOURCE
param PinSource :
- GPIO_PIN_SOURCE0
- GPIO_PIN_SOURCE1
- GPIO_PIN_SOURCE2
- GPIO_PIN_SOURCE3
- GPIO_PIN_SOURCE4
- GPIO_PIN_SOURCE5
- GPIO_PIN_SOURCE6
- GPIO_PIN_SOURCE7
- GPIO_PIN_SOURCE8
- GPIO_PIN_SOURCE9
- GPIO_PIN_SOURCE10
- GPIO_PIN_SOURCE11
- GPIO_PIN_SOURCE12
- GPIO_PIN_SOURCE13
- GPIO_PIN_SOURCE14
- GPIO_PIN_SOURCE15
return none
void GPIO_ClearEXTILine( uint8_t LineSource)Clear the GPIO pin used as EXTI Line.
name GPIO_ClearEXTILine.
fun Clear the GPIO pin used as EXTI Line.
param LineSource :
- GPIO_EXTILINE_SOURCE0
- GPIO_EXTILINE_SOURCE1
- GPIO_EXTILINE_SOURCE2
- GPIO_EXTILINE_SOURCE3
- GPIO_EXTILINE_SOURCE4
- GPIO_EXTILINE_SOURCE5
- GPIO_EXTILINE_SOURCE6
return none
void AFIO_ConfigEXTIFlitEN(FunctionalState Cmd)Configure IO filter number in APB clock.
name AFIO_ConfigIOFlitNum.
fun Configure IO filter number in APB clock.
param Cmd :
- ENABLE
- DISABLE
return none
Use note: The name field in this comment is written as AFIO_ConfigIOFlitNum., which does not match the function name AFIO_ConfigEXTIFlitEN; the declaration is on line 241 of n32g033_gpio.h.
void GPIO_ConfigPinRemap(uint8_t PortSource, uint8_t PinSource, uint32_t AlternateFunction)Pin remapping configuration.
name GPIO_ConfigPinRemap.
fun Pin remapping configuration.
param PortSource :
- GPIOA_PORT_SOURCE
- GPIOB_PORT_SOURCE
- GPIOF_PORT_SOURCE
param PinSource :
- GPIO_PIN_SOURCE0
- GPIO_PIN_SOURCE1
- GPIO_PIN_SOURCE2
- GPIO_PIN_SOURCE3
- GPIO_PIN_SOURCE4
- GPIO_PIN_SOURCE5
- GPIO_PIN_SOURCE6
- GPIO_PIN_SOURCE7
- GPIO_PIN_SOURCE8
- GPIO_PIN_SOURCE9
- GPIO_PIN_SOURCE10
- GPIO_PIN_SOURCE11
- GPIO_PIN_SOURCE12
- GPIO_PIN_SOURCE13
- GPIO_PIN_SOURCE14
- GPIO_PIN_SOURCE15
param AlternateFunction :
- GPIO_AF0
- GPIO_AF1
- GPIO_AF2
- GPIO_AF3
- GPIO_AF4
- GPIO_AF5
- GPIO_AF6
- GPIO_AF7
- GPIO_AF8
- GPIO_AF9
- GPIO_AF10
- GPIO_AF11
- GPIO_AF12
- GPIO_NO_AF NO alternate Function mapping
return none
void AFIO_ConfigADCExternalTrigRemap(AFIO_ADC_Trig_RemapType ADC_trigger)Configurate ADC external trigger.
name AFIO_ConfigADCExternalTrigRemap.
fun Configurate ADC external trigger.
param ADC_trigger :
specifies the external trigger line be configured.
- AFIO_ADC_TRIG_EXTI_0
- AFIO_ADC_TRIG_EXTI_1
- AFIO_ADC_TRIG_EXTI_2
- AFIO_ADC_TRIG_EXTI_3
- AFIO_ADC_TRIG_EXTI_4
- AFIO_ADC_TRIG_EXTI_5
- AFIO_ADC_TRIG_EXTI_6
return none
void AFIO_ConfigSPINSSMode(uint32_t AFIO_SPIx_NSS, uint32_t SpiNssMode)Selects the alternate function SPIx NSS mode.
name AFIO_ConfigSPINSSMode.
fun Selects the alternate function SPIx NSS mode.
param AFIO_SPIx_NSS :
choose which SPI configuration.
- AFIO_SPI1_NSS
- AFIO_SPI2_NSS
param SpiNssMode :
specifies the SPI_NSS mode to be configured.
- AFIO_SPI_NSS_HIGH_IMPEDANCE
- AFIO_SPI_NSS_High_LEVEL
return none
void AFIO_ConfigIOFlitNum(uint8_t Flit_Num)Configure IO filter number in APB clock.
name AFIO_ConfigIOFlitNum.
fun Configure IO filter number in APB clock.
param Flit_Num :
- 0~7
return none
void AFIO_DIGEFTEnable(uint8_t PortSource, uint16_t Pin, FunctionalState Cmd)Enables or disable digital EFT of port pins.
name AFIO_DIGEFTEnable.
fun Enables or disable digital EFT of port pins.
param PortSource :
- GPIOA_PORT_SOURCE
- GPIOB_PORT_SOURCE
- GPIOF_PORT_SOURCE
param Pin :
- GPIO_PIN_0
- GPIO_PIN_1
- GPIO_PIN_2
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
- GPIO_PIN_6
- GPIO_PIN_7
- GPIO_PIN_8
- GPIO_PIN_9
- GPIO_PIN_10
- GPIO_PIN_11
- GPIO_PIN_12
- GPIO_PIN_13
- GPIO_PIN_14
- GPIO_PIN_15
- GPIO_PIN_ALL
param Cmd :
- ENABLE
- DISABLE
return none
void GPIOB_Driver_Set(uint32_t current, uint32_t GPIO_Pin)GPIOB driver configuration.
name GPIOB_Driver_Set.
fun GPIOB driver configuration.
param current
- GPIOB_HIGH_DREIVE
- GPIOB_LOW_DREIVE
param GPIO_Pin
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
return none
void GPIOB_SlewRate_Set(uint32_t slew_rate, uint32_t GPIO_Pin)GPIOB slew rate configuration.
name GPIOB_SlewRate_Set.
fun GPIOB slew rate configuration.
param slew_rate
- GPIOB_SLEW_RATE_FAST
- GPIOB_SLEW_RATE_SLOW
param GPIO_Pin
- GPIO_PIN_3
- GPIO_PIN_4
- GPIO_PIN_5
return none
5.8.3 Demo descriptions
This section describes the single GPIO example: LedBlink drives the LEDs from three GPIO pins and toggles and switches them on a fixed rhythm, showing initialization, bit operations, and port writes.
5.8.3.1 LedBlink LED blinking
Example directory: projects/n32g033_EVAL/examples/GPIO/LedBlink/
Enable the GPIO clock→Configure the three LED pins as push-pull outputs→Light the three LEDs→Toggle and switch each LED from the main loop with a delay
| Item | Source analysis |
|---|---|
| Function | Drives the LEDs on PA6, PA7, and PB1 and toggles and switches them on a fixed rhythm, showing bit operations and port writes. |
| Source files | src/main.c holds the four helpers LedInit, LedOn, LedOff, and LedBlink plus the main loop;inc/main.h defines the port and pin macros for the three LEDs;the project files are in MDK-ARM/ and EWARM/, and readme.txt gives the configuration and test steps. |
| Key configuration | LED1 on PA6, LED2 on PA7, and LED3 on PB1, all push-pull outputs; the system clock is 64 MHz; each main-loop step waits 1000 ms. |
| Program and data path | main -> LedInit enables the GPIO clock and initializes the three pins as GPIO_MODE_OUTPUT_PP -> LedOn lights the three LEDs -> the main loop switches each LED with LedBlink, LedOff, and LedOn and waits with SysTick_Delay_Ms on each step. |
| Main APIs | GPIO_InitStruct, GPIO_InitPeripheral, GPIO_SetBits, GPIO_ResetBits, GPIO_TogglePin |
| Verification | Compile, download, and reset; on the board the three LEDs D1, D2, and D3 blink in turn. |
| Use note | The development environment is KEIL MDK-ARM V5.34.0.0 or IAR EWARM 8.50.1 on the N32G033K8Q7-1_STB V1.0 evaluation board; the system clock is 64 MHz. |
Core-code walkthrough and porting
The example wraps LED initialization and the on, off, and toggle actions into four helpers, then combines them in the main loop to blink the LEDs.
Data path: LedInit enables the GPIO clock and configures the pins as push-pull outputs with GPIO_InitStruct and GPIO_InitPeripheral → LedOn lights them through GPIO_SetBits → the main-loop LedBlink, LedOff, and LedOn change the pin states through GPIO_TogglePin, GPIO_ResetBits, and GPIO_SetBits → SysTick_Delay_Ms sets the rhythm
1. The LED initialization wraps structure setup and peripheral configuration. It assigns defaults, sets the pin and push-pull mode, and then applies the configuration.
void LedInit(GPIO_Module* GPIOx, uint16_t Pin)
{
GPIO_InitType GPIO_InitStructure;
/* Enable the GPIO Clock */
RCC_EnableAPBPeriphClk(RCC_APB_PERIPH_GPIO, ENABLE);
/* Configure the GPIO pin */
if (Pin <= GPIO_PIN_ALL)
{
GPIO_InitStruct(&GPIO_InitStructure);
GPIO_InitStructure.Pin = Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitPeripheral(GPIOx, &GPIO_InitStructure);
}
}
Call GPIO_InitStruct to assign defaults before you change GPIO_Mode and GPIO_Pull; otherwise a leftover value can put the pin into another mode.
2. The bit-operation helpers map on, off, and toggle to the library functions. Each helper acts on one pin and leaves the other pins of the same port unchanged.
void LedOn(GPIO_Module *GPIOx, uint16_t Pin)
{
GPIO_SetBits(GPIOx, Pin);
}
void LedOff(GPIO_Module* GPIOx, uint16_t Pin)
{
GPIO_ResetBits(GPIOx, Pin);
}
void LedBlink(GPIO_Module* GPIOx, uint16_t Pin)
{
GPIO_TogglePin(GPIOx, Pin);
}
LED1 and LED2 share GPIOA, and the bit operations act per pin, so these helpers can be reused directly in a multi-LED design.
3. The main loop switches each LED with a delay. Each step waits 1000 ms, so changing the delay changes the blinking rhythm.
while (1)
{
/*LED1_PORT, LED2_PORT and LED3_PORT are the same port group.
*Enable Led2 blink and not effect Led1 and Led2 by Exclusive-OR operation.*/
LedBlink(LED2_PORT, LED2_PIN);
/*LED1_PORT, LED2_PORT and LED3_PORT are the same port group.
*Turn Led3 off and not effect other ports by PBC register, correspond to PORT_GROUP->POD &= ~LED3_PIN*/
LedOff(LED3_PORT, LED3_PIN);
/* Insert delay */
SysTick_Delay_Ms(1000);
/*Turn Led1 off and not effect other ports by PBC register, correspond to PORT_GROUP->POD &= ~LED1_PIN*/
LedOff(LED1_PORT, LED1_PIN);
/* Insert delay */
SysTick_Delay_Ms(1000);
/*Turn on Led1 and Led3*/
LedOn(LED1_PORT, LED1_PIN);
LedOn(LED3_PORT, LED3_PIN);
/* Insert delay */
SysTick_Delay_Ms(1000);
}
The loop toggles LED2 and switches LED1 and LED3 on and off, so split different indication logic along those lines when porting.
Corresponding source files: src/main.c, inc/main.h, firmware/n32g033_std_periph_driver/inc/n32g033_gpio.h
5.8.4 Notes and troubleshooting
| Scenario | Check & action | Source |
|---|---|---|
| Register access width | The GPIO and AFIO chapter of the user manual states that the GPIO registers must be accessed as 32-bit words and that 16-bit halfword and 8-bit byte access is not supported; avoid byte or halfword reads and writes of the GPIO registers when porting. |
User manual |
| Default mode after reset | The GPIO and AFIO chapter of the user manual states that, except for NRST, the SWD pins, and PF2, every GPIO is in analog mode after reset; configure a pin explicitly before you use it as a digital input or output. |
User manual |
| A locked pin cannot be changed | The GPIO and AFIO chapter of the user manual states that the lock sequence is write 1, write 0, write 1, read 0, and that a locked pin keeps its configuration until reset; do not lock a pin that must stay reconfigurable. |
User manual |
| Pin grouping of the EXTI lines | The GPIO and AFIO chapter of the user manual states that each EXTI line maps to a group of pins and only one of them can be selected at a time; confirm the target pin matches the EXTI line number before you select it. |
User manual |
| Port direction for external interrupts | The Interrupts and events chapter of the user manual states that a port must work in input mode to generate an interrupt; do not forget the input mode when you use EXTI triggering. |
User manual |
Errata sheet V1.0.0 (2025.9.25) covers revision A silicon and lists no GPIO entries.