Basic Custom Code

<< Click to Display Table of Contents >>

Navigation:  STM32F4 Target > Demos > Waijung Demos >

Basic Custom Code

Previous pageReturn to chapter overviewNext page

demo File: stm32f4_customcode_demo.mdl




This example demonstrates how to use the Basic Custom Code Block. The example toggles the 4 LEDs on STM32F4DISCOVERY board as follows.

When a user presses the user button B1 (Blue button):

1. LD3 (Orange) and LD6 (Blue) OFF

2. LD5 (Red) and LD4 (Green) ON

When a user releases the user button B1 (Blue button):

1. LD3 (Orange) and LD6 (Blue) ON

2. LD5 (Red) and LD4 (Green) OFF


Basic Custom Code Demo


The source codes that initialises the hardware (GPIO module) and for the algorithm that toggles the IO pins are defined in the Basic Custom Code Block.

Note: PA0 of STM32F4DISCOVERY is connected to the user button.

Software Setup

1. In this example there are two custom code files: stm32f4_io_customcode.h and stm32f4_io_customcode.c as shown below.



2. "Basic Custom Code" block is configured as shown.



3. The Custom Code Block code generation mechanism uses your configuration information in the Custom Code Block mask above to create corresponding "function wrapper" in the model_step() function and the waijung_hwdrvlib.h and waijung_hwdrvlib.c functions as shown below.

Model Step Function









Hardware Setup

Standard STM32F4DISCOVERY board.