KETCube
Macros | Functions | Variables
ketCube_spi.c File Reference

This file contains implementation of the ketCube SPI driver. More...

#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include "hw_conf.h"
#include "ketCube_gpio.h"
#include "ketCube_spi.h"

Macros

#define SPI_CLK_ENABLE()   __HAL_RCC_SPI1_CLK_ENABLE()
 
#define SPI1_AF   GPIO_AF0_SPI1
 

Functions

static void ketCube_SPI_IoInit (void)
 
static void ketCube_SPI_IoDeInit (void)
 
static uint32_t SpiFrequency (uint32_t hz)
 Calculates Spi Divisor based on Spi Frequency and Mcu Frequency. More...
 
ketCube_cfg_DrvError_t ketCube_SPI_Init (void)
 Initializes the SPI object and MCU peripheral. More...
 
ketCube_cfg_DrvError_t ketCube_SPI_DeInit (void)
 De-initializes the SPI object and MCU peripheral. More...
 
ketCube_cfg_DrvError_t ketCube_SPI_SleepEnter (void)
 Set-UP SPI befere sleep enter. More...
 
ketCube_cfg_DrvError_t ketCube_SPI_SleepExit (void)
 Set-UP SPI after sleep exit. More...
 
uint16_t ketCube_SPI_InOut (uint16_t txData)
 Sends outData and receives inData. More...
 

Variables

static volatile bool initialized = FALSE
 
static SPI_HandleTypeDef hspi
 

Detailed Description

This file contains implementation of the ketCube SPI driver.

Author
Jan Belohoubek
Version
alpha
Date
2019-12-09
Note
This code is based on Semtech and STM SPI driver implementation. See the original file licenses in LICENSE_SEMTECH and LICENSE_STM respectively.
Attention

© Copyright (c) 2019 University of West Bohemia in Pilsen All rights reserved.

Developed by: The SmartCampus Team Department of Technologies and Measurement www.smartcampus.cz | www.zcu.cz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.

Macro Definition Documentation

◆ SPI1_AF

#define SPI1_AF   GPIO_AF0_SPI1

◆ SPI_CLK_ENABLE

#define SPI_CLK_ENABLE ( )    __HAL_RCC_SPI1_CLK_ENABLE()

Function Documentation

◆ ketCube_SPI_IoDeInit()

static void ketCube_SPI_IoDeInit ( void  )
static

◆ ketCube_SPI_IoInit()

static void ketCube_SPI_IoInit ( void  )
static

◆ SpiFrequency()

static uint32_t SpiFrequency ( uint32_t  hz)
static

Calculates Spi Divisor based on Spi Frequency and Mcu Frequency.

Parameters
[IN]Spi Frequency
Return values
Spidivisor

Variable Documentation

◆ hspi

SPI_HandleTypeDef hspi
static

◆ initialized

volatile bool initialized = FALSE
static