2

I am using VS code, and have 2 Atmega2560 boards talking to each other. I am programming in pure C. Their .c and .h files are both found with in the src folder. I want to include an Uno R3 board as well. How do I set up the .h file or what do I include in the platformio.ini file? Here are the 3 snippets of code from the 3 locations. It is the UnoRobot that I am concerned with.

The .c file is

#include "UnoRobot.h"
#include "util/delay.h"
#include "avr/io.h"
int main(void){
while (1){
_delay_ms(100);
}
}

The .h file is

#ifndef CONTROLLER_H_ // double inclusion guard
#define CONTROLLER_H_
        
// Include standard libraries
#include "serial.h"
#include "adc.h"
#include "milliseconds.h"
#include "hd44780.h"
        
// Constants
#define BUILD_DATE __TIME__ " " __DATE__"\n"
        
// Dummy function declaration (add more later!)
void dummy_function(void);
        
#endif /* UNOROBOT_H_ */

And the .ini file is

[env:Controller]
platform = atmelavr
board = megaatmega2560
framework = arduino
monitor_port = COM7
monitor_speed = 115200
upload_port = com7
build_src_filter =
+<**/*.c>
-<Robot.c>
-<UnoRobot.c>
        
[env:Robot]
platform = atmelavr
board = megaatmega2560
framework = arduino
monitor_port = com3
monitor_speed = 115200
upload_port = com3
build_src_filter =
+<**/*.c>
-<Controller.c>
-<Robot.c>
-<UnoRobot.c>
        
[env:UnoRobot]
platform = atmelavr
board = uno
framework = arduino
monitor_port = com6
monitor_speed = 115200
upload_port = com6
build_src_filter =
+<**/*.c>
-<Robot.c>
-<Controller.c>
4
  • So what is your problem? Do you need to have several different source files depending on boards? Or do you not know how to define a section describing a robot a specify for what board this robot is? Please edit your question.
    – White Owl
    Commented Apr 19 at 12:50
  • I want to add an uno board to the existing set up that is using 2 atmega 2560 boards. I don't know how to set up some aspect of the system that recognises the uno
    – gavin
    Commented Apr 19 at 14:33
  • Any reason you're not using the official Arduino IDE? You could theoretically upload the same files to any board you wanted (with some limitations)
    – xingharvey
    Commented Apr 19 at 18:28
  • Yes... the boards are programmed in pure c, not in standard arduino c. Pure C doesn't recognise a lot of arduino standard language such as serial.println() and such. Pure C is more powerful and functional, but... so, so much more cumbersome and confusing
    – gavin
    Commented Apr 20 at 4:36

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.