File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
zmu_cortex_m/src/semihosting Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,12 @@ pub fn get_semihost_func(start: Instant) -> impl FnMut(&SemihostingCommand) -> S
8282 SemihostingResponse :: SysIstty { result : Err ( -1 ) }
8383 }
8484 }
85+ SemihostingCommand :: SysWriteC { ref data} => {
86+ // println!("writec: data={:?}", data);
87+ print ! ( "{}" , * data as char ) ;
88+ io:: stdout ( ) . flush ( ) . expect ( "Could not flush stdout" ) ;
89+ SemihostingResponse :: SysWrite { result : Ok ( 0 ) }
90+ }
8591 SemihostingCommand :: SysWrite { handle, ref data } => {
8692 // println!("write: handle={}, data={:?}", handle, data);
8793 if * handle == TT_HANDLE_STDOUT {
Original file line number Diff line number Diff line change @@ -107,6 +107,13 @@ pub enum SemihostingCommand {
107107 handle : u32 ,
108108 } ,
109109 ///
110+ /// Write single char to the debug console
111+ ///
112+ SysWriteC {
113+ /// char to write
114+ data : u8 ,
115+ } ,
116+ ///
110117 /// Write data to open file handle
111118 ///
112119 SysWrite {
@@ -230,6 +237,7 @@ pub enum SemihostingResponse {
230237
231238const SYS_OPEN : u32 = 0x01 ;
232239const SYS_CLOSE : u32 = 0x02 ;
240+ const SYS_WRITEC : u32 = 0x03 ;
233241const SYS_WRITE : u32 = 0x05 ;
234242const SYS_READ : u32 = 0x06 ;
235243const SYS_ISTTY : u32 = 0x09 ;
@@ -273,6 +281,13 @@ pub fn decode_semihostcmd(
273281 let handle = processor. read32 ( params_ptr) ?;
274282 SemihostingCommand :: SysClose { handle }
275283 }
284+ SYS_WRITEC => {
285+ let params_ptr = r1;
286+ let ch = processor. read8 ( params_ptr) ?;
287+ SemihostingCommand :: SysWriteC {
288+ data : ch,
289+ }
290+ }
276291 SYS_WRITE => {
277292 let params_ptr = r1;
278293 let handle = processor. read32 ( params_ptr) ?;
You can’t perform that action at this time.
0 commit comments