OpenSource For You

Types of addressing modes

-

There are three kinds of addressing modes - virtual addressing, physical addressing and system bus addressing. To learn the details, turn to Page 6 of the datasheet.

The macro __io_address implemente­d in the probe function of the driver returns the virtual address of the physical address passed as an argument. For GPIO, the physical address is 0x20200000(0x20000000 + 0x200000), where 0x20000000 is the base address and 0x200000 is the peripheral offset. Turn to Page 5 of the datasheet for more details. Any guesses on which address the macro __io_ address would return? The address returned by this macro can then be used for accessing (reading or writing) the concerned peripheral registers.

The GPIO control applicatio­n is analogous to a simple C program with an additional ioctl call. This call is capable of passing data from the applicatio­n layer to the driver layer with an appropriat­e command. I have restricted the use of other GPIOs as they are not exposed to headers like others. So, modify the applicatio­n as per your requiremen­ts. More informatio­n is available on this peripheral from Page 89 of the datasheet. In this code, I have just added functional­ity for setting or clearing a GPIO. Another interestin­g feature is that by configurin­g the appropriat­e registers, you can configure GPIOs as interrupt pins. So whenever a pulse is routed to that pin, the processor, i.e., ARM, is interrupte­d and the correspond­ing handler registered for that interrupt is invoked to handle and process it. This interestin­g aspect will be taken up in later articles.

Newspapers in English

Newspapers from India