Skip to content

Commit 405bfc8

Browse files
committed
Add println to examples, remove unused code
1 parent c433199 commit 405bfc8

File tree

1 file changed

+2
-44
lines changed

1 file changed

+2
-44
lines changed

src/uart.rs

+2-44
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ impl UartDevice {
122122
.map_err(UartDeviceError::from_c)
123123
}
124124

125-
126125
/// Tries to initialize the given `UART`. Returns a Result with rather `Ok<RMain>` where `RMain` is the value returned by the scoped main function
127126
/// or a `Err<UartDeviceStatus>` containing the error
128127
///
@@ -141,7 +140,7 @@ impl UartDevice {
141140
/// ```
142141
/// use riot_wrappers::uart::UartDevice;
143142
/// let mut cb = |new_data| {
144-
/// //do something here with the received data
143+
/// println!("Received {:02x}", new_data);
145144
/// };
146145
/// let mut scoped_main = |self_: &mut UartDevice| loop {
147146
/// self_.write(b"Hello from UART")
@@ -204,7 +203,7 @@ impl UartDevice {
204203
/// ```
205204
/// use riot_wrappers::uart::UartDevice;
206205
/// static mut CB: fn(u8) = |new_data| {
207-
/// //do something here with the received data
206+
/// println!("Received {:02x}", new_data);
208207
/// };
209208
/// let mut uart = UartDevice::new_with_static_cb(0, 115200, unsafe { &mut CB })
210209
/// .unwrap_or_else(|e| panic!("Error initializing UART: {e:?}"));
@@ -307,36 +306,6 @@ impl UartDevice {
307306
crate::gpio::GPIO::from_c(unsafe { uart_pin_tx(self.dev) })
308307
}
309308

310-
/// Configure the function that will be called when a start condition is detected
311-
/// This will not enable / disable the generation of the RX start interrupt
312-
/// # Arguments
313-
/// * `user_fxopt` - The user defined callback function that gets called when a start condition is detected
314-
#[cfg(riot_module_periph_uart_rxstart_irq)]
315-
pub fn rxstart_irq_configure<F>(&mut self, user_fxopt: &'a mut F)
316-
where
317-
F: FnMut() + Send + 'static,
318-
{
319-
unsafe {
320-
uart_rxstart_irq_configure(
321-
dev,
322-
Self::rxstart_callback::<F>,
323-
user_fxopt as *mut _ as *mut c_void,
324-
)
325-
};
326-
}
327-
328-
/// Enable the RX start interrupt
329-
#[cfg(riot_module_periph_uart_rxstart_irq)]
330-
pub fn rxstart_irq_enable(&mut self) {
331-
unsafe { uart_rxstart_irq_enable(self.dev) };
332-
}
333-
334-
/// Disable the RX start interrupt
335-
#[cfg(riot_module_periph_uart_rxstart_irq)]
336-
pub fn rxstart_irq_disable(&mut self) {
337-
unsafe { uart_rxstart_irq_disable(self.dev) };
338-
}
339-
340309
/// This is the callback that gets called directly from the kernel if new data from the `UART` is received
341310
/// # Arguments
342311
/// * `user_callback` - The address pointing to the user defined callback
@@ -347,17 +316,6 @@ impl UartDevice {
347316
{
348317
(*(user_callback as *mut F))(data); // We cast the void* back to the closure and call it
349318
}
350-
351-
/// This is the callback that gets called directly from the kernel when a start condition is detected
352-
/// # Arguments
353-
/// * `user_callback` - The address pointing to the user defined callback
354-
#[cfg(riot_module_periph_uart_rxstart_irq)]
355-
unsafe extern "C" fn rxstart_callback<F>(user_callback: *mut c_void)
356-
where
357-
F: FnMut() + 'scope,
358-
{
359-
(*(user_callback as *mut F))(); // We cast the void* back to the closure and call it
360-
}
361319
}
362320

363321
impl Drop for UartDevice {

0 commit comments

Comments
 (0)