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.
213 lines
6.1 KiB
213 lines
6.1 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
|
|
|
|
/* Mirrored inter-Core exchange structures */
|
|
typedef struct{
|
|
volatile int32_t MY_status;
|
|
volatile int32_t MY_cmd;
|
|
volatile uint32_t SCRATCH0;
|
|
volatile uint32_t SCRATCH1;
|
|
volatile uint32_t SCRATCH2;
|
|
volatile uint32_t SCRATCH3;
|
|
} structCOPUS;
|
|
|
|
typedef struct{
|
|
volatile int32_t ANOTHER_status;
|
|
volatile int32_t ANOTHER_cmd;
|
|
volatile uint32_t SCRATCH0;
|
|
volatile uint32_t SCRATCH1;
|
|
volatile uint32_t SCRATCH2;
|
|
volatile uint32_t SCRATCH3;
|
|
} structPOPUS;
|
|
|
|
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; // 10x4
|
|
|
|
typedef struct{
|
|
volatile uint32_t headZero:1;
|
|
volatile uint32_t baseZero:1;
|
|
volatile uint32_t rsrvd:14;
|
|
volatile uint32_t sun_bits:16;
|
|
} structSignalStatus; // 4x4
|
|
|
|
#ifndef __linux__ // PRU internals
|
|
|
|
#define PRUSS0_CORE_MEM_SIZE 0x01000
|
|
#define PRUSS_CORE_GAP 0x02000
|
|
#define PRUSS1_CORE_MEM_SIZE 0x02000
|
|
#define PRUSS_GAP 0x40000
|
|
|
|
#define CORE0_TUPUS_400_ADDR (PRUSS0_CORE_MEM_SIZE - sizeof(structTUPUS)) //0x00000FBB // 9x4 0x24
|
|
#define CORE0_TUPUS_401_ADDR (CORE0_TUPUS_400_ADDR + PRUSS_CORE_GAP)
|
|
#define CORE0_TUPUS_41X_ADDR (CORE0_TUPUS_400_ADDR + PRUSS_GAP)
|
|
|
|
#define CORE1_TUPUS_400_ADDR (CORE0_TUPUS_401_ADDR)
|
|
#define CORE1_TUPUS_401_ADDR (CORE0_TUPUS_400_ADDR)
|
|
#define CORE1_TUPUS_41X_ADDR (CORE0_TUPUS_401_ADDR + PRUSS_GAP)
|
|
|
|
#define CORE2_TUPUS_410_ADDR (PRUSS1_CORE_MEM_SIZE - sizeof(structTUPUS))
|
|
#define CORE2_TUPUS_411_ADDR (CORE2_TUPUS_410_ADDR + PRUSS_CORE_GAP)
|
|
#define CORE2_TUPUS_40X_ADDR (CORE2_TUPUS_410_ADDR + PRUSS_GAP)
|
|
|
|
#define CORE3_TUPUS_410_ADDR (CORE2_TUPUS_411_ADDR)
|
|
#define CORE3_TUPUS_411_ADDR (CORE2_TUPUS_410_ADDR)
|
|
#define CORE3_TUPUS_40X_ADDR (CORE2_TUPUS_411_ADDR + PRUSS_GAP)
|
|
|
|
#define PRSS0_PRU0_IO_400_ADDR (CORE0_TUPUS_400_ADDR - sizeof(PRSS0_PRU0_IO))
|
|
#define PRSS0_PRU0_IO_401_ADDR (CORE0_TUPUS_401_ADDR - sizeof(PRSS0_PRU0_IO))
|
|
#define PRSS0_PRU0_IO_41X_ADDR (CORE0_TUPUS_41X_ADDR - sizeof(PRSS0_PRU0_IO))
|
|
|
|
#define PRSS0_PRU1_IO_400_ADDR (CORE1_TUPUS_400_ADDR - sizeof(PRSS0_PRU1_IO))
|
|
#define PRSS0_PRU1_IO_401_ADDR (CORE1_TUPUS_401_ADDR - sizeof(PRSS0_PRU1_IO))
|
|
#define PRSS0_PRU1_IO_41X_ADDR (CORE1_TUPUS_41X_ADDR - sizeof(PRSS0_PRU1_IO))
|
|
|
|
#define PRSS1_PRU0_IO_410_ADDR (CORE2_TUPUS_410_ADDR - sizeof(PRSS1_PRU0_IO))
|
|
#define PRSS1_PRU0_IO_411_ADDR (CORE2_TUPUS_411_ADDR - sizeof(PRSS1_PRU0_IO))
|
|
#define PRSS1_PRU0_IO_40X_ADDR (CORE2_TUPUS_40X_ADDR - sizeof(PRSS1_PRU0_IO))
|
|
|
|
#define PRSS1_PRU1_IO_410_ADDR (CORE3_TUPUS_410_ADDR - sizeof(PRSS1_PRU1_IO))
|
|
#define PRSS1_PRU1_IO_411_ADDR (CORE3_TUPUS_411_ADDR - sizeof(PRSS1_PRU1_IO))
|
|
#define PRSS1_PRU1_IO_40X_ADDR (CORE3_TUPUS_40X_ADDR - sizeof(PRSS1_PRU1_IO))
|
|
|
|
#define HW_CORE1_ADDR (PRSS0_PRU1_IO_401_ADDR - sizeof(HW_STATUS_MODE))
|
|
#define HW_CORE0_ADDR (PRSS0_PRU1_IO_400_ADDR - sizeof(HW_STATUS_MODE))
|
|
|
|
//#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
|