Git Product home page Git Product logo

Comments (3)

japaric avatar japaric commented on September 28, 2024

to write a single data frame, but at that point, one may as well be using C. :)

Or you could write an extension trait implement it on the register type and then be able to write: spi.dr.write_u8(0xaa).

The proper way to fix this in the SVD file is to use overloaded registers. Basically you declare two registers at the same address in the SVD file and then svd2rust gives you an API to use the register as one variant or the other so would be able to write spi.dr8.write(0xaa) or spi.dr16.write(0xaaaa). Or least that how it should work; svd2rust doesn't currently know how to handle "overloaded registers" so it just emits API for one of the registers.

Yet another way would be to extend the register API generated by svd2rust to provide methods to directly write to the upper / lower half-word / byte. But that method would be unsafe by default as the register may have "meaning" (configuration register) instead of just being a data register. Perhaps there can be some mechanism to opt into safety; for example the bits method becomes safe when <writeConstraint> in the SVD file says that the whole range is safe to use.

from stm32f30x.

hydra avatar hydra commented on September 28, 2024

any solution to this yet? AFAIK this is still a problem and in recent rust nightlies the workaround above results in compilation failures:

error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell`

from stm32f30x.

hydra avatar hydra commented on September 28, 2024

Also related: stm32-rs/stm32-rs#755

from stm32f30x.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.