Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driver: adxl38x - bare-metal driver for parts ADXL380 and ADXL382 #2210

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BalarupiniRajendran
Copy link

@BalarupiniRajendran BalarupiniRajendran commented Jun 12, 2024

Pull Request Description

Bare metal device drivers for ADXL380/382 parts.

Please replace this with a detailed description and motivation of the changes.
You can tick the checkboxes below with an 'x' between square brackets or just check them after publishing the PR.
If this PR contains a breaking change, list dependent PRs and try to push all related PRs at the same time.

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have followed the Coding style guidelines
  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have build all projects affected by the changes in this PR
  • I have tested in hardware affected projects, at the relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc), if applies

@CLAassistant
Copy link

CLAassistant commented Jun 12, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@amiclaus amiclaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thanks for the PR.

  • Please sign the CLA
  • add separate commit for the application example
  • add a commit for documentation of the driver
  • add a commit for the documentation of the project

@rbolboac
Copy link
Contributor

There are some compilation warnings which need to be fix:

2024-06-13T15:35:15.9048705Z CC adxl38x.c
2024-06-13T15:35:15.9273766Z accel/adxl38x/adxl38x.c: In function 'adxl38x_soft_reset':
2024-06-13T15:35:15.9274999Z accel/adxl38x/adxl38x.c:252:30: warning: unused variable 'flags' [-Wunused-variable]
2024-06-13T15:35:15.9275353Z   252 |  union adxl38x_sts_reg_flags flags;
2024-06-13T15:35:15.9275663Z       |                              ^~~~~
2024-06-13T15:35:15.9281204Z accel/adxl38x/adxl38x.c: In function 'adxl38x_get_op_mode':
2024-06-13T15:35:15.9283047Z accel/adxl38x/adxl38x.c:312:58: warning: passing argument 4 of 'adxl38x_read_device_data' from incompatible pointer type [-Wincompatible-pointer-types]
2024-06-13T15:35:15.9284126Z   312 |  ret = adxl38x_read_device_data(dev, ADXL38x_OP_MODE, 1, &op_mode_reg_val);
2024-06-13T15:35:15.9284450Z       |                                                          ^~~~~~~~~~~~~~~~
2024-06-13T15:35:15.9284766Z       |                                                          |
2024-06-13T15:35:15.9285103Z       |                                                          uint8_t (*)[1] {aka unsigned char (*)[1]}
2024-06-13T15:35:15.9285838Z accel/adxl38x/adxl38x.c:78:33: note: expected 'uint8_t *' {aka 'unsigned char *'} but argument is of type 'uint8_t (*)[1]' {aka 'unsigned char (*)[1]'}
2024-06-13T15:35:15.9286625Z    78 |         uint16_t size, uint8_t *read_data)
2024-06-13T15:35:15.9287176Z       |                        ~~~~~~~~~^~~~~~~~~
2024-06-13T15:35:15.9292415Z accel/adxl38x/adxl38x.c: In function 'adxl38x_set_range':
2024-06-13T15:35:15.9293544Z accel/adxl38x/adxl38x.c:334:58: warning: passing argument 4 of 'adxl38x_read_device_data' from incompatible pointer type [-Wincompatible-pointer-types]
2024-06-13T15:35:15.9294004Z   334 |  ret = adxl38x_read_device_data(dev, ADXL38x_OP_MODE, 1, &range_reg_val);
2024-06-13T15:35:15.9294382Z       |                                                          ^~~~~~~~~~~~~~
2024-06-13T15:35:15.9294760Z       |                                                          |
2024-06-13T15:35:15.9295021Z       |                                                          uint8_t (*)[1] {aka unsigned char (*)[1]}
2024-06-13T15:35:15.9295614Z accel/adxl38x/adxl38x.c:78:33: note: expected 'uint8_t *' {aka 'unsigned char *'} but argument is of type 'uint8_t (*)[1]' {aka 'unsigned char (*)[1]'}
2024-06-13T15:35:15.9296227Z    78 |         uint16_t size, uint8_t *read_data)
2024-06-13T15:35:15.9296581Z       |                        ~~~~~~~~~^~~~~~~~~
2024-06-13T15:35:15.9303021Z accel/adxl38x/adxl38x.c:345:59: warning: passing argument 4 of 'adxl38x_write_device_data' from incompatible pointer type [-Wincompatible-pointer-types]
2024-06-13T15:35:15.9303555Z   345 |  ret = adxl38x_write_device_data(dev, ADXL38x_OP_MODE, 1, &range_reg_val);
2024-06-13T15:35:15.9303951Z       |                                                           ^~~~~~~~~~~~~~
2024-06-13T15:35:15.9304265Z       |                                                           |
2024-06-13T15:35:15.9304514Z       |                                                           uint8_t (*)[1] {aka unsigned char (*)[1]}
2024-06-13T15:35:15.9305250Z accel/adxl38x/adxl38x.c:111:34: note: expected 'uint8_t *' {aka 'unsigned char *'} but argument is of type 'uint8_t (*)[1]' {aka 'unsigned char (*)[1]'}
2024-06-13T15:35:15.9305627Z   111 |          uint16_t size, uint8_t *write_data)
2024-06-13T15:35:15.9305947Z       |                         ~~~~~~~~~^~~~~~~~~~
2024-06-13T15:35:15.9311329Z accel/adxl38x/adxl38x.c: In function 'adxl38x_get_range':
2024-06-13T15:35:15.9312372Z accel/adxl38x/adxl38x.c:366:58: warning: passing argument 4 of 'adxl38x_read_device_data' from incompatible pointer type [-Wincompatible-pointer-types]
2024-06-13T15:35:15.9312822Z   366 |  ret = adxl38x_read_device_data(dev, ADXL38x_OP_MODE, 1, &range_reg_val);
2024-06-13T15:35:15.9313210Z       |                                                          ^~~~~~~~~~~~~~
2024-06-13T15:35:15.9313873Z       |                                                          |
2024-06-13T15:35:15.9314127Z       |                                                          uint8_t (*)[1] {aka unsigned char (*)[1]}
2024-06-13T15:35:15.9314783Z accel/adxl38x/adxl38x.c:78:33: note: expected 'uint8_t *' {aka 'unsigned char *'} but argument is of type 'uint8_t (*)[1]' {aka 'unsigned char (*)[1]'}
2024-06-13T15:35:15.9315163Z    78 |         uint16_t size, uint8_t *read_data)
2024-06-13T15:35:15.9315480Z       |                        ~~~~~~~~~^~~~~~~~~
2024-06-13T15:35:15.9325204Z accel/adxl38x/adxl38x.c: In function 'adxl38x_get_sts_reg':
2024-06-13T15:35:15.9326139Z accel/adxl38x/adxl38x.c:475:58: warning: passing argument 4 of 'adxl38x_read_device_data' from incompatible pointer type [-Wincompatible-pointer-types]
2024-06-13T15:35:15.9327101Z   475 |  ret = adxl38x_read_device_data(dev, ADXL38x_STATUS0, 4, &status_value);
2024-06-13T15:35:15.9327502Z       |                                                          ^~~~~~~~~~~~~
2024-06-13T15:35:15.9327825Z       |                                                          |
2024-06-13T15:35:15.9328098Z       |                                                          uint8_t (*)[4] {aka unsigned char (*)[4]}
2024-06-13T15:35:15.9332361Z accel/adxl38x/adxl38x.c:78:33: note: expected 'uint8_t *' {aka 'unsigned char *'} but argument is of type 'uint8_t (*)[4]' {aka 'unsigned char (*)[4]'}
2024-06-13T15:35:15.9332857Z    78 |         uint16_t size, uint8_t *read_data)
2024-06-13T15:35:15.9333285Z       |                        ~~~~~~~~~^~~~~~~~~
2024-06-13T15:35:15.9341760Z accel/adxl38x/adxl38x.c: In function 'adxl38x_get_temp':
2024-06-13T15:35:15.9342639Z accel/adxl38x/adxl38x.c:540:6: warning: unused variable 'j' [-Wunused-variable]
2024-06-13T15:35:15.9343022Z   540 |  int j = 0;
2024-06-13T15:35:15.9343502Z       |      ^
2024-06-13T15:35:15.9351386Z accel/adxl38x/adxl38x.c: In function 'adxl38x_get_raw_data':
2024-06-13T15:35:15.9355587Z accel/adxl38x/adxl38x.c:649:29: warning: assignment to 'uint8_t' {aka 'unsigned char'} from 'void *' makes integer from pointer without a cast [-Wint-conversion]
2024-06-13T15:35:15.9357392Z   649 |    array_rearranged_data[i] = NULL;
2024-06-13T15:35:15.9357796Z       |                             ^
2024-06-13T15:35:15.9362833Z accel/adxl38x/adxl38x.c:650:31: warning: assignment to 'uint8_t' {aka 'unsigned char'} from 'void *' makes integer from pointer without a cast [-Wint-conversion]
2024-06-13T15:35:15.9363514Z   650 |    array_rearranged_data[i+1] = NULL;
2024-06-13T15:35:15.9364256Z       |                               ^
2024-06-13T15:35:15.9371922Z accel/adxl38x/adxl38x.c: In function 'adxl38x_get_xyz_gees':
2024-06-13T15:35:15.9379493Z accel/adxl38x/adxl38x.c:686:10: warning: unused variable 'dummy' [-Wunused-variable]
2024-06-13T15:35:15.9381166Z   686 |  int64_t dummy;
2024-06-13T15:35:15.9381552Z       |          ^~~~~
2024-06-13T15:35:15.9386357Z accel/adxl38x/adxl38x.c:683:11: warning: unused variable 'dum' [-Wunused-variable]
2024-06-13T15:35:15.9386872Z   683 |  uint16_t dum;
2024-06-13T15:35:15.9387367Z       |           ^~~
2024-06-13T15:35:15.9442160Z accel/adxl38x/adxl38x.c: In function 'adxl38x_init':
2024-06-13T15:35:15.9443062Z accel/adxl38x/adxl38x.c:150:17: warning: 'dev' may be used uninitialized in this function [-Wmaybe-uninitialized]
2024-06-13T15:35:15.9443776Z   150 |   dev->dev_type = init_param.dev_type;
2024-06-13T15:35:15.9444128Z       |   ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

