Ejemplo n.º 1
2
void Uart0::isr() {
  uint32_t Status;
  char data;
  Uart0 *object;

// Process UARTA0
  if (g_uart0_object != NULL) {
    Status = MAP_UARTIntStatus(UARTA0_BASE, true);
    MAP_UARTIntClear(UARTA0_BASE, Status);
    object = g_uart0_object;

    if (Status & UART_INT_RX) {
      data = MAP_UARTCharGet(UARTA0_BASE);

      if (object->echo)
        MAP_UARTCharPut(UARTA0_BASE, data);

      object->in_buffer()->push_front_isr(data);
    }

    if (!object->out_buffer()->is_empty()) {
      data = object->out_buffer()->pop_isr();
      MAP_UARTCharPut(UARTA0_BASE, data);
    }
  }
}
Ejemplo n.º 2
0
//****************************************************************************
//
//! Get Ssid name form the user over UART
//!
//! \param pcSsidName is a pointer to the array which will contain the ssid name
//! 
//! This function  
//!    1. gets the ssid name string over uart
//!
//! \return iStringLength is the length of the ssid(user input).
//
//****************************************************************************
int GetSsidName(char *pcSsidName, unsigned int uiMaxLen)
{
    char cCharacter;
    int iStringLength = 0;
    while(1)
    {          
        //
        // Fetching the input from the terminal.
        //
        cCharacter = MAP_UARTCharGet(CONSOLE);
        
        if(cCharacter == '\r' || cCharacter == '\n' ||
           (iStringLength >= uiMaxLen-1))
        {
            if(iStringLength >= uiMaxLen-1)
            {                
                MAP_UARTCharPut(CONSOLE, cCharacter);
                pcSsidName[iStringLength] = cCharacter;
                iStringLength++;
                
            }
            MAP_UARTCharPut(CONSOLE, '\n');
            MAP_UARTCharPut(CONSOLE, '\r');
            pcSsidName[iStringLength] = '\0';
            break;
        }
        else
        {
            MAP_UARTCharPut(CONSOLE, cCharacter);
            pcSsidName[iStringLength] = cCharacter;
            iStringLength++;
        }
    }
    return(iStringLength);
}
Ejemplo n.º 3
0
	//*****************************************************************************
	//
	//! GETChar
	//!
	//!  \param  ucBuffer to which Command will be populated
	//!
	//!  \return Success or Failure
	//!
	//!  \brief   Get the char string from UART
	//
	//*****************************************************************************
	unsigned int GETChar(unsigned char *ucBuffer)
	{

		int i = 0;
		char c;
		uiUartline = 0;

			    //
			    // Wait to receive a character over UART
			    //
		while (MAP_UARTCharsAvail(CONSOLE) == false)
		{
			osi_Sleep(1);
		}
		c = MAP_UARTCharGetNonBlocking(CONSOLE);

		MAP_UARTCharPut(CONSOLE, c);
		ilength = 0;
		//
		// Checking the end of line
		//
		while (c != '\r' && c != '\n')
		{
			uiUartline = 1;
			//
			// Copying Data from UART into a buffer
			//
			if (c != '\b')
			{
				ilength++;
				*(ucBuffer + i) = c;
				i++;
			}
			//
			// Deleting last character when you hit backspace
			//
			if (c == '\b')
			{
				i--;
				ilength--;
			}
			while (MAP_UARTCharsAvail(CONSOLE) == false)
			{
				osi_Sleep(1);
			}
			c = MAP_UARTCharGetNonBlocking(CONSOLE);
			MAP_UARTCharPut(CONSOLE, c);
		}

		strncpy((char*)g_ucUARTBuffer, (char *)ucBuffer, ilength);
		memset(g_ucUARTRecvBuffer, 0, sizeof(g_ucUARTRecvBuffer));

		return uiUartline;
	}
