summaryrefslogtreecommitdiff
path: root/driver/accel_bma2x2.c
Commit message (Collapse)AuthorAgeFilesLines
* driver: Sort header filesJeremy Bettis2022-11-291-1/+1
| | | | | | | | | | | | | | | | | | | | | Sort all includes in driver with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=zmake build -a TEST=./twister --clobber -v -i TEST=make -j72 buildall_only runtests TEST=zmake compare-builds -a Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I675e0db416b6b7cbcfce031c97fd24ad97b66f4f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4052767 Reviewed-by: Yuval Peress <peress@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* util: remove unused includesYuval Peress2022-08-051-0/+1
| | | | | | | | | | | | | | | | Remove these includes as they're not needed in this header. Instead, the includes should go where they're actually being used. BRANCH=none BUG=b:240574048 TEST=make buildall -j TEST=zmake build -a Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I64b10af3216654b2a20caa1cabd267661a0bca39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791980 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* driver/accel_bma2x2.c: Format with clang-formatJack Rosenthal2022-07-011-12/+12
| | | | | | | | | | | BUG=b:236386294 BRANCH=none TEST=none Change-Id: I84419a1c36800f79bd3181cea72381bc350f8621 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729764 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* driver: Add argument check in BMA2x2 driverTomasz Michalec2021-06-301-4/+19
| | | | | | | | | | | | | | set_range and set_data_rate functions of BMA2x2 driver should check input values to not set values outside of range supported by device. BUG=none BRANCH=none TEST=makeall Signed-off-by: Tomasz Michalec <tm@semihalf.com> Change-Id: Ie9650975e00a99e86a5229ee200dab24be536076 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2953222 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* Zephyr: Create public headers for bmi260, bma2x2, and tcs3400Hyungwoo Yang2021-01-201-1/+1
| | | | | | | | | | | | | | | Separate out the public part of sensor headers so it can be included from Zephyr. BUG=b:175434113 BRANCH=none TEST=make buildall -j8 build volteer on zephyr Signed-off-by: Hyungwoo Yang <hyungwoo.yang@intel.corp-partner.google.com> Change-Id: I899e9aea99d6c7d56a1b6735538b280fe0735313 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2637251 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* motion_sense: Make change in range permanentGwendal Grignou2020-11-121-14/+5
| | | | | | | | | | | | | | | | | | | | | | | | | When AP changes range, unlike offset or ODR, it was not surviving init() call. If the sensor is powered off in S3, at resume the range would be back to the default. To make it consistent with other attributes, remember range change until EC powers down. - remove get_range - add current_range to store the range currently used. This is modifiable by the AP - when the AP shutdown, revert current_range to default_range - Remove const attribute for sensor structure when init and set_range is called. BUG=chromium:1083791 BRANCH=none TEST=One eve branch, check range is preserved even after 'shutdown -h 0' Change-Id: Ia7126ac0cc9c3fef60b4464d95d6dd15e64b0fc4 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2215751 Reviewed-by: Yuval Peress <peress@chromium.org>
* driver: bma253: use rotation matrix to handle offsetsJian-Jia Su2020-08-041-2/+11
| | | | | | | | | | | | | | | Store offsets using sensor axis, not the device axis. Therefore apply rot_standard_ref to the offset vector before get and rot_standard_ref^-1 before set. BUG=b:160842447 TEST=check the offset follow device axis BRANCH=none Signed-off-by: Jian-Jia Su <jjsu@chromium.org> Change-Id: I3a4f5caabd9fdfdc3825cccc622a854a3521bed4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2325525 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* bma2x2: Add an assert that verifies the mutexKeith Short2019-12-131-0/+3
| | | | | | | | | | | | | | | | | | The BMA2x2 accelerometer driver requires that the motionsense entry defines a mutex. Add an assert to enforce the mutex. Without the assert, initializing the driver causes a watchdog timeout. BUG=b:146081107 BRANCH=none TEST=make buildall TEST=On Volteer, add BMA2x2 driver to motionsense without creating mutex, verify assert. With mutex present, driver initializes correctly. Change-Id: Id66b5dea3568a3fa31ce9e125d8176141627f241 Signed-off-by: Keith Short <keithshort@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1965645 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* driver: Add support for calibration modeGwendal Grignou2019-07-241-1/+4
| | | | | | | | | | | | | | | | | For TCS3400, performing calibration is not just a one-shot event: The RBG sensor stays in calibration mode: returns raw value in R, G, B space. When out of calibration, it returns light information in X, Y and Z space. BUG=b:124512628 BRANCH=hatch,flapjack TEST=unit test Change-Id: I6766907054c8e79a3cbcb629ef91a0967ea0780a Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1702543 Reviewed-by: Nick Vaccaro <nvaccaro@google.com>
* Remove __7b, __8b and __7bfDenis Brockus2019-07-201-19/+19
| | | | | | | | | | | | | | | | | | | The extentions were added to make the compiler perform most of the verification that the conversion was being done correctly to remove 8bit addressing as the standard I2C/SPI address type. Now that the compiler has verified the code, the extra extentions are being removed BUG=chromium:971296 BRANCH=none TEST=make buildall -j TEST=verify sensor functionality on arcada_ish Change-Id: I36894f8bb9daefb5b31b5e91577708f6f9af2a4f Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1704792 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Use 7bit I2C/SPI slave addresses in ECDenis Brockus2019-07-191-23/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opt for 7bit slave addresses in EC code. If 8bit is expected by a driver, make it local and show this in the naming. Use __7b, __7bf and __8b as name extensions for i2c/spi addresses used in the EC codebase. __7b indicates a 7bit address by itself. __7bf indicates a 7bit address with optional flags attached. __8b indicates a 8bit address by itself. Allow space for 10bit addresses, even though this is not currently being used by any of our attached devices. These extensions are for verification purposes only and will be removed in the last pass of this ticket. I want to make sure the variable names reflect the type to help eliminate future 7/8/7-flags confusion. BUG=chromium:971296 BRANCH=none TEST=make buildall -j Change-Id: I2fc3d1b52ce76184492b2aaff3060f486ca45f45 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1699893 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* type: Rename vector_3_t to intv3_t.Yilun Lin2018-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* drivers: Refactor to use high-level i2c APIsJonathan Brandmeyer2018-08-091-14/+1
| | | | | | | | | | | | | | | | | | | | | | | | Using the high-level APIs for block transfers eliminates some code duplication and error-prone manual locking sequences. - common/cbi: Block transfers - driver/accel_bma2x2: Block transfers - driver/accel_kionix: Block transfers - driver/accelgyro_bmi160: Block transfers - driver/accelgyro_lsm6ds0: Block transfers - driver/baro_bmp280: Block and byte transfers - driver/charger/rt946x: Block transfers - driver/gyro_l3gd20h: Block transfers - driver/stm_mems_common: Block transfers - driver/tcpm: Block transfers TEST=buildall; motionsense and PD testing on Grunt convertible which exercises the bma160, kionix and tcpcm drivers. BRANCH=none BUG=chromium:871851 Change-Id: I1732253a244c3343459265ce1e1e54488cee65b8 Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1167958 Reviewed-by: Jett Rink <jettrink@chromium.org>
* sensor: bmi160/bma2x2: Fix the timeout value of compensation.Marco Chen2018-03-261-1/+1
| | | | | | | | | | | | | | | | | | | CL:957872 introduced "get_time().val + 400" as the deadline to perform compensation and the comment in bma2x2.c mentioned the deadline should be 400ms. But the unit of val in timestamp_t is microsecond not milisecond so only 400us is defined not 400ms. BRANCH=none BUG=b:76234078 BUG=b:76202592 TEST=test manually on the dut by performing calibrate. Change-Id: I7a834ef6dcb0772569d2c8d6c507803deb5d2fc1 Signed-off-by: Marco Chen <marcochen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/979512 Commit-Ready: Gwendal Grignou <gwendal@chromium.org> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
* driver: bma2x2: Add perform_calibGwendal Grignou2018-03-161-28/+84
| | | | | | | | | | | | | | | | | | Add fast compensation automatic calibration, like bmi160. Use timestamp_expired for timeout measurement for both perform_calib functions. Remove driver offset field, remove private bma2x2 structure. BUG=b:73205042 BRANCH=master TEST=echo 1 > calibrate perform calibration. Reading in_accel_*_calibbias is within range. Check on Lami for both bma2x2 and bmi160. Change-Id: I3472865287fa4769a05e6f872b92d7c3f933cb4e Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/957872 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* driver: sensor: Remove set_resolution when NOOPGwendal Grignou2018-03-151-12/+0
| | | | | | | | | | | | | | set_resolution is only used for few sensors and is not exposed to the AP. Remove definition when sensors have a fixed resolution. BUG=none BRANCH=master TEST=compile, kevin has enough space for perform_calib. Change-Id: I8482387e135356467edaee44da3a0e47cf1db524 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/961222 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
* driver: bma2x2: Remove tables for range/frequencyGwendal Grignou2018-03-151-79/+21
| | | | | | | | | | | | | | | | To save space, instead of using tables, use macros to convert range/frequencies into register values. BUG=b:73205042 BRANCH=none TEST=Check we save space on Kevin. (184 bytes looking at __image_size in kevin.RO.map). Check on nami that range/bandwidth are set properly. Change-Id: I193768be1f2e7325b986e8ccff25a7809bfb4096 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/959388 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* driver: bma2x2: indent register definitionGwendal Grignou2018-03-121-2/+2
| | | | | | | | | | | BUG=none BRANCH=none TEST=compile Change-Id: I9507cbe760f886acaa4c6b432cfd8482faeb4618 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/959387 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
* motion_sense: Put set_range in common codeGwendal Grignou2017-11-171-7/+1
| | | | | | | | | | | | | | | | At the end of the sensor initialization, all _init sensor routines set the range to the default value from board.c file. Put all the code in a single place, move it from sensor_common.c to motion_sense.c. BUG=none BRANCH=none TEST=compile Change-Id: If89cf27c6438e0f215c193d68a480e027110174c Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/767610 Reviewed-by: Shawn N <shawnn@chromium.org>
* console: Add non-verbose print config optionShawn Nematbakhsh2017-02-111-2/+1
| | | | | | | | | | | | | | | | | Shorten certain long prints and reduce the precision of timestamp prints when CONFIG_CONSOLE_VERBOSE is undef'd. BUG=chromium:688743 BRANCH=gru TEST=On kevin, cold reset the EC, boot to OS, and verify cros_ec.log contains all data since sysjump and is < 2K bytes (~1500 bytes). Change-Id: Ia9390867788d0ab3087f827b0296107b4e9d4bca Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/438932 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
* driver: Add support bma255 sensorWonjoon Lee2016-05-311-0/+340
BMA255 is one of BMA2x2 accel sensor series. Adding defines,driver from https://github.com/BoschSensortec/BMA2x2_driver BUG=chrome-os-partner:52877 BRANCH=none TEST="accelread 2" is working on kevin, also check accelrate, accelrange can set proper value on IC Change-Id: I99932ff75aae91a744fe18dddc010b802085a2da Signed-off-by: Wonjoon Lee <woojoo.lee@samsung.com> Reviewed-on: https://chromium-review.googlesource.com/347722 Reviewed-by: Shawn N <shawnn@chromium.org>