The function below reads the image on the page using read_page (pageIter, pageArr, PAGESIZE) and outputs the data to the DOUT and CCLK pins.
I was told that this is inefficient, but I can’t find a way to do it faster. This is basically a pipe running on a 64-pin uProcessor, between two memory spaces. One holds the image, and the other receives the image.
I used the register keyword, removed the indexing of the array and replaced it with arithemetic, but it should be faster.
Thank!
#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80
#define PAGESIZE 1024
void copyImage(ulong startAddress, ulong endAddress)
{
ulong pageIter;
uchar *eByte, *byteIter, pageArr[PAGESIZE];
register uchar bitIter, portCvar;
portCvar = PORTC;
for(pageIter = startAddress ; pageIter <= endAddress ; pageIter += PAGESIZE)
{
read_page(pageIter, pageArr, PAGESIZE);
eByte = pageArr+PAGESIZE;
for(byteIter = pageArr; byteIter <= eByte; byteIter++)
{
for(bitIter = 0x01; bitIter != 0x00; bitIter = bitIter << 1)
{
PORTC = portCvar | BIT0;
(bitIter & *byteIter) ? (PORTC = portCvar & ~BIT7) : (PORTC = portCvar | BIT7);
PORTC = portCvar & ~BIT0;
}
}
}
}
user656925
source
share