@@ -81,10 +81,36 @@ pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER;
8181/// BIOS version
8282const GIT_VERSION : & str = git_version ! ( ) ;
8383
84+ /// Create a new Text Console
85+ static TEXT_CONSOLE : vga:: TextConsole = vga:: TextConsole :: new ( ) ;
86+
8487// -----------------------------------------------------------------------------
8588// Functions
8689// -----------------------------------------------------------------------------
8790
91+ /// Prints to the screen
92+ #[ macro_export]
93+ macro_rules! print {
94+ ( $( $arg: tt) * ) => {
95+ {
96+ use core:: fmt:: Write as _;
97+ write!( & TEXT_CONSOLE , $( $arg) * ) . unwrap( ) ;
98+ }
99+ } ;
100+ }
101+
102+ /// Prints to the screen and puts a new-line on the end
103+ #[ macro_export]
104+ macro_rules! println {
105+ ( ) => ( print!( "\n " ) ) ;
106+ ( $( $arg: tt) * ) => {
107+ {
108+ use core:: fmt:: Write as _;
109+ writeln!( & TEXT_CONSOLE , $( $arg) * ) . unwrap( ) ;
110+ }
111+ } ;
112+ }
113+
88114/// This is the entry-point to the BIOS. It is called by cortex-m-rt once the
89115/// `.bss` and `.data` sections have been initialised.
90116#[ entry]
@@ -96,7 +122,7 @@ fn main() -> ! {
96122 // Grab the singleton containing all the RP2040 peripherals
97123 let mut pac = pac:: Peripherals :: take ( ) . unwrap ( ) ;
98124 // Grab the singleton containing all the generic Cortex-M peripherals
99- let mut core = pac:: CorePeripherals :: take ( ) . unwrap ( ) ;
125+ let _core = pac:: CorePeripherals :: take ( ) . unwrap ( ) ;
100126
101127 // Reset the DMA engine. If we don't do this, starting from probe-run
102128 // (as opposed to a cold-start) is unreliable.
@@ -168,8 +194,6 @@ fn main() -> ! {
168194 let mut b_power_save = pins. b_power_save . into_push_pull_output ( ) ;
169195 b_power_save. set_high ( ) . unwrap ( ) ;
170196
171- info ! ( "Pins OK" ) ;
172-
173197 // Give H-Sync, V-Sync and 12 RGB colour pins to PIO0 to output video
174198 let _h_sync = pins. gpio0 . into_mode :: < hal:: gpio:: FunctionPio0 > ( ) ;
175199 let _v_sync = pins. gpio1 . into_mode :: < hal:: gpio:: FunctionPio0 > ( ) ;
@@ -186,6 +210,8 @@ fn main() -> ! {
186210 let _blue2 = pins. gpio12 . into_mode :: < hal:: gpio:: FunctionPio0 > ( ) ;
187211 let _blue3 = pins. gpio13 . into_mode :: < hal:: gpio:: FunctionPio0 > ( ) ;
188212
213+ info ! ( "Pins OK" ) ;
214+
189215 vga:: init (
190216 pac. PIO0 ,
191217 pac. DMA ,
@@ -195,8 +221,14 @@ fn main() -> ! {
195221 & mut pac. PSM ,
196222 ) ;
197223
224+ TEXT_CONSOLE . set_text_buffer ( unsafe { & mut vga:: CHAR_ARRAY } ) ;
225+
226+ info ! ( "VGA intialised" ) ;
227+
228+ let mut x = 0 ;
198229 loop {
199- cortex_m:: asm:: wfi ( ) ;
230+ println ! ( "x = {}" , x) ;
231+ x = x + 1 ;
200232 }
201233}
202234
0 commit comments