示例#1
0
inline static void _draw_char(int c, uint32_t x, uint32_t y, uint16_t fore, uint16_t back) {
	uint32_t i, j;
	uint8_t line;
	unsigned char *p = (unsigned char *) cp437_font + (c * (int) FONT_CHAR_H);

	uint16_t buffer[FONT_CHAR_H * FONT_CHAR_W];
	uint16_t *q = buffer;

	for (i = 0; i < FONT_CHAR_H; i++) {
		line = (uint8_t) *p++;
		for (j = 0; j < FONT_CHAR_W; j++) {
			if ((line & 0x1) != 0) {
				*q = __builtin_bswap16(fore);
			} else {
				*q = __builtin_bswap16(back);
			}
			line >>= 1;
			q++;
		}
	}

	write_command(0x2A);
	write_data_word(x);
	write_data_word(x + FONT_CHAR_H - 1);
	write_command(0x2B);
	write_data_word(y);
	write_data_word(y + FONT_CHAR_W - 1);
	write_command(0x2C);

	bcm2835_spi_writenb((char *) buffer, 2 * FONT_CHAR_H * FONT_CHAR_W);
}
示例#2
0
void ili9340_clear(void) {
	write_command(0x2A);
	write_data_word(0);
	write_data_word(239);
	write_command(0x2B);
	write_data_word(0);
	write_data_word(319);
	write_command(0x2C);

	bcm2835_spi_writenb((char *) buffer, 2 * ILI9340_HEIGHT * ILI9340_WIDTH);
}
示例#3
0
void ili9340_draw_pixel(uint16_t x, uint16_t y, uint16_t color) {
	if (x >= ILI9340_HEIGHT)
		return;

	if (y >= ILI9340_WIDTH)
		return;

	write_command(0x2A);
	write_data_word(x);
	write_data_word(x);
	write_command(0x2B);
	write_data_word(y);
	write_data_word(y);
	write_command(0x2C);
	write_data_word(color);
}
示例#4
0
//-----------------------------------------------------------------------------
int do_lpc_stuff ( int erase_all )
{
    unsigned int ra,rb,rc;
    unsigned int ramadd;
    unsigned int romadd;
    unsigned int romsec;

    if(lpc_isp_synchronize()) return(1);

    //ra=0;
    //sdata[ra++]='J';
    //sdata[ra++]=0x0D;
    //ser_senddata(sdata,ra);
    //watch_for();

    //ra=0;
    //sdata[ra++]='K';
    //sdata[ra++]=0x0D;
    //ser_senddata(sdata,ra);
    //watch_for();



    //Turn off echo
    ra=0;
    sdata[ra++]='A';
    sdata[ra++]=' ';
    sdata[ra++]='0';
    sdata[ra++]=0x0D;
    sdata[ra++]=0x0A;
    ser_senddata(sdata,ra);
    if(sync_wait_for(sdata,ra-1)) return(1);
    //----
    //the ra-1 is so that everything from the chip is 0x0A...stuff...0x0D
    //----
    if(get_return_code()) return(1);
    //Unlock
    ra=0;
    sdata[ra++]='U';
    sdata[ra++]=' ';
    sdata[ra++]='2';
    sdata[ra++]='3';
    sdata[ra++]='1';
    sdata[ra++]='3';
    sdata[ra++]='0';
    sdata[ra++]=0x0D;
    ser_senddata(sdata,ra);
    if(get_return_code()) return(1);

    ////write program to ram and run from ram
    //rb=0x40000200;
    //for(ra=0;ra<bin_length;ra++)
    //{
        //if(write_data_word(rb,bin_data[ra])) return(1);
        //rb+=4;
    //}
    //sprintf((char *)sdata,"G %u A\r",0x40000200);
    //ra=strlen((char *)sdata);
    //ser_senddata(sdata,ra);
    ////if(get_return_code()) return(1);

    if(erase_all)
    {
        printf("Erase All\n");
        if(flash_erase_all())
        {
            printf("flash_erase_all() failed\n");
            return(1);
        }
    }

    //write program to flash

    printf("Programming 0x%04X bytes to flash\n",fdatalen<<2);

    //patch vector table, first 0x20 bytes worth of words need to add to zero
    fdata[0x14>>2]=0x0;
    rc=0; for(ra=0;ra<0x20;ra+=4) rc+=fdata[ra>>2];
    rc=-rc;
    fdata[0x14>>2]=rc;

    printf("0x%08X\n",fdata[0]);


    romadd=0x00000000;
    //ramadd=0x40000200;
    for(ra=0;ra<fdatalen;ra+=64)
    {
        romsec=romadd>>12; //armmite uses 4KB sectors
        if((romadd&0xFFF)==0) //armmite uses 4KB sectors
        {
            printf("\nErasing 0x%04X\n",romadd);

            sprintf((char *)sdata,"P %u %u\r",romsec,romsec);
            ser_senddata(sdata,strlen((char *)sdata));
            if(get_return_code()) return(1);

            sprintf((char *)sdata,"E %u %u\r",romsec,romsec);
            ser_senddata(sdata,strlen((char *)sdata));
            if(get_return_code()) return(1);
            ramadd=0x40000200;
        }

        printf("\nProgramming 0x%04X\n",romadd);

        rc=ramadd;
        for(rb=0;rb<64;rb++) //256 bytes per copy
        {
            if(write_data_word(rc,fdata[ra+rb])) return(1);
            rc+=4;
        }

        sprintf((char *)sdata,"P %u %u\r",romsec,romsec);
        ser_senddata(sdata,strlen((char *)sdata));
        if(get_return_code()) return(1);

        sprintf((char *)sdata,"C %u %u 256\r",romadd,ramadd);
        ser_senddata(sdata,strlen((char *)sdata));
        if(get_return_code()) return(1);

        romadd+=256;
        ramadd+=256;
    }

    printf("\n====\n");
    while(1)
    {
        rb=ser_copystring(rdata);
        for(ra=0;ra<rb;ra++)
        {
            printf("0x%02X ",rdata[ra]);
            if((rdata[ra]>=0x20)&&(rdata[ra]<127)) printf("[%c]",rdata[ra]);
            printf("\n");
        }
        ser_dump(rb);
    }

    return(0);
}