File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
application/main/src/keyboard Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -163,3 +163,19 @@ void adc_init()
163163 err_code = app_timer_create (& adc_timer , APP_TIMER_MODE_REPEATED , adc_convert );
164164 APP_ERROR_CHECK (err_code );
165165}
166+
167+ /**
168+ * @brief 阻塞式读取 ADC 值
169+ *
170+ * @param channel_index
171+ */
172+ nrf_saadc_value_t adc_read_sync (uint8_t channel_index )
173+ {
174+ nrf_saadc_value_t result_sync = 0 ;
175+ ret_code_t err_code ;
176+
177+ err_code = nrfx_saadc_sample_convert (channel_index , & result_sync );
178+ APP_ERROR_CHECK (err_code );
179+
180+ return result_sync ;
181+ }
Original file line number Diff line number Diff line change @@ -38,4 +38,5 @@ struct adc_channel_config {
3838#define ADC_CONVERT_CHANNEL (conf ) NRF_SECTION_ITEM_REGISTER(adc_channel, const struct adc_channel_config* _pt_##conf) = &conf
3939
4040void adc_timer_start (void );
41- void adc_init (void );
41+ void adc_init (void );
42+ nrf_saadc_value_t adc_read_sync (uint8_t channel_index );
You can’t perform that action at this time.
0 commit comments