# Difference between __I and __IO and __O in CMSIS core

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 ?!
• Naming convention? I think the keyword you're looking for is "volatile const". – Long Pham Oct 15 '18 at 15:17

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.