Difference between revisions of "Events/2020/AVR"

From Hacksburg Wiki
< Events‎ | 2020
Jump to navigation Jump to search
(Godbolt 1)
(Godbolt 1)
Line 2: Line 2:
  
 
== Code Samples ==
 
== Code Samples ==
=== Godbolt 1 ===
+
#define __AVR_ATmega328P__
#define __AVR_ATmega328P__
+
 
+
#include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/stdlib.h"
#include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/stdlib.h"
+
#include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/avr/io.h"
#include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/avr/io.h"
+
#include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/avr/interrupt.h"
+
 
#define DIRECTION_PORT DDRB
+
#define DIRECTION_PORT DDRB
+
 
int main()
+
int main()
{
+
{
 
   const int DIRECTION_MASK = 0b00001110;
 
   const int DIRECTION_MASK = 0b00001110;
 
   uint8_t direction = 0b00001010;
 
   uint8_t direction = 0b00001010;
 
   // https://github.com/gnea/grbl/blob/master/grbl/stepper.c#L324
 
   // https://github.com/gnea/grbl/blob/master/grbl/stepper.c#L324
 
   DIRECTION_PORT = (DIRECTION_PORT & ~DIRECTION_MASK) | (direction & DIRECTION_MASK);
 
   DIRECTION_PORT = (DIRECTION_PORT & ~DIRECTION_MASK) | (direction & DIRECTION_MASK);
 +
  cli();
 +
  sei();
 
   return 0;
 
   return 0;
}
+
}

Revision as of 11:58, 24 January 2021

Have you ever wondered what a little Arduino is really capable of? Ever wanted to really understand a chip? Learn lots of nitty-gritty details about the Microchip AVR architecture, the processor architecture that powers the Arduino and many other products.

Code Samples

  1. define __AVR_ATmega328P__
  1. include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/stdlib.h"
  2. include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/avr/io.h"
  3. include "https://raw.githubusercontent.com/vancegroup-mirrors/avr-libc/master/avr-libc/include/avr/interrupt.h"
  1. define DIRECTION_PORT DDRB

int main() {

  const int DIRECTION_MASK = 0b00001110;
  uint8_t direction = 0b00001010;
  // https://github.com/gnea/grbl/blob/master/grbl/stepper.c#L324
  DIRECTION_PORT = (DIRECTION_PORT & ~DIRECTION_MASK) | (direction & DIRECTION_MASK);
  cli();
  sei();
  return 0;

}