[En-Nut-Discussion] SW SPI bus reading data
Aigars
aigars at egle.cs.rtu.lv
Fri Sep 16 10:36:52 CEST 2016
On re configuring NutOS&rebuilding and adding to httpserv.c file:
NUTSPINODE my_node = {
&spiBus0Gpio, /* Pointer to the bus controller driver. */
NULL, /* Optional pointer to device specific settings. */
10000, /* SPI clock rate. */
3, /* SPI mode. */
8, /* SPI data bits. */
0, /* Chip select index. */
};
I get:
c:\ethernut-4.6.5\nutapp_charon2\httpd>make
avr-gcc -c -mmcu=atmega128 -Os -fno-delete-null-pointer-checks -Wall
-Wstrict-prototypes -Wa,-ahlms=httpserv.lst -DCHARON2 -D__HARVARD_ARCH__
-I../../nutbld_charon2/include -I../../nut/include httpserv.c -o httpserv.o
httpserv.c:259: error: expected '=', ',', ';', 'asm' or '__attribute__'
before 'my_node'
httpserv.c: In function 'NutAppMain':
httpserv.c:886: warning: no return statement in function returning non-void
make: *** [httpserv.o] Error 1
The same if I add your definition.
NUTSPINODE nodeIli9341_0 = {
NULL, /*!< \brief Pointer to the bus controller driver, node_bus. */
NULL, /*!< \brief Pointer to the bus device driver specific settings, node_stat. */
ILI9341_0_SPI_RATE, /*!< \brief Initial clock rate, node_rate. */
ILI9341_SPI_MODE, /*!< \brief Initial mode, node_mode. */
8, /*!< \brief Initial data bits, node_bits. */
FB0_CS_INDEX, /*!< \brief Chip select, node_cs. */
&ili9341_0_dcb, /*!< \brief Pointer to our private device control block, node_dcb. */
};
Is there something else I missed?
Without defining SPI device build is OK.
Aigars
On 2016.09.02. 12:38, Uwe Bonnes wrote:
>>>>>> "Aigars" == Aigars <aigars at egle.cs.rtu.lv> writes:
> Aigars> Hello. Is there some examples on how to read data from SPI
> Aigars> interface ? For given case I need to read temperature from
> Aigars> MAX6675 thermocouple attached to F port on 2.1B version
> Aigars> board. As I understand there is SW bitbanging possibility in
> Aigars> configuration, but wiki topic on SPI is little to complex for my
> Aigars> level...
>
> All those legacy SPI drivers make things hard to understand. It is also a
> pity that the Wiki is offline. The spibus
> driver is the most recent. For spibus do:
>
> -First, you need to define the pin settings for the bitbang driver. E.g.
> for the nucleo_l476rg board I have:
>
> SBBI0_CS0_PORT = "NUTGPIO_PORTA"
> SBBI0_CS0_PIN = "4"
> SBBI0_CS1_PORT = "NUTGPIO_PORTB"
> SBBI0_CS1_PIN = "5"
> SBBI0_SCK_PORT = "NUTGPIO_PORTA"
> SBBI0_SCK_PIN = "5"
> SBBI0_MISO_PORT = "NUTGPIO_PORT"
> SBBI0_MISO_PIN = "6"
> SBBI0_MOSI_PORT = "NUTGPIO_PORTA"
> SBBI0_MOSI_PIN = "7"
>
> Either do that in the <board>.conf file or use qnutconf
> Device Drivers-> Serial Bit Banged Interface 0
>
> - Now define your device, like
>
> /*!
> * \brief First ILI9341 LCD Controller SPI node implementation structure.
> */
> NUTSPINODE nodeIli9341_0 = {
> NULL, /*!< \brief Pointer to the bus controller driver, node_bus. */
> NULL, /*!< \brief Pointer to the bus device driver specific settings, node_stat. */
> ILI9341_0_SPI_RATE, /*!< \brief Initial clock rate, node_rate. */
> ILI9341_SPI_MODE, /*!< \brief Initial mode, node_mode. */
> 8, /*!< \brief Initial data bits, node_bits. */
> FB0_CS_INDEX, /*!< \brief Chip select, node_cs. */
> &ili9341_0_dcb, /*!< \brief Pointer to our private device control block, node_dcb. */
> };
>
> Register your device like:
> rc = NutRegisterSpiDevice(&DEV_FB, &DEF_SPIBUS, FB0_CS_INDEX);
>
> Now talk to your device lik
> rc = (*bus->bus_alloc) (node, 0);
> data[0] = LS0XX_CMD_CLEAR_ALL;
> data[1] = 0;
> data[2] = 0;
> data[3] = 0;
> if (rc == 0) {
> rc = (*bus->bus_transfer) (node, &data, NULL, 4);
> if (rc == 0) {
> (*bus->bus_wait) (node, NUT_WAIT_INFINITE);
> }
> (*bus->bus_release) (node);
> }
> return rc;
>
> I hope I did not miss anything. Please give feedback on Success/error.
>
> Bye
More information about the En-Nut-Discussion
mailing list