stm32f446re/
chip_specs.rs

1// Licensed under the Apache License, Version 2.0 or the MIT License.
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// Copyright OxidOS Automotive SRL.
4//
5// Author: Ioan-Cristian CÎRSTEA <ioan.cirstea@oxidos.io>
6
7//! STM32F446 specifications
8
9use stm32f4xx::chip_specific::clock_constants::{PllConstants, SystemClockConstants};
10use stm32f4xx::chip_specific::flash::{FlashChipSpecific, FlashLatency16};
11
12pub enum Stm32f446Specs {}
13
14impl PllConstants for Stm32f446Specs {
15    const MIN_FREQ_MHZ: usize = 13;
16}
17
18impl SystemClockConstants for Stm32f446Specs {
19    const APB1_FREQUENCY_LIMIT_MHZ: usize = 45;
20    const SYS_CLOCK_FREQUENCY_LIMIT_MHZ: usize = 168;
21}
22
23impl FlashChipSpecific for Stm32f446Specs {
24    type FlashLatency = FlashLatency16;
25
26    fn get_number_wait_cycles_based_on_frequency(frequency_mhz: usize) -> Self::FlashLatency {
27        match frequency_mhz {
28            0..=30 => Self::FlashLatency::Latency0,
29            31..=60 => Self::FlashLatency::Latency1,
30            61..=90 => Self::FlashLatency::Latency2,
31            91..=120 => Self::FlashLatency::Latency3,
32            121..=150 => Self::FlashLatency::Latency4,
33            _ => Self::FlashLatency::Latency5,
34        }
35    }
36}