Move active pointer code to Rust

This commit is contained in:
Greg Shuflin 2021-03-01 23:32:38 -08:00
parent 0acf55a971
commit 5658759cf3
2 changed files with 12 additions and 13 deletions

10
radio.c
View File

@ -59,16 +59,6 @@ static radio_tab_t radio_tab[] = {
}; };
*/ */
static radio_device_t *active_device; // Device-dependent interface
radio_device_t* get_active_device() {
return active_device;
}
void set_active_device(radio_device_t* d) {
active_device = d;
}
// //
// Read the configuration from text file, and modify the firmware. // Read the configuration from text file, and modify the firmware.
// //

View File

@ -37,9 +37,6 @@ pub static mut radio_mem: [u8; 1024*1024*2] = [0; 1024*1024*2];
extern { extern {
fn get_active_device() -> *const radio_device_t;
fn set_active_device(device: *const radio_device_t);
fn radio_parse_config(device: *const radio_device_t, filename: *const c_char); fn radio_parse_config(device: *const radio_device_t, filename: *const c_char);
fn dfu_init(vid: c_uint, pid: c_uint) -> *const c_char; fn dfu_init(vid: c_uint, pid: c_uint) -> *const c_char;
@ -55,6 +52,18 @@ extern {
fn serial_close(); fn serial_close();
} }
static mut active_device: *const radio_device_t = std::ptr::null(); // Device-dependent interface
unsafe fn get_active_device() -> *const radio_device_t {
return active_device;
}
unsafe fn set_active_device(d: *const radio_device_t) {
active_device = d;
}
/// Connect to the radio via the serial port. /// Connect to the radio via the serial port.
/// and identify the type of device. /// and identify the type of device.
pub fn connect() -> Radio { pub fn connect() -> Radio {