Type & Object attribute

本文详细介绍了在ARM体系中使用的类型属性与对象属性的概念及其语法。类型属性定义了函数调用的方式或数据对象的访问方式,而对象属性则影响函数和数据对象的内部功能。文章还提供了使用这些属性的具体示例。

Type attributes

Type attributes define how a function is called, or how a data object is accessed. This means that if you use a type attribute, it must be specified both when a function or data object is defined and when it is declared.

You can either place the type attributes directly in your source code, or use the pragma directive #pragma type_attribute.

The following general type attributes are available:

    • Function type attributes affect how the function should be called: __arm, __fiq, __interwork, __irq, __swi, and __thumb
    • Data type attributes: __big_endian, const, __little_endian, __packed, and volatile

You can specify as many type attributes as required for each level of pointer indirection.

To read more about the type qualifiers const and volatile, see the IAR C/C++ Development Guide for ARM®.

Syntax for type attributes used on data objects

In general, type attributes for data objects follow the same syntax as the type qualifiers const and volatile.

The following declaration assigns the __little_endian type attribute to the variables i and j; in other words, the variables i and j will be accessed with little endian byte order. The variables k and l behave in the same way:

__little_endian int i, j; 
int __little_endian k, l; 

Note that the attribute affects both identifiers.

The following declaration of i and j is equivalent with the previous one:

#pragma type_attribute=__little_endian 
int i, j; 

The advantage of using pragma directives for specifying keywords is that it offers you a method to make sure that the source code is portable. Note that the pragma directive has no effect if a memory attribute is already explicitly declared.

Syntax for type attributes on data pointers

The syntax for declaring pointers using type attributes follows the same syntax as the type qualifiers const and volatile:

int __little_endian * p;
 
The int object will be accessed in little endian byte order.
int * __little_endian p;
 
The pointer will be accessed in little endian byte order.
__little_endian int * p;
 
The pointer will be accessed in little endian byte order.

Syntax for type attributes on functions

The syntax for using type attributes on functions differs slightly from the syntax of type attributes on data objects. For functions, the attribute must be placed either in front of the return type, or in parentheses, for example:

__irq __arm void my_handler(void); 

or

void (__irq __arm my_handler)(void); 

The following declaration of my_handler is equivalent with the previous one:

#pragma type_attribute=__irq __arm 
void my_handler(void); 
 
 

Object attributes

Object attributes affect the internal functionality of functions and data objects, but not how the function is called or how the data is accessed. This means that an object attribute does not need to be present in the declaration of an object.

The following object attributes are available:

    • Object attributes that can be used for variables: __no_init
    • Object attributes that can be used for functions and variables: location, @, __root, and __weak,
    • Object attributes that can be used for functions: __intrinsic, __nested, __noreturn, and __ramfunc.

You can specify as many object attributes as required for a specific function or data object.

For more information about location and @, see the IAR C/C++ Development Guide for ARM®.

Syntax for object attributes

The object attribute must be placed in front of the type. For example, to place myarray in memory that is not initialized at startup:

__no_init int myarray[10];  

The #pragma object_attribute directive can also be used. The following declaration is equivalent to the previous one:

#pragma object_attribute=__no_init 
int myarray[10]; 
基于实时迭代的数值鲁棒NMPC双模稳定预测模型(Matlab代码实现)内容概要:本文介绍了基于实时迭代的数值鲁棒非线性模型预测控制(NMPC)双模稳定预测模型的研究与Matlab代码实现,重点在于提升系统在存在不确定性与扰动情况下的控制性能与稳定性。该模型结合实时迭代优化机制,增强了传统NMPC的数值鲁棒性,并通过双模控制策略兼顾动态响应与稳态精度,适用于复杂非线性系统的预测控制问题。文中还列举了多个相关技术方向的应用案例,涵盖电力系统、路径规划、信号处理、机器学习等多个领域,展示了该方法的广泛适用性与工程价值。; 适合人群:具备一定控制理论基础和Matlab编程能力,从事自动化、电气工程、智能制造、机器人控制等领域研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于非线性系统的高性能预测控制设计,如电力系统调度、无人机控制、机器人轨迹跟踪等;②解决存在模型不确定性、外部扰动下的系统稳定控制问题;③通过Matlab仿真验证控制算法的有效性与鲁棒性,支撑科研论文复现与工程原型开发。; 阅读建议:建议读者结合提供的Matlab代码进行实践,重点关注NMPC的实时迭代机制与双模切换逻辑的设计细节,同时参考文中列举的相关研究方向拓展应用场景,强化对数值鲁棒性与系统稳定性之间平衡的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值