Developer Application Interface (ARC API) v3.6.2
ARC, Inc. GenII/III Application Interface
CArcPCI.h
Go to the documentation of this file.
1// +------------------------------------------------------------------------------------------------------------------+
2// | FILE: CArcPCI.h |
3// +------------------------------------------------------------------------------------------------------------------+
4// | PURPOSE: This file defines the ARC-64 PCI device class. |
5// | |
6// | AUTHOR: Scott Streit DATE: ? |
7// | |
8// | Copyright Astronomical Research Cameras, Inc. All rights reserved. |
9// +------------------------------------------------------------------------------------------------------------------+
12#pragma once
13
14#ifdef _WINDOWS
15#pragma warning( disable: 4251 )
16#endif
17
18#include <string_view>
19#include <filesystem>
20#include <vector>
21#include <string>
22#include <memory>
23
24#include <CArcDeviceDllMain.h>
25#include <CArcPCIBase.h>
26#include <CArcStringList.h>
27#include <ArcDefs.h>
28
29using namespace std::string_literals;
30
31
32namespace arc
33{
34 namespace gen3
35 {
36
43 class GEN3_CARCDEVICE_API CArcPCI : public CArcPCIBase
44 {
45 public:
46
49 CArcPCI( void );
50
53 ~CArcPCI( void );
54
58 constexpr std::string_view toString( void );
59
60 // CArcPCIBase methods
61 // +-------------------------------------------------+
62
68 std::uint32_t getCfgSpByte( const std::uint32_t uiOffset );
69
75 std::uint32_t getCfgSpWord( const std::uint32_t uiOffset );
76
82 std::uint32_t getCfgSpDWord( const std::uint32_t uiOffset );
83
89 void setCfgSpByte( const std::uint32_t uiOffset, const std::uint32_t uiValue );
90
96 void setCfgSpWord( const std::uint32_t uiOffset, const std::uint32_t uiValue );
97
103 void setCfgSpDWord( const std::uint32_t uiOffset, const std::uint32_t uiValue );
104
110 void getCfgSp( void );
111
118 void getBarSp( void );
119
120
121 // Device access
122 // +-------------------------------------------------+
123
127 static void findDevices( void );
128
132 static std::uint32_t deviceCount( void ) noexcept;
133
138 static const std::weak_ptr<std::string[]> getDeviceStringList( void );
139
143 bool isOpen( void ) noexcept;
144
149 void open( const std::uint32_t uiDeviceNumber = 0 );
150
157 void open( const std::uint32_t uiDeviceNumber, const std::uint32_t uiBytes );
158
167 void open( const std::uint32_t uiDeviceNumber, const std::uint32_t uiRows, const std::uint32_t uiCols );
168
171 void close( void );
172
176 void reset( void );
177
182 bool getCommonBufferProperties( void );
183
189 void mapCommonBuffer( std::size_t uiBytes = 0 );
190
194 void unMapCommonBuffer( void );
195
199 std::uint32_t getId( void );
200
205 std::uint32_t getStatus( void );
206
209 void clearStatus( void );
210
215 void set2xFOTransmitter( bool bOnOff );
216
221 void loadDeviceFile( const std::filesystem::path& tFile );
222
223 // Setup & General commands
224 // +-------------------------------------------------+
225
233 std::uint32_t command( const std::initializer_list<const std::uint32_t>& tCmdList );
234
239 std::uint32_t getControllerId( void );
240
244 void resetController( void );
245
250 bool isControllerConnected( void );
251
252
253 // expose commands
254 // +-------------------------------------------------+
255
259 void stopExposure( void );
260
265 bool isReadout( void );
266
271 std::uint32_t getPixelCount( void );
272
277 std::uint32_t getCRPixelCount( void );
278
283 std::uint32_t getFrameCount( void );
284
285
286 // PCI only commands
287 // +-------------------------------------------------+
288
295 void setHCTR( const std::uint32_t uiVal );
296
301 std::uint32_t getHSTR( void );
302
307 std::uint32_t getHCTR( void );
308
314 std::uint32_t PCICommand( const std::uint32_t uiCommand );
315
316
317 // Driver ioctl commands
318 // +------------------------------------------------------------------------------
319
321 static constexpr auto ASTROPCI_GET_HCTR = static_cast< std::uint32_t >( 0x01 );
322
324 static constexpr auto ASTROPCI_GET_PROGRESS = static_cast< std::uint32_t >( 0x02 );
325
327 static constexpr auto ASTROPCI_GET_DMA_ADDR = static_cast< std::uint32_t >( 0x03 );
328
330 static constexpr auto ASTROPCI_GET_HSTR = static_cast< std::uint32_t >( 0x04 );
331
333 static constexpr auto ASTROPCI_MEM_MAP = static_cast< std::uint32_t >( 0x05 );
334
336 static constexpr auto ASTROPCI_GET_DMA_SIZE = static_cast< std::uint32_t >( 0x06 );
337
339 static constexpr auto ASTROPCI_GET_FRAMES_READ = static_cast< std::uint32_t >( 0x07 );
340
343 static constexpr auto ASTROPCI_HCVR_DATA = static_cast< std::uint32_t >( 0x10 );
344
346 static constexpr auto ASTROPCI_SET_HCTR = static_cast< std::uint32_t >( 0x11 );
347
349 static constexpr auto ASTROPCI_SET_HCVR = static_cast< std::uint32_t >( 0x12 );
350
352 static constexpr auto ASTROPCI_PCI_DOWNLOAD = static_cast< std::uint32_t >( 0x13 );
353
355 static constexpr auto ASTROPCI_PCI_DOWNLOAD_WAIT = static_cast< std::uint32_t >( 0x14 );
356
358 static constexpr auto ASTROPCI_COMMAND = static_cast< std::uint32_t >( 0x15 );
359
361 static constexpr auto ASTROPCI_MEM_UNMAP = static_cast< std::uint32_t >( 0x16 );
362
364 static constexpr auto ASTROPCI_ABORT = static_cast< std::uint32_t >( 0x17 );
365
367 static constexpr auto ASTROPCI_CONTROLLER_DOWNLOAD = static_cast< std::uint32_t >( 0x19 );
368
370 static constexpr auto ASTROPCI_GET_CR_PROGRESS = static_cast< std::uint32_t >( 0x20 );
371
373 static constexpr auto ASTROPCI_GET_DMA_LO_ADDR = static_cast< std::uint32_t >( 0x21 );
374
376 static constexpr auto ASTROPCI_GET_DMA_HI_ADDR = static_cast< std::uint32_t >( 0x22 );
377
379 static constexpr auto ASTROPCI_GET_CONFIG_BYTE = static_cast< std::uint32_t >( 0x30 );
380
382 static constexpr auto ASTROPCI_GET_CONFIG_WORD = static_cast< std::uint32_t >( 0x31 );
383
385 static constexpr auto ASTROPCI_GET_CONFIG_DWORD = static_cast< std::uint32_t >( 0x32 );
386
388 static constexpr auto ASTROPCI_SET_CONFIG_BYTE = static_cast< std::uint32_t >( 0x33 );
389
391 static constexpr auto ASTROPCI_SET_CONFIG_WORD = static_cast< std::uint32_t >( 0x34 );
392
394 static constexpr auto ASTROPCI_SET_CONFIG_DWORD = static_cast< std::uint32_t >( 0x35 );
395
396
397 // Status register ( HSTR ) constants
398 // +------------------------------------------------------------------------------
399
401 static constexpr auto HTF_BIT_MASK = static_cast< std::uint32_t >( 0x00000038 );
402
420 enum class ePCIStatus : std::uint32_t
421 {
422 TIMEOUT_STATUS = 0,
423 DONE_STATUS,
424 READ_REPLY_STATUS,
425 ERROR_STATUS,
426 SYSTEM_RESET_STATUS,
427 READOUT_STATUS,
428 BUSY_STATUS
429 };
430
431
432 // PCI commands
433 // +----------------------------------------------------------------------------
434
436 static constexpr auto PCI_RESET = static_cast< std::uint32_t >( 0x8077 );
437
439 static constexpr auto ABORT_READOUT = static_cast< std::uint32_t >( 0x8079 );
440
442 static constexpr auto BOOT_EEPROM = static_cast< std::uint32_t >( 0x807B );
443
445 static constexpr auto READ_HEADER = static_cast< std::uint32_t >( 0x81 );
446
448 static constexpr auto RESET_CONTROLLER = static_cast< std::uint32_t >( 0x87 );
449
451 static constexpr auto INITIALIZE_IMAGE_ADDRESS = static_cast< std::uint32_t >( 0x91 );
452
454 static constexpr auto WRITE_COMMAND = static_cast< std::uint32_t >( 0xB1 );
455
456
457 // +----------------------------------------------------------------------------
458 // | PCI File Download Constants
459 // +----------------------------------------------------------------------------
460
462 static constexpr auto HTF_MASK = static_cast< std::uint32_t >( 0x200 );
463
465 static constexpr auto HTF_CLEAR_MASK = static_cast< std::uint32_t >( 0xFFFFFCFF ); // Bits 8 and 9
466
468 static constexpr auto MAX_PCI_COMM_TEST = static_cast< std::uint32_t >( 3 );
469
471 static constexpr auto PCI_COM_TEST_VALUE = static_cast< std::uint32_t >( 0xABC123 );
472
473 private:
474
481 std::uint32_t getContinuousImageSize( const std::uint32_t uiImageSize );
482
490 std::uint32_t smallCamDLoad( const std::uint32_t uiBoardId, const std::vector<std::uint32_t>* pvData );
491
500 void loadGen23ControllerFile( const std::filesystem::path& tFilename, bool bValidate, bool* pAbort = nullptr );
501
504 void setByteSwapping( void );
505
514 const std::string formatPCICommand( const std::uint32_t uiCmd, const std::uint64_t uiReply, const std::uint32_t uiArg = CArcDevice::NOPARAM, bool bGetSysErr = false );
515
524 const std::string formatPCICommand( const std::uint32_t uiCmd, const std::uint64_t uiReply, const std::initializer_list<const std::uint32_t>& tArgList, bool bGetSysErr = false );
525
531 std::unique_ptr<CArcStringList> getHSTRBitList( const std::uint32_t uiData, bool bDrawSeparator = false );
532
537 std::function<std::uint32_t( const std::uint16_t )> m_fnValidDeviceVendorId;
538
540 static std::unique_ptr<std::vector<arc::gen3::arcDev_t>> m_pvDevList;
541
543 static std::shared_ptr<std::string[]> m_psDevList;
544 };
545
546 } // end gen3 namespace
547} // end arc namespace
static constexpr auto NOPARAM
Definition: CArcDevice.h:604
Definition: CArcPCIBase.h:95
Definition: CArcPCI.h:44