mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 20:59:42 +02:00
lpc111x-isp/lpc111x.c: define IO pins via array, not #defines
This commit is contained in:
parent
9ddc377969
commit
3b0c8c699e
@ -25,14 +25,6 @@
|
||||
#include <ubb/swuart.h>
|
||||
|
||||
|
||||
#define TGT_nRESET UBB_CMD
|
||||
#define TGT_nISP UBB_DAT1
|
||||
#define TGT_TX UBB_DAT3
|
||||
#define TGT_RX UBB_DAT2
|
||||
|
||||
#define HOST_RX TGT_TX
|
||||
#define HOST_TX TGT_RX
|
||||
|
||||
#define BPS 115200
|
||||
|
||||
#define MAX_BUF 10000 /* receive buffer */
|
||||
@ -53,6 +45,27 @@
|
||||
#define SECTOR 4096
|
||||
#define PAGE 256
|
||||
|
||||
|
||||
enum {
|
||||
pin_rxd, /* RXD pin on the device (PIO1_6) */
|
||||
pin_txd, /* TXD pin on the device (PIO1_7) */
|
||||
pin_nisp, /* nISP: ISP mode selection (PIO0_1) */
|
||||
pin_nreset, /* nRESET pin (PIO0_0) */
|
||||
pin_end /* last value */
|
||||
};
|
||||
|
||||
static struct pin {
|
||||
const char *name;
|
||||
const char *alt_name;
|
||||
uint32_t pin;
|
||||
} pin[] = {
|
||||
[pin_rxd] = { "RXD", "P1_6", UBB_DAT2 },
|
||||
[pin_txd] = { "TXD", "P1_7", UBB_DAT3 },
|
||||
[pin_nisp] = { "nISP", "P0_1", UBB_DAT1 },
|
||||
[pin_nreset] = { "nRESET", "P0_0", UBB_CMD },
|
||||
[pin_end] = { NULL }
|
||||
};
|
||||
|
||||
static int verbose = 0;
|
||||
static int quiet = 0;
|
||||
|
||||
@ -210,9 +223,9 @@ static int autobaud(void)
|
||||
const char *res;
|
||||
|
||||
for (i = 0; i != AUTOBAUD_TRIES; i++) {
|
||||
CLR(TGT_nRESET);
|
||||
CLR(pin[pin_nreset].pin);
|
||||
usleep(10); /* DS Table 9 pg 29 says min 50 ns */
|
||||
SET(TGT_nRESET);
|
||||
SET(pin[pin_nreset].pin);
|
||||
|
||||
usleep(5*1000); /* UM 26.3.1 pg 408 says max 3 ms */
|
||||
|
||||
@ -542,13 +555,13 @@ static void start_isp(int power)
|
||||
|
||||
usleep(100*1000);
|
||||
|
||||
SET(TGT_nRESET);
|
||||
OUT(TGT_nRESET);
|
||||
SET(pin[pin_nreset].pin);
|
||||
OUT(pin[pin_nreset].pin);
|
||||
|
||||
CLR(TGT_nISP);
|
||||
OUT(TGT_nISP);
|
||||
CLR(pin[pin_nisp].pin);
|
||||
OUT(pin[pin_nisp].pin);
|
||||
|
||||
if (swuart_open(HOST_TX, HOST_RX, BPS) < 0) {
|
||||
if (swuart_open(pin[pin_rxd].pin, pin[pin_txd].pin, BPS) < 0) {
|
||||
perror("swuart_open");
|
||||
exit(1);
|
||||
}
|
||||
@ -579,16 +592,16 @@ static void run_target(int power)
|
||||
if (power)
|
||||
ubb_power(1);
|
||||
|
||||
SET(TGT_nRESET);
|
||||
OUT(TGT_nRESET);
|
||||
SET(pin[pin_nreset].pin);
|
||||
OUT(pin[pin_nreset].pin);
|
||||
|
||||
IN(TGT_nISP);
|
||||
IN(pin[pin_nisp].pin);
|
||||
|
||||
CLR(TGT_nRESET);
|
||||
CLR(pin[pin_nreset].pin);
|
||||
usleep(10); /* DS Table 9 pg 29 says min 50 ns */
|
||||
SET(TGT_nRESET);
|
||||
SET(pin[pin_nreset].pin);
|
||||
|
||||
ubb_close(UBB_nPWR | TGT_nRESET | TGT_nISP);
|
||||
ubb_close(UBB_nPWR | pin[pin_nreset].pin | pin[pin_nisp].pin);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user