Beispiel #1
0
// Helper to get timeout and timer_id values.
void cmn_get_timeout_data(timer_data_type *timeout,
			  unsigned *timer_id,
			  val **param,
			  int timeout_index,
			  int timer_id_index)
{
  *timeout = param[timeout_index]->Val->UnsignedLongInteger;
  if (*timeout < 0 || *timeout > PLATFORM_TIMER_INF_TIMEOUT)
    pmod_error("invalid timeout value");
  *timer_id = param[timer_id_index]->Val->UnsignedInteger;
  if (*timer_id == PLATFORM_TIMER_SYS_ID &&
      !platform_timer_sys_available())
    pmod_error("the system timer is not implemented on this platform");
}
Beispiel #2
0
static void uart_get_timeout_data( lua_State *L, int pidx, timer_data_type *ptimeout, unsigned *pid )
{
  lua_Number tempn;

  *ptimeout = PLATFORM_TIMER_INF_TIMEOUT;
  if( lua_type( L, pidx ) == LUA_TNUMBER )
  {
    tempn = lua_tonumber( L, pidx );
    if( tempn < 0 || tempn > PLATFORM_TIMER_INF_TIMEOUT )
      luaL_error( L, "invalid timeout value" );
    *ptimeout = ( timer_data_type )tempn;
  }
  *pid = ( unsigned )luaL_optinteger( L, pidx + 1, PLATFORM_TIMER_SYS_ID );
  if( *pid == PLATFORM_TIMER_SYS_ID && !platform_timer_sys_available() )
    luaL_error( L, "the system timer is not implemented on this platform" );
}