Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a562de8

Browse files
alexandruradovicilschuermann
authored andcommitted
add reset function to cortexm::support
1 parent f96c4ef commit a562de8

File tree

20 files changed

+31
-209
lines changed

20 files changed

+31
-209
lines changed

arch/cortex-m/src/support.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33
// Copyright Tock Contributors 2022.
44

5+
use crate::scb;
56
use core::ops::FnOnce;
67

78
#[cfg(all(target_arch = "arm", target_os = "none"))]
@@ -58,3 +59,14 @@ where
5859
{
5960
unimplemented!()
6061
}
62+
63+
pub fn reset() -> ! {
64+
unsafe {
65+
scb::reset();
66+
}
67+
loop {
68+
// This is required to avoid the empty loop clippy
69+
// warning #[warn(clippy::empty_loop)]
70+
nop();
71+
}
72+
}

boards/clue_nrf52840/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,6 @@ fn baud_rate_reset_bootloader_enter() {
138138
}
139139
}
140140

141-
// Function for the process console to use to reboot the board
142-
fn reset() -> ! {
143-
unsafe {
144-
cortexm4::scb::reset();
145-
}
146-
loop {
147-
cortexm4::support::nop();
148-
}
149-
}
150-
151141
/// Supported drivers by the platform
152142
pub struct Platform {
153143
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
@@ -738,7 +728,7 @@ pub unsafe fn main() {
738728
uart_mux,
739729
mux_alarm,
740730
process_printer,
741-
Some(reset),
731+
Some(cortexm4::support::reset),
742732
)
743733
.finalize(components::process_console_component_static!(
744734
nrf52840::rtc::Rtc

boards/hail/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ static mut PROCESS_PRINTER: Option<&'static kernel::process::ProcessPrinterText>
4848
#[link_section = ".stack_buffer"]
4949
pub static mut STACK_MEMORY: [u8; 0x1000] = [0; 0x1000];
5050

51-
// Function for the process console to use to reboot the board
52-
fn reset() -> ! {
53-
unsafe {
54-
cortexm4::scb::reset();
55-
}
56-
loop {
57-
cortexm4::support::nop();
58-
}
59-
}
60-
6151
/// A structure representing this platform that holds references to all
6252
/// capsules for this platform.
6353
struct Hail {
@@ -314,7 +304,7 @@ pub unsafe fn main() {
314304
uart_mux,
315305
mux_alarm,
316306
process_printer,
317-
Some(reset),
307+
Some(cortexm4::support::reset),
318308
)
319309
.finalize(components::process_console_component_static!(
320310
sam4l::ast::Ast<'static>

boards/imix/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,6 @@ static mut PROCESS_PRINTER: Option<&'static kernel::process::ProcessPrinterText>
109109
#[link_section = ".stack_buffer"]
110110
pub static mut STACK_MEMORY: [u8; 0x2000] = [0; 0x2000];
111111

112-
// Function for the process console to use to reboot the board
113-
fn reset() -> ! {
114-
unsafe {
115-
cortexm4::scb::reset();
116-
}
117-
loop {
118-
cortexm4::support::nop();
119-
}
120-
}
121-
122112
struct Imix {
123113
pconsole: &'static capsules_core::process_console::ProcessConsole<
124114
'static,
@@ -416,7 +406,7 @@ pub unsafe fn main() {
416406
uart_mux,
417407
mux_alarm,
418408
process_printer,
419-
Some(reset),
409+
Some(cortexm4::support::reset),
420410
)
421411
.finalize(components::process_console_component_static!(
422412
sam4l::ast::Ast

boards/microbit_v2/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,6 @@ pub static mut STACK_MEMORY: [u8; 0x2000] = [0; 0x2000];
8181
// debug mode requires more stack space
8282
// pub static mut STACK_MEMORY: [u8; 0x2000] = [0; 0x2000];
8383

84-
// Function for the process console to use to reboot the board
85-
fn reset() -> ! {
86-
unsafe {
87-
cortexm4::scb::reset();
88-
}
89-
loop {
90-
cortexm4::support::nop();
91-
}
92-
}
93-
9484
/// Supported drivers by the platform
9585
pub struct MicroBit {
9686
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
@@ -692,7 +682,7 @@ unsafe fn start() -> (
692682
uart_mux,
693683
mux_alarm,
694684
process_printer,
695-
Some(reset),
685+
Some(cortexm4::support::reset),
696686
)
697687
.finalize(components::process_console_component_static!(
698688
nrf52833::rtc::Rtc

boards/nano33ble/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,6 @@ fn baud_rate_reset_bootloader_enter() {
115115
}
116116
}
117117

118-
// Function for the process console to use to reboot the board.
119-
fn reset() -> ! {
120-
unsafe {
121-
cortexm4::scb::reset();
122-
}
123-
loop {
124-
cortexm4::support::nop();
125-
}
126-
}
127-
128118
/// Supported drivers by the platform
129119
pub struct Platform {
130120
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
@@ -386,7 +376,7 @@ pub unsafe fn main() {
386376
uart_mux,
387377
mux_alarm,
388378
process_printer,
389-
Some(reset),
379+
Some(cortexm4::support::reset),
390380
)
391381
.finalize(components::process_console_component_static!(
392382
nrf52::rtc::Rtc<'static>

boards/nano_rp2040_connect/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@ mod flash_bootloader;
4949
#[link_section = ".stack_buffer"]
5050
pub static mut STACK_MEMORY: [u8; 0x1500] = [0; 0x1500];
5151

52-
// Function for the process console to reboot the Nano RP2040 Connect.
53-
fn reset_function() -> ! {
54-
unsafe {
55-
cortexm0p::scb::reset();
56-
}
57-
loop {
58-
cortexm0p::support::nop();
59-
}
60-
}
61-
6252
// Manually setting the boot header section that contains the FCB header
6353
#[used]
6454
#[link_section = ".flash_bootloader"]
@@ -545,7 +535,7 @@ pub unsafe fn main() {
545535
uart_mux,
546536
mux_alarm,
547537
process_printer,
548-
Some(reset_function),
538+
Some(cortexm0p::support::reset),
549539
)
550540
.finalize(components::process_console_component_static!(RPTimer));
551541
let _ = process_console.start();

boards/nordic/nrf52840_dongle/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ static mut PROCESS_PRINTER: Option<&'static kernel::process::ProcessPrinterText>
7575
#[link_section = ".stack_buffer"]
7676
pub static mut STACK_MEMORY: [u8; 0x1000] = [0; 0x1000];
7777

78-
// Function for the process console to use to reboot the board
79-
fn reset() -> ! {
80-
unsafe {
81-
cortexm4::scb::reset();
82-
}
83-
loop {
84-
cortexm4::support::nop();
85-
}
86-
}
87-
8878
/// Supported drivers by the platform
8979
pub struct Platform {
9080
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
@@ -336,7 +326,7 @@ pub unsafe fn main() {
336326
uart_mux,
337327
mux_alarm,
338328
process_printer,
339-
Some(reset),
329+
Some(cortexm4::support::reset),
340330
)
341331
.finalize(components::process_console_component_static!(
342332
nrf52840::rtc::Rtc<'static>

boards/nordic/nrf52840dk/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,6 @@ static mut PROCESS_PRINTER: Option<&'static kernel::process::ProcessPrinterText>
156156
#[link_section = ".stack_buffer"]
157157
pub static mut STACK_MEMORY: [u8; 0x2000] = [0; 0x2000];
158158

159-
// Function for the process console to use to reboot the board
160-
fn reset() -> ! {
161-
unsafe {
162-
cortexm4::scb::reset();
163-
}
164-
loop {
165-
cortexm4::support::nop();
166-
}
167-
}
168-
169159
/// Supported drivers by the platform
170160
pub struct Platform {
171161
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
@@ -499,7 +489,7 @@ pub unsafe fn main() {
499489
uart_mux,
500490
mux_alarm,
501491
process_printer,
502-
Some(reset),
492+
Some(cortexm4::support::reset),
503493
)
504494
.finalize(components::process_console_component_static!(
505495
nrf52840::rtc::Rtc<'static>

boards/nordic/nrf52dk/src/main.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,6 @@ static mut PROCESS_PRINTER: Option<&'static kernel::process::ProcessPrinterText>
134134
#[link_section = ".stack_buffer"]
135135
pub static mut STACK_MEMORY: [u8; 0x1000] = [0; 0x1000];
136136

137-
// Function for the process console to use to reboot the board
138-
fn reset() -> ! {
139-
unsafe {
140-
cortexm4::scb::reset();
141-
}
142-
loop {
143-
cortexm4::support::nop();
144-
}
145-
}
146-
147137
/// Supported drivers by the platform
148138
pub struct Platform {
149139
ble_radio: &'static capsules_extra::ble_advertising_driver::BLE<
@@ -394,7 +384,7 @@ pub unsafe fn main() {
394384
uart_mux,
395385
mux_alarm,
396386
process_printer,
397-
Some(reset),
387+
Some(cortexm4::support::reset),
398388
)
399389
.finalize(components::process_console_component_static!(Rtc<'static>));
400390

0 commit comments

Comments
 (0)