]> git.gag.com Git - fw/openocd/blob - contrib/loaders/flash/nrf5/nrf5.S
nrf5: Refresh the watchdog while flashing
[fw/openocd] / contrib / loaders / flash / nrf5 / nrf5.S
1 /***************************************************************************
2  *   Copyright (C) 2014 Angus Gratton                                      *
3  *   gus@projectgus.com                                                    *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.                                        *
18  ***************************************************************************/
19
20         .text
21         .syntax unified
22         .thumb
23
24 /*
25  * Params :
26  * r0 = byte count
27  * r1 = buffer start
28  * r2 = buffer end
29  * r3 = target address
30  * r6 = watchdog refresh value
31  * r7 = watchdog refresh register address
32  */
33
34         .thumb_func
35         .global _start
36 _start:
37 wait_fifo:
38         str     r6, [r7, #0]
39         ldr     r5, [r1, #0]
40         cmp     r5, #0
41         beq.n   exit
42         ldr     r4, [r1, #4]
43         cmp     r4, r5
44         beq.n   wait_fifo
45         ldmia   r4!, {r5}
46         stmia   r3!, {r5}
47         cmp     r4, r2
48         bcc.n   no_wrap
49         mov     r4, r1
50         adds    r4, #8
51 no_wrap:
52         str     r4, [r1, #4]
53         subs    r0, #4
54         bne.n   wait_fifo
55 exit:
56         bkpt    #0x00
57
58         .pool