Created
April 11, 2021 11:08
-
-
Save nerdralph/891fba0d06a874c024ef012a77e2b38a to your computer and use it in GitHub Desktop.
avr-gcc extern __flash array bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
extern __flash const uint8_t digital_pin_to_bit_mask_PGM[]; | |
uint8_t read_array(uint8_t i) | |
{ | |
return digital_pin_to_bit_mask_PGM[i]; // bug: uses ld | |
// return *(digital_pin_to_bit_mask_PGM + i); // uses lpm | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setup() { | |
// put your setup code here, to run once: | |
} | |
extern "C" uint8_t read_array(uint8_t index); | |
void loop() { | |
// put your main code here, to run repeatedly: | |
PORTB = read_array(PINB); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment