1
0
mirror of https://github.com/elua/elua.git synced 2025-01-25 01:02:54 +08:00
elua/inc/common.h
Bogdan Marinescu 5978c7b680 - Changed interrupt support infrastructure. No docs yet (will be added later), but check src/platform/lpc24xx/platform_int.c for a quick glimpse of the concept.
- Added direct access to interrupt flags; an interrupt doesn't have to trigger a handler anymore, its flag(s) can be checked instead (platform_cpu_get_interrupt_flag).
- Added experimental C interrupt handlers support (NOT TESTED). It can be compiled and used separately from the Lua interrupt support implementation. Hint: src/elua_int.c, elua_int_set_c_handler and elua_int_get_c_handler, also BUILD_C_INT_HANDLERS (as opposed to BUILD_LUA_INT_HANDLERS).
- Added tmr.set_match_int function that sets a match interrupt on a timer (one-shot or cyclic). Also works on virtual timers. In fact, it currently works only on virtual timers, as none of the platforms have support for this operation with hardware timers.
-Added more interrupt support functions in the CPU module.

All of the above were implemented and tested on the ELUA-PUC board, and nothing else. As a side effect, THIS COMMIT BRAKES THE STR912 PORT! The port will be modified to take advantage of the new interrupt structure soon; until then, please don't update it.
2010-11-03 23:57:27 +00:00

26 lines
809 B
C

// Common platform functions
#ifndef __COMMON_H__
#define __COMMON_H__
#include "elua_int.h"
// Virtual timers data
#define VTMR_FIRST_ID ( 32 )
#define VTMR_GET_ID( x ) ( ( x ) - VTMR_FIRST_ID )
#define TIMER_IS_VIRTUAL( x ) ( ( VTMR_NUM_TIMERS > 0 ) && ( ( x ) >= VTMR_FIRST_ID ) && ( ( x ) < VTMR_NUM_TIMERS + VTMR_FIRST_ID ) )
// Functions exported by the common platform layer
void cmn_platform_init();
void cmn_virtual_timer_cb();
void cmn_int_handler( elua_int_id id, elua_int_resnum resnum );
// Timer-specific functions
int cmn_tmr_int_set_status( elua_int_resnum resnum, int status );
int cmn_tmr_int_get_status( elua_int_resnum resnum );
int cmn_tmr_int_get_flag( elua_int_resnum resnum, int clear );
unsigned int intlog2( unsigned int v );
#endif // #ifndef __COMMON_H__