{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE NoImplicitPrelude           #-}
{-# LANGUAGE TemplateHaskell             #-}
{-# LANGUAGE RecordWildCards             #-}

-- |
-- Module:      SwiftNav.SBP.Flash
-- Copyright:   Copyright (C) 2015-2021 Swift Navigation, Inc.
-- License:     MIT
-- Contact:     https://support.swiftnav.com
-- Stability:   experimental
-- Portability: portable
--
-- \< Messages for reading/writing the device's onboard flash memory. Many of
-- these messages target specific flash memory peripherals used in Swift
-- Navigation devices: the STM32 flash and the M25Pxx FPGA configuration flash
-- from Piksi 2.3.1.  This module does not apply to Piksi Multi. \>

module SwiftNav.SBP.Flash
  ( module SwiftNav.SBP.Flash
  ) where

import BasicPrelude
import Control.Lens
import Control.Monad.Loops
import Data.Binary
import Data.Binary.Get
import Data.Binary.IEEE754
import Data.Binary.Put
import Data.ByteString.Lazy    hiding (ByteString)
import Data.Int
import Data.Word
import SwiftNav.SBP.TH
import SwiftNav.SBP.Types

{-# ANN module ("HLint: ignore Use camelCase"::String) #-}
{-# ANN module ("HLint: ignore Redundant do"::String) #-}
{-# ANN module ("HLint: ignore Use newtype instead of data"::String) #-}


msgFlashProgram :: Word16
msgFlashProgram :: Word16
msgFlashProgram = Word16
0x00E6

-- | SBP class for message MSG_FLASH_PROGRAM (0x00E6).
--
-- The flash program message programs a set of addresses of either the STM or
-- M25 flash. The device replies with either a MSG_FLASH_DONE message
-- containing the return code FLASH_OK (0) on success, or FLASH_INVALID_LEN
-- (2) if the maximum write size is exceeded. Note that the sector-containing
-- addresses must be erased before addresses can be programmed.
data MsgFlashProgram = MsgFlashProgram
  { MsgFlashProgram -> Word8
_msgFlashProgram_target   :: !Word8
    -- ^ Target flags
  , MsgFlashProgram -> [Word8]
_msgFlashProgram_addr_start :: ![Word8]
    -- ^ Starting address offset to program
  , MsgFlashProgram -> Word8
_msgFlashProgram_addr_len :: !Word8
    -- ^ Length of set of addresses to program, counting up from starting
    -- address
  , MsgFlashProgram -> [Word8]
_msgFlashProgram_data     :: ![Word8]
    -- ^ Data to program addresses with, with length N=addr_len
  } deriving ( Int -> MsgFlashProgram -> ShowS
[MsgFlashProgram] -> ShowS
MsgFlashProgram -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgFlashProgram] -> ShowS
$cshowList :: [MsgFlashProgram] -> ShowS
show :: MsgFlashProgram -> String
$cshow :: MsgFlashProgram -> String
showsPrec :: Int -> MsgFlashProgram -> ShowS
$cshowsPrec :: Int -> MsgFlashProgram -> ShowS
Show, ReadPrec [MsgFlashProgram]
ReadPrec MsgFlashProgram
Int -> ReadS MsgFlashProgram
ReadS [MsgFlashProgram]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgFlashProgram]
$creadListPrec :: ReadPrec [MsgFlashProgram]
readPrec :: ReadPrec MsgFlashProgram
$creadPrec :: ReadPrec MsgFlashProgram
readList :: ReadS [MsgFlashProgram]
$creadList :: ReadS [MsgFlashProgram]
readsPrec :: Int -> ReadS MsgFlashProgram
$creadsPrec :: Int -> ReadS MsgFlashProgram
Read, MsgFlashProgram -> MsgFlashProgram -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgFlashProgram -> MsgFlashProgram -> Bool
$c/= :: MsgFlashProgram -> MsgFlashProgram -> Bool
== :: MsgFlashProgram -> MsgFlashProgram -> Bool
$c== :: MsgFlashProgram -> MsgFlashProgram -> Bool
Eq )

instance Binary MsgFlashProgram where
  get :: Get MsgFlashProgram
get = do
    Word8
_msgFlashProgram_target <- Get Word8
getWord8
    [Word8]
_msgFlashProgram_addr_start <- forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM Int
3 Get Word8
getWord8
    Word8
_msgFlashProgram_addr_len <- Get Word8
getWord8
    [Word8]
_msgFlashProgram_data <- forall (m :: * -> *) a. Monad m => m Bool -> m a -> m [a]
whileM (Bool -> Bool
not forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Bool
isEmpty) Get Word8
getWord8
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgFlashProgram {[Word8]
Word8
_msgFlashProgram_data :: [Word8]
_msgFlashProgram_addr_len :: Word8
_msgFlashProgram_addr_start :: [Word8]
_msgFlashProgram_target :: Word8
_msgFlashProgram_data :: [Word8]
_msgFlashProgram_addr_len :: Word8
_msgFlashProgram_addr_start :: [Word8]
_msgFlashProgram_target :: Word8
..}

  put :: MsgFlashProgram -> Put
put MsgFlashProgram {[Word8]
Word8
_msgFlashProgram_data :: [Word8]
_msgFlashProgram_addr_len :: Word8
_msgFlashProgram_addr_start :: [Word8]
_msgFlashProgram_target :: Word8
_msgFlashProgram_data :: MsgFlashProgram -> [Word8]
_msgFlashProgram_addr_len :: MsgFlashProgram -> Word8
_msgFlashProgram_addr_start :: MsgFlashProgram -> [Word8]
_msgFlashProgram_target :: MsgFlashProgram -> Word8
..} = do
    Word8 -> Put
putWord8 Word8
_msgFlashProgram_target
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Word8 -> Put
putWord8 [Word8]
_msgFlashProgram_addr_start
    Word8 -> Put
putWord8 Word8
_msgFlashProgram_addr_len
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Word8 -> Put
putWord8 [Word8]
_msgFlashProgram_data

$(makeSBP 'msgFlashProgram ''MsgFlashProgram)
$(makeJSON "_msgFlashProgram_" ''MsgFlashProgram)
$(makeLenses ''MsgFlashProgram)

msgFlashDone :: Word16
msgFlashDone :: Word16
msgFlashDone = Word16
0x00E0

-- | SBP class for message MSG_FLASH_DONE (0x00E0).
--
-- This message defines success or failure codes for a variety of flash memory
-- requests from the host to the device. Flash read and write messages, such
-- as MSG_FLASH_READ_REQ, or MSG_FLASH_PROGRAM, may return this message on
-- failure.
data MsgFlashDone = MsgFlashDone
  { MsgFlashDone -> Word8
_msgFlashDone_response :: !Word8
    -- ^ Response flags
  } deriving ( Int -> MsgFlashDone -> ShowS
[MsgFlashDone] -> ShowS
MsgFlashDone -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgFlashDone] -> ShowS
$cshowList :: [MsgFlashDone] -> ShowS
show :: MsgFlashDone -> String
$cshow :: MsgFlashDone -> String
showsPrec :: Int -> MsgFlashDone -> ShowS
$cshowsPrec :: Int -> MsgFlashDone -> ShowS
Show, ReadPrec [MsgFlashDone]
ReadPrec MsgFlashDone
Int -> ReadS MsgFlashDone
ReadS [MsgFlashDone]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgFlashDone]
$creadListPrec :: ReadPrec [MsgFlashDone]
readPrec :: ReadPrec MsgFlashDone
$creadPrec :: ReadPrec MsgFlashDone
readList :: ReadS [MsgFlashDone]
$creadList :: ReadS [MsgFlashDone]
readsPrec :: Int -> ReadS MsgFlashDone
$creadsPrec :: Int -> ReadS MsgFlashDone
Read, MsgFlashDone -> MsgFlashDone -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgFlashDone -> MsgFlashDone -> Bool
$c/= :: MsgFlashDone -> MsgFlashDone -> Bool
== :: MsgFlashDone -> MsgFlashDone -> Bool
$c== :: MsgFlashDone -> MsgFlashDone -> Bool
Eq )

instance Binary MsgFlashDone where
  get :: Get MsgFlashDone
get = do
    Word8
_msgFlashDone_response <- Get Word8
getWord8
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgFlashDone {Word8
_msgFlashDone_response :: Word8
_msgFlashDone_response :: Word8
..}

  put :: MsgFlashDone -> Put
put MsgFlashDone {Word8
_msgFlashDone_response :: Word8
_msgFlashDone_response :: MsgFlashDone -> Word8
..} = do
    Word8 -> Put
putWord8 Word8
_msgFlashDone_response

$(makeSBP 'msgFlashDone ''MsgFlashDone)
$(makeJSON "_msgFlashDone_" ''MsgFlashDone)
$(makeLenses ''MsgFlashDone)

msgFlashReadReq :: Word16
msgFlashReadReq :: Word16
msgFlashReadReq = Word16
0x00E7

-- | SBP class for message MSG_FLASH_READ_REQ (0x00E7).
--
-- The flash read message reads a set of addresses of either the STM or M25
-- onboard flash. The device replies with a MSG_FLASH_READ_RESP message
-- containing either the read data on success or a MSG_FLASH_DONE message
-- containing the return code FLASH_INVALID_LEN (2) if the maximum read size
-- is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the
-- allowed range.
data MsgFlashReadReq = MsgFlashReadReq
  { MsgFlashReadReq -> Word8
_msgFlashReadReq_target   :: !Word8
    -- ^ Target flags
  , MsgFlashReadReq -> [Word8]
_msgFlashReadReq_addr_start :: ![Word8]
    -- ^ Starting address offset to read from
  , MsgFlashReadReq -> Word8
_msgFlashReadReq_addr_len :: !Word8
    -- ^ Length of set of addresses to read, counting up from starting address
  } deriving ( Int -> MsgFlashReadReq -> ShowS
[MsgFlashReadReq] -> ShowS
MsgFlashReadReq -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgFlashReadReq] -> ShowS
$cshowList :: [MsgFlashReadReq] -> ShowS
show :: MsgFlashReadReq -> String
$cshow :: MsgFlashReadReq -> String
showsPrec :: Int -> MsgFlashReadReq -> ShowS
$cshowsPrec :: Int -> MsgFlashReadReq -> ShowS
Show, ReadPrec [MsgFlashReadReq]
ReadPrec MsgFlashReadReq
Int -> ReadS MsgFlashReadReq
ReadS [MsgFlashReadReq]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgFlashReadReq]
$creadListPrec :: ReadPrec [MsgFlashReadReq]
readPrec :: ReadPrec MsgFlashReadReq
$creadPrec :: ReadPrec MsgFlashReadReq
readList :: ReadS [MsgFlashReadReq]
$creadList :: ReadS [MsgFlashReadReq]
readsPrec :: Int -> ReadS MsgFlashReadReq
$creadsPrec :: Int -> ReadS MsgFlashReadReq
Read, MsgFlashReadReq -> MsgFlashReadReq -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgFlashReadReq -> MsgFlashReadReq -> Bool
$c/= :: MsgFlashReadReq -> MsgFlashReadReq -> Bool
== :: MsgFlashReadReq -> MsgFlashReadReq -> Bool
$c== :: MsgFlashReadReq -> MsgFlashReadReq -> Bool
Eq )

instance Binary MsgFlashReadReq where
  get :: Get MsgFlashReadReq
get = do
    Word8
_msgFlashReadReq_target <- Get Word8
getWord8
    [Word8]
_msgFlashReadReq_addr_start <- forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM Int
3 Get Word8
getWord8
    Word8
_msgFlashReadReq_addr_len <- Get Word8
getWord8
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgFlashReadReq {[Word8]
Word8
_msgFlashReadReq_addr_len :: Word8
_msgFlashReadReq_addr_start :: [Word8]
_msgFlashReadReq_target :: Word8
_msgFlashReadReq_addr_len :: Word8
_msgFlashReadReq_addr_start :: [Word8]
_msgFlashReadReq_target :: Word8
..}

  put :: MsgFlashReadReq -> Put
put MsgFlashReadReq {[Word8]
Word8
_msgFlashReadReq_addr_len :: Word8
_msgFlashReadReq_addr_start :: [Word8]
_msgFlashReadReq_target :: Word8
_msgFlashReadReq_addr_len :: MsgFlashReadReq -> Word8
_msgFlashReadReq_addr_start :: MsgFlashReadReq -> [Word8]
_msgFlashReadReq_target :: MsgFlashReadReq -> Word8
..} = do
    Word8 -> Put
putWord8 Word8
_msgFlashReadReq_target
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Word8 -> Put
putWord8 [Word8]
_msgFlashReadReq_addr_start
    Word8 -> Put
putWord8 Word8
_msgFlashReadReq_addr_len

$(makeSBP 'msgFlashReadReq ''MsgFlashReadReq)
$(makeJSON "_msgFlashReadReq_" ''MsgFlashReadReq)
$(makeLenses ''MsgFlashReadReq)

msgFlashReadResp :: Word16
msgFlashReadResp :: Word16
msgFlashReadResp = Word16
0x00E1

-- | SBP class for message MSG_FLASH_READ_RESP (0x00E1).
--
-- The flash read message reads a set of addresses of either the STM or M25
-- onboard flash. The device replies with a MSG_FLASH_READ_RESP message
-- containing either the read data on success or a MSG_FLASH_DONE message
-- containing the return code FLASH_INVALID_LEN (2) if the maximum read size
-- is exceeded or FLASH_INVALID_ADDR (3) if the address is outside of the
-- allowed range.
data MsgFlashReadResp = MsgFlashReadResp
  { MsgFlashReadResp -> Word8
_msgFlashReadResp_target   :: !Word8
    -- ^ Target flags
  , MsgFlashReadResp -> [Word8]
_msgFlashReadResp_addr_start :: ![Word8]
    -- ^ Starting address offset to read from
  , MsgFlashReadResp -> Word8
_msgFlashReadResp_addr_len :: !Word8
    -- ^ Length of set of addresses to read, counting up from starting address
  } deriving ( Int -> MsgFlashReadResp -> ShowS
[MsgFlashReadResp] -> ShowS
MsgFlashReadResp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgFlashReadResp] -> ShowS
$cshowList :: [MsgFlashReadResp] -> ShowS
show :: MsgFlashReadResp -> String
$cshow :: MsgFlashReadResp -> String
showsPrec :: Int -> MsgFlashReadResp -> ShowS
$cshowsPrec :: Int -> MsgFlashReadResp -> ShowS
Show, ReadPrec [MsgFlashReadResp]
ReadPrec MsgFlashReadResp
Int -> ReadS MsgFlashReadResp
ReadS [MsgFlashReadResp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgFlashReadResp]
$creadListPrec :: ReadPrec [MsgFlashReadResp]
readPrec :: ReadPrec MsgFlashReadResp
$creadPrec :: ReadPrec MsgFlashReadResp
readList :: ReadS [MsgFlashReadResp]
$creadList :: ReadS [MsgFlashReadResp]
readsPrec :: Int -> ReadS MsgFlashReadResp
$creadsPrec :: Int -> ReadS MsgFlashReadResp
Read, MsgFlashReadResp -> MsgFlashReadResp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgFlashReadResp -> MsgFlashReadResp -> Bool
$c/= :: MsgFlashReadResp -> MsgFlashReadResp -> Bool
== :: MsgFlashReadResp -> MsgFlashReadResp -> Bool
$c== :: MsgFlashReadResp -> MsgFlashReadResp -> Bool
Eq )

instance Binary MsgFlashReadResp where
  get :: Get MsgFlashReadResp
get = do
    Word8
_msgFlashReadResp_target <- Get Word8
getWord8
    [Word8]
_msgFlashReadResp_addr_start <- forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM Int
3 Get Word8
getWord8
    Word8
_msgFlashReadResp_addr_len <- Get Word8
getWord8
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgFlashReadResp {[Word8]
Word8
_msgFlashReadResp_addr_len :: Word8
_msgFlashReadResp_addr_start :: [Word8]
_msgFlashReadResp_target :: Word8
_msgFlashReadResp_addr_len :: Word8
_msgFlashReadResp_addr_start :: [Word8]
_msgFlashReadResp_target :: Word8
..}

  put :: MsgFlashReadResp -> Put
put MsgFlashReadResp {[Word8]
Word8
_msgFlashReadResp_addr_len :: Word8
_msgFlashReadResp_addr_start :: [Word8]
_msgFlashReadResp_target :: Word8
_msgFlashReadResp_addr_len :: MsgFlashReadResp -> Word8
_msgFlashReadResp_addr_start :: MsgFlashReadResp -> [Word8]
_msgFlashReadResp_target :: MsgFlashReadResp -> Word8
..} = do
    Word8 -> Put
putWord8 Word8
_msgFlashReadResp_target
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Word8 -> Put
putWord8 [Word8]
_msgFlashReadResp_addr_start
    Word8 -> Put
putWord8 Word8
_msgFlashReadResp_addr_len

$(makeSBP 'msgFlashReadResp ''MsgFlashReadResp)
$(makeJSON "_msgFlashReadResp_" ''MsgFlashReadResp)
$(makeLenses ''MsgFlashReadResp)

msgFlashErase :: Word16
msgFlashErase :: Word16
msgFlashErase = Word16
0x00E2

-- | SBP class for message MSG_FLASH_ERASE (0x00E2).
--
-- The flash erase message from the host erases a sector of either the STM or
-- M25 onboard flash memory. The device will reply with a MSG_FLASH_DONE
-- message containing the return code - FLASH_OK (0) on success or
-- FLASH_INVALID_FLASH (1) if the flash specified is invalid.
data MsgFlashErase = MsgFlashErase
  { MsgFlashErase -> Word8
_msgFlashErase_target   :: !Word8
    -- ^ Target flags
  , MsgFlashErase -> Word32
_msgFlashErase_sector_num :: !Word32
    -- ^ Flash sector number to erase (0-11 for the STM, 0-15 for the M25)
  } deriving ( Int -> MsgFlashErase -> ShowS
[MsgFlashErase] -> ShowS
MsgFlashErase -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgFlashErase] -> ShowS
$cshowList :: [MsgFlashErase] -> ShowS
show :: MsgFlashErase -> String
$cshow :: MsgFlashErase -> String
showsPrec :: Int -> MsgFlashErase -> ShowS
$cshowsPrec :: Int -> MsgFlashErase -> ShowS
Show, ReadPrec [MsgFlashErase]
ReadPrec MsgFlashErase
Int -> ReadS MsgFlashErase
ReadS [MsgFlashErase]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgFlashErase]
$creadListPrec :: ReadPrec [MsgFlashErase]
readPrec :: ReadPrec MsgFlashErase
$creadPrec :: ReadPrec MsgFlashErase
readList :: ReadS [MsgFlashErase]
$creadList :: ReadS [MsgFlashErase]
readsPrec :: Int -> ReadS MsgFlashErase
$creadsPrec :: Int -> ReadS MsgFlashErase
Read, MsgFlashErase -> MsgFlashErase -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgFlashErase -> MsgFlashErase -> Bool
$c/= :: MsgFlashErase -> MsgFlashErase -> Bool
== :: MsgFlashErase -> MsgFlashErase -> Bool
$c== :: MsgFlashErase -> MsgFlashErase -> Bool
Eq )

instance Binary MsgFlashErase where
  get :: Get MsgFlashErase
get = do
    Word8
_msgFlashErase_target <- Get Word8
getWord8
    Word32
_msgFlashErase_sector_num <- Get Word32
getWord32le
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgFlashErase {Word8
Word32
_msgFlashErase_sector_num :: Word32
_msgFlashErase_target :: Word8
_msgFlashErase_sector_num :: Word32
_msgFlashErase_target :: Word8
..}

  put :: MsgFlashErase -> Put
put MsgFlashErase {Word8
Word32
_msgFlashErase_sector_num :: Word32
_msgFlashErase_target :: Word8
_msgFlashErase_sector_num :: MsgFlashErase -> Word32
_msgFlashErase_target :: MsgFlashErase -> Word8
..} = do
    Word8 -> Put
putWord8 Word8
_msgFlashErase_target
    Word32 -> Put
putWord32le Word32
_msgFlashErase_sector_num

$(makeSBP 'msgFlashErase ''MsgFlashErase)
$(makeJSON "_msgFlashErase_" ''MsgFlashErase)
$(makeLenses ''MsgFlashErase)

msgStmFlashLockSector :: Word16
msgStmFlashLockSector :: Word16
msgStmFlashLockSector = Word16
0x00E3

-- | SBP class for message MSG_STM_FLASH_LOCK_SECTOR (0x00E3).
--
-- The flash lock message locks a sector of the STM flash memory. The device
-- replies with a MSG_FLASH_DONE message.
data MsgStmFlashLockSector = MsgStmFlashLockSector
  { MsgStmFlashLockSector -> Word32
_msgStmFlashLockSector_sector :: !Word32
    -- ^ Flash sector number to lock
  } deriving ( Int -> MsgStmFlashLockSector -> ShowS
[MsgStmFlashLockSector] -> ShowS
MsgStmFlashLockSector -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgStmFlashLockSector] -> ShowS
$cshowList :: [MsgStmFlashLockSector] -> ShowS
show :: MsgStmFlashLockSector -> String
$cshow :: MsgStmFlashLockSector -> String
showsPrec :: Int -> MsgStmFlashLockSector -> ShowS
$cshowsPrec :: Int -> MsgStmFlashLockSector -> ShowS
Show, ReadPrec [MsgStmFlashLockSector]
ReadPrec MsgStmFlashLockSector
Int -> ReadS MsgStmFlashLockSector
ReadS [MsgStmFlashLockSector]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgStmFlashLockSector]
$creadListPrec :: ReadPrec [MsgStmFlashLockSector]
readPrec :: ReadPrec MsgStmFlashLockSector
$creadPrec :: ReadPrec MsgStmFlashLockSector
readList :: ReadS [MsgStmFlashLockSector]
$creadList :: ReadS [MsgStmFlashLockSector]
readsPrec :: Int -> ReadS MsgStmFlashLockSector
$creadsPrec :: Int -> ReadS MsgStmFlashLockSector
Read, MsgStmFlashLockSector -> MsgStmFlashLockSector -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgStmFlashLockSector -> MsgStmFlashLockSector -> Bool
$c/= :: MsgStmFlashLockSector -> MsgStmFlashLockSector -> Bool
== :: MsgStmFlashLockSector -> MsgStmFlashLockSector -> Bool
$c== :: MsgStmFlashLockSector -> MsgStmFlashLockSector -> Bool
Eq )

