Skip to content

Commit 98697e6

Browse files
committed
adapted config to vibration detection
1 parent d9a849f commit 98697e6

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

src/config/feature_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
feature_config.ringer.h
1+
feature_config.bell.h

src/twi/bma400.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,28 @@ ret_code_t bma400_read(uint8_t register_address, uint8_t *data, uint8_t length)
3131
}
3232

3333
ret_code_t bma400_reset(){
34-
uint8_t data[] = {0x7e, 0xb6};
34+
uint8_t data[] = {
35+
0x7e, 0xb6 // CMD, reset
36+
};
3537
return bma400_write(data, sizeof(data));
3638
}
3739

3840
ret_code_t bma400_set_low_power(){
39-
uint8_t data[] = {0x19, 0x01};
41+
uint8_t data[] = {
42+
0x19, 0x01 // ACC_CONFIG0, low power
43+
};
4044
return bma400_write(data, sizeof(data));
4145
}
4246

4347
ret_code_t bma400_set_auto_wakeup(){
44-
uint8_t wakeup_int_data[] = {0x2d, 0x02};
48+
uint8_t wakeup_int_data[] = {
49+
0x2d, 0x02 // AUTOWAKEUP_1, enable interrupt
50+
};
4551
CHECK_ERROR(bma400_write(wakeup_int_data, sizeof(wakeup_int_data)));
4652

4753
uint8_t data[] = {
48-
0x2f, 0xe2, // WKUP_INT_CONFIG0, enable xyz, ref update every time
49-
0x30, 0x28, // WKUP_INT_CONFIG1, threshold 40
54+
0x2f, 0x82, // WKUP_INT_CONFIG0, sample count 0, enable xyz, ref update every time
55+
0x30, 0x1A, // WKUP_INT_CONFIG1, threshold 40
5056
// 0x31, 0x00, // WKUP_INT_CONFIG2 refx 0
5157
// 0x32, 0x00, // WKUP_INT_CONFIG3 refy 0
5258
// 0x33, 0x40 // WKUP_INT_CONFIG4 refz 64
@@ -56,15 +62,17 @@ ret_code_t bma400_set_auto_wakeup(){
5662
}
5763

5864
ret_code_t bma400_set_auto_low_power(){
59-
uint8_t autolowpower_int_data[] = {0x2b, 0x02};
65+
uint8_t autolowpower_int_data[] = {
66+
0x2b, 0x02 // AUTOLOWPOW_1 gen1_int
67+
};
6068
CHECK_ERROR(bma400_write(autolowpower_int_data, sizeof(autolowpower_int_data)));
6169

6270
uint8_t data[] = {
63-
0x3f, 0xf9, // GEN1INT_CONFIG0 all axes, filter source acc_filt2, gen1_act_refu every time, gen1_act_hyst 24mg
71+
0x3f, 0x99, // GEN1INT_CONFIG0 all axes, filter source acc_filt2, gen1_act_refu every time, gen1_act_hyst 24mg
6472
0x40, 0x01, // GEN1INT_CONFIG1 logical AND
65-
0x41, 0x05, // GEN1INT_CONFIG2 gen1_int_thres 5
73+
0x41, 0x50, // GEN1INT_CONFIG2 gen1_int_thres 5
6674
0x42, 0x00, // GEN1INT_CONFIG3 duration 0
67-
0x43, 0x32, // GEN1INT_CONFIG4 duration 50
75+
0x43, 0xFF, // GEN1INT_CONFIG4 duration 50
6876
};
6977

7078
CHECK_ERROR(bma400_write(data, sizeof(data)));
@@ -95,6 +103,8 @@ void bma400_handle_gpio_event(uint32_t index, gpio_config_input_digital_t *confi
95103

96104
// NRF_LOG_DEBUG("int stat: %x\n", interrupt_reg);
97105

106+
/*
107+
98108
(*continue_handling) = false;
99109
100110
if(config->state != 1) {
@@ -181,6 +191,7 @@ void bma400_handle_gpio_event(uint32_t index, gpio_config_input_digital_t *confi
181191
gpio_config_input_digital_t *config = gpio_find_input_by_index(count);
182192
config->changed = false;
183193
}
194+
*/
184195
}
185196

186197
ret_code_t bma400_setup_orientation_detection(gpio_input_change_handler_t change_handler){
@@ -200,9 +211,8 @@ ret_code_t bma400_setup_orientation_detection(gpio_input_change_handler_t change
200211
CHECK_ERROR(bma400_set_auto_low_power());
201212

202213
uint8_t data[] = {
203-
0x20, 0x00, // INT_CONFIG1
204-
0x21, 0x04, // INT1_MAP gen1_int1
205-
0x22, 0x00, // INT2_MAP
214+
0x21, 0x00, // INT1_MAP gen1_int1
215+
0x22, 0x01, // INT2_MAP wakeup
206216
0x23, 0x00, // INT12_MAP
207217
};
208218

@@ -214,11 +224,15 @@ ret_code_t bma400_setup_orientation_detection(gpio_input_change_handler_t change
214224

215225
CHECK_ERROR(bma400_write(data2, sizeof(data2)));
216226

217-
uint8_t gen1_int_en_data[] = {0x1f, 0x04};
227+
uint8_t gen1_int_en_data[] = {
228+
0x1f, 0x04, // INT_CONFIG0 gen1_int_enable
229+
0x20, 0x00 // INT_CONFIG1
230+
};
218231
CHECK_ERROR(bma400_write(gen1_int_en_data, sizeof(gen1_int_en_data)));
219232

220-
return NRF_SUCCESS;
233+
NRF_LOG_INFO("BMA400 set up successfully.\n");
221234

235+
#if 0
222236
app_timer_create(
223237
&state_timer,
224238
APP_TIMER_MODE_REPEATED,
@@ -230,6 +244,7 @@ ret_code_t bma400_setup_orientation_detection(gpio_input_change_handler_t change
230244
APP_TIMER_TICKS(500, APP_TIMER_PRESCALER),
231245
NULL
232246
);
247+
#endif
233248

234249
return NRF_SUCCESS;
235250
}

0 commit comments

Comments
 (0)