3 ms·
> Which is throughly incorrect. Of course you can set the state of an output register that’s set to input, that state will just not appear on the pin. The cont
by KMag 9y ago
> Which is throughly incorrect. Of course you can set the state of an output register that’s set to input, that state will just not appear on the pin.
The context is Rust, where the statement is clearly correct. One can't call a function if the Rust compiler refuses to generate the binary. The author probably should have used a period between the first and second independent clauses and a semicolon between the second and third in order to show the close relations ship between being unable to call the function and it being a compile error.
- foldr 9y agoThe OP means that this is an incorrect model of the microcontroller.
- KMag 9y agoMy point was that the OP's objection would be valid if the statement being objected to were about architectural limitations of the hardware. However, the statement being objected to was under the section about the 3rd level of abstraction: "The Embedded HAL to the Rescue", which is detailing an extra semantic restriction imposed by Rust. The final two sentences of section 2 even allude to the prevented actions being legal but almost certainly being a logic error. To object that the hardware allows nonsensical actions without trapping is to miss the point of section 3 of the article. At the third level of abstraction: Rust prevents something legal but nonsensical. Now, if this particular board doesn't clear output state when switching a GPIO pin from input to output, then it's a valid criticism that perhaps the developer wants to set the output state correctly before driving the pin and the prevented action is in fact semantically meaningful and perhaps the intent of the developer. However, that wasn't the OP's objection. The OP's objection was simply that Rust was preventing something that the underlying platform allows.
- foldr 9y agoNo, I just mean that you misunderstood what the OP was calling "incorrect". They weren't saying that it's incorrect that a compile time error is triggered in the situation described.
- KMag 9y agoI understand that the OP was calling the model of the microcontroller incorrect. To recap: The article said "Rust doesn't allow you to do X" The OP said "Wrong!!!! The mocrocontoller totally allows you to do X" I pointed out that the article never said the microcontroller doesn't allow X.