Project

General

Profile

Revision 1518

Added by Brad Neuman over 14 years ago

updated library to add DRAGONFLY_DEBUG stuff
Can now call make debug which will recompile the library with debug flags!

View differences:

branches/init_refactor/code/behaviors/BOM_test/beaconBot/main.c
3 3
int main(void)
4 4
{
5 5

  
6
	/* initialize components, set wireless channel */
7
	if (dragonfly_init(ANALOG|ORB|BOM) != 0) {
6
  /* initialize components, set wireless channel */
7
  if (dragonfly_init(/* ANALOG|ORB|BOM */ ALL_ON) != 0) {
8 8
    orbs_set_color(YELLOW, YELLOW);
9 9
    while(1) { ; }
10 10
  }
11 11

  
12
	if (bom_on() != 0) {
12
  if (bom_on() != 0) {
13 13
    orbs_set_color(RED, RED);
14 14
    while(1) { ; }
15 15
  }
16 16
  
17 17
	
18
	while (1) {
18
  while (1) {
19 19

  
20
		orbs_set_color(GREEN, BLUE);
20
    orbs_set_color(GREEN, BLUE);
21 21

  
22
		delay_ms(1000);
22
    delay_ms(1000);
23 23

  
24
		orbs_set_color(BLUE, GREEN);
24
    orbs_set_color(BLUE, GREEN);
25 25

  
26
		delay_ms(1000);
26
    delay_ms(1000);
27 27

  
28
	}
28
  }
29 29

  
30
	return 0;
30
  return 0;
31 31
}
branches/init_refactor/code/lib/include/libwireless/wl_defs.h
42 42
//uncomment this line for debug information
43 43
//#define WL_DEBUG
44 44

  
45
//return value definitions
46
/** @brief Error code for init failure **/
47
#define WL_ERROR_INIT_FAILED 1
48
/** @brief Error code for duplicate init calls **/
49
#define WL_ERROR_INIT_ALREADY_INITD 2
50
/** @brief Error code for not calling init **/
51
#define WL_ERROR_LIBRARY_NOT_INITD 3
52

  
45 53
// Packet Groups and Types
46 54

  
47 55
// Error group
branches/init_refactor/code/lib/include/libdragonfly/dragonfly_lib.h
42 42
 **/
43 43

  
44 44
/** @brief Initialize the board **/
45
void dragonfly_init(int config);
45
int dragonfly_init(int config);
46 46

  
47 47
/** @} **/ //end addtogroup
48 48

  
branches/init_refactor/code/lib/include/libdragonfly/dragonfly_defs.h
90 90
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0)
91 91

  
92 92

  
93
#endif
93
#ifdef DRAGONFLY_DEBUG
94
#define DRAGONFLY_DEBUG_PRINT(s) usb_puts(s)
95
#define DRAGONFLY_DEBUG_PRINTLN(s) usb_puts(__FILE__ ":" __LINE__ ">>" s "\r\n")
96
#define DRAGONFLY_DEBUG_PRINT_INT(i) usb_puti(i)
97
#else
98
#define DRAGONFLY_DEBUG_PRINT(s)
99
#define DRAGONFLY_DEBUG_PRINTLN(s)
100
#define DRAGONFLY_DEBUG_PRINT_INT(i)
101
#endif
102

  
103
#endif
branches/init_refactor/code/projects/libdragonfly/dragonfly_lib.c
67 67

  
68 68
int dragonfly_init(int config) 
69 69
{
70
  int ret = 0;
71

  
70 72
    sei();
71 73
    // Set directionality of various IO pins
72 74
    DDRG &= ~(_BV(PING0)|_BV(PING1));
73 75
    PORTG |= _BV(PING0)|_BV(PING1);
74 76
    
75
    if(config & ANALOG)
76
        analog_init(ADC_START);
77
    if(config & ANALOG) {
78
      analog_init(ADC_START);
79
    }
77 80
    
78 81
    if(config & COMM)
79 82
    {
......
116 119
            return ERROR_INIT_FAILED;
117 120
    }
118 121

  
119
	if (config & ENCODERS)
120
	{
121
		encoders_init();
122
	}
122
    if (config & ENCODERS)
123
    {
124
        encoders_init();
125
    }
123 126

  
124 127
    // delay a bit for stability
125 128
    _delay_ms(1);
branches/init_refactor/code/projects/libdragonfly/Makefile
151 151

  
152 152
# Combine all necessary flags and optional flags.
153 153
# Add target processor to flags.
154
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
154
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) $(GLOBAL_CFLAGS)
155 155
ALL_ASFLAGS = rcs
156 156

  
157 157
# Default target.
......
159 159

  
160 160
dist: all publish
161 161

  
162
debug_dist: ALL_CFLAGS += -DDRAGONFLY_DEBUG
163
debug_dist: test all publish
164

  
165
test:
166
	echo "~~~~~~~ $(ALL_CFLAGS)"
167

  
168

  
162 169
publish:
163 170
	$(COPY) $(TARGET).a $(COLONYROOT)/code/lib/bin
164 171
	$(COPY) *.h $(COLONYROOT)/code/lib/include/$(TARGET)
branches/init_refactor/code/projects/libdragonfly/bom.c
32 32
 *
33 33
 * @author Colony Project, CMU Robotics Club
34 34
 **/
35

  
36
//#include "dragonfly_defs.h"
35
#include "dragonfly_defs.h"
37 36
#include "bom.h"
38 37
#include "dio.h"
39 38
#include "serial.h"
branches/init_refactor/code/projects/libdragonfly/dragonfly_defs.h
90 90
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0)
91 91

  
92 92

  
93
#endif
93
#ifdef DRAGONFLY_DEBUG
94
#define DRAGONFLY_DEBUG_PRINT(s) usb_puts(s)
95
#define DRAGONFLY_DEBUG_PRINTLN(s) usb_puts(__FILE__ ":" __LINE__ ">>" s "\r\n")
96
#define DRAGONFLY_DEBUG_PRINT_INT(i) usb_puti(i)
97
#else
98
#define DRAGONFLY_DEBUG_PRINT(s)
99
#define DRAGONFLY_DEBUG_PRINTLN(s)
100
#define DRAGONFLY_DEBUG_PRINT_INT(i)
101
#endif
102

  
103
#endif
branches/init_refactor/code/Makefile
40 40
# make program = Download the hex file to the device, using avrdude.
41 41
#                Please customize the avrdude settings below first!
42 42
#
43
# make debug = Start either simulavr or avarice as specified for debugging,
43
# make avrdebug = Start either simulavr or avarice as specified for debugging,
44 44
#              with avr-gdb or avr-insight as the front end for debugging.
45 45
#
46
# make debug = recompile the library with debug flags
47
#
46 48
# make library = Build the library, then make software
47 49
#
48 50
# make filename.s = Just compile filename.c into the assembler code only.
......
92 94
#     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs.
93 95
#     AVR Studio 4.10 requires dwarf-2.
94 96
#     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run.
95
DEBUG =
97
AVRDEBUG =
96 98

  
97 99
# Compiler flag to set the C Standard level.
98 100
#     c89   = "ANSI" C
......
124 126
#  -Wa,...:      tell GCC to pass this to the assembler.
125 127
#    -adhlns...: create assembler listing
126 128
CFLAGS =
127
# CFLAGS = -g$(DEBUG)
129
# CFLAGS = -g$(AVRDEBUG)
128 130
CFLAGS += $(CDEFS) $(CINCS)
129 131
CFLAGS += -O$(OPT)
130 132
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
......
315 317

  
316 318
# Combine all necessary flags and optional flags.
317 319
# Add target processor to flags.
318
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
320
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) $(GLOBAL_CFLAGS)
319 321
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
320 322

  
321 323

  
......
378 380
	$(AVRMEM) 2>/dev/null; echo; fi
