pros_sys/
lib.rs

1#![no_std]
2#![allow(non_upper_case_globals)]
3#![allow(non_camel_case_types)]
4#![allow(non_snake_case)]
5#![allow(dead_code)]
6
7pub mod adi;
8#[cfg(feature = "xapi")]
9pub mod apix;
10pub mod colors;
11pub mod distance;
12pub mod error;
13pub mod ext_adi;
14pub mod gps;
15pub mod imu;
16pub mod link;
17pub mod misc;
18pub mod motor;
19pub mod optical;
20pub mod rotation;
21pub mod rtos;
22pub mod screen;
23pub mod vision;
24
25use core::ffi::{c_char, c_int, c_void};
26
27pub use adi::*;
28pub use colors::*;
29pub use distance::*;
30pub use error::*;
31pub use ext_adi::*;
32pub use gps::*;
33pub use imu::*;
34pub use link::*;
35pub use misc::*;
36pub use motor::*;
37pub use optical::*;
38pub use rotation::*;
39pub use rtos::*;
40pub use screen::*;
41#[cfg(feaute = "apix")]
42pub use serial::*;
43pub use vision::*;
44#[cfg(feaute = "apix")]
45pub mod serial;
46
47pub const CLOCKS_PER_SEC: u32 = 1000;
48
49extern "C" {
50    #[cfg(not(target_arch = "wasm32"))]
51    pub fn memalign(alignment: usize, size: usize) -> *mut c_void;
52    #[cfg(not(target_arch = "wasm32"))]
53    pub fn free(ptr: *mut c_void);
54    pub fn __errno() -> *mut i32;
55    pub fn clock() -> i32;
56    pub fn puts(s: *const c_char) -> i32;
57    pub fn exit(code: i32) -> !;
58    pub fn write(fd: c_int, buf: *const c_void, count: usize) -> isize;
59
60    fn initialize();
61    fn opcontrol();
62    fn autonomous();
63    fn disabled();
64    fn competition_initialize();
65}
66
67#[no_mangle]
68unsafe extern "C" fn cpp_opcontrol() {
69    opcontrol();
70}
71#[no_mangle]
72unsafe extern "C" fn cpp_autonomous() {
73    autonomous();
74}
75#[no_mangle]
76unsafe extern "C" fn cpp_disabled() {
77    disabled();
78}
79#[no_mangle]
80unsafe extern "C" fn cpp_competition_initialize() {
81    competition_initialize();
82}
83#[no_mangle]
84unsafe extern "C" fn cpp_initialize() {
85    initialize();
86}
87#[no_mangle]
88unsafe extern "C" fn task_fn_wrapper(function: task_fn_t, args: *mut c_void) {
89    function.unwrap()(args);
90}