Пример #1
0
// Lua: write( id, string1, [string2], ..., [stringn] )
static int uart_write( lua_State* L )
{
  int id;
  const char* buf;
  size_t len, i;
  int total = lua_gettop( L ), s;
  
  id = luaL_checkinteger( L, 1 );
  MOD_CHECK_ID( uart, id );
  for( s = 2; s <= total; s ++ )
  {
    if( lua_type( L, s ) == LUA_TNUMBER )
    {
      len = lua_tointeger( L, s );
      if( ( len < 0 ) || ( len > 255 ) )
        return luaL_error( L, "invalid number" );
      platform_uart_send( id, ( u8 )len );
    }
    else
    {
      luaL_checktype( L, s, LUA_TSTRING );
      buf = lua_tolstring( L, s, &len );
      for( i = 0; i < len; i ++ )
        platform_uart_send( id, buf[ i ] );
    }
  }
  return 0;
}
Пример #2
0
void prtn(const char *Aux, int len)
{
int i = 0;
	for( i = 0; i < len; i ++ )
	{
		platform_uart_send( 0, Aux[ i ] );
	}
	platform_uart_send( 0, EOL[ 0 ] );
	platform_uart_send( 0, EOL[ 1 ] );
}
Пример #3
0
/*******************************************************************************
* Function Name  : BusFaultException
* Description    : This function handles Bus Fault exception.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void BusFaultException(void)
{
  /* Go to infinite loop when Bus Fault exception occurs */
  while (1)
  {
    platform_uart_send(0, ' ');
    platform_uart_send(0, 'B');
    platform_uart_send(0, 'F');
    platform_uart_send(0, '!');
  }
}
Пример #4
0
/*******************************************************************************
* Function Name  : MemManageException
* Description    : This function handles Memory Manage exception.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void MemManageException(void)
{
  /* Go to infinite loop when Memory Manage exception occurs */
  while (1)
  {
    platform_uart_send(0, ' ');
    platform_uart_send(0, 'M');
    platform_uart_send(0, 'M');
    platform_uart_send(0, '!');
  }
}
Пример #5
0
void nrf_ll_send_packet( const u8 *packet, u16 len )
{
  unsigned i;

  for( i = 0; i < len; i ++ )
    platform_uart_send( NRF24L01_UART_ID, packet[ i ] );
}
Пример #6
0
void transport_write_buffer( Transport *tpt, const u8 *buffer, int length )
{
	int i;
	struct exception e;
	TRANSPORT_VERIFY_OPEN;

	for( i = 0; i < length; i ++ )
		platform_uart_send( tpt->fd, buffer[ i ] );
}
Пример #7
0
// Lua: send( id, out1, out2, ... )
static int uart_send( lua_State* L )
{
  u8 value;
  int total = lua_gettop( L ), i, id;
  
  id = luaL_checkinteger( L, 1 );
  MOD_CHECK_ID( uart, id );
  for( i = 2; i <= total; i ++ )
  {
    value = luaL_checkinteger( L, i );  
    platform_uart_send( id, value );
  }
  return 0;
}
Пример #8
0
void nrf_ll_read_packet( u8 *packet, u16 len )
{
  int data;
  unsigned i;

  for( i = 0; i < len; i ++ )
  {
    platform_uart_send( NRF24L01_UART_ID, 0xFF );
    data = platform_uart_recv( NRF24L01_UART_ID, 0, NRF24L01_TIMEOUT );
    if( data == -1 )
      printf( "INVALID DATA RECEIVED ON NRF_LL_READ_PACKET!\n" );
    packet[ i ] = data;
  }
}
Пример #9
0
// Lua: sendbuf( id, buf )
static int uart_sendbuf( lua_State* L )
{
  int id;
  const char* buf;
  size_t len, i;
  
  //MOD_CHECK_MIN_ARGS( 2 );  
  id = luaL_checkinteger( L, 1 );
  luaL_checktype( L, 2, LUA_TSTRING );
  buf = lua_tolstring( L, 2, &len );
  for( i = 0; i < len; i ++ )
    platform_uart_send( id, buf[ i ] );
  return 0;
}
Пример #10
0
// Lua: sendstr( id, string1, string2, ... )
static int uart_sendstr( lua_State* L )
{
  int id;
  const char* buf;
  size_t len, i;
  int total = lua_gettop( L ), s;
  
  id = luaL_checkinteger( L, 1 );
  MOD_CHECK_ID( uart, id );
  for( s = 2; s <= total; s ++ )
  {
    luaL_checktype( L, s, LUA_TSTRING );
    buf = lua_tolstring( L, s, &len );
    for( i = 0; i < len; i ++ )
      platform_uart_send( id, buf[ i ] );
  }
  return 0;
}
Пример #11
0
static void term_out( u8 data )
{
  platform_uart_send( CON_UART_ID, data );
}
Пример #12
0
static void xmodem_send( u8 data )
{
  platform_uart_send( CON_UART_ID, data );
}
Пример #13
0
static void uart_send( int fd, char c )
{
  fd = fd;
  platform_uart_send( CON_UART_ID, c );
}
Пример #14
0
static void uart_send( int fd, char c )
{
  fd = fd;
  platform_uart_send( 0, c );
}