/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */


#ifndef ECXX_PLATFORM_COMMON_SPI_CONSTANT_H
#define ECXX_PLATFORM_COMMON_SPI_CONSTANT_H


namespace eCxx {


//
// Default SPI clock frequency
//
static constexpr uint32_t DefaultSPIFrequency = 400000UL;


//
// SPI mode
//
enum class SPIMode : uint8_t {
    Master = 1,
    Slave  = 2
};


//
// SPI data mode
//
enum class SPIDataMode : uint8_t {
    Mode0 = 0x00, // Mode 0 => Shift SCK-Edge = Falling          ; Capture SCK-Edge = Rising
    Mode1 = 0x01, // Mode 1 => Shift SCK-Edge = Rising           ; Capture SCK-Edge = Falling
    Mode2 = 0x10, // Mode 2 => Shift SCK-Edge = Rising           ; Capture SCK-Edge = Falling
    Mode3 = 0x11, // Mode 3 => Shift SCK-Edge = Falling          ; Capture SCK-Edge = Rising
                  //
                  // Mode 0 => Leading Edge   = Sample (Rising ) ; Trailing Edge    = Setup  (Falling)
                  // Mode 1 => Leading Edge   = Setup  (Rising ) ; Trailing Edge    = Sample (Falling)
                  // Mode 2 => Leading Edge   = Sample (Falling) ; Trailing Edge    = Setup  (Rising )
                  // Mode 3 => Leading Edge   = Setup  (Falling) ; Trailing Edge    = Sample (Rising )
};


} // namespace eCxx


#endif
