1#[allow(unused_imports)]
15use crate::{
16 base58::Uid, byte_converter::*, device::*, error::TinkerforgeError, ip_connection::async_io::AsyncIpConnection,
17 low_level_traits::LowLevelRead,
18};
19#[allow(unused_imports)]
20use futures_core::Stream;
21#[allow(unused_imports)]
22use tokio_stream::StreamExt;
23pub enum Xmc1400BreakoutBrickletFunction {
24 SetGpioConfig,
25 GetGpioInput,
26 SetAdcChannelConfig,
27 GetAdcChannelConfig,
28 GetAdcChannelValue,
29 GetAdcValues,
30 SetAdcValuesCallbackConfiguration,
31 GetAdcValuesCallbackConfiguration,
32 GetCount,
33 SetCountCallbackConfiguration,
34 GetCountCallbackConfiguration,
35 GetSpitfpErrorCount,
36 SetBootloaderMode,
37 GetBootloaderMode,
38 SetWriteFirmwarePointer,
39 WriteFirmware,
40 SetStatusLedConfig,
41 GetStatusLedConfig,
42 GetChipTemperature,
43 Reset,
44 WriteUid,
45 ReadUid,
46 GetIdentity,
47 CallbackAdcValues,
48 CallbackCount,
49}
50impl From<Xmc1400BreakoutBrickletFunction> for u8 {
51 fn from(fun: Xmc1400BreakoutBrickletFunction) -> Self {
52 match fun {
53 Xmc1400BreakoutBrickletFunction::SetGpioConfig => 1,
54 Xmc1400BreakoutBrickletFunction::GetGpioInput => 2,
55 Xmc1400BreakoutBrickletFunction::SetAdcChannelConfig => 3,
56 Xmc1400BreakoutBrickletFunction::GetAdcChannelConfig => 4,
57 Xmc1400BreakoutBrickletFunction::GetAdcChannelValue => 5,
58 Xmc1400BreakoutBrickletFunction::GetAdcValues => 6,
59 Xmc1400BreakoutBrickletFunction::SetAdcValuesCallbackConfiguration => 7,
60 Xmc1400BreakoutBrickletFunction::GetAdcValuesCallbackConfiguration => 8,
61 Xmc1400BreakoutBrickletFunction::GetCount => 10,
62 Xmc1400BreakoutBrickletFunction::SetCountCallbackConfiguration => 11,
63 Xmc1400BreakoutBrickletFunction::GetCountCallbackConfiguration => 12,
64 Xmc1400BreakoutBrickletFunction::GetSpitfpErrorCount => 234,
65 Xmc1400BreakoutBrickletFunction::SetBootloaderMode => 235,
66 Xmc1400BreakoutBrickletFunction::GetBootloaderMode => 236,
67 Xmc1400BreakoutBrickletFunction::SetWriteFirmwarePointer => 237,
68 Xmc1400BreakoutBrickletFunction::WriteFirmware => 238,
69 Xmc1400BreakoutBrickletFunction::SetStatusLedConfig => 239,
70 Xmc1400BreakoutBrickletFunction::GetStatusLedConfig => 240,
71 Xmc1400BreakoutBrickletFunction::GetChipTemperature => 242,
72 Xmc1400BreakoutBrickletFunction::Reset => 243,
73 Xmc1400BreakoutBrickletFunction::WriteUid => 248,
74 Xmc1400BreakoutBrickletFunction::ReadUid => 249,
75 Xmc1400BreakoutBrickletFunction::GetIdentity => 255,
76 Xmc1400BreakoutBrickletFunction::CallbackAdcValues => 9,
77 Xmc1400BreakoutBrickletFunction::CallbackCount => 13,
78 }
79 }
80}
81pub const XMC1400_BREAKOUT_BRICKLET_THRESHOLD_OPTION_OFF: char = 'x';
82pub const XMC1400_BREAKOUT_BRICKLET_THRESHOLD_OPTION_OUTSIDE: char = 'o';
83pub const XMC1400_BREAKOUT_BRICKLET_THRESHOLD_OPTION_INSIDE: char = 'i';
84pub const XMC1400_BREAKOUT_BRICKLET_THRESHOLD_OPTION_SMALLER: char = '<';
85pub const XMC1400_BREAKOUT_BRICKLET_THRESHOLD_OPTION_GREATER: char = '>';
86pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_TRISTATE: u8 = 0;
87pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_PULL_DOWN: u8 = 1;
88pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_PULL_UP: u8 = 2;
89pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_SAMPLING: u8 = 3;
90pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_INVERTED_TRISTATE: u8 = 4;
91pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_INVERTED_PULL_DOWN: u8 = 5;
92pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_INVERTED_PULL_UP: u8 = 6;
93pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_INPUT_INVERTED_SAMPLING: u8 = 7;
94pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_OUTPUT_PUSH_PULL: u8 = 8;
95pub const XMC1400_BREAKOUT_BRICKLET_GPIO_MODE_OUTPUT_OPEN_DRAIN: u8 = 9;
96pub const XMC1400_BREAKOUT_BRICKLET_GPIO_INPUT_HYSTERESIS_STANDARD: u8 = 0;
97pub const XMC1400_BREAKOUT_BRICKLET_GPIO_INPUT_HYSTERESIS_LARGE: u8 = 4;
98pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
99pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
100pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
101pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
102pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
103pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
104pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
105pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
106pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
107pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
108pub const XMC1400_BREAKOUT_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
109pub const XMC1400_BREAKOUT_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
110pub const XMC1400_BREAKOUT_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
111pub const XMC1400_BREAKOUT_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
112pub const XMC1400_BREAKOUT_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
113
114#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
115pub struct AdcValuesCallbackConfiguration {
116 pub period: u32,
117 pub value_has_to_change: bool,
118}
119impl FromByteSlice for AdcValuesCallbackConfiguration {
120 fn bytes_expected() -> usize {
121 5
122 }
123 fn from_le_byte_slice(bytes: &[u8]) -> AdcValuesCallbackConfiguration {
124 AdcValuesCallbackConfiguration {
125 period: <u32>::from_le_byte_slice(&bytes[0..4]),
126 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
127 }
128 }
129}
130
131#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
132pub struct CountCallbackConfiguration {
133 pub period: u32,
134 pub value_has_to_change: bool,
135 pub option: char,
136 pub min: u32,
137 pub max: u32,
138}
139impl FromByteSlice for CountCallbackConfiguration {
140 fn bytes_expected() -> usize {
141 14
142 }
143 fn from_le_byte_slice(bytes: &[u8]) -> CountCallbackConfiguration {
144 CountCallbackConfiguration {
145 period: <u32>::from_le_byte_slice(&bytes[0..4]),
146 value_has_to_change: <bool>::from_le_byte_slice(&bytes[4..5]),
147 option: <char>::from_le_byte_slice(&bytes[5..6]),
148 min: <u32>::from_le_byte_slice(&bytes[6..10]),
149 max: <u32>::from_le_byte_slice(&bytes[10..14]),
150 }
151 }
152}
153
154#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
155pub struct SpitfpErrorCount {
156 pub error_count_ack_checksum: u32,
157 pub error_count_message_checksum: u32,
158 pub error_count_frame: u32,
159 pub error_count_overflow: u32,
160}
161impl FromByteSlice for SpitfpErrorCount {
162 fn bytes_expected() -> usize {
163 16
164 }
165 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
166 SpitfpErrorCount {
167 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
168 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
169 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
170 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
171 }
172 }
173}
174
175#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
176pub struct Identity {
177 pub uid: String,
178 pub connected_uid: String,
179 pub position: char,
180 pub hardware_version: [u8; 3],
181 pub firmware_version: [u8; 3],
182 pub device_identifier: u16,
183}
184impl FromByteSlice for Identity {
185 fn bytes_expected() -> usize {
186 25
187 }
188 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
189 Identity {
190 uid: <String>::from_le_byte_slice(&bytes[0..8]),
191 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
192 position: <char>::from_le_byte_slice(&bytes[16..17]),
193 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
194 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
195 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
196 }
197 }
198}
199
200#[derive(Clone)]
202pub struct Xmc1400BreakoutBricklet {
203 device: Device,
204}
205impl Xmc1400BreakoutBricklet {
206 pub const DEVICE_IDENTIFIER: u16 = 279;
207 pub const DEVICE_DISPLAY_NAME: &'static str = "XMC1400 Breakout Bricklet";
208 pub fn new(uid: Uid, connection: AsyncIpConnection) -> Xmc1400BreakoutBricklet {
210 let mut result = Xmc1400BreakoutBricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
211 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::SetGpioConfig) as usize] = ResponseExpectedFlag::False;
212 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetGpioInput) as usize] =
213 ResponseExpectedFlag::AlwaysTrue;
214 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::SetAdcChannelConfig) as usize] =
215 ResponseExpectedFlag::False;
216 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetAdcChannelConfig) as usize] =
217 ResponseExpectedFlag::AlwaysTrue;
218 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetAdcChannelValue) as usize] =
219 ResponseExpectedFlag::AlwaysTrue;
220 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetAdcValues) as usize] =
221 ResponseExpectedFlag::AlwaysTrue;
222 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::SetAdcValuesCallbackConfiguration) as usize] =
223 ResponseExpectedFlag::True;
224 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetAdcValuesCallbackConfiguration) as usize] =
225 ResponseExpectedFlag::AlwaysTrue;
226 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetCount) as usize] = ResponseExpectedFlag::AlwaysTrue;
227 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::SetCountCallbackConfiguration) as usize] =
228 ResponseExpectedFlag::True;
229 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetCountCallbackConfiguration) as usize] =
230 ResponseExpectedFlag::AlwaysTrue;
231 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetSpitfpErrorCount) as usize] =
232 ResponseExpectedFlag::AlwaysTrue;
233 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::SetBootloaderMode) as usize] =
234 ResponseExpectedFlag::AlwaysTrue;
235 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetBootloaderMode) as usize] =
236 ResponseExpectedFlag::AlwaysTrue;
237 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::SetWriteFirmwarePointer) as usize] =
238 ResponseExpectedFlag::False;
239 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::WriteFirmware) as usize] =
240 ResponseExpectedFlag::AlwaysTrue;
241 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::SetStatusLedConfig) as usize] =
242 ResponseExpectedFlag::False;
243 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetStatusLedConfig) as usize] =
244 ResponseExpectedFlag::AlwaysTrue;
245 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetChipTemperature) as usize] =
246 ResponseExpectedFlag::AlwaysTrue;
247 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
248 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
249 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
250 result.device.response_expected[u8::from(Xmc1400BreakoutBrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
251 result
252 }
253
254 pub fn get_response_expected(&mut self, fun: Xmc1400BreakoutBrickletFunction) -> Result<bool, GetResponseExpectedError> {
269 self.device.get_response_expected(u8::from(fun))
270 }
271
272 pub fn set_response_expected(
281 &mut self,
282 fun: Xmc1400BreakoutBrickletFunction,
283 response_expected: bool,
284 ) -> Result<(), SetResponseExpectedError> {
285 self.device.set_response_expected(u8::from(fun), response_expected)
286 }
287
288 pub fn set_response_expected_all(&mut self, response_expected: bool) {
290 self.device.set_response_expected_all(response_expected)
291 }
292
293 pub fn get_api_version(&self) -> [u8; 3] {
296 self.device.api_version
297 }
298
299 pub async fn get_adc_values_callback_receiver(&mut self) -> impl Stream<Item = [u16; 8]> {
307 self.device
308 .get_callback_receiver(u8::from(Xmc1400BreakoutBrickletFunction::CallbackAdcValues))
309 .await
310 .map(|p| <[u16; 8]>::from_le_byte_slice(p.body()))
311 }
312
313 pub async fn get_count_callback_receiver(&mut self) -> impl Stream<Item = u32> {
318 self.device
319 .get_callback_receiver(u8::from(Xmc1400BreakoutBrickletFunction::CallbackCount))
320 .await
321 .map(|p| u32::from_le_byte_slice(p.body()))
322 }
323
324 pub async fn set_gpio_config(
341 &mut self,
342 port: u8,
343 pin: u8,
344 mode: u8,
345 input_hysteresis: u8,
346 output_level: bool,
347 ) -> Result<(), TinkerforgeError> {
348 let mut payload = [0; 5];
349 port.write_to_slice(&mut payload[0..1]);
350 pin.write_to_slice(&mut payload[1..2]);
351 mode.write_to_slice(&mut payload[2..3]);
352 input_hysteresis.write_to_slice(&mut payload[3..4]);
353 output_level.write_to_slice(&mut payload[4..5]);
354
355 #[allow(unused_variables)]
356 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::SetGpioConfig), &payload).await?;
357 Ok(())
358 }
359
360 pub async fn get_gpio_input(&mut self, port: u8, pin: u8) -> Result<bool, TinkerforgeError> {
363 let mut payload = [0; 2];
364 port.write_to_slice(&mut payload[0..1]);
365 pin.write_to_slice(&mut payload[1..2]);
366
367 #[allow(unused_variables)]
368 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetGpioInput), &payload).await?;
369 Ok(bool::from_le_byte_slice(result.body()))
370 }
371
372 pub async fn set_adc_channel_config(&mut self, channel: u8, enable: bool) -> Result<(), TinkerforgeError> {
385 let mut payload = [0; 2];
386 channel.write_to_slice(&mut payload[0..1]);
387 enable.write_to_slice(&mut payload[1..2]);
388
389 #[allow(unused_variables)]
390 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::SetAdcChannelConfig), &payload).await?;
391 Ok(())
392 }
393
394 pub async fn get_adc_channel_config(&mut self, channel: u8) -> Result<bool, TinkerforgeError> {
396 let mut payload = [0; 1];
397 channel.write_to_slice(&mut payload[0..1]);
398
399 #[allow(unused_variables)]
400 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetAdcChannelConfig), &payload).await?;
401 Ok(bool::from_le_byte_slice(result.body()))
402 }
403
404 pub async fn get_adc_channel_value(&mut self, channel: u8) -> Result<u16, TinkerforgeError> {
406 let mut payload = [0; 1];
407 channel.write_to_slice(&mut payload[0..1]);
408
409 #[allow(unused_variables)]
410 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetAdcChannelValue), &payload).await?;
411 Ok(u16::from_le_byte_slice(result.body()))
412 }
413
414 pub async fn get_adc_values(&mut self) -> Result<Box<[u16; 8]>, TinkerforgeError> {
420 let payload = [0; 0];
421
422 #[allow(unused_variables)]
423 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetAdcValues), &payload).await?;
424 Ok(Box::<[u16; 8]>::from_le_byte_slice(result.body()))
425 }
426
427 pub async fn set_adc_values_callback_configuration(&mut self, period: u32, value_has_to_change: bool) -> Result<(), TinkerforgeError> {
437 let mut payload = [0; 5];
438 period.write_to_slice(&mut payload[0..4]);
439 value_has_to_change.write_to_slice(&mut payload[4..5]);
440
441 #[allow(unused_variables)]
442 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::SetAdcValuesCallbackConfiguration), &payload).await?;
443 Ok(())
444 }
445
446 pub async fn get_adc_values_callback_configuration(&mut self) -> Result<AdcValuesCallbackConfiguration, TinkerforgeError> {
449 let payload = [0; 0];
450
451 #[allow(unused_variables)]
452 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetAdcValuesCallbackConfiguration), &payload).await?;
453 Ok(AdcValuesCallbackConfiguration::from_le_byte_slice(result.body()))
454 }
455
456 pub async fn get_count(&mut self) -> Result<u32, TinkerforgeError> {
467 let payload = [0; 0];
468
469 #[allow(unused_variables)]
470 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetCount), &payload).await?;
471 Ok(u32::from_le_byte_slice(result.body()))
472 }
473
474 pub async fn set_count_callback_configuration(
507 &mut self,
508 period: u32,
509 value_has_to_change: bool,
510 option: char,
511 min: u32,
512 max: u32,
513 ) -> Result<(), TinkerforgeError> {
514 let mut payload = [0; 14];
515 period.write_to_slice(&mut payload[0..4]);
516 value_has_to_change.write_to_slice(&mut payload[4..5]);
517 option.write_to_slice(&mut payload[5..6]);
518 min.write_to_slice(&mut payload[6..10]);
519 max.write_to_slice(&mut payload[10..14]);
520
521 #[allow(unused_variables)]
522 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::SetCountCallbackConfiguration), &payload).await?;
523 Ok(())
524 }
525
526 pub async fn get_count_callback_configuration(&mut self) -> Result<CountCallbackConfiguration, TinkerforgeError> {
535 let payload = [0; 0];
536
537 #[allow(unused_variables)]
538 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetCountCallbackConfiguration), &payload).await?;
539 Ok(CountCallbackConfiguration::from_le_byte_slice(result.body()))
540 }
541
542 pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
554 let payload = [0; 0];
555
556 #[allow(unused_variables)]
557 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetSpitfpErrorCount), &payload).await?;
558 Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
559 }
560
561 pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
584 let mut payload = [0; 1];
585 mode.write_to_slice(&mut payload[0..1]);
586
587 #[allow(unused_variables)]
588 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::SetBootloaderMode), &payload).await?;
589 Ok(u8::from_le_byte_slice(result.body()))
590 }
591
592 pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
601 let payload = [0; 0];
602
603 #[allow(unused_variables)]
604 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetBootloaderMode), &payload).await?;
605 Ok(u8::from_le_byte_slice(result.body()))
606 }
607
608 pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
615 let mut payload = [0; 4];
616 pointer.write_to_slice(&mut payload[0..4]);
617
618 #[allow(unused_variables)]
619 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::SetWriteFirmwarePointer), &payload).await?;
620 Ok(())
621 }
622
623 pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
632 let mut payload = [0; 64];
633 data.write_to_slice(&mut payload[0..64]);
634
635 #[allow(unused_variables)]
636 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::WriteFirmware), &payload).await?;
637 Ok(u8::from_le_byte_slice(result.body()))
638 }
639
640 pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
654 let mut payload = [0; 1];
655 config.write_to_slice(&mut payload[0..1]);
656
657 #[allow(unused_variables)]
658 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::SetStatusLedConfig), &payload).await?;
659 Ok(())
660 }
661
662 pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
670 let payload = [0; 0];
671
672 #[allow(unused_variables)]
673 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetStatusLedConfig), &payload).await?;
674 Ok(u8::from_le_byte_slice(result.body()))
675 }
676
677 pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
684 let payload = [0; 0];
685
686 #[allow(unused_variables)]
687 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetChipTemperature), &payload).await?;
688 Ok(i16::from_le_byte_slice(result.body()))
689 }
690
691 pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
698 let payload = [0; 0];
699
700 #[allow(unused_variables)]
701 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::Reset), &payload).await?;
702 Ok(())
703 }
704
705 pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
711 let mut payload = [0; 4];
712 uid.write_to_slice(&mut payload[0..4]);
713
714 #[allow(unused_variables)]
715 let result = self.device.set(u8::from(Xmc1400BreakoutBrickletFunction::WriteUid), &payload).await?;
716 Ok(())
717 }
718
719 pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
722 let payload = [0; 0];
723
724 #[allow(unused_variables)]
725 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::ReadUid), &payload).await?;
726 Ok(u32::from_le_byte_slice(result.body()))
727 }
728
729 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
740 let payload = [0; 0];
741
742 #[allow(unused_variables)]
743 let result = self.device.get(u8::from(Xmc1400BreakoutBrickletFunction::GetIdentity), &payload).await?;
744 Ok(Identity::from_le_byte_slice(result.body()))
745 }
746}