-- | Construct a virtual CAN transmit mailbox that a client can use as
-- if it had sole ownership of the bus. The returned 'CANTask' must be
-- passed to an instance of 'canScheduler'; otherwise, the virtual
-- mailbox will discard requests sent to it and will never complete
-- them.
canTask :: Tower e (CANTask, AbortableTransmit ('Struct "can_message") ('Stored IBool))
canTask = do
  (abortableTransmit, canTaskReq) <- channel
  (canTaskRes, abortableComplete) <- channel
  (abortableAbort, canTaskAbortReq) <- channel
  return (CANTask { .. }, AbortableTransmit { .. })

-- | Multiplex a collection of CAN transmit tasks onto a collection of
-- hardware transmit mailboxes. The transmit mailboxes must ensure that
-- the highest-priority message queued on any of them is sent first.
canTask :: Tower e (CANTask, AbortableTransmit ('Struct "can_message") ('Stored IBool))
canTask = do
  (abortableTransmit, canTaskReq) <- channel
  (canTaskRes, abortableComplete) <- channel
  (abortableAbort, canTaskAbortReq) <- channel
  return (CANTask { .. }, AbortableTransmit { .. })

-- | Multiplex a collection of CAN transmit tasks onto a collection of
-- hardware transmit mailboxes. The transmit mailboxes must ensure that
-- the highest-priority message queued on any of them is sent first.
canTask = do
  (abortableTransmit, canTaskReq) <- channel
  (canTaskRes, abortableComplete) <- channel
  (abortableAbort, canTaskAbortReq) <- channel
  return (CANTask { .. }, AbortableTransmit { .. })

-- | Multiplex a collection of CAN transmit tasks onto a collection of
-- hardware transmit mailboxes. The transmit mailboxes must ensure that
-- the highest-priority message queued on any of them is sent first.