Here I'll let some experiments with bare metal in AVR microcontrollers.
In this repository, all the examples and stuff will be exclusively to ATmega328P (which is a microcontroller from AVR family) and Arduino Uno.
The code here are focused to re-create the functions provided by the Arduino Library, such as pinMode, digitalWrite, digitalRead, delay, etc. The examples in examples dir use those functions.
set_pin_mode(): sets the pin mode (INPUTorOUTPUT).digital_write(): writesLOWorHIGHin the given pin.digital_read(): readsLOWorHIGHfrom the given pin.delay_ms(): delays in the given ms.delay_us(): delays in the given us.uart_init(): initializes the UART with the given baudrate.uart_sendbyte(): sends a byte through UART.uart_recvbyte(): receives a byte through UART.uart_puts(): sends a string through UART.uart_gets(): receives a string through UART.
Firstly, you'll need these tools:
Compiling the standard lib and the examples:
makeAfter that, you can upload the examples inside the build/examples/ dir:
./upload [SERIALPORT] build/examples/*.bin
SERIALPORT is platform dependent, but in my case is something like
/dev/ttyUSB0.
Any .bin in
build/examplescan be uploaded, but check and modify the code inexamplesif necessary.
Remember: only works on ATmega328P
- Delay functions with internal timers
- UART support