Re: SPI Documentation

bon-1JbLm1bU5j5ZIx36JBfelj3+ndqKAYMe9FMPySWZwLkb1SvskN2V4Q@public.gmane.org Fri, 3 Apr 2020 15:35:20 +0200
Newsgroups gmane.comp.hardware.microcontrollers.ethernut
Message-ID <[email protected]>
Nikolas Becker writes:
> Hi guys,
> 
> I'm working now with my ethernut5 and the TCP/IP-functionality is just so nice working out of the box, very happy with it.
> 
> Now I need to read data from several ADCs via SPI. And here comes my problem: where can I find some documentation for the SPI device driver? 
> 
> In the Nut/OS Software manual 
> http://www.ethernut.de/pdf/enswm28e.pdf
>  there are some lines regarding SPI on page 45, suggesting the use of NutRegisterSpiDevice(), but not much more.
> 
> In the Nut/OS wiki, I found this article:
> http://www.ethernut.de/nutwiki/index.php/Documents/NTN-6_SPI
> Which gives some examples for using the SPI and are very similar to the usage here:
> http://www.ethernut.de/nutwiki/index.php/SPI
> So I tried this:
> 
> #define NUMBER_OF_CHANNELS				4
> #define ADC_CONV_PIN 					3
> #define ADC_CONV_PORT 					NUTGPIO_PORTB
> 
> NUTSPINODE adc_node = {&spiBus0At91, NULL, 45158500, 0, (NUMBER_OF_CHANNELS*32), 0};
Hello Nikolas,

the initialisation seem fishy. In 2020, is good habit to use modern C
struct initialization like:

NUTSPINODE spi_node = {
    .node_bus  =  &DEF_SPIBUS,
    .node_stat = NULL,
    .node_rate = 1000000,
    .node_mode = SPI_MODE_0,
    .node_bits = 8,
    .node_cs = 0,
    .node_dcb = NULL,
};

.node_bits seems not good in your code. Most SPI IP transfers in units
of 8 bits. But even if the IP can do more, Ethernut device driver must
support it and I am not sure about Atmel. I use Stm32.

Otherwise, I am still missing exact error output from the problem you
had last week. We help you, you help us...

Bye
-- 
Uwe Bonnes                bon-1JbLm1bU5j5ZIx36JBfelj3+ndqKAYMe9FMPySWZwLkb1SvskN2V4Q@public.gmane.org

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion