Skip to content

Commit eab4fc9

Browse files
authored
Merge pull request #52 from chauhan-bhargav/master
Added driver for Sunlight sensor for PYNQ Bootcamp
2 parents bb813b8 + ff96ed2 commit eab4fc9

File tree

8 files changed

+890
-1
lines changed

8 files changed

+890
-1
lines changed
209 KB
Loading
22.3 KB
Loading
23.3 KB
Loading
42.1 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#pragma once
2+
3+
#include <grove_constants.h>
4+
#include <pytypes.h>
5+
#include <stdint.h>
6+
7+
// Device typedef
8+
typedef py_int grove_sunlight;
9+
10+
//defines
11+
#define DEVICE_ADDRESS 0x53
12+
#define RESET_CMD_CTR 0x00
13+
#define RESET_SW 0x01
14+
#define FORCE 0x11
15+
#define PAUSE 0x12
16+
#define START 0x13
17+
18+
#define PART_ID 0x00
19+
#define REV_ID 0x01
20+
#define MFR_ID 0x02
21+
#define INFO_0 0x03
22+
#define INFO_1 0x04
23+
#define HOSTIN_3 0x07
24+
#define HOSTIN_2 0x08
25+
26+
#define HOSTIN_0 0x0A
27+
#define COMMAND 0x0B
28+
#define IRQ_ENABLE 0x0F
29+
#define RESPONSE_0 0x11
30+
#define RESPONSE_1 0x10
31+
32+
#define IRQ_STATUS 0x12
33+
#define HOSTOUT_0 0x13
34+
#define HOSTOUT_1 0x14
35+
#define HOSTOUT_2 0x15
36+
#define HOSTOUT_3 0x16
37+
#define HOSTOUT_4 0x17
38+
#define HOSTOUT_5 0x18
39+
#define HOSTOUT_6 0x19
40+
#define HOSTOUT_7 0x1A
41+
#define HOSTOUT_8 0x1B
42+
#define HOSTOUT_9 0x1C
43+
#define HOSTOUT_10 0x1D
44+
#define HOSTOUT_11 0x1E
45+
#define HOSTOUT_12 0x1F
46+
#define HOSTOUT_13 0x20
47+
#define HOSTOUT_14 0x21
48+
#define HOSTOUT_15 0x22
49+
#define HOSTOUT_16 0x23
50+
#define HOSTOUT_17 0x24
51+
#define HOSTOUT_18 0x25
52+
#define HOSTOUT_19 0x26
53+
#define HOSTOUT_20 0x27
54+
#define HOSTOUT_21 0x28
55+
#define HOSTOUT_22 0x29
56+
#define HOSTOUT_23 0x2A
57+
#define HOSTOUT_24 0x2B
58+
#define HOSTOUT_25 0x2C
59+
60+
#define I2C_ADDR 0x00
61+
#define CHAN_LIST 0x01
62+
63+
#define ADCCONFIG_0 0x02
64+
#define ADCSENS_0 0x03
65+
#define ADCPOST_0 0x04
66+
#define MEASCONFIG_0 0x05
67+
68+
#define ADCCONFIG_1 0x06
69+
#define ADCPOST_1 0x08
70+
#define ADCSENS_1 0x07
71+
#define MEASCONFIG_1 0x09
72+
73+
#define ADCCONFIG_2 0x0A
74+
#define ADCSENS_2 0x0B
75+
#define ADCPOST_2 0x0C
76+
#define MEASCONFIG_2 0x0D
77+
78+
#define ADCCONFIG_3 0x0E
79+
#define ADCSENS_3 0x0F
80+
#define ADCPOST_3 0x10
81+
#define MEASCONFIG_3 0x11
82+
83+
#define ADCCONFIG_4 0x12
84+
#define ADCSENS_4 0x13
85+
#define ADCPOST_4 0x14
86+
#define MEASCONFIG_4 0x15
87+
88+
#define ADCCONFIG_5 0x16
89+
#define ADCSENS_5 0x17
90+
#define ADCPOST_5 0x18
91+
#define MEASCONFIG_5 0x19
92+
93+
#define MEASRATE_H 0x1A
94+
#define MEASRATE_L 0x1B
95+
#define MEASCOUNT_0 0x1C
96+
#define MEASCOUNT_1 0x1D
97+
#define MEASCOUNT_2 0x1E
98+
99+
#define LED1_A 0x1F
100+
#define LED1_B 0x20
101+
#define LED2_A 0x21
102+
#define LED2_B 0x22
103+
#define LED3_A 0x23
104+
#define LED3_B 0x24
105+
106+
#define THRESHOLD0_H 0x25
107+
#define THRESHOLD0_L 0x26
108+
#define THRESHOLD1_H 0x27
109+
#define THRESHOLD1_L 0x28
110+
#define THRESHOLD2_H 0x29
111+
#define THRESHOLD2_L 0x2A
112+
113+
#define BURST 0x2B
114+
115+
116+
// Device lifetime functions
117+
grove_sunlight grove_sunlight_open(int grove_id);
118+
void grove_sunlight_close(grove_sunlight p);
119+
120+
// Device functions
121+
//void grove_sunlight_example(grove_sunlight p, const char* buffer, int length);
122+
123+
py_int grove_sunlight_is_device_ready(grove_sunlight p);
124+
125+
py_int grove_sunlight_configure_sunlight_sensor(grove_sunlight p);
126+
127+
py_int grove_sunlight_read_visible_light(grove_sunlight p);
128+
129+
py_int grove_sunlight_read_infrared_light(grove_sunlight p);
130+
131+
py_float grove_sunlight_read_ultravoilet_light(grove_sunlight p);
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+

0 commit comments

Comments
 (0)