aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32f4/src/bin/eth.rs4
-rw-r--r--examples/stm32f4/src/bin/usb_ethernet.rs12
-rw-r--r--examples/stm32f4/src/bin/usb_hid_keyboard.rs12
-rw-r--r--examples/stm32f4/src/bin/usb_hid_mouse.rs12
-rw-r--r--examples/stm32f4/src/bin/usb_raw.rs12
-rw-r--r--examples/stm32f4/src/bin/usb_serial.rs12
-rw-r--r--examples/stm32f7/src/bin/eth.rs4
-rw-r--r--examples/stm32f7/src/bin/usb_serial.rs12
-rw-r--r--examples/stm32h7/src/bin/eth_client.rs4
-rw-r--r--examples/stm32h7/src/bin/eth_client_mii.rs4
-rw-r--r--examples/stm32h7/src/bin/usb_serial.rs12
-rw-r--r--examples/stm32h7rs/src/bin/i2c.rs42
-rw-r--r--examples/stm32l4/src/bin/usb_serial.rs12
-rw-r--r--examples/stm32u5/src/bin/usb_serial.rs4
14 files changed, 94 insertions, 64 deletions
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs
index 7f5c8fdb1..648c45bbd 100644
--- a/examples/stm32f4/src/bin/eth.rs
+++ b/examples/stm32f4/src/bin/eth.rs
@@ -62,9 +62,9 @@ async fn main(spawner: Spawner) -> ! {
62 62
63 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 63 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
64 64
65 static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new(); 65 static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
66 let device = Ethernet::new( 66 let device = Ethernet::new(
67 PACKETS.init(PacketQueue::<16, 16>::new()), 67 PACKETS.init(PacketQueue::<4, 4>::new()),
68 p.ETH, 68 p.ETH,
69 Irqs, 69 Irqs,
70 p.PA1, 70 p.PA1,
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs
index 34e58f282..19ae16e8b 100644
--- a/examples/stm32f4/src/bin/usb_ethernet.rs
+++ b/examples/stm32f4/src/bin/usb_ethernet.rs
@@ -77,13 +77,11 @@ async fn main(spawner: Spawner) {
77 let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..]; 77 let ep_out_buffer = &mut OUTPUT_BUFFER.init([0; 256])[..];
78 let mut config = embassy_stm32::usb::Config::default(); 78 let mut config = embassy_stm32::usb::Config::default();
79 79
80 // Enable vbus_detection 80 // Do not enable vbus_detection. This is a safe default that works in all boards.
81 // Note: some boards don't have this wired up and might not require it, 81 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
82 // as they are powered through usb! 82 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
83 // If you hang on boot, try setting this to "false"! 83 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
84 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 84 config.vbus_detection = false;
85 // for more information
86 config.vbus_detection = true;
87 85
88 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config); 86 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, ep_out_buffer, config);
89 87
diff --git a/examples/stm32f4/src/bin/usb_hid_keyboard.rs b/examples/stm32f4/src/bin/usb_hid_keyboard.rs
index de9b692b1..537ff63ea 100644
--- a/examples/stm32f4/src/bin/usb_hid_keyboard.rs
+++ b/examples/stm32f4/src/bin/usb_hid_keyboard.rs
@@ -55,13 +55,11 @@ async fn main(_spawner: Spawner) {
55 let mut ep_out_buffer = [0u8; 256]; 55 let mut ep_out_buffer = [0u8; 256];
56 let mut config = embassy_stm32::usb::Config::default(); 56 let mut config = embassy_stm32::usb::Config::default();
57 57
58 // Enable vbus_detection 58 // Do not enable vbus_detection. This is a safe default that works in all boards.
59 // Note: some boards don't have this wired up and might not require it, 59 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
60 // as they are powered through usb! 60 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
61 // If you hang on boot, try setting this to "false"! 61 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
62 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 62 config.vbus_detection = false;
63 // for more information
64 config.vbus_detection = true;
65 63
66 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 64 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
67 65
diff --git a/examples/stm32f4/src/bin/usb_hid_mouse.rs b/examples/stm32f4/src/bin/usb_hid_mouse.rs
index d15ad52dc..df4b7426c 100644
--- a/examples/stm32f4/src/bin/usb_hid_mouse.rs
+++ b/examples/stm32f4/src/bin/usb_hid_mouse.rs
@@ -52,13 +52,11 @@ async fn main(_spawner: Spawner) {
52 let mut ep_out_buffer = [0u8; 256]; 52 let mut ep_out_buffer = [0u8; 256];
53 let mut config = embassy_stm32::usb::Config::default(); 53 let mut config = embassy_stm32::usb::Config::default();
54 54
55 // Enable vbus_detection 55 // Do not enable vbus_detection. This is a safe default that works in all boards.
56 // Note: some boards don't have this wired up and might not require it, 56 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
57 // as they are powered through usb! 57 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
58 // If you hang on boot, try setting this to "false"! 58 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
59 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 59 config.vbus_detection = false;
60 // for more information
61 config.vbus_detection = true;
62 60
63 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 61 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
64 62
diff --git a/examples/stm32f4/src/bin/usb_raw.rs b/examples/stm32f4/src/bin/usb_raw.rs
index d058abdd0..1452e7c5f 100644
--- a/examples/stm32f4/src/bin/usb_raw.rs
+++ b/examples/stm32f4/src/bin/usb_raw.rs
@@ -105,13 +105,11 @@ async fn main(_spawner: Spawner) {
105 let mut ep_out_buffer = [0u8; 256]; 105 let mut ep_out_buffer = [0u8; 256];
106 let mut config = embassy_stm32::usb::Config::default(); 106 let mut config = embassy_stm32::usb::Config::default();
107 107
108 // Enable vbus_detection 108 // Do not enable vbus_detection. This is a safe default that works in all boards.
109 // Note: some boards don't have this wired up and might not require it, 109 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
110 // as they are powered through usb! 110 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
111 // If you hang on boot, try setting this to "false"! 111 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
112 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 112 config.vbus_detection = false;
113 // for more information
114 config.vbus_detection = true;
115 113
116 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 114 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
117 115
diff --git a/examples/stm32f4/src/bin/usb_serial.rs b/examples/stm32f4/src/bin/usb_serial.rs
index 91cfae87b..b2bd390b6 100644
--- a/examples/stm32f4/src/bin/usb_serial.rs
+++ b/examples/stm32f4/src/bin/usb_serial.rs
@@ -52,13 +52,11 @@ async fn main(_spawner: Spawner) {
52 let mut ep_out_buffer = [0u8; 256]; 52 let mut ep_out_buffer = [0u8; 256];
53 let mut config = embassy_stm32::usb::Config::default(); 53 let mut config = embassy_stm32::usb::Config::default();
54 54
55 // Enable vbus_detection 55 // Do not enable vbus_detection. This is a safe default that works in all boards.
56 // Note: some boards don't have this wired up and might not require it, 56 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
57 // as they are powered through usb! 57 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
58 // If you hang on boot, try setting this to "false"! 58 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
59 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 59 config.vbus_detection = false;
60 // for more information
61 config.vbus_detection = true;
62 60
63 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 61 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
64 62
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs
index 9a608e909..41e2a6061 100644
--- a/examples/stm32f7/src/bin/eth.rs
+++ b/examples/stm32f7/src/bin/eth.rs
@@ -63,9 +63,9 @@ async fn main(spawner: Spawner) -> ! {
63 63
64 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 64 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
65 65
66 static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new(); 66 static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
67 let device = Ethernet::new( 67 let device = Ethernet::new(
68 PACKETS.init(PacketQueue::<16, 16>::new()), 68 PACKETS.init(PacketQueue::<4, 4>::new()),
69 p.ETH, 69 p.ETH,
70 Irqs, 70 Irqs,
71 p.PA1, 71 p.PA1,
diff --git a/examples/stm32f7/src/bin/usb_serial.rs b/examples/stm32f7/src/bin/usb_serial.rs
index 02ab4d1f2..0e5cc7c5c 100644
--- a/examples/stm32f7/src/bin/usb_serial.rs
+++ b/examples/stm32f7/src/bin/usb_serial.rs
@@ -52,13 +52,11 @@ async fn main(_spawner: Spawner) {
52 let mut ep_out_buffer = [0u8; 256]; 52 let mut ep_out_buffer = [0u8; 256];
53 let mut config = embassy_stm32::usb::Config::default(); 53 let mut config = embassy_stm32::usb::Config::default();
54 54
55 // Enable vbus_detection 55 // Do not enable vbus_detection. This is a safe default that works in all boards.
56 // Note: some boards don't have this wired up and might not require it, 56 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
57 // as they are powered through usb! 57 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
58 // If you hang on boot, try setting this to "false"! 58 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
59 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 59 config.vbus_detection = false;
60 // for more information
61 config.vbus_detection = true;
62 60
63 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 61 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
64 62
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs
index aeb169e19..0639fb99f 100644
--- a/examples/stm32h7/src/bin/eth_client.rs
+++ b/examples/stm32h7/src/bin/eth_client.rs
@@ -64,10 +64,10 @@ async fn main(spawner: Spawner) -> ! {
64 64
65 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 65 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
66 66
67 static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new(); 67 static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
68 68
69 let device = Ethernet::new( 69 let device = Ethernet::new(
70 PACKETS.init(PacketQueue::<16, 16>::new()), 70 PACKETS.init(PacketQueue::<4, 4>::new()),
71 p.ETH, 71 p.ETH,
72 Irqs, 72 Irqs,
73 p.PA1, 73 p.PA1,
diff --git a/examples/stm32h7/src/bin/eth_client_mii.rs b/examples/stm32h7/src/bin/eth_client_mii.rs
index de6ea522a..9a52e8d3b 100644
--- a/examples/stm32h7/src/bin/eth_client_mii.rs
+++ b/examples/stm32h7/src/bin/eth_client_mii.rs
@@ -64,10 +64,10 @@ async fn main(spawner: Spawner) -> ! {
64 64
65 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 65 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
66 66
67 static PACKETS: StaticCell<PacketQueue<16, 16>> = StaticCell::new(); 67 static PACKETS: StaticCell<PacketQueue<4, 4>> = StaticCell::new();
68 68
69 let device = Ethernet::new_mii( 69 let device = Ethernet::new_mii(
70 PACKETS.init(PacketQueue::<16, 16>::new()), 70 PACKETS.init(PacketQueue::<4, 4>::new()),
71 p.ETH, 71 p.ETH,
72 Irqs, 72 Irqs,
73 p.PA1, 73 p.PA1,
diff --git a/examples/stm32h7/src/bin/usb_serial.rs b/examples/stm32h7/src/bin/usb_serial.rs
index 71d0c0a25..1c50fc1c8 100644
--- a/examples/stm32h7/src/bin/usb_serial.rs
+++ b/examples/stm32h7/src/bin/usb_serial.rs
@@ -53,13 +53,11 @@ async fn main(_spawner: Spawner) {
53 let mut ep_out_buffer = [0u8; 256]; 53 let mut ep_out_buffer = [0u8; 256];
54 let mut config = embassy_stm32::usb::Config::default(); 54 let mut config = embassy_stm32::usb::Config::default();
55 55
56 // Enable vbus_detection 56 // Do not enable vbus_detection. This is a safe default that works in all boards.
57 // Note: some boards don't have this wired up and might not require it, 57 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
58 // as they are powered through usb! 58 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
59 // If you hang on boot, try setting this to "false"! 59 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
60 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 60 config.vbus_detection = false;
61 // for more information
62 config.vbus_detection = true;
63 61
64 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 62 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
65 63
diff --git a/examples/stm32h7rs/src/bin/i2c.rs b/examples/stm32h7rs/src/bin/i2c.rs
new file mode 100644
index 000000000..31e83cbb5
--- /dev/null
+++ b/examples/stm32h7rs/src/bin/i2c.rs
@@ -0,0 +1,42 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_stm32::i2c::{Error, I2c};
7use embassy_stm32::time::Hertz;
8use embassy_stm32::{bind_interrupts, i2c, peripherals};
9use {defmt_rtt as _, panic_probe as _};
10
11const ADDRESS: u8 = 0x5F;
12const WHOAMI: u8 = 0x0F;
13
14bind_interrupts!(struct Irqs {
15 I2C2_EV => i2c::EventInterruptHandler<peripherals::I2C2>;
16 I2C2_ER => i2c::ErrorInterruptHandler<peripherals::I2C2>;
17});
18
19#[embassy_executor::main]
20async fn main(_spawner: Spawner) {
21 info!("Hello world!");
22 let p = embassy_stm32::init(Default::default());
23
24 let mut i2c = I2c::new(
25 p.I2C2,
26 p.PB10,
27 p.PB11,
28 Irqs,
29 p.GPDMA1_CH4,
30 p.GPDMA1_CH5,
31 Hertz(100_000),
32 Default::default(),
33 );
34
35 let mut data = [0u8; 1];
36
37 match i2c.blocking_write_read(ADDRESS, &[WHOAMI], &mut data) {
38 Ok(()) => info!("Whoami: {}", data[0]),
39 Err(Error::Timeout) => error!("Operation timed out"),
40 Err(e) => error!("I2c Error: {:?}", e),
41 }
42}
diff --git a/examples/stm32l4/src/bin/usb_serial.rs b/examples/stm32l4/src/bin/usb_serial.rs
index a378cdc6b..ed9671d0f 100644
--- a/examples/stm32l4/src/bin/usb_serial.rs
+++ b/examples/stm32l4/src/bin/usb_serial.rs
@@ -47,13 +47,11 @@ async fn main(_spawner: Spawner) {
47 let mut ep_out_buffer = [0u8; 256]; 47 let mut ep_out_buffer = [0u8; 256];
48 let mut config = embassy_stm32::usb::Config::default(); 48 let mut config = embassy_stm32::usb::Config::default();
49 49
50 // Enable vbus_detection 50 // Do not enable vbus_detection. This is a safe default that works in all boards.
51 // Note: some boards don't have this wired up and might not require it, 51 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
52 // as they are powered through usb! 52 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
53 // If you hang on boot, try setting this to "false"! 53 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
54 // See https://embassy.dev/book/dev/faq.html#_the_usb_examples_are_not_working_on_my_board_is_there_anything_else_i_need_to_configure 54 config.vbus_detection = false;
55 // for more information
56 config.vbus_detection = true;
57 55
58 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 56 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
59 57
diff --git a/examples/stm32u5/src/bin/usb_serial.rs b/examples/stm32u5/src/bin/usb_serial.rs
index f107928a9..4d56395da 100644
--- a/examples/stm32u5/src/bin/usb_serial.rs
+++ b/examples/stm32u5/src/bin/usb_serial.rs
@@ -43,6 +43,10 @@ async fn main(_spawner: Spawner) {
43 // Create the driver, from the HAL. 43 // Create the driver, from the HAL.
44 let mut ep_out_buffer = [0u8; 256]; 44 let mut ep_out_buffer = [0u8; 256];
45 let mut config = embassy_stm32::usb::Config::default(); 45 let mut config = embassy_stm32::usb::Config::default();
46 // Do not enable vbus_detection. This is a safe default that works in all boards.
47 // However, if your USB device is self-powered (can stay powered on if USB is unplugged), you need
48 // to enable vbus_detection to comply with the USB spec. If you enable it, the board
49 // has to support it or USB won't work at all. See docs on `vbus_detection` for details.
46 config.vbus_detection = false; 50 config.vbus_detection = false;
47 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config); 51 let driver = Driver::new_fs(p.USB_OTG_FS, Irqs, p.PA12, p.PA11, &mut ep_out_buffer, config);
48 52