nrf/twim: make pullup configurable, do not enable it by default.
This commit is contained in:
		
							parent
							
								
									b449f6de9d
								
							
						
					
					
						commit
						8dfb6dff86
					
				| @ -30,12 +30,16 @@ pub enum Frequency { | |||||||
| #[non_exhaustive] | #[non_exhaustive] | ||||||
| pub struct Config { | pub struct Config { | ||||||
|     pub frequency: Frequency, |     pub frequency: Frequency, | ||||||
|  |     pub sda_pullup: bool, | ||||||
|  |     pub scl_pullup: bool, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl Default for Config { | impl Default for Config { | ||||||
|     fn default() -> Self { |     fn default() -> Self { | ||||||
|         Self { |         Self { | ||||||
|             frequency: Frequency::K100, |             frequency: Frequency::K100, | ||||||
|  |             sda_pullup: false, | ||||||
|  |             scl_pullup: false, | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -61,15 +65,19 @@ impl<'d, T: Instance> Twim<'d, T> { | |||||||
|         sda.conf().write(|w| { |         sda.conf().write(|w| { | ||||||
|             w.dir().input(); |             w.dir().input(); | ||||||
|             w.input().connect(); |             w.input().connect(); | ||||||
|             w.pull().pullup(); |  | ||||||
|             w.drive().s0d1(); |             w.drive().s0d1(); | ||||||
|  |             if config.sda_pullup { | ||||||
|  |                 w.pull().pullup(); | ||||||
|  |             } | ||||||
|             w |             w | ||||||
|         }); |         }); | ||||||
|         scl.conf().write(|w| { |         scl.conf().write(|w| { | ||||||
|             w.dir().input(); |             w.dir().input(); | ||||||
|             w.input().connect(); |             w.input().connect(); | ||||||
|             w.pull().pullup(); |  | ||||||
|             w.drive().s0d1(); |             w.drive().s0d1(); | ||||||
|  |             if config.scl_pullup { | ||||||
|  |                 w.pull().pullup(); | ||||||
|  |             } | ||||||
|             w |             w | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user