~ruther/avr-device

ref: 38126f08ee554f40fe34a1e4d8948f53c5840899 avr-device/gen-intr-lut.sh -rwxr-xr-x 686 bytes
38126f08 — Adam Gausmann Add support for ATtiny404 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