1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Flrc mode device configuration definitions

use super::common::*;

/// FLRC configuration structure
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
pub struct FlrcChannel {
    /// Operating frequency
    pub freq: u32,
    /// Bitrate bandwidth
    pub br_bw: FlrcBitrate,
    /// Coding rate
    pub cr: FlrcCodingRate,
    /// Modulation shaping
    pub ms: ModShaping,
}

impl Default for FlrcChannel {
    fn default() -> Self {
        Self {
            freq: 2.4e9 as u32,
            br_bw: FlrcBitrate::BR_2_080_BW_2_4,
            cr: FlrcCodingRate::Cr3_4,
            ms: ModShaping::Off,
        }   
    }
}


/// FLRC packet configuration structure
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
pub struct FlrcConfig {
    pub preamble_length: PreambleLength,
    pub sync_word_length: FlrcSyncWordLength,
    pub sync_word_match: SyncWordRxMatch,
    pub header_type: GfskFlrcPacketLength,
    pub payload_length: u8,
    pub crc_type: GfskFlrcCrcModes,
    pub whitening: WhiteningModes
}

/// Bit rate / bandwidth pairs for FLRC mode
#[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize)]
pub enum FlrcBitrate {
    BR_2_600_BW_2_4                    = 0x04,
    BR_2_080_BW_2_4                    = 0x28,
    BR_1_300_BW_1_2                    = 0x45,
    BR_1_040_BW_1_2                    = 0x69,
    BR_0_650_BW_0_6                    = 0x86,
    BR_0_520_BW_0_6                    = 0xAA,
    BR_0_325_BW_0_3                    = 0xC7,
    BR_0_260_BW_0_3                    = 0xEB,
}

/// Coding rates for FLRC mode
#[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize)]
pub enum FlrcCodingRate {
    Cr1_2 = 0x00,
    Cr3_4 = 0x02,
    Cr1_0 = 0x04,
}

/// FLRC sync word length
#[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize)]
pub enum FlrcSyncWordLength {
    /// No sync word
    None = 0x00,
    /// 4-byte sync word
    Length4 = 0x04,
}