File tree Expand file tree Collapse file tree 4 files changed +7
-6
lines changed
autd3-firmware-emulator/src Expand file tree Collapse file tree 4 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -141,8 +141,8 @@ impl CPUEmulator {
141
141
}
142
142
143
143
impl CPUEmulator {
144
- pub ( crate ) const fn cast < T > ( data : & [ u8 ] ) -> & T {
145
- unsafe { & * ( data. as_ptr ( ) as * const T ) }
144
+ pub ( crate ) const fn cast < T > ( data : & [ u8 ] ) -> T {
145
+ unsafe { ( data. as_ptr ( ) as * const T ) . read_unaligned ( ) }
146
146
}
147
147
148
148
const fn get_addr ( select : u8 , addr : u16 ) -> u16 {
Original file line number Diff line number Diff line change 1
1
use crate :: { cpu:: params:: * , CPUEmulator } ;
2
2
3
+ #[ allow( dead_code) ]
3
4
#[ repr( C , align( 2 ) ) ]
4
5
struct Clear {
5
6
tag : u8 ,
6
7
}
7
8
8
9
impl CPUEmulator {
9
- pub ( crate ) unsafe fn clear ( & mut self , data : & [ u8 ] ) -> u8 {
10
- let _d = Self :: cast :: < Clear > ( data) ;
10
+ pub ( crate ) unsafe fn clear ( & mut self , _data : & [ u8 ] ) -> u8 {
11
+ // let _d = Self::cast::<Clear>(data);
11
12
12
13
self . read_fpga_state = false ;
13
14
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ impl CPUEmulator {
24
24
let data = unsafe {
25
25
std:: slice:: from_raw_parts (
26
26
data[ std:: mem:: size_of :: < Gain > ( ) ..] . as_ptr ( ) as * const u16 ,
27
- ( data . len ( ) - 2 ) >> 1 ,
27
+ self . num_transducers ,
28
28
)
29
29
} ;
30
30
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ impl Memory {
101
101
}
102
102
103
103
pub fn read_bram_as < T > ( bram : & [ u16 ] , addr : usize ) -> T {
104
- unsafe { ( bram. as_ptr ( ) . add ( addr) as * const T ) . read ( ) }
104
+ unsafe { ( bram. as_ptr ( ) . add ( addr) as * const T ) . read_unaligned ( ) }
105
105
}
106
106
107
107
pub fn write ( & mut self , addr : u16 , data : u16 ) {
You can’t perform that action at this time.
0 commit comments