void __section("SectionForFlashOperations") Native_Profiler_WriteToCOM(void *buffer, UINT32 size) { UINT64 time1, time2; time1 = Native_Profiler_TimeInMicroseconds(); USART_Initialize( ConvertCOM_ComPort(USART_DEFAULT_PORT), HalSystemConfig.USART_DefaultBaudRate, USART_PARITY_NONE, 8, USART_STOP_BITS_ONE, USART_FLOW_NONE ); // disable watchdog Watchdog_GetSetEnabled( FALSE, TRUE ); // flush existing characters USART_Flush( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); // write string char *offset = (char *) buffer; do { UINT32 bytes_written = USART_Write(ConvertCOM_ComPort(USART_DEFAULT_PORT), offset, size); offset += bytes_written; size -= bytes_written; } while(size); // flush new characters USART_Flush( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); Watchdog_GetSetEnabled( TRUE, TRUE ); time2 = Native_Profiler_TimeInMicroseconds(); s_native_profiler.initTime += (time2 - time1); }
void __section("SectionForFlashOperations") Native_Profiler_Dump() { lcd_printf("Buffer is full. Dumping...\r\n"); UINT64 time1, time2; time1 = Native_Profiler_TimeInMicroseconds(); USART_Initialize( ConvertCOM_ComPort(USART_DEFAULT_PORT), HalSystemConfig.USART_DefaultBaudRate, USART_PARITY_NONE, 8, USART_STOP_BITS_ONE, USART_FLOW_NONE ); // clear_watchdog // if we do not disable the watchdog, it can be called while we dump data Watchdog_GetSetEnabled( FALSE, TRUE ); // flush existing characters USART_Flush( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); // write string char *offset = (char *)&ProfilerBufferBegin; UINT32 size = (char *)s_native_profiler.position - (char *)&ProfilerBufferBegin; do { UINT32 bytes_written = USART_Write(ConvertCOM_ComPort(USART_DEFAULT_PORT), offset, size); offset += bytes_written; size -= bytes_written; } while(size); // flush new characters USART_Flush( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); Watchdog_GetSetEnabled( TRUE, TRUE ); time2 = Native_Profiler_TimeInMicroseconds(); s_native_profiler.initTime += (time2 - time1); s_native_profiler.position = &ProfilerBufferBegin; *s_native_profiler.position++ = NATIVE_PROFILER_START_TAG; *s_native_profiler.position++ = s_native_profiler.engineTimeOffset; s_native_profiler.writtenData = FALSE; }
void StartApplication( void (*StartAddress)() ) { PortBooterLoadProgram((void**)&StartAddress); hal_printf( "Starting main application at 0x%08x\r\n", (size_t)StartAddress ); LCD_Clear(); USART_Flush( ConvertCOM_ComPort(g_State.UsartPort) ); if(g_State.UsingUsb) { USB_Flush( ConvertCOM_UsbStream( g_State.UsbPort ) ); USB_CloseStream( ConvertCOM_UsbStream(g_State.UsbPort) ); USB_Uninitialize( ConvertCOM_UsbController(g_State.UsbPort) ); //disable the USB for the next application } DISABLE_INTERRUPTS(); LCD_Uninitialize(); CPU_DisableCaches(); (*StartAddress)(); }
void monitor_debug_printf( const char* format, ... ) { char buffer[256]; va_list arg_ptr; va_start( arg_ptr, format ); int len = hal_vsnprintf( buffer, sizeof(buffer)-1, format, arg_ptr ); // flush existing characters USART_Flush( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); // write string USART_Write( ConvertCOM_ComPort(USART_DEFAULT_PORT), buffer, len ); // flush new characters USART_Flush( ConvertCOM_ComPort(USART_DEFAULT_PORT) ); va_end( arg_ptr ); }
BOOL DebuggerPort_Flush( COM_HANDLE ComPortNum ) { NATIVE_PROFILE_PAL_COM(); switch(ExtractTransport(ComPortNum)) { case USART_TRANSPORT: return USART_Flush( ConvertCOM_ComPort( ComPortNum ) ); case USB_TRANSPORT: return USB_Flush( ConvertCOM_UsbStream(ComPortNum) ); case SOCKET_TRANSPORT: return SOCKETS_Flush( ConvertCOM_SockPort(ComPortNum) ); } return FALSE; }
int TickFct_BluetoothReceiver(int state){ switch(state){ case bluetoothWait: if(USART_HasReceived(0) && !bluetoothEnable){ USART_Flush(0); state = bluetoothWait; } else if(USART_HasReceived(0) && bluetoothEnable){ state = bluetoothReceived; position = 0; lastReceivedChar = 0; clearInputPin(); } else{ state = bluetoothWait; } break; case bluetoothReceived: if(!bluetoothEnable){ state = bluetoothWait; } else if(lastReceivedChar != '*'){ state = bluetoothWaitForNext; } else{ state = bluetoothWait; } break; case bluetoothWaitForNext: if(!bluetoothEnable){ state = bluetoothWait; } else if(!USART_HasReceived(0)){ state = bluetoothWaitForNext; } else{ state = bluetoothReceived; } break; default: state = bluetoothWait; break; } switch(state){ case bluetoothWait: break; case bluetoothReceived: while(lastReceivedChar != '*'){ lastReceivedChar = USART_Receive(0); if(lastReceivedChar != '*'){ inputPin[position++] = lastReceivedChar; } else{ inputPin[position] = '\0'; pinInputComplete = 1; } } break; case bluetoothWaitForNext: break; } return state; }