[En-Nut-Discussion] EVK1100 SPI Slave

Philippgl2 mt1961 at thi.de
Mon Oct 13 11:24:52 CEST 2014


F***ing Mailprogramm 

Sorry hope it works this time:

#include <cfg/crt.h>
/* Device specific definitions. */
#include <dev/board.h>
#include <dev/reset.h>
#include <dev/gpio.h>

/* OS specific definitions. */
#include <sys/version.h>
#include <sys/confnet.h>
#include <sys/heap.h>

/* Standard C header files. */
#include <stdlib.h>
#include <stdio.h>

/*Globale Variablen*/
#include <C:\ethernut-4.10\nut\arch\avr32\dev\spibus0.c>   //Replace with
your path


int rc;

NUTSPINODE my_node = {
    &spiBus0Avr32, 			/* Pointer to the bus controller driver. */
    NULL,		 			/* Optional pointer to device specific settings. */
    10000, 					/* SPI clock rate. */
    0, 						/* SPI mode */
    8, 						/* SPI data bits. */
    1	 					/* Chip select index. */
};

int MyInit(void)
{
    rc = Avr32SpiBusNodeInit(&my_node);
	 
    if (rc == 0) {
        NutEventPost(&spiBus0Avr32.bus_mutex);
    }
    return rc;
}

 	
int MyTransfer(uint8_t *buf, int len)
{	
	
	rc = Avr32SpiBus0Select(&my_node, NUT_WAIT_INFINITE);
    if (rc == 0) {
        rc =  Avr32SpiBus0Transfer(&my_node, buf, NULL, len);
    }
	Avr32SpiBus0Deselect(&my_node);
    return rc;
}

int main(void)
{
	
	uint8_t *tx;
	
	tx = (uint8_t*) malloc(10);
	
	int i = 0;
	
	MyInit();
	
	for(i=0;i<10;i++){						//SPI BUFFER
		tx[i] = 0xAA;
	}
	
	for(;;){
	
		MyTransfer(tx,10);
		
	 }
		
	return 0;		
}

Kind Regards 
Philippgl





--
View this message in context: http://microcontrollers.2385.n7.nabble.com/EVK1100-SPI-Slave-tp192311p192404.html
Sent from the MicroControllers - Ethernut mailing list archive at Nabble.com.


More information about the En-Nut-Discussion mailing list