annotate target-utils/flash-boot-test/watchdog.c @ 999:30fad2b3afd2

doc/Flash-write-protection: document flash lock-state retrieval
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 04 Dec 2023 20:40:50 +0000
parents 3d7b546c710c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
490
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
1 #include <sys/types.h>
488
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include "types.h"
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 void
490
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
5 cmd_wd()
488
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 {
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 /* stop/disable the watchdog timer */
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 *(volatile u16 *)0xFFFFF804 = 0xF5;
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 *(volatile u16 *)0xFFFFF804 = 0xA0;
cd900b885eb2 target-utils/flash-boot-test: added wd (watchdog disable) command
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 }
490
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
11
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
12 void
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
13 cmd_we()
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
14 {
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
15 /* watchdog enable */
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
16 *(volatile u16 *)0xFFFFF804 = 0x8000;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
17 }
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
18
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
19 void
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
20 cmd_wr()
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
21 {
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
22 /* read and display watchdog downcount register */
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
23 printf("%04X\n", *(volatile u16 *)0xFFFFF802);
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
24 }
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
25
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
26 void
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
27 cmd_ww(argbulk)
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
28 char *argbulk;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
29 {
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
30 /* single or double write to WATCHDOG_TIM_MODE */
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
31 char *argv[3];
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
32 u_long w1, w2;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
33
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
34 if (parse_args(argbulk, 1, 2, argv, 0) < 0)
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
35 return;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
36 if (parse_hexarg(argv[0], 4, &w1) < 0) {
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
37 printf("ERROR: arg1 must be a valid 16-bit hex value\n");
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
38 return;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
39 }
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
40 if (argv[1] && parse_hexarg(argv[1], 4, &w2) < 0) {
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
41 printf("ERROR: arg2 must be a valid 16-bit hex value\n");
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
42 return;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
43 }
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
44 /* do it */
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
45 *(volatile u16 *)0xFFFFF804 = w1;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
46 if (argv[1])
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
47 *(volatile u16 *)0xFFFFF804 = w2;
3d7b546c710c target-utils/flash-boot-test: more watchdog experimentation commands
Mychaela Falconia <falcon@freecalypso.org>
parents: 488
diff changeset
48 }