Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Run the blink routine on the Developerkit development board

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article describes how to run the blink routines provided by AliOS Tings on the Developerkit development board in the VScode environment.

Cdn.com/413f8cd9e7ea5426c663ce40bb9ab8b3efc03556.png ">

DeveloperKit development board

Two led and a button are used in the routine, which are marked with a red box in the image above. After the routine runs correctly, one LED flashes for a period of 1 second, and the other LED switches the output level when the key is pressed. In this article, the allocation of each hardware is as follows:

Peripheral name

Corresponding gpio

Functions in the experiment

LED1

PB6

Blinks once per second

LED2

PE3

Switch the output level when a key is detected

Button M

PE11

Through the interrupt detection, we enter the code next, and modify the source code according to the specific hardware corresponding pins.

Open the AliOS-Things 2.0 source code with VS CODE. If you do not have the AliOS-Things source code, you can pull it from the VS code console through the git tool. The pull command is as follows:

Git clone https://github.com/alibaba/AliOS-Things.git

After opening the source code, we open blink.c in the app/example/blink directory of the source code, and find several macro definitions at the top of the source code as follows:

# define GPIO_LED_IO 18#define GPIO_TRIGGER_IO 4#define GPIO_INPUT_IO 5

The above macro definitions need to correspond to our actual hardware, as shown in the table below:

Macro definition

Corresponding hardware

Actual IO port

Pin number in OS

Functions in the experiment

GPIO_LED_IO

LED1

PB6

twenty-two

Blinks once per second

GPIO_TRIGGER_IO

LED2

PE3

sixty-seven

Switch the output level when a key is detected

GPIO_INPUT_IO

Button M

PE11

seventy-five

Detect keys by interrupt mode

Because AliOS-Things abstracts the hardware, the operation of GPIO needs to convert the GPIO of MCU into numbering according to certain rules. The conversion rule is the GPIO bank number X 16 of MCU + the location of the specific gpio in the bank, and the number of the bank starts at 0. If PB6, whose bank number is 1 and position in bank is 6, PB6 should be converted to 1 X 16 + 6 = 22; similarly, PE3=4 x 16 + 3 = 67. Because the routine is not written for the Developerkit development board, the first macro in the routine needs to be modified as follows:

# define GPIO_LED_IO 67 / / PE3#define GPIO_TRIGGER_IO 22 / / PB6#define GPIO_INPUT_IO 75 / / PE11

When you are finished, save the blink.c file.

In the VS CODE environment, in the alios-studio in the lower left corner, click the compile target selection button

The command input box at the top of the editor will pop up to select the target to compile, select blink at this time

Immediately after that, you will continue to ask to select the development board, and select the Developerkit development board at this time.

Next, start the compilation through the compile button of the alios-studio toolbar.

Wait for the compilation to complete.

Making blink@developerkit.binMaking blink@developerkit.hex AOS MEMORY MAP | = | MODULE | ROM | RAM | | = | newlib_stub | 296 | 0 | | sal | 6977 | 250 | | kv | | 3055 | 3055 | common | 256 | 12 | | libc_nano | 19649 | 602 | | kernel_init | 653 | 36 | | rhino | | | 16225 | 7821 | | developerkit | 5045 | 1403 | | vfs | 950 | 1141 | | digest_algorithm | 92 | 0 | libgcc | 3320 | 0 | | stm32l4xx_cube | | | 26592 | 8506 | | cli | 6234 | 357 | | yloop | 2369 | 28 | | device_sal_bk7231 | 8542 | 8542 | sensor | | | 9451 | 303 | | osal | 1074 | 4 | | log | 412 | 20 | | hal | 16412 | 12 | blink | 325 | | | 24 | | atparser | 5882 | 297 | | armv7m | 1975 | 0 | * fill* | 1599 | = | | TOTAL (bytes) | 119688 | 22784 | | = | Build complete |

Connect the Developerkit to the PC to ensure that the STlink driver of the development board is installed correctly.

Download the compiled firmware to the development board through the download button in the alios-studio toolbar.

After burning and writing, the development board will run automatically, and you can see that the LED starts flashing at intervals of 1 second. Press the "M" button on the board and LED2 will switch the output. It should be pointed out here that blink Demo mainly demonstrates the HAL layer operation function of GPIO, and does not press the key to jitter, so when clicking the button, it may appear to press LED2 once and switch directly twice. Please also pay attention to the ability of keystroke to shake in the actual code design. At this point, the routine has completed running successfully.

Author: Ba people.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report