Hi,
I'm working on lcd128x64 spi library. And was working with my Arduino Atmega328p chip.
Now I want to run the code with my maple mini board.
So I have to differentiate the name on the pins for each chip. I find these statements in big libraries that supports different chips.
But I want to learn the basics of how to write these statements.
First of all, this is an example from SPI.CPP for Arduino core libraries.
// mapping of interrupt numbers to bits within SPI_AVR_EIMSK
#if defined(__AVR_ATmega32U4__)
#define SPI_INT0_MASK (1<<INT0)
#define SPI_INT1_MASK (1<<INT1)
#define SPI_INT2_MASK (1<<INT2)
#define SPI_INT3_MASK (1<<INT3)
#define SPI_INT4_MASK (1<<INT6)
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
#define SPI_INT0_MASK (1<<INT0)
#define SPI_INT1_MASK (1<<INT1)
#define SPI_INT2_MASK (1<<INT2)
#define SPI_INT3_MASK (1<<INT3)
#define SPI_INT4_MASK (1<<INT4)
#define SPI_INT5_MASK (1<<INT5)
#define SPI_INT6_MASK (1<<INT6)
#define SPI_INT7_MASK (1<<INT7)
#elif defined(EICRA) && defined(EICRB) && defined(EIMSK)
#define SPI_INT0_MASK (1<<INT4)
#define SPI_INT1_MASK (1<<INT5)
#define SPI_INT2_MASK (1<<INT0)
#define SPI_INT3_MASK (1<<INT1)
#define SPI_INT4_MASK (1<<INT2)
#define SPI_INT5_MASK (1<<INT3)
#define SPI_INT6_MASK (1<<INT6)
#define SPI_INT7_MASK (1<<INT7)
#else
#ifdef INT0
#define SPI_INT0_MASK (1<<INT0)
#endif
#ifdef INT1
#define SPI_INT1_MASK (1<<INT1)
#endif
#ifdef INT2
#define SPI_INT2_MASK (1<<INT2)
#endif
#endif
What I want to do is similar, so it should be like this:
- I found in STM32 spi examples the pin locations for each spi module.
/* Using the second SPI port (SPI_2)
SS <--> PB12 <--> BOARD_SPI2_NSS_PIN
SCK <--> PB13 <--> BOARD_SPI2_SCK_PIN
MISO <--> PB14 <--> BOARD_SPI2_MISO_PIN
MOSI <--> PB15 <--> BOARD_SPI2_MOSI_PIN
*/
So I guess depending on the type of STM chip that specifies that it's the on used on maple mini which is stm32f103.
So I found in stm32.h this definition but I don't know if it specifies that it's the chip on the maple mini.
There's a main definition for stm32f1 series, then after that it defines the different chips in that series.
#if defined(__AVR_ATmega328P__)
#define CS_PIN 10
#define MOSI_PIN 11
#define CLK_PIN 13
#elif defined(STM32_SERIES_F1)
#define CS_PIN PB12
#define MOSI_PIN PB15
#define CLK_PIN PB13
#endif
I'm pretty sure that the names I used aren't correct. I even didn't encounter this line:
#if defined(__AVR_ATmega328P__)
I wrote it myself.
When I get to the part of defining different chips, they mention chips other than the Atmega328p, why ? Is the Atmega328p the default one ?
Any suggestions ?