| Copyright | (c) UBC Orbit |
|---|---|
| Maintainer | sam.schwiegel@ubcorbit.com |
| Safe Haskell | None |
| Language | Haskell2010 |
STLink.Driver
Description
Most users shouldn't have to import this module, since the important bits are re-exported elsewhere.
- inCommand :: DeviceHandle -> ByteString -> Size -> ExceptT String IO ByteString
- outCommand :: DeviceHandle -> ByteString -> ByteString -> ExceptT String IO ()
- withAutoBoard :: STLink a -> IO (Maybe a)
- withBoard :: Device -> STLink a -> IO (Maybe a)
- newtype STLink a = STLink (DeviceHandle -> ExceptT String IO a)
Documentation
inCommand :: DeviceHandle -> ByteString -> Size -> ExceptT String IO ByteString Source #
Low-level command that formats an "inward" command the way the STLink dongle likes it:
USB_BULK out <up to 16 bytes of commands> USB_BULK in <expected response length>
Since USB is a host-oriented protocol, we have to know in advance how many bytes to read from the device's buffer.
outCommand :: DeviceHandle -> ByteString -> ByteString -> ExceptT String IO () Source #
Low-level command that formats an "outward" command the way the STLink dongle likes it:
USB_BULK out <up to 16 bytes of commands> USB_BULK out <outward-bound data>
withAutoBoard :: STLink a -> IO (Maybe a) Source #
Automatically finds a board (and prompts the user to select one
if several are attached) and then runs the STLink action with
that board.
withBoard :: Device -> STLink a -> IO (Maybe a) Source #
Lets the user manually specify a USB Device to execute the
STLink action on.
This monad lets you write effectful computations that communicate
with an STLink dongle, without explicitly specifying the dongle you
want to talk with for every command. Generally, 'runSTLink
wouldn't be used directly since it takes a low-level DeviceHandle
instead of a general Device. See withBoard for a safe,
high-level way to run an STLink.