[En-Nut-Discussion] SPI Documentation

bon at elektron.ikp.physik.tu-darmstadt.de bon at elektron.ikp.physik.tu-darmstadt.de
Fri Apr 3 15:35:20 CEST 2020


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 at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------


More information about the En-Nut-Discussion mailing list