|
| 1 | +#![no_std] |
| 2 | +#![no_main] |
| 3 | + |
| 4 | +extern crate avr_std_stub; |
| 5 | + |
| 6 | +use avr_delay::delay_cycles; |
| 7 | + |
| 8 | +#[no_mangle] |
| 9 | +fn main() {} |
| 10 | + |
| 11 | +/* |
| 12 | +
|
| 13 | +Interesting corner case values. They are picked to be right around the switch between lower to |
| 14 | +higher number of bits for the dealy counter. |
| 15 | +
|
| 16 | +#!/bin/bash |
| 17 | +while read i; do |
| 18 | + echo "#[inline(never)] #[no_mangle] pub fn test_${i}() { delay_cycles::<${i}>(); }" |
| 19 | +done <<EOF |
| 20 | +0 |
| 21 | +1 |
| 22 | +2 |
| 23 | +3 |
| 24 | +4 |
| 25 | +5 |
| 26 | +6 |
| 27 | +7 |
| 28 | +8 |
| 29 | +9 |
| 30 | +11 |
| 31 | +12 |
| 32 | +767 |
| 33 | +768 |
| 34 | +769 |
| 35 | +770 |
| 36 | +771 |
| 37 | +772 |
| 38 | +773 |
| 39 | +774 |
| 40 | +262_144 |
| 41 | +262_145 |
| 42 | +262_146 |
| 43 | +262_147 |
| 44 | +262_148 |
| 45 | +262_149 |
| 46 | +262_150 |
| 47 | +262_151 |
| 48 | +262_152 |
| 49 | +262_153 |
| 50 | +262_154 |
| 51 | +262_155 |
| 52 | +83_886_081 |
| 53 | +83_886_082 |
| 54 | +83_886_083 |
| 55 | +83_886_084 |
| 56 | +83_886_085 |
| 57 | +83_886_086 |
| 58 | +83_886_087 |
| 59 | +83_886_088 |
| 60 | +83_886_089 |
| 61 | +83_886_090 |
| 62 | +83_886_091 |
| 63 | +83_886_092 |
| 64 | +83_886_093 |
| 65 | +83_886_094 |
| 66 | +83_886_095 |
| 67 | +25_769_803_778 |
| 68 | +25_769_803_779 |
| 69 | +25_769_803_780 |
| 70 | +25_769_803_783 |
| 71 | +25_769_803_784 |
| 72 | +EOF |
| 73 | +
|
| 74 | +*/ |
| 75 | + |
| 76 | +#[inline(never)] #[no_mangle] pub fn test_0() { delay_cycles::<0>(); } |
| 77 | +#[inline(never)] #[no_mangle] pub fn test_1() { delay_cycles::<1>(); } |
| 78 | +#[inline(never)] #[no_mangle] pub fn test_2() { delay_cycles::<2>(); } |
| 79 | +#[inline(never)] #[no_mangle] pub fn test_3() { delay_cycles::<3>(); } |
| 80 | +#[inline(never)] #[no_mangle] pub fn test_4() { delay_cycles::<4>(); } |
| 81 | +#[inline(never)] #[no_mangle] pub fn test_5() { delay_cycles::<5>(); } |
| 82 | +#[inline(never)] #[no_mangle] pub fn test_6() { delay_cycles::<6>(); } |
| 83 | +#[inline(never)] #[no_mangle] pub fn test_7() { delay_cycles::<7>(); } |
| 84 | +#[inline(never)] #[no_mangle] pub fn test_8() { delay_cycles::<8>(); } |
| 85 | +#[inline(never)] #[no_mangle] pub fn test_9() { delay_cycles::<9>(); } |
| 86 | +#[inline(never)] #[no_mangle] pub fn test_11() { delay_cycles::<11>(); } |
| 87 | +#[inline(never)] #[no_mangle] pub fn test_12() { delay_cycles::<12>(); } |
| 88 | +#[inline(never)] #[no_mangle] pub fn test_767() { delay_cycles::<767>(); } |
| 89 | +#[inline(never)] #[no_mangle] pub fn test_768() { delay_cycles::<768>(); } |
| 90 | +#[inline(never)] #[no_mangle] pub fn test_769() { delay_cycles::<769>(); } |
| 91 | +#[inline(never)] #[no_mangle] pub fn test_770() { delay_cycles::<770>(); } |
| 92 | +#[inline(never)] #[no_mangle] pub fn test_771() { delay_cycles::<771>(); } |
| 93 | +#[inline(never)] #[no_mangle] pub fn test_772() { delay_cycles::<772>(); } |
| 94 | +#[inline(never)] #[no_mangle] pub fn test_773() { delay_cycles::<773>(); } |
| 95 | +#[inline(never)] #[no_mangle] pub fn test_774() { delay_cycles::<774>(); } |
| 96 | +#[inline(never)] #[no_mangle] pub fn test_262_144() { delay_cycles::<262_144>(); } |
| 97 | +#[inline(never)] #[no_mangle] pub fn test_262_145() { delay_cycles::<262_145>(); } |
| 98 | +#[inline(never)] #[no_mangle] pub fn test_262_146() { delay_cycles::<262_146>(); } |
| 99 | +#[inline(never)] #[no_mangle] pub fn test_262_147() { delay_cycles::<262_147>(); } |
| 100 | +#[inline(never)] #[no_mangle] pub fn test_262_148() { delay_cycles::<262_148>(); } |
| 101 | +#[inline(never)] #[no_mangle] pub fn test_262_149() { delay_cycles::<262_149>(); } |
| 102 | +#[inline(never)] #[no_mangle] pub fn test_262_150() { delay_cycles::<262_150>(); } |
| 103 | +#[inline(never)] #[no_mangle] pub fn test_262_151() { delay_cycles::<262_151>(); } |
| 104 | +#[inline(never)] #[no_mangle] pub fn test_262_152() { delay_cycles::<262_152>(); } |
| 105 | +#[inline(never)] #[no_mangle] pub fn test_262_153() { delay_cycles::<262_153>(); } |
| 106 | +#[inline(never)] #[no_mangle] pub fn test_262_154() { delay_cycles::<262_154>(); } |
| 107 | +#[inline(never)] #[no_mangle] pub fn test_262_155() { delay_cycles::<262_155>(); } |
| 108 | +#[inline(never)] #[no_mangle] pub fn test_83_886_081() { delay_cycles::<83_886_081>(); } |
| 109 | +#[inline(never)] #[no_mangle] pub fn test_83_886_082() { delay_cycles::<83_886_082>(); } |
| 110 | +#[inline(never)] #[no_mangle] pub fn test_83_886_083() { delay_cycles::<83_886_083>(); } |
| 111 | +#[inline(never)] #[no_mangle] pub fn test_83_886_084() { delay_cycles::<83_886_084>(); } |
| 112 | +#[inline(never)] #[no_mangle] pub fn test_83_886_085() { delay_cycles::<83_886_085>(); } |
| 113 | +#[inline(never)] #[no_mangle] pub fn test_83_886_086() { delay_cycles::<83_886_086>(); } |
| 114 | +#[inline(never)] #[no_mangle] pub fn test_83_886_087() { delay_cycles::<83_886_087>(); } |
| 115 | +#[inline(never)] #[no_mangle] pub fn test_83_886_088() { delay_cycles::<83_886_088>(); } |
| 116 | +#[inline(never)] #[no_mangle] pub fn test_83_886_089() { delay_cycles::<83_886_089>(); } |
| 117 | +#[inline(never)] #[no_mangle] pub fn test_83_886_090() { delay_cycles::<83_886_090>(); } |
| 118 | +#[inline(never)] #[no_mangle] pub fn test_83_886_091() { delay_cycles::<83_886_091>(); } |
| 119 | +#[inline(never)] #[no_mangle] pub fn test_83_886_092() { delay_cycles::<83_886_092>(); } |
| 120 | +#[inline(never)] #[no_mangle] pub fn test_83_886_093() { delay_cycles::<83_886_093>(); } |
| 121 | +#[inline(never)] #[no_mangle] pub fn test_83_886_094() { delay_cycles::<83_886_094>(); } |
| 122 | +#[inline(never)] #[no_mangle] pub fn test_83_886_095() { delay_cycles::<83_886_095>(); } |
| 123 | +#[inline(never)] #[no_mangle] pub fn test_25_769_803_778() { delay_cycles::<25_769_803_778>(); } |
| 124 | +#[inline(never)] #[no_mangle] pub fn test_25_769_803_779() { delay_cycles::<25_769_803_779>(); } |
| 125 | +#[inline(never)] #[no_mangle] pub fn test_25_769_803_780() { delay_cycles::<25_769_803_780>(); } |
| 126 | +#[inline(never)] #[no_mangle] pub fn test_25_769_803_783() { delay_cycles::<25_769_803_783>(); } |
| 127 | +#[inline(never)] #[no_mangle] pub fn test_25_769_803_784() { delay_cycles::<25_769_803_784>(); } |
| 128 | + |
| 129 | +// This shouldn't compile, but we don't have static assertion yet. The code produced is still |
| 130 | +// correct. But it costs more than calling delay_cycles twice. |
| 131 | +#[inline(never)] #[no_mangle] pub fn test_25_769_803_785_bad() { delay_cycles::<25_769_803_785>(); } |
| 132 | + |
| 133 | +// This shouldn't compile, but we don't have static assertion yet. The code produced is still |
| 134 | +// correct. But it costs more than calling delay_cycles twice. |
| 135 | +#[inline(never)] #[no_mangle] pub fn test_25_853_952_778_bad() { delay_cycles::<25_853_952_778>(); } |
| 136 | + |
| 137 | +// This shouldn't compile, but we don't have static assertion yet. The code produced is still |
| 138 | +// correct. But it costs more than calling delay_cycles twice. This is the absolute limit. |
| 139 | +#[inline(never)] #[no_mangle] pub fn test_25_853_952_779_bad() { delay_cycles::<25_853_952_779>(); } |
| 140 | + |
| 141 | +// This shouldn't compile, but we don't have static assertion yet. This does overflow and should |
| 142 | +// produces the same function as 25_769_803_778. |
| 143 | +#[inline(never)] #[no_mangle] pub fn test_25_853_952_780_overflow() { delay_cycles::<25_853_952_780>(); } |
0 commit comments