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
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright OxidOS Automotive SRL.
//
// Author: Ioan-Cristian CÎRSTEA <ioan.cirstea@oxidos.io>

//! STM32F429 specifications

use stm32f4xx::chip_specific::clock_constants::{PllConstants, SystemClockConstants};
use stm32f4xx::chip_specific::flash::{FlashChipSpecific, FlashLatency16};

pub enum Stm32f429Specs {}

impl PllConstants for Stm32f429Specs {
    const MIN_FREQ_MHZ: usize = 13;
}

impl SystemClockConstants for Stm32f429Specs {
    const APB1_FREQUENCY_LIMIT_MHZ: usize = 45;
    const SYS_CLOCK_FREQUENCY_LIMIT_MHZ: usize = 168;
}

impl FlashChipSpecific for Stm32f429Specs {
    type FlashLatency = FlashLatency16;

    fn get_number_wait_cycles_based_on_frequency(frequency_mhz: usize) -> Self::FlashLatency {
        match frequency_mhz {
            0..=30 => Self::FlashLatency::Latency0,
            31..=60 => Self::FlashLatency::Latency1,
            61..=90 => Self::FlashLatency::Latency2,
            91..=120 => Self::FlashLatency::Latency3,
            121..=150 => Self::FlashLatency::Latency4,
            _ => Self::FlashLatency::Latency5,
        }
    }
}