~ruther/avr-device

ref: b0abe893ed36425cfd63bbe5a9d0881bcee053cb avr-device/gen-intr-lut.sh -rwxr-xr-x 619 bytes
b0abe893 — Andrew Dona-Couch Add support for ATtiny88 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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 "$(dirname "$intr_path")")"
    echo "        \"$chip\" => match intr {"

    sed '/=> Ok(Interrupt::.\+),$/!d
    s/ \+\(.\+\) => Ok(Interrupt::\(.\+\)),$/            "\2" => Some(\1),/' "$intr_path"

    echo "            _ => None,"
    echo "        },"
done

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