File tree Expand file tree Collapse file tree 3 files changed +95
-0
lines changed
examples/blinky-button-demo Expand file tree Collapse file tree 3 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = " blinky-button-demo"
3
+ version = " 0.1.0"
4
+ authors = [" Andres O. Vela" ]
5
+ edition = " 2018"
6
+
7
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
+
9
+ [dependencies ]
10
+ cortex-m = " 0.6.2"
11
+ rtt-target = {version = " 0.2.0" , features = [" cortex-m" ] }
12
+ nrf52832-hal = { features = [" rt" ], path = " ../../nrf52832-hal" }
13
+
14
+ [dependencies .embedded-hal ]
15
+ version = " 0.2.3"
16
+ features = [" unproven" ]
Original file line number Diff line number Diff line change
1
+ [probe ]
2
+ # The index of the probe in the connected probe list.
3
+ # probe_index = 0
4
+ # The protocol to be used for communicating with the target.
5
+ protocol = " Swd"
6
+ # The speed in kHz of the data link to the target.
7
+ # speed = 1337
8
+
9
+ [flashing ]
10
+ # Whether or not the target should be flashed.
11
+ enabled = true
12
+ # Whether or not the target should be halted after flashing.
13
+ halt_afterwards = false
14
+ # Whether or not bytes erased but not rewritten with data from the ELF
15
+ # should be restored with their contents before erasing.
16
+ restore_unwritten_bytes = false
17
+ # The path where an SVG of the assembled flash layout should be written to.
18
+ # flash_layout_output_path = "out.svg"
19
+
20
+ [general ]
21
+ # The chip name of the chip to be debugged.
22
+ chip = " nRF52832"
23
+ # A list of chip descriptions to be loaded during runtime.
24
+ chip_descriptions = []
25
+ # The default log level to be used.
26
+ log_level = " Warn"
27
+
28
+ [rtt ]
29
+ # Whether or not an RTTUI should be opened after flashing.
30
+ # This is exclusive and cannot be used with GDB at the moment.
31
+ enabled = true
32
+ # A list of channel associations to be displayed. If left empty, all channels are displayed.
33
+ channels = [
34
+ # { up = 0, down = 0, name = "name" }
35
+ ]
36
+ # The duration in ms for which the logger should retry to attach to RTT.
37
+ timeout = 3000
38
+ # Whether timestamps in the RTTUI are enabled
39
+ show_timestamps = true
40
+
41
+ [gdb ]
42
+ # Whether or not a GDB server should be opened after flashing.
43
+ # This is exclusive and cannot be used with RTT at the moment.
44
+ enabled = false
45
+ # The connection string in host:port format wher the GDB server will open a socket.
46
+ # gdb_connection_string
Original file line number Diff line number Diff line change
1
+ #![ no_main]
2
+ #![ no_std]
3
+
4
+ use core:: sync:: atomic:: { AtomicUsize , Ordering } ;
5
+ use embedded_hal:: digital:: v2:: InputPin ;
6
+ use embedded_hal:: digital:: v2:: OutputPin ;
7
+ use nrf52832_hal as hal;
8
+ use nrf52832_hal:: gpio:: Level ;
9
+
10
+ #[ panic_handler] // panicking behavior
11
+ fn panic ( _: & core:: panic:: PanicInfo ) -> ! {
12
+ loop {
13
+ cortex_m:: asm:: bkpt ( ) ;
14
+ }
15
+ }
16
+
17
+ #[ cortex_m_rt:: entry]
18
+ fn main ( ) -> ! {
19
+ rtt_init_print ! ( ) ;
20
+ let p = hal:: pac:: Peripherals :: take ( ) . unwrap ( ) ;
21
+ let port0 = hal:: gpio:: p0:: Parts :: new ( p. P0 ) ;
22
+ let button = port0. p0_13 . into_pullup_input ( ) ;
23
+ let mut led = port0. p0_17 . into_push_pull_output ( Level :: Low ) ;
24
+
25
+ rprintln ! ( "Blinky button demo starting" ) ;
26
+ loop {
27
+ if button. is_high ( ) . unwrap ( ) {
28
+ led. set_high ( ) . unwrap ( ) ;
29
+ } else {
30
+ led. set_low ( ) . unwrap ( ) ;
31
+ }
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments