Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of COG4050_adxl355_adxl357-ver2 by
ADXRS290.h
00001 00002 #ifndef ADXRS290_H_ 00003 #define ADXRS290_H_ 00004 00005 class ADXRS290 00006 { 00007 public: 00008 #define gyro_sens 0.005; // 200 [LSB/°/s] 00009 #define t_sens 0.1; // 10 [LSB/°C] 00010 // -------------------------- // 00011 // REGISTERS // 00012 // -------------------------- // 00013 typedef enum { 00014 ADI_ID = 0x00, 00015 MEMS_ID = 0x01, 00016 DEV_ID = 0x02, 00017 REV_ID = 0x03, 00018 SN0 = 0x04, 00019 SN1 = 0x05, 00020 SN2 = 0x06, 00021 SN3 = 0x07, 00022 DATAX0 = 0x08, 00023 DATAX1 = 0x09, 00024 DATAY0 = 0x0A, 00025 DATAY1 = 0x0B, 00026 TEMP0 = 0x0C, 00027 TEMP1 = 0x0D, 00028 POWER_CTL = 0x10, 00029 FILTER = 0x11, 00030 DATA_READY = 0x12 00031 } ADXRS290_register_t; 00032 // -------------------------- // 00033 // REGISTERS - DEFAULT VALUES // 00034 // -------------------------- // 00035 // Modes - POWER_CTL 00036 typedef enum { 00037 TEMP_ON = 0x00, 00038 TEMP_OFF = 0x01, 00039 STANDBY = 0x00, 00040 MEASUREMENT = 0x02 00041 } ADXL355_modes_t; 00042 // High-Pass and Low-Pass Filter - FILTER 00043 typedef enum { 00044 LPF480 = 0x00, 00045 LPF320 = 0x01, 00046 LPF160 = 0x02, 00047 LPF80 = 0x03, 00048 LPF56 = 0x04, 00049 LPF40 = 0x05, 00050 LPF28 = 0x06, 00051 LPF20 = 0x07, 00052 HPFOFF = 0x00, 00053 HPF001 = 0x10, 00054 HPF002 = 0x20, 00055 HPF004 = 0x30, 00056 HPF008 = 0x40, 00057 HPF017 = 0x50, 00058 HPF035 = 0x60, 00059 HPF070 = 0x70, 00060 HPF140 = 0x80, 00061 HPF280 = 0x90, 00062 HPF1130 = 0xA0 00063 } ADXRS290_filter_ctl_t; 00064 // External timing register - INT_MAP 00065 typedef enum { 00066 OVR_EN = 0x04, 00067 FULL_EN = 0x02, 00068 RDY_EN = 0x01 00069 } ADXRS290_intmap_ctl_t; 00070 // External timing register - SYNC 00071 typedef enum { 00072 ANAL_SYNC = 0x00, 00073 DIGI_SYNC = 0x01 00074 } ADXRS290_dataready_ctl_t; 00075 // -------------------------- // 00076 // OUTPUT DATA // 00077 // -------------------------- // 00078 typedef struct { 00079 float rt_x; 00080 float rt_y; 00081 float rt_z; 00082 } ADXRS290_rate_t; 00083 ADXRS290_rate_t rate_data; 00084 // -------------------------- // 00085 // FUNCTIONS // 00086 // -------------------------- // 00087 // SPI configuration & constructor 00088 ADXRS290(PinName cs_pin , PinName MOSI , PinName MISO , PinName SCK ); 00089 void frequency(int hz); 00090 // SPI configuration & constructor 00091 void write_reg(ADXRS290_register_t reg, uint8_t data); 00092 uint8_t read_reg(ADXRS290_register_t reg); 00093 uint16_t read_reg_u16(ADXRS290_register_t reg); 00094 // ADXRS general register R/W methods 00095 void set_power_ctl_reg(uint8_t data); 00096 void set_filter_ctl_reg(ADXRS290_filter_ctl_t hpf, ADXRS290_filter_ctl_t odr); 00097 void set_sync(ADXRS290_dataready_ctl_t data); 00098 // ADXRS X/Y/T scanning methods 00099 uint16_t scanx(); 00100 uint16_t scany(); 00101 uint16_t scant(); 00102 ADXRS290_rate_t scan(); 00103 private: 00104 // SPI adxl355; ///< SPI instance of the ADXL 00105 Timeout conv_time; 00106 SPI adxrs290; DigitalOut cs; 00107 const static uint8_t _DEVICE_AD = 0x92; // contect of DEVID_AD (only-read) register 00108 const static uint8_t _DUMMY_BYTE = 0xAA; // 10101010 00109 const static uint8_t _WRITE_REG_CMD = 0x00; // write register 00110 const static uint8_t _READ_REG_CMD = 0x80; // read register 00111 const static uint8_t _SPI_MODE = 4; // timing scheme 00112 }; 00113 00114 #endif
Generated on Wed Jul 13 2022 09:03:43 by
1.7.2
