KISS Data Aquisition and Control System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

148 lines
5.6 KiB

  1. #define CLOCK_CNTR_ADDR 0x00000000
  2. #define ADC_STATE_ADDR 0x00000004
  3. #define ADC_CNTRL_STR_ADDR 0x00000008
  4. #define ADC_CNTRL_CHANGE 0x0000000C
  5. #define ADC_ADDR 0x00000010
  6. #define ADC_SIZE 0x00000014
  7. #define ADC_SAMPLE_DIVISOR 0x00000018
  8. #define PRU1_NUM_BLOCKS 0x0000001C
  9. #define PRU0_NUM_BLOCKS 0x00000020
  10. #define BLOCK_SIZE_ADDR 0x00000024
  11. #define PRU1_WR_FLAG 0x00000028
  12. #define PRU1_BUFF_COUNT 0x0000002C
  13. #define PRU1_HEAD 0x00000030
  14. #define PRU1_WRAP_COUNT 0x00000034
  15. #define PRU0_WR_FLAG 0x00000038
  16. #define PRU0_BUFF_COUNT 0x0000003C
  17. #define PRU0_HEAD 0x00000040
  18. #define PRU0_WRAP_COUNT 0x00000044
  19. // This map documents pin mapping to the ADS1287, and the associated registers
  20. #define PWDN_B_CH_1_4 r30.t6 // Pin 8.39
  21. #define PWDN_C_CH_1_4 r30.t7 // Pin 8.40
  22. #define PWDN_B_CH_5_8 r30.t4 // Pin 8.41
  23. #define PWDN_D_CH_1_4 r30.t5 // Pin 8.42
  24. #define PWDN_A_CH_5_8 r30.t2 // Pin 8.43
  25. #define PWDN_D_CH_5_8 r30.t3 // Pin 8.44
  26. #define PWDN_A_CH_1_4 r30.t0 // Pin 8.45
  27. #define PWDN_C_CH_5_8 r30.t1 // Pin 8.46
  28. #define DELAY_PULSES 0x10000
  29. // SPI Interface to AD1278 B & D vi PRU1
  30. #define SPI_CLK_B_D_PIN R30.t8 // Pin 8.27
  31. #define SPI_DSR_B_D_PIN R31.t10 // Pin 8.28
  32. #define SPI_DATA_IN_B_D_PIN R31.t11 // Pin 8.30
  33. #define SPI_SYNC_PIN R30.t9 // Pin 8.29
  34. // SPI Interface to AD1278 A & C vi PRU0
  35. #define SPI_CLK_A_C_PIN R30.t1 // Pin 9.29
  36. #define SPI_DSR_A_C_PIN R31.t5 // Pin 9.27
  37. #define SPI_DATA_IN_A_C_PIN R31.t3 // Pin 9.28
  38. #define PWDN_B_1_4_BIT 0x1 // Pin 8.39
  39. #define PWDN_C_1_4_BIT 0x2 // Pin 8.40
  40. #define PWDN_B_5_8_BIT 0x4 // Pin 8.41
  41. #define PWDN_D_1_4_BIT 0x8 // Pin 8.42
  42. #define PWDN_A_5_8_BIT 0x10 // Pin 8.43
  43. #define PWDN_D_5_8_BIT 0x20 // Pin 8.44
  44. #define PWDN_A_1_4_BIT 0x40 // Pin 8.45
  45. #define PWDN_C_5_8_BIT 0x80 // Pin 8.46
  46. // Register Use
  47. // R0 General Purpose / Indexing
  48. // R1 General Purpose
  49. #define CLOCK_COUNT r2 // Clock Counter used to determine SCLOCK frequency
  50. #define RUN_STATE r3 // Run State - can turn off data acq via this
  51. #define ADC_CNTRL_STR r4 // ADC Control string used to enable/disable daq channels and daq
  52. #define ADC_CHNG_FLG r5 // ADC Control Change flag used to indicate a settings change
  53. #define SMPL_BIT_CNTR r6 // Sample bit counter, used to count number of bits read
  54. #define CHAN_BITMASK r7 // Channel bitmask used to append channel in MSB of the sample
  55. #define SHR_MEM_PTR r8 // Pointer to the shared memory buffer used to store data
  56. #define SHR_MEM_SZ r9 // Size of shared memory buffer
  57. #define COUNT r10 // Sample count
  58. #define HEAD r11 // Buffer head
  59. #define TAIL r12 // Buffer Tail
  60. #define PRU_DATA_STRT r13 // We store a pointer to the beginning of buffer space here
  61. #define CURRENT_SAMPLE r14
  62. #define CURRENT_BUF r15 // Current 128K buffer we are writing to (0 - 9)
  63. #define CUR_BUF_ADRS r16 // Memory address of current 128K buffer
  64. #define CUR_BUF_LEFT r17 // This is the amount left of the current buffer in bytes
  65. #define SHR_MEM_START r18 // Address of shared memory region
  66. #define NUM_BLOCKS r19 // Number of 128k blocks we are going to record
  67. #define BUFF_COUNT r20
  68. #define SAMPLE1 r21
  69. #define SAMPLE2 r22
  70. #define SAMPLE3 r23
  71. #define SAMPLE4 r24
  72. #define SAMPLE5 r25
  73. #define SAMPLE6 r26
  74. #define SAMPLE7 r27
  75. #define SAMPLE8 r28
  76. #define WRAP_COUNT r29
  77. // R30 and R31 are input/output registers, do not use for general purpose regs.
  78. #define BUFSIZE 0x20000 // 128K is optimal flash write size for bbone.
  79. #define SHARED_MEM_SIZE 0x100000
  80. #define QUEUE_SIZE 8 // Number of buffers of BUFSIZE in the queue
  81. #define DAQ_FILE_SIZE 2000 // Number of 128k blocks.
  82. //#define DAQ_FILE_SIZE 0x40 // Number of 128k blocks.
  83. #define PRU1_START_OFFSET 0x00000100
  84. #define PRU0_START_OFFSET 0x00100000
  85. #define FULL_COUNT 0x00FFFFFF
  86. #define BUF_HDR_SIZE 32 // 32 Byte header contained at start of 128k buffer
  87. #define SAMPLE_SIZE 24
  88. #define ADS_CONTROL_STRING 0x1FF // Banks A enabled
  89. #define ADS_SAMPLE_DIVISOR 0x1
  90. #define ADS_CLOCKS 0x0E /// Number of instructions to wait between toggling clock high to low.
  91. //#define ADS_CLOCKS 0x6 /// Number of instructions to wait between toggling clock high to low.
  92. #define PRU0_ADC_CONTROL_PRU 0 // PRU 0 controls ADC2 and ADC3
  93. #define PRU1_ADC_CONTROL_PRU 1 // PRU 1 controls power up/down of ads1278 channels, ADC0 and ADC1
  94. #define BYTES_PER_SAMPLE 4
  95. #define ADS_BOARD_ENABLE 0x100
  96. #define ADC_PRU_DATA_SIZE 128
  97. #define INSTRUCTIONS_PER_SAMPLE 0x02509 //Roughly the number of delay count to be equal to one minute
  98. #define OK 1
  99. #define ERR -1
  100. #define MAP_SIZE 0x0FFFFFFF
  101. #define MAP_MASK (MAP_SIZE - 1)
  102. #define MMAP0_LOC "/sys/class/uio/uio0/maps/map0/"
  103. #define MMAP1_LOC "/sys/class/uio/uio0/maps/map1/"
  104. #define PRU0_R31_VEC_VALID 32 // allows notification of program completion
  105. #define PRU_EVTOUT_0 0 // the event number that is sent back
  106. #define STOP 0
  107. #define RUN 1
  108. #define TEST 2
  109. #define CHANGE 1
  110. #define NO_CHANGE 0
  111. #define TRUE 1
  112. #define FALSE 0
  113. #define ENABLED 1