instance Binary MsgStmFlashLockSector where
  get :: Get MsgStmFlashLockSector
get = do
    Word32
_msgStmFlashLockSector_sector <- Get Word32
getWord32le
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgStmFlashLockSector {Word32
_msgStmFlashLockSector_sector :: Word32
_msgStmFlashLockSector_sector :: Word32
..}

  put :: MsgStmFlashLockSector -> Put
put MsgStmFlashLockSector {Word32
_msgStmFlashLockSector_sector :: Word32
_msgStmFlashLockSector_sector :: MsgStmFlashLockSector -> Word32
..} = do
    Word32 -> Put
putWord32le Word32
_msgStmFlashLockSector_sector

$(makeSBP 'msgStmFlashLockSector ''MsgStmFlashLockSector)
$(makeJSON "_msgStmFlashLockSector_" ''MsgStmFlashLockSector)
$(makeLenses ''MsgStmFlashLockSector)

msgStmFlashUnlockSector :: Word16
msgStmFlashUnlockSector :: Word16
msgStmFlashUnlockSector = Word16
0x00E4

-- | SBP class for message MSG_STM_FLASH_UNLOCK_SECTOR (0x00E4).
--
-- The flash unlock message unlocks a sector of the STM flash memory. The
-- device replies with a MSG_FLASH_DONE message.
data MsgStmFlashUnlockSector = MsgStmFlashUnlockSector
  { MsgStmFlashUnlockSector -> Word32
_msgStmFlashUnlockSector_sector :: !Word32
    -- ^ Flash sector number to unlock
  } deriving ( Int -> MsgStmFlashUnlockSector -> ShowS
[MsgStmFlashUnlockSector] -> ShowS
MsgStmFlashUnlockSector -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgStmFlashUnlockSector] -> ShowS
$cshowList :: [MsgStmFlashUnlockSector] -> ShowS
show :: MsgStmFlashUnlockSector -> String
$cshow :: MsgStmFlashUnlockSector -> String
showsPrec :: Int -> MsgStmFlashUnlockSector -> ShowS
$cshowsPrec :: Int -> MsgStmFlashUnlockSector -> ShowS
Show, ReadPrec [MsgStmFlashUnlockSector]
ReadPrec MsgStmFlashUnlockSector
Int -> ReadS MsgStmFlashUnlockSector
ReadS [MsgStmFlashUnlockSector]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgStmFlashUnlockSector]
$creadListPrec :: ReadPrec [MsgStmFlashUnlockSector]
readPrec :: ReadPrec MsgStmFlashUnlockSector
$creadPrec :: ReadPrec MsgStmFlashUnlockSector
readList :: ReadS [MsgStmFlashUnlockSector]
$creadList :: ReadS [MsgStmFlashUnlockSector]
readsPrec :: Int -> ReadS MsgStmFlashUnlockSector
$creadsPrec :: Int -> ReadS MsgStmFlashUnlockSector
Read, MsgStmFlashUnlockSector -> MsgStmFlashUnlockSector -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgStmFlashUnlockSector -> MsgStmFlashUnlockSector -> Bool
$c/= :: MsgStmFlashUnlockSector -> MsgStmFlashUnlockSector -> Bool
== :: MsgStmFlashUnlockSector -> MsgStmFlashUnlockSector -> Bool
$c== :: MsgStmFlashUnlockSector -> MsgStmFlashUnlockSector -> Bool
Eq )

