1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
#![allow(dead_code)] use core::default::Default; pub const RTC_IEN_COMP0: u32 = (0x1 << 1); #[repr(C)] #[derive(Copy, Clone)] pub struct Init { pub enable: bool, pub debug_run: bool, pub comp0_top: bool } impl Default for Init { fn default() -> Init { Init { enable: true, debug_run: false, comp0_top: true } } } #[link(name = "emlib")] extern { fn RTC_CompareGet(comp: u32) -> u32; fn RTC_CompareSet(comp: u32, value: u32); fn STATIC_INLINE_RTC_CounterGet(); fn STATIC_INLINE_RTC_IntClear(flags: u32); fn STATIC_INLINE_RTC_IntDisable(flags: u32); fn STATIC_INLINE_RTC_IntEnable(flags: u32); fn STATIC_INLINE_RTC_IntGet() -> u32; fn STATIC_INLINE_RTC_IntSet(flags: u32); fn RTC_Reset(); fn RTC_Enable(enable: bool); fn RTC_FreezeEnable(enable: bool); fn RTC_Init(init: &Init); fn RTC_CounterReset(); } pub fn compare_get(comp: u32) -> u32 { unsafe { RTC_CompareGet(comp) } } pub fn compare_set(comp: u32, value: u32) { unsafe { RTC_CompareSet(comp, value) } } pub fn counter_get() { unsafe { STATIC_INLINE_RTC_CounterGet() } } pub fn int_clear(flags: u32) { unsafe { STATIC_INLINE_RTC_IntClear(flags) } } pub fn int_disable(flags: u32) { unsafe { STATIC_INLINE_RTC_IntDisable(flags) } } pub fn int_enable(flags: u32) { unsafe { STATIC_INLINE_RTC_IntEnable(flags) } } pub fn int_get() -> u32 { unsafe { STATIC_INLINE_RTC_IntGet() } } pub fn int_set(flags: u32) { unsafe { STATIC_INLINE_RTC_IntSet(flags) } } pub fn reset() { unsafe { RTC_Reset() } } pub fn enable(enable: bool) { unsafe { RTC_Enable(enable) } } pub fn freeze_enable(enable: bool) { unsafe { RTC_FreezeEnable(enable) } } pub fn init(init: &Init) { unsafe { RTC_Init(init) } } pub fn counter_reset() { unsafe { RTC_CounterReset() } }