simpletools library
v0.8
Collection of convenience functions for common microcontroller tasks
Main Page
Files
File List
Globals
simpletools.h
Go to the documentation of this file.
1
47
#ifndef SIMPLETOOLS_H
48
#define SIMPLETOOLS_H
49
50
#if defined(__cplusplus)
51
extern
"C"
{
52
#endif
53
54
#include <propeller.h>
55
#include <driver.h>
56
#include <stdio.h>
57
#include <stdlib.h>
58
#include <string.h>
59
#include <cog.h>
60
#include <ctype.h>
61
#include <unistd.h>
62
#include <sys/stat.h>
63
#include <dirent.h>
64
#include <sys/sd.h>
65
#include <i2c.h>
66
#include <math.h>
67
68
// Global variables shared by functions in separate files
69
extern
long
iodt;
70
extern
long
t_timeout;
71
extern
long
pauseTicks;
72
extern
long
t_mark;
73
extern
char
setForget;
74
extern
int
fdserDriverIndex;
75
extern
unsigned
int
buscnt;
76
//extern int dacCtrBits;
77
78
#ifndef PI
79
#define PI 3.141592653589793
80
#endif
81
82
#ifndef EEPROM_ADDR
83
#define EEPROM_ADDR 0xA0
84
#endif
85
86
87
// Values for use with SimpleIDE Terminal
88
#define HOME 1
89
#define CRSRXY 2
90
#define CRSRLF 3
91
#define CRSRRT 4
92
#define CRSRUP 5
93
#define CRSRDN 6
94
#define BEEP 7
95
#define BKSP 8
96
#define TAB 9
97
#define NL 10
98
#define CLREOL 11
99
#define CLRDN 12
100
#define CR 13
101
#define CRSRX 14
102
#define CRSRY 15
103
#define CLS 16
104
105
// Values for use with shift_in
106
#define MSBPRE 0
107
#define LSBPRE 1
108
#define MSBPOST 2
109
#define LSBPOST 3
110
111
// Values for use with shift_out
112
#define LSBFIRST 0
113
#define MSBFIRST 1
114
115
// Counter module values
116
#ifndef NCO_PWM_1
117
#define NCO_PWM_1 (0b00100 << 26)
118
#endif
119
#ifndef CTR_NCO
120
#define CTR_NCO (0b100 << 26)
121
#endif
122
#ifndef CTR_PLL
123
#define CTR_PLL (0b10 << 26)
124
#endif
125
#ifndef DUTY_SE
126
#define DUTY_SE (0b110 << 26)
127
#endif
128
129
// Define types for simplified driver declarations
130
typedef
FILE* serial;
131
typedef
FILE* fdserial;
132
typedef
FILE* sdcard;
133
typedef
I2C* i2c;
134
145
void
high
(
int
pin);
146
157
void
low
(
int
pin);
158
170
unsigned
int
toggle
(
int
pin);
171
185
unsigned
int
input
(
int
pin);
186
198
unsigned
int
reverse
(
int
pin);
199
217
unsigned
int
get_state
(
int
pin);
218
233
unsigned
int
get_direction
(
int
pin);
234
247
unsigned
int
get_output
(
int
pin);
248
257
void
set_direction
(
int
pin,
int
direction);
258
271
void
set_output
(
int
pin,
int
state);
272
286
unsigned
int
get_states
(
int
endPin,
int
startPin);
287
300
unsigned
int
get_directions
(
int
endPin,
int
startPin);
301
314
unsigned
int
get_outputs
(
int
endPin,
int
startPin);
315
327
void
set_directions
(
int
endPin,
int
startPin,
unsigned
int
pattern);
328
340
void
set_outputs
(
int
endPin,
int
startPin,
unsigned
int
pattern);
341
352
void
pause
(
int
time);
353
375
#define pause_ticks(pticks) __builtin_propeller_waitcnt(pticks+CNT, 0)
376
383
void
mark
(
void
);
384
393
int
timeout
(
int
time);
394
405
void
wait
(
int
time);
406
417
void
set_pause_dt
(
int
clockticks);
418
428
long
count
(
int
pin,
long
duration);
429
458
void
dac_ctr
(
int
pin,
int
channel,
int
dacVal);
459
473
void
dac_ctr_res
(
int
bits);
474
482
void
dac_ctr_stop
(
void
);
483
494
void
freqout
(
int
pin,
int
msTime,
int
frequency);
495
510
int
pwm_start
(
unsigned
int
cycleMicroseconds);
511
537
void
pwm_set
(
int
pin,
int
channel,
int
tHigh);
538
546
void
pwm_stop
(
void
);
547
560
long
pulse_in
(
int
pin,
int
state);
561
577
void
pulse_out
(
int
pin,
int
time);
578
594
long
rc_time
(
int
pin,
int
state);
595
614
void
square_wave
(
int
pin,
int
channel,
int
freq);
615
623
void
square_wave_stop
(
void
);
624
634
void
set_io_timeout
(
long
clockTicks);
635
646
void
set_io_dt
(
long
clockticks);
647
648
660
int
shift_in
(
int
pinDat,
int
pinClk,
int
mode,
int
bits);
661
671
void
shift_out
(
int
pinDat,
int
pinClk,
int
mode,
int
bits,
int
value);
672
684
FILE*
sser_setTxRx
(
int
pinTxOut,
int
pinRxIn,
int
baudRate);
685
705
FILE*
sser_setTx
(
int
pinTxOut,
int
baudRate);
706
716
FILE*
sser_setRx
(
int
pinRxIn,
int
baudRate);
717
723
int
sser_close
(FILE* peripheral);
724
748
FILE*
fdser_start
(
int
pinTxOut,
int
pinRxIn,
int
baudRate,
int
mode);
749
755
int
fdser_stop
(FILE* peripheral);
756
770
I2C*
i2c_newbus
(
int
sclpin,
int
sdapin);
771
780
void
ee_put_byte
(
char
value,
int
addr);
781
791
char
ee_get_byte
(
int
addr);
792
802
void
ee_put_int
(
int
value,
int
addr);
803
813
int
ee_get_int
(
int
addr);
814
825
void
ee_put_str
(
char
* s,
int
n,
int
addr);
826
841
char
*
ee_get_str
(
char
* s,
int
n,
int
addr);
842
857
void
ee_put_float32
(
float
value,
int
addr);
858
874
float
ee_get_float32
(
int
addr);
875
889
int
sd_mount
(
int
doPin,
int
clkPin,
int
diPin,
int
csPin);
890
904
char
*
itoa
(
int
i,
char
b[],
int
base);
905
906
int
add_driver(_Driver *driverAddr);
907
908
909
#if defined(__cplusplus)
910
}
911
#endif
912
/* __cplusplus */
913
#endif
914
/* SIMPLETOOLS_H */
915
Generated on Mon Apr 29 2013 17:02:37 for simpletools library by
1.8.1.2