]> rtime.felk.cvut.cz Git - mf624-simulink.git/blobdiff - mf624_SIMULINK.c
Use correct header file for alloca for Linux build.
[mf624-simulink.git] / mf624_SIMULINK.c
index 59242a577a2105777acceafea5ee2ffb74eb57fe..94c3e0463854926f3f2722bc157874563097f552 100644 (file)
@@ -1,21 +1,35 @@
 /*
- * Application using MF624 UIO driver
+ * Common Humusoft MF624 card Simulink code for use with Linux UIO driver
  *
- * Copyright (C) 2011 Rostislav Lisovy <lisovy@gmail.com>
+ * Copyright (C) 2011-2014 Rostislav Lisovy <lisovy@gmail.com>
+ * Copyright (C) 2013 Michal Kreč <krecmich@fel.cvut.cz>
+ * Copyright (C) 2013 Michal Sojka <sojkam1@fel.cvut.cz>
  *
- * 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.
+ * Department of Control Engineering
+ * Faculty of Electrical Engineering
+ * Czech Technical University in Prague (CTU)
  *
- * 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.
+ * The ERT Linux support code can be distributed in compliance
+ * with GNU General Public License (GPL) version 2 or later.
+ * Other licence can negotiated with CTU.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Next exception is granted in addition to GPL.
+ * Instantiating or linking compiled version of this code
+ * to produce an application image/executable, does not
+ * by itself cause the resulting application image/executable
+ * to be covered by the GNU General Public License.
+ * This exception does not however invalidate any other reasons
+ * why the executable file might be covered by the GNU Public License.
+ * Publication of enhanced or derived S-function files is required
+ * although.
+ *
+ * Linux ERT code is available from
+ *    http://rtime.felk.cvut.cz/gitweb/ert_linux.git
+ * More CTU Linux target for Simulink components are available at
+ *    http://lintarget.sourceforge.net/
+ *
+ * sfuntmpl_basic.c by The MathWorks, Inc. has been used to accomplish
+ * required S-function structure.
  */
 
 #include <stdio.h>
@@ -216,6 +230,16 @@ double ADC_read(mf624_state_t* mfst, adc_channel_t channel)
        return 10.0 * ((int16_t) (result << 2)) / (double) 0x8000;
 }
 
+extern uint32_t IRC_mode_change(mf624_state_t* mfst, uint32_t change_mask, uint32_t change_val)
+{
+       /* This sequence should be protected by mutex to protect changes in multirate systems */
+       mfst->IRC_mode = (mfst->IRC_mode & ~change_mask) | (change_val & change_mask);
+       mf624_write32(mfst->IRC_mode, MFST2REG(mfst, 4, IRCCTRL_reg));
+        /*printf("change_mask 0x%08x, change_val 0x%08x\n", change_mask, change_val);*/
+        /*printf("IRC mode set to %08lx\n", mfst->IRC_mode);*/
+       return mfst->IRC_mode;
+}
+
 
 static int open_device(char* path) {
        int device_fd;