pub fn with_clock(spi_clock: u32) -> ClockMask {
        let mut divider_bits = if spi_clock >= config::CPU_FREQUENCY_HZ / 2 {
            0
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 4 {
            1
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 8 {
            2
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 16 {
            3
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 32 {
            4
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 64 {
            5
        } else {
            6
        };

        // Invert the SPI2X bit
        divider_bits ^= 0x1;

        // Compensate for the duplicate F_osc/64
        if divider_bits == 6 {
            divider_bits = 7;
        }
        ClockMask(divider_bits)
    }
/// Gets the clock mask for a specific baute rate.
Gets the clock mask for a specific baute rate.
Gets the clock mask for a specific baute rate .
pub fn with_clock(spi_clock: u32) -> ClockMask {
        let mut divider_bits = if spi_clock >= config::CPU_FREQUENCY_HZ / 2 {
            0
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 4 {
            1
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 8 {
            2
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 16 {
            3
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 32 {
            4
        } else if spi_clock >= config::CPU_FREQUENCY_HZ / 64 {
            5
        } else {
            6
        };
        // Invert the SPI2X bit
        divider_bits ^= 0x1;
        // Compensate for the duplicate F_osc/64
        if divider_bits == 6 {
            divider_bits = 7;
        }
        ClockMask(divider_bits)
    }
pub fn with_clock ( spi_clock : u32 ) -> ClockMask { let mut divider_bits = if spi_clock >= config :: CPU_FREQUENCY_HZ / 2 { 0 } else if spi_clock >= config :: CPU_FREQUENCY_HZ / 4 { 1 } else if spi_clock >= config :: CPU_FREQUENCY_HZ / 8 { 2 } else if spi_clock >= config :: CPU_FREQUENCY_HZ / 16 { 3 } else if spi_clock >= config :: CPU_FREQUENCY_HZ / 32 { 4 } else if spi_clock >= config :: CPU_FREQUENCY_HZ / 64 { 5 } else { 6 } ; // Invert the SPI2X bit divider_bits ^= 0x1 ; // Compensate for the duplicate F_osc/64 if divider_bits == 6 { divider_bits = 7 ; } ClockMask ( divider_bits ) }
Gets the clock mask for a specific baute rate.
Gets the clock mask for a specific baute rate .
spi_clock
u32