379 381

  
380 382

  
383
# debug flags
384
debug: ALL_CFLAGS += -DDRAGONFLY_DEBUG
385
debug: test debug_library  build  checksize 
381 386

  
387
test:
388
	echo "$(ALL_CFLAGS)"
389

  
390

  
391
# Build the library
392
debug_library:
393
	@echo $(MSG_LIBRARY_BUILD)
394
	make clean -C $(COLONYROOT)/code/projects/libdragonfly
395
	make debug_dist -C $(COLONYROOT)/code/projects/libdragonfly
396
	make clean -C $(COLONYROOT)/code/projects/libwireless/lib
397
	make dist -C $(COLONYROOT)/code/projects/libwireless/lib
398

  
382 399
# Display compiler version information.
383 400
gccversion :
384 401
	@$(CC) --version
385
  
386
  
402

  
403

  
387 404
# Build the library
388 405
library:
389 406
	@echo $(MSG_LIBRARY_BUILD)
......
419 436
endif
420 437
	@echo break main >> $(GDBINIT_FILE)
421 438

  
422
debug: gdb-config $(TARGET).elf
439
avrdebug: gdb-config $(TARGET).elf
423 440
ifeq ($(DEBUG_BACKEND), avarice)
424 441
	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays.
425 442
	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \

Also available in: Unified diff