Commit f9ae9552 authored by Simon Wörner's avatar Simon Wörner
Browse files

added comments

parent 6dc28a8a
......@@ -6,6 +6,7 @@ use std::mem::transmute;
use std::ptr::null_mut;
use std::sync::atomic::Ordering;
/// Constructs a new `EmergencyStop` on heap and returns pointer.
#[no_mangle]
pub extern "C" fn emergency_stop_init(stop: u8) -> *mut EmergencyStop {
match EmergencyStop::new(stop) {
......@@ -14,11 +15,13 @@ pub extern "C" fn emergency_stop_init(stop: u8) -> *mut EmergencyStop {
}
}
/// Drops a `EmergencyStop` pointer on heap.
#[no_mangle]
pub extern "C" fn emergency_stop_clean(emergency_stop: *mut EmergencyStop) {
let _emergency_stop: Box<EmergencyStop> = unsafe { transmute(emergency_stop) };
}
/// Returns `EmergencyStop` pointer state.
#[no_mangle]
pub extern "C" fn emergency_stop_get_state(emergency_stop: *mut EmergencyStop) -> bool {
let emergency_stop = unsafe { &mut *emergency_stop };
......
......@@ -7,6 +7,7 @@ use std::ptr::null_mut;
use std::mem::transmute;
use std::os::raw::c_char;
/// Constructs a new `Measure` on heap and returns pointer.
#[no_mangle]
pub extern "C" fn measure_init(name: *const c_char) -> *mut Measure {
if name.is_null() {
......@@ -21,11 +22,13 @@ pub extern "C" fn measure_init(name: *const c_char) -> *mut Measure {
}
}
/// Drops a `Measure` pointer on heap.
#[no_mangle]
pub extern "C" fn measure_clean(measure: *mut Measure) {
let _measure: Box<Measure> = unsafe { transmute(measure) };
}
/// Starts measure on `Measure` pointer.
#[no_mangle]
pub extern "C" fn measure_start(measure: *mut Measure) {
let measure = unsafe { &mut *measure };
......@@ -33,6 +36,7 @@ pub extern "C" fn measure_start(measure: *mut Measure) {
measure.start();
}
/// Pause measure on `Measure` pointer.
#[no_mangle]
pub extern "C" fn measure_pause(measure: *mut Measure) {
let measure = unsafe { &mut *measure };
......@@ -40,6 +44,7 @@ pub extern "C" fn measure_pause(measure: *mut Measure) {
measure.pause();
}
/// Stop measure on `Measure` pointer.
#[no_mangle]
pub extern "C" fn measure_stop(measure: *mut Measure) {
let measure = unsafe { &mut *measure };
......
......@@ -6,6 +6,7 @@ use std::sync::atomic::Ordering;
use self::ultrasonic_irq::Ultrasonic;
/// Constructs a new `Ultrasonic` on heap and returns pointer.
#[no_mangle]
pub extern "C" fn ultrasonic_init(trigger: u8, echo: u8, temperature: u8) -> *mut Ultrasonic {
match Ultrasonic::new(trigger, echo, temperature) {
......@@ -14,11 +15,13 @@ pub extern "C" fn ultrasonic_init(trigger: u8, echo: u8, temperature: u8) -> *mu
}
}
/// Drops a `Ultrasonic` pointer on heap.
#[no_mangle]
pub extern "C" fn ultrasonic_clean(ultrasonic: *mut Ultrasonic) {
let _ultrasonic: Box<Ultrasonic> = unsafe { transmute(ultrasonic) };
}
/// Returns `Ultrasonic` pointer distance.
#[no_mangle]
pub extern "C" fn ultrasonic_get_distance(ultrasonic: *mut Ultrasonic) -> u32 {
let ultrasonic = unsafe { &mut *ultrasonic };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment