~ruther/avr-device

ref: 5162a8a230eee0714ddc1b4a981491235e2a89d0 avr-device/gen-intr-lut.sh -rwxr-xr-x 686 bytes
5162a8a2 — Rahix Update CHANGELOG 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