Comments (3)
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.
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.
Also related: stm32-rs/stm32-rs#755
from stm32f30x.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stm32f30x.