summaryrefslogtreecommitdiff
path: root/driver/mag_bmm150.c
Commit message (Collapse)AuthorAgeFilesLines
* common: replace 1 << digits, with BIT(digits)Gwendal Grignou2019-03-261-5/+5
| | | | | | | | | | | | | | | | Requested for linux integration, use BIT instead of 1 << First step replace bit operation with operand containing only digits. Fix an error in motion_lid try to set bit 31 of a signed integer. BUG=None BRANCH=None TEST=compile Change-Id: Ie843611f2f68e241f0f40d4067f7ade726951d29 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1518659 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* type: Rename vector_3_t to intv3_t.Yilun Lin2018-09-131-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Naming of many vector types and matrix types are not clear enough. For example, we have: vector_3_t, which is a vector of three int. vec3_t, which is a vector of three float. size4_t, which is a vector of four size_t. mat33_t, which is a 3x3 matrix of float. matrix_3x3_t, which is a 3x3 matrix of fixed point. Besides, we have types like int8_t, uint16_t types. To clearly distinguished types, the CL propose to, For vector types, naming should be `$type + 'v' + $num + '_t'`: vector_3_t becomes intv3_t vec3_t becomes floatv3_t vector 4 of uint16_t becomes uint16v4_t (which doesn't exist yet) For matrix types, naming should be `mat$N$N_` + $type + '_t', where $N is the matrix size: matrix_3x3_t becomes mat33_fp_t # fp: fixed point mat33_t becomes mat33_float_t TEST=make buildall -j BUG=b:114662791 Change-Id: I865aa3ecbab6cb97f8585a081a679adf00febe1d Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1215442 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
* driver: bmi160: Rename secondary i2c access functionsGwendal Grignou2018-06-171-3/+9
| | | | | | | | | | | | | Make it more generic to support sensor other than BMI159. BUG=b:110143516 BRANCH=none TEST=compile Change-Id: I954df2e9301e05968930add396cd724ca0dfa262 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1101550 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bmi160: Remove unnecessary delayGwendal Grignou2016-11-211-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | Rereading the specification, remove delays when not needed: - When we move the sensor out of suspend, we need to wait before using it (BMI160 spec: 2.11.38 Register (0x7E) CMD) When we do a softreset, we need just need to wait 300us for the sensor to go in suspend, we will wait only when we change the rate and enable the sensor. - The timeout at fifo flush is not needed, it was added for debugging. - Remove unnecessary printf when initializing the magnetometer. BUG=chrome-os-partner:59188 BRANCH=glados, reef, strago TEST=On reef, check the EC boot faster: time spend initializing the sensors decreased from 240ms to 133ms Change-Id: Ia80232da42aa705df819a4988da483a344ffcbb4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/411964 Commit-Ready: David Hendricks <dhendrix@chromium.org> Tested-by: David Hendricks <dhendrix@chromium.org> Reviewed-by: David Hendricks <dhendrix@chromium.org>
* sensor: update sensor driver to use I2C port from motion_sensor_tKevin K Wong2016-03-311-15/+15
| | | | | | | | | | | | | this allow motion sensor devices to be locate on different I2C port BUG=none BRANCH=none TEST=make buildall Change-Id: Ia7ba2f5729ebb19561768ec87fdb267e79aafb6a Signed-off-by: Kevin K Wong <kevin.k.wong@intel.com> Reviewed-on: https://chromium-review.googlesource.com/334269 Reviewed-by: Shawn N <shawnn@chromium.org>
* driver: bmm150: Use Bosch recommend repetitionGwendal Grignou2015-10-151-2/+2
| | | | | | | | | | | | | | To minimize noise, instead of using recommend preset from the documentation, use specific repetition value. BRANCH=smaug BUG=chrome-os-partner:45436 TEST=Check the noise is somewhat reduced, still not great. Change-Id: I0ed3409dd907fa1e393d1eb77b6f23ff03763e53 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/305588 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* motion: fix spellingGwendal Grignou2015-10-151-1/+1
| | | | | | | | | | | | | | | | | | Fix various spelling errors. Command used: spell include/motion_sense.h | sort | uniq -c | \ grep -v -f ~/tmp/known_words | sort -n > /tmp/checking_spell Appended /tmp/checking_spell to ~/tmp/known_words to avoid C code. BRANCH=smaug TEST=compile BUG=none Change-Id: I39acfeaefef51d142a587940bccb02db86e87068 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/305570 Reviewed-by: Alec Berg <alecaberg@chromium.org>
* common: Add magnetometer online calibration.Gwendal Grignou2015-10-131-12/+17
| | | | | | | | | | | | | | | | Code for hard iron calibration: Every seconds (or faster if enough samples), find a sphere that fit the compass data. Based on Android code. BRANCH=smaug BUG=chrome-os-partner:39900 TEST=Check hard-iron bias is removed. Works better outside. Change-Id: Iab479d5113b6560b4f01b0fd87373d2eecdb9b54 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299583 Reviewed-by: Anton Staaf <robotboy@chromium.org>
* driver: bmm150: fix repetiton registersGwendal Grignou2015-09-201-2/+2
| | | | | | | | | | | | | | Rereading the spec, the repetition registers are massaged by the chip to produce the repetition value: for XY: 1 + 2 * REPxy, Z axis: 1 + REPz BRANCH=smaug BUG=chrome-os-partner:39900 TEST=check the registers matches the spec. Change-Id: Ic8618d70c18b4f408e3c95acdbe7fcdf6d95e39e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/299582 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* driver: bmi160: use rotation matrix to handle offsets.Gwendal Grignou2015-08-241-5/+2
| | | | | | | | | | | | | | | | Store offsets using sensors axis, not the device axis. Therefore apply rot_standard_ref to the offset vector before get and rot_standard_ref^-1 before set. BRANCH=smaug TEST=using mag sensor, check the offset are applied to the right axis and store correctly. BUG=chromium:517675 Change-Id: I95c8ef2a62603890184412674e7bde91ebecd288 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/294596 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* bmm150: add measurement repetitionGwendal Grignou2015-08-241-0/+8
| | | | | | | | | | | | | | | | To reduce noise the magnetometer measures in burst and average the data. Use "regular" presets: max frequency is limited to 100Hz. Using a more precise presets limit frequency to no more than 50Hz. BRANCH=smaug TEST=Check magnetomter still works. BUG=chrome-os-partner:39900 Change-Id: Ida6af86f6c207cc91e11378c129032f6d9e6b9ea Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291990 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* bmm150: Add support for calibrationGwendal Grignou2015-08-221-0/+26
| | | | | | | | | | | | | Allow sending calibration information to the magnetometer. BRANCH=smaug TEST=Check from user space that calibration is taken into account. BUG=chrome-os-partner:39900 Change-Id: Ic0f595bde1afdc0b6a79e3516a42b55d1f50c17c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/291333 Reviewed-by: Sheng-liang Song <ssl@chromium.org>
* driver: bmi160: Fix bugs found testing SPIGwendal Grignou2015-08-011-0/+1
| | | | | | | | | | | | | | | | | | SPI being much faster, need to add right sleep to wait for sensor to change state from suspend. Set the ODR before the range, an issue I did not have with i2c. Fix test used when FIFO is disabled. BRANCH=smaug BUG=chrome-os-partner:42304 TEST=Check sensors are coming and rate/range are correctly set. Change-Id: I5bf655626f1f4232478a04d1d4e1a0d443efbf0f Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/288517 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
* accel: mechanical changes from i2c_addr to addrGwendal Grignou2015-07-301-11/+11
| | | | | | | | | | | | | | | Encode both the I2C address and SPI GPIO CS in addr field. Mechanical change to rename i2c_addr into addr. BRANCH=smaug TEST=compile BUG=chrome-os-partner:42304 Change-Id: I1c7435398deacb27211445afa27a08716d224c06 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/288513 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: David James <davidjames@chromium.org>
* driver: bmm150 measurement compensationGwendal Grignou2015-07-221-0/+214
Using Bosh reference document, compensate X,Y,Z axis based on internal registers and R HALL values. Change compass unites to 1/16 uT per LSB. Reference: https://github.com/suribi/Thunder-Kernel/blob/master/mediatek/custom/common/kernel/magnetometer/bmm150/bmm150.c BRANCH=smaug TEST=Check compass value in user space. BUG=chrome-os-partner:39900 Change-Id: I0c480521771ef6004ac6e5182cc1d27e82c5bc7c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/285020 Reviewed-by: Alec Berg <alecaberg@chromium.org>