use of SPI2 on SPI- or Ethernet lib

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
Ralf9
Posts: 33
Joined: Sat Jan 11, 2020 7:21 pm
Answers: 1
Location: Germany, BaWü

use of SPI2 on SPI- or Ethernet lib

Post by Ralf9 »

Hi,

is there a possibility to use on Maple Mini SPI2 on the SPI- or Ethernet library?

I don't find any way at the SPI- or Ethernet library, how I can specify that I want use SPI2

Thank you
Ralf
User avatar
fpiSTM
Posts: 1754
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: use of SPI2 on SPI- or Ethernet lib

Post by fpiSTM »

Ralf9
Posts: 33
Joined: Sat Jan 11, 2020 7:21 pm
Answers: 1
Location: Germany, BaWü

Re: use of SPI2 on SPI- or Ethernet lib

Post by Ralf9 »

With this it works with the pins of SPI2

Code: Select all

	#define csPin	31
	#define mosiPin 28   // MOSI out
	#define misoPin 29   // MISO in
	#define sckPin  30   // SCLK out
	
	SPI.setMISO(misoPin);
	SPI.setMOSI(mosiPin);
	SPI.setSCLK(sckPin);
	SPI.begin(); //Initialize the SPI port.
	SPI.setBitOrder(MSBFIRST);
	SPI.setDataMode(SPI_MODE0);
	SPI.setClockDivider(SPI_CLOCK_DIV16);      // Slow speed (72 / 4 = 4.5 MHz SPI speed)
When I try this

Code: Select all

	#include <SPI.h>
	SPIClass SPI2(mosiPin, misoPin, sckPin);
I become on the Arduino IDE the follow Errors

Code: Select all

/home/ralf/.arduino15/packages/STM32/hardware/stm32/1.8.0/system/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:654:43: error: expected ')' before '*' token
  654 | #define SPI2                ((SPI_TypeDef *)SPI2_BASE)
      |                              ~            ^
sketch/cc1101.h:18:11: note: in expansion of macro 'SPI2'
   18 |  SPIClass SPI2(mosiPin, misoPin, sckPin);
      |           ^~~~
/home/ralf/.arduino15/packages/STM32/hardware/stm32/1.8.0/system/Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h:654:43: error: expected ')' before '*' token
  654 | #define SPI2                ((SPI_TypeDef *)SPI2_BASE)
      |                             ~             ^
sketch/cc1101.h:18:11: note: in expansion of macro 'SPI2'
   18 |  SPIClass SPI2(mosiPin, misoPin, sckPin);
      |           ^~~~
I want use cc1101 Modules on SPI2 and a W5500 Lan Modul on SPI1


My sketch should work too on an existing hardware with the cc1101 Modules on SPI1 and the Lan Modul on SPI2.

Ist there a a possibility to use the W5500 Lan Modul on SPI2?
User avatar
fpiSTM
Posts: 1754
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: use of SPI2 on SPI- or Ethernet lib

Post by fpiSTM »

You couldn't call your SPI2 instance SPI2 because it is a CMSIS definition.
So call it SPI_2 for example.
Post Reply

Return to “General discussion”