You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KED/ked/csl/interfaces/spi.h

92 lines
2.1 KiB

/**
**************************************************************************************************
* @file spi.h
* @author Kerem Yollu & Edwin Koch
* @date 12.03.2022
* @version 1.0
**************************************************************************************************
* @brief This is the genral interface for spi.
*
* **Detailed Description :**
* This the spi interface and belongs to the interface layer.
*
**************************************************************************************************
*/
#ifndef _SPI_H_
#define _SPI_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "hardwareDescription.h"
typedef enum{
NONINVERTED,
INVERTED
}spi_clkPol_t;
typedef enum{
MSB_FIRST,
LSB_FIRST
}spi_framef_t;
/**
* @brief This is the spi hardware channel class
* @param spi_hw_ch SPI hardware channel
*/
void spi_init(spiCH_t spi_hw_ch);
/**
* @brief SPI hardware peripheral reset
* @param spi_hw_ch SPI hardware channel
*/
void spi_reset(spiCH_t spi_hw_ch);
/**
* @brief Enable spi hardware channel
* @param spi_hw_ch SPI hardware channel
*/
void spi_enable(spiCH_t spi_hw_ch);
/**
* @brief set SPI clock polarity
* @param spi_hw_ch SPI hardware channel
* @param clkPol Clock polarity
*/
void spi_setPolarity(spiCH_t spi_hw_ch, spi_clkPol_t clkPol);
/**
* @brief Set SPI frame format
* @param spi_hw_ch SPI hardware cannel
* @param framef Frame format
*/
void spi_setFrameFormat(spiCH_t spi_hw_ch, spi_framef_t framef);
/**
* @brief Set Clock Prescaler
* This is dependent on your target device. Please enter in the correct value.
* The entered Value will be masked with the maximal number of bits (truncated)
* @param spi_hw_ch SPI hardware channel
* @param clkDiv
*/
void spi_setClockPrescaler(spiCH_t spi_hw_ch,uint32_t clkDiv);
/*!
* @brief Transmits and receives on byte of data
* @param spi_hw_ch SPI hardware channel
* @param tx_data 'tx_data' The byte to be transmitted"
* @return The received data
*/
uint8_t spi_trx(spiCH_t spi_hw_ch, uint8_t tx_data);
#ifdef __cplusplus
}
#endif
#endif // _SPI_H_