Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Lotlab/nrf52-keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-kirisame committed Sep 10, 2024
2 parents 4450f4f + ca44a7d commit 9b376b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion application/main/src/ble/ble_services.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,11 @@ static void gap_params_init(void)

set_device_name();

#ifdef DEVICE_BLE_APPEARANCE
err_code = sd_ble_gap_appearance_set(DEVICE_BLE_APPEARANCE);
#else
err_code = sd_ble_gap_appearance_set(BLE_APPEARANCE_GENERIC_HID);
#endif
APP_ERROR_CHECK(err_code);

memset(&gap_conn_params, 0, sizeof(gap_conn_params));
Expand Down Expand Up @@ -1008,4 +1012,4 @@ void ble_services_init()
dfu_init();
#endif
conn_params_init();
}
}
16 changes: 16 additions & 0 deletions application/main/src/keyboard/adc_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,19 @@ void adc_init()
err_code = app_timer_create(&adc_timer, APP_TIMER_MODE_REPEATED, adc_convert);
APP_ERROR_CHECK(err_code);
}

/**
* @brief 阻塞式读取 ADC 值
*
* @param channel_index
*/
nrf_saadc_value_t adc_read_sync(uint8_t channel_index)
{
nrf_saadc_value_t result_sync = 0;
ret_code_t err_code;

err_code = nrfx_saadc_sample_convert(channel_index, &result_sync);
APP_ERROR_CHECK(err_code);

return result_sync;
}
3 changes: 2 additions & 1 deletion application/main/src/keyboard/adc_convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ struct adc_channel_config {
#define ADC_CONVERT_CHANNEL(conf) NRF_SECTION_ITEM_REGISTER(adc_channel, const struct adc_channel_config* _pt_##conf) = &conf

void adc_timer_start(void);
void adc_init(void);
void adc_init(void);
nrf_saadc_value_t adc_read_sync(uint8_t channel_index);

0 comments on commit 9b376b3

Please sign in to comment.