add comments
parent
76102d28a4
commit
24daab9c17
14
src/main.rs
14
src/main.rs
|
@ -5,16 +5,30 @@
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
use core::ptr::{read_volatile, write_volatile};
|
use core::ptr::{read_volatile, write_volatile};
|
||||||
|
|
||||||
|
/*
|
||||||
|
PORTC{0..5} Analog
|
||||||
|
PORTC6 Reset
|
||||||
|
|
||||||
|
PORTB{0..5} Digital {8..13}
|
||||||
|
PORTD{0..7} Digital {0..7}
|
||||||
|
|
||||||
|
PORTB5 LED_BUILTIN
|
||||||
|
*/
|
||||||
|
|
||||||
const DDRB: *mut u8 = 0x24 as *mut u8;
|
const DDRB: *mut u8 = 0x24 as *mut u8;
|
||||||
const PORTB: *mut u8 = 0x25 as *mut u8;
|
const PORTB: *mut u8 = 0x25 as *mut u8;
|
||||||
|
|
||||||
|
// ATmega328p cycle speed
|
||||||
const CPU_SPEED: u32 = 16_000_000;
|
const CPU_SPEED: u32 = 16_000_000;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn main() -> ! {
|
pub extern "C" fn main() -> ! {
|
||||||
|
// Set all the B pins on OUTPUT mode
|
||||||
unsafe { write_volatile(DDRB, 0b11111111) };
|
unsafe { write_volatile(DDRB, 0b11111111) };
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
// if pin[5] == 1: 1^1 = 0
|
||||||
|
// if pin[5] == 0: 0^1 = 1
|
||||||
let mut portb_value = unsafe { read_volatile(PORTB) };
|
let mut portb_value = unsafe { read_volatile(PORTB) };
|
||||||
portb_value = portb_value ^ (1 << 5);
|
portb_value = portb_value ^ (1 << 5);
|
||||||
unsafe { write_volatile(PORTB, portb_value) };
|
unsafe { write_volatile(PORTB, portb_value) };
|
||||||
|
|
Loading…
Reference in New Issue