Thundersoft
/
IKS01A2_for_TT_Mxx
Creating a project about IKS10A2 for TT_Mxx
IKS01A2.cpp@1:28de8dff2317, 2019-04-26 (annotated)
- Committer:
- ThunderSoft
- Date:
- Fri Apr 26 09:51:19 2019 +0000
- Revision:
- 1:28de8dff2317
- Parent:
- 0:69ddd5bce0a0
"Update the mbed-os code to support TT_M4G9"
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThunderSoft | 0:69ddd5bce0a0 | 1 | #include "IKS01A2.h" |
ThunderSoft | 0:69ddd5bce0a0 | 2 | |
ThunderSoft | 0:69ddd5bce0a0 | 3 | |
ThunderSoft | 0:69ddd5bce0a0 | 4 | IKS01A2::IKS01A2(I2C *i2c) |
ThunderSoft | 0:69ddd5bce0a0 | 5 | { |
ThunderSoft | 0:69ddd5bce0a0 | 6 | lsm = new LSM6DSLSensor(i2c,LSM6DSL_ACC_GYRO_I2C_ADDRESS_HIGH); |
ThunderSoft | 0:69ddd5bce0a0 | 7 | Acc = new LSM303AGR_ACC_Sensor(i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 8 | Mag = new LSM303AGR_MAG_Sensor(i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 9 | |
ThunderSoft | 0:69ddd5bce0a0 | 10 | HumTemp = new HTS221Sensor (i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 11 | PressTemp = new LPS22HBSensor(i2c); |
ThunderSoft | 0:69ddd5bce0a0 | 12 | //init |
ThunderSoft | 0:69ddd5bce0a0 | 13 | init(); |
ThunderSoft | 0:69ddd5bce0a0 | 14 | } |
ThunderSoft | 0:69ddd5bce0a0 | 15 | |
ThunderSoft | 0:69ddd5bce0a0 | 16 | uint32_t IKS01A2::isConnect() |
ThunderSoft | 0:69ddd5bce0a0 | 17 | { |
ThunderSoft | 0:69ddd5bce0a0 | 18 | uint32_t temp_value = CONNECT; |
ThunderSoft | 0:69ddd5bce0a0 | 19 | uint8_t temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 20 | lsm->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 21 | if(temp_id != LSM6DSL_ACC_GYRO_WHO_AM_I) |
ThunderSoft | 0:69ddd5bce0a0 | 22 | temp_value |= LSM6D_NOT_CONNECT; |
ThunderSoft | 0:69ddd5bce0a0 | 23 | Acc->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 24 | if(temp_id != LSM303AGR_ACC_WHO_AM_I) |
ThunderSoft | 0:69ddd5bce0a0 | 25 | temp_value |= LSM303_ACC_NOT_CONNECT; |
ThunderSoft | 0:69ddd5bce0a0 | 26 | Mag->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 27 | if(temp_id != LSM303AGR_MAG_WHO_AM_I) |
ThunderSoft | 0:69ddd5bce0a0 | 28 | temp_value |= LSM303_MAG_NOT_CONNECT; |
ThunderSoft | 0:69ddd5bce0a0 | 29 | HumTemp->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 30 | if(temp_id != HTS221_WHO_AM_I_VAL) |
ThunderSoft | 0:69ddd5bce0a0 | 31 | temp_value |= HTS221_NOT_CONNECT; |
ThunderSoft | 0:69ddd5bce0a0 | 32 | PressTemp->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 33 | if(temp_id != LPS22HB_WHO_AM_I_VAL) |
ThunderSoft | 0:69ddd5bce0a0 | 34 | temp_value |= LPS22_NOT_CONNECT; |
ThunderSoft | 0:69ddd5bce0a0 | 35 | return temp_value; |
ThunderSoft | 0:69ddd5bce0a0 | 36 | } |
ThunderSoft | 0:69ddd5bce0a0 | 37 | |
ThunderSoft | 0:69ddd5bce0a0 | 38 | void IKS01A2::init() |
ThunderSoft | 0:69ddd5bce0a0 | 39 | { |
ThunderSoft | 0:69ddd5bce0a0 | 40 | lsm->Enable_X(); |
ThunderSoft | 0:69ddd5bce0a0 | 41 | lsm->Enable_G(); |
ThunderSoft | 0:69ddd5bce0a0 | 42 | // |
ThunderSoft | 0:69ddd5bce0a0 | 43 | Acc->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 44 | Mag->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 45 | |
ThunderSoft | 0:69ddd5bce0a0 | 46 | HumTemp->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 47 | PressTemp->Enable(); |
ThunderSoft | 0:69ddd5bce0a0 | 48 | } |
ThunderSoft | 0:69ddd5bce0a0 | 49 | |
ThunderSoft | 0:69ddd5bce0a0 | 50 | void IKS01A2::getXAxesLSM6DSL(int32_t *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 51 | { |
ThunderSoft | 0:69ddd5bce0a0 | 52 | lsm->Get_X_Axes(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 53 | } |
ThunderSoft | 0:69ddd5bce0a0 | 54 | |
ThunderSoft | 0:69ddd5bce0a0 | 55 | void IKS01A2::getGAxesLSM6DSL(int32_t *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 56 | { |
ThunderSoft | 0:69ddd5bce0a0 | 57 | lsm->Get_G_Axes(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 58 | } |
ThunderSoft | 0:69ddd5bce0a0 | 59 | |
ThunderSoft | 0:69ddd5bce0a0 | 60 | void IKS01A2::getDataLSM303AGR(int32_t *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 61 | { |
ThunderSoft | 0:69ddd5bce0a0 | 62 | Acc->GetAxes(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 63 | } |
ThunderSoft | 0:69ddd5bce0a0 | 64 | |
ThunderSoft | 0:69ddd5bce0a0 | 65 | void IKS01A2::getDataLSM303MAG(int32_t *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 66 | { |
ThunderSoft | 0:69ddd5bce0a0 | 67 | Mag->GetAxes(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 68 | } |
ThunderSoft | 0:69ddd5bce0a0 | 69 | |
ThunderSoft | 0:69ddd5bce0a0 | 70 | void IKS01A2::GetHumidity(float *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 71 | { |
ThunderSoft | 0:69ddd5bce0a0 | 72 | HumTemp->GetHumidity(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 73 | } |
ThunderSoft | 0:69ddd5bce0a0 | 74 | |
ThunderSoft | 0:69ddd5bce0a0 | 75 | void IKS01A2::GetTemperatureHTS221(float *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 76 | { |
ThunderSoft | 0:69ddd5bce0a0 | 77 | HumTemp->GetTemperature(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 78 | } |
ThunderSoft | 0:69ddd5bce0a0 | 79 | |
ThunderSoft | 0:69ddd5bce0a0 | 80 | void IKS01A2::GetPressure(float *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 81 | { |
ThunderSoft | 0:69ddd5bce0a0 | 82 | PressTemp->GetPressure(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 83 | } |
ThunderSoft | 0:69ddd5bce0a0 | 84 | |
ThunderSoft | 0:69ddd5bce0a0 | 85 | void IKS01A2::GetTemperatureLPS22HB(float *arg) |
ThunderSoft | 0:69ddd5bce0a0 | 86 | { |
ThunderSoft | 0:69ddd5bce0a0 | 87 | PressTemp->GetTemperature(arg); |
ThunderSoft | 0:69ddd5bce0a0 | 88 | } |
ThunderSoft | 0:69ddd5bce0a0 | 89 | |
ThunderSoft | 0:69ddd5bce0a0 | 90 | |
ThunderSoft | 0:69ddd5bce0a0 | 91 | char IKS01A2::getIdLSM6DSL() |
ThunderSoft | 0:69ddd5bce0a0 | 92 | { |
ThunderSoft | 0:69ddd5bce0a0 | 93 | uint8_t temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 94 | lsm->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 95 | return temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 96 | } |
ThunderSoft | 0:69ddd5bce0a0 | 97 | |
ThunderSoft | 0:69ddd5bce0a0 | 98 | char IKS01A2::getIdLSM303AGR() |
ThunderSoft | 0:69ddd5bce0a0 | 99 | { |
ThunderSoft | 0:69ddd5bce0a0 | 100 | uint8_t temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 101 | Acc->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 102 | return temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 103 | } |
ThunderSoft | 0:69ddd5bce0a0 | 104 | |
ThunderSoft | 0:69ddd5bce0a0 | 105 | char IKS01A2::getIdLSM303MAG() |
ThunderSoft | 0:69ddd5bce0a0 | 106 | { |
ThunderSoft | 0:69ddd5bce0a0 | 107 | uint8_t temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 108 | Mag->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 109 | return temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 110 | } |
ThunderSoft | 0:69ddd5bce0a0 | 111 | |
ThunderSoft | 0:69ddd5bce0a0 | 112 | char IKS01A2::getIdHTS221() |
ThunderSoft | 0:69ddd5bce0a0 | 113 | { |
ThunderSoft | 0:69ddd5bce0a0 | 114 | uint8_t temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 115 | HumTemp->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 116 | return temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 117 | } |
ThunderSoft | 0:69ddd5bce0a0 | 118 | |
ThunderSoft | 0:69ddd5bce0a0 | 119 | char IKS01A2::getIdLPS22HB() |
ThunderSoft | 0:69ddd5bce0a0 | 120 | { |
ThunderSoft | 0:69ddd5bce0a0 | 121 | uint8_t temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 122 | PressTemp->ReadID(&temp_id); |
ThunderSoft | 0:69ddd5bce0a0 | 123 | return temp_id; |
ThunderSoft | 0:69ddd5bce0a0 | 124 | } |