[En-Nut-Discussion] using SPI Controller of AT91SAM7X

Dominik Schröder dominik.schroeder at bh-informativ.de
Thu Mar 11 16:37:33 CET 2010


Dear Harald

I am just working with this page. Here my complete code to init the OLED:

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

char init_OLED(void)
{
	int rc;
	
	printf("Initialisiere OLED...\n");
	//Power ON sequence
	GpioPinSetLow(OUTBANK_A, DISP_RESET);
	NutSleep(5);
	GpioPinSetHigh(OUTBANK_A, DISP_RESET);
	NutSleep(5);
	GpioPinSetHigh(OUTBANK_A, DISP_VCC);
	NutSleep(50);
	
	rc = (*spiBus0Gpio.bus_initnode) (&OLED_node);
	if(rc == 0)
	{
		NutEventPost(&spiBus0Gpio.bus_mutex);
	}
	
	GpioPinSetHigh(OUTBANK_A, OLED_DC);
	
	rc = (*spiBus0Gpio.bus_alloc) (&OLED_node, 1000);
    if (rc == 0) {
        rc = (*spiBus0Gpio.bus_transfer) (&OLED_node, 0xFF, 0x00, 1);
    }
    (*spiBus0Gpio.bus_release) (&OLED_node);

	return 0;
}

In function "init_OLED" I only try to send 0xFF via the SPI Bus. But I cant
see any clock/data...
Can you see where the Problem is with this code?
Later I need to access 2 SPI nodes (SPI-Flash and OLED). Is that also
possible with this kind of low level bus access?

Best regards

Dominik Schröder

-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] Im Auftrag von Harald Kipp
Gesendet: Donnerstag, 11. März 2010 16:02
An: Ethernut User Chat (English)
Betreff: Re: [En-Nut-Discussion] using SPI Controller of AT91SAM7X

Dominik Schröder wrote:

> I want to use the SPI controller of my AT91SAM7X to communicate with an
OLED
> Display. I haven’t found some good information about which steps are
needed
> to get the SPI device working
 L

Will this page help
http://www.ethernut.de/en/documents/ntn-6_spi.html
?

Beside that, you can always directly access the SPI registers of the
SAM7X, which is typically easier than implementing a Nut/OS SPI Node Driver.

The advantage of the Nut/OS driver is, however, that the SPI bus can be
shared among several SPI devices.

Harald


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list