This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
****************************************************************************** | |
* @file main.c | |
* @author Auto-generated by STM32CubeIDE | |
* @version V1.0 | |
* @brief All addresses found in STM32f4 reference manual | |
****************************************************************************** | |
*/ | |
#include<stdint.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! calculate { | |
(eval $e:expr) => {{ | |
{ | |
let val: usize = $e; // Force types to be integers | |
println!("{} = {}", stringify!{$e}, val); | |
} | |
}}; | |
} | |
fn main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::ops::{Add, Mul, Sub}; | |
macro_rules! assert_equal_len { | |
// The `tt` (token tree) designator is used for | |
// operators and tokens. | |
($a:expr, $b:expr, $func:ident, $op:tt) => { | |
assert!($a.len() == $b.len(), | |
"{:?}: dimension mismatch: {:?} {:?} {:?}", | |
stringify!($func), | |
($a.len(),), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::prelude::*; | |
use std::net::TcpStream; | |
fn main() -> std::io::Result<()> { | |
let mut connection = TcpStream::connect("www.rustinaction.com:80")?; // We need to specify the port (80) explicitly, TcpStream does not know that this will become a HTTP request. | |
connection.write_all(b"GET / HTTP/1.0")?; // GET is the HTTP method, / is the resource we're attempting to access and HTTP/1.0 is the protocol version we're requesting. Why 1.0? It does not support "keep alive" requests, which will allow our stream to close without difficulty. | |
connection.write_all(b"\r\n")?; // In many networking protocols, \r\n is how a new lines | |
connection.write_all(b"Host: www.rustinaction.com")?; // The hostname provided on line 5 is actually discarded once it is converted to an IP address. The Host HTTP header allows the server to know which host we're connecting to.. | |
connection.write_all(b"\r\n\r\n")?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct CPU { | |
registers: [u8; 16], | |
position_in_memory: usize, | |
memory: [u8; 4096], | |
stack: [u16; 16], | |
stack_pointer: usize, | |
} | |
impl CPU { | |
fn run(&mut self) { |