File tree Expand file tree Collapse file tree 4 files changed +19
-32
lines changed Expand file tree Collapse file tree 4 files changed +19
-32
lines changed Original file line number Diff line number Diff line change @@ -47,29 +47,14 @@ use heapless::String;
47
47
48
48
use lotus_input:: control:: * ;
49
49
use lotus_input:: graphics:: * ;
50
+ use lotus_input:: serialnum:: get_serialnum;
50
51
51
52
// FRA - Framwork
52
53
// KDE - Lotus C2 LED Matrix
53
54
// AM - Atemitech
54
55
// 00 - Default Configuration
55
56
// 00000000 - Device Identifier
56
57
const DEFAULT_SERIAL : & str = "FRAKDEAM0000000000" ;
57
- // Get serial number from last 4K block of the first 1M
58
- const FLASH_OFFSET : usize = 0x10000000 ;
59
- const LAST_4K_BLOCK : usize = 0xff000 ;
60
- const SERIALNUM_LEN : usize = 18 ;
61
-
62
- fn get_serialnum ( ) -> Option < & ' static str > {
63
- // Flash is mapped into memory, just read it from there
64
- let ptr: * const u8 = ( FLASH_OFFSET + LAST_4K_BLOCK ) as * const u8 ;
65
- unsafe {
66
- let slice: & [ u8 ] = core:: slice:: from_raw_parts ( ptr, SERIALNUM_LEN ) ;
67
- if slice[ 0 ] == 0xFF || slice[ 0 ] == 0x00 {
68
- return None ;
69
- }
70
- core:: str:: from_utf8 ( slice) . ok ( )
71
- }
72
- }
73
58
74
59
#[ allow( clippy:: large_enum_variant) ]
75
60
#[ derive( Clone ) ]
Original file line number Diff line number Diff line change @@ -100,29 +100,14 @@ use lotus_input::control::*;
100
100
use lotus_input:: lotus:: LotusLedMatrix ;
101
101
use lotus_input:: matrix:: * ;
102
102
use lotus_input:: patterns:: * ;
103
+ use lotus_input:: serialnum:: get_serialnum;
103
104
104
105
// FRA - Framwork
105
106
// KDE - Lotus C2 LED Matrix
106
107
// AM - Atemitech
107
108
// 00 - Default Configuration
108
109
// 00000000 - Device Identifier
109
110
const DEFAULT_SERIAL : & str = "FRAKDEAM0000000000" ;
110
- // Get serial number from last 4K block of the first 1M
111
- const FLASH_OFFSET : usize = 0x10000000 ;
112
- const LAST_4K_BLOCK : usize = 0xff000 ;
113
- const SERIALNUM_LEN : usize = 18 ;
114
-
115
- fn get_serialnum ( ) -> Option < & ' static str > {
116
- // Flash is mapped into memory, just read it from there
117
- let ptr: * const u8 = ( FLASH_OFFSET + LAST_4K_BLOCK ) as * const u8 ;
118
- unsafe {
119
- let slice: & [ u8 ] = core:: slice:: from_raw_parts ( ptr, SERIALNUM_LEN ) ;
120
- if slice[ 0 ] == 0xFF || slice[ 0 ] == 0x00 {
121
- return None ;
122
- }
123
- core:: str:: from_utf8 ( slice) . ok ( )
124
- }
125
- }
126
111
127
112
#[ entry]
128
113
fn main ( ) -> ! {
Original file line number Diff line number Diff line change @@ -17,3 +17,4 @@ pub mod graphics;
17
17
pub mod lotus_lcd_hal;
18
18
19
19
pub mod control;
20
+ pub mod serialnum;
Original file line number Diff line number Diff line change
1
+ // Get serial number from last 4K block of the first 1M
2
+ const FLASH_OFFSET : usize = 0x10000000 ;
3
+ const LAST_4K_BLOCK : usize = 0xff000 ;
4
+ const SERIALNUM_LEN : usize = 18 ;
5
+
6
+ pub fn get_serialnum ( ) -> Option < & ' static str > {
7
+ // Flash is mapped into memory, just read it from there
8
+ let ptr: * const u8 = ( FLASH_OFFSET + LAST_4K_BLOCK ) as * const u8 ;
9
+ unsafe {
10
+ let slice: & [ u8 ] = core:: slice:: from_raw_parts ( ptr, SERIALNUM_LEN ) ;
11
+ if slice[ 0 ] == 0xFF || slice[ 0 ] == 0x00 {
12
+ return None ;
13
+ }
14
+ core:: str:: from_utf8 ( slice) . ok ( )
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments