2019-07-23 14:21:39 -05:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2014 Angus Gratton *
|
|
|
|
* gus@projectgus.com *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
.text
|
|
|
|
.syntax unified
|
2020-04-13 10:33:10 -05:00
|
|
|
.cpu cortex-m0
|
2019-07-23 14:21:39 -05:00
|
|
|
.thumb
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Params :
|
|
|
|
* r0 = byte count
|
|
|
|
* r1 = buffer start
|
|
|
|
* r2 = buffer end
|
|
|
|
* r3 = target address
|
2019-07-22 16:13:29 -05:00
|
|
|
* r6 = watchdog refresh value
|
|
|
|
* r7 = watchdog refresh register address
|
2019-07-23 14:21:39 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
.thumb_func
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
wait_fifo:
|
2019-08-06 15:08:18 -05:00
|
|
|
// Kick the watchdog
|
2019-07-22 16:13:29 -05:00
|
|
|
str r6, [r7, #0]
|
2019-08-06 15:08:18 -05:00
|
|
|
// Load write pointer
|
2019-07-23 14:21:39 -05:00
|
|
|
ldr r5, [r1, #0]
|
2019-08-06 15:08:18 -05:00
|
|
|
// Abort if it is NULL
|
2019-07-23 14:21:39 -05:00
|
|
|
cmp r5, #0
|
|
|
|
beq.n exit
|
2019-08-06 15:08:18 -05:00
|
|
|
// Load read pointer
|
2019-07-23 14:21:39 -05:00
|
|
|
ldr r4, [r1, #4]
|
2019-08-06 15:08:18 -05:00
|
|
|
// Continue waiting if it equals the write pointer
|
2019-07-23 14:21:39 -05:00
|
|
|
cmp r4, r5
|
|
|
|
beq.n wait_fifo
|
2019-08-06 15:08:18 -05:00
|
|
|
// Copy one word from buffer to target, and increment pointers
|
2019-07-23 14:21:39 -05:00
|
|
|
ldmia r4!, {r5}
|
|
|
|
stmia r3!, {r5}
|
2019-08-06 15:08:18 -05:00
|
|
|
// If at end of buffer, wrap back to buffer start
|
2019-07-23 14:21:39 -05:00
|
|
|
cmp r4, r2
|
|
|
|
bcc.n no_wrap
|
|
|
|
mov r4, r1
|
|
|
|
adds r4, #8
|
|
|
|
no_wrap:
|
2019-08-06 15:08:18 -05:00
|
|
|
// Update read pointer inside the buffer
|
2019-07-23 14:21:39 -05:00
|
|
|
str r4, [r1, #4]
|
2019-08-06 15:08:18 -05:00
|
|
|
// Deduce the word transferred from the byte count
|
2019-07-23 14:21:39 -05:00
|
|
|
subs r0, #4
|
2019-08-06 15:08:18 -05:00
|
|
|
// Start again
|
2019-07-23 14:21:39 -05:00
|
|
|
bne.n wait_fifo
|
|
|
|
exit:
|
2019-08-06 15:08:18 -05:00
|
|
|
// Wait for OpenOCD
|
2019-07-23 14:21:39 -05:00
|
|
|
bkpt #0x00
|
|
|
|
|
|
|
|
.pool
|