<commit_before>
#include "Arduino.h"
#include <SPI.h>
#include "spi_drv.h"                   
#include "pins_arduino.h"
//#define _DEBUG_
extern "C" {
#include "debug.h"
}

#define DATAOUT 	11 // MOSI
#define DATAIN  	12 // MISO
#define SPICLOCK  	13 // sck
#define SLAVESELECT 10 // ss
#define SLAVEREADY 	7  // handshake pin
#define WIFILED 	9  // led on wifi shield

#define DELAY_100NS do { asm volatile("nop"); }while(0);
#define DELAY_SPI(X) { int ii=0; do {  asm volatile("nop"); }while(++ii<X);}
#define DELAY_TRANSFER() DELAY_SPI(10)

void SpiDrv::begin()
{
//	  pinMode(SCK, OUTPUT);
//	  pinMode(MOSI, OUTPUT);
//	  pinMode(SS, OUTPUT);

	  SPI.begin();
	  pinMode(SLAVESELECT, OUTPUT);
	  pinMode(SLAVEREADY, INPUT);
	  pinMode(WIFILED, OUTPUT);

	  digitalWrite(SCK, LOW);
	  digitalWrite(MOSI, LOW);
	  digitalWrite(SS, HIGH);
	  digitalWrite(SLAVESELECT, HIGH);
	  digitalWrite(WIFILED, LOW);

#ifdef _DEBUG_
	  INIT_TRIGGER()
#endif
}

void SpiDrv::end() {
	SPI.end();
}

void SpiDrv::spiSlaveSelect()
{
    digitalWrite(SLAVESELECT,LOW);
}


void SpiDrv::spiSlaveDeselect()
{
    digitalWrite(SLAVESELECT,HIGH);
}

//void delaySpi()
//{
//	int i = 0;
//	const int DELAY = 1000;
//	for (;i<DELAY;++i)
//	{
//		int a =a+1;
//	}
//}

char SpiDrv::spiTransfer(volatile char data)
{
	char result = SPI.transfer(data);
//    SPDR = data;                    // Start the transmission
//    while (!(SPSR & (1<<SPIF)))     // Wait the end of the transmission
//    {
//    };
//    char result = SPDR;
    DELAY_TRANSFER();<commit_msg>Fixed Wifi library for Arduino Due<commit_after>
#include "Arduino.h"
#include <SPI.h>
#include "spi_drv.h"                   
#include "pins_arduino.h"
//#define _DEBUG_
extern "C" {
#include "debug.h"
}

#define DATAOUT 	11 // MOSI
#define DATAIN  	12 // MISO
#define SPICLOCK  	13 // sck
#define SLAVESELECT 10 // ss
#define SLAVEREADY 	7  // handshake pin
#define WIFILED 	9  // led on wifi shield

#define DELAY_SPI(X) { int ii=0; do { asm volatile("nop"); } while (++ii < X*6); }
#define DELAY_TRANSFER() DELAY_SPI(10)

void SpiDrv::begin()
{
	  SPI.begin();
	  pinMode(SLAVESELECT, OUTPUT);
	  pinMode(SLAVEREADY, INPUT);
	  pinMode(WIFILED, OUTPUT);

	  digitalWrite(SCK, LOW);
	  digitalWrite(MOSI, LOW);
	  digitalWrite(SS, HIGH);
	  digitalWrite(SLAVESELECT, HIGH);
	  digitalWrite(WIFILED, LOW);

#ifdef _DEBUG_
	  INIT_TRIGGER()
#endif
}

void SpiDrv::end() {
	SPI.end();
}

void SpiDrv::spiSlaveSelect()
{
    digitalWrite(SLAVESELECT,LOW);
}


void SpiDrv::spiSlaveDeselect()
{
    digitalWrite(SLAVESELECT,HIGH);
}

//void delaySpi()
//{
//	int i = 0;
//	const int DELAY = 1000;
//	for (;i<DELAY;++i)
//	{
//		int a =a+1;
//	}
//}

char SpiDrv::spiTransfer(volatile char data)
{
	char result = SPI.transfer(data);
    DELAY_TRANSFER();
{'fraction_non_alphanumeric': 0.16493738819320214, 'fraction_numerical': 0.015742397137745976, 'mean_word_length': 3.314814814814815, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4623367', 'n_tokens_mistral': 1227, 'n_tokens_neox': 1170, 'n_words': 251}