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.

154 lines
3.6 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __TUPUS_PRU_EXTENSION_HEADER__
  2. #define __TUPUS_PRU_EXTENSION_HEADER__
  3. #include <stdint.h>
  4. typedef enum {
  5. TU_COMMAND_UNDEF = -1,
  6. TU_COMMAND_NONE = 0,
  7. TU_COMMAND_GET_ID = 1,
  8. TU_COMMAND_SET_ADDRESS,
  9. TU_COMMAND_SET_VSP,
  10. TU_COMMAND_SET_HSP,
  11. TU_COMMAND_END_CONFIG,
  12. TU_COMMAND_START_MOTORS,
  13. TU_COMMAND_GET_COUNT,
  14. TU_COMMAND_SET_DMA,
  15. TU_COMMAND_SET_MODE,
  16. TU_COMMAND_INIT,
  17. TU_COMMAND_ENABLE_ADC,
  18. TU_COMMAND_DISABLE_ADC,
  19. TU_COMMAND_START_SYNC,
  20. TU_COMMAND_STOP_SYNC,
  21. TU_COMMAND_Z_MARK,
  22. TU_COMMAND_RESTART,
  23. TU_COMMAND_HALT
  24. }TUPUS_COMMAND;
  25. typedef enum{
  26. TU_STATUS_UNDEF = -1,
  27. TU_STATUS_NONE = 0,
  28. TU_STATUS_INIT = 1,
  29. TU_STATUS_OK,
  30. TU_STATUS_START_MOTORS,
  31. TU_STATUS_WAITING,
  32. TU_STATUS_BUSY,
  33. TU_ERROR_ZERO1,
  34. TU_ERROR_ZERO2,
  35. TU_ERROR_GENERIC
  36. }TUPUS_STATUS;
  37. typedef enum{
  38. CORE_INIT = 0,
  39. CORE_CONFIG = 1,
  40. CORE_WORK_LVL_1 = 2,
  41. CORE_WORK_LVL_2,
  42. CORE_WORK_LVL_3,
  43. CORE_WORK_LVL_4,
  44. CORE_WORK_LVL_5,
  45. CORE_WORK_LVL_6,
  46. CORE_WORK_LVL_7,
  47. CORE_WORK_LVL_8,
  48. CORE_WORK_LVL_9,
  49. CORE_WORK_LVL_10,
  50. CORE_HALTED
  51. } CORE_WORK_STATUS;
  52. typedef enum{
  53. TU_CL_STATUS_MASK = 0x00,
  54. TU_HZ_STATUS_MASK = 0x01,
  55. TU_VZ_STATUS_MASK = 0x02,
  56. TU_HM_STATUS_MASK = 0x04,
  57. TU_VM_STATUS_MASK = 0x08,
  58. TU_SG_STATUS_MASK = 0x0F,
  59. TU_WE_STATUS_MASK = 0x10,
  60. } CORE_STATUS_MASKS;
  61. typedef struct {
  62. union {
  63. volatile uint32_t STATUS;
  64. volatile struct{
  65. uint32_t Q_motor_cnt:14;
  66. uint32_t Q_index_flg:1;
  67. uint32_t B_motor_cnt:14;
  68. uint32_t B_index_flg:1;
  69. uint32_t sun_bit0:1;
  70. uint32_t sun_bit1:1;
  71. //uint32_t sun_bit2:1;
  72. //uint32_t sun_bit3:1;
  73. }STATUS_bit;
  74. };
  75. union {
  76. volatile uint32_t MODE;
  77. volatile struct{
  78. uint32_t wait_Q_index:1;
  79. uint32_t wait_B_index:1;
  80. uint32_t pulse_enabled:1;
  81. uint32_t series_enabled:1;
  82. uint32_t sun_bit2:1;
  83. uint32_t sun_bit3:1;
  84. uint32_t sun_bit4:1;
  85. uint32_t sun_bit5:1;
  86. uint32_t dc:1;
  87. uint32_t Q_index_flg_id:2;
  88. uint32_t B_index_flg_id:2;
  89. uint32_t rsrvd: 19;
  90. } MODE_bit;
  91. };
  92. uint32_t Q_P2P_TICKS;
  93. uint32_t Q_P_COUNT;
  94. uint32_t B_P2P_TICKS;
  95. uint32_t B_P_COUNT;
  96. uint32_t Q_RUN_COUNTER;
  97. uint32_t B_RUN_COUNTER;
  98. } HW_STATUS_MODE; // 8 x 4 bytes
  99. typedef struct{
  100. volatile int32_t HOST_status;
  101. volatile int32_t HOST_command;
  102. volatile uint32_t HOST_address;
  103. volatile uint32_t HOST_data;
  104. /*********** **********/
  105. volatile uint32_t PRU_id;
  106. volatile int32_t PRU_status;
  107. volatile uint32_t PRU_address;
  108. volatile uint32_t PRU_data;
  109. /*********** **********/
  110. volatile uint32_t CORE_id;
  111. } structTUPUS; // 9 x 4 bytes
  112. typedef struct{
  113. volatile uint32_t errorAngle:2; // 0-1
  114. volatile uint32_t angleID:12; // 2-13
  115. volatile uint32_t detectionMode:1; // 14-14
  116. volatile uint32_t activeTH:1; // 15-15
  117. volatile uint32_t currentMirror:2; // 16-17
  118. volatile uint32_t flipCount:8; // 18-25
  119. volatile uint32_t baseMode:1; // 26-26
  120. volatile uint32_t headMode:2; // 27-28
  121. volatile uint32_t rsrvd:3; // 29-31
  122. } structDetectorStatus; // 1x4
  123. typedef struct{
  124. volatile uint32_t headZero:1;
  125. volatile uint32_t baseZero:1;
  126. volatile uint32_t rsrvd:14;
  127. volatile uint32_t sun_bits:16;
  128. } structSignalStatus; // 1x4
  129. #ifndef __linux__ // PRU internals
  130. //#define DR_TUPUS (*((volatile structTUPUS*) 0x00000FD0 ))
  131. //#define HW_MY (*((volatile HW_STATUS_MODE*) 0x00000F9C ))
  132. //#define HW_CORE1 (*((volatile HW_STATUS_MODE*) 0x00002F9C ))
  133. //#define DR_COPUS (*((volatile structCOPUS*) 0x00000FF8 ))
  134. //#define DR_POPUS (*((volatile structPOPUS*) 0x00002FF8 ))
  135. #endif
  136. #endif