Commit eb82fd70347b1aa606ed13cad750a30e1d02831e
1 parent
f72e80af
--no commit message
Showing
5 changed files
with
194 additions
and
43 deletions
Project/applications/smartcities/.cproject
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
2 | +<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> | ||
3 | + <storageModule moduleId="org.eclipse.cdt.core.settings"> | ||
4 | + <cconfiguration id="0.1346025819"> | ||
5 | + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1346025819" moduleId="org.eclipse.cdt.core.settings" name="Default"> | ||
6 | + <externalSettings/> | ||
7 | + <extensions> | ||
8 | + <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
9 | + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
10 | + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> | ||
11 | + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
12 | + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
13 | + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
14 | + </extensions> | ||
15 | + </storageModule> | ||
16 | + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> | ||
17 | + <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1346025819" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg"> | ||
18 | + <folderInfo id="0.1346025819." name="/" resourcePath=""> | ||
19 | + <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.2133444034" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain"> | ||
20 | + <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.2133444034.188848607" name=""/> | ||
21 | + <builder id="org.eclipse.cdt.build.core.settings.default.builder.149909515" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/> | ||
22 | + <tool id="org.eclipse.cdt.build.core.settings.holder.libs.2110133536" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/> | ||
23 | + <tool id="org.eclipse.cdt.build.core.settings.holder.1682403289" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
24 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1787663460" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
25 | + </tool> | ||
26 | + <tool id="org.eclipse.cdt.build.core.settings.holder.101893097" name="UPC" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
27 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1170982175" languageId="org.eclipse.cdt.core.parser.upc.upc" languageName="UPC" sourceContentType="org.eclipse.cdt.core.parser.upc.upcSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
28 | + </tool> | ||
29 | + <tool id="org.eclipse.cdt.build.core.settings.holder.271471685" name="LLVM bytecode assembly" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
30 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1615809395" languageId="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssembly" languageName="LLVM bytecode assembly" sourceContentType="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssemblySource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
31 | + </tool> | ||
32 | + <tool id="org.eclipse.cdt.build.core.settings.holder.523044175" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
33 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.862068615" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
34 | + </tool> | ||
35 | + <tool id="org.eclipse.cdt.build.core.settings.holder.1605230744" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
36 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.473630919" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
37 | + </tool> | ||
38 | + </toolChain> | ||
39 | + </folderInfo> | ||
40 | + </configuration> | ||
41 | + </storageModule> | ||
42 | + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> | ||
43 | + </cconfiguration> | ||
44 | + <cconfiguration id="0.1346025819.607674731"> | ||
45 | + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1346025819.607674731" moduleId="org.eclipse.cdt.core.settings" name="smartcities"> | ||
46 | + <externalSettings/> | ||
47 | + <extensions> | ||
48 | + <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
49 | + <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
50 | + <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> | ||
51 | + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
52 | + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
53 | + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> | ||
54 | + </extensions> | ||
55 | + </storageModule> | ||
56 | + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> | ||
57 | + <configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1346025819.607674731" name="smartcities" parent="org.eclipse.cdt.build.core.prefbase.cfg"> | ||
58 | + <folderInfo id="0.1346025819.607674731." name="/" resourcePath=""> | ||
59 | + <toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1592903170" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain"> | ||
60 | + <targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1592903170.1667514691" name=""/> | ||
61 | + <builder buildPath="${workspace_loc:/smartcities}" command="make" id="org.eclipse.cdt.build.core.settings.default.builder.851317214" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/> | ||
62 | + <tool id="org.eclipse.cdt.build.core.settings.holder.libs.2068283138" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/> | ||
63 | + <tool id="org.eclipse.cdt.build.core.settings.holder.2119795676" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
64 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1496390785" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
65 | + </tool> | ||
66 | + <tool id="org.eclipse.cdt.build.core.settings.holder.972184461" name="UPC" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
67 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1621684940" languageId="org.eclipse.cdt.core.parser.upc.upc" languageName="UPC" sourceContentType="org.eclipse.cdt.core.parser.upc.upcSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
68 | + </tool> | ||
69 | + <tool id="org.eclipse.cdt.build.core.settings.holder.872209065" name="LLVM bytecode assembly" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
70 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.645721644" languageId="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssembly" languageName="LLVM bytecode assembly" sourceContentType="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssemblySource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
71 | + </tool> | ||
72 | + <tool id="org.eclipse.cdt.build.core.settings.holder.896878809" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
73 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.301865645" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
74 | + </tool> | ||
75 | + <tool id="org.eclipse.cdt.build.core.settings.holder.728194814" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder"> | ||
76 | + <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.178672071" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/> | ||
77 | + </tool> | ||
78 | + </toolChain> | ||
79 | + </folderInfo> | ||
80 | + </configuration> | ||
81 | + </storageModule> | ||
82 | + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> | ||
83 | + </cconfiguration> | ||
84 | + </storageModule> | ||
85 | + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> | ||
86 | + <project id="smartcities.null.681823964" name="smartcities"/> | ||
87 | + </storageModule> | ||
88 | + <storageModule moduleId="scannerConfiguration"> | ||
89 | + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
90 | + <scannerConfigBuildInfo instanceId="0.1671097709"> | ||
91 | + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
92 | + </scannerConfigBuildInfo> | ||
93 | + <scannerConfigBuildInfo instanceId="0.1346025819"> | ||
94 | + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> | ||
95 | + </scannerConfigBuildInfo> | ||
96 | + </storageModule> | ||
97 | + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> | ||
98 | + <storageModule moduleId="refreshScope" versionNumber="2"> | ||
99 | + <configuration configurationName="Default"> | ||
100 | + <resource resourceType="PROJECT" workspacePath="/smartcities"/> | ||
101 | + </configuration> | ||
102 | + </storageModule> | ||
103 | +</cproject> |
Project/applications/smartcities/.project
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<projectDescription> | ||
3 | + <name>smartcities</name> | ||
4 | + <comment></comment> | ||
5 | + <projects> | ||
6 | + </projects> | ||
7 | + <buildSpec> | ||
8 | + <buildCommand> | ||
9 | + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> | ||
10 | + <triggers>clean,full,incremental,</triggers> | ||
11 | + <arguments> | ||
12 | + </arguments> | ||
13 | + </buildCommand> | ||
14 | + <buildCommand> | ||
15 | + <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name> | ||
16 | + <triggers>full,incremental,</triggers> | ||
17 | + <arguments> | ||
18 | + </arguments> | ||
19 | + </buildCommand> | ||
20 | + </buildSpec> | ||
21 | + <natures> | ||
22 | + <nature>org.eclipse.cdt.core.cnature</nature> | ||
23 | + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> | ||
24 | + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> | ||
25 | + </natures> | ||
26 | +</projectDescription> |
Project/applications/smartcities/include/sensors.h
@@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
2 | #define SENSORS_H | 2 | #define SENSORS_H |
3 | 3 | ||
4 | #include <stdint.h> | 4 | #include <stdint.h> |
5 | +#include <stdio.h> | ||
6 | +#include "i2c.h" | ||
7 | +#include "libwismart.h" | ||
5 | 8 | ||
6 | 9 | ||
7 | typedef struct { | 10 | typedef struct { |
@@ -11,7 +14,13 @@ typedef struct { | @@ -11,7 +14,13 @@ typedef struct { | ||
11 | char* unit; | 14 | char* unit; |
12 | } sensor; | 15 | } sensor; |
13 | 16 | ||
14 | -extern sensor humidity_sensor; | 17 | +// PRESSURE SENSOR FUNCTIONS |
15 | 18 | ||
19 | +extern sensor pressure_sensor; | ||
20 | +uint16_t get_pressure_data(void); | ||
21 | +void pressure_start_conversion(void); | ||
22 | +void pressure_get_coefficients(void); | ||
23 | +uint16_t pressure_read_pressure_data(void); | ||
24 | +uint16_t pressure_process_data(uint16_t data); | ||
16 | 25 | ||
17 | #endif | 26 | #endif |
18 | \ No newline at end of file | 27 | \ No newline at end of file |
Project/applications/smartcities/main_demo.c
@@ -47,26 +47,6 @@ int main(void) | @@ -47,26 +47,6 @@ int main(void) | ||
47 | 47 | ||
48 | I2C_init(); | 48 | I2C_init(); |
49 | printf("I2C Initialized\r\n"); | 49 | printf("I2C Initialized\r\n"); |
50 | - /*I2C_start(I2C1,0x77 << 1, I2C_Direction_Transmitter); | ||
51 | - I2C_write(I2C1, 0xF4); | ||
52 | - I2C_write(I2C1, 0x2E); | ||
53 | - I2C_stop(I2C1); | ||
54 | - printf("I2C Temperature measurment started\r\n"); | ||
55 | - | ||
56 | - I2C_start(I2C1,0x77 << 1, I2C_Direction_Transmitter); | ||
57 | - I2C_write(I2C1, 0xF6); | ||
58 | - I2C_stop(I2C1); | ||
59 | - printf("I2C Temperature measurment request sent\r\n"); | ||
60 | - | ||
61 | - I2C_start(I2C1, 0x77<<1, I2C_Direction_Receiver); | ||
62 | - printf("I2C Read request sent\r\n"); | ||
63 | - received_data = I2C_read_ack(I2C1); | ||
64 | - received_data = received_data << 8; | ||
65 | - received_data = received_data | I2C_read_ack(I2C1); | ||
66 | - printf("I2C data received\r\n"); | ||
67 | - | ||
68 | - sprintf(answer,"%d",received_data); | ||
69 | - printf("Data: %s\r\n",answer);*/ | ||
70 | 50 | ||
71 | I2C_start(I2C1,0x39 << 1, I2C_Direction_Transmitter); | 51 | I2C_start(I2C1,0x39 << 1, I2C_Direction_Transmitter); |
72 | I2C_write(I2C1, 0x0C); | 52 | I2C_write(I2C1, 0x0C); |
@@ -118,27 +98,6 @@ int main(void) | @@ -118,27 +98,6 @@ int main(void) | ||
118 | 98 | ||
119 | for(;;) | 99 | for(;;) |
120 | { | 100 | { |
121 | - /*// i2c get info= data | ||
122 | - char* data=NULL; | ||
123 | - put_message(data, buffer ,&ind); | ||
124 | - int res=check_memory(); | ||
125 | - if(res==SOFT_REACHED){ | ||
126 | - | ||
127 | - int ok=send(buffer, ind, "", ""); | ||
128 | - if(ok==JSON_COMM_ERROR) | ||
129 | - { | ||
130 | - printf("wismart is not connected\r\n"); | ||
131 | - } | ||
132 | - else if( ok==JSON_OTHER_ERROR){ | ||
133 | - printf("some error ocurred\r\n"); | ||
134 | - } | ||
135 | - else if(ok ==JSON_POST_OK){ | ||
136 | - printf(" send OK \r\n"); | ||
137 | - } | ||
138 | - } | ||
139 | - else if(res==HARD_REACHED){ | ||
140 | - destroy(buffer); | ||
141 | - }*/ | ||
142 | chThdSleepMilliseconds(500); | 101 | chThdSleepMilliseconds(500); |
143 | } | 102 | } |
144 | } | 103 | } |
Project/applications/smartcities/sensors.c
1 | #include "sensors.h" | 1 | #include "sensors.h" |
2 | 2 | ||
3 | -sensor humidity_sensor = {0x77, "Humidity sensor", "humidity", "%"}; /* append 0/1 flag for read write */ | 3 | +sensor pressure_sensor = {0xC0, "Presure sensor", "pressure", "KPa"}; /* append 0/1 flag for read write */ |
4 | + | ||
5 | +uint16_t get_pressure_data() | ||
6 | +{ | ||
7 | + I2C_init(); | ||
8 | + printf("I2C Initialized\r\n"); | ||
9 | + pressure_start_conversion(); | ||
10 | + chThdSleepMilliseconds(10000); | ||
11 | + pressure_get_coefficients(); | ||
12 | + return pressure_process_data(pressure_read_pressure_data()); | ||
13 | +} | ||
14 | + | ||
15 | +void pressure_start_conversion() | ||
16 | +{ | ||
17 | + I2C_start(I2C1,pressure_sensor.ID << 1, I2C_Direction_Transmitter); | ||
18 | + I2C_write(I2C1, 0x12); | ||
19 | + I2C_stop(I2C1); | ||
20 | + printf("I2C Pressure measurment request sent\r\n"); | ||
21 | +} | ||
22 | + | ||
23 | +void pressure_get_coefficients() | ||
24 | +{ | ||
25 | + | ||
26 | +} | ||
27 | + | ||
28 | +uint16_t pressure_read_pressure_data() | ||
29 | +{ | ||
30 | + uint16_t received_data; | ||
31 | + I2C_start(I2C1,pressure_sensor.ID << 1, I2C_Direction_Transmitter); | ||
32 | + I2C_write(I2C1, 0x00); | ||
33 | + I2C_stop(I2C1); | ||
34 | + printf("I2C Read MSB pressure data sent\r\n"); | ||
35 | + | ||
36 | + I2C_start(I2C1, pressure_sensor.ID << 1, I2C_Direction_Receiver); | ||
37 | + printf("I2C Read request sent\r\n"); | ||
38 | + received_data = I2C_read_ack(I2C1); | ||
39 | + received_data = received_data << 8; | ||
40 | + printf("I2C data received\r\n"); | ||
41 | + | ||
42 | + I2C_start(I2C1,pressure_sensor.ID << 1, I2C_Direction_Transmitter); | ||
43 | + I2C_write(I2C1, 0x01); | ||
44 | + I2C_stop(I2C1); | ||
45 | + printf("I2C Read LSB pressure data sent\r\n"); | ||
46 | + | ||
47 | + I2C_start(I2C1, pressure_sensor.ID << 1, I2C_Direction_Receiver); | ||
48 | + printf("I2C Read request sent\r\n"); | ||
49 | + received_data = received_data | I2C_read_ack(I2C1); | ||
50 | + printf("I2C data received\r\n"); | ||
51 | + return received_data; | ||
52 | +} | ||
53 | + | ||
54 | +uint16_t pressure_process_data(uint16_t data) | ||
55 | +{ | ||
56 | + return data; | ||
57 | +} | ||
4 | \ No newline at end of file | 58 | \ No newline at end of file |