Skip to content

Commit

Permalink
Add serde derives to flash params
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani authored and SergioGasquez committed Dec 12, 2023
1 parent 71d7a63 commit ba49cbb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add --confirm-port argument to flash command (#455)
- Add --chip argument for flash and write-bin commands (#514)
- Add --partition-table-offset argument for specifying the partition table offset (#516)
- Add `Serialize` and `Deserialize` to `FlashFrequency`, `FlashMode` and `FlashSize`. (#528)

### Fixed

Expand Down
31 changes: 28 additions & 3 deletions espflash/src/flasher/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::{borrow::Cow, str::FromStr, thread::sleep};
use bytemuck::{Pod, Zeroable, __core::time::Duration};
use esp_idf_part::PartitionTable;
use log::{debug, info, warn};
use serde::{Deserialize, Serialize};
use serialport::UsbPortInfo;
use strum::{Display, EnumIter, EnumVariantNames};

Expand Down Expand Up @@ -39,7 +40,19 @@ const FLASH_SECTORS_PER_BLOCK: usize = FLASH_SECTOR_SIZE / FLASH_BLOCK_SIZE;
///
/// Note that not all frequencies are supported by each target device.
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, Display, EnumVariantNames)]
#[derive(
Debug,
Default,
Clone,
Copy,
Hash,
PartialEq,
Eq,
Display,
EnumVariantNames,
Serialize,
Deserialize,
)]
#[non_exhaustive]
#[repr(u8)]
pub enum FlashFrequency {
Expand Down Expand Up @@ -85,7 +98,7 @@ impl FlashFrequency {

/// Supported flash modes
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Copy, Clone, Debug, Default, EnumVariantNames)]
#[derive(Copy, Clone, Debug, Default, EnumVariantNames, Serialize, Deserialize)]
#[non_exhaustive]
#[strum(serialize_all = "lowercase")]
pub enum FlashMode {
Expand All @@ -104,7 +117,19 @@ pub enum FlashMode {
///
/// Note that not all sizes are supported by each target device.
#[cfg_attr(feature = "cli", derive(clap::ValueEnum))]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Display, EnumVariantNames, EnumIter)]
#[derive(
Clone,
Copy,
Debug,
Default,
Eq,
PartialEq,
Display,
EnumVariantNames,
EnumIter,
Serialize,
Deserialize,
)]
#[non_exhaustive]
#[repr(u8)]
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
Expand Down

0 comments on commit ba49cbb

Please sign in to comment.