Hi there. I’m a new user of PlatformIo and already programmed a few basic codes to my Teensy 3.5 board. People on reddit told me I could program the board bare metal in PlatformIo. Can I just write a main function and ignore the pre-made arduino functions like “loop”, “setup”, “digitalWrite” etc? If so, how can I write to peripherals? I’ve used AtmelStudio before and in there you could type the register name and assign values, I was hoping to find something similar here. Sorry if I posted in the wrong category.
Hi, yes! Just remove framework = arduino
line from platformio.ini
.
I’ve read somewhere that removing “framework = arduino” lets you write your code using a main function normally as you would in C. But one more question: How can I access the peripherals now? There will be no more digital/analog read/write. Is there any library for peripherals access? Where should I look for it?
Maybe I didn’t express myself in the best way. Let me rephrase it:
Can I IGNORE the arduino code, but let the START UP code in there so I dont have to write it all myself?
Not using the arduino functions but still not dealing with the system initialization?
Hi @StalkerRigo! There is a workaround for your case. You can skip the main function implemented in the framework by using an extra script, something like this:
platformio.ini:
[env:teensy35]
platform = teensy
framework = arduino
board = teensy35
extra_scripts = pre:extra_script.py
extra_script.py:
Import("env")
import os
# --- Skip main.cpp file from Arduino framework
def skip_arduino_main(node):
if node.srcnode().get_path().endswith(os.path.join("cores", "teensy3", "main.cpp")):
return None
return node
env.AddBuildMiddleware(skip_arduino_main)
So now you can implement your own main
function.