Skip to content

Commit

Permalink
Last CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alloncm committed Aug 19, 2023
1 parent a3c50c8 commit be21fa2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
26 changes: 12 additions & 14 deletions rpi/src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const CNTP_CTL_ISTATUS:u32 = 1<<2;
// This function is busy waiting, when the interrupt controller will be implemented
// I could make this function not busy wait
pub fn wait_ms(duration:u32){
let mut counter_timer_freq_reg:u32; // the freq of the system timer
// read CNTFRQ ARM register
unsafe{asm!("mrc p15, 0, {r}, c14, c0, 0", r = out(reg) counter_timer_freq_reg)};

let required_count_increase:u32 = (counter_timer_freq_reg / 1000) * duration;
unsafe{
let mut counter_timer_freq_reg:u32; // the freq of the system timer
// read CNTFRQ ARM register
asm!("mrc p15, 0, {r}, c14, c0, 0", r = out(reg) counter_timer_freq_reg);

let required_count_increase:u32 = (counter_timer_freq_reg / 1000) * duration;
// set CNTP_TVAL ARM register
asm!("mcr p15, 0, {r}, c14, c2, 0", r = in(reg) required_count_increase);
// set CNTP_CTL ARM register to start and disable timer interrupt
Expand All @@ -21,16 +21,14 @@ pub fn wait_ms(duration:u32){
asm!("mrc p15, 0, {r}, c14, c2, 1", r = out(reg) cntp_ctl_reg);
cntp_ctl_reg |= CNTP_CTL_ENABLE | CNTP_CTL_IMASK;
asm!("mcr p15, 0, {r}, c14, c2, 1", r = in(reg) cntp_ctl_reg);
}
loop {
let mut cntp_ctl_reg:u32;
unsafe{asm!("mrc p15, 0, {r}, c14, c2, 1", r = out(reg) cntp_ctl_reg)};
if cntp_ctl_reg & CNTP_CTL_ISTATUS != 0{
break;
loop {
let mut cntp_ctl_reg:u32;
asm!("mrc p15, 0, {r}, c14, c2, 1", r = out(reg) cntp_ctl_reg);
if cntp_ctl_reg & CNTP_CTL_ISTATUS != 0{
break;
}
}
}
// set ARM Timer to stop counting
unsafe{
// set ARM Timer to stop counting
let mut cntp_ctl_reg:u32;
// read CNTP_CTL ARM register
asm!("mrc p15, 0, {r}, c14, c2, 1", r = out(reg) cntp_ctl_reg);
Expand Down
3 changes: 2 additions & 1 deletion rpi/src/drivers/fat32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ impl Fat32{
if dir.file_name[0] == DIR_EOF_PREFIX{
break 'search;
}
else if dir.file_name[0] == DELETED_DIR_ENTRY_PREFIX{
if dir.file_name[0] == DELETED_DIR_ENTRY_PREFIX{
continue;
}
if dir.attributes == ATTR_LONG_NAME{
continue;
// handle long file names here
}
if discard > 0{
discard -= 1;
Expand Down

0 comments on commit be21fa2

Please sign in to comment.