On Wed, Mar 6, 2013 at 6:43 AM, Kiwamu Okabe <[email protected]> wrote:
> How do I write the code with extern volatile style?
As a quick test that won't require modifying jhc, add
extern volatile void physicalAddress;
to your rts header
and compile adding the flag "-Wl,--defsym=physicalAddress=0"
then in your haskell code where you want to do hardware register access do
foreign import "&physicalAddress" physicalAddress :: Ptr Word32
and use physicalAddress instead of nullPtr in your code as the base,
by going through the volatile physicalAddress it will know not to
optimize it away, whereas it knows that 'nullPtr' is actually zero
which is why it was causing issues. So you would have
periphBase = physicalAddress `plusPtr` 0x40000000
then you won't have to modify the poke and peek primitives.
John
_______________________________________________
jhc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/jhc