Skip to content

Commit e15bcbe

Browse files
committed
Add docs so clippy is happy.
1 parent ae0b866 commit e15bcbe

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/algo.rs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ macro_rules! algo {
3333
static mut _IS_INIT: bool = false;
3434
static mut _ALGO_INSTANCE: MaybeUninit<$type> = MaybeUninit::uninit();
3535

36+
/// Initialise the Flash Algorithm
37+
///
38+
/// # Safety
39+
///
40+
/// Will disable execution from Flash. Ensure you are running from SRAM
41+
/// and do not call any flash-based based functions.
3642
#[no_mangle]
3743
#[link_section = ".entry"]
3844
pub unsafe extern "C" fn Init(addr: u32, clock: u32, function: u32) -> u32 {
@@ -48,16 +54,25 @@ macro_rules! algo {
4854
Err(e) => e.get(),
4955
}
5056
}
57+
/// Uninitialise the Flash Algorithm
5158
#[no_mangle]
5259
#[link_section = ".entry"]
53-
pub unsafe extern "C" fn UnInit() -> u32 {
54-
if !_IS_INIT {
55-
return 1;
60+
pub extern "C" fn UnInit() -> u32 {
61+
unsafe {
62+
if !_IS_INIT {
63+
return 1;
64+
}
65+
_ALGO_INSTANCE.as_mut_ptr().drop_in_place();
66+
_IS_INIT = false;
5667
}
57-
_ALGO_INSTANCE.as_mut_ptr().drop_in_place();
58-
_IS_INIT = false;
5968
0
6069
}
70+
/// Erase the flash chip.
71+
///
72+
/// # Safety
73+
///
74+
/// Will erase the flash chip. Ensure you really want to erase the
75+
/// flash chip.
6176
#[no_mangle]
6277
#[link_section = ".entry"]
6378
pub unsafe extern "C" fn EraseChip() -> u32 {
@@ -70,6 +85,11 @@ macro_rules! algo {
7085
Err(e) => e.get(),
7186
}
7287
}
88+
/// Erase the a sector on the flash chip.
89+
///
90+
/// # Safety
91+
///
92+
/// Will erase the given sector. Pass a valid sector address.
7393
#[no_mangle]
7494
#[link_section = ".entry"]
7595
pub unsafe extern "C" fn EraseSector(addr: u32) -> u32 {
@@ -82,6 +102,12 @@ macro_rules! algo {
82102
Err(e) => e.get(),
83103
}
84104
}
105+
/// Write to a page on the flash chip.
106+
///
107+
/// # Safety
108+
///
109+
/// Will program the given page. Pass a valid page address, and a
110+
/// valid pointer to at least `size` bytes of data.
85111
#[no_mangle]
86112
#[link_section = ".entry"]
87113
pub unsafe extern "C" fn ProgramPage(addr: u32, size: u32, data: *const u8) -> u32 {

0 commit comments

Comments
 (0)