Working on RF2500.

This commit is contained in:
Daniel Beer 2010-01-04 16:05:53 +13:00
parent 228812e7de
commit 7036aec135
3 changed files with 30 additions and 11 deletions

22
fet.c
View File

@ -503,6 +503,18 @@ static const struct {
0x00, 0x00, 0x01, 0x61, 0x01, 0x00, 0xD1, 0x4D, 0x00, 0x00, 0x01, 0x61, 0x01, 0x00, 0xD1, 0x4D,
0x80, 0x00}, 0x80, 0x00},
.idtext = "MSP430F1611" .idtext = "MSP430F1611"
},
{
.reply = {0xf2, 0x27, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x01, 0x01, 0x04, 0xb1, 0x62,
0x80, 0x00},
.idtext = "MSP430F2274"
},
{
.reply = {0xf2, 0x01, 0x10, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00,
0x00, 0x00},
.idtext = "MSP430F2013"
} }
}; };
@ -630,9 +642,10 @@ int fet_open(const struct fet_transport *tr, int proto_flags, int vcc_mv)
int fet_reset(int flags) int fet_reset(int flags)
{ {
int wh = flags & FET_RESET_HALT ? 1 : 0; int wh = flags & FET_RESET_HALT ? 0 : 1;
int wr = flags & FET_RESET_RELEASE ? 1 : 0;
if (xfer(C_RESET, NULL, 3, flags & FET_RESET_ALL, wh, wh) < 0) { if (xfer(C_RESET, NULL, 0, 3, flags & FET_RESET_ALL, wh, wr) < 0) {
fprintf(stderr, "fet_reset: reset failed\n"); fprintf(stderr, "fet_reset: reset failed\n");
return -1; return -1;
} }
@ -789,7 +802,10 @@ int fet_poll(void)
int fet_run(int type) int fet_run(int type)
{ {
if (xfer(C_RUN, NULL, 0, 2, type, 0) < 0) { int wr = type & FET_RUN_RELEASE ? 1 : 0;
type &= ~FET_RUN_RELEASE;
if (xfer(C_RUN, NULL, 0, 2, type, wr) < 0) {
fprintf(stderr, "fet_run: run failed\n"); fprintf(stderr, "fet_run: run failed\n");
return -1; return -1;
} }

14
fet.h
View File

@ -50,11 +50,12 @@ int fet_close(void);
* of three methods, and you can choose whether or not to leave the CPU * of three methods, and you can choose whether or not to leave the CPU
* halted after reset. * halted after reset.
*/ */
#define FET_RESET_PUC 0x01 #define FET_RESET_PUC 0x01
#define FET_RESET_RST 0x02 #define FET_RESET_RST 0x02
#define FET_RESET_VCC 0x04 #define FET_RESET_VCC 0x04
#define FET_RESET_ALL 0x07 #define FET_RESET_ALL 0x07
#define FET_RESET_HALT 0x10 #define FET_RESET_HALT 0x10
#define FET_RESET_RELEASE 0x20
int fet_reset(int flags); int fet_reset(int flags);
@ -92,11 +93,12 @@ int fet_poll(void);
/* CPU run/step/stop control. While the CPU is running, memory and /* CPU run/step/stop control. While the CPU is running, memory and
* registers are inaccessible (only fet_poll() or fet_stop()) will * registers are inaccessible (only fet_poll() or fet_stop()) will
* work. fet_step() is used to single-step the CPU. * work.
*/ */
#define FET_RUN_FREE 1 #define FET_RUN_FREE 1
#define FET_RUN_STEP 2 #define FET_RUN_STEP 2
#define FET_RUN_BREAKPOINT 3 #define FET_RUN_BREAKPOINT 3
#define FET_RUN_RELEASE 0x10
int fet_run(int type); int fet_run(int type);
int fet_stop(void); int fet_stop(void);

5
main.c
View File

@ -445,7 +445,7 @@ static int cmd_prog(char **arg)
} }
printf("Erasing...\n"); printf("Erasing...\n");
if (fet_erase(FET_ERASE_ALL, 0, 0) < 0) { if (fet_erase(FET_ERASE_ALL, 0x1000, 0x100) < 0) {
fclose(in); fclose(in);
return -1; return -1;
} }
@ -567,6 +567,7 @@ static void reader_loop(void)
.sa_flags = 0 .sa_flags = 0
}; };
printf("\n");
cmd_help(NULL); cmd_help(NULL);
sigaction(SIGINT, &siga, NULL); sigaction(SIGINT, &siga, NULL);
@ -646,7 +647,7 @@ int main(int argc, char **argv)
reader_loop(); reader_loop();
} }
fet_run(FET_RUN_FREE); fet_run(FET_RUN_FREE | FET_RUN_RELEASE);
fet_close(); fet_close();
return 0; return 0;