diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-05-11 01:38:33 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-11 01:38:33 +0200 |
| commit | 4705333b5e7b54ee2e14fb4f9741c95edb8bb76a (patch) | |
| tree | 3ac40e1f52a0ed3981d2983074fafe70563548e6 | |
| parent | 65b78119dc61952dc7eb9dbea2b9d2fd4abf3b4d (diff) | |
| parent | e0809ab0fb64ff71be23e2d041d4fbae67dca234 (diff) | |
Merge pull request #173 from embassy-rs/priority
PriorityX enums
| -rw-r--r-- | embassy-extras/src/interrupt.rs | 571 | ||||
| -rw-r--r-- | embassy-extras/src/lib.rs | 1 | ||||
| -rw-r--r-- | embassy-nrf-examples/src/bin/multiprio.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/interrupt.rs | 41 | ||||
| -rw-r--r-- | embassy-rp/src/interrupt.rs | 41 | ||||
| -rw-r--r-- | embassy-stm32-examples/src/bin/usb_serial.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/interrupt.rs | 57 |
7 files changed, 578 insertions, 139 deletions
diff --git a/embassy-extras/src/interrupt.rs b/embassy-extras/src/interrupt.rs new file mode 100644 index 000000000..80b2cad5d --- /dev/null +++ b/embassy-extras/src/interrupt.rs | |||
| @@ -0,0 +1,571 @@ | |||
| 1 | use core::mem; | ||
| 2 | |||
| 3 | macro_rules! prio { | ||
| 4 | ($name:ident, $mask:expr, ($($k:ident = $v:expr,)*)) => { | ||
| 5 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 6 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 7 | #[repr(u8)] | ||
| 8 | pub enum $name { | ||
| 9 | $($k = $v),* | ||
| 10 | } | ||
| 11 | |||
| 12 | impl From<u8> for $name { | ||
| 13 | fn from(priority: u8) -> Self { | ||
| 14 | unsafe { mem::transmute(priority & $mask) } | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | impl From<$name> for u8 { | ||
| 19 | fn from(p: $name) -> Self { | ||
| 20 | p as u8 | ||
| 21 | } | ||
| 22 | } | ||
| 23 | }; | ||
| 24 | } | ||
| 25 | |||
| 26 | #[rustfmt::skip] | ||
| 27 | prio!(Priority0, 0x00, ( | ||
| 28 | P0 = 0x0, | ||
| 29 | )); | ||
| 30 | |||
| 31 | #[rustfmt::skip] | ||
| 32 | prio!(Priority1, 0x80, ( | ||
| 33 | P0 = 0x0, | ||
| 34 | P1 = 0x80, | ||
| 35 | )); | ||
| 36 | |||
| 37 | #[rustfmt::skip] | ||
| 38 | prio!(Priority2, 0xc0, ( | ||
| 39 | P0 = 0x0, | ||
| 40 | P1 = 0x40, | ||
| 41 | P2 = 0x80, | ||
| 42 | P3 = 0xc0, | ||
| 43 | )); | ||
| 44 | |||
| 45 | #[rustfmt::skip] | ||
| 46 | prio!(Priority3, 0xe0, ( | ||
| 47 | P0 = 0x0, | ||
| 48 | P1 = 0x20, | ||
| 49 | P2 = 0x40, | ||
| 50 | P3 = 0x60, | ||
| 51 | P4 = 0x80, | ||
| 52 | P5 = 0xa0, | ||
| 53 | P6 = 0xc0, | ||
| 54 | P7 = 0xe0, | ||
| 55 | )); | ||
| 56 | |||
| 57 | #[rustfmt::skip] | ||
| 58 | prio!(Priority4, 0xf0, ( | ||
| 59 | P0 = 0x0, | ||
| 60 | P1 = 0x10, | ||
| 61 | P2 = 0x20, | ||
| 62 | P3 = 0x30, | ||
| 63 | P4 = 0x40, | ||
| 64 | P5 = 0x50, | ||
| 65 | P6 = 0x60, | ||
| 66 | P7 = 0x70, | ||
| 67 | P8 = 0x80, | ||
| 68 | P9 = 0x90, | ||
| 69 | P10 = 0xa0, | ||
| 70 | P11 = 0xb0, | ||
| 71 | P12 = 0xc0, | ||
| 72 | P13 = 0xd0, | ||
| 73 | P14 = 0xe0, | ||
| 74 | P15 = 0xf0, | ||
| 75 | )); | ||
| 76 | |||
| 77 | #[rustfmt::skip] | ||
| 78 | prio!(Priority5, 0xf8, ( | ||
| 79 | P0 = 0x0, | ||
| 80 | P1 = 0x8, | ||
| 81 | P2 = 0x10, | ||
| 82 | P3 = 0x18, | ||
| 83 | P4 = 0x20, | ||
| 84 | P5 = 0x28, | ||
| 85 | P6 = 0x30, | ||
| 86 | P7 = 0x38, | ||
| 87 | P8 = 0x40, | ||
| 88 | P9 = 0x48, | ||
| 89 | P10 = 0x50, | ||
| 90 | P11 = 0x58, | ||
| 91 | P12 = 0x60, | ||
| 92 | P13 = 0x68, | ||
| 93 | P14 = 0x70, | ||
| 94 | P15 = 0x78, | ||
| 95 | P16 = 0x80, | ||
| 96 | P17 = 0x88, | ||
| 97 | P18 = 0x90, | ||
| 98 | P19 = 0x98, | ||
| 99 | P20 = 0xa0, | ||
| 100 | P21 = 0xa8, | ||
| 101 | P22 = 0xb0, | ||
| 102 | P23 = 0xb8, | ||
| 103 | P24 = 0xc0, | ||
| 104 | P25 = 0xc8, | ||
| 105 | P26 = 0xd0, | ||
| 106 | P27 = 0xd8, | ||
| 107 | P28 = 0xe0, | ||
| 108 | P29 = 0xe8, | ||
| 109 | P30 = 0xf0, | ||
| 110 | P31 = 0xf8, | ||
| 111 | )); | ||
| 112 | |||
| 113 | #[rustfmt::skip] | ||
| 114 | prio!(Priority6, 0xfc, ( | ||
| 115 | P0 = 0x0, | ||
| 116 | P1 = 0x4, | ||
| 117 | P2 = 0x8, | ||
| 118 | P3 = 0xc, | ||
| 119 | P4 = 0x10, | ||
| 120 | P5 = 0x14, | ||
| 121 | P6 = 0x18, | ||
| 122 | P7 = 0x1c, | ||
| 123 | P8 = 0x20, | ||
| 124 | P9 = 0x24, | ||
| 125 | P10 = 0x28, | ||
| 126 | P11 = 0x2c, | ||
| 127 | P12 = 0x30, | ||
| 128 | P13 = 0x34, | ||
| 129 | P14 = 0x38, | ||
| 130 | P15 = 0x3c, | ||
| 131 | P16 = 0x40, | ||
| 132 | P17 = 0x44, | ||
| 133 | P18 = 0x48, | ||
| 134 | P19 = 0x4c, | ||
| 135 | P20 = 0x50, | ||
| 136 | P21 = 0x54, | ||
| 137 | P22 = 0x58, | ||
| 138 | P23 = 0x5c, | ||
| 139 | P24 = 0x60, | ||
| 140 | P25 = 0x64, | ||
| 141 | P26 = 0x68, | ||
| 142 | P27 = 0x6c, | ||
| 143 | P28 = 0x70, | ||
| 144 | P29 = 0x74, | ||
| 145 | P30 = 0x78, | ||
| 146 | P31 = 0x7c, | ||
| 147 | P32 = 0x80, | ||
| 148 | P33 = 0x84, | ||
| 149 | P34 = 0x88, | ||
| 150 | P35 = 0x8c, | ||
| 151 | P36 = 0x90, | ||
| 152 | P37 = 0x94, | ||
| 153 | P38 = 0x98, | ||
| 154 | P39 = 0x9c, | ||
| 155 | P40 = 0xa0, | ||
| 156 | P41 = 0xa4, | ||
| 157 | P42 = 0xa8, | ||
| 158 | P43 = 0xac, | ||
| 159 | P44 = 0xb0, | ||
| 160 | P45 = 0xb4, | ||
| 161 | P46 = 0xb8, | ||
| 162 | P47 = 0xbc, | ||
| 163 | P48 = 0xc0, | ||
| 164 | P49 = 0xc4, | ||
| 165 | P50 = 0xc8, | ||
| 166 | P51 = 0xcc, | ||
| 167 | P52 = 0xd0, | ||
| 168 | P53 = 0xd4, | ||
| 169 | P54 = 0xd8, | ||
| 170 | P55 = 0xdc, | ||
| 171 | P56 = 0xe0, | ||
| 172 | P57 = 0xe4, | ||
| 173 | P58 = 0xe8, | ||
| 174 | P59 = 0xec, | ||
| 175 | P60 = 0xf0, | ||
| 176 | P61 = 0xf4, | ||
| 177 | P62 = 0xf8, | ||
| 178 | P63 = 0xfc, | ||
| 179 | )); | ||
| 180 | |||
| 181 | #[rustfmt::skip] | ||
| 182 | prio!(Priority7, 0xfe, ( | ||
| 183 | P0 = 0x0, | ||
| 184 | P1 = 0x2, | ||
| 185 | P2 = 0x4, | ||
| 186 | P3 = 0x6, | ||
| 187 | P4 = 0x8, | ||
| 188 | P5 = 0xa, | ||
| 189 | P6 = 0xc, | ||
| 190 | P7 = 0xe, | ||
| 191 | P8 = 0x10, | ||
| 192 | P9 = 0x12, | ||
| 193 | P10 = 0x14, | ||
| 194 | P11 = 0x16, | ||
| 195 | P12 = 0x18, | ||
| 196 | P13 = 0x1a, | ||
| 197 | P14 = 0x1c, | ||
| 198 | P15 = 0x1e, | ||
| 199 | P16 = 0x20, | ||
| 200 | P17 = 0x22, | ||
| 201 | P18 = 0x24, | ||
| 202 | P19 = 0x26, | ||
| 203 | P20 = 0x28, | ||
| 204 | P21 = 0x2a, | ||
| 205 | P22 = 0x2c, | ||
| 206 | P23 = 0x2e, | ||
| 207 | P24 = 0x30, | ||
| 208 | P25 = 0x32, | ||
| 209 | P26 = 0x34, | ||
| 210 | P27 = 0x36, | ||
| 211 | P28 = 0x38, | ||
| 212 | P29 = 0x3a, | ||
| 213 | P30 = 0x3c, | ||
| 214 | P31 = 0x3e, | ||
| 215 | P32 = 0x40, | ||
| 216 | P33 = 0x42, | ||
| 217 | P34 = 0x44, | ||
| 218 | P35 = 0x46, | ||
| 219 | P36 = 0x48, | ||
| 220 | P37 = 0x4a, | ||
| 221 | P38 = 0x4c, | ||
| 222 | P39 = 0x4e, | ||
| 223 | P40 = 0x50, | ||
| 224 | P41 = 0x52, | ||
| 225 | P42 = 0x54, | ||
| 226 | P43 = 0x56, | ||
| 227 | P44 = 0x58, | ||
| 228 | P45 = 0x5a, | ||
| 229 | P46 = 0x5c, | ||
| 230 | P47 = 0x5e, | ||
| 231 | P48 = 0x60, | ||
| 232 | P49 = 0x62, | ||
| 233 | P50 = 0x64, | ||
| 234 | P51 = 0x66, | ||
| 235 | P52 = 0x68, | ||
| 236 | P53 = 0x6a, | ||
| 237 | P54 = 0x6c, | ||
| 238 | P55 = 0x6e, | ||
| 239 | P56 = 0x70, | ||
| 240 | P57 = 0x72, | ||
| 241 | P58 = 0x74, | ||
| 242 | P59 = 0x76, | ||
| 243 | P60 = 0x78, | ||
| 244 | P61 = 0x7a, | ||
| 245 | P62 = 0x7c, | ||
| 246 | P63 = 0x7e, | ||
| 247 | P64 = 0x80, | ||
| 248 | P65 = 0x82, | ||
| 249 | P66 = 0x84, | ||
| 250 | P67 = 0x86, | ||
| 251 | P68 = 0x88, | ||
| 252 | P69 = 0x8a, | ||
| 253 | P70 = 0x8c, | ||
| 254 | P71 = 0x8e, | ||
| 255 | P72 = 0x90, | ||
| 256 | P73 = 0x92, | ||
| 257 | P74 = 0x94, | ||
| 258 | P75 = 0x96, | ||
| 259 | P76 = 0x98, | ||
| 260 | P77 = 0x9a, | ||
| 261 | P78 = 0x9c, | ||
| 262 | P79 = 0x9e, | ||
| 263 | P80 = 0xa0, | ||
| 264 | P81 = 0xa2, | ||
| 265 | P82 = 0xa4, | ||
| 266 | P83 = 0xa6, | ||
| 267 | P84 = 0xa8, | ||
| 268 | P85 = 0xaa, | ||
| 269 | P86 = 0xac, | ||
| 270 | P87 = 0xae, | ||
| 271 | P88 = 0xb0, | ||
| 272 | P89 = 0xb2, | ||
| 273 | P90 = 0xb4, | ||
| 274 | P91 = 0xb6, | ||
| 275 | P92 = 0xb8, | ||
| 276 | P93 = 0xba, | ||
| 277 | P94 = 0xbc, | ||
| 278 | P95 = 0xbe, | ||
| 279 | P96 = 0xc0, | ||
| 280 | P97 = 0xc2, | ||
| 281 | P98 = 0xc4, | ||
| 282 | P99 = 0xc6, | ||
| 283 | P100 = 0xc8, | ||
| 284 | P101 = 0xca, | ||
| 285 | P102 = 0xcc, | ||
| 286 | P103 = 0xce, | ||
| 287 | P104 = 0xd0, | ||
| 288 | P105 = 0xd2, | ||
| 289 | P106 = 0xd4, | ||
| 290 | P107 = 0xd6, | ||
| 291 | P108 = 0xd8, | ||
| 292 | P109 = 0xda, | ||
| 293 | P110 = 0xdc, | ||
| 294 | P111 = 0xde, | ||
| 295 | P112 = 0xe0, | ||
| 296 | P113 = 0xe2, | ||
| 297 | P114 = 0xe4, | ||
| 298 | P115 = 0xe6, | ||
| 299 | P116 = 0xe8, | ||
| 300 | P117 = 0xea, | ||
| 301 | P118 = 0xec, | ||
| 302 | P119 = 0xee, | ||
| 303 | P120 = 0xf0, | ||
| 304 | P121 = 0xf2, | ||
| 305 | P122 = 0xf4, | ||
| 306 | P123 = 0xf6, | ||
| 307 | P124 = 0xf8, | ||
| 308 | P125 = 0xfa, | ||
| 309 | P126 = 0xfc, | ||
| 310 | P127 = 0xfe, | ||
| 311 | )); | ||
| 312 | |||
| 313 | #[rustfmt::skip] | ||
| 314 | prio!(Priority8, 0xff, ( | ||
| 315 | P0 = 0x0, | ||
| 316 | P1 = 0x1, | ||
| 317 | P2 = 0x2, | ||
| 318 | P3 = 0x3, | ||
| 319 | P4 = 0x4, | ||
| 320 | P5 = 0x5, | ||
| 321 | P6 = 0x6, | ||
| 322 | P7 = 0x7, | ||
| 323 | P8 = 0x8, | ||
| 324 | P9 = 0x9, | ||
| 325 | P10 = 0xa, | ||
| 326 | P11 = 0xb, | ||
| 327 | P12 = 0xc, | ||
| 328 | P13 = 0xd, | ||
| 329 | P14 = 0xe, | ||
| 330 | P15 = 0xf, | ||
| 331 | P16 = 0x10, | ||
| 332 | P17 = 0x11, | ||
| 333 | P18 = 0x12, | ||
| 334 | P19 = 0x13, | ||
| 335 | P20 = 0x14, | ||
| 336 | P21 = 0x15, | ||
| 337 | P22 = 0x16, | ||
| 338 | P23 = 0x17, | ||
| 339 | P24 = 0x18, | ||
| 340 | P25 = 0x19, | ||
| 341 | P26 = 0x1a, | ||
| 342 | P27 = 0x1b, | ||
| 343 | P28 = 0x1c, | ||
| 344 | P29 = 0x1d, | ||
| 345 | P30 = 0x1e, | ||
| 346 | P31 = 0x1f, | ||
| 347 | P32 = 0x20, | ||
| 348 | P33 = 0x21, | ||
| 349 | P34 = 0x22, | ||
| 350 | P35 = 0x23, | ||
| 351 | P36 = 0x24, | ||
| 352 | P37 = 0x25, | ||
| 353 | P38 = 0x26, | ||
| 354 | P39 = 0x27, | ||
| 355 | P40 = 0x28, | ||
| 356 | P41 = 0x29, | ||
| 357 | P42 = 0x2a, | ||
| 358 | P43 = 0x2b, | ||
| 359 | P44 = 0x2c, | ||
| 360 | P45 = 0x2d, | ||
| 361 | P46 = 0x2e, | ||
| 362 | P47 = 0x2f, | ||
| 363 | P48 = 0x30, | ||
| 364 | P49 = 0x31, | ||
| 365 | P50 = 0x32, | ||
| 366 | P51 = 0x33, | ||
| 367 | P52 = 0x34, | ||
| 368 | P53 = 0x35, | ||
| 369 | P54 = 0x36, | ||
| 370 | P55 = 0x37, | ||
| 371 | P56 = 0x38, | ||
| 372 | P57 = 0x39, | ||
| 373 | P58 = 0x3a, | ||
| 374 | P59 = 0x3b, | ||
| 375 | P60 = 0x3c, | ||
| 376 | P61 = 0x3d, | ||
| 377 | P62 = 0x3e, | ||
| 378 | P63 = 0x3f, | ||
| 379 | P64 = 0x40, | ||
| 380 | P65 = 0x41, | ||
| 381 | P66 = 0x42, | ||
| 382 | P67 = 0x43, | ||
| 383 | P68 = 0x44, | ||
| 384 | P69 = 0x45, | ||
| 385 | P70 = 0x46, | ||
| 386 | P71 = 0x47, | ||
| 387 | P72 = 0x48, | ||
| 388 | P73 = 0x49, | ||
| 389 | P74 = 0x4a, | ||
| 390 | P75 = 0x4b, | ||
| 391 | P76 = 0x4c, | ||
| 392 | P77 = 0x4d, | ||
| 393 | P78 = 0x4e, | ||
| 394 | P79 = 0x4f, | ||
| 395 | P80 = 0x50, | ||
| 396 | P81 = 0x51, | ||
| 397 | P82 = 0x52, | ||
| 398 | P83 = 0x53, | ||
| 399 | P84 = 0x54, | ||
| 400 | P85 = 0x55, | ||
| 401 | P86 = 0x56, | ||
| 402 | P87 = 0x57, | ||
| 403 | P88 = 0x58, | ||
| 404 | P89 = 0x59, | ||
| 405 | P90 = 0x5a, | ||
| 406 | P91 = 0x5b, | ||
| 407 | P92 = 0x5c, | ||
| 408 | P93 = 0x5d, | ||
| 409 | P94 = 0x5e, | ||
| 410 | P95 = 0x5f, | ||
| 411 | P96 = 0x60, | ||
| 412 | P97 = 0x61, | ||
| 413 | P98 = 0x62, | ||
| 414 | P99 = 0x63, | ||
| 415 | P100 = 0x64, | ||
| 416 | P101 = 0x65, | ||
| 417 | P102 = 0x66, | ||
| 418 | P103 = 0x67, | ||
| 419 | P104 = 0x68, | ||
| 420 | P105 = 0x69, | ||
| 421 | P106 = 0x6a, | ||
| 422 | P107 = 0x6b, | ||
| 423 | P108 = 0x6c, | ||
| 424 | P109 = 0x6d, | ||
| 425 | P110 = 0x6e, | ||
| 426 | P111 = 0x6f, | ||
| 427 | P112 = 0x70, | ||
| 428 | P113 = 0x71, | ||
| 429 | P114 = 0x72, | ||
| 430 | P115 = 0x73, | ||
| 431 | P116 = 0x74, | ||
| 432 | P117 = 0x75, | ||
| 433 | P118 = 0x76, | ||
| 434 | P119 = 0x77, | ||
| 435 | P120 = 0x78, | ||
| 436 | P121 = 0x79, | ||
| 437 | P122 = 0x7a, | ||
| 438 | P123 = 0x7b, | ||
| 439 | P124 = 0x7c, | ||
| 440 | P125 = 0x7d, | ||
| 441 | P126 = 0x7e, | ||
| 442 | P127 = 0x7f, | ||
| 443 | P128 = 0x80, | ||
| 444 | P129 = 0x81, | ||
| 445 | P130 = 0x82, | ||
| 446 | P131 = 0x83, | ||
| 447 | P132 = 0x84, | ||
| 448 | P133 = 0x85, | ||
| 449 | P134 = 0x86, | ||
| 450 | P135 = 0x87, | ||
| 451 | P136 = 0x88, | ||
| 452 | P137 = 0x89, | ||
| 453 | P138 = 0x8a, | ||
| 454 | P139 = 0x8b, | ||
| 455 | P140 = 0x8c, | ||
| 456 | P141 = 0x8d, | ||
| 457 | P142 = 0x8e, | ||
| 458 | P143 = 0x8f, | ||
| 459 | P144 = 0x90, | ||
| 460 | P145 = 0x91, | ||
| 461 | P146 = 0x92, | ||
| 462 | P147 = 0x93, | ||
| 463 | P148 = 0x94, | ||
| 464 | P149 = 0x95, | ||
| 465 | P150 = 0x96, | ||
| 466 | P151 = 0x97, | ||
| 467 | P152 = 0x98, | ||
| 468 | P153 = 0x99, | ||
| 469 | P154 = 0x9a, | ||
| 470 | P155 = 0x9b, | ||
| 471 | P156 = 0x9c, | ||
| 472 | P157 = 0x9d, | ||
| 473 | P158 = 0x9e, | ||
| 474 | P159 = 0x9f, | ||
| 475 | P160 = 0xa0, | ||
| 476 | P161 = 0xa1, | ||
| 477 | P162 = 0xa2, | ||
| 478 | P163 = 0xa3, | ||
| 479 | P164 = 0xa4, | ||
| 480 | P165 = 0xa5, | ||
| 481 | P166 = 0xa6, | ||
| 482 | P167 = 0xa7, | ||
| 483 | P168 = 0xa8, | ||
| 484 | P169 = 0xa9, | ||
| 485 | P170 = 0xaa, | ||
| 486 | P171 = 0xab, | ||
| 487 | P172 = 0xac, | ||
| 488 | P173 = 0xad, | ||
| 489 | P174 = 0xae, | ||
| 490 | P175 = 0xaf, | ||
| 491 | P176 = 0xb0, | ||
| 492 | P177 = 0xb1, | ||
| 493 | P178 = 0xb2, | ||
| 494 | P179 = 0xb3, | ||
| 495 | P180 = 0xb4, | ||
| 496 | P181 = 0xb5, | ||
| 497 | P182 = 0xb6, | ||
| 498 | P183 = 0xb7, | ||
| 499 | P184 = 0xb8, | ||
| 500 | P185 = 0xb9, | ||
| 501 | P186 = 0xba, | ||
| 502 | P187 = 0xbb, | ||
| 503 | P188 = 0xbc, | ||
| 504 | P189 = 0xbd, | ||
| 505 | P190 = 0xbe, | ||
| 506 | P191 = 0xbf, | ||
| 507 | P192 = 0xc0, | ||
| 508 | P193 = 0xc1, | ||
| 509 | P194 = 0xc2, | ||
| 510 | P195 = 0xc3, | ||
| 511 | P196 = 0xc4, | ||
| 512 | P197 = 0xc5, | ||
| 513 | P198 = 0xc6, | ||
| 514 | P199 = 0xc7, | ||
| 515 | P200 = 0xc8, | ||
| 516 | P201 = 0xc9, | ||
| 517 | P202 = 0xca, | ||
| 518 | P203 = 0xcb, | ||
| 519 | P204 = 0xcc, | ||
| 520 | P205 = 0xcd, | ||
| 521 | P206 = 0xce, | ||
| 522 | P207 = 0xcf, | ||
| 523 | P208 = 0xd0, | ||
| 524 | P209 = 0xd1, | ||
| 525 | P210 = 0xd2, | ||
| 526 | P211 = 0xd3, | ||
| 527 | P212 = 0xd4, | ||
| 528 | P213 = 0xd5, | ||
| 529 | P214 = 0xd6, | ||
| 530 | P215 = 0xd7, | ||
| 531 | P216 = 0xd8, | ||
| 532 | P217 = 0xd9, | ||
| 533 | P218 = 0xda, | ||
| 534 | P219 = 0xdb, | ||
| 535 | P220 = 0xdc, | ||
| 536 | P221 = 0xdd, | ||
| 537 | P222 = 0xde, | ||
| 538 | P223 = 0xdf, | ||
| 539 | P224 = 0xe0, | ||
| 540 | P225 = 0xe1, | ||
| 541 | P226 = 0xe2, | ||
| 542 | P227 = 0xe3, | ||
| 543 | P228 = 0xe4, | ||
| 544 | P229 = 0xe5, | ||
| 545 | P230 = 0xe6, | ||
| 546 | P231 = 0xe7, | ||
| 547 | P232 = 0xe8, | ||
| 548 | P233 = 0xe9, | ||
| 549 | P234 = 0xea, | ||
| 550 | P235 = 0xeb, | ||
| 551 | P236 = 0xec, | ||
| 552 | P237 = 0xed, | ||
| 553 | P238 = 0xee, | ||
| 554 | P239 = 0xef, | ||
| 555 | P240 = 0xf0, | ||
| 556 | P241 = 0xf1, | ||
| 557 | P242 = 0xf2, | ||
| 558 | P243 = 0xf3, | ||
| 559 | P244 = 0xf4, | ||
| 560 | P245 = 0xf5, | ||
| 561 | P246 = 0xf6, | ||
| 562 | P247 = 0xf7, | ||
| 563 | P248 = 0xf8, | ||
| 564 | P249 = 0xf9, | ||
| 565 | P250 = 0xfa, | ||
| 566 | P251 = 0xfb, | ||
| 567 | P252 = 0xfc, | ||
| 568 | P253 = 0xfd, | ||
| 569 | P254 = 0xfe, | ||
| 570 | P255 = 0xff, | ||
| 571 | )); | ||
diff --git a/embassy-extras/src/lib.rs b/embassy-extras/src/lib.rs index be08ddf1e..7036986ef 100644 --- a/embassy-extras/src/lib.rs +++ b/embassy-extras/src/lib.rs | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // This mod MUST go first, so that the others see its macros. | 3 | // This mod MUST go first, so that the others see its macros. |
| 4 | pub(crate) mod fmt; | 4 | pub(crate) mod fmt; |
| 5 | 5 | ||
| 6 | pub mod interrupt; | ||
| 6 | mod macros; | 7 | mod macros; |
| 7 | pub mod peripheral; | 8 | pub mod peripheral; |
| 8 | pub mod peripheral_shared; | 9 | pub mod peripheral_shared; |
diff --git a/embassy-nrf-examples/src/bin/multiprio.rs b/embassy-nrf-examples/src/bin/multiprio.rs index c6228a1ea..9ed5c1368 100644 --- a/embassy-nrf-examples/src/bin/multiprio.rs +++ b/embassy-nrf-examples/src/bin/multiprio.rs | |||
| @@ -135,7 +135,7 @@ fn main() -> ! { | |||
| 135 | 135 | ||
| 136 | // High-priority executor: SWI1_EGU1, priority level 6 | 136 | // High-priority executor: SWI1_EGU1, priority level 6 |
| 137 | let irq = interrupt::take!(SWI1_EGU1); | 137 | let irq = interrupt::take!(SWI1_EGU1); |
| 138 | irq.set_priority(interrupt::Priority::Level6); | 138 | irq.set_priority(interrupt::Priority::P6); |
| 139 | let alarm = ALARM_HIGH.put(rtc.alarm2()); | 139 | let alarm = ALARM_HIGH.put(rtc.alarm2()); |
| 140 | let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); | 140 | let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq)); |
| 141 | executor.set_alarm(alarm); | 141 | executor.set_alarm(alarm); |
| @@ -145,7 +145,7 @@ fn main() -> ! { | |||
| 145 | 145 | ||
| 146 | // Medium-priority executor: SWI0_EGU0, priority level 7 | 146 | // Medium-priority executor: SWI0_EGU0, priority level 7 |
| 147 | let irq = interrupt::take!(SWI0_EGU0); | 147 | let irq = interrupt::take!(SWI0_EGU0); |
| 148 | irq.set_priority(interrupt::Priority::Level7); | 148 | irq.set_priority(interrupt::Priority::P7); |
| 149 | let alarm = ALARM_MED.put(rtc.alarm1()); | 149 | let alarm = ALARM_MED.put(rtc.alarm1()); |
| 150 | let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); | 150 | let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq)); |
| 151 | executor.set_alarm(alarm); | 151 | executor.set_alarm(alarm); |
diff --git a/embassy-nrf/src/interrupt.rs b/embassy-nrf/src/interrupt.rs index 8d069e329..a29861977 100644 --- a/embassy-nrf/src/interrupt.rs +++ b/embassy-nrf/src/interrupt.rs | |||
| @@ -3,48 +3,9 @@ | |||
| 3 | //! This module implements an API for managing interrupts compatible with | 3 | //! This module implements an API for managing interrupts compatible with |
| 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. | 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. |
| 5 | 5 | ||
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | ||
| 7 | |||
| 8 | use crate::pac::NVIC_PRIO_BITS; | ||
| 9 | |||
| 10 | // Re-exports | 6 | // Re-exports |
| 11 | pub use embassy::interrupt::{declare, take, Interrupt}; | 7 | pub use embassy::interrupt::{declare, take, Interrupt}; |
| 12 | 8 | pub use embassy_extras::interrupt::Priority3 as Priority; | |
| 13 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 14 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 15 | #[repr(u8)] | ||
| 16 | pub enum Priority { | ||
| 17 | Level0 = 0, | ||
| 18 | Level1 = 1, | ||
| 19 | Level2 = 2, | ||
| 20 | Level3 = 3, | ||
| 21 | Level4 = 4, | ||
| 22 | Level5 = 5, | ||
| 23 | Level6 = 6, | ||
| 24 | Level7 = 7, | ||
| 25 | } | ||
| 26 | |||
| 27 | impl From<u8> for Priority { | ||
| 28 | fn from(priority: u8) -> Self { | ||
| 29 | match priority >> (8 - NVIC_PRIO_BITS) { | ||
| 30 | 0 => Self::Level0, | ||
| 31 | 1 => Self::Level1, | ||
| 32 | 2 => Self::Level2, | ||
| 33 | 3 => Self::Level3, | ||
| 34 | 4 => Self::Level4, | ||
| 35 | 5 => Self::Level5, | ||
| 36 | 6 => Self::Level6, | ||
| 37 | 7 => Self::Level7, | ||
| 38 | _ => unreachable!(), | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | impl From<Priority> for u8 { | ||
| 44 | fn from(p: Priority) -> Self { | ||
| 45 | (p as u8) << (8 - NVIC_PRIO_BITS) | ||
| 46 | } | ||
| 47 | } | ||
| 48 | 9 | ||
| 49 | #[cfg(feature = "52810")] | 10 | #[cfg(feature = "52810")] |
| 50 | mod irqs { | 11 | mod irqs { |
diff --git a/embassy-rp/src/interrupt.rs b/embassy-rp/src/interrupt.rs index cb9f36546..262f7f546 100644 --- a/embassy-rp/src/interrupt.rs +++ b/embassy-rp/src/interrupt.rs | |||
| @@ -3,48 +3,9 @@ | |||
| 3 | //! This module implements an API for managing interrupts compatible with | 3 | //! This module implements an API for managing interrupts compatible with |
| 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. | 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. |
| 5 | 5 | ||
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | ||
| 7 | |||
| 8 | use crate::pac::NVIC_PRIO_BITS; | ||
| 9 | |||
| 10 | // Re-exports | 6 | // Re-exports |
| 11 | pub use embassy::interrupt::{declare, take, Interrupt}; | 7 | pub use embassy::interrupt::{declare, take, Interrupt}; |
| 12 | 8 | pub use embassy_extras::interrupt::Priority3 as Priority; | |
| 13 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 14 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 15 | #[repr(u8)] | ||
| 16 | pub enum Priority { | ||
| 17 | Level0 = 0, | ||
| 18 | Level1 = 1, | ||
| 19 | Level2 = 2, | ||
| 20 | Level3 = 3, | ||
| 21 | Level4 = 4, | ||
| 22 | Level5 = 5, | ||
| 23 | Level6 = 6, | ||
| 24 | Level7 = 7, | ||
| 25 | } | ||
| 26 | |||
| 27 | impl From<u8> for Priority { | ||
| 28 | fn from(priority: u8) -> Self { | ||
| 29 | match priority >> (8 - NVIC_PRIO_BITS) { | ||
| 30 | 0 => Self::Level0, | ||
| 31 | 1 => Self::Level1, | ||
| 32 | 2 => Self::Level2, | ||
| 33 | 3 => Self::Level3, | ||
| 34 | 4 => Self::Level4, | ||
| 35 | 5 => Self::Level5, | ||
| 36 | 6 => Self::Level6, | ||
| 37 | 7 => Self::Level7, | ||
| 38 | _ => unreachable!(), | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | |||
| 43 | impl From<Priority> for u8 { | ||
| 44 | fn from(p: Priority) -> Self { | ||
| 45 | (p as u8) << (8 - NVIC_PRIO_BITS) | ||
| 46 | } | ||
| 47 | } | ||
| 48 | 9 | ||
| 49 | mod irqs { | 10 | mod irqs { |
| 50 | use super::*; | 11 | use super::*; |
diff --git a/embassy-stm32-examples/src/bin/usb_serial.rs b/embassy-stm32-examples/src/bin/usb_serial.rs index e13275dd3..38656b979 100644 --- a/embassy-stm32-examples/src/bin/usb_serial.rs +++ b/embassy-stm32-examples/src/bin/usb_serial.rs | |||
| @@ -41,7 +41,7 @@ async fn run1(bus: &'static mut UsbBusAllocator<UsbBus<USB>>) { | |||
| 41 | .build(); | 41 | .build(); |
| 42 | 42 | ||
| 43 | let irq = interrupt::take!(OTG_FS); | 43 | let irq = interrupt::take!(OTG_FS); |
| 44 | irq.set_priority(interrupt::Priority::Level3); | 44 | irq.set_priority(interrupt::Priority::P3); |
| 45 | 45 | ||
| 46 | let usb = Usb::new(device, serial, irq); | 46 | let usb = Usb::new(device, serial, irq); |
| 47 | pin_mut!(usb); | 47 | pin_mut!(usb); |
diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index 1d48dc584..76dea28f6 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs | |||
| @@ -3,64 +3,9 @@ | |||
| 3 | //! This module implements an API for managing interrupts compatible with | 3 | //! This module implements an API for managing interrupts compatible with |
| 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. | 4 | //! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. |
| 5 | 5 | ||
| 6 | use core::sync::atomic::{compiler_fence, Ordering}; | ||
| 7 | |||
| 8 | use crate::pac::NVIC_PRIO_BITS; | ||
| 9 | |||
| 10 | // Re-exports | 6 | // Re-exports |
| 11 | pub use embassy::interrupt::{declare, take, Interrupt}; | 7 | pub use embassy::interrupt::{declare, take, Interrupt}; |
| 12 | 8 | pub use embassy_extras::interrupt::Priority4 as Priority; | |
| 13 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 14 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 15 | #[repr(u8)] | ||
| 16 | pub enum Priority { | ||
| 17 | Level0 = 0, | ||
| 18 | Level1 = 1, | ||
| 19 | Level2 = 2, | ||
| 20 | Level3 = 3, | ||
| 21 | Level4 = 4, | ||
| 22 | Level5 = 5, | ||
| 23 | Level6 = 6, | ||
| 24 | Level7 = 7, | ||
| 25 | Level8 = 8, | ||
| 26 | Level9 = 9, | ||
| 27 | Level10 = 10, | ||
| 28 | Level11 = 11, | ||
| 29 | Level12 = 12, | ||
| 30 | Level13 = 13, | ||
| 31 | Level14 = 14, | ||
| 32 | Level15 = 15, | ||
| 33 | } | ||
| 34 | |||
| 35 | impl From<u8> for Priority { | ||
| 36 | fn from(priority: u8) -> Self { | ||
| 37 | match priority >> (8 - NVIC_PRIO_BITS) { | ||
| 38 | 0 => Self::Level0, | ||
| 39 | 1 => Self::Level1, | ||
| 40 | 2 => Self::Level2, | ||
| 41 | 3 => Self::Level3, | ||
| 42 | 4 => Self::Level4, | ||
| 43 | 5 => Self::Level5, | ||
| 44 | 6 => Self::Level6, | ||
| 45 | 7 => Self::Level7, | ||
| 46 | 8 => Self::Level8, | ||
| 47 | 9 => Self::Level9, | ||
| 48 | 10 => Self::Level10, | ||
| 49 | 11 => Self::Level11, | ||
| 50 | 12 => Self::Level12, | ||
| 51 | 13 => Self::Level13, | ||
| 52 | 14 => Self::Level14, | ||
| 53 | 15 => Self::Level15, | ||
| 54 | _ => unreachable!(), | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | impl From<Priority> for u8 { | ||
| 60 | fn from(p: Priority) -> Self { | ||
| 61 | (p as u8) << (8 - NVIC_PRIO_BITS) | ||
| 62 | } | ||
| 63 | } | ||
| 64 | 9 | ||
| 65 | #[cfg(feature = "stm32f401")] | 10 | #[cfg(feature = "stm32f401")] |
| 66 | mod irqs { | 11 | mod irqs { |