instance Binary MsgStmFlashUnlockSector where
  get :: Get MsgStmFlashUnlockSector
get = do
    Word32
_msgStmFlashUnlockSector_sector <- Get Word32
getWord32le
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgStmFlashUnlockSector {Word32
_msgStmFlashUnlockSector_sector :: Word32
_msgStmFlashUnlockSector_sector :: Word32
..}

  put :: MsgStmFlashUnlockSector -> Put
put MsgStmFlashUnlockSector {Word32
_msgStmFlashUnlockSector_sector :: Word32
_msgStmFlashUnlockSector_sector :: MsgStmFlashUnlockSector -> Word32
..} = do
    Word32 -> Put
putWord32le Word32
_msgStmFlashUnlockSector_sector

$(makeSBP 'msgStmFlashUnlockSector ''MsgStmFlashUnlockSector)
$(makeJSON "_msgStmFlashUnlockSector_" ''MsgStmFlashUnlockSector)
$(makeLenses ''MsgStmFlashUnlockSector)

msgStmUniqueIdReq :: Word16
msgStmUniqueIdReq :: Word16
msgStmUniqueIdReq = Word16
0x00E8

-- | SBP class for message MSG_STM_UNIQUE_ID_REQ (0x00E8).
--
-- This message reads the device's hard-coded unique ID. The host requests the
-- ID by sending a MSG_STM_UNIQUE_ID_REQ. The device responds with a
-- MSG_STM_UNIQUE_ID_RESP with the 12-byte unique ID in the payload.
data MsgStmUniqueIdReq = MsgStmUniqueIdReq
  deriving ( Int -> MsgStmUniqueIdReq -> ShowS
[MsgStmUniqueIdReq] -> ShowS
MsgStmUniqueIdReq -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgStmUniqueIdReq] -> ShowS
$cshowList :: [MsgStmUniqueIdReq] -> ShowS
show :: MsgStmUniqueIdReq -> String
$cshow :: MsgStmUniqueIdReq -> String
showsPrec :: Int -> MsgStmUniqueIdReq -> ShowS
$cshowsPrec :: Int -> MsgStmUniqueIdReq -> ShowS
Show, ReadPrec [MsgStmUniqueIdReq]
ReadPrec MsgStmUniqueIdReq
Int -> ReadS MsgStmUniqueIdReq
ReadS [MsgStmUniqueIdReq]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgStmUniqueIdReq]
$creadListPrec :: ReadPrec [MsgStmUniqueIdReq]
readPrec :: ReadPrec MsgStmUniqueIdReq
$creadPrec :: ReadPrec MsgStmUniqueIdReq
readList :: ReadS [MsgStmUniqueIdReq]
$creadList :: ReadS [MsgStmUniqueIdReq]
readsPrec :: Int -> ReadS MsgStmUniqueIdReq
$creadsPrec :: Int -> ReadS MsgStmUniqueIdReq
Read, MsgStmUniqueIdReq -> MsgStmUniqueIdReq -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgStmUniqueIdReq -> MsgStmUniqueIdReq -> Bool
$c/= :: MsgStmUniqueIdReq -> MsgStmUniqueIdReq -> Bool
== :: MsgStmUniqueIdReq -> MsgStmUniqueIdReq -> Bool
$c== :: MsgStmUniqueIdReq -> MsgStmUniqueIdReq -> Bool
Eq )

