]> rtime.felk.cvut.cz Git - jenkicar/rpp-simulink.git/commitdiff
Adding support for library modules initialization.
authorCarlos Miguel Jenkins Pérez <carlos@jenkins.co.cr>
Sun, 19 May 2013 02:29:49 +0000 (04:29 +0200)
committerCarlos Miguel Jenkins Pérez <carlos@jenkins.co.cr>
Sun, 19 May 2013 02:29:49 +0000 (04:29 +0200)
34 files changed:
rpp/lib/rpp/README.txt
rpp/lib/rpp/generate.py
rpp/lib/rpp/include/RppConfig.h
rpp/lib/rpp/include/rpp.h
rpp/lib/rpp/include/rpp_ain.h
rpp/lib/rpp/include/rpp_aout.h
rpp/lib/rpp/include/rpp_can.h
rpp/lib/rpp/include/rpp_din.h
rpp/lib/rpp/include/rpp_dout.h
rpp/lib/rpp/include/rpp_eth.h
rpp/lib/rpp/include/rpp_fr.h
rpp/lib/rpp/include/rpp_hout.h
rpp/lib/rpp/include/rpp_lin.h
rpp/lib/rpp/include/rpp_mout.h
rpp/lib/rpp/include/rpp_pout.h
rpp/lib/rpp/include/rpp_sci.h
rpp/lib/rpp/include/rpp_sdc.h
rpp/lib/rpp/include/rpp_sdr.h
rpp/lib/rpp/src/rpp.c [new file with mode: 0644]
rpp/lib/rpp/src/rpp_ain.c
rpp/lib/rpp/src/rpp_aout.c
rpp/lib/rpp/src/rpp_can.c
rpp/lib/rpp/src/rpp_din.c
rpp/lib/rpp/src/rpp_dout.c
rpp/lib/rpp/src/rpp_eth.c
rpp/lib/rpp/src/rpp_fr.c
rpp/lib/rpp/src/rpp_hout.c
rpp/lib/rpp/src/rpp_lin.c
rpp/lib/rpp/src/rpp_mout.c
rpp/lib/rpp/src/rpp_pout.c
rpp/lib/rpp/src/rpp_sci.c
rpp/lib/rpp/src/rpp_sdc.c
rpp/lib/rpp/src/rpp_sdr.c
rpp/rpp/rpp_lib_support.m

index 7902e070fde43a6053cb4b6c541b0e904d9fc727..c90187373e6dd634ce80c5a228b92ede86488711 100644 (file)
@@ -58,7 +58,7 @@ Library file layout:
         to {mnemonic} module. The inclusion of this header can be configured
         in RppConfig.h using rppCONFIG_INCLUDE_{MNEMONIC} directive.
 
-    -> rpp_{mnemonic}.c
+    -> src/rpp_{mnemonic}.c
 
         Implementation of rpp_{mnemonic}.h's functions on top of the DRV
         library.
index c6c9c9e8896a174db981ada4230a6d899c044a6c..01faa88cb5cdba1231a1ec4dbf938fa2c843e94a 100755 (executable)
@@ -34,12 +34,6 @@ header = '''\
 
 '''
 
