From 17aeef3bd64c3f51108decf1e0cdc6b9395265e5 Mon Sep 17 00:00:00 2001 From: ImplFerris Date: Thu, 26 Dec 2024 22:19:03 +0530 Subject: [PATCH] notes update --- src/led/code.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/led/code.md b/src/led/code.md index 8a67d77..5af99e1 100644 --- a/src/led/code.md +++ b/src/led/code.md @@ -2,10 +2,26 @@ Now comes the fun part; let's dive into the coding! -Let's start by initializing the peripherals with the default configuration. This function configures the CPU clock and watchdog, and then returns the instance of the peripherals. +### Generate project using esp-generate + +You have done this step already in the quick start section. + +To create the project, use the `esp-generate` command. Run the following: + +```sh +esp-generate --chip esp32 led-fader +``` + +This will open a screen asking you to select options. For now, we dont need to select any options. Just save it by pressing "s" in the keyboard. + +Let's start by initializing the peripherals with the default configuration. This function configures the CPU clock and watchdog, and then returns the instance of the peripherals. ```rust -let peripherals = esp_hal::init(esp_hal::Config::default()); + let peripherals = esp_hal::init({ + let mut config = esp_hal::Config::default(); + config.cpu_clock = CpuClock::max(); + config +}); ``` Next, we take our desired GPIO from the peripherals instance. In this case, we're turning on the onboard LED of the Devkit, which is connected to GPIO 2. @@ -83,7 +99,11 @@ use esp_hal::{ #[entry] fn main() -> ! { - let peripherals = esp_hal::init(esp_hal::Config::default()); + let peripherals = esp_hal::init({ + let mut config = esp_hal::Config::default(); + config.cpu_clock = CpuClock::max(); + config + }); let led = peripherals.GPIO2; // let led = peripherals.GPIO5;