aboutsummaryrefslogtreecommitdiff
path: root/embassy-mcxa
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-mcxa')
-rw-r--r--embassy-mcxa/src/adc.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/embassy-mcxa/src/adc.rs b/embassy-mcxa/src/adc.rs
index 16b40fa45..af7191573 100644
--- a/embassy-mcxa/src/adc.rs
+++ b/embassy-mcxa/src/adc.rs
@@ -435,9 +435,17 @@ impl<'a, I: Instance, M: ModeAdc> Adc<'a, I, M> {
435 /// # Arguments 435 /// # Arguments
436 /// * `index` - Command index 436 /// * `index` - Command index
437 /// * `config` - Command configuration 437 /// * `config` - Command configuration
438 pub fn set_conv_command_config(&self, index: u32, config: &ConvCommandConfig) { 438 ///
439 /// # Returns
440 /// * `Ok(())` if the command was configured successfully
441 /// * `Err(Error::InvalidConfig)` if the index is out of range
442 pub fn set_conv_command_config(&self, index: u32, config: &ConvCommandConfig) -> Result<()> {
439 let adc = I::ptr(); 443 let adc = I::ptr();
440 444
445 if index < 1 || index > 7 {
446 return Err(Error::InvalidConfig);
447 }
448
441 macro_rules! write_cmd { 449 macro_rules! write_cmd {
442 ($idx:expr) => {{ 450 ($idx:expr) => {{
443 paste! { 451 paste! {
@@ -475,8 +483,10 @@ impl<'a, I: Instance, M: ModeAdc> Adc<'a, I, M> {
475 5 => write_cmd!(5), 483 5 => write_cmd!(5),
476 6 => write_cmd!(6), 484 6 => write_cmd!(6),
477 7 => write_cmd!(7), 485 7 => write_cmd!(7),
478 _ => panic!("Invalid command index: must be between 1 and 7"), 486 _ => unreachable!(),
479 } 487 }
488
489 Ok(())
480 } 490 }
481 491
482 /// Get default conversion trigger configuration. 492 /// Get default conversion trigger configuration.