Project

General

Profile

Revision 193

added get and reset functions back in to work with existing code, added get from a particular function, and reset all

View differences:

branches/encoders/code/lib/src/libdragonfly/time.c
79 79
 int rtc_multi_init(int* prescale_opt,  void (*rtc_func[])(void), int argc) {
80 80
	
81 81
	//Check that the number of functions doesn't exceed alloted space
82
	if(argc >= MAX_FUNCTIONS)
82
	if(argc > MAX_FUNCTIONS)
83 83
		return -1;
84 84
	
85 85
	function_count = argc;
......
147 147
 *
148 148
 * @see rtc_init, rtc_reset
149 149
 **/
150
 /*
150
 
151 151
int rtc_get(void){
152
	return _rtc_val;
153
}*/
152
	return _rtc_val[0];
153
}
154 154

  
155
int rtc_get_pos(int pos){
156
	return _rtc_val[pos];
157
}
158

  
155 159
/**
156 160
 * Resets the real time clock counter to 0.
157 161
 *
158 162
 * @see rtc_init, rtc_get
159 163
 **/
160
 /*
164
 
161 165
void rtc_reset(void){
162
	_rtc_val = 0;
163
}*/
166
	_rtc_val[0] = 0;
167
}
164 168

  
169
void rtc_reset_all(void)
170
{
171
	for(int i =0; i <MAX_FUNCTIONS; i++)
172
		_rtc_val[i] = 0;
173
}
174

  
165 175
/** @} **/ //end defgroup
166 176

  
167 177
/*	Called every pulse. Function in _rtc_f is called every _rtc_scale and also the counter is updated.
branches/encoders/code/projects/template/main.c
1 1
#include <dragonfly_lib.h>
2 2

  
3
void a1()
4
{
5
	usb_puts("a\n");
6
}
7

  
8
void a2()
9
{
10
	usb_puts("b\n");
11
}
12

  
13
void a3()
14
{
15
	usb_puts("c\n");
16
}
17

  
18
void a4()
19
{
20
	usb_puts("4\n");
21
}
22

  
23
void a5()
24
{
25
	usb_puts("5\n");
26
}
27

  
28
void a6()
29
{
30
	usb_puts("6\n");
31
}
32

  
33
void a7()
34
{
35
	usb_puts("7\n");
36
}
37

  
38
void a8()
39
{
40
	usb_puts("8\n");
41
}
42

  
43
void a9()
44
{
45
	usb_puts("9\n");
46
}
47

  
48
void a10()
49
{
50
usb_puts("A");
51
for(int i = 0; i <10; i++)
52
{
53
	buzzer_chirp(1000,C4);
54
	buzzer_chirp(1000,C5);
55
}
56
}
57

  
3 58
int main(void)
4 59
{
5 60
	dragonfly_init(ALL_ON);
61
	buzzer_init();
62
	void (*functions[])(void) = {a1,a2,a3,a4,a5,a6,a7,a8,a9,a10};
63
	int test[] = {1,2,3,4,5,6,7,8,9,1000};
64
	rtc_multi_init(test, functions, 10);
65
	
66
	while(1){};
67
	
6 68
	return 0;
69
	
7 70
}
8 71

  
branches/encoders/code/projects/template/Makefile
14 14
# USE_WIRELESS = 1
15 15

  
16 16
# com1 = serial port. Use lpt1 to connect to parallel port.
17
AVRDUDE_PORT = com4
17
AVRDUDE_PORT = com1
18 18
#
19 19
#
20 20
###################################
branches/encoders/code/projects/libdragonfly/time.c
79 79
 int rtc_multi_init(int* prescale_opt,  void (*rtc_func[])(void), int argc) {
80 80
	
81 81
	//Check that the number of functions doesn't exceed alloted space
82
	if(argc >= MAX_FUNCTIONS)
82
	if(argc > MAX_FUNCTIONS)
83 83
		return -1;
84 84
	
85 85
	function_count = argc;
......
147 147
 *
148 148
 * @see rtc_init, rtc_reset
149 149
 **/
150
 /*
150
 
151 151
int rtc_get(void){
152
	return _rtc_val;
153
}*/
152
	return _rtc_val[0];
153
}
154 154

  
155
int rtc_get_pos(int pos){
156
	return _rtc_val[pos];
157
}
158

  
155 159
/**
156 160
 * Resets the real time clock counter to 0.
157 161
 *
158 162
 * @see rtc_init, rtc_get
159 163
 **/
160
 /*
164
 
161 165
void rtc_reset(void){
162
	_rtc_val = 0;
163
}*/
166
	_rtc_val[0] = 0;
167
}
164 168

  
169
void rtc_reset_all(void)
170
{
171
	for(int i =0; i <MAX_FUNCTIONS; i++)
172
		_rtc_val[i] = 0;
173
}
174

  
165 175
/** @} **/ //end defgroup
166 176

  
167 177
/*	Called every pulse. Function in _rtc_f is called every _rtc_scale and also the counter is updated.

Also available in: Unified diff