/* initialise everything */ void PicocInitialise(Picoc *pc, int StackSize) { memset(pc, '\0', sizeof(*pc)); PlatformInit(pc); BasicIOInit(pc); HeapInit(pc, StackSize); TableInit(pc); VariableInit(pc); LexInit(pc); TypeInit(pc); #ifndef NO_HASH_INCLUDE IncludeInit(pc); #endif LibraryInit(pc); #ifdef BUILTIN_MINI_STDLIB LibraryAdd(pc, &pc->GlobalTable, "c library", &CLibrary[0]); CLibraryInit(pc); #endif PlatformLibraryInit(pc); DebugInit(pc); }
/////////////////////////////////////////////////////////////////////////////// // CreateScene - Creates and returns a new Scene ISystemScene* HavokPhysicsSystem::CreateScene( void ) { // // Initialize Havok. // PlatformInit(); hkMemorySystem::FrameInfo finfo(500 * 1024); // Allocate 500KB of Physics solver buffer hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault(hkMallocAllocator::m_defaultMallocAllocator, finfo); hkBaseSystem::init( memoryRouter, ErrorReport ); // // Disable some unnecessary warnings. // hkError::getInstance().setEnabled( 0x2a2cde91, false ); hkError::getInstance().setEnabled( 0x6e8d163b, false ); hkError::getInstance().setEnabled( 0xad345a23, false ); hkError::getInstance().setEnabled( 0x11fce585, false ); hkError::getInstance().setEnabled( 0x34df5494, false ); #ifdef __HAVOK_VDB__ hkError::getInstance().setEnabled( 0x1293ADE8, false ); hkError::getInstance().setEnabled( 0x1293ADEF, false ); #endif return new HavokPhysicsScene( this ); }
/** * main - main application loop. Sets up platform and then performs simple * transfers (simplex) while incrementing the sequence number for the lifetime * of execution. * * @return Exit code of the main application, however, this application * should never exit. */ int main(void) { // Setup hardware and protocol. PlatformInit(); while (true) { // Perform a simple transfer of the packet. if (!ProtocolSimpleTransfer((unsigned char*)&gPacket, sizeof(struct sPacket))) { // Put the microcontroller into a low power state (sleep). Remain here // until the ISR wakes up the processor. McuSleep(); } /** * Check if the protocol is busy. If it is, a new transfer cannot occur * until it becomes ready for the next instruction. Do not increment the * sequence number until the protocol is ready. This prevents incrementing * the sequence number more than once between transmissions. */ if (!ProtocolBusy()) { // Increment the sequence number for the next transmission. gPacket.seqNum++; } } }
ibRenderDevice::ibRenderDevice() { PlatformInit(); BlendReset(); BlendCommit(); DepthStencilReset(); DepthStencilCommit(); }
int main(int argc, char *argv[]) { PlatformInit(argc, argv); otEnable(); otNcpInit(); while (1) { otProcessNextTasklet(); PlatformProcessDrivers(); } return 0; }
int main(int argc, char *argv[]) { otInstance *sInstance; #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES size_t otInstanceBufferLength = 0; uint8_t *otInstanceBuffer = NULL; #endif pseudo_reset: PlatformInit(argc, argv); #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES // Call to query the buffer size (void)otInstanceInit(NULL, &otInstanceBufferLength); // Call to allocate the buffer otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength); assert(otInstanceBuffer); // Initialize OpenThread with the buffer sInstance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength); #else sInstance = otInstanceInitSingle(); #endif assert(sInstance); otNcpInit(sInstance); #if OPENTHREAD_ENABLE_DIAG otDiagInit(sInstance); #endif while (!PlatformPseudoResetWasRequested()) { otTaskletsProcess(sInstance); PlatformProcessDrivers(sInstance); } otInstanceFinalize(sInstance); #if OPENTHREAD_ENABLE_MULTIPLE_INSTANCES free(otInstanceBuffer); #endif goto pseudo_reset; return 0; }
Result Init(int argc, char* argv[]) { /* * * Will be defined in platform-specific utility sources. * This weird declaration is so that this function isn't * exposed as end-user API * */ extern Result PlatformInit(int, char*[]); if(!glfwInit()) { printf("GLFW initialization failed\n"); return BGE_FAILURE; } /* We don't want the shared context window visible */ glfwWindowHint(GLFW_VISIBLE, GL_FALSE); /* Create our shared context window */ Window::SharedContext = glfwCreateWindow(16, 16, "", NULL, NULL); if(Window::SharedContext == NULL) { printf("Error creating shared context\n"); return BGE_FAILURE; } /* Need to make context current so we can init the shader library */ glfwMakeContextCurrent(Window::SharedContext); /* So future GLFW windows are visible */ glfwWindowHint(GLFW_VISIBLE, GL_TRUE); if(glewInit() != GLEW_OK) { printf("Error initializing GLEW\n"); return BGE_FAILURE; } /* Initialize our Bakge shader library */ if(ShaderProgram::InitShaderLibrary() != BGE_SUCCESS) return BGE_FAILURE; /* Run platform-specific initialization protocol */ if(PlatformInit(argc, argv) != BGE_SUCCESS) return BGE_FAILURE; return BGE_SUCCESS; }
void HavokPhysics::Init(void) { // Shamelessly stolen from the Havok Physics demo... PlatformInit(); // Need to have memory allocated for the solver. Allocate 1mb for it. hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault( hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo( 500* 1024 ) ); hkBaseSystem::init( memoryRouter, HavokPhysics::ErrorReport ); this->m_HavokError = new HavokError(HavokPhysics::ErrorReport ); hkError::replaceInstance( this->m_HavokError ); // The world cinfo contains global simulation parameters, including gravity, solver settings etc. hkpWorldCinfo worldInfo; // Set the simulation type of the world to multi-threaded. worldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_CONTINUOUS; // Flag objects that fall "out of the world" to be automatically removed - just necessary for this physics scene worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_REMOVE_ENTITY; this->m_pHavok_world = new hkpWorld(worldInfo); // Disable deactivation, so that you can view timers in the VDB. This should not be done in your game. this->m_pHavok_world->m_wantDeactivation = false; // When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks // to make sure only one thread is modifying the world at once to prevent multithreaded bugs. Each thread // must call markForRead / markForWrite before it modifies the world to enable these checks. this->m_pHavok_world->markForWrite(); // Register all collision agents, even though only box - box will be used in this particular example. // It's important to register collision agents before adding any entities to the world. hkpAgentRegisterUtil::registerAllAgents( this->m_pHavok_world->getCollisionDispatcher() ); }
/** * diagnostics module tests */ void TestDiag() { static const struct { const char *command; const char *output; } tests[] = { { "diag\n", "diagnostics mode is disabled\r\n", }, { "diag send 10 100\n", "failed\r\nstatus 0xe\r\n", }, { "diag start\n", "start diagnostics mode\r\nstatus 0x00\r\n", }, { "diag\n", "diagnostics mode is enabled\r\n", }, { "diag channel 10\n", "failed\r\nstatus 0x7\r\n", }, { "diag channel 11\n", "set channel to 11\r\nstatus 0x00\r\n", }, { "diag channel\n", "channel: 11\r\n", }, { "diag power -10\n", "set tx power to -10 dBm\r\nstatus 0x00\r\n", }, { "diag power\n", "tx power: -10 dBm\r\n", }, { "diag stats\n", "received packets: 0\r\nsent packets: 0\r\nfirst received packet: rssi=0, lqi=0\r\n", }, { "diag send 20 100\n", "sending 0x14 packet(s), length 0x64\r\nstatus 0x00\r\n", }, { "diag repeat 100 100\n", "sending packets of length 0x64 at the delay of 0x64 ms\r\nstatus 0x00\r\n" }, { "diag sleep\n", "sleeping now...\r\n", }, { "diag stop\n", "received packets: 0\r\nsent packets: 0\r\nfirst received packet: rssi=0, lqi=0\r\n\nstop diagnostics mode\r\nstatus 0x00\r\n", }, { "diag\n", "diagnostics mode is disabled\r\n", }, }; // initialize platform layer int argc = 2; char *argv[8] = {(char *)"test_diag", (char *)"1"}; PlatformInit(argc, argv); // initialize diagnostics module diagInit(NULL); // test diagnostics commands VerifyOrQuit(!isDiagEnabled(), "diagnostics mode shoud be disabled as default\n"); for (unsigned int i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { char string[50]; char *output = NULL; memcpy(string, tests[i].command, strlen(tests[i].command) + 1); output = diagProcessCmdLine(string); VerifyOrQuit(memcmp(output, tests[i].output, strlen(tests[i].output)) == 0, "Test Diagnostics module failed\r\n"); } }
int main(void) { int delay; float fTemperature, fPressure, fAltitude, fK_Altitude, fAltitude_sum,fK_Altitude_sum; int count,i; // static float f_meas[VAR_COUNT], fAlt_Mean, fAlt_Var; unsigned short sw1_count, sw2_count; unsigned char sw1_was_cleared = 0, sw2_was_cleared = 0; // Set the clocking to run directly from the external crystal/oscillator. MAP_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | WRFL_XTAL); //init ports and peripherals PlatformInit(); Nokia5110_Init(); Nokia5110_Clear(); Nokia5110_DrawFullImage(gears_logo); for(delay=0; delay<1000000; delay=delay+1); Nokia5110_Clear(); Nokia5110_SetCursor(3, 1); Nokia5110_OutString("WRFL"); Nokia5110_SetCursor(1, 2); Nokia5110_OutString("Prototype"); Nokia5110_SetCursor(2, 4); Nokia5110_OutString("VER 0.1"); Nokia5110_SetCursor(0, 5); Nokia5110_OutString("NightMecanic"); for(delay=0; delay<1000000; delay=delay+1); Nokia5110_Clear(); // // Enable interrupts to the processor. // MAP_IntMasterEnable(); // // Initialize I2C1 peripheral. // I2CMInit(&g_sI2CInst, BMP180_I2C_BASE, BMP180_I2C_INT, 0xff, 0xff, MAP_SysCtlClockGet()); // // Initialize the BMP180 // BMP180Init(&g_sBMP180Inst, &g_sI2CInst, BMP180_I2C_ADDRESS, BMP180AppCallback, &g_sBMP180Inst); // // Wait for initialization callback to indicate reset request is complete. // while(g_vui8DataFlag == 0) { // // Wait for I2C Transactions to complete. // } // // Reset the data ready flag // g_vui8DataFlag = 0; //set oversampling to 8x g_sBMP180Inst.ui8Mode = 0xC0; //Initialize the Kalman filter Kalman_Init(&Alt_KState, 0.0f, 1.0f, ALT_KALMAN_R, ALT_KALMAN_Q); // // Enable the system ticks at 10 hz. // MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / (40 * 3)); MAP_SysTickIntEnable(); MAP_SysTickEnable(); Nokia5110_SetCursor(0, 0); Nokia5110_OutString("SW1:"); Nokia5110_SetCursor(0, 2); Nokia5110_OutString("SW2:"); //config done count = 0; // // Begin the data collection and printing. Loop Forever. // while(1) { // SW1 if (sw_state & SW1){ if (sw1_was_cleared){ sw1_was_cleared = 0; sw1_count++; Nokia5110_SetCursor(5, 0); Nokia5110_OutUDec(sw1_count); } }else sw1_was_cleared = 1; //SW2 if (sw_state & SW2){ if (sw2_was_cleared){ sw2_was_cleared = 0; sw2_count++; Nokia5110_SetCursor(5, 2); Nokia5110_OutUDec(sw2_count); } }else sw2_was_cleared = 1; // handle BMP180 data (display average every 50 samples) if (g_vui8DataFlag ){ // // Reset the data ready flag. // g_vui8DataFlag = 0; // // Get a local copy of the latest temperature data in float format. // BMP180DataTemperatureGetFloat(&g_sBMP180Inst, &fTemperature); // // Print temperature with three digits of decimal precision. // //Nokia5110_SetCursor(0, 0); //Nokia5110_OutString("Temp:"); //Nokia5110_OutFloatp3(fTemperature); // // Get a local copy of the latest air pressure data in float format. // BMP180DataPressureGetFloat(&g_sBMP180Inst, &fPressure); // // Print Pressure with three digits of decimal precision. // //Nokia5110_SetCursor(0, 1); // Nokia5110_OutString("Pres:"); //Nokia5110_SetCursor(0, 2); //display in hPa //Nokia5110_OutFloatp3((fPressure / 100.0f)); // // Calculate the altitude. // //fAltitude = 44330.0f * (1.0f - powf(fPressure / 101325.0f, // 1.0f / 5.255f)); //corrected: fAltitude = 44330.0f * (1.0f - powf(fPressure / LOC_ALT_P0, 1.0f / 5.255f)); // Kalman filtered altitude Kalman_Update (&Alt_KState, fAltitude); fK_Altitude = Alt_KState.X; fAltitude_sum += fAltitude; fK_Altitude_sum += fK_Altitude; count++; if (count>=50){ Nokia5110_SetCursor(0, 3); Nokia5110_OutString("Alt:"); Nokia5110_OutFloatp3(fAltitude_sum/50.0); Nokia5110_SetCursor(0, 5); Nokia5110_OutString("KAlt:"); Nokia5110_OutFloatp3(fK_Altitude_sum/50.0); fAltitude_sum = 0; fK_Altitude_sum = 0; count = 0; } /* //calculate variance f_meas[count]=fK_Altitude; count++; if (count>=VAR_COUNT){ fAlt_Mean = 0.0f; fAlt_Var = 0.0f; // calculate mean for(i=0; i<VAR_COUNT; i++){ fAlt_Mean = fAlt_Mean +f_meas[i]; } fAlt_Mean = fAlt_Mean/((float) VAR_COUNT); // Calculate Var for(i=0; i<VAR_COUNT; i++){ fAlt_Var = fAlt_Var + powf((f_meas[i] - fAlt_Mean),2.0f); } fAlt_Var = fAlt_Var/((float) VAR_COUNT); // // Print altitude with three digits of decimal precision. // Nokia5110_SetCursor(0, 4); Nokia5110_OutString("Var:"); Nokia5110_OutFloatp3(fAlt_Var); count = 0; } */ // // Delay to keep printing speed reasonable. About 100msec. // //MAP_SysCtlDelay(MAP_SysCtlClockGet() / (10 * 3)); } }//while end }