Giter Site home page Giter Site logo

spi-unit's Introduction

Banner

spi-unit

SPI driver for AVR microcontroller

Version : 0.0.0

  • Type : Embedded Software.

  • Support : AVR microcontroller.

  • Program Language : C/C++

  • Properties :

Initialization and de-initialization functions:

  • SPI_Init()
  • SPI_DeInit()
  • SPI_DefaultMasterInit()
  • SPI_DefaultSlaveInit()

IO operation functions:

  • SPI_Transmit()
  • SPI_Receive()
  • SPI_TransmitReceive()
  • SPI_Transmit_IT()
  • SPI_Receive_IT()
  • SPI_TransmitReceive_IT()

How to use this driver

The SPI driver can be used as follows:

1.1 Set SPI DDR Register & Pins in the spi_unit_conf.h header, for example:

   /* ------ SPI DDR Register ------ */
   #define _DDR_SPI   DDRB  
   
   /* ---------- SPI Pins ---------- */  
   #define _MOSI_PIN  3  
   #define _MISO_PIN  4  
   #define _SCK_PIN   5  

1.2 Move out the SPI_TxCpltCallback() function from spi_unit_conf.h and paste in .c file

2.1 Manual initialize:

  • Declare a SPI_InitTypeDef initialize structure, for example:

    SPI_InitTypeDef uspi;
    
  • Set your configuration in SPI_InitTypeDef, for example:

    uspi.Mode = _SPI_MODE_MASTER  
    uspi.FirstBit = _SPI_FIRSTBIT_MSB;  
    uspi.ClockPhase = _SPI_CLOCKPHASE_FIRSTEDGE;  
    uspi.ClockPolarity = _SPI_CLOCKPOLARITY_LOW;  
    uspi.ClockFrequency = _SPI_CLOCKRATE_FCPU_16;  
    
  • Initialize the SPI by implementing the SPI_Init() API:

    SPI_Init(&uspi);
    

2.2 Default initialize: Initialize the SPI by implementing the SPI_DefaultxInit() API:

   SPI_DefaultMasterInit();   
   SPI_DefaultSlaveInit(); 

3.1 If using SPI_x_IT functions, enable the SPI Interrupt by __SPI_ENABLE_IT macro, for example:

   // First enable your global interrupt   
   __SPI_ENABLE_IT

4.1 Enable the SPI Peripheral by __SPI_ENABLE macros, for example:

   __SPI_ENABLE

5.1 use the IO operation functions, for example:

   SPI_Transmit("Hello Word", 10, 1000);  

Developer: Majid Derhambakhsh

spi-unit's People

Contributors

majid-derhambakhsh avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.