core timer replacement. need to work on system config stuff one day, or not
--- a/delay.c Sat Feb 18 16:59:35 2017 +0000
+++ b/delay.c Sat Feb 18 17:04:01 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Darron Broad
+ * Copyright (C) 2005-2017 Darron Broad
* All rights reserved.
*
* This file is part of Mindy Microchip PIC ICSP.
@@ -22,15 +22,31 @@
#include "mindy.h"
+/*
+ * Get processor cycle count
+ */
+static inline uint32_t __attribute__((nomips16))
+_ReadCoreTimer(void)
+{
+ uint32_t timer;
+
+ asm volatile("mfc0 %0, $9" : "=r"(timer));
+
+ return timer;
+}
+
+/*
+ * Time delay
+ */
void
_delay_ms(uint32_t ms)
{
uint32_t startTime, waitTime;
- startTime = ReadCoreTimer();
+ startTime = _ReadCoreTimer();
waitTime = (FCY / 2000) * ms;
- while ((ReadCoreTimer() - startTime) < waitTime)
+ while ((_ReadCoreTimer() - startTime) < waitTime)
;
}