instance Binary MsgStmUniqueIdReq where
  get :: Get MsgStmUniqueIdReq
get =
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgStmUniqueIdReq
MsgStmUniqueIdReq

  put :: MsgStmUniqueIdReq -> Put
put MsgStmUniqueIdReq
MsgStmUniqueIdReq =
    forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
$(makeSBP 'msgStmUniqueIdReq ''MsgStmUniqueIdReq)
$(makeJSON "_msgStmUniqueIdReq_" ''MsgStmUniqueIdReq)
$(makeLenses ''MsgStmUniqueIdReq)

msgStmUniqueIdResp :: Word16
msgStmUniqueIdResp :: Word16
msgStmUniqueIdResp = Word16
0x00E5

-- | SBP class for message MSG_STM_UNIQUE_ID_RESP (0x00E5).
--
-- This message reads the device's hard-coded unique ID. The host requests the
-- ID by sending a MSG_STM_UNIQUE_ID_REQ. The device responds with a
-- MSG_STM_UNIQUE_ID_RESP with the 12-byte unique ID in the payload.
data MsgStmUniqueIdResp = MsgStmUniqueIdResp
  { MsgStmUniqueIdResp -> [Word8]
_msgStmUniqueIdResp_stm_id :: ![Word8]
    -- ^ Device unique ID
  } deriving ( Int -> MsgStmUniqueIdResp -> ShowS
[MsgStmUniqueIdResp] -> ShowS
MsgStmUniqueIdResp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgStmUniqueIdResp] -> ShowS
$cshowList :: [MsgStmUniqueIdResp] -> ShowS
show :: MsgStmUniqueIdResp -> String
$cshow :: MsgStmUniqueIdResp -> String
showsPrec :: Int -> MsgStmUniqueIdResp -> ShowS
$cshowsPrec :: Int -> MsgStmUniqueIdResp -> ShowS
Show, ReadPrec [MsgStmUniqueIdResp]
ReadPrec MsgStmUniqueIdResp
Int -> ReadS MsgStmUniqueIdResp
ReadS [MsgStmUniqueIdResp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgStmUniqueIdResp]
$creadListPrec :: ReadPrec [MsgStmUniqueIdResp]
readPrec :: ReadPrec MsgStmUniqueIdResp
$creadPrec :: ReadPrec MsgStmUniqueIdResp
readList :: ReadS [MsgStmUniqueIdResp]
$creadList :: ReadS [MsgStmUniqueIdResp]
readsPrec :: Int -> ReadS MsgStmUniqueIdResp
$creadsPrec :: Int -> ReadS MsgStmUniqueIdResp
Read, MsgStmUniqueIdResp -> MsgStmUniqueIdResp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgStmUniqueIdResp -> MsgStmUniqueIdResp -> Bool
$c/= :: MsgStmUniqueIdResp -> MsgStmUniqueIdResp -> Bool
== :: MsgStmUniqueIdResp -> MsgStmUniqueIdResp -> Bool
$c== :: MsgStmUniqueIdResp -> MsgStmUniqueIdResp -> Bool
Eq )