-config_doc = '''\
-/**
- * Modules include RPP configuration options
- */
-'''
-
 files = OrderedDict([
         ('din'  , 'Digital Input RPP API {type_name} file.'),
         ('dout' , 'Digital Output RPP API {type_name} file.'),
@@ -65,18 +59,18 @@ def generate_file(where, prefix, mne, ext, abstract, type_name):
 
         mneu=mne.upper()
         if ext == '.h':
-            f.write('#ifndef __RPP_{mneu}_H\n'.format(**locals()))
-            f.write('#define __RPP_{mneu}_H\n\n\n'.format(**locals()))
-            f.write('void rpp_{mne}_init();\n\n'.format(**locals()))
-            f.write('#endif /* __RPP_{mneu}_H */\n\n'.format(**locals()))
+            f.write(('#ifndef __RPP_{mneu}_H\n'
+                     '#define __RPP_{mneu}_H\n\n'
+                     '/**\n'
+                     ' * {mneu} module initialization.\n'
+                     ' * Call this method before using this module.\n'
+                     ' */\n'
+                     'void rpp_{mne}_init();\n\n\n'
+                     '#endif /* __RPP_{mneu}_H */\n\n').format(**locals()))
         else:
-            f.write('/**\n')
-            f.write(' * {mneu} module initialization.\n'.format(**locals()))
-            f.write(' * Call this method before using this module./\n')
-            f.write(' */\n')
-            f.write('void rpp_{mne}_init() {\n'.format(**locals()))
-            f.write('    // FIXME: Implement.\n')
-            f.write('}\n')
+            f.write(('void rpp_{mne}_init() {{\n'
+                     '    // FIXME: Implement.\n'
+                     '}}\n\n\n').format(**locals()))
 
 
 def generate_files():
@@ -86,15 +80,15 @@ def generate_files():
 
     if not os.path.exists('src'):
         os.makedirs('src')
-        
-    # Generate files
+
+    # Generate modules sources and header files
     for where, ext, type_name in [['include/', '.h', 'header'        ],
-                                  ['',         '.c', 'implementation']]:
+                                  ['src/',     '.c', 'implementation']]:
         for mne in files:
             abstract = files[mne].format(**locals())
             generate_file(where, 'rpp_', mne, ext, abstract, type_name)
 
-    # Generate config file
+    # Generate library config file
     with open('include/RppConfig.h', 'w') as f:
 
         # Write header
@@ -104,13 +98,16 @@ def generate_files():
                               abstract='RPP API configuration file.'))
 
         # Write include configuration options
-        f.write(config_doc)
+        f.write(('/**\n'
+                 '* Modules include RPP configuration options\n'
+                 '*/\n'))
+
         for mne in files:
             line = '#define rppCONFIG_INCLUDE_{mne}{{space}}1\n'.format(mne=mne.upper())
             f.write(line.format(space=((50-len(line)) * ' ')))
         f.write('\n\n')
 
-    # Generate API header file
+    # Generate main library header file
     with open('include/rpp.h', 'w') as f:
 
         # Write header
@@ -120,13 +117,45 @@ def generate_files():
                               abstract='RPP API library header file.'))
 
         # Include configuration file
-        f.write('#include "RppConfig.h"\n\n')
+        f.write('/* Include configuration and modules */\n'
+                '#include "RppConfig.h"\n\n')
 
         # Write includes
         for mne in files:
-            f.write('#if rppCONFIG_INCLUDE_{mne} == 1\n'.format(mne=mne.upper()))
-            f.write('#include "rpp_{mne}.h"\n'.format(mne=mne))
-            f.write('#endif\n\n')
+            mneu = mne.upper()
+            f.write(('#if rppCONFIG_INCLUDE_{mneu} == 1\n'
+                     '#include "rpp_{mne}.h"\n'
+                     '#endif\n\n').format(**locals()))
+
+        # Declare initialization function
+        f.write('\n/* Library main functions */\n'
+                '\n'
+                '/**\n'
+                ' * Library initialization function.\n'
+                ' * Call this method before using this library.\n'
+                ' */\n'
+                'void rpp_init();\n\n')
+
+    # Generate library main file
+    with open('src/rpp.c', 'w') as f:
+
+        # Write header
+        f.write(header.format(prefix='',
+                              mne='rpp',
+                              ext='.c',
+                              abstract='RPP API library implementation file.'))
+
+        # Include library file
+        f.write('#include "rpp.h"\n\n')
+
+        # Declare initialization function
+        f.write('void rpp_init() {\n\n')
+        for mne in files:
+            mneu = mne.upper()
+            f.write(('#if rppCONFIG_INCLUDE_{mneu} == 1\n'
+                     '    rpp_{mne}_init();\n'
+                     '#endif\n\n').format(**locals()))
+        f.write('}\n\n')
 
 
 if __name__ == '__main__':
index c1026d6b9dfe12bdebd9589c4746ba540c8721af..788b6f89f2413e00f08b23f0d6f91962159e614f 100644 (file)
@@ -26,8 +26,8 @@
 
 
 /**
- * Modules include RPP configuration options
- */
+* Modules include RPP configuration options
+*/
 #define rppCONFIG_INCLUDE_DIN            1
 #define rppCONFIG_INCLUDE_DOUT           1
 #define rppCONFIG_INCLUDE_AIN            1
