diff --git a/CHANGELOG.md b/CHANGELOG.md index 02b0dd76..9af87bd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] - Fix `enumeratedValues` with `isDefault` only -- Generate unique identifier instead of `DEVICE_PERIPHERALS` to solve +- Remove `#[no_mangle]` attribute of `DEVICE_PERIPHERALS` to solve the link time issue when multiple devices used ## [v0.33.4] - 2024-06-16 diff --git a/src/generate/device.rs b/src/generate/device.rs index 8786d374..9a785602 100644 --- a/src/generate/device.rs +++ b/src/generate/device.rs @@ -1,8 +1,6 @@ use crate::svd::{array::names, Device, Peripheral}; use proc_macro2::{Span, TokenStream}; use quote::{quote, ToTokens}; -use regex::Regex; -use syn::Ident; use log::debug; use std::fs::File; @@ -272,22 +270,8 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result Result Option { critical_section::with(|_| { // SAFETY: We are in a critical section, so we have exclusive access - // to `#taken`. - if unsafe { #taken } { + // to `DEVICE_PERIPHERALS`. + if unsafe { DEVICE_PERIPHERALS } { return None } - // SAFETY: `#taken` is set to `true` by `Peripherals::steal`, + // SAFETY: `DEVICE_PERIPHERALS` is set to `true` by `Peripherals::steal`, // ensuring the peripherals can only be returned once. Some(unsafe { Peripherals::steal() }) }) @@ -320,7 +304,7 @@ pub fn render(d: &Device, config: &Config, device_x: &mut String) -> Result Self { - #taken = true; + DEVICE_PERIPHERALS = true; Peripherals { #exprs