Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
buhe committed Oct 15, 2021
1 parent 0ae2cba commit 90cfcaf
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions os/src/driver/gpio/led.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use k210_soc::{

pub fn init() {
// led b 映射到 gpiohs 0
// io::LED_B 为物理 pin
fpioa::set_function(io::LED_B, fpioa::function::GPIOHS0);
// gpiohs 设置 0 为输出
gpiohs::set_direction(0, gpio::direction::OUTPUT);
Expand Down
24 changes: 23 additions & 1 deletion os/src/driver/gpio/led_ex.rs
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
// 外部的 led
// 外部的 led

use k210_soc::{
fpioa::{self, io},
gpio, gpiohs,
};

pub fn init() {
// led b 映射到 gpiohs 0
// 9
fpioa::set_function(io::BPSK_P, fpioa::function::GPIOHS0);
// 10
fpioa::set_function(io::BPSK_N, fpioa::function::GPIOHS1);
// gpiohs 设置 0 为输出
gpiohs::set_direction(0, gpio::direction::OUTPUT);
gpiohs::set_direction(1, gpio::direction::OUTPUT);

gpiohs::set_pin(0, false);
gpiohs::set_pin(1, true);

println!("0 is {}", gpiohs::get_pin(0));
println!("1 is {}", gpiohs::get_pin(1));
}
14 changes: 14 additions & 0 deletions os/src/driver/gpio/led_gpio.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use k210_soc::{
fpioa::{self, io},
gpio, gpiohs,
};

pub fn init() {
// led b 映射到 gpiohs 0
fpioa::set_function(io::LED_R, fpioa::function::GPIOHS5);
// gpiohs 设置 0 为输出
gpiohs::set_direction(5, gpio::direction::OUTPUT);
// gpiohs 0 为 false , false 为点亮
gpiohs::set_pin(5, false);
println!("0 is {}", gpiohs::get_pin(5));
}
4 changes: 2 additions & 2 deletions os/src/driver/gpio/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod led;
mod led_ex;
pub fn init() {
led::init();
led_ex::init();
}

0 comments on commit 90cfcaf

Please sign in to comment.