ISP example program.

Dependencies:   SLCD mbed USBLocalFileSystem

/media/uploads/va009039/lpc81isp-360x240.jpg

FRDM-KL46ZLPC810
UART RXDPTE23p2(P0_4)
UART TXDPTE22p8(P0_0)
nRESETD6p1(P0_5)
nISPD8p5(P0_1)
GNDGNDp7
3.3VP3V3p6

Copy binary image to the disk called LPC81ISP.
Push sw1 or sw3, start write to LPC810 flash.

src/utils.cpp

Committer:
va009039
Date:
2014-02-15
Revision:
0:ad2b1fc04955

File content as of revision 0:ad2b1fc04955:


// from lpcsp.c http://elm-chan.org/works/sp78k/lpcsp.zip

/* Create an uuencoded asciz string from a byte array */
void uuencode (
    const void* src,    /* Pointer to the input data */
    int srcsize,        /* Size of input data (0 to 45) */
    char* dst           /* Pointer to the output buffer */
)
{
    const unsigned char *bin = (const unsigned char*)src;
    unsigned char c1, c2, c3;
    char c;
    int cc;


    if (srcsize >= 0 || srcsize <= 45) {
        c = srcsize + 0x20;
        *dst++ = (c == ' ') ? '`' : c;

        for (cc = 1; srcsize > 0; srcsize -= 3, cc += 4) {
            c1 = *bin++;
            c2 = c3 = 0;
            if (srcsize >= 2) {
                c2 = *bin++;
                if (srcsize >= 3) {
                    c3 = *bin++;
                }
            }
            c = (c1 >> 2) + 0x20;
            *dst++ = (c == ' ') ? '`' : c;
            c = ((c1 & 3) << 4) + (c2 >> 4) + 0x20;
            *dst++ = (c == ' ') ? '`' : c;
            c = ((c2 & 15) << 2) + (c3 >> 6) + 0x20;
            *dst++ = (c == ' ') ? '`' : c;
            c = (c3 & 63) + 0x20;
            *dst++ = (c == ' ') ? '`' : c;
        }
    }
    *dst = 0;
}