index c8f0713b4f1f7fcc4b82d5cdd91dc25c09583f1e..55c4bc0813d326354e5fbb33877232b589525e1e 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 
+/* Include configuration and modules */
 #include "RppConfig.h"
 
 #if rppCONFIG_INCLUDE_DIN == 1
 #include "rpp_sdr.h"
 #endif
 
+
+/* Library main functions */
+
+/**
+ * Library initialization function.
+ * Call this method before using this library.
+ */
+void rpp_init();
+
index 62f3cf5f642fc8cf189bc30b93f38a4706cf8630..678d2256e8f742f1b9950e4cb8b303d80a4d79e2 100644 (file)
 #ifndef __RPP_AIN_H
 #define __RPP_AIN_H
 
+/**
+ * AIN module initialization.
+ * Call this method before using this module.
+ */
+void rpp_ain_init();
+
 
 #endif /* __RPP_AIN_H */
 
index 2c04264001b852032ea78400b68216c8045d48cd..b5145bba7f03fd326a8a8849e2455660f5f7634d 100644 (file)
 #ifndef __RPP_AOUT_H
 #define __RPP_AOUT_H
 
+/**
+ * AOUT module initialization.
+ * Call this method before using this module.
+ */
+void rpp_aout_init();
+
 
 #endif /* __RPP_AOUT_H */
 
index 4aff96875d5087068715422614cfe64e8f780f80..429527e839cfaa0a8afdf6565b5cd84399cbd395 100644 (file)
 #ifndef __RPP_CAN_H
 #define __RPP_CAN_H
 
+/**
+ * CAN module initialization.
+ * Call this method before using this module.
+ */
+void rpp_can_init();
+
 
 #endif /* __RPP_CAN_H */
 
index 4a5bc289ce356de4f8cf12c4225fc02c31c66cbd..9f7eea2891cbbf54536b1d8d19a6c31859263776 100644 (file)
 #ifndef __RPP_DIN_H
 #define __RPP_DIN_H
 
+/**
+ * DIN module initialization.
+ * Call this method before using this module.
+ */
+void rpp_din_init();
+
 
 #endif /* __RPP_DIN_H */
 
index d165638f7a7bfbb55d8b72b18f5a82b24200c139..781d66ec51954923c58d354d4493c006d4cf66bc 100644 (file)
 #ifndef __RPP_DOUT_H
 #define __RPP_DOUT_H
 
+/**
+ * DOUT module initialization.
+ * Call this method before using this module.
+ */
+void rpp_dout_init();
+
 
 #endif /* __RPP_DOUT_H */
 
index a5b450a09a90abd8db664bfbac8cd8ab9f3ca32b..b6c03ac6db48f000f7d0a54bd1144d0ab975fdcc 100644 (file)
 #ifndef __RPP_ETH_H
 #define __RPP_ETH_H
 
+/**
+ * ETH module initialization.
+ * Call this method before using this module.
+ */
+void rpp_eth_init();
+
 
 #endif /* __RPP_ETH_H */
 
index 1c29fbbb51199548eb0c694059bfd6b86d77c71b..48f40d110aae2dd79eda8c4d27f148e406d7b557 100644 (file)
 #ifndef __RPP_FR_H
 #define __RPP_FR_H
 
+/**
+ * FR module initialization.
+ * Call this method before using this module.
+ */
+void rpp_fr_init();
+
 
 #endif /* __RPP_FR_H */
 
index 9b48dc409a407e91b518213c2c745542469dd190..c92c2b6af1126940db61078fe21af90bd8992856 100644 (file)
 #ifndef __RPP_HOUT_H
 #define __RPP_HOUT_H
 
+/**
+ * HOUT module initialization.
+ * Call this method before using this module.
+ */
+void rpp_hout_init();
+
 
 #endif /* __RPP_HOUT_H */
 
index 0da4b05fdcdf6a15cbcca1cbddac71aaf747f166..cf9f02354b5b29c199297de7d306b24972c2561c 100644 (file)
 #ifndef __RPP_LIN_H
 #define __RPP_LIN_H
 
