simpletools library
v0.98.1
Collection of convenience functions for common microcontroller tasks
simpletools.h
Go to the documentation of this file.
1
103
#ifndef SIMPLETOOLS_H
104
#define SIMPLETOOLS_H
105
106
#if defined(__cplusplus)
107
extern
"C"
{
108
#endif
109
110
#include <propeller.h>
111
#include "simpletext.h"
112
#include <driver.h>
113
#include <stdio.h>
114
#include <stdlib.h>
115
#include <string.h>
116
#include <cog.h>
117
#include <ctype.h>
118
#include <unistd.h>
119
#include <sys/stat.h>
120
#include <dirent.h>
121
#include <sys/sd.h>
122
#include <math.h>
123
#include "simplei2c.h"
124
125
129
extern
int
ms
;
130
131
135
extern
int
us
;
136
137
138
150
extern
int
st_msTicks
;
151
152
157
extern
int
st_usTicks
;
158
159
164
extern
int
st_iodt
;
165
170
extern
int
st_timeout
;
171
176
extern
int
st_pauseTicks
;
177
181
extern
int
st_mark
;
182
186
extern
unsigned
int
st_buscnt
;
187
191
extern
i2c *
st_eeprom
;
192
196
extern
int
st_eeInitFlag
;
197
198
205
#ifndef PI
206
209
#define PI 3.141592653589793
210
#endif
211
212
213
221
/* Values for use with SimpleIDE Terminal */
222
#ifndef HOME
223
226
#define HOME (1)
227
#endif
228
229
#ifndef CRSRXY
230
236
#define CRSRXY (2)
237
#endif
238
239
#ifndef CRSRLF
240
244
#define CRSRLF (3)
245
#endif
246
247
#ifndef CRSRRT
248
252
#define CRSRRT (4)
253
#endif
254
255
#ifndef CRSRUP
256
260
#define CRSRUP (5)
261
#endif
262
263
#ifndef CRSRDN
264
268
#define CRSRDN (6)
269
#endif
270
271
#ifndef BEEP
272
276
#define BEEP (7)
277
#endif
278
279
#ifndef BKSP
280
285
#define BKSP (8)
286
#endif
287
288
#ifndef TAB
289
293
#define TAB (9)
294
#endif
295
296
#ifndef NL
297
301
#define NL (10)
302
#endif
303
304
#ifndef LF
305
308
#define LF (10)
309
#endif
310
311
#ifndef CLREOL
312
316
#define CLREOL (11)
317
#endif
318
319
#ifndef CLRDN
320
324
#define CLRDN (12)
325
#endif
326
327
#ifndef CR
328
332
#define CR (13)
333
#endif
334
335
#ifndef CRSRX
336
340
#define CRSRX (14)
341
#endif
342
343
#ifndef CRSRY
344
348
#define CRSRY (15)
349
#endif
350
351
#ifndef CLS
352
356
#define CLS (16)
357
#endif
358
359
360
370
#ifndef MSBPRE
371
374
#define MSBPRE 0
375
#endif
376
377
#ifndef LSBPRE
378
381
#define LSBPRE 1
382
#endif
383
384
#ifndef MSBPOST
385
388
#define MSBPOST 2
389
#endif
390
391
#ifndef LSBPOST
392
395
#define LSBPOST 3
396
#endif
397
398
// Values for use with shift_out
399
#ifndef LSBFIRST
400
403
#define LSBFIRST 0
404
#endif
405
406
#ifndef MSBFIRST
407
410
#define MSBFIRST 1
411
#endif
412
413
414
424
#ifndef NCO_PWM_1
425
429
#define NCO_PWM_1 (0b00100 << 26)
430
#endif
431
432
#ifndef CTR_NCO
433
437
#define CTR_NCO (0b100 << 26)
438
#endif
439
440
#ifndef CTR_PLL
441
445
#define CTR_PLL (0b10 << 26)
446
#endif
447
448
#ifndef DUTY_SE
449
453
#define DUTY_SE (0b110 << 26)
454
#endif
455
456
457
470
#define ee_put_byte ee_putByte
471
472
476
#define ee_get_byte ee_getByte
477
478
482
#define ee_put_int ee_putInt
483
484
488
#define ee_get_int ee_getInt
489
490
494
#define ee_put_str ee_putStr
495
496
500
#define ee_get_str ee_getStr
501
502
506
#define ee_put_float32 ee_putFloat32
507
508
513
#define pause_ticks(pticks) __builtin_propeller_waitcnt(pticks+CNT, 0)
514
515
516
526
#ifndef EEPROM_ADDR
527
530
#define EEPROM_ADDR 0x50
531
#endif
532
533
534
551
void
high
(
int
pin);
552
553
564
void
low
(
int
pin);
565
566
581
int
input
(
int
pin);
582
583
584
604
unsigned
int
toggle
(
int
pin);
605
617
unsigned
int
reverse
(
int
pin);
618
619
637
unsigned
int
get_state
(
int
pin);
638
653
unsigned
int
get_direction
(
int
pin);
654
667
unsigned
int
get_output
(
int
pin);
668
677
void
set_direction
(
int
pin,
int
direction);
678
691
void
set_output
(
int
pin,
int
state);
692
693
694
717
unsigned
int
get_states
(
int
endPin,
int
startPin);
718
731
unsigned
int
get_directions
(
int
endPin,
int
startPin);
732
745
unsigned
int
get_outputs
(
int
endPin,
int
startPin);
746
758
void
set_directions
(
int
endPin,
int
startPin,
unsigned
int
pattern);
759
771
void
set_outputs
(
int
endPin,
int
startPin,
unsigned
int
pattern);
772
773
774
775
796
void
pause
(
int
time);
797
808
void
set_pause_dt
(
int
clockticks);
809
810
811
812
832
long
count
(
int
pin,
long
duration);
833
862
void
dac_ctr
(
int
pin,
int
channel,
int
dacVal);
863
877
void
dac_ctr_res
(
int
bits);
878
886
void
dac_ctr_stop
(
void
);
887
898
void
freqout
(
int
pin,
int
msTime,
int
frequency);
899
914
int
pwm_start
(
unsigned
int
cycleMicroseconds);
915
941
void
pwm_set
(
int
pin,
int
channel,
int
tHigh);
942
950
void
pwm_stop
(
void
);
951
964
long
pulse_in
(
int
pin,
int
state);
965
981
void
pulse_out
(
int
pin,
int
time);
982
998
long
rc_time
(
int
pin,
int
state);
999
1018
void
square_wave
(
int
pin,
int
channel,
int
freq);
1019
1027
void
square_wave_stop
(
void
);
1028
1038
void
set_io_timeout
(
long
clockTicks);
1039
1050
void
set_io_dt
(
long
clockticks);
1051
1052
1053
1054
1076
int
shift_in
(
int
pinDat,
int
pinClk,
int
mode,
int
bits);
1077
1087
void
shift_out
(
int
pinDat,
int
pinClk,
int
mode,
int
bits,
int
value);
1088
1089
1090
1091
1120
i2c *
i2c_newbus
(
int
sclPin,
int
sdaPin,
int
sclDrive);
1121
1122
1150
HUBTEXT
int
i2c_out
(i2c *busID,
int
i2cAddr,
1151
int
memAddr,
int
memAddrCount,
1152
const
unsigned
char
*data,
int
dataCount);
1153
1154
1182
HUBTEXT
int
i2c_in
(i2c *busID,
int
i2cAddr,
1183
int
memAddr,
int
memAddrCount,
1184
unsigned
char
*data,
int
dataCount);
1185
1186
1196
HUBTEXT
int
i2c_busy
(i2c *busID,
int
i2cAddr);
1197
1198
1199
1200
1220
void
ee_putByte
(
unsigned
char
value,
int
addr);
1221
1231
char
ee_getByte
(
int
addr);
1232
1233
1243
void
ee_putInt
(
int
value,
int
addr);
1244
1254
int
ee_getInt
(
int
addr);
1255
1266
void
ee_putStr
(
unsigned
char
*s,
int
n,
int
addr);
1267
1282
unsigned
char
*
ee_getStr
(
unsigned
char
* s,
int
n,
int
addr);
1283
1298
void
ee_putFloat32
(
float
value,
int
addr);
1299
1315
float
ee_getFloat32
(
int
addr);
1316
1338
void
ee_config
(
int
sclPin,
int
sdaPin,
int
sclDrive);
1339
1340
1341
1365
int
sd_mount
(
int
doPin,
int
clkPin,
int
diPin,
int
csPin);
1366
1367
1368
1404
int
*
cog_run
(
void
(*
function
)(
void
*par),
int
stacksize);
1405
1406
1414
int
cog_num
(
int
*coginfo);
1415
1416
1426
void
cog_end
(
int
*coginfo);
1427
1428
1429
1452
void
endianSwap
(
void
*resultAddr,
void
*varAddr,
int
byteCount);
1453
1454
1455
1479
void
mark
(
void
);
1480
1503
int
timeout
(
int
time);
1504
1531
void
wait
(
int
time);
1532
1533
1534
1541
#if defined(__cplusplus)
1542
}
1543
#endif
1544
/* __cplusplus */
1545
#endif
1546
/* SIMPLETOOLS_H */
1547
Generated on Mon Aug 25 2014 11:07:07 for simpletools library by
1.8.1.2