3
\$\begingroup\$

in core_cm4.h header file defined some thing like this:

#ifdef __cplusplus
  #define   __I     volatile             /*!< Defines 'read only' permissions                 */
#else
  #define   __I     volatile const       /*!< Defines 'read only' permissions                 */
#endif
#define     __O     volatile             /*!< Defines 'write only' permissions                */
#define     __IO    volatile             /*!< Defines 'read / write' permissions              */

What's the difference between __I , __O and __IO while they are defined in same way.

  • and how they work to specify "read/write only" while they are only defined as a volatile variable ?!
\$\endgroup\$
  • 2
    \$\begingroup\$ Naming convention? I think the keyword you're looking for is "volatile const". \$\endgroup\$ – Long Pham Oct 15 '18 at 15:17
3
\$\begingroup\$

I means Input O means Output IO means Input and Output

As Long Pham notes, it is a naming convention, but also it is normal to use meanings to a type. Like an integer can be a counter, a timestamp, a date etc.

There are some reasons to use this:

  • It is good for readability
  • Whenever in future the type of an I, O or IO would change, (user) source code using I, O and IO does not need to be changed, only the type definitions / defines itself.
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.