diff options
| author | JuliDi <[email protected]> | 2023-06-19 13:54:22 +0200 |
|---|---|---|
| committer | JuliDi <[email protected]> | 2023-06-19 13:54:22 +0200 |
| commit | 56ab6d9f143ecc3041ac9726e621eedea729ca4d (patch) | |
| tree | 7b71ffa5fb2a4a41c65bd6a39cc7d5981c4b1733 /embassy-stm32 | |
| parent | 88052480b14b8dd38e7c4ba179b7035390f59618 (diff) | |
remove write_X variants
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/dac/mod.rs | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs index 704b77b37..f02adeed9 100644 --- a/embassy-stm32/src/dac/mod.rs +++ b/embassy-stm32/src/dac/mod.rs | |||
| @@ -86,6 +86,7 @@ impl Ch2Trigger { | |||
| 86 | 86 | ||
| 87 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | 87 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] |
| 88 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 88 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 89 | /// Single 8 or 12 bit value that can be output by the DAC | ||
| 89 | pub enum Value { | 90 | pub enum Value { |
| 90 | // 8 bit value | 91 | // 8 bit value |
| 91 | Bit8(u8), | 92 | Bit8(u8), |
| @@ -97,6 +98,7 @@ pub enum Value { | |||
| 97 | 98 | ||
| 98 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | 99 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] |
| 99 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 100 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 101 | /// Array variant of [`Value`] | ||
| 100 | pub enum ValueArray<'a> { | 102 | pub enum ValueArray<'a> { |
| 101 | // 8 bit values | 103 | // 8 bit values |
| 102 | Bit8(&'a [u8]), | 104 | Bit8(&'a [u8]), |
| @@ -239,29 +241,7 @@ impl<'d, T: Instance, Tx> Dac<'d, T, Tx> { | |||
| 239 | /// ## Current limitations | 241 | /// ## Current limitations |
| 240 | /// - Only CH1 Supported | 242 | /// - Only CH1 Supported |
| 241 | /// | 243 | /// |
| 242 | /// TODO: Allow an array of Value instead of only u16, right-aligned | 244 | pub async fn write(&mut self, data_ch1: ValueArray<'_>, circular: bool) -> Result<(), Error> |
| 243 | pub async fn write_8bit(&mut self, data_ch1: &[u8], circular: bool) -> Result<(), Error> | ||
| 244 | where | ||
| 245 | Tx: Dma<T>, | ||
| 246 | { | ||
| 247 | self.write_inner(ValueArray::Bit8(data_ch1), circular).await | ||
| 248 | } | ||
| 249 | |||
| 250 | pub async fn write_12bit_right_aligned(&mut self, data_ch1: &[u16], circular: bool) -> Result<(), Error> | ||
| 251 | where | ||
| 252 | Tx: Dma<T>, | ||
| 253 | { | ||
| 254 | self.write_inner(ValueArray::Bit12Right(data_ch1), circular).await | ||
| 255 | } | ||
| 256 | |||
| 257 | pub async fn write_12bit_left_aligned(&mut self, data_ch1: &[u16], circular: bool) -> Result<(), Error> | ||
| 258 | where | ||
| 259 | Tx: Dma<T>, | ||
| 260 | { | ||
| 261 | self.write_inner(ValueArray::Bit12Left(data_ch1), circular).await | ||
| 262 | } | ||
| 263 | |||
| 264 | async fn write_inner(&mut self, data_ch1: ValueArray<'_>, circular: bool) -> Result<(), Error> | ||
| 265 | where | 245 | where |
| 266 | Tx: Dma<T>, | 246 | Tx: Dma<T>, |
| 267 | { | 247 | { |
