Skip to content

Instantly share code, notes, and snippets.

@seebs
Created April 23, 2018 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seebs/848fb98ae05526195e73d08f74a37635 to your computer and use it in GitHub Desktop.
Save seebs/848fb98ae05526195e73d08f74a37635 to your computer and use it in GitHub Desktop.
- // read from teensy
- return
- (PINF&(1<<0) ? 0 : (1<<0)) |
- (PINF&(1<<1) ? 0 : (1<<1)) |
- (PINF&(1<<4) ? 0 : (1<<2)) |
- (PINF&(1<<5) ? 0 : (1<<3)) |
- (PINF&(1<<6) ? 0 : (1<<4)) |
- (PINF&(1<<7) ? 0 : (1<<5)) ;
+ /* read from teensy
+ * bitmask is 0b11110011, but we want those all
+ * in the lower six bits.
+ * we'll return 1s for the top two, but that's harmless.
+ */
+
+ return ~((PINF & 0x03) | ((PINF & 0xF0) >> 2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment