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

#ifndef __TUPUS_PRU_EXTENSION_HEADER__
#define __TUPUS_PRU_EXTENSION_HEADER__
#include <stdint.h>
typedef enum {
TU_COMMAND_UNDEF = -1,
TU_COMMAND_NONE = 0,
TU_COMMAND_GET_ID = 1,
TU_COMMAND_SET_ADDRESS,
TU_COMMAND_SET_VSP,
TU_COMMAND_SET_HSP,
TU_COMMAND_END_CONFIG,
TU_COMMAND_START_MOTORS,
TU_COMMAND_GET_COUNT,
TU_COMMAND_SET_DMA,
TU_COMMAND_SET_MODE,
TU_COMMAND_INIT,
TU_COMMAND_ENABLE_ADC,
TU_COMMAND_DISABLE_ADC,
TU_COMMAND_START_SYNC,
TU_COMMAND_STOP_SYNC,
TU_COMMAND_Z_MARK,
TU_COMMAND_RESTART,
TU_COMMAND_HALT
}TUPUS_COMMAND;
typedef enum{
TU_STATUS_UNDEF = -1,
TU_STATUS_NONE = 0,
TU_STATUS_INIT = 1,
TU_STATUS_OK,
TU_STATUS_START_MOTORS,
TU_STATUS_WAITING,
TU_STATUS_BUSY,
TU_ERROR_ZERO1,
TU_ERROR_ZERO2,
TU_ERROR_GENERIC
}TUPUS_STATUS;
typedef enum{
CORE_INIT = 0,
CORE_CONFIG = 1,
CORE_WORK_LVL_1 = 2,
CORE_WORK_LVL_2,
CORE_WORK_LVL_3,
CORE_WORK_LVL_4,
CORE_WORK_LVL_5,
CORE_WORK_LVL_6,
CORE_WORK_LVL_7,
CORE_WORK_LVL_8,
CORE_WORK_LVL_9,
CORE_WORK_LVL_10,
CORE_HALTED
} CORE_WORK_STATUS;
typedef enum{
TU_CL_STATUS_MASK = 0x00,
TU_HZ_STATUS_MASK = 0x01,
TU_VZ_STATUS_MASK = 0x02,
TU_HM_STATUS_MASK = 0x04,
TU_VM_STATUS_MASK = 0x08,
TU_SG_STATUS_MASK = 0x0F,
TU_WE_STATUS_MASK = 0x10,
} CORE_STATUS_MASKS;
typedef struct {
union {
volatile uint32_t STATUS;
volatile struct{
uint32_t Q_motor_cnt:14;
uint32_t Q_index_flg:1;
uint32_t B_motor_cnt:14;
uint32_t B_index_flg:1;
uint32_t sun_bit0:1;
uint32_t sun_bit1:1;
//uint32_t sun_bit2:1;
//uint32_t sun_bit3:1;
}STATUS_bit;
};
union {
volatile uint32_t MODE;
volatile struct{
uint32_t wait_Q_index:1;
uint32_t wait_B_index:1;
uint32_t pulse_enabled:1;
uint32_t series_enabled:1;
uint32_t sun_bit2:1;
uint32_t sun_bit3:1;
uint32_t sun_bit4:1;
uint32_t sun_bit5:1;
uint32_t dc:1;
uint32_t Q_index_flg_id:2;
uint32_t B_index_flg_id:2;
uint32_t rsrvd: 19;
} MODE_bit;
};
uint32_t Q_P2P_TICKS;
uint32_t Q_P_COUNT;
uint32_t B_P2P_TICKS;
uint32_t B_P_COUNT;
uint32_t Q_RUN_COUNTER;
uint32_t B_RUN_COUNTER;
} HW_STATUS_MODE; // 8 x 4 bytes
typedef struct{
volatile int32_t HOST_status;
volatile int32_t HOST_command;
volatile uint32_t HOST_address;
volatile uint32_t HOST_data;
/*********** **********/
volatile uint32_t PRU_id;
volatile int32_t PRU_status;
volatile uint32_t PRU_address;
volatile uint32_t PRU_data;
/*********** **********/
volatile uint32_t CORE_id;
} structTUPUS; // 9 x 4 bytes
typedef struct{
volatile uint32_t errorAngle:2; // 0-1
volatile uint32_t angleID:12; // 2-13
volatile uint32_t detectionMode:1; // 14-14
volatile uint32_t activeTH:1; // 15-15
volatile uint32_t currentMirror:2; // 16-17
volatile uint32_t flipCount:8; // 18-25
volatile uint32_t baseMode:1; // 26-26
volatile uint32_t headMode:2; // 27-28
volatile uint32_t rsrvd:3; // 29-31
} structDetectorStatus; // 1x4
typedef struct{
volatile uint32_t headZero:1;
volatile uint32_t baseZero:1;
volatile uint32_t rsrvd:14;
volatile uint32_t sun_bits:16;
} structSignalStatus; // 1x4
#ifndef __linux__ // PRU internals
//#define DR_TUPUS (*((volatile structTUPUS*) 0x00000FD0 ))
//#define HW_MY (*((volatile HW_STATUS_MODE*) 0x00000F9C ))
//#define HW_CORE1 (*((volatile HW_STATUS_MODE*) 0x00002F9C ))
//#define DR_COPUS (*((volatile structCOPUS*) 0x00000FF8 ))
//#define DR_POPUS (*((volatile structPOPUS*) 0x00002FF8 ))
#endif
#endif