Modifying board definitions corectly
Posted: Wed Sep 28, 2022 12:19 pm
Hello,
I am developing a custom board based on stm32F030CCTx chip. I have generated a custom board variant in STM32duino and it works ok. My main goal is to use all 6 uarts that the chip offers. But due to an unrelated issue i can not use this board because a library does not play well with it.
Therefore i have opted to use the built in board stm32F030C8Tx , which is almost identical other then the fact that that chip only has 2 USARTS.
All my code is compatible between both of them (other then the USART part) and if i compile the code for this chip the library plays nicely.
So i am trying to modify the board definition files so that i can use all 6 USARTS on the chip, while still compiling for stm32F030C8Tx (since the library likes that better).
I have been modifying the files in \AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.3.0\variants\STM32F0xx\F030C8T
So far i have edited the ParipheralPins.c file so that it is the same as that of stm32F030CCTx, but the compiler still spews out errors:
error: 'USART3' undeclared here (not in a function); did you mean 'USART1'?
'GPIO_AF4_USART3' undeclared here (not in a function); did you mean 'GPIO_AF1_USART1'?
My question is how do i modify the files so that i can add more USARTS?
here is the simple code i am using to test usart functionality:
#include <HardwareSerial.h>
HardwareSerial Serial_MODBUS_S1(USART1);
HardwareSerial Serial_mbus_1(USART2);
HardwareSerial Serial_MODBUS_M2(USART3);
HardwareSerial Serial_MODBUS_S2(USART4);
HardwareSerial Serial_mbus_2(USART5);
HardwareSerial Serial_MODBUS_M1(USART6);
int BAUD1 = 9600;
int BAUD2 = 9600;
int BAUD3 = 9600;
int BAUD4 = 9600;
int BAUD5 = 9600;
int BAUD6 = 9600;
void setup() {
Serial_MODBUS_S1.begin(BAUD1);
Serial_MODBUS_S2.begin(BAUD2);
Serial_MODBUS_M1.begin(BAUD3);
Serial_MODBUS_M2.begin(BAUD4);
Serial_mbus_1.begin(BAUD5);
Serial_mbus_2.begin(BAUD6);
}
void loop() {
Serial_MODBUS_M1.println("Serial_MODBUS_M1:");
Serial_MODBUS_M2.println("Serial_MODBUS_M2:");
Serial_mbus_1.println("Serial_mbus_1:");
Serial_mbus_2.println("Serial_mbus_2");
Serial_MODBUS_S2.println("Serial_MODBUS_S2");
Serial_MODBUS_S1.println("Serial_MODBUS_S1");
delay(1000);
}
This works good when compiled for stm32F030CCTx board bot cant compile for stm32F030C8Tx
I am developing a custom board based on stm32F030CCTx chip. I have generated a custom board variant in STM32duino and it works ok. My main goal is to use all 6 uarts that the chip offers. But due to an unrelated issue i can not use this board because a library does not play well with it.
Therefore i have opted to use the built in board stm32F030C8Tx , which is almost identical other then the fact that that chip only has 2 USARTS.
All my code is compatible between both of them (other then the USART part) and if i compile the code for this chip the library plays nicely.
So i am trying to modify the board definition files so that i can use all 6 USARTS on the chip, while still compiling for stm32F030C8Tx (since the library likes that better).
I have been modifying the files in \AppData\Local\Arduino15\packages\STMicroelectronics\hardware\stm32\2.3.0\variants\STM32F0xx\F030C8T
So far i have edited the ParipheralPins.c file so that it is the same as that of stm32F030CCTx, but the compiler still spews out errors:
error: 'USART3' undeclared here (not in a function); did you mean 'USART1'?
'GPIO_AF4_USART3' undeclared here (not in a function); did you mean 'GPIO_AF1_USART1'?
My question is how do i modify the files so that i can add more USARTS?
here is the simple code i am using to test usart functionality:
#include <HardwareSerial.h>
HardwareSerial Serial_MODBUS_S1(USART1);
HardwareSerial Serial_mbus_1(USART2);
HardwareSerial Serial_MODBUS_M2(USART3);
HardwareSerial Serial_MODBUS_S2(USART4);
HardwareSerial Serial_mbus_2(USART5);
HardwareSerial Serial_MODBUS_M1(USART6);
int BAUD1 = 9600;
int BAUD2 = 9600;
int BAUD3 = 9600;
int BAUD4 = 9600;
int BAUD5 = 9600;
int BAUD6 = 9600;
void setup() {
Serial_MODBUS_S1.begin(BAUD1);
Serial_MODBUS_S2.begin(BAUD2);
Serial_MODBUS_M1.begin(BAUD3);
Serial_MODBUS_M2.begin(BAUD4);
Serial_mbus_1.begin(BAUD5);
Serial_mbus_2.begin(BAUD6);
}
void loop() {
Serial_MODBUS_M1.println("Serial_MODBUS_M1:");
Serial_MODBUS_M2.println("Serial_MODBUS_M2:");
Serial_mbus_1.println("Serial_mbus_1:");
Serial_mbus_2.println("Serial_mbus_2");
Serial_MODBUS_S2.println("Serial_MODBUS_S2");
Serial_MODBUS_S1.println("Serial_MODBUS_S1");
delay(1000);
}
This works good when compiled for stm32F030CCTx board bot cant compile for stm32F030C8Tx