+/**
+ * LIN module initialization.
+ * Call this method before using this module.
+ */
+void rpp_lin_init();
+
 
 #endif /* __RPP_LIN_H */
 
index 85b45b46056093369f49ac234df016791768abc4..d32e361cec157625ea1207cfa61b5c163b2f9ae1 100644 (file)
 #ifndef __RPP_MOUT_H
 #define __RPP_MOUT_H
 
+/**
+ * MOUT module initialization.
+ * Call this method before using this module.
+ */
+void rpp_mout_init();
+
 
 #endif /* __RPP_MOUT_H */
 
index 07d1aaaa02272c150a16e69c9ceb12d2488295f1..fa222ad9a4e1c6a370e466b321cf7bae0d31c939 100644 (file)
 #ifndef __RPP_POUT_H
 #define __RPP_POUT_H
 
+/**
+ * POUT module initialization.
+ * Call this method before using this module.
+ */
+void rpp_pout_init();
+
 
 #endif /* __RPP_POUT_H */
 
index 05baca773cfcd56390f64baf006af438394372fd..c8c1a09685511e8700bdcd602a49e68d3d20834b 100644 (file)
 #ifndef __RPP_SCI_H
 #define __RPP_SCI_H
 
+/**
+ * SCI module initialization.
+ * Call this method before using this module.
+ */
+void rpp_sci_init();
+
 
 #endif /* __RPP_SCI_H */
 
index 6d74a6c12b47bb68b1f09e00943be96ce333b121..3df76b6019861da0166add0cce9104494578c360 100644 (file)
 #ifndef __RPP_SDC_H
 #define __RPP_SDC_H
 
+/**
+ * SDC module initialization.
+ * Call this method before using this module.
+ */
+void rpp_sdc_init();
+
 
 #endif /* __RPP_SDC_H */
 
index 8ce60316b31246b940fa7344e695fd4ff1e6b1ef..3475a97782f635399340379180f4454bbe05c7e0 100644 (file)
 #ifndef __RPP_SDR_H
 #define __RPP_SDR_H
 
+/**
+ * SDR module initialization.
+ * Call this method before using this module.
+ */
+void rpp_sdr_init();
+
 
 #endif /* __RPP_SDR_H */
 
