/*
 * software_spi.h
 *
 * Created: 19/08/2018 13:58:56
 *  Author: Ledo
 */ 


#ifndef SOFTWARE_SPI_H_
#define SOFTWARE_SPI_H_
#include "globales.h"
#include "asf.h"
  
#include <stdint.h>
 

#define SPI_MSBFIRST 1
	
#define SPI_CLK_LOW()            {ioport_set_pin_level(PIO_PA14_IDX,false);}
#define SPI_CLK_HIGH()           {ioport_set_pin_level(PIO_PA14_IDX,true);}
#define SPI_MOSI_LOW()           {ioport_set_pin_level(PIO_PA13_IDX,false);}
#define SPI_MOSI_HIGH()          {ioport_set_pin_level(PIO_PA13_IDX,true);}
#define SPI_MOSI_LEVEL(level)    {ioport_set_pin_level(PIO_PA13_IDX,level);}
#define SPI_MISO()               ioport_get_pin_level(PIO_PA12_IDX)
    
void soft_spi_transfer(uint8_t b) ;
void soft_spi_init();
    
 

#define DELAY_T0        30//60//60 //low
#define DELAY_T1        14//35//25 //low
#define DELAY_T2        8//15 //pulse
#define DELAY_T3        15//30 //pulse

  


#endif /* SOFTWARE_SPI_H_ */