cortex-m icon indicating copy to clipboard operation
cortex-m copied to clipboard

Allow setting exception return value in exceptions

Open wildarch opened this issue 6 years ago • 0 comments

As far as I could tell the API does not currently allow setting the exception return value (EXC_RETURN) in exception handlers, which would be useful for implementing context switching etc.

Could we add an extra case to the #[exception] macro to also accept something like:

#[exception]
fn SysTick(exc: ExceptionReturn) -> ExceptionReturn

Where:

pub enum ExceptionReturn {
    HandlerMsp,
    HandlerFpuMsp,
    ThreadMsp,
    ....
}

This enum can then be used under the hood to set the correct value for LR/PC upon exception return.

I'd be happy to further experiment with this idea and turn it into a pull request.

wildarch avatar Nov 08 '18 08:11 wildarch