diff --git a/rpp/lib/rpp/src/rpp.c b/rpp/lib/rpp/src/rpp.c
new file mode 100644 (file)
index 0000000..7f52293
--- /dev/null
@@ -0,0 +1,89 @@
+/* Copyright (C) 2013 Czech Technical University in Prague
+ *
+ * Authors:
+ *     - Carlos Jenkins <carlos@jenkins.co.cr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * File : rpp.c
+ * Abstract:
+ *     RPP API library implementation file.
+ *
+ * References:
+ *     RPP API documentation.
+ */
+
+
+#include "rpp.h"
+
+void rpp_init() {
+
+#if rppCONFIG_INCLUDE_DIN == 1
+    rpp_din_init();
+#endif
+
+#if rppCONFIG_INCLUDE_DOUT == 1
+    rpp_dout_init();
+#endif
+
+#if rppCONFIG_INCLUDE_AIN == 1
+    rpp_ain_init();
+#endif
+
+#if rppCONFIG_INCLUDE_AOUT == 1
+    rpp_aout_init();
+#endif
+
+#if rppCONFIG_INCLUDE_HOUT == 1
+    rpp_hout_init();
+#endif
+
+#if rppCONFIG_INCLUDE_POUT == 1
+    rpp_pout_init();
+#endif
+
+#if rppCONFIG_INCLUDE_MOUT == 1
+    rpp_mout_init();
+#endif
+
+#if rppCONFIG_INCLUDE_CAN == 1
+    rpp_can_init();
+#endif
+
+#if rppCONFIG_INCLUDE_LIN == 1
+    rpp_lin_init();
+#endif
+
+#if rppCONFIG_INCLUDE_FR == 1
+    rpp_fr_init();
+#endif
+
+#if rppCONFIG_INCLUDE_SCI == 1
+    rpp_sci_init();
+#endif
+
+#if rppCONFIG_INCLUDE_ETH == 1
+    rpp_eth_init();
+#endif
+
+#if rppCONFIG_INCLUDE_SDC == 1
+    rpp_sdc_init();
+#endif
+
+#if rppCONFIG_INCLUDE_SDR == 1
+    rpp_sdr_init();
+#endif
+
+}
+
index 7bc91edc72536aab509b8ff2fd0c56adb9dedcbf..d48918925db7338b3d686b7bebdb1d1b244b1d2a 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_ain_init() {
+    // FIXME: Implement.
+}
+
+
index 56848b05db487f33075a411d53263ad45b138ceb..2adf073035d56cf4c403162dcb98140f32fbf75a 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_aout_init() {
+    // FIXME: Implement.
+}
+
+
index 041eaee4a1fda3adb8873f6228de401377cece83..31b6096fc4172c7a14a1acf7fd71b8fb286c5185 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_can_init() {
+    // FIXME: Implement.
+}
+
+
index f9a1d8244b623ed7053d45c8f1ee40132933e83e..d9212eb1672feb7bab29fbae876254f60238b76a 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_din_init() {
+    // FIXME: Implement.
+}
+
+
index 668002925d9daf4314a191db22b0def95161a41b..317d0691bc5aa4d4367fc593f6410c636b946c16 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_dout_init() {
+    // FIXME: Implement.
+}
+
+
index 56f30dce71b0d5ef1c37810948ecef7796fd15a6..99b620b30af43ac82132786356586754ac7b8b7e 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_eth_init() {
+    // FIXME: Implement.
+}
+
+
index 26ad08d47c009f8fff9e92edbe5cdc7ddc137662..68b9198fe5a2e901d1382551af187feb224beca8 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_fr_init() {
+    // FIXME: Implement.
+}
+
+
index 146df8048fc461e20a37f142f569f760a2eac3f3..ad6bfb971228ff7928f5510988065d036601efeb 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_hout_init() {
+    // FIXME: Implement.
+}
+
+
index 9dcb3c9aa2e397e7b0af35c5f262857b86fa9e76..75fe14f376b4da1569437dd787eaac03b20b3262 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_lin_init() {
+    // FIXME: Implement.
+}
+
+
index 1a102149488ee4843ac93efcdc133df632dbde3f..af2aa6fc5790dfea198c8d42d92de3750bcb3852 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_mout_init() {
+    // FIXME: Implement.
+}
+
+
index 96d8c0d0533959eb16bda32d8e6f8b0ca6fea020..5968063f4dd2cf6948974c7e0274720167e2ea10 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_pout_init() {
+    // FIXME: Implement.
+}
+
+
index 2c40e5498f2a4047b2e1fe31bce61a4c492ab708..9967125b57ae96e51f4bb08980875baa9f31b369 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_sci_init() {
+    // FIXME: Implement.
+}
+
+
index dcdf9d7a169563e7e616aed67e030940f16a2d21..f3882ff1f9aa7177cd985792c45be1b3def1fd07 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_sdc_init() {
+    // FIXME: Implement.
+}
+
+
index 10a9fc93944a7017fdcf279f6b9624e198372bd5..aa3257f3547d7f54f356c73a8da0c55a691fd97f 100644 (file)
@@ -25,3 +25,8 @@
  */
 
 
+void rpp_sdr_init() {
+    // FIXME: Implement.
+}
+
+
index 20cab15922a0f9774696b5acd1ad5a45d5add60a..ad164e093f225b720ba7e55b016154972e147832 100644 (file)
@@ -45,7 +45,7 @@ function rpp_freertos_support(modelName, buildInfo)
                'timers.c'   };
 
     % Get working directories
-    osLibRoot = fullfile(getpref('rpp', 'RppLibRoot'), 'os');
+    osLibRoot = fullfile(getpref('rpp', 'RppLibRoot'), 'os', 'src');
     % TODO: get suffix from rpp.tlc BuildDirSuffix
     modelRoot = Simulink.fileGenControl('getConfig').CodeGenFolder;
     outputFolder = fullfile(modelRoot, [modelName, '_rpp']);