logic-analyzer
config_avr.h
1 #pragma once
2 #ifdef AVR
3 #include "Arduino.h"
4 #include "SoftwareSerial.h"
5 
6 #define MAX_CAPTURE_SIZE 500
7 #define SERIAL_SPEED 9600
8 #define SERIAL_TIMEOUT 500
9 #define MAX_FREQ 100000
10 #define MAX_FREQ_THRESHOLD 100000
11 #define START_PIN 0
12 #define PIN_COUNT sizeof(PinBitArray)*8
13 #define DESCRIPTION "Arduino-AVR"
14 
15 // Software Serial for logging
16 #define LOG soft_serial
17 #define RXD2 12
18 #define TXD2 13
19 
20 
21 namespace logic_analyzer {
22 
24 inline SoftwareSerial soft_serial(RXD2, TXD2); // RX, TX
25 
26 void setupLogger() {
27  LOG.begin(115200);
28 }
29 
31 typedef uint8_t PinBitArray;
32 
33 
40 class PinReader {
41  public:
42  PinReader(int startPin){
43  this->start_pin = startPin;
44  }
45 
47  inline PinBitArray readAll() {
48  uint16_t result = ((uint16_t)PORTB & B00111111) << 8 | PORTD;
49  return result >> start_pin;
50  }
51 
52  private:
53  int start_pin;
54 };
55 
56 
57 } // namespace
58 
59 #endif
60 
AVR specific implementation Logic for the PinReader.
Definition: config_avr.h:40
PinBitArray readAll()
reads all pins and provides the result as bitmask - PORTD:pins 0 to 7 / PORTB: pins 8 to 13
Definition: config_avr.h:47