当前位置:网站首页>Test enumeration types with STM32 platform running RT thread
Test enumeration types with STM32 platform running RT thread
2022-06-30 07:18:00 【liwuxing】
An enumeration type describes a collection of integer values , It is convenient to use descriptions to use corresponding values . If you need to modify an enumeration member ( Constant ) Value , You can directly modify the enumeration type definition .
About enumeration types ( Enumeration label )、 Members of the enumeration ( Enumeration constants )、 Enumerate variables :

enum Example : Enumeration members are defined as INT type (4 byte ) The number number of , The number can be repeated ; Usually from 0 Add... In sequence 1; Or define yourself .
The value range of an enumeration variable should normally be one of the enumeration members of the corresponding enumeration type .
Utilization operation rt-thread Of stm32 platform , You can test enumeration types with the following sample code .
#include <rtthread.h>
#define INT_MIN -2147483648 //80000000
#define INT_MAX 2147483647 //7FFFFFFF
enum test{m1=INT_MIN,m1_1,m2=33,m2_1,m3=INT_MAX,m4=33};
int enum_test(void)
{
rt_kprintf(" Enumerate application examples \n");
rt_kprintf("%d\n%d\n%d\n%d\n%d\n%d\n", m1,m1_1,m2,m2_1,m3,m4);
rt_kprintf(" Enumerate application examples 2\n");
rt_kprintf("%d\n%d\n",(int)INT_MIN,(int)INT_MAX);
enum test test1,test2,test3;
test1=m2_1;
test2=m3;
test3=11; // Illegal use ,MDK Compile time warnings , But I don't think it's wrong .
rt_kprintf("%d\n%d\n%d\n",test1,test2,test3);
return 0;
}
/* Export to msh In the command list */
MSH_CMD_EXPORT(enum_test, test enum app.);
Debug serial port output :

\ | /
- RT - Thread Operating System
/ | \ 4.0.2 build Feb 12 2022
2006 - 2019 Copyright by rt-thread team
turn off LED!
msh >enum_test
Enumerate application examples
-2147483648
-2147483647
33
34
2147483647
33
Enumerate application examples 2
-2147483648
2147483647
34
2147483647
11
msh >
边栏推荐
- 将本地电脑文件复制到虚拟机系统中详细方法
- 套接字socket编程——UDP
- Determine whether the picture is in JPG picture format
- Stm32g0 porting FreeRTOS
- Cubemx completes STM32F103 dual serial port 485 transceiver transmission
- Linux服務器安裝Redis
- 【SemiDrive源码分析】【X9芯片启动流程】33 - Display模块 相关概念解析
- Pit stepping record: Supervisor log return information: redis extension is not installed
- Network security - layer 3 switching technology and internal network planning
- The class imported by idea import clearly exists, but it is red?
猜你喜欢
随机推荐
Go常用命令
【申博攻略】五.专家推荐信模板
视频播放器(二):视频解码
vs2019和sql
Golan common shortcut key settings
Resolved: initialize specified but the data directory has files in it Aborting
grep命令用法
grep命令用法
IDEA import导入的类明明存在,却飘红?
[semidrive source code analysis] [x9 chip startup process] 34 - RTOS side display module SDM_ display_ Init display initialization source code analysis
Network security ARP protocol and defense
单测调用对象的私有方法
Swiftui creates a beautiful custom press feedback button
Binary tree traversal
01 - embedded learning route and career planning: embedded basic knowledge and development process
02 - bare metal and RTOS development modes: five development modes of bare metal and the introduction of RTOS
记录开发过程中无法使用管理员身份修改系统文件问题
Resolution: div failed to get keyboard event
The most convenient serial port screen chip scheme designed at the charging pile in China
js创建pdf文件