Copy link
Contributor

@rbolboac rbolboac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some remarks from my side. most of them are duplicated, but please check the files again to make changes are applies too all instances

drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
Copy link
Contributor

@rbolboac rbolboac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some remarks on the second commit

projects/eval-adxl38x/src/platform/stm32/parameters.h Outdated Show resolved Hide resolved
projects/eval-adxl38x/src/platform/stm32/parameters.h Outdated Show resolved Hide resolved
projects/eval-adxl38x/src/platform/stm32/parameters.c Outdated Show resolved Hide resolved
projects/eval-adxl38x/src/platform/stm32/parameters.c Outdated Show resolved Hide resolved
projects/eval-adxl38x/src/platform/stm32/main.c Outdated Show resolved Hide resolved
projects/eval-adxl38x/src/examples/examples_src.mk Outdated Show resolved Hide resolved
@BalarupiniRajendran BalarupiniRajendran force-pushed the staging/adxl38x branch 3 times, most recently from 1e9e058 to 6748188 Compare June 26, 2024 19:57
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.h Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
size + 1);
} else {
dev->comm_buff[0] = base_address;
ret = no_os_i2c_write(dev->com_desc.i2c_desc, dev->comm_buff, size + 1, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
drivers/accel/adxl38x/adxl38x.c Outdated Show resolved Hide resolved
Bare-metal driver for parts ADXL380 and ADXL382

Signed-off-by: Balarupini Rajendran <[email protected]>
Signed-off-by: Balarupini Rajendran <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants