Create run_timers function for async calls

async
jeltz 4 years ago
parent 5b1a286999
commit 9b44a7a7ab
Signed by: jeltz
GPG Key ID: 800882B66C0C3326

1
.gitignore vendored

@ -37,3 +37,4 @@ config.status
*.bbl
auto
autom4te.cache
!/lib/c/*.h

@ -31,4 +31,22 @@ struct
let gen_copy_func_out cd = gen_copy_func cd "_out"
let includes = ["avr"]
let decls_and_defs classes =
(* run_timers is declared in avr.h (because of the ISR macro which
* I don't know how to generate here) *)
let defs = [
Cfundef {
C.f_name = "run_timers";
f_retty = Cty_void;
f_args = [];
f_body = {
var_decls = [];
block_body = []
}
}
] in
[], defs
end

@ -5,4 +5,6 @@ module type AsyncBackend =
sig
val gen_copy_func_in : class_def -> cdef
val gen_copy_func_out : class_def -> cdef
val includes : string list
val decls_and_defs : class_def list -> cdecl list * cdef list
end

@ -1080,9 +1080,14 @@ let global_file_header name prog =
| s -> s ^ "_types")
dependencies in
let dependencies_types = AvrBackend.includes @ dependencies_types in
let classes = program_classes prog in
let (decls, defs) =
List.split (List.map cdefs_and_cdecls_of_class_def classes) in
let decls_and_defs = List.map cdefs_and_cdecls_of_class_def classes in
let decls_and_defs =
(AvrBackend.decls_and_defs classes) :: decls_and_defs
in
let (decls, defs) = List.split decls_and_defs in
let decls = List.concat decls
and defs = List.concat defs in

@ -0,0 +1,52 @@
/***********************************************************************/
/* */
/* Heptagon */
/* */
/* Gwenael Delaval, LIG/INRIA, UJF */
/* Leonard Gerard, Parkas, ENS */
/* Adrien Guatto, Parkas, ENS */
/* Cedric Pasteur, Parkas, ENS */
/* Marc Pouzet, Parkas, ENS */
/* */
/* Copyright 2012 ENS, INRIA, UJF */
/* */
/* This file is part of the Heptagon compiler. */
/* */
/* Heptagon 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 3 of the License, or */
/* (at your option) any later version. */
/* */
/* Heptagon 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 Heptagon. If not, see <http://www.gnu.org/licenses/> */
/* */
/***********************************************************************/
/* Pervasives module for the Heptagon compiler */
#ifndef DECADES_AVR_H
#define DECADES_AVR_H
#ifdef __AVR__
#include <util/atomic.h>
#include <avr/interrupt.h>
void run_timers();
ISR(TIMER0_OVF_vect) {
run_timers();
}
static inline void atomic_memcpy(void *dest, const void *src, size_t size) {
ATOMIC_BLOCK(ATOMIC_FORCEON) {
memcpy(dest, src, size);
}
}
#endif
#endif

@ -32,9 +32,6 @@
#ifndef DECADES_PERVASIVES_H
#define DECADES_PERVASIVES_H
#include <string.h>
#ifdef __AVR__
#include <util/atomic.h>
#endif
typedef float real;
@ -45,13 +42,5 @@ static inline int between(int idx, int n)
return o;
}
#ifdef __AVR__
static inline void atomic_memcpy(void *dest, const void *src, size_t size) {
ATOMIC_BLOCK(ATOMIC_FORCEON) {
memcpy(dest, src, size);
}
}
#endif
#endif

Loading…
Cancel
Save