simpletools library
v0.93
Collection of convenience functions for common microcontroller tasks
Main Page
Files
File List
Globals
simpletools.h
Go to the documentation of this file.
1
73
#ifndef SIMPLETOOLS_H
74
#define SIMPLETOOLS_H
75
76
#if defined(__cplusplus)
77
extern
"C"
{
78
#endif
79
80
#include <propeller.h>
81
#include "simpletext.h"
82
#include <driver.h>
83
#include <stdio.h>
84
#include <stdlib.h>
85
#include <string.h>
86
#include <cog.h>
87
#include <ctype.h>
88
#include <unistd.h>
89
#include <sys/stat.h>
90
#include <dirent.h>
91
#include <sys/sd.h>
92
#include <i2c.h>
93
#include <math.h>
94
#include "simplei2c.h"
95
96
// Global variables shared by functions in separate files
97
extern
long
iodt;
98
extern
long
t_timeout;
99
extern
long
pauseTicks;
100
extern
long
t_mark;
101
extern
char
setForget;
102
extern
int
fdserDriverIndex;
103
extern
unsigned
int
buscnt;
104
extern
i2c *eeprom;
105
extern
int
eeInitFlag;
106
107
//extern i2c *eeprom;
108
//extern int dacCtrBits;
109
110
#ifndef PI
111
#define PI 3.141592653589793
112
#endif
113
114
#ifndef EEPROM_ADDR
115
#define EEPROM_ADDR 0xA0 >> 1
116
#endif
117
118
/* Values for use with SimpleIDE Terminal */
119
#ifndef HOME
120
#define HOME (1)
121
#endif
122
#ifndef CRSRXY
123
#define CRSRXY (2)
124
#endif
125
#ifndef CRSRLF
126
#define CRSRLF (3)
127
#endif
128
#ifndef CRSRRT
129
#define CRSRRT (4)
130
#endif
131
#ifndef CRSRUP
132
#define CRSRUP (5)
133
#endif
134
#ifndef CRSRDN
135
#define CRSRDN (6)
136
#endif
137
#ifndef BEEP
138
#define BEEP (7)
139
#endif
140
#ifndef BKSP
141
#define BKSP (8)
142
#endif
143
#ifndef TAB
144
#define TAB (9)
145
#endif
146
#ifndef NL
147
#define NL (10)
148
#endif
149
#ifndef LF
150
#define LF (10)
151
#endif
152
#ifndef CLREOL
153
#define CLREOL (11)
154
#endif
155
#ifndef CLRDN
156
#define CLRDN (12)
157
#endif
158
#ifndef CR
159
#define CR (13)
160
#endif
161
#ifndef CRSRX
162
#define CRSRX (14)
163
#endif
164
#ifndef CRSRY
165
#define CRSRY (15)
166
#endif
167
#ifndef CLS
168
#define CLS (16)
169
#endif
170
171
172
// Values for use with shift_in
173
#ifndef MSBPRE
174
#define MSBPRE 0
175
#endif
176
#ifndef LSBPRE
177
#define LSBPRE 1
178
#endif
179
#ifndef MSBPOST
180
#define MSBPOST 2
181
#endif
182
#ifndef LSBPOST
183
#define LSBPOST 3
184
#endif
185
186
// Values for use with shift_out
187
#ifndef LSBFIRST
188
#define LSBFIRST 0
189
#endif
190
191
#ifndef MSBFIRST
192
#define MSBFIRST 1
193
#endif
194
195
// Counter module values
196
#ifndef NCO_PWM_1
197
#define NCO_PWM_1 (0b00100 << 26)
198
#endif
199
200
#ifndef CTR_NCO
201
#define CTR_NCO (0b100 << 26)
202
#endif
203
204
#ifndef CTR_PLL
205
#define CTR_PLL (0b10 << 26)
206
#endif
207
208
#ifndef DUTY_SE
209
#define DUTY_SE (0b110 << 26)
210
#endif
211
212
// Define types for simplified driver declarations
213
//typedef FILE* serial;
214
//typedef FILE* fdserial;
215
//typedef FILE* sdcard;
216
//typedef I2C* i2c;
217
228
void
high
(
int
pin);
229
240
void
low
(
int
pin);
241
253
unsigned
int
toggle
(
int
pin);
254
268
unsigned
int
input
(
int
pin);
269
281
unsigned
int
reverse
(
int
pin);
282
300
unsigned
int
get_state
(
int
pin);
301
316
unsigned
int
get_direction
(
int
pin);
317
330
unsigned
int
get_output
(
int
pin);
331
340
void
set_direction
(
int
pin,
int
direction);
341
354
void
set_output
(
int
pin,
int
state);
355
369
unsigned
int
get_states
(
int
endPin,
int
startPin);
370
383
unsigned
int
get_directions
(
int
endPin,
int
startPin);
384
397
unsigned
int
get_outputs
(
int
endPin,
int
startPin);
398
410
void
set_directions
(
int
endPin,
int
startPin,
unsigned
int
pattern);
411
423
void
set_outputs
(
int
endPin,
int
startPin,
unsigned
int
pattern);
424
435
void
pause
(
int
time);
436
458
#define pause_ticks(pticks) __builtin_propeller_waitcnt(pticks+CNT, 0)
459
466
void
mark
(
void
);
467
476
int
timeout
(
int
time);
477
488
void
wait
(
int
time);
489
500
void
set_pause_dt
(
int
clockticks);
501
511
long
count
(
int
pin,
long
duration);
512
541
void
dac_ctr
(
int
pin,
int
channel,
int
dacVal);
542
556
void
dac_ctr_res
(
int
bits);
557
565
void
dac_ctr_stop
(
void
);
566
577
void
freqout
(
int
pin,
int
msTime,
int
frequency);
578
593
int
pwm_start
(
unsigned
int
cycleMicroseconds);
594
620
void
pwm_set
(
int
pin,
int
channel,
int
tHigh);
621
629
void
pwm_stop
(
void
);
630
643
long
pulse_in
(
int
pin,
int
state);
644
660
void
pulse_out
(
int
pin,
int
time);
661
677
long
rc_time
(
int
pin,
int
state);
678
697
void
square_wave
(
int
pin,
int
channel,
int
freq);
698
706
void
square_wave_stop
(
void
);
707
717
void
set_io_timeout
(
long
clockTicks);
718
729
void
set_io_dt
(
long
clockticks);
730
731
743
int
shift_in
(
int
pinDat,
int
pinClk,
int
mode,
int
bits);
744
754
void
shift_out
(
int
pinDat,
int
pinClk,
int
mode,
int
bits,
int
value);
755
776
i2c *
i2c_newbus
(
int
sclpin,
int
sdapin,
int
scldrive);
777
778
806
HUBTEXT
int
i2c_out
(i2c *bus,
int
i2cAddr,
807
const
unsigned
char
*regAddr,
int
regSize,
808
const
unsigned
char
*data,
int
count
);
809
810
839
HUBTEXT
int
i2c_in
(i2c *bus,
int
i2cAddr,
840
const
unsigned
char
*regAddr,
int
regSize,
841
unsigned
char
*data,
int
count
);
842
843
852
void
ee_putByte
(
char
value,
int
addr);
853
857
#define ee_put_byte ee_putByte
858
859
869
char
ee_getByte
(
int
addr);
870
874
#define ee_get_byte ee_getByte
875
876
886
void
ee_putInt
(
int
value,
int
addr);
887
891
#define ee_put_int ee_putInt
892
893
903
int
ee_getInt
(
int
addr);
904
908
#define ee_get_int ee_getInt
909
910
921
void
ee_putStr
(
unsigned
char
*s,
int
n,
int
addr);
922
926
#define ee_put_str ee_putStr
927
928
943
char
*
ee_getStr
(
unsigned
char
* s,
int
n,
int
addr);
944
948
#define ee_get_str ee_getStr
949
950
965
void
ee_putFloat32
(
float
value,
int
addr);
966
970
#define ee_put_float32 ee_putFloat32
971
972
988
float
ee_getFloat32
(
int
addr);
989
993
#define ee_get_float32 ee_getFloat32
994
995
1009
int
sd_mount
(
int
doPin,
int
clkPin,
int
diPin,
int
csPin);
1010
1024
char
*
itoa
(
int
i,
char
b[],
int
base);
1025
1026
int
add_driver(_Driver *driverAddr);
1027
1028
#if defined(__cplusplus)
1029
}
1030
#endif
1031
/* __cplusplus */
1032
#endif
1033
/* SIMPLETOOLS_H */
1034
Generated on Tue Jul 9 2013 22:50:18 for simpletools library by
1.8.1.2