Example #1
0
/*----------------------------------------------------------------------------------------------------------------------
Function: DebugInitialize

Description:
Sets up the debug command list and activates the debug functionality.

Requires:
  - The debug application is not yet running
  - The UART resource requested should be free

Promises:
  - UART resource Debug_au8RxBuffer initialized to all 0
  - Buffer pointers Debug_pu8CmdBufferCurrentChar and Debug_pu8RxBufferParser set to the start of the buffer
  - Debug_pfnStateMachine set to Idle
*/
void DebugInitialize(void)
{
  UartConfigurationType sUartConfig;  

  /* Clear the receive buffer */
  for (u16 i = 0; i < DEBUG_RX_BUFFER_SIZE; i++)
  {
    Debug_au8RxBuffer[i] = 0;
  }

  /* Clear the scanf buffer and counter */
  G_u8DebugScanfCharCount = 0;
  for (u8 i = 0; i < DEBUG_SCANF_BUFFER_SIZE; i++)
  {
    G_au8DebugScanfBuffer[i] = 0;
  }

  /* Initailze startup values and the command array */
  Debug_pu8RxBufferParser    = &Debug_au8RxBuffer[0];
  Debug_pu8RxBufferNextChar  = &Debug_au8RxBuffer[0]; 
  Debug_pu8CmdBufferNextChar = &Debug_au8CommandBuffer[0]; 

  /* Request the UART resource to be used for the Debug application */
  sUartConfig.UartPeripheral     = DEBUG_UART;
  sUartConfig.pu8RxBufferAddress = &Debug_au8RxBuffer[0];
  sUartConfig.pu8RxNextByte      = &Debug_pu8RxBufferNextChar;
  sUartConfig.u16RxBufferSize    = DEBUG_RX_BUFFER_SIZE;
  sUartConfig.fnRxCallback       = DebugRxCallback;
  
  Debug_Uart = UartRequest(&sUartConfig);
  
  /* Go to error state if the UartRequest failed */
  if(Debug_Uart == NULL)
  {
    Debug_pfnStateMachine = DebugSM_Error;

  }
  /* Otherwise send the first message, set "good" flag and head to Idle */
  else
  {
    DebugPrintf(Debug_au8StartupMsg);   
    G_u32ApplicationFlags |= _APPLICATION_FLAGS_DEBUG;
    Debug_pfnStateMachine = DebugSM_Idle;
  }
  
} /* end  DebugInitialize() */
Example #2
0
/*----------------------------------------------------------------------------------------------------------------------
Function: DebugInitialize

Description:
Sets up the debug command list and activates the debug functionality.

Requires:
  - The debug application is not yet running
  - The UART resource requested should be free

Promises:
  - UART resource Debug_au8RxBuffer initialized to all 0
  - Buffer pointers Debug_pu8CmdBufferCurrentChar and Debug_pu8RxBufferParser set to the start of the buffer
  - G_DebugStateMachine set to Idle
*/
void DebugInitialize(void)
{
  UartConfigurationType sUartConfig;  
  u8 au8DebugStarted[] = "Debug task initialized\n\r";

  /* Clear the receive buffer */
  for (u16 i = 0; i < DEBUG_RX_BUFFER_SIZE; i++)
  {
    Debug_au8RxBuffer[i] = 0;
  }

  /* Initailze startup values and the command array */
  Debug_pu8RxBufferParser    = &Debug_au8RxBuffer[0];
  Debug_pu8RxBufferNextChar  = &Debug_au8RxBuffer[0]; 
  Debug_pu8CmdBufferNextChar = &Debug_au8CommandBuffer[0]; 

  /* Request the UART resource to be used for the Debug application */
  sUartConfig.UartPeripheral     = DEBUG_UART;
  sUartConfig.pu8RxBufferAddress = &Debug_au8RxBuffer[0];
  sUartConfig.pu8RxNextByte      = &Debug_pu8RxBufferNextChar;
  sUartConfig.u32RxBufferSize    = DEBUG_RX_BUFFER_SIZE;
  
  Debug_Uart = UartRequest(&sUartConfig);
  
  /* Go to error state if the UartRequest failed */
  if(Debug_Uart == NULL)
  {
    G_DebugStateMachine = DebugSM_Error;

  }
  /* Otherwise send the first message, set "good" flag and head to Idle */
  else
  {
    DebugLineFeed();
    DebugLineFeed();
    UartWriteData(Debug_Uart, sizeof(au8DebugStarted) - 1, &au8DebugStarted[0]);
    
    G_u32ApplicationFlags |= _APPLICATION_FLAGS_DEBUG;
    G_DebugStateMachine = DebugSM_Idle;
  }
  
} /* end  DebugInitialize() */