File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ #include "dps310_i2c.h"
2+
3+ // Atmel includes
4+ #include "delay.h"
5+
6+ // App includes
7+ #include "app_i2c.h"
8+
9+ // Sensor driver includes
10+ #include "dps310_errors.h"
11+
12+
13+ void dps310_i2c_init (void ) {
14+ }
15+
16+ void dps310_i2c_release (void ) {
17+ }
18+
19+ int8_t dps310_i2c_read (uint8_t address , uint8_t reg , uint8_t * data , uint16_t count ) {
20+ int8_t ret ;
21+ uint8_t buff [1 ];
22+
23+ buff [0 ] = reg ;
24+
25+ ret = app_i2c_write_wait (address , buff , 1 );
26+
27+ if (ret != STATUS_OK ) {
28+ return DPS310_I2C_FAIL_ERROR ;
29+ }
30+
31+ delay_ms (10 );
32+
33+ ret = app_i2c_read_wait (address , data , count );
34+
35+ if (ret != STATUS_OK ) {
36+ return DPS310_I2C_FAIL_ERROR ;
37+ }
38+
39+ return DPS310_OK ;
40+ }
41+
42+ int8_t dps310_i2c_write (uint8_t address , uint8_t reg , const uint8_t * data , uint16_t count ) {
43+ int8_t ret ;
44+ uint16_t count_with_reg = count + 1 ;
45+ uint8_t buff [DPS310_I2C_MAX_BUFF_SIZE ];
46+
47+ buff [0 ] = reg ;
48+
49+ for (uint8_t i = 1 ; i < count_with_reg ; i ++ ) {
50+ buff [i ] = data [i - 1 ];
51+ }
52+
53+ ret = app_i2c_write_wait (address , buff , count_with_reg );
54+
55+ if (ret != STATUS_OK ) {
56+ return DPS310_I2C_FAIL_ERROR ;
57+ }
58+
59+ return DPS310_OK ;
60+ }
61+
62+ void dps310_i2c_delay_ms (uint32_t delay ) {
63+ delay_ms (delay );
64+ }
You can’t perform that action at this time.
0 commit comments