Calculate port number based on address and stride

This allows out of order letter to port mapping
This commit is contained in:
Ulf Lilleengen 2021-09-15 13:35:22 +02:00
parent 840a83e196
commit 701dd9fa36

View file

@ -415,8 +415,7 @@ pub fn gen(options: Options) {
match bi.module.as_str() {
"gpio" => {
let port_letter = name.chars().skip(4).next().unwrap();
let port_num = port_letter as u32 - 'A' as u32;
assert_eq!(p.address as u32, gpio_base + gpio_stride * port_num);
let port_num = (p.address as u32 - gpio_base) / gpio_stride;
for pin_num in 0..16 {
let pin_name = format!("P{}{}", port_letter, pin_num);