Skip to content

Add SysTick flags #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 3, 2018
Merged

Add SysTick flags #116

merged 5 commits into from
Oct 3, 2018

Conversation

qwerty19106
Copy link
Contributor

@qwerty19106 qwerty19106 commented Sep 24, 2018

CMSIS core headers contains SCB_ICSR_PENDSVSET_*** and SCB_ICSR_PENDSTSET_*** definitions, which I need in my projects. In CMSIS it is used to check, set and clear this flags (rtx_core_cm.h and os_systick.c).

I suggest adding it to scb.rs. I put initial commit, but I need help to add compiler barriers where its are needed.

For details, see CMSIS:
CMSIS_5/CMSIS/Core/Include/core_cm3.h (or other core_cm{X}.h)
CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_core_cm.h)
CMSIS_5/CMSIS/RTOS2/Source/os_systick.c)

FIX: I have not seen that PENDSV is already added. I review PENDST code to be like PENDSV.

@qwerty19106 qwerty19106 requested a review from a team as a code owner September 24, 2018 10:00
@qwerty19106
Copy link
Contributor Author

FIX: I have not seen that PENDSV is already added. I review PENDST code to be like PENDSV.

@qwerty19106 qwerty19106 changed the title Add PendSV and SysTick flags Add SysTick flags Sep 25, 2018
@qwerty19106
Copy link
Contributor Author

bors try

@bors
Copy link
Contributor

bors bot commented Sep 25, 2018

🔒 Permission denied

Existing reviewers: click here to make qwerty19106 a reviewer


/// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt
#[inline]
pub fn clear_systick_pending(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this operation require exclusive access to SCB (&mut self)? With clear_pendsv() it wasn't required because setting just the PENDSTCLR bit doesn't affect any other bits in the register, so you can't have data races.

Copy link
Contributor Author

@qwerty19106 qwerty19106 Oct 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exclusive access to SCB is not required. I think that clear_systick_pending needs to change analogiously.


/// Set the PENDSTCLR bit in the ICSR register which will clear a pending SysTick interrupt
#[inline]
pub fn set_systick(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about calling this set_systick when just above we have set_pendsv. Really this one should be set_pendst or we need to rename both (causing a major version change). Same applies to is_systick_pending and clear_systick_pending. I'd prefer just using pendst here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, set_pendst looks better.

@qwerty19106
Copy link
Contributor Author

I added requested changes, needs to review.

}
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: One blank line too many.

@qwerty19106
Copy link
Contributor Author

Do I need to run rustfmt before create commit?
I try run rustfmt and got many changes on other lines.

@therealprof
Copy link
Contributor

Not a hard requirement but IMHO a good thing to do.

@qwerty19106
Copy link
Contributor Author

qwerty19106 commented Oct 3, 2018

Are there any other changes I have to do?

@adamgreig
Copy link
Member

@therealprof are you happy with the result of rustfmt here, especially around L610? If anything I think it looks a bit messier now. I'm happy with everything else in the PR.

@therealprof
Copy link
Contributor

@adamgreig I agree it looks messier now but I'm not in charge of the formatting rules. I still think adhering to the standard formatting is a good idea even if the result is not what I personally prefer.

@adamgreig
Copy link
Member

Okay, let's merge this and we can consider tidying up more of the code for rustfmt another time.

@adamgreig
Copy link
Member

bors r+

@adamgreig
Copy link
Member

Thanks @qwerty19106 !

bors bot added a commit that referenced this pull request Oct 3, 2018
116: Add SysTick flags r=adamgreig a=qwerty19106

CMSIS core headers contains SCB_ICSR_PENDSVSET_*** and SCB_ICSR_PENDSTSET_*** definitions, which I need in my projects. In CMSIS it is used to check, set and clear this flags (rtx_core_cm.h and os_systick.c).

I suggest adding it to scb.rs. I put initial commit, but I need help to add compiler barriers where its are needed.

For details, see CMSIS:
[CMSIS_5/CMSIS/Core/Include/core_cm3.h](https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/Core/Include/core_cm3.h)  (or other core_cm{X}.h)
[CMSIS_5/CMSIS/RTOS2/RTX/Source/rtx_core_cm.h)](https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/RTOS2/RTX/Source/rtx_core_cm.h)
[CMSIS_5/CMSIS/RTOS2/Source/os_systick.c)](https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS/RTOS2/Source/os_systick.c)

FIX: I have not seen that PENDSV is already added. I review PENDST code to be like PENDSV.


Co-authored-by: qwerty19106 <[email protected]>
@bors
Copy link
Contributor

bors bot commented Oct 3, 2018

Build succeeded

@bors bors bot merged commit 2cb6f4b into rust-embedded:master Oct 3, 2018
@qwerty19106 qwerty19106 deleted the scb_pendsv_and_systick_flags branch October 3, 2018 21:24
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
that contains static variables that will not be initialized by the runtime

this implements only the linker section described in RFC #116 so that downstream
libraries / framework can leverage it without (a) forking this crate or (b)
requiring the end user to pass additional linker scripts to the linker when
building their crate.

This commit doesn't add the user interface described in RFC #116; instead it
documents how to use this linker section in the advanced section of the crate
level documentation
adamgreig pushed a commit that referenced this pull request Jan 12, 2022
192: add a .uninit section r=therealprof a=japaric

that contains static variables that will not be initialized by the runtime

this implements only the linker section described in RFC #116 so that downstream
libraries / framework can leverage it without (a) forking this crate or (b)
requiring the end user to pass additional linker scripts to the linker when
building their crate.

This commit doesn't add the user interface described in RFC #116; instead it
documents how to use this linker section in the advanced section of the crate
level documentation

Co-authored-by: Jorge Aparicio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants