@hackage hocd0.1.0.0

OpenOCD Haskell interface

GitHub Workflow Status Hackage version Dependencies

hocd

OpenOCD RPC service client.

API

See Haddocks or HOCD.Monad

Example

{-# LANGUAGE TypeApplications #-}

import Data.Word (Word32)
import HOCD

main :: IO ()
main = runOCD example >>= print

-- | For STM32G474
example
  :: MonadOCD m
  => m ([Word32], Word32)
example = do
  halt'

  -- Read RCC.CR register
  rccCr <- readMemCount @Word32 0x40021000 2

  -- Read and increment GPIOA.ODR register
  let gpioaOdr = 0x48000014
  odr <- readMem32 gpioaOdr
  writeMem gpioaOdr [odr+1]
  r <- readMem32 gpioaOdr

  pure (rccCr, r)

This example is runnable from git repository using:

openocd -f nucleo.cfg
cabal run hocd-readme

Executable

hocd-read-mem can be used to read a single or multiple addresses:

cabal run hocd-read-mem -- 0x40021000 0x48000014

Outputs:

0x40021000: 0x3030500
0x48000014: 0x9