Specification of Bit Handling Library (BFXLibrary)¶
| 属性 | 值 |
|---|---|
| 平台 | CP |
| 类别 | SWS — 软件模块规范(Software Specification) |
| UID | 399 |
| 规范版本 | R25-11 |
本地文件¶
- 规范 PDF:
F:\Work\Standards\01_Sources\CP_SWS_BFXLibrary_399\AUTOSAR_CP_SWS_BFXLibrary.pdf - ARXML 模型:
F:\Work\Standards\01_Sources\CP_SWS_BFXLibrary_399\AUTOSAR_CP_SWS_BFXLibrary.arxml - 纯文本全文:
F:\Work\Standards\01_Sources\CP_SWS_BFXLibrary_399\zzgen\CP_SWS_BFXLibrary.complete.txt
文档简介¶
AUTOSAR Library routines are the part of system services in AUTOSAR architecture and below figure shows position of AUTOSAR library in layered architecture.
Bfx routines specification specifies the functionality and API of the AUTOSAR library for bit functionality dedicated to fixed-point arithmetic routines.
All Bfx routines are re-entrant and can handle several simultaneous requests from different users.
模块依赖¶
The Bfx Library has no dependency to other modules.
章节详细内容¶
1. 简介与功能概述¶
原文标题:Introduction and functional overview
AUTOSAR Library routines are the part of system services in AUTOSAR architecture and below figure shows position of AUTOSAR library in layered architecture.
Bfx routines specification specifies the functionality and API of the AUTOSAR library for bit functionality dedicated to fixed-point arithmetic routines.
All Bfx routines are re-entrant and can handle several simultaneous requests from different users.
2. 缩略语¶
原文标题:Acronyms and Abbreviations
The glossary below includes acronyms and abbreviations relevant to the Bfx Library that are not included in the .
| Abbreviation / Acronym: | Description: |
|---|---|
| Bfx | Short name for Bitfield functions for fixed point |
3. 相关文档¶
原文标题:Related documentation
4. 输入文档与相关标准规范¶
原文标题:Input documents & related standards and norms
5. 相关规范¶
原文标题:Related specification
AUTOSAR provides a General Specification on Basic Software modules , which is also valid for Bfx Library.
Thus, the specification SWS BSW General shall be considered as additional and required specification for Bfx Library.
6. 约束与假设¶
原文标题:Constraints and assumptions
7. 限制¶
原文标题:Limitations
No limitations
8. 适用的车型领域¶
原文标题:Applicability to car domains
No restrictions
9. 对其他模块的依赖¶
原文标题:Dependencies to other modules
The Bfx Library has no dependency to other modules.
10. 文件结构¶
原文标题:File structure
An implementation of the Bfx Library shall follow the naming rules for files outined in .
11. 需求追踪¶
原文标题:Requirements Tracing
The following tables reference the requirements specified in and and links to the fulfillment of these.
| Requirement | Description | Satisfied by |
|---|---|---|
| Each library shall provide one header file with its public interface | ||
| All library functions shall be re-entrant | ||
| All function names and type names shall start with "Library short name_" | ||
| It shall be possible to configure the microcontroller so that the library code is shared between all callers | ||
| Usage of macros should be avoided | ||
| A library function may only call library functions |
12. 功能规范¶
原文标题:Functional specification
13. 初始化 and 关机¶
原文标题:Initialization and shutdown
The Bfx Library does not provide a Init() function nor requires an initialization phase.
A function of the Bfx library may be called at the very first step of ECU initialization, e.g. even by the OS or EcuM, thus the library shall be ready. The only assumption of the Bfx Library regarding their context is that it assumes a completed C startup.
Also the Bfx Library does not require a shutdown operation phase.
14. Using 库 API¶
原文标题:Using Library API
The Bfx Library functions (APIs) can be directly called from BSW modules or SWC.
Using a library should be documented. If a BSW module or a SWC uses the Bfx Library, the developer should add an Implementation-DependencyOnArtifact in the BSW/SWC template.
15. 库 implementation¶
原文标题:Library implementation
Upstream requirements: ⌈ The Bfx library shall be implemented in a way that the code can be shared among callers in different memory partitions. ⌋
Upstream requirements: ⌈ Usage of C macros shall be avoided in the context of Bfx Library. The library functions shall be declared as function or as inline function. ⌋
This means that the routine shall not be realized as C macro (i.e. not using a #define).
Upstream requirements: ⌈ A Bfx Library function shall not call any BSW module functions, e.g. the DET. A library function can call any other library functions since all library functions are re-entrant. ⌋
⌈ All Bfx Library functions shall avoid handling user faults and values outside specified range. Providing input values which are outside the specified range results in undefined behavior. ⌋
Note: Example of such undefined behavior is calling Bfx_SetBit_u8u8 with a value of 8 (or higher) as bit position argument.
16. 错误分类¶
原文标题:Error Classification
Chapter describes the error handling of the Basic Software in detail. Above all, it constitutes a classification scheme consisting of four error types which may occur in BSW modules.
Based on this foundation, the following section specifies particular errors arranged in the respective subsections below.
17. Development 错误¶
原文标题:Development Errors
There are no development errors.
18. Runtime 错误¶
原文标题:Runtime Errors
There are no runtime errors
19. Production 错误¶
原文标题:Production Errors
There are no production errors.
20. Extended Production 错误¶
原文标题:Extended Production Errors
There are no extended production errors.
21. API 规范¶
原文标题:API specification
22. Imported 类型¶
原文标题:Imported types
Definition of imported datatypes of module Bfx ⌈ | Module | Header File | Imported Type | |---|---|---| | There are no imported types. | < | < |
⌋
It is observed that since the sizes of the integer types provided by the C language are implementation-defined, the range of values that may be represented within each of the integer types will vary between CPU architectures and their compilers.
Thus, in order to improve the portability of the software, the types are defined in are used. The following mnemonic(s) are used in the library routine names to express the variablity.
Note: The naming convention for the API's with boolean return type/parameter type is given as _u8 which shall be interpreted as boolean. If there is no boolean data type present in the return type/parameter type then _u8 shall be interpreted as _uint8 only.
| Size | Platform Type | Mnemonic |
|---|---|---|
| unsigned 8-Bit | boolean | u8 |
| signed 8-Bit | sint8 | s8 |
| signed 16-Bit | sint16 | s16 |
| signed 32-Bit | sint32 | s32 |
| signed 64-Bit | sint64 | s64 |
| unsigned 8-Bit | uint8 | u8 |
| unsigned 16-Bit | uint16 | u16 |
| unsigned 32-Bit | uint32 | u32 |
| unsigned 64-Bit | uint64 | u64 |
The ranges of these types can be found in .
……本章内容较长已节选,完整内容见「本地文件」中的纯文本全文。
23. 类型定义¶
原文标题:Type definitions
None
24. Comment about functions optimized for target¶
The functions described in this library may be realized as regular functions or as inline functions.
25. Bit functions 定义¶
原文标题:Bit functions definitions
26. Bfx_SetBit¶
Definition of API function Bfx_SetBit_
⌋
Expected functionality:
| *Data = *Data | (0x01 BitPn) |
|---|---|
Example:
Data = 10001010b;
Bfx_SetBit_u8u8(&Data, 2);
The Data will be updated to 10001110b
List of Bfx_SetBit functions
⌈
| Service ID | Function prototype | Valid values for parameter BitPn |
|---|---|---|
| 0x01 | void Bfx_SetBit_u8u8(uint8, uint8) | 0,1,2,..,7 |
| 0x02 | void Bfx_SetBit_u16u8(uint16, uint8) | 0,1,2,..,15 |
| 0x03 | void Bfx_SetBit_u32u8(uint32, uint8) | 0,1,2,..,31 |
| 0x04 | void Bfx_SetBit_u64u8(uint64, uint8) | 0,1,2,..,63 |
⌋
27. Bfx_ClrBit¶
Definition of API function Bfx_ClrBit_
⌋
Expected functionality:
Data = (Data & ~(0x01 BitPn))
Example:
Data = 10001010b;
Bfx_ClrBit_u8u8(&Data, 1);
The Data will be updated to 10001000b
List of Bfx_ClrBit functions
⌈
| Service ID | Function prototype | Valid values for parameter BitPn |
|---|---|---|
| 0x06 | void Bfx_ClrBit_u8u8(uint8, uint8) | 0,1,2,..,7 |
| 0x07 | void Bfx_ClrBit_u16u8(uint16, uint8) | 0,1,2,..,15 |
| 0x08 | void Bfx_ClrBit_u32u8(uint32, uint8) | 0,1,2,..,31 |
| 0x09 | void Bfx_ClrBit_u64u8(uint64, uint8) | 0,1,2,..,63 |
⌋
28. Bfx_GetBit¶
Definition of API function Bfx_GetBit_
⌋
Expected functionality:
if ((Data & (0x01 BitPn)) != 0) return TRUE; else return FALSE;
Example:
result = Bfx_GetBit_u8u8(10001010b, 1);
The result will be TRUE.
List of Bfx_GetBit functions
⌈
| Service ID | Function prototype | Valid values for parameter BitPn |
|---|---|---|
| 0x0A | boolean Bfx_GetBit_u8u8_u8(uint8,uint8) | 0,1,2,..,7 |
| 0x0B | boolean Bfx_GetBit_u16u8_u8(uint16,uint8) | 0,1,2,..,15 |
| 0x0C | boolean Bfx_GetBit_u32u8_u8(uint32,uint8) | 0,1,2,..,31 |
| 0x0D | boolean Bfx_GetBit_u64u8_u8(uint64,uint8) | 0,1,2,..,63 |
⌋
29. Bfx_SetBits¶
Definition of API function Bfx_SetBits_
⌋
Example:
Data = 1110100000000111b;
Bfx_SetBits_u16u8u8u8(&Data, 5, 5, 1);
Before the Bfx_SetBits_u16u8u8u8 function call Data contains this value:
The yellow fields mark those area which will be updated by the call (starting at bit position 5 and containing 5 bits). After the call the Data contains 1110101111100111b.
Another example setting bits to '0':
Value = 1110100000000111b;
Bfx_SetBits_u16u8u8u8(&Value, 0, 8, 0);
/_ Value is now 1110100000000000 _/
……本章内容较长已节选,完整内容见「本地文件」中的纯文本全文。
30. Bfx_GetBits¶
Definition of API function Bfx_GetBits_
⌋
Example:
result = Bfx_GetBits_u16u8u8_u16(1110100000000111b, 9, 5);
The result will be 0000000000010100b.
……本章内容较长已节选,完整内容见「本地文件」中的纯文本全文。
31. Bfx_SetBitMask¶
Definition of API function Bfx_SetBitMask_
⌋
Expected functionality:
| *Data = *Data | Mask |
|---|---|
List of Bfx_SetBitMask functions
⌈
| Service ID | Function prototype |
|---|---|
| 0x2A | void Bfx_SetBitMask_u8u8(uint8, uint8) |
| 0x2B | void Bfx_SetBitMask_u16u16(uint16, uint16) |
| 0x2C | void Bfx_SetBitMask_u32u32(uint32, uint32) |
| 0x2D | void Bfx_SetBitMask_u64u64(uint64, uint64) |
⌋
32. Bfx_ClrBitMask¶
Definition of API function Bfx_ClrBitMask_
⌋
⌈ This function shall clear the data to logical status '0' as per the corresponding mask bits value when set to 1. The remaining bits shall retain their original values. ⌋
Expected functionality:
*Data = *Data & ~Mask
List of Bfx_ClrBitMask functions
⌈
| Service ID | Function prototype |
|---|---|
| 0x30 | void Bfx_ClrBitMask_u8u8(uint8, uint8) |
| 0x31 | void Bfx_ClrBitMask_u16u16(uint16, uint16) |
| 0x32 | void Bfx_ClrBitMask_u32u32(uint32, uint32) |
| 0x33 | void Bfx_ClrBitMask_u64u64(uint64, uint64) |
⌋
33. Bfx_TstBitMask¶
Definition of API function Bfx_TstBitMask_
⌋
Expected functionality:
if ((Data & Mask) == Mask) return TRUE; else return FALSE;
Example:
result = Bfx_TstBitMask_u8u8_u8(10010011b,10010000b);
The result will be TRUE.
List of Bfx_TstBitMask functions
⌈
| Service ID | Function prototype |
|---|---|
| 0x36 | boolean Bfx_TstBitMask_u8u8_u8(uint8,uint8) |
| 0x37 | boolean Bfx_TstBitMask_u16u16_u8(uint16,uint16) |
| 0x38 | boolean Bfx_TstBitMask_u32u32_u8(uint32,uint32) |
| 0x39 | boolean Bfx_TstBitMask_u64u64_u8(uint64,uint64) |
⌋
34. Bfx_TstBitLnMask¶
Definition of API function Bfx_TstBitLnMask_
⌋
Example:
result = Bfx_TstBitLnMask_u8u8_u8(10010011b,10000111b);
The result will be TRUE.
List of Bfx_TstBitLnMask functions
⌈
| Service ID | Function prototype |
|---|---|
| 0x3A | boolean Bfx_TstBitLnMask_u8u8_u8(uint8,uint8) |
| 0x3B | boolean Bfx_TstBitLnMask_u16u16_u8(uint16,uint16) |
| 0x3C | boolean Bfx_TstBitLnMask_u32u32_u8(uint32,uint32) |
| 0x3D | boolean Bfx_TstBitLnMask_u64u64_u8(uint64,uint64) |
⌋
35. Bfx_TstParityEven¶
Definition of API function Bfx_TstParityEven_
⌋
Examples when Bfx_TstParityEven returns TRUE:
result_a = Bfx_TstParityEven_u8_u8(10010011b);
result_b = Bfx_TstParityEven_u16_u8(0);
/_ result_a == result_b == TRUE _/
The following example calls return FALSE:
result_c = Bfx_TstParityEven_u8_u8(11100011b);
result_d = Bfx_TstParityEven_u16_u8(1);
result_e = Bfx_TstParityEven_u16_u8(1001111100101010b);
/_ result_c == result_d == result_e == FALSE _/
……本章内容较长已节选,完整内容见「本地文件」中的纯文本全文。
36. Bfx_ToggleBits¶
Definition of API function Bfx_ToggleBits_
⌋
Example:
data = 10010011b;
Bfx_ToggleBits_u8(&data);
The data will be 01101100b.
List of Bfx_ToggleBits functions
⌈
| Service ID | Function prototype |
|---|---|
| 0x46 | void Bfx_ToggleBits_u8(uint8) |
| 0x47 | void Bfx_ToggleBits_u16(uint16) |
| 0x48 | void Bfx_ToggleBits_u32(uint32) |
| 0x49 | void Bfx_ToggleBits_u64(uint64) |
⌋
37. Bfx_ToggleBitMask¶
Definition of API function Bfx_ToggleBitMask_
⌋
Example:
data = 11110000b;
Bfx_ToggleBitMask_u8u8(&data, 00111100b);
The data will be 11001100b.
List of Bfx_ToggleBitMask functions
⌈
| Service ID | Function prototype |
|---|---|
| 0x4A | void Bfx_ToggleBitMask_u8u8(uint8, uint8) |
| 0x4B | void Bfx_ToggleBitMask_u16u16(uint16, uint16) |
| 0x4C | void Bfx_ToggleBitMask_u32u32(uint32, uint32) |
| 0x4D | void Bfx_ToggleBitMask_u64u64(uint64, uint64) |
⌋
38. Bfx_ShiftBitRt¶
Definition of API function Bfx_ShiftBitRt_
⌋
Example:
data = 10010011b;
Bfx_ShiftBitRt_u8u8(&data,3);
The data will be 00010010b.
List of Bfx_ShiftBitRt functions
⌈
| Service ID | Function prototype | Maximum value of ShiftCnt |
|---|---|---|
| 0x50 | void Bfx_ShiftBitRt_u8u8(uint8, uint8) | 7 |
| 0x51 | void Bfx_ShiftBitRt_u16u8(uint16, uint8) | 15 |
| 0x52 | void Bfx_ShiftBitRt_u32u8(uint32, uint8) | 31 |
| 0x53 | void Bfx_ShiftBitRt_u64u8(uint64, uint8) | 63 |
⌋
39. Bfx_ShiftBitLt¶
Definition of API function Bfx_ShiftBitLt_
⌋
Example:
data = 10010011b;
Bfx_ShiftBitLt_u8u8(&data,3);
The data will be 10011000b.
List of Bfx_ShiftBitLt functions
⌈
| Service ID | Function prototype | Maximum value of ShiftCnt |
|---|---|---|
| 0x56 | void Bfx_ShiftBitLt_u8u8(uint8, uint8) | 7 |
| 0x57 | void Bfx_ShiftBitLt_u16u8(uint16, uint8) | 15 |
| 0x58 | void Bfx_ShiftBitLt_u32u8(uint32, uint8) | 31 |
| 0x59 | void Bfx_ShiftBitLt_u64u8(uint64, uint8) | 63 |
⌋
40. Bfx_RotBitRt¶
Definition of API function Bfx_RotBitRt_
⌋
Examples:
data_a = 00010111b;
Bfx_RotBitRt_u8u8(&data,1);
data_b = 00010111b;
Bfx_RotBitRt_u8u8(&data,3);
The data_a will be 10001011b and data_b will be 11100010b.
List of Bfx_RotBitRt functions
⌈
| Service ID | Function prototype | Maximum value of ShiftCnt |
|---|---|---|
| 0x5A | void Bfx_RotBitRt_u8u8(uint8, uint8) | 7 |
| 0x5B | void Bfx_RotBitRt_u16u8(uint16, uint8) | 15 |
| 0x5C | void Bfx_RotBitRt_u32u8(uint32, uint8) | 31 |
| 0x5D | void Bfx_RotBitRt_u64u8(uint64, uint8) | 63 |
⌋
41. Bfx_RotBitLt¶
Definition of API function Bfx_RotBitLt_
⌋
Examples:
data_a = 10110111b;
Bfx_RotBitLt_u8u8(&data,1);
data_b = 10110111b;
Bfx_RotBitLt_u8u8(&data,3);
The data_a will be 01101111b and data_b will be 10111101b.
List of Bfx_RotBitLt functions
⌈
| Sevice ID | Function prototype | Maximum value of ShiftCnt |
|---|---|---|
| 0x60 | void Bfx_RotBitLt_u8u8(uint8, uint8) | 7 |
| 0x61 | void Bfx_RotBitLt_u16u8(uint16, uint8) | 15 |
| 0x62 | void Bfx_RotBitLt_u32u8(uint32, uint8) | 31 |
| 0x63 | void Bfx_RotBitLt_u64u8(uint64, uint8) | 63 |
⌋
42. Bfx_CopyBit¶
Definition of API function Bfx_CopyBit_
⌋
Example:
DestinationData = 10100001b;
Bfx_CopyBit_u8u8u8u8(&DestinationData, 6, 11011010, 1);
The DestinationData will have 11100001b.
……本章内容较长已节选,完整内容见「本地文件」中的纯文本全文。
43. Bfx_PutBits¶
Definition of API function Bfx_PutBits_
⌋
Example:
Data = 11110000b;
Bfx_PutBits_u8u8u8u8(&Data, 1, 3, 00000011b);
The Data will have 11110110b.
……本章内容较长已节选,完整内容见「本地文件」中的纯文本全文。
44. Bfx_PutBitsMask¶
Definition of API function Bfx_PutBitsMask_
⌋
Example:
data = 11100000b;
Bfx_PutBitsMask_u8u8u8(&data, 11001101b, 00001111b);
The data will contain 11101101b.
List of Bfx_PutBitsMask functions
⌈
| Service ID | Function prototype |
|---|---|
| 0x80 | void Bfx_PutBitsMask_u8u8u8(uint8, uint8, uint8) |
| 0x81 | void Bfx_PutBitsMask_u16u16u16(uint16, uint16, uint16) |
| 0x82 | void Bfx_PutBitsMask_u32u32u32(uint32, uint32, uint32) |
| 0x83 | void Bfx_PutBitsMask_u64u64u64(uint64, uint64, uint64) |
⌋
其余 32 章(内容从略,见纯文本全文)¶
- Bfx_PutBit
- Bfx_ShiftBitSat
- Bfx_CountLeadingOnes
- Bfx_CountLeadingSigns
- Bfx_CountLeadingZeros
- Callback 通知
- Scheduled functions
- Expected 接口
- Mandatory 接口
- Optional 接口
- Configurable 接口
- 服务接口
- 时序图
- 配置规范
- How to read this chapter
- Containers and 配置 parameters
- 发布信息
- 附录
- 不适用需求
- History of 规范 Items
- 规范 Item History of this document compared to AUTOSAR R24-11
- Added 规范 Items in R25-11
- Changed 规范 Items in R25-11
- Deleted 规范 Items in R25-11
- 规范 Item History of this document compared to AUTOSAR R23-11
- Added 规范 Items in R24-11
- Changed 规范 Items in R24-11
- Deleted 规范 Items in R24-11
- 规范 Item History of this document compared to AUTOSAR R22-11
- Added 规范 Items in R23-11
- Changed 规范 Items in R23-11
- Deleted 规范 Items in R23-11