6
6
#![ no_std]
7
7
#![ no_main]
8
8
9
+ use rp2040_hal as hal;
10
+
9
11
use hal:: gpio:: { FunctionPio0 , Pin } ;
10
- use hal:: pac;
11
12
use hal:: pio:: PIOExt ;
12
13
use hal:: Sio ;
14
+
15
+ // Ensure we halt the program on panic (if we don't mention this crate it won't
16
+ // be linked)
13
17
use panic_halt as _;
14
- use rp2040_hal as hal;
15
18
16
19
/// The linker will place this boot block at the start of our program image. We
17
20
/// need this to help the ROM bootloader get our code up and running.
@@ -23,11 +26,11 @@ pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GENERIC_03H;
23
26
24
27
/// Entry point to our bare-metal application.
25
28
///
26
- /// The `#[rp2040_hal ::entry]` macro ensures the Cortex-M start-up code calls this function
29
+ /// The `#[hal ::entry]` macro ensures the Cortex-M start-up code calls this function
27
30
/// as soon as all global variables and the spinlock are initialised.
28
- #[ rp2040_hal :: entry]
31
+ #[ hal :: entry]
29
32
fn main ( ) -> ! {
30
- let mut pac = pac:: Peripherals :: take ( ) . unwrap ( ) ;
33
+ let mut pac = hal :: pac:: Peripherals :: take ( ) . unwrap ( ) ;
31
34
32
35
let sio = Sio :: new ( pac. SIO ) ;
33
36
let pins = hal:: gpio:: Pins :: new (
@@ -44,18 +47,18 @@ fn main() -> ! {
44
47
45
48
// Define some simple PIO program.
46
49
let program = pio_proc:: pio_asm!(
47
- ".side_set 1" , // each instruction may set 1 bit
50
+ ".side_set 1" , // each instruction must set 1 bit
48
51
".wrap_target" ,
49
- " nop side 1" ,
50
- " nop side 0" ,
52
+ " nop side 1 [15] " ,
53
+ " nop side 0 [15] " ,
51
54
".wrap" ,
52
55
) ;
53
56
54
57
// Initialize and start PIO
55
58
let ( mut pio, sm0, _, _, _) = pac. PIO0 . split ( & mut pac. RESETS ) ;
56
59
let installed = pio. install ( & program. program ) . unwrap ( ) ;
57
60
let ( int, frac) = ( 0 , 0 ) ; // as slow as possible (0 is interpreted as 65536)
58
- let ( mut sm, _, _) = rp2040_hal :: pio:: PIOBuilder :: from_installed_program ( installed)
61
+ let ( mut sm, _, _) = hal :: pio:: PIOBuilder :: from_installed_program ( installed)
59
62
. side_set_pin_base ( led_pin_id)
60
63
. clock_divisor_fixed_point ( int, frac)
61
64
. build ( sm0) ;
@@ -68,3 +71,16 @@ fn main() -> ! {
68
71
cortex_m:: asm:: wfi ( ) ;
69
72
}
70
73
}
74
+
75
+ /// Program metadata for `picotool info`
76
+ #[ link_section = ".bi_entries" ]
77
+ #[ used]
78
+ pub static PICOTOOL_ENTRIES : [ hal:: binary_info:: EntryAddr ; 5 ] = [
79
+ hal:: binary_info:: rp_cargo_bin_name!( ) ,
80
+ hal:: binary_info:: rp_cargo_version!( ) ,
81
+ hal:: binary_info:: rp_program_description!( c"PIO Side-set Example" ) ,
82
+ hal:: binary_info:: rp_cargo_homepage_url!( ) ,
83
+ hal:: binary_info:: rp_program_build_attribute!( ) ,
84
+ ] ;
85
+
86
+ // End of file
0 commit comments