Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using '__IOM' for peripheral register definitions #3

Closed
utkarshsethi opened this issue May 7, 2021 · 2 comments
Closed

Using '__IOM' for peripheral register definitions #3

utkarshsethi opened this issue May 7, 2021 · 2 comments
Assignees
Labels
cmsis CMSIS-related issue or pull-request. enhancement New feature or request internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system wontfix This will not be worked on

Comments

@utkarshsethi
Copy link

utkarshsethi commented May 7, 2021

Additional context

Is there a specific reason to not use '__IO' for peripheral register definitions instead of '__IOM' as per guidelines for versions greater than v4.2?

typedef struct { __IO uint32_t SR; /*!< ADC status register, Address offset: 0x00 */ __IO uint32_t CR1; /*!< ADC control register 1, Address offset: 0x04 */ __IO uint32_t CR2; /*!< ADC control register 2, Address offset: 0x08 */ __IO uint32_t SMPR1; /*!< ADC sample time register 1, Address offset: 0x0C */ __IO uint32_t SMPR2; /*!< ADC sample time register 2, Address offset: 0x10 */ __IO uint32_t JOFR1; /*!< ADC injected channel data offset register 1, Address offset: 0x14 */ __IO uint32_t JOFR2; /*!< ADC injected channel data offset register 2, Address offset: 0x18 */ __IO uint32_t JOFR3; /*!< ADC injected channel data offset register 3, Address offset: 0x1C */ __IO uint32_t JOFR4; /*!< ADC injected channel data offset register 4, Address offset: 0x20 */ __IO uint32_t HTR; /*!< ADC watchdog higher threshold register, Address offset: 0x24 */ __IO uint32_t LTR; /*!< ADC watchdog lower threshold register, Address offset: 0x28 */ __IO uint32_t SQR1; /*!< ADC regular sequence register 1, Address offset: 0x2C */ __IO uint32_t SQR2; /*!< ADC regular sequence register 2, Address offset: 0x30 */ __IO uint32_t SQR3; /*!< ADC regular sequence register 3, Address offset: 0x34 */ __IO uint32_t JSQR; /*!< ADC injected sequence register, Address offset: 0x38*/ __IO uint32_t JDR1; /*!< ADC injected data register 1, Address offset: 0x3C */ __IO uint32_t JDR2; /*!< ADC injected data register 2, Address offset: 0x40 */ __IO uint32_t JDR3; /*!< ADC injected data register 3, Address offset: 0x44 */ __IO uint32_t JDR4; /*!< ADC injected data register 4, Address offset: 0x48 */ __IO uint32_t DR; /*!< ADC regular data register, Address offset: 0x4C */ } ADC_TypeDef;

https://developer.arm.com/documentation/ka002980/latest

Note:
Since CMSIS-Core V4.20 the macros __I, __O and __IO should only be used for scalar variables. For peripheral register definitions in structures, the macros __IM, __OM and __IOM should now be used. The definition __IM always contains the const type qualifier because C++ does not optimize struct-members to constants. This way, registers can be write-protected even in C++.

or https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/Core/Include/core_cm4.h#L229
/* following defines should be used for structure members */ #define __IM volatile const /*! Defines 'read only' structure member permissions */ #define __OM volatile /*! Defines 'write only' structure member permissions */ #define __IOM volatile /*! Defines 'read / write' structure member permissions */

@RKOUSTM
Copy link
Contributor

RKOUSTM commented Jun 29, 2021

Hi @utkarshsethi,

Thank you for your contribution.

This request will be forwarded to our technical committee. I will be back to you as soon as they provide me with their answer.

This duplicated issue will remain closed. This pull-request will be kept open to track the point.

Thank you again for your contribution.

With regards,

@RKOUSTM RKOUSTM added cmsis CMSIS-related issue or pull-request. duplicate This issue or pull request already exists labels Jun 29, 2021
@RKOUSTM RKOUSTM closed this as completed Jun 29, 2021
stm32cube-mcu-cmsis-dashboard automation moved this from To do to Done Jun 29, 2021
@STMicroelectronics STMicroelectronics deleted a comment from RKOUSTM Mar 18, 2024
@ALABSTM
Copy link
Collaborator

ALABSTM commented Mar 18, 2024

ST Internal Reference: 109857

@ALABSTM ALABSTM added enhancement New feature or request internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system and removed duplicate This issue or pull request already exists labels Mar 18, 2024
@ALABSTM ALABSTM closed this as not planned Won't fix, can't repro, duplicate, stale Mar 18, 2024
@ALABSTM ALABSTM added the wontfix This will not be worked on label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmsis CMSIS-related issue or pull-request. enhancement New feature or request internal bug tracker Issue confirmed and reported into a ticket in the internal bug tracking system wontfix This will not be worked on
3 participants