File tree Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Original file line number Diff line number Diff line change 22 "swiftPM" : {
33 "configuration" : " release" ,
44 "triple" : " armv7em-none-none-eabi" ,
5-
6- "__comment" : " XXX SourceKit-LSP seems to ignore the toolset (relative or absolute path)..." ,
7- "toolset" : " .../toolset.json" ,
8-
5+ "toolsets" : [" toolset.json" ],
96 "swiftCompilerFlags" : [
107 " -enable-experimental-feature" , " Embedded" ,
11- " -enable-experimental-feature" , " Extern" ,
8+ " -enable-experimental-feature" , " Extern"
129 ]
1310 }
1411}
Original file line number Diff line number Diff line change @@ -273,6 +273,13 @@ extension UInt64 {
273273 }
274274}
275275
276+ func log2_exact( _ val: UInt32 ) -> UInt32 {
277+ guard val. nonzeroBitCount == 1 else {
278+ preconditionFailure ( " Value \( val) is not a power of 2 " )
279+ }
280+ return UInt32 ( val. trailingZeroBitCount)
281+ }
282+
276283extension Main {
277284 static func setPrescalers( _ prescalers: ( hpre: UInt32 , ppre1: UInt32 , ppre2: UInt32 ) ) {
278285 let log2_ahb : UInt32 = log2_exact ( prescalers. hpre)
Original file line number Diff line number Diff line change @@ -41,12 +41,3 @@ static inline void delay(uint32_t i) {
4141 : "cc"
4242 );
4343}
44-
45- void panic (const char * );
46-
47- static uint32_t log2_exact (uint32_t value ) {
48- if ((value == 0 ) || (__builtin_popcount (value ) != 1 )) {
49- panic ("log2_exact" );
50- }
51- return 31U - __builtin_clz (value );
52- }
You can’t perform that action at this time.
0 commit comments