📄 adis16350.h
字号:
//==========for SPI0 setup====================
#define BIT_ENABLE 1<<2 //if bit_enable then we choose number of bit select by BITs
#define CPHA 1<<3 //if CHPA then sampling data on the second clock edge .transfer data starts
//at fist CLK and ends with the last sampling edge when SSEL activation
//else sampling on the 1st clock edge.transfer data starts and
//ends with activation and deactivation of SSEL signal
#define CPOL 1<<4 //if CPOL then SCK active low else active high
#define SPI_MASTER 1<<5 //choose master mode .otherwise slave mode
#define LSBF 1<<6 // if LSBF bit 0 fist else bit 7 first
#define SPIE ((unsigned long) 1<<7) //Interrupt enable each time of SPIF of MODF active
#define BITS(n) n<<8 //control number of bits per transfer
//n=number of bits per transfer 8=<n<=15
//n=0 16 bits per transfer
#define ABRT_MASK (unsigned long) (1<<3)//mask to read status of slave abort
#define MODF_MASK (unsigned long) (1<<4)//mask to read status of mode default abort
#define ROVR_MASK (unsigned long) (1<<5)//mask to read status of overrun
#define WCOL_MASK (unsigned long) (1<<6)//mask to read status of Write collision
#define SPIF_MASK (unsigned long) (1<<7)//mask to read status of SPI transfer complette
#define SPI_CLK_SCALE(n) n //SCK=PCLK/VPBDIV/n n>=8
#define SPI_INT_FLAG_CLR 1 //write to s0spint to clear SPI int flag
//select PIN CS to control ADIS16350 chip
#define CS_ADIS16350_SELECT_PIN PINSEL0 &= (unsigned long) (~(0x11<<14)) /*select P0.7 as GPIO*/
#define CS_SETUP_OUTPUT_PIN IODIR0 |= (unsigned long) (1<<7)
//depend on chip slect pin defined
#define CS_ADIS16350_HIGH IOSET0 |= (unsigned long) 1<<7 /*set CS high*/
#define CS_ADIS16350_LOW IOCLR0 |= (unsigned long) 1<<7 /*set CS low*/
//ADIS16350 Inertial Sensor
//maximum sample rate of 819.2 samples per second
#define SUPPLY_OUT 0x0200 /*Power supply measurement */
#define XGYRO_OUT 0x0500 /*X-axis gyroscope output measurement*/
#define YGYRO_OUT 0x0600 /*Y-axis gyroscope output measurement*/
#define ZGYRO_OUT 0x0800 /*Z-axis gyroscope output measurement*/
#define XACCL_OUT 0x0A00 /*X-axis acceleration output measurement */
#define YACCL_OUT 0x0C00 /*Y-axis acceleration output measurement */
#define ZACCL_OUT 0x0E00 /*Z-axis acceleration output measurement */
#define XTEMP_OUT 0x1000 /*X-axis gyroscope sensor temperature measurement*/
#define YTEMP_OUT 0x1200 /*Y-axis gyroscope sensor temperature measurement*/
#define ZTEMP_OUT 0x1400 /*Z-axis gyroscope sensor temperature measurement*/
#define AUX_ADC 0x1600 /*Auxiliary analog input data */
#define ENDURANCE_NoneVolatile 0x0000 /*Flash memory write count length 2 bye*/
#define ENDURANCE_Volatile 0x0200 /* Output data length 22byte */
#define XGYRO_OFF_LSB 0x1A00 /*X-axis gyroscope bias offset factor */
#define XGYRO_OFF_MSB 0x1B00 /*X-axis gyroscope bias offset factor */
#define YGYRO_OFF_LSB 0x1C00 /*Y-axis gyroscope bias offset factor */
#define YGYRO_OFF_MSB 0x1D00 /*Y-axis gyroscope bias offset factor */
#define ZGYRO_OFF_LSB 0x1E00 /*Z-axis gyroscope bias offset factor */
#define ZGYRO_OFF_MSB 0x1F00 /*Z-axis gyroscope bias offset factor */
#define XACCL_OFF_LSB 0x2000 /*X-axis acceleration bias offset factor */
#define XACCL_OFF_MSB 0x2100 /*X-axis acceleration bias offset factor */
#define YACCL_OFF_LSB 0x2200 /*Y-axis acceleration bias offset factor */
#define YACCL_OFF_MSB 0x2300 /*Y-axis acceleration bias offset factor */
#define ZACCL_OFF_LSB 0x2400 /*Z-axis acceleration bias offset factor */
#define ZACCL_OFF_MSB 0x2500 /*Z-axis acceleration bias offset factor */
#define ALM_MAG1_LSB 0x2600 /*Alarm 1 amplitude threshold */
#define ALM_MAG1_MSB 0x2700 /*Alarm 1 amplitude threshold */
#define ALM_MAG2_LSB 0x2800 /*Alarm 2 amplitude threshold */
#define ALM_MAG2_MSB 0x2900 /*Alarm 2 amplitude threshold */
#define ALM_SMPL1_LSB 0x2A00 /*Alarm 1 sample size */
#define ALM_SMPL1_MSB 0x2B00 /*Alarm 1 sample size */
#define ALM_SMPL2_LSB 0x2C00 /*Alarm 2 sample size */
#define ALM_SMPL2_MSB 0x2D00 /*Alarm 2 sample size */
#define ALM_CTRL_LSB 0x2E00 /*Alarm control */
#define ALM_CTRL_MSB 0x2F00 /*Alarm control */
#define AUX_DAC_LSB 0x3000 /* volatile Auxiliary DAC data */
#define AUX_DAC_MSB 0x3100 /* volatile Auxiliary DAC data */
#define GPIO_CTRL_LSB 0x3200 /* Volatile Auxiliary digital input/output control */
#define GPIO_CTRL_MSB 0x3300 /* Volatile Auxiliary digital input/output control */
#define MSC_CTRL_LSB 0x3400 /*Miscellaneous control*/
#define MSC_CTRL_MSB 0x3500 /*Miscellaneous control*/
#define SMPL_PRD_LSB 0x3600 /*Internal sample period (rate) control */
#define SMPL_PRD_MSB 0x3700 /*Internal sample period (rate) control */
#define SENS_AVG_LSB 0x3800 /* volatile Dynamic range/digital filter control */
#define SENS_AVG_MSB 0x3900 /* volatile Dynamic range/digital filter control */
#define SLP_CNT_LSB 0x3A00 /* Volatile Sleep mode control */
#define SLP_CNT_MSB 0x3B00 /* Volatile Sleep mode control */
#define STATUS_LSB 0x3C00 /* only Read Volatile System status */
#define STATUS_MSB 0x3D00 /* only Read Volatile System status */
#define COMMAND_LSB 0x3E00 /*only WR System command */
#define COMMAND_MSB 0x3F00 /*only WR System command */
#define Cmd_Rd 0<<15
#define Cmd_Wr 1<<15
#define SIGN_BIT_MASK 1<<13
//unit
#define SupplyScalar 1.8315 //mVolt
#define GyroScalar 0.07326 //degree/s2
#define AcclScalar 2.522 //mg
#define TempScalar 0.1453 //degree/C3
#define AUX_ADCScalar 0.6105 //mV
signed short map_14bit_to_16bit_format(unsigned short data14bit);
void delay_loop(unsigned long count1);
void init_SPI_to_connect_ADIS16350(void);
void init_ADIS16350 (void);
void SPI_write16_ADIS16350(unsigned short adis16350_addr);
void SPI_read16_ADIS16350(unsigned short *rbuffer) ;//read data from ADIS
void ReadWrite_SPI16_ADIS16350(unsigned short adis16350_addr,unsigned short *rbuffer);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -