AJA NTV2 SDK  17.0.1.1246
NTV2 SDK 17.0.1.1246
ntv2mailbox.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef CNTV2MAILBOX_H
9 #define CNTV2MAILBOX_H
10 
11 #include "ntv2card.h"
12 #include "ntv2enums.h"
13 #include "ntv2registers2022.h"
14 #include <stdint.h>
15 
16 #define MB_tWRDATA 0 // 0x00
17 #define MB_tRDDATA 2 // 0x08
18 #define MB_tSTATUS 4 // 0x10
19 #define MB_tERROR 5 // 0x14
20 #define MB_tSIT 6 // 0x18 // send interrupt threshold
21 #define MB_tRIT 6 // 0x18 // receive interrupt threshold
22 #define MB_tIS 8 // 0x20 // interrupt status register
23 #define MB_tIE 9 // 0x24 // interrupt enable register
24 #define MB_tIP 10 // 0x28 // interrupt pending register
25 
26 #define MBS_RX_EMPTY BIT(0)
27 #define MBS_TX_FULL BIT(1)
28 #define MBS_SEND_LT_TA BIT(2) // send level <= SIT
29 #define MBS_RCV_GT_TA BIT(3) // receive level > RIT
30 
31 #define MBE_RX_EMPTY BIT(1)
32 #define MBE_TX_FULL BIT(2)
33 
34 #define MB_RX_INT BIT(1)
35 
36 #define FIFO_SIZE 1024 // 32-bit words
37 #define MB_TIMEOUT 50 // milliseconds
38 
39 #define SEQNUM_MIN 1
40 #define SEQNUM_MAX 500
41 
43 {
44 public:
45  CNTV2MailBox(CNTV2Card & device);
46  ~CNTV2MailBox();
47 
48  bool sendMsg(char * msg, uint32_t timeout); // returns response
49  bool sendMsg(uint32_t timeout);
50 
51  void getError(std::string & error);
52  void getResponse(std::string & response);
53 
54  bool WriteChannelRegister (ULWord reg, ULWord value, ULWord mask = 0xFFFFFFFF, ULWord shift = 0x0);
55 
56  bool ReadChannelRegister (const ULWord inReg, ULWord & outValue, const ULWord inMask = 0xFFFFFFFF, const ULWord inShift = 0x0);
57  inline bool ReadChannelRegister (ULWord inReg, ULWord *pOutValue, ULWord mask = 0xFFFFFFFF, ULWord shift = 0x0) {return pOutValue ? ReadChannelRegister (inReg, *pOutValue, mask, shift) : false;}
58 
59  void SetChannel(ULWord channelOffset, ULWord channelNumber);
60 
61  bool AcquireMailbox();
62  void ReleaseMailbox();
63 
64 protected:
65  bool rcvMsg(uint32_t timeout);
66 
67  bool writeMB(uint32_t val, uint32_t timeout = MB_TIMEOUT);
68  bool readMB(uint32_t & val, uint32_t timeout = MB_TIMEOUT);
69 
70  bool waitSOM(uint32_t timeout);
71  bool waitRxReady(uint32_t timeout);
72  bool waitTxReady(uint32_t timeout);
73 
74  bool rxReady();
75 
76  uint32_t getStatus();
77  uint32_t getFeatures();
78 
80 
83 
84 private:
85  void startTimer();
86  uint64_t getElapsedTime();
87  int64_t getSystemCounter();
88  int64_t getSystemFrequency();
89  uint64_t getSystemMilliseconds();
90 
91 
92  uint32_t nextSeqNum() {if (++_seqNum > SEQNUM_MAX) return SEQNUM_MIN; else return _seqNum;}
93  uint32_t currentSeqNum() {return _seqNum;}
94 
95  uint32_t chanOffset;
96  uint32_t chanNumber;
97 
98  uint32_t bOffset; // base offset
99 protected:
100  uint32_t txBuf[FIFO_SIZE+1]; // CNTV2MBController needs access to this
101 private:
102  uint32_t rxBuf[FIFO_SIZE+1];
103 
104  uint64_t _startTime;
105  uint32_t _seqNum;
106 };
107 
108 #endif // CNTV2MAILBOX_H
SEQNUM_MIN
#define SEQNUM_MIN
Definition: ntv2mailbox.h:39
CNTV2MailBox::ReadChannelRegister
bool ReadChannelRegister(ULWord inReg, ULWord *pOutValue, ULWord mask=0xFFFFFFFF, ULWord shift=0x0)
Definition: ntv2mailbox.h:57
CNTV2MailBox::mDevice
CNTV2Card & mDevice
Definition: ntv2mailbox.h:79
FIFO_SIZE
#define FIFO_SIZE
Definition: ntv2mailbox.h:36
CNTV2MailBox::mIpInternalErrorString
std::string mIpInternalErrorString
Definition: ntv2mailbox.h:82
ULWord
uint32_t ULWord
Definition: ajatypes.h:246
ntv2registers2022.h
Defines the KonaIP/IoIP S2022 registers.
ntv2card.h
Declares the CNTV2Card class.
ntv2enums.h
Enumerations for controlling NTV2 devices.
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:262
SEQNUM_MAX
#define SEQNUM_MAX
Definition: ntv2mailbox.h:40
CNTV2MailBox::mIpErrorCode
NTV2IpError mIpErrorCode
Definition: ntv2mailbox.h:81
MB_TIMEOUT
#define MB_TIMEOUT
Definition: ntv2mailbox.h:37
NTV2IpError
NTV2IpError
Definition: ntv2enums.h:4224
AJAExport
#define AJAExport
Definition: export.h:33
CNTV2MailBox
Definition: ntv2mailbox.h:42