From 1d51e3739bb9889f4288c34b1d61171756865086 Mon Sep 17 00:00:00 2001 From: ImplFerris Date: Fri, 25 Oct 2024 01:00:18 +0530 Subject: [PATCH] template --- src/SUMMARY.md | 1 + src/cargo-generate.md | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/cargo-generate.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index ea7c0bb..87dfb12 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -3,6 +3,7 @@ - [Introduction](./index.md) - [Dev Environment](./setup.md) - [Quick Start](./quick-start.md) + - [Project Template](./cargo-generate.md) - [Running the Program](./running.md) - [Blink LED](./blinky/index.md) diff --git a/src/cargo-generate.md b/src/cargo-generate.md new file mode 100644 index 0000000..2314da0 --- /dev/null +++ b/src/cargo-generate.md @@ -0,0 +1,41 @@ +# Project Template with `cargo-generate` + +"cargo-generate is a developer tool to help you get up and running quickly with a new Rust project by leveraging a pre-existing git repository as a template." + +Read more about [here](https://github.com/cargo-generate/cargo-generate). + +## Prerequisites + +Before starting, ensure you have the following tools installed: + +- [Rust](https://www.rust-lang.org/tools/install) +- [cargo-generate](https://github.com/cargo-generate/cargo-generate) for generating the project template. + +You can install `cargo-generate` using the following command: +```sh +cargo install cargo-generate +``` + +## Step 1: Generate the Project +Run the following command to generate the project from the template: + +```sh +cargo generate --git https://github.com/ImplFerris/pico2-template.git +``` + +This will prompt you to answer a few questions: +Project name: Name your project. +HAL choice: You can choose between embassy or rp-hal. + +## Step 2: Default LED Blink Example +By default, the project will be generated with a simple LED blink example. The code structure may look like this: + +src/main.rs: Contains the default blink logic. +Cargo.toml: Includes dependencies for the selected HAL. + +## Step 3: Choose Your HAL and Modify Code +Once the project is generated, you can decide to keep the default LED blink code or remove it and replace it with your own code based on the HAL you selected. + +## Removing Unwanted Code +You can remove the blink logic from src/main.rs and replace it with your own code. Modify the Cargo.toml dependencies and project structure as needed for your project. +