Skip to content

Instantly share code, notes, and snippets.

@nmk456
Created April 22, 2020 18:05
Show Gist options
  • Save nmk456/159b37fcaf441d5d9612e707b68140bd to your computer and use it in GitHub Desktop.
Save nmk456/159b37fcaf441d5d9612e707b68140bd to your computer and use it in GitHub Desktop.
#include <Arduino.h>
#define clk_out 10
#define clk_in 9
uint8_t data;
unsigned long count;
elapsedMillis time;
inline uint8_t readPixel() {
return (GPIO6_PSR & 0b00000000'00000000'00000000'00001100) >> 2 | // 1, 0
(GPIO6_PSR & 0b00000000'00001111'00000000'00000000) >> 14 | // 19, 18, 14, 15
(GPIO6_PSR & 0b00001100'00000000'00000000'00000000) >> 20; // 20, 21
}
inline bool clk() {
return digitalReadFast(clk_in);
// return (CORE_PIN10_PINREG & CORE_PIN10_BITMASK) ? 1 : 0;
}
inline bool href() {
return 0;
}
inline bool vsync() {
return 0;
}
void setup() {
Serial.begin(115200);
while(!Serial);
pinMode(clk_out, OUTPUT);
pinMode(clk_in, INPUT);
analogWriteFrequency(clk_out, 50'000'000);
analogWrite(clk_out, 127);
Serial.println("Setup done.");
}
void loop() {
time = 0;
count = 0;
while(time < 1000) {
while(clk());
data = readPixel();
count++;
while(!clk());
}
Serial.println(count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment