Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5838

Re: Using GPIO

Newsgroups comp.sys.acorn.programmer
Date 2019-10-02 13:17 -0700
References <570d0efa57.Alan.Adams@ArmX6.adamshome.org.uk>
Message-ID <20e4dedf-b9f9-4630-9b74-e2eec33bbd12@googlegroups.com> (permalink)
Subject Re: Using GPIO
From sales@elesar.co.uk

Show all headers | View raw


On Friday, 27 September 2019 12:50:17 UTC+1, Alan Adams  wrote:
> Does anyone here understand the documentation for the GPIO module? I'm 
> completely confused. There was a module (pre 2017 it seems) with a host of 
> SWIs which were more or less descriptive. The replacement seems to only 
> have about ten SWIs and I can't make out from the only documentation (a 
> StrongHelp file) which ones would do what I need.

Except for GPIO_Features, the subset of 10 to which you refer all existed in the myriad of 107 previously. Those 10 are the common ones across all platforms which support GPIO (eg. you could prototype on a Beagleboard and deploy on a Pi).

If you remember your BBC Micro 6522 VIA they should be relatively easy to understand:
  ReadData/WriteData = the data register
  ReadOE/WriteOE = the data direction register

The ReadMode/WriteMode calls are extras needed because most pins on modern micros can also be multiplexed with things other than GPIO, for example it may be possible to get a UART to come out on the same pins by changing the mode.

The ReadEvent/WriteEvent calls are to poll for transitions that were captured (based on what you asked them to watch out for with WriteMode) - most analogous to the handshaking strobe lines on the beeb.

The Info/Features calls are there to allow you to enumerate and find out features programmatically. You could ignore them, but then you'll be tied to a certain pinout on one board (beware! there are even variations from Pi to Pi between models).

> On an rpi, I need to enable two pins as inputs, causing an interrupt. 
> (Using a change of state event will not be fast enough, as that has to be 
> polled for).
> 
> I need to create a small module which will react to the interrupt, decide 
> which pin it was, and store the current clock time, then change a 
> pollword.  (I'm assuming here that servicing an interrupt requires a 
> module.)
> 
> I have the hardware manual, so I know the hardware is capable of this. 
> What I can't see is how the GPIO module helps. Maybe it doesn't... Ideally 
> it would already be capable of handling the interrupt for me, but I have 
> doubts about that.

The GPIO module doesn't currently despatch interrupts, you'd have to do that yourself. The GPIO SWIs also have the disadvantage that they're single bit wide, so tend to result in lots of very verbose code. Underneath the GPIO module is the GPIO HAL interface - that's 32b port wide which makes manipulating several bits at once much easier.

It's definitely possible to service interrupts, our parallel port HAT
  http://shop.elesar.co.uk/index.php?route=product/product&product_id=76

does just that for the printer ACK line. 

> This is likely to be a learning experience for me, as I've never written 
> any C. At the monment I'm thinking it would be easier for me to write it 
> in assembler, especially as I have a module to use as an example - the 
> Socketwatch module is also in assembler. I have in the past written 
> assembler for VAX, Z80 and 6502. The Z80 was a language ROM providing a 
> complete terminal emulator, including enlarged buffers hooked into the 
> vectors, so not exactly trivial.

Provided your handler is in permanently paged in memory (such as the RMA) you don't particularly need to write a module. An application could claim some RMA, install a handler, then poll a shared flag - probably simpler than learning a new programming language!

Recommend buying a reset button for your Pi, there will be plenty of crashes along the journey!
Robert.

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Using GPIO Alan Adams <alan@adamshome.org.uk> - 2019-09-27 12:49 +0100
  Re: Using GPIO sales@elesar.co.uk - 2019-10-02 13:17 -0700
    Re: Using GPIO Alan Adams <alan@adamshome.org.uk> - 2019-10-02 21:40 +0100
    Re: Using GPIO Alan Adams <alan@adamshome.org.uk> - 2019-10-05 16:19 +0100
      Re: Using GPIO sales@elesar.co.uk - 2019-10-12 13:15 -0700

csiph-web