2009-01-07 20:17:18 +00:00
|
|
|
// Common platform functions
|
|
|
|
|
|
|
|
#ifndef __COMMON_H__
|
|
|
|
#define __COMMON_H__
|
|
|
|
|
2010-11-03 23:57:27 +00:00
|
|
|
#include "elua_int.h"
|
2011-10-08 20:07:14 +03:00
|
|
|
#include "lua.h"
|
|
|
|
#include "platform.h"
|
2010-11-03 23:57:27 +00:00
|
|
|
|
2009-01-07 20:17:18 +00:00
|
|
|
// Virtual timers data
|
2011-10-08 20:07:14 +03:00
|
|
|
// VTMR_FIRST_ID must be LARGER than PLATFORM_TIMER_SYS_ID (as declared in platform.h)
|
|
|
|
#define VTMR_FIRST_ID ( 0x200 )
|
2009-01-07 20:17:18 +00:00
|
|
|
#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();
|
2010-11-03 23:57:27 +00:00
|
|
|
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 );
|
2011-10-08 20:07:14 +03:00
|
|
|
// System timer generic implemenation
|
|
|
|
void cmn_systimer_set_base_freq( u32 freq_hz );
|
|
|
|
void cmn_systimer_set_interrupt_freq( u32 freq_hz );
|
2011-10-10 01:22:56 +03:00
|
|
|
void cmn_systimer_set_interrupt_period_us( u32 period );
|
2011-10-08 20:07:14 +03:00
|
|
|
void cmn_systimer_periodic();
|
|
|
|
timer_data_type cmn_systimer_get();
|
|
|
|
|
2011-01-16 00:23:19 +00:00
|
|
|
void cmn_uart_setup_sermux();
|
2009-01-07 20:17:18 +00:00
|
|
|
|
2009-01-27 20:49:45 +00:00
|
|
|
unsigned int intlog2( unsigned int v );
|
2011-10-07 17:19:51 +03:00
|
|
|
const char* cmn_str64( u64 x );
|
2011-10-08 20:07:14 +03:00
|
|
|
void cmn_get_timeout_data( lua_State *L, int pidx, timer_data_type *ptimeout, unsigned *pid );
|
2009-01-27 20:49:45 +00:00
|
|
|
|
2009-01-07 20:17:18 +00:00
|
|
|
#endif // #ifndef __COMMON_H__
|
2010-11-03 23:57:27 +00:00
|
|
|
|