Skip to main content

DSPS and I2C sensor code

4 years ago

DSPS and I2C sensor code

Posted byprasanth.velli…0 points 1 reply
0 upvotes

// My application is => SERVER profile reads data from I2C sensor and sends to CLIENT profile and CLIENT profile sends data via UART

int sample128_timer_handler(ke_msg_id_t const msgid,
struct gapm_cmp_evt const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{

ke_timer_set(APP_SAMPLE128_TIMER,TASK_APP,300); // Adv.delay => 50 -> 0.5s , 100 -> 1s , 300 -> 3s

Read_from_sensor(); // Reads data from I2C sensor

struct sample128_upd_char2_req *req = KE_MSG_ALLOC(
SAMPLE128_UPD_CHAR2_REQ,
TASK_SAMPLE128,
TASK_APP,
sample128_upd_char2_req
);
//req->val = sample128_placeholder;
//memcpy(&req->val,&sample128_placeholder,sizeof(sample128_placeholder));
memcpy(&req->val_1,&SensorData,sizeof(SensorData)); // sends sensor data via BLE
req->conhdl = app_env.conhdl;
ke_msg_send(req);
}
I have created custom profile that reads data from my sensor via I2C , using - sample128_After section 7.3.6 - project , and its working fine , i can see the data in android app .

Q1 : If i put the same Read_from_sensor(); code inside the DSPS device project , code stopping at line - WAIT_FOR_RECEIVED_BYTE();

i have tried with in functions -void user_ble_pull (bool init, bool success) ->code stopping at - WAIT_FOR_RECEIVED_BYTE();
-void user_send_ble_data(const uint8_t *data,uint16_t length) ->code stopping at - WAIT_FOR_RECEIVED_BYTE();
could you please help me with this issue...

4 years ago

MT_dialog -30 points

Hi prasanth,

The problem lies in the sensor, the 580 waits for the sensor to get some data back but there is no response from the sensor and it keeps waiting, check your connections and the responses that you get from the sensor also check if you have configured your pins correctly. The definition just checks if there are data in the I2C FIFO.

Thanks MT_dialog