Ejemplo n.º 4
0
ssize_t _write(int fd, const void *buf, size_t count) {
  if (fd != 1 && fd != 2) {
    _not_implemented("_write to files");
  }
  for (size_t i = 0; i < count; i++) {
    const char c = ((const char *) buf)[i];
    if (c == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r');
    MAP_UARTCharPut(CONSOLE_UART, c);
  }
  return count;
}
Ejemplo n.º 5
0
int _write(int file, char *ptr, unsigned int len)
{
    unsigned int i;
    for(i = 0; i < len; i++){
		if( ptr[i] == '\n' && ( i > 0 && ptr[i-1] != '\r' ) )
		{
			MAP_UARTCharPut(UART0_BASE, '\r');
		}
        MAP_UARTCharPut(UART0_BASE, ptr[i]);
    }
    return i;
}
Ejemplo n.º 6
0
//****************************************************************************
//
//! Confgiures the mode in which the device will work
//!
//! \param iMode is the current mode of the device
//!
//! This function
//!    1. prompt user for desired configuration and accordingly configure the
//!          networking mode(STA or AP).
//!       2. also give the user the option to configure the ssid name in case of
//!       AP mode.
//!
//! \return 0: success, -ve: failure.
//
//****************************************************************************
long ConfigureMode(int iMode)
{
    char cCharacter = 'a';
    char pcSsidName[33];
    unsigned short   len;
    long lRetVal = -1;

    while(cCharacter != '1' && cCharacter != '2' && cCharacter != '3')
    {
        UART_PRINT("Do you Want to Switch Mode\n\r1. STA mode\n\r2. AP Mode\n\r"
                    "3. P2P Mode :");
        cCharacter = MAP_UARTCharGet(CONSOLE);
        MAP_UARTCharPut(CONSOLE,cCharacter);
        MAP_UARTCharPut(CONSOLE,'\n');
        MAP_UARTCharPut(CONSOLE,'\r');
    }
    if(cCharacter == '1')
    {
        lRetVal = sl_WlanSetMode(ROLE_STA);
        ASSERT_ON_ERROR(lRetVal);
        UART_PRINT("mode configured\n\r");
    }
    else if(cCharacter == '2')
    {
        UART_PRINT("Enter the SSID name: ");
        GetSsidName(pcSsidName,33);
        _SlNonOsMainLoopTask();
        lRetVal = sl_WlanSetMode(ROLE_AP);
        ASSERT_ON_ERROR(lRetVal);

        len = strlen(pcSsidName);
        lRetVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, len,
                                (unsigned char*) pcSsidName);
        ASSERT_ON_ERROR(lRetVal);

        UART_PRINT("mode configured\n\r");
    }
    else if(cCharacter == '3')
    {
        lRetVal = sl_WlanSetMode(ROLE_P2P);
        ASSERT_ON_ERROR(lRetVal);

        UART_PRINT("mode configured\n\r");
    }
    else
    {
       UART_PRINT("Wrong input\n\r");
    }
    return 0;
}
Ejemplo n.º 7
0
static void cc32xx_int_handler(struct mgos_uart_state *us) {
  if (us == NULL) return;
  struct cc32xx_uart_state *ds = (struct cc32xx_uart_state *) us->dev_data;
  uint32_t int_st = MAP_UARTIntStatus(ds->base, true /* masked */);
  us->stats.ints++;
  uint32_t int_dis = UART_TX_INTS;
  if (int_st & UART_INT_OE) {
    us->stats.rx_overflows++;
    HWREG(ds->base + UART_O_ECR) = 0xff;
  }
  if (int_st & (UART_RX_INTS | UART_TX_INTS)) {
    if (int_st & UART_RX_INTS) {
      us->stats.rx_ints++;
      struct cs_rbuf *irxb = &ds->isr_rx_buf;
      cc32xx_uart_rx_bytes(ds->base, irxb);
      if (us->cfg.rx_fc_type == MGOS_UART_FC_SW &&
          irxb->used >= CC32xx_UART_ISR_RX_BUF_FC_THRESH && !us->xoff_sent) {
        MAP_UARTCharPut(ds->base, MGOS_UART_XOFF_CHAR);
        us->xoff_sent = true;
      }
      /* Do not disable RX ints if we have space in the ISR buffer. */
      if (irxb->avail == 0) int_dis |= UART_RX_INTS;
    }
    if (int_st & UART_TX_INTS) us->stats.tx_ints++;
    mgos_uart_schedule_dispatcher(us->uart_no, true /* from_isr */);
  }
  MAP_UARTIntDisable(ds->base, int_dis);
  MAP_UARTIntClear(ds->base, int_st);
}
Ejemplo n.º 8
0
void dbg_putc(char c) {
#ifndef NO_DEBUG
  MAP_UARTCharPut(DEBUG_UART_BASE, c);
#else
  (void) c;
#endif
}
Ejemplo n.º 9
0
void cc3200_console_putc(int fd, char c) {
  MAP_UARTCharPut(CONSOLE_UART, c);
#ifdef SJ_ENABLE_CLUBBY
  if (fd == 1 && get_cfg()->console.send_to_cloud) cc3200_console_cloud_putc(c);
#endif
  (void) fd;
}
Ejemplo n.º 10
0
Archivo: syscalls.c Proyecto: cmonr/PAL
int _write(int file, char *ptr, unsigned int len)
{
    unsigned int i;
    for(i = 0; i < len; i++){
        MAP_UARTCharPut(UART0_BASE, ptr[i]);
    }
    return i;
}
Ejemplo n.º 11
0
void platform_s_uart_send( unsigned id, u8 data )
{
#ifdef BUILD_USB_CDC
  if( id == CDC_UART_ID )
    USBBufferWrite( &g_sTxBuffer, &data, 1 );
  else
#endif
    MAP_UARTCharPut( uart_base[ id ], data );
}
Ejemplo n.º 12
0
static void logger_writer(struct LOGGER_APPENDER *appender, int level, const char *buf, int len)
{
    const char *p = buf;

    if (p != NULL)
    {
        while(*p != '\0')
        {
            MAP_UARTCharPut(CONSOLE, *p++);
        }
    }
}
Ejemplo n.º 13
0
//*****************************************************************************
//
//!    Outputs a character string to the console
//!
//! \param str is the pointer to the string to be printed
//!
//! This function
//!        1. prints the input string character by character on to the console.
//!
//! \return none
//
//*****************************************************************************
void 
Message(const char *str)
{
#ifndef NOTERM
    if(str != NULL)
    {
        while(*str!='\0')
        {
            MAP_UARTCharPut(CONSOLE,*str++);
        }
    }
#endif
}
Ejemplo n.º 14
0
//*****************************************************************************
//
// Send a string to the UART.  This function sends a string of characters to a
// particular UART module.
//
//*****************************************************************************
void
UARTSend(uint32_t ui32UARTBase, const uint8_t *pui8Buffer, uint32_t ui32Count)
{
    //
    // Loop while there are more characters to send.
    //
    while(ui32Count--)
    {
        //
        // Write the next character to the UART.
        //
        MAP_UARTCharPut(ui32UARTBase, *pui8Buffer++);
    }
}
Ejemplo n.º 15
0
//*****************************************************************************
//
//! GetKey - Gets the Key from User
//!
//! \param  uiKeySize - Key Size Used
//! \param pucKeyBuff - Key Buffer into which Key will be populated
//!
//! \return Success or Failure
//!
//*****************************************************************************
bool
GetKey(unsigned int uiKeySize,char *pucKeyBuff)
{
    char cChar;
    unsigned int uiMsgLen;
    UART_PRINT("\n\r Do you want to use Pre-Defined Key ???(y/n) \n\r");
    
    //
    // Get the option
    //
    cChar = MAP_UARTCharGet(UARTA0_BASE);
    
    //
    // Echo the received character
    //
    MAP_UARTCharPut(UARTA0_BASE, cChar);
    UART_PRINT("\n\r");
    if(cChar=='y' || cChar=='Y' )
    {
        //
        // Fetch the key
        //
        if(uiKeySize==8)
        {
            UART_PRINT("\n\r Press 1 for Key - %s\n\r Press 2 for Key - %s "
                        "\n\r Press 3 for Key - %s\n\r",DESKey1,DESKey2,DESKey3);
            cChar = MAP_UARTCharGet(UARTA0_BASE);
            
            //
            // Echo the received character
            //
            MAP_UARTCharPut(UARTA0_BASE, cChar);
            UART_PRINT("\n\r");
            if(cChar=='1' )
              memcpy(&uiDESKey,DESKey1,8);
            else if(cChar=='2')
              memcpy(&uiDESKey,DESKey2,8);
            else if(cChar=='3')
              memcpy(&uiDESKey,DESKey3,8);
            else
            {
              UART_PRINT("\n\r Invalid Input \n\r");
              return false;
            }
        }
        else if(uiKeySize==24)
        {
            UART_PRINT("\n\r Press 1 for Key - %s\n\r Press 2 for Key - %s "
                     "\n\r Press 3 for Key - %s\n\r",TDESKey1,TDESKey2,TDESKey3);
            cChar = MAP_UARTCharGet(UARTA0_BASE);
            
            //
            // Echo the received character
            //
            MAP_UARTCharPut(UARTA0_BASE, cChar);
            UART_PRINT("\n\r");
            if(cChar=='1' )
              memcpy(&uiTDESKey,TDESKey1,24);
            else if(cChar=='2')
              memcpy(&uiTDESKey,TDESKey2,24);
            else if(cChar=='3')
              memcpy(&uiTDESKey,TDESKey3,24);
            else
            {
              UART_PRINT("\n\r Invalid Input \n\r");
              return false;
            }
        }


      }
      else if(cChar=='n' || cChar=='N')
      {
          //
          // Ask for the Key
          //
          UART_PRINT("\n\rEnter the Key \n\r");
          uiMsgLen=GetCmd(pucKeyBuff,BUFFER_LEN);
          if(uiMsgLen!=uiKeySize)
          {
            UART_PRINT("\n\r Enter Valid Key of length %d\n\r",uiKeySize);
            return false;
          }

      }
    else
    {
        UART_PRINT("\n\r Invalid Input \n\r");
        return false;
    }
    return true;
}
Ejemplo n.º 16
0
//*****************************************************************************
//
//! CRCParser 
//!
//! \param  ucCMDBuffer - Buffer which contains command from UART
//! \param  uiConfig - Sets Configuration Value
//!
//! \return none
//!
//*****************************************************************************
bool
CRCParser( char *ucCMDBuffer,unsigned int *uiConfig)
{
    char *ucInpString,cChar;
    ucInpString = strtok(ucCMDBuffer, " ");

    //
    // Check Whether Command is valid
    //
    if((ucInpString != NULL) && ((!strcmp(ucInpString,"crc"))))
    {
        //
        // Get which Algorithm you are using
        //
        ucInpString = strtok(NULL, " ");

        //
        // Get Key Length
        //
        if(ucInpString != NULL && ((!strcmp(ucInpString,"P8005")) || \
                            (!strcmp(ucInpString,"p8005"))))
            *uiConfig=CRC_CFG_TYPE_P8005;
        else if (ucInpString != NULL && (!strcmp(ucInpString,"P1021") || \
                            (!strcmp(ucInpString,"p1021"))))
            *uiConfig=CRC_CFG_TYPE_P1021;
        else if (ucInpString != NULL && (!strcmp(ucInpString,"P4C11DB7") || \
                            !strcmp(ucInpString,"p4c11db7")))
            *uiConfig=CRC_CFG_TYPE_P4C11DB7;
        else if (ucInpString != NULL && (!strcmp(ucInpString,"P1EDC6F41") || \
                        !strcmp(ucInpString,"p1edc6f41") ))
            *uiConfig=CRC_CFG_TYPE_P1EDC6F41;
        else if (ucInpString != NULL && (!strcmp(ucInpString,"TCPCHKSUM") || \
                        !strcmp(ucInpString,"tcpchksum")))
            *uiConfig=CRC_CFG_TYPE_TCPCHKSUM;
        else
        {
            UART_PRINT("\n\r Invalid CRC type \n\r");
            return false;
        }

        UART_PRINT("\n\rPress 1 to Initialize Seed\n\rPress 2 to Initialize to"
                       "all 0's\n\rPress 3 to Initialize to all 1's \n\r");
     
        //
        // Get the option
        //
        cChar = MAP_UARTCharGet(UARTA0_BASE);

        //
        // Echo the received character
        //
        MAP_UARTCharPut(UARTA0_BASE, cChar);
        UART_PRINT("\n\r");
        if(cChar=='1' )
        {
            *uiConfig|=CRC_CFG_INIT_SEED;
        }
        else if(cChar=='2')
        {
            *uiConfig|=CRC_CFG_INIT_0;
        }
        else if(cChar=='3')
        {
            *uiConfig|=CRC_CFG_INIT_1;
        }
        else
        {
            UART_PRINT("\n\r Invalid Input \n\r");
            return false;
        }
        UART_PRINT("\n\rPress 1 for byte write\n\rPress 2 for word write \n\r");

        //
        // Get the option
        //
        cChar = MAP_UARTCharGet(UARTA0_BASE);

        //
        // Echo the received character
        //
        MAP_UARTCharPut(UARTA0_BASE, cChar);
        UART_PRINT("\n\r");
        if(cChar=='1' )
        {
            *uiConfig|=CRC_CFG_SIZE_8BIT;

        }
        else if(cChar=='2')
        {
            *uiConfig|=CRC_CFG_SIZE_32BIT;

        }
        else
        {
            UART_PRINT("\n\r Invalid Input \n\r");
            return false;
        }
#if 0
        UART_PRINT("\n\rPress 1 for Result Inverse\n\rPress 2 for Output "
                        "Inverse \n\r");

        //
        // Get the option
        //
        cChar = MAP_UARTCharGet(UARTA0_BASE);

        //
        // Echo the received character
        //
        MAP_UARTCharPut(UARTA0_BASE, cChar);
        UART_PRINT("\n\r");
        if(cChar=='1' )
        {
        *uiConfig|=CRC_CFG_RESINV;
        }
        else if(cChar=='2')
        {
        *uiConfig|=CRC_CFG_OBR;
        }
        else
        {
        UART_PRINT("\n\r Invalid Input \n\r");
        return false;
        }
#endif
    }
    else
    {
        return false;
    }
    return true;
}
Ejemplo n.º 17
0
void uart_write_char(char c){
    MAP_UARTCharPut(UART0_BASE, c);
}
Ejemplo n.º 18
0
//*****************************************************************************
//
//! Get Key Function
//!
//! This function
//!        1. Gets the Key from the User
//! \param uiKeySize - Key Size used
//! \out pucKeyBuff - KeyBuffer in which Key is stored
//!
//! \return Success or Failure
//
//*****************************************************************************
bool
GetKey(unsigned int uiKeySize, char *pucKeyBuff)
{
  char cChar;
  unsigned int uiMsgLen;
  UART_PRINT("\n\r Do you want to use Pre-Defined Key ???(y/n) \n\r");
  
  //
  // Get the option
  //
  cChar = MAP_UARTCharGet(UARTA0_BASE);
  
  //
  // Echo the received character
  //
  MAP_UARTCharPut(UARTA0_BASE, cChar);
  UART_PRINT("\n\r");
  if(cChar=='y' || cChar=='Y' )
  {
      //
      // Fetch the key
      //
      if(uiKeySize==AES_CFG_KEY_SIZE_128BIT)
      {
        UART_PRINT("\n\r Press 1 for Key - %s\n\r Press 2 for Key - %s \n\r "
                   "Press 3 for Key - %s\n\r",AES128Key1,AES128Key2,AES128Key3);
        cChar = MAP_UARTCharGet(UARTA0_BASE);
        
        //
        // Echo the received character
        //
        MAP_UARTCharPut(UARTA0_BASE, cChar);
        UART_PRINT("\n\r");
        if(cChar=='1' )
          memcpy(&uiKey128,AES128Key1,16);
        else if(cChar=='2')
          memcpy(&uiKey128,AES128Key2,16);
        else if(cChar=='3')
          memcpy(&uiKey128,AES128Key3,16);
        else
        {
          UART_PRINT("\n\r Invalid Input \n\r");
          return false;
        }
      }
      else if(uiKeySize==AES_CFG_KEY_SIZE_192BIT)
      {
        UART_PRINT("\n\r Press 1 for Key - %s\n\r Press 2 for Key - %s \n\r "
                   "Press 3 for Key - %s\n\r",AES192Key1,AES192Key2,AES192Key3);
        cChar = MAP_UARTCharGet(UARTA0_BASE);
        
        //
        // Echo the received character
        //
        MAP_UARTCharPut(UARTA0_BASE, cChar);
        UART_PRINT("\n\r");
        if(cChar=='1' )
          memcpy(&uiKey192,AES192Key1,24);
        else if(cChar=='2')
          memcpy(&uiKey192,AES192Key2,24);
        else if(cChar=='3')
          memcpy(&uiKey192,AES192Key3,24);
        else
        {
          UART_PRINT("\n\r Invalid Input \n\r");
          return false;
        }
      }
      else if(uiKeySize==AES_CFG_KEY_SIZE_256BIT)
      {
        UART_PRINT("\n\r Press 1 for Key - %s\n\r Press 2 for Key - %s \n\r"
                   " Press 3 for Key - %s\n\r",AES256Key1,AES256Key2,AES256Key3);
        cChar = MAP_UARTCharGet(UARTA0_BASE);
        
        //
        // Echo the received character
        //
        MAP_UARTCharPut(UARTA0_BASE, cChar);
        UART_PRINT("\n\r");
        if(cChar=='1' )
          memcpy(&uiKey256,AES256Key1,32);
        else if(cChar=='2')
          memcpy(&uiKey256,AES256Key2,32);
        else if(cChar=='3')
          memcpy(&uiKey256,AES256Key3,32);
        else
        {
          UART_PRINT("\n\r Invalid Input \n\r");
          return false;
        }
      }

  }

  else if(cChar=='n' || cChar=='N')
  {
      //
      // Ask for the Key
      //
      UART_PRINT("\n\rEnter the Key \n\r");
      uiMsgLen=GetCmd(pucKeyBuff,520);
      if(uiMsgLen!=uiKeySize)
      {
        UART_PRINT("\n\r Enter Valid Key of length %d\n\r",uiKeySize);
        return false;
      }

  }
  else
  {
    UART_PRINT("\n\r Invalid Input \n\r");
    return false;
  }
  return true;
}
Ejemplo n.º 19
0
int main()
{
    UserIn User;
    int iFlag = 1;
    long lRetVal = -1;
    char cChar;
    unsigned char policyVal;
    
    //
    // Initialize Board configuration
    //
    BoardInit();
    
    //
    //
    //Pin muxing
    //
    PinMuxConfig();
    
    // Configuring UART
    //
    InitTerm();
    DisplayBanner(APPLICATION_NAME);

    InitializeAppVariables();

    //
    // Following function configure the device to default state by cleaning
    // the persistent settings stored in NVMEM (viz. connection profiles &
    // policies, power policy etc)
    //
    // Applications may choose to skip this step if the developer is sure
    // that the device is in its default state at start of applicaton
    //
    // Note that all profiles and persistent settings that were done on the
    // device will be lost
    //
    lRetVal = ConfigureSimpleLinkToDefaultState();
    if(lRetVal < 0)
    {
        if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
          UART_PRINT("Failed to configure the device in its default state \n\r");
          LOOP_FOREVER();
    }

    UART_PRINT("Device is configured in default state \n\r");

    CLR_STATUS_BIT_ALL(g_ulStatus);

    //
    // Assumption is that the device is configured in station mode already
    // and it is in its default state
    //
    lRetVal = sl_Start(0, 0, 0);
    if (lRetVal < 0 || ROLE_STA != lRetVal)
    {
        UART_PRINT("Failed to start the device \n\r");
        LOOP_FOREVER();
    }

    UART_PRINT("Device started as STATION \n\r");

    //
    // reset all network policies
    //
    lRetVal = sl_WlanPolicySet(  SL_POLICY_CONNECTION,
                  SL_CONNECTION_POLICY(0,0,0,0,0),
                  &policyVal,
                  1 /*PolicyValLen*/);
    if (lRetVal < 0)
    {
        UART_PRINT("Failed to set policy \n\r");
        LOOP_FOREVER();
    }

    while (iFlag)
    { 
    User = UserInput();

    switch(User.choice)
    {
    case(1):

        /*******An example of Tx continuous on user selected channel, rate 11,
        * user selected number of packets, minimal delay between packets*******/
        lRetVal = Tx_continuous(User.channel,User.rate,User.packets, \
                             User.Txpower,0);
        if(lRetVal < 0)
        {
            UART_PRINT("Error during transmission of raw data\n\r");
            LOOP_FOREVER();
        }
        break;
    case(2):

        /******An example of Rx statistics using user selected channel *******/
        lRetVal = RxStatisticsCollect();
        if(lRetVal < 0)
        {
            UART_PRINT("Error while collecting statistics data\n\r");
            LOOP_FOREVER();
        }
        break;
    }

    UART_PRINT("\n\rEnter \"1\" to restart or \"0\" to quit: ");
    //
    // Wait to receive a character over UART
    //
    cChar = MAP_UARTCharGet(CONSOLE);
    //
    // Echo the received character
    //
    MAP_UARTCharPut(CONSOLE, cChar);
    UART_PRINT("\n\r");
    iFlag = atoi(&cChar);
    }
    UART_PRINT("\r\nEnding the application....");
    //
    // power off network processor
    //
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);

    LOOP_FOREVER();

}
Ejemplo n.º 20
0
void platform_s_uart_send( unsigned id, u8 data )
{
    MAP_UARTCharPut( uart_base[ id ], data );
}
Ejemplo n.º 21
0
void uart_write_str(char *str) {
	while (*str)
	{
		MAP_UARTCharPut(UART0_BASE, *str++);
	}
}
Ejemplo n.º 22
0
void fprint_str(FILE *fp, const char *str) {
  while (*str != '\0') {
    if (*str == '\n') MAP_UARTCharPut(CONSOLE_UART, '\r');
    MAP_UARTCharPut(CONSOLE_UART, *str++);
  }
}
Ejemplo n.º 23
0
//*****************************************************************************
//
//! Get Key - Gets the Key into the Buffer from User
//!
//! \param  pucKeyBuff is the Key buffer to which Key will be populated
//!
//! \return Success or Failure
//!
//*****************************************************************************
bool
GetKey(char *pucKeyBuff)
{
    char cChar;
    unsigned int uiMsgLen;
    if(uiHMAC)
    {
        UART_PRINT("\n\rDo you want to use Pre-Defined Key or not (y/n) ? \n\r");
        //
        // Get the option
        //
        cChar = MAP_UARTCharGet(UARTA0_BASE);
        //
        // Echo the received character
        //
        MAP_UARTCharPut(UARTA0_BASE, cChar);
        UART_PRINT("\n\r");
        if(cChar=='y' || cChar=='Y' )
        {
            //
            // Fetch the key
            //
            UART_PRINT("\n\r Press 1 for Key - %s\n\r Press 2 for Key - %s \n\r"
                        " Press 3 for Key - %s\n\r",HMACKey1,HMACKey2,HMACKey3);
            cChar = MAP_UARTCharGet(UARTA0_BASE);
            //
            // Echo the received character
            //
            MAP_UARTCharPut(UARTA0_BASE, cChar);
            UART_PRINT("\n\r");
            if(cChar=='1' )
              memcpy(&uiHMACKey,HMACKey1,64);
            else if(cChar=='2')
              memcpy(&uiHMACKey,HMACKey2,64);
            else if(cChar=='3')
              memcpy(&uiHMACKey,HMACKey3,64);
            else
            {
                UART_PRINT("\n\r Wrong Key \n\r");
                return false;
            }

       }
       else if(cChar=='n' || cChar=='N')
       {
            //
            // Ask for the Key
            //
            UART_PRINT("Enter the Key \n\r");
            uiMsgLen=GetCmd(pucKeyBuff,520);
            if(uiMsgLen!=64)
            {
                UART_PRINT("\n\r Enter Valid Key of length 64\n\r");
                return false;
            }
       }
       else
       {
            UART_PRINT("\n\r Invalid Input \n\r");
            return false;
       }
    }

    return true;
}
Ejemplo n.º 24
0
//*****************************************************************************
//
//! Get the Command string from UART
//!
//! \param  pucBuffer is the command store to which command will be populated
//! \param  ucBufLen is the length of buffer store available
//!
//! \return Length of the bytes received. -1 if buffer length exceeded.
//! 
//*****************************************************************************
int
GetCmd(char *pcBuffer, unsigned int uiBufLen)
{
    char cChar;
    int iLen = 0;
    
    //
    // Wait to receive a character over UART
    //
    while(MAP_UARTCharsAvail(CONSOLE) == false)
    {
#if defined(USE_FREERTOS) || defined(USE_TI_RTOS)
    	osi_Sleep(1);
#endif
    }
    cChar = MAP_UARTCharGetNonBlocking(CONSOLE);
    
    //
    // Echo the received character
    //
    MAP_UARTCharPut(CONSOLE, cChar);
    iLen = 0;
    
    //
    // Checking the end of Command
    //
    while((cChar != '\r') && (cChar !='\n') )
    {
        //
        // Handling overflow of buffer
        //
        if(iLen >= uiBufLen)
        {
            return -1;
        }
        
        //
        // Copying Data from UART into a buffer
        //
        if(cChar != '\b')
        { 
            *(pcBuffer + iLen) = cChar;
            iLen++;
        }
        else
        {
            //
            // Deleting last character when you hit backspace 
            //
            if(iLen)
            {
                iLen--;
            }
        }
        //
        // Wait to receive a character over UART
        //
        while(MAP_UARTCharsAvail(CONSOLE) == false)
        {
#if defined(USE_FREERTOS) || defined(USE_TI_RTOS)
        	osi_Sleep(1);
#endif
        }
        cChar = MAP_UARTCharGetNonBlocking(CONSOLE);
        //
        // Echo the received character
        //
        MAP_UARTCharPut(CONSOLE, cChar);
    }

    *(pcBuffer + iLen) = '\0';

    Report("\n\r");

    return iLen;
}