~ruther/avr-device

ref: 1e37fc069fcf1789c9ccf211b039d933769d88d5 avr-device/gen-intr-lut.sh -rwxr-xr-x 686 bytes
1e37fc06 — Michael Buesch Update the bare-metal crate to 1.0.0 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash
# Generate a lookup table function for interrupts of all supported chips
set -e

echo     "// Autogenerated.  Do not edit."
echo     "pub fn lookup_vector(chip: &str, intr: &str) -> Option<usize> {"
echo     "    match chip {"

for intr_path in "$@"; do
    chip="$(basename "${intr_path%.svd.patched}")"
    echo "        \"$chip\" => match intr {"
    # toupper() to be compliant with svd2rust interrupts name
    svd interrupts --no-gaps $intr_path | awk '{print "            \""toupper(substr($2, 1, length($2)-1))"\"" " => Some(" $1"),"}'
    echo "            _ => None,"
    echo "        },"
done

echo     "        _ => None,"
echo     "    }"
echo     "}"
Do not follow this link