aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-09-13 13:32:01 -0400
committerMarti Bolivar <mbolivar@mit.edu>2010-09-13 13:32:01 -0400
commitee5667f54d76022beec4584ccf50879c68361a33 (patch)
tree555d9c15d11f5d56fa675e4dda0a930013cd00a9
parent5bfeb40e4795eb5cf21ea84311936acf97969365 (diff)
downloadlibrambutan-ee5667f54d76022beec4584ccf50879c68361a33.tar.gz
librambutan-ee5667f54d76022beec4584ccf50879c68361a33.zip
bugfix MAPLE_RELOAD_VAL, whitespace fixes
-rw-r--r--libmaple/libmaple.h10
-rw-r--r--wirish/boards.h8
-rw-r--r--wirish/time.c2
-rw-r--r--wirish/time.h7
4 files changed, 13 insertions, 14 deletions
diff --git a/libmaple/libmaple.h b/libmaple/libmaple.h
index c5763c8..8124516 100644
--- a/libmaple/libmaple.h
+++ b/libmaple/libmaple.h
@@ -34,14 +34,10 @@
#include "libmaple_types.h"
// General configuration
-#ifndef DEBUG_LEVEL
- //#define DEBUG_LEVEL DEBUG_ALL
- #define DEBUG_LEVEL DEBUG_FAULT
- //#define DEBUG_LEVEL DEBUG_NONE
-#endif
+#define MAPLE_DEBUG 1
// MCU-specific configuration
-#ifdef MCU_STM32F103RB
+#ifdef MCU_STM32F103RB
// eg, LeafLabs Maple
// Number of GPIO ports (GPIOA, GPIOB, etc), definately used
@@ -96,7 +92,7 @@
#define BITBAND_PERI_BASE 0x42000000
#endif
-#ifdef MCU_STM32F103ZE
+#ifdef MCU_STM32F103ZE
// eg, LeafLabs Maple Native
#define NR_GPIO_PORTS 7
#define NR_GPIO_PINS 63
diff --git a/wirish/boards.h b/wirish/boards.h
index 617a7ad..03d0b0e 100644
--- a/wirish/boards.h
+++ b/wirish/boards.h
@@ -72,10 +72,10 @@ typedef struct ExtiInfo {
} ExtiInfo;
// LeafLabs Maple rev3, rev4
-#ifdef BOARD_maple
+#ifdef BOARD_maple
#define CYCLES_PER_MICROSECOND 72
- #define MAPLE_RELOAD_VAL 72000
+ #define MAPLE_RELOAD_VAL 71999 /* takes a cycle to reload */
static __attribute__ ((unused)) PinMapping PIN_MAP[NR_GPIO_PINS] = {
{GPIOA_BASE, 3, ADC3, TIMER2_CH4_CCR}, // D0/PA3
@@ -142,10 +142,10 @@ typedef struct ExtiInfo {
#endif
// LeafLabs Maple Native (prototype)
-#ifdef BOARD_maple_native
+#ifdef BOARD_maple_native
#define CYCLES_PER_MICROSECOND 72
- #define MAPLE_RELOAD_VAL 72000
+ #define MAPLE_RELOAD_VAL 71999 /* takes a cycle to reload */
// TODO:
static __attribute__ ((unused)) PinMapping PIN_MAP[NR_GPIO_PINS] = {
diff --git a/wirish/time.c b/wirish/time.c
index ea8ebe1..eaa3c9e 100644
--- a/wirish/time.c
+++ b/wirish/time.c
@@ -23,7 +23,7 @@
* ****************************************************************************/
/**
- * @brief
+ * @brief
*/
#include "libmaple.h"
diff --git a/wirish/time.h b/wirish/time.h
index f73d133..ad39057 100644
--- a/wirish/time.h
+++ b/wirish/time.h
@@ -23,7 +23,7 @@
* ****************************************************************************/
/**
- * @brief
+ * @brief
*/
#ifndef _TIME_H
@@ -59,7 +59,10 @@ static inline uint32 micros(void) {
nvic_globalirq_enable();
- res = (ms * US_PER_MS) + (MAPLE_RELOAD_VAL - cycle_cnt)/CYCLES_PER_MICROSECOND;
+ /* MAPLE_RELOAD_VAL is 1 less than the number of cycles it actually
+ takes to complete a systick reload */
+ res = (ms * US_PER_MS) +
+ (MAPLE_RELOAD_VAL + 1 - cycle_cnt)/CYCLES_PER_MICROSECOND;
return res;
}