Skip to content
Snippets Groups Projects
Commit 17d6b71c authored by Anton's avatar Anton
Browse files

bare4_1

parent a6897afb
No related branches found
No related tags found
No related merge requests found
...@@ -58,22 +58,22 @@ const APP: () = { ...@@ -58,22 +58,22 @@ const APP: () = {
fn init(_cx: init::Context) { fn init(_cx: init::Context) {
// power on GPIOA // power on GPIOA
let r = read_u32(RCC_AHB1ENR); // read let r = read_u32(RCC_AHB1ENR); // read
write_u32(RCC_AHB1ENR, r | 1); // set enable write_u32(RCC_AHB1ENR, r | 1); // set enable GPIOAEN, IOPort A clock
// configure PA5 as output // configure PA5 as output
let r = read_u32(GPIOA_MODER) & !(0b11 << (5 * 2)); // read and mask let r = read_u32(GPIOA_MODER) & !(0b11 << (5 * 2)); // read and mask, keep all values except MODER5, MODER5 = 00.
write_u32(GPIOA_MODER, r | 0b01 << (5 * 2)); // set output mode write_u32(GPIOA_MODER, r | 0b01 << (5 * 2)); // set output mode, set MODER5 to 01 = general purpose output mode.
// and alter the data output through the BSRR register // and alter the data output through the BSRR register
// this is more efficient as the read register is not needed. // this is more efficient as the read register is not needed.
loop { loop {
// set PA5 high // set PA5 high
write_u32(GPIOA_BSRR, 1 << 5); // set bit, output hight (turn on led) write_u32(GPIOA_BSRR, 1 << 5); // set bit, output hight (turn on led), sets the 5:th ODRx bit
wait(10_000); wait(10_000);
// set PA5 low // set PA5 low
write_u32(GPIOA_BSRR, 1 << (5 + 16)); // clear bit, output low (turn off led) write_u32(GPIOA_BSRR, 1 << (5 + 16)); // clear bit, output low (turn off led), resets the 5:th ODRx bit
wait(10_000); wait(10_000);
} }
} }
...@@ -83,7 +83,7 @@ const APP: () = { ...@@ -83,7 +83,7 @@ const APP: () = {
// //
// 1. Did you enjoy the blinking? // 1. Did you enjoy the blinking?
// //
// ** your answer here ** // Yes, it is very nice.
// //
// Now lookup the data-sheets, and read each section referred, // Now lookup the data-sheets, and read each section referred,
// 6.3.11, 8.4.1, 8.4.7 // 6.3.11, 8.4.1, 8.4.7
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment