Skip to content

Instantly share code, notes, and snippets.

@nerdralph
Created Apr 11, 2021
Embed
What would you like to do?
avr-gcc extern __flash array bug
#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
}
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