skel.h
Go to the documentation of this file.
00001 /*
00002         Aseba - an event-based framework for distributed robot control
00003         Copyright (C) 2007--2012:
00004                 Stephane Magnenat <stephane at magnenat dot net>
00005                 (http://stephane.magnenat.net)
00006                 and other contributors, see authors.txt for details
00007         
00008         This program is free software: you can redistribute it and/or modify
00009         it under the terms of the GNU Lesser General Public License as published
00010         by the Free Software Foundation, version 3 of the License.
00011         
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU Lesser General Public License for more details.
00016         
00017         You should have received a copy of the GNU Lesser General Public License
00018         along with this program. If not, see <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 
00022 #ifndef _SKEL_H_
00023 #define _SKEL_H_
00024 
00025 // Molole includes
00026 #include <can/can.h>
00027 #include <dma/dma.h>
00028 #include <gpio/gpio.h>
00029 #include <types/types.h>
00030 
00031 
00032 // Aseba include
00033 #include <vm/natives.h>
00034 #include <vm/vm.h>
00035 
00036 #include <common/types.h>
00037 
00038 #include <skel-user.h>
00039 
00040 
00041 
00042 
00043 extern struct _vmVariables vmVariables;
00044 
00045 extern unsigned int events_flags;
00046 
00047 extern AsebaVMState vmState;
00048 
00049 
00050 /*** In your code, put "SET_EVENT(EVENT_NUMBER)" when you want to trigger an 
00051          event. This macro is interrupt-safe, you can call it anywhere you want.
00052 ***/
00053 #define SET_EVENT(event) atomic_or(&events_flags, 1 << event)
00054 #define CLEAR_EVENT(event) atomic_and(&events_flags, ~(1 << event))
00055 #define IS_EVENT(event) (events_flags & (1 << event))
00056 
00057 
00058 
00059 
00060 
00061 // Call this when everything is initialised and you are ready to give full control to the VM
00062 void __attribute((noreturn)) run_aseba_main_loop(void);
00063 
00064 // Call this to init aseba. Beware, this will:
00065 // 1. init the CAN module
00066 // 2. clear vmVariables.
00067 // 3. Load any bytecode in flash if present
00068 void init_aseba_and_can(void);
00069 
00070 // This function must update the variable to match the microcontroller state
00071 // It is called _BEFORE_ running the VM, so it's a {Microcontroller state} -> {Aseba Variable}
00072 // synchronisation
00073 // Implement it yourself
00074 void update_aseba_variables_read(void);
00075 
00076 // This function must update the microcontrolleur state to match the variables
00077 // It is called _AFTER_ running the VM, so it's a {Aseba Variables} -> {Microcontroller state}
00078 // synchronisation
00079 //Implement it yourself
00080 void update_aseba_variables_write(void);
00081 
00082 // This function load the settings structure from flash. Call it _AFTER_ init_aseba_and_can()
00083 // return 0 if the settings were loaded
00084 // return non-zero if the settings were NOT found (settings is non-initilised)
00085 int load_settings_from_flash(void);
00086 
00087 
00088 extern struct private_settings settings;
00089 
00090 
00091 #endif


aseba
Author(s): Stéphane Magnenat
autogenerated on Sun Oct 5 2014 23:46:39