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 too. So I have to specify the name on the pins for each chip board. But I want to learn the basics of how to write these statements.
Could you tell me where to find the attributions for each board ?
For now I want to define the pin names for the Atmega328p and maple mini. This is my intention:
#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 don't think that's %100 correct, but I'm pretty sure that it's not the correct names of boards.
2 Answers 2
The Arduino defines to identify a board are in form of ARDUINO_<board>
, where <board>
is the value from <x>.build.board
from boards.txt for board <x>
For example for Arduino AVR boards, in the boards.txt file is uno.build.board=AVR_UNO
so the define is ARDUINO_AVR_UNO
.
And Arduino has 'architecture' identification define too. This has form of ARDUINO_ARCH_<arch.name>
. The <arch.name>
is the uppercase version of the folder name with the boards package version. For example AVR for packages/arduino/hardware/avr/1.6.21.
-
But I want the specific attribution that are like in this link. @microchip.com/webdoc/avrlibcreferencemanual/… I want the same for the STM32 I couldn't find its attribution.R1S8K– R1S8K2020年03月10日 16:44:45 +00:00Commented Mar 10, 2020 at 16:44
-
1@R1S8K, use arduino board or architecture identification, not the chip identification.2020年03月10日 17:46:02 +00:00Commented Mar 10, 2020 at 17:46
-
OK but I get now fatal error that including the avr/io ..
Arduino: 1.8.12 (Windows 10), Board: "Maple Mini, Original (17k RAM,108k Flash), 72MHz (Normal), Smallest (default)" H:\Programming\Program_Files\Arduino\libraries\lcd128x64_spi\lcd128x64_spi.cpp:14:20: fatal error: avr/io.h: No such file or directory #include <avr/io.h> ^ compilation terminated. exit status 1 Error compiling for board Maple Mini. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.
What to do now ?R1S8K– R1S8K2020年03月10日 17:52:55 +00:00Commented Mar 10, 2020 at 17:52 -
1@R1S8K, ask a new question2020年03月10日 17:54:35 +00:00Commented Mar 10, 2020 at 17:54
-
1@R1S8K, instead of
__AVR_ATmega328P__
useARDUINO_AVR_UNO
for pin mapping defines2020年03月12日 05:09:35 +00:00Commented Mar 12, 2020 at 5:09
If you are working on Maple Mini, you may look in this folder, you will found the pin mapping between STM32 and Arduino nomenclature.
-
Yep, you're right. I didn't notice the rest of the name ! I thought they are just STM chips but I found the maple mini folder there, but also couldn't find the right attribution.R1S8K– R1S8K2020年03月10日 17:51:41 +00:00Commented Mar 10, 2020 at 17:51
-
1I don't get what you are looking for: is not enough this {&gpiob, NULL, NULL, 11, 0, ADCx}, /* D0/PB11 */ ?fabianoriccardi– fabianoriccardi2020年03月10日 18:04:03 +00:00Commented Mar 10, 2020 at 18:04
-
Maybe the official repo is cleaner: look at this filefabianoriccardi– fabianoriccardi2020年03月10日 18:11:49 +00:00Commented Mar 10, 2020 at 18:11
-
1try this define, for me it worked ;) ARDUINO_MAPLEMINI_F103CBfabianoriccardi– fabianoriccardi2020年03月10日 20:29:19 +00:00Commented Mar 10, 2020 at 20:29
-
1Which Arduino Core are you using? I had installed this onefabianoriccardi– fabianoriccardi2020年03月10日 20:47:09 +00:00Commented Mar 10, 2020 at 20:47
void lcd128x64_init(void){ pinMode(CS_PIN, OUTPUT); pinMode(CLK_PIN, OUTPUT); pinMode(MOSI_PIN, OUTPUT); digitalWrite(CS_PIN, LOW); // disable CS_PIN SPI.begin(); _delay_ms(100); // initial delay digitalWrite(CS_PIN, HIGH); // enable CS_PIN ... }
the pins names are different, so I want to unify them in the header file.SPI_2.begin(); //Initialize the SPI_2 port. SPI_2.setBitOrder(MSBFIRST); // Set the SPI_2 bit order SPI_2.setDataMode(SPI_MODE0); //Set the SPI_2 data mode 0 SPI_2.setClockDivider(SPI_CLOCK_DIV16); // Use a different speed to SPI 1 pinMode(SPI2_NSS_PIN, OUTPUT);
so I have put that in my lcd128x64 libArduino: 1.8.12 (Windows 10), Board: "Maple Mini, Original (17k RAM,108k Flash), 72MHz (Normal), Smallest (default)" H:\Programming\Program_Files\Arduino\libraries\lcd128x64_spi\lcd128x64_spi.cpp:14:20: fatal error: avr/io.h: No such file or directory #include <avr/io.h> ^ compilation terminated. exit status 1 Error compiling for board Maple Mini. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.