AthulMuralidhar
AthulMuralidhar

Reputation: 715

what is the equivalent of __IO in rust?

Upvotes: 1

Views: 195

Answers (1)

Clifford
Clifford

Reputation: 93476

All the I/O qualifier macros are defined in core_cm4.h (normally included indirectly via stm324xx.h) thus:

#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 */

as you can see they are simply aliases for standard C qualifiers and not themselves C keyword or even compiler extensions - they are part of the CMSIS.

I am no Rust expert, but it seems that there is no direct equivalent in Rust, in that you cannot simply qualify a variable to ensure all accesses are explicit, so memory-mapped I/O uses a different approach. There is an mmio crate and read_volatile/write_volatile and also a Volatile wrapper, all of which may be relevant to this issue.

Upvotes: 1

Related Questions