File tree 4 files changed +15
-11
lines changed
4 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ fn panic(info :&PanicInfo) -> ! {
82
82
}
83
83
}
84
84
85
+ /// Set the logger that the log crate will use to a printk-based logger within Zephyr.
85
86
#[ cfg( CONFIG_PRINTK ) ]
86
87
pub fn set_logger ( ) {
87
88
printk:: set_printk_logger ( ) ;
@@ -111,6 +112,11 @@ pub mod alloc_impl;
111
112
// If we have allocation, we can also support logging.
112
113
#[ cfg( CONFIG_RUST_ALLOC ) ]
113
114
pub mod log {
115
+ //! A simple logging system using printk.
116
+ //!
117
+ //! As a stopgap for full logging, this allows Rust's logging to be transmitted via printk
118
+ //! messages.
119
+
114
120
#[ cfg( CONFIG_LOG ) ]
115
121
compile_error ! ( "Rust with CONFIG_LOG is not yet supported" ) ;
116
122
Original file line number Diff line number Diff line change @@ -20,20 +20,10 @@ extern "C" {
20
20
fn printk ( fmt : * const i8 , ...) ;
21
21
}
22
22
23
+ #[ doc( hidden) ]
23
24
pub fn log_message ( message : & str ) {
24
25
let raw = CString :: new ( message) . expect ( "CString::new failed" ) ;
25
26
unsafe {
26
27
printk ( c"%s\n " . as_ptr ( ) , raw. as_ptr ( ) ) ;
27
28
}
28
29
}
29
-
30
- // We assume the log message is accessible at $crate::log::log_message.
31
- #[ macro_export]
32
- macro_rules! println {
33
- ( $( $arg: tt) +) => {
34
- {
35
- let message = $crate:: log:: format!( $( $arg) +) ;
36
- $crate:: log:: log_message( & message) ;
37
- }
38
- } ;
39
- }
Original file line number Diff line number Diff line change @@ -74,12 +74,14 @@ static PRINTK_LOGGER: PrintkLogger = PrintkLogger;
74
74
75
75
// The cfg matches what is in the log crate, which doesn't use portable atomic, and assumes the
76
76
// racy init when not the case.
77
+ #[ doc( hidden) ]
77
78
#[ cfg( target_has_atomic = "ptr" ) ]
78
79
pub fn set_printk_logger ( ) {
79
80
log:: set_logger ( & PRINTK_LOGGER ) . unwrap ( ) ;
80
81
log:: set_max_level ( LevelFilter :: Info ) ;
81
82
}
82
83
84
+ #[ doc( hidden) ]
83
85
#[ cfg( not( target_has_atomic = "ptr" ) ) ]
84
86
pub fn set_printk_logger ( ) {
85
87
unsafe {
Original file line number Diff line number Diff line change @@ -145,6 +145,12 @@ pub mod flash {
145
145
146
146
use crate :: raw;
147
147
148
+ /// A flash controller
149
+ ///
150
+ /// This is a wrapper around the `struct device` in Zephyr that represents a flash controller.
151
+ /// Using the flash controller allows flash operations on the entire device. See
152
+ /// [`FlashPartition`] for a wrapper that limits the operation to a partition as defined in the
153
+ /// DT.
148
154
#[ allow( dead_code) ]
149
155
pub struct FlashController {
150
156
pub ( crate ) device : * const raw:: device ,
You can’t perform that action at this time.
0 commit comments