instance Binary MsgStmUniqueIdResp where
  get :: Get MsgStmUniqueIdResp
get = do
    [Word8]
_msgStmUniqueIdResp_stm_id <- forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM Int
12 Get Word8
getWord8
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgStmUniqueIdResp {[Word8]
_msgStmUniqueIdResp_stm_id :: [Word8]
_msgStmUniqueIdResp_stm_id :: [Word8]
..}

  put :: MsgStmUniqueIdResp -> Put
put MsgStmUniqueIdResp {[Word8]
_msgStmUniqueIdResp_stm_id :: [Word8]
_msgStmUniqueIdResp_stm_id :: MsgStmUniqueIdResp -> [Word8]
..} = do
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Word8 -> Put
putWord8 [Word8]
_msgStmUniqueIdResp_stm_id

$(makeSBP 'msgStmUniqueIdResp ''MsgStmUniqueIdResp)
$(makeJSON "_msgStmUniqueIdResp_" ''MsgStmUniqueIdResp)
$(makeLenses ''MsgStmUniqueIdResp)

msgM25FlashWriteStatus :: Word16
msgM25FlashWriteStatus :: Word16
msgM25FlashWriteStatus = Word16
0x00F3

-- | SBP class for message MSG_M25_FLASH_WRITE_STATUS (0x00F3).
--
-- The flash status message writes to the 8-bit M25 flash status register. The
-- device replies with a MSG_FLASH_DONE message.
data MsgM25FlashWriteStatus = MsgM25FlashWriteStatus
  { MsgM25FlashWriteStatus -> [Word8]
_msgM25FlashWriteStatus_status :: ![Word8]
    -- ^ Byte to write to the M25 flash status register
  } deriving ( Int -> MsgM25FlashWriteStatus -> ShowS
[MsgM25FlashWriteStatus] -> ShowS
MsgM25FlashWriteStatus -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsgM25FlashWriteStatus] -> ShowS
$cshowList :: [MsgM25FlashWriteStatus] -> ShowS
show :: MsgM25FlashWriteStatus -> String
$cshow :: MsgM25FlashWriteStatus -> String
showsPrec :: Int -> MsgM25FlashWriteStatus -> ShowS
$cshowsPrec :: Int -> MsgM25FlashWriteStatus -> ShowS
Show, ReadPrec [MsgM25FlashWriteStatus]
ReadPrec MsgM25FlashWriteStatus
Int -> ReadS MsgM25FlashWriteStatus
ReadS [MsgM25FlashWriteStatus]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsgM25FlashWriteStatus]
$creadListPrec :: ReadPrec [MsgM25FlashWriteStatus]
readPrec :: ReadPrec MsgM25FlashWriteStatus
$creadPrec :: ReadPrec MsgM25FlashWriteStatus
readList :: ReadS [MsgM25FlashWriteStatus]
$creadList :: ReadS [MsgM25FlashWriteStatus]
readsPrec :: Int -> ReadS MsgM25FlashWriteStatus
$creadsPrec :: Int -> ReadS MsgM25FlashWriteStatus
Read, MsgM25FlashWriteStatus -> MsgM25FlashWriteStatus -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsgM25FlashWriteStatus -> MsgM25FlashWriteStatus -> Bool
$c/= :: MsgM25FlashWriteStatus -> MsgM25FlashWriteStatus -> Bool
== :: MsgM25FlashWriteStatus -> MsgM25FlashWriteStatus -> Bool
$c== :: MsgM25FlashWriteStatus -> MsgM25FlashWriteStatus -> Bool
Eq )

instance Binary MsgM25FlashWriteStatus where
  get :: Get MsgM25FlashWriteStatus
get = do
    [Word8]
_msgM25FlashWriteStatus_status <- forall (m :: * -> *) a. Applicative m => Int -> m a -> m [a]
replicateM Int
1 Get Word8
getWord8
    forall (f :: * -> *) a. Applicative f => a -> f a
pure MsgM25FlashWriteStatus {[Word8]
_msgM25FlashWriteStatus_status :: [Word8]
_msgM25FlashWriteStatus_status :: [Word8]
..}

  put :: MsgM25FlashWriteStatus -> Put
put MsgM25FlashWriteStatus {[Word8]
_msgM25FlashWriteStatus_status :: [Word8]
_msgM25FlashWriteStatus_status :: MsgM25FlashWriteStatus -> [Word8]
..} = do
    forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Word8 -> Put
putWord8 [Word8]
_msgM25FlashWriteStatus_status

$(makeSBP 'msgM25FlashWriteStatus ''MsgM25FlashWriteStatus)
$(makeJSON "_msgM25FlashWriteStatus_" ''MsgM25FlashWriteStatus)
$(makeLenses ''MsgM25FlashWriteStatus)