rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
debug.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
16 /*
17  Author: Michael Hauspie <michael.hauspie@univ-lille1.fr>
18  Created:
19  Time-stamp: <2014-05-29 00:50:31 (mickey)>
20 */
24 #ifndef __RFLPC_DEBUG_H__
25 #define __RFLPC_DEBUG_H__
26 
27 
28 
29 #include "drivers/leds.h"
30 
32 extern unsigned char _stack[RFLPC_STACK_SIZE];
46 #define RFLPC_DELAY(c) do { \
47  int i; \
48  for (i=0 ; i < (c) ; ++i) \
49  __ASM volatile ("nop"); \
50 } while (0)
51 
55 #define RFLPC_DELAY_MICROSECS(c) RFLPC_DELAY(32*(c))
56 
58 #define RFLPC_STOP(l,c) do { \
59  uint32_t leds = (l); \
60  while(1) { \
61  rflpc_led_val(leds); \
62  RFLPC_DELAY((c)); \
63  leds=~leds; \
64  } \
65  } \
66  while(0)
67 
68 
73 #define RFLPC_ARM_GET_REGISTER(reg, var) do { \
74  __ASM volatile ("MOV %0, "#reg"\n" : "=r" ((var))); \
75  } while(0)
76 
81 #define RFLPC_DUMP_STACK() do { \
82  register uint8_t *mstack; \
83  register int i; \
84  RFLPC_ARM_GET_REGISTER(sp,(uint32_t)mstack); \
85  mstack = (uint8_t *) sp; \
86  for (i = 0 ; i < 128 ; ++i) \
87  { \
88  if (i % 16 == 0) \
89  printf("\n\r%p: ", mstack + i); \
90  printf("%02x ", mstack[i]); \
91  } \
92  printf("\n\r"); \
93  } while(0)
94 
98 #define RFLPC_ASSERT(cond) do { if (!(cond)) { RFLPC_STOP(0, 50000); } } while (0)
99 
103 #define RFLPC_ADDR_IN(addr, inf, sup) ( ((void*)(addr)) >= ((void*)(inf)) ? (((void*)(addr)) < ((void*)(sup))) : 0)
104 #ifdef RFLPC_CONFIG_PLATFORM_MBED
105 #define RFLPC_ADDR_IN_FLASH(addr) RFLPC_ADDR_IN((addr), 0, 0x7ffff)
106 #define RFLPC_ADDR_IN_RAM(addr) (RFLPC_ADDR_IN((addr), 0x1000000, 0x10007FFF) || RFLPC_ADDR_IN((addr), 0x2007c000, 0x2007ffff))
107 #endif
108 
110 #endif
111 
112 
#define RFLPC_STACK_SIZE
size of the stack in bytes
Definition: config.h:58
On board LEDs peripheral driver.