Merge pull request #16 from veritazz/master

Fix compilation issue and add displayPrefetch function
This commit is contained in:
Mr.Blinky 2022-02-10 19:58:35 +01:00 committed by GitHub
commit db243c954c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 1 deletions

View File

@ -695,3 +695,50 @@ uint32_t FX::readIndexedUInt32(uint24_t address, uint8_t index)
seekDataArray(address, index, 0, sizeof(uint24_t)); seekDataArray(address, index, 0, sizeof(uint24_t));
return readPendingLastUInt32(); return readPendingLastUInt32();
} }
void FX::displayPrefetch(uint24_t address, uint8_t* target, uint16_t len, bool clear)
{
seekData(address);
asm volatile
( "dbg:\n"
" ldi r30, lo8(%[sbuf]) \n" // uint8_t* ptr = Arduboy2::sBuffer;
" ldi r31, hi8(%[sbuf]) \n"
" ldi r25, hi8(%[end]) \n"
" in r0, %[spsr] \n" // wait(); //for 1st target data recieved (can't enable OLED mid transfer)
" sbrs r0, %[spif] \n"
" rjmp .-6 \n"
" cbi %[csport], %[csbit] \n" // enableOLED();
"1: \n" // while (true) {
" ld r0, Z ;2 \ \n" // uint8_t displaydata = *ptr;
" in r24, %[spdr] ;1 /3 \n" // uint8_t targetdata = SPDR;
" out %[spdr], r0 ;1 \ \n" // SPDR = displaydata;
" cpse %[clear], r1 ;1-2 \n" // if (clear) displaydata = 0;
" mov r0, r1 ;1 \n"
" st Z+, r0 ;2 \n" // *ptr++ = displaydata;
" subi %A[len], 1 ;1 \n" // if (--len >= 0) *target++ = targetdata;
" sbci %B[len], 0 ;1 \n"
" brmi 3f ;1-2 \n" // branch ahead and back to 2 to burn 4 cycles
" nop ;1 \n"
" st %a[target]+, r24 ;2 /11 \n"
"2: \n"
" cpi r30, lo8(%[end]) ;1 \ \n" // if (ptr >= Arduboy2::sBuffer + WIDTH * HEIGHT / 8) break;
" cpc r31, r25 ;1 \n"
" brcs 1b ;1-2/4 \n" // }
"3: \n"
" brmi 2b ;1-2 \n" // branch only when coming from above brmi
: [target] "+e" (target),
[len] "+d" (len)
: [sbuf] "" (Arduboy2::sBuffer),
[end] "" (Arduboy2::sBuffer + WIDTH * HEIGHT / 8),
[clear] "r" (clear),
[spsr] "I" (_SFR_IO_ADDR(SPSR)),
[spif] "I" (SPIF),
[spdr] "I" (_SFR_IO_ADDR(SPDR)),
[csport] "I" (_SFR_IO_ADDR(CS_PORT)),
[csbit] "I" (CS_BIT)
: "r24", "r25", "r30", "r31"
);
disableOLED();
disable();
SPSR;
}

View File

@ -125,6 +125,8 @@ class FX
static uint8_t readByte(); //read a single byte from flash memory static uint8_t readByte(); //read a single byte from flash memory
static void displayPrefetch(uint24_t address, uint8_t* target, uint16_t len, bool clear);
static void begin(); // Initializes flash memory. Use only when program does not require data and save areas in flash memory static void begin(); // Initializes flash memory. Use only when program does not require data and save areas in flash memory
static void begin(uint16_t programDataPage); // Initializes flash memory. Use when program depends on data in flash memory static void begin(uint16_t programDataPage); // Initializes flash memory. Use when program depends on data in flash memory
@ -201,7 +203,7 @@ class FX
static void readDataArray(uint24_t address, uint8_t index, uint8_t offset, uint8_t elementSize, uint8_t* buffer, size_t length); static void readDataArray(uint24_t address, uint8_t index, uint8_t offset, uint8_t elementSize, uint8_t* buffer, size_t length);
static uint16_t readIndexedUInt8(uint24_t address, uint8_t index); static uint8_t readIndexedUInt8(uint24_t address, uint8_t index);
static uint16_t readIndexedUInt16(uint24_t address, uint8_t index); static uint16_t readIndexedUInt16(uint24_t address, uint8_t index);