MATLAB XPC TARGET 4 - DEVICE DRIVERS User's Guide Page 75

  • Download
  • Add to my manuals
  • Print
  • Page
    / 111
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 74
Accessing Registers
Accessing Registers
In this section...
“I/O Space” on page 6-7
“Memory-Mapped Space” on page 6-7
I/O Space
For registers in I/O space, use the xPC Target I/O read and write functions:
Read functions
uint32_T xpcInpDW(uint16_T port ); // read a 32 bit word
uint16_T xpcInpW(uint16_T port ); // read a 16 bit word
uint8_T xpcInpB(uint16_T port ); // read an 8 bit byte
Write fun
ctions
void xpc
OutpDW(uint16_T port, uint32_T value ); // writ e 32 bits
void xpc
OutpW(uint16_T port, uint16_T value ); // write 16 bits
void xpc
OutpB(uint8_T port, uint8_T value ); // write a byte
TheportaddressisthevaluereturnedintheBaseAddr ess array.
Memory-Mapped Space
For registers in memory-mapped space, access them by dereferencing
through a pointer that contains the virtual address returned by the
xpcReserveMemoryRegion function. Because modern compilers have
aggressive optimizers, you must declare the pointer to be volatile. Doing
so ensures that the compiler does not optimize out reads a nd writes using
that pointer. The following pseudocode illustrates t h is using two me t ho ds:
structure and array.
6-7
Page view 74
1 2 ... 70 71 72 73 74 75 76 77 78 79 80 ... 110 111

Comments to this Manuals

No comments