コード例 #1
0
ファイル: tutorial11_device.cpp プロジェクト: davenso/embree
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* set error handler */
  rtcSetErrorFunction(error_handler);
  
  /* set start render mode */
  renderPixel = renderPixelStandard;

  /* create random bounding boxes */
  const size_t N = 2300000;
  isa::PrimInfo pinfo(empty);
  vector_t<PrimRef> prims; 
  for (size_t i=0; i<N; i++) {
    const Vec3fa p = 1000.0f*Vec3fa(drand48(),drand48(),drand48());
    const BBox3fa b = BBox3fa(p,p+Vec3fa(1.0f));
    pinfo.add(b);
    const PrimRef prim = PrimRef(b,i);
    prims.push_back(prim);
  }

  build_sah(prims,pinfo);
  build_morton(prims,pinfo);
}
コード例 #2
0
 SingleRayDevice::SingleRayDevice(size_t numThreads, const char* cfg)
 {
   rtcInit(cfg);
   //rtcSetVerbose(verbose);
   //rtcStartThreads(numThreads);
   TaskScheduler::create(numThreads);
 }
コード例 #3
0
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
    /* initialize ray tracing core */
    rtcInit(cfg);

    /* create scene */
    g_scene = rtcNewScene(RTC_SCENE_DYNAMIC,RTC_INTERSECT1);

    /* create some triangulated spheres */
    for (int i=0; i<numSpheres; i++)
    {
        const float phi = i*2.0f*float(pi)/numSpheres;
        const float r = 2.0f*float(pi)/numSpheres;
        const Vec3f p = 2.0f*Vec3f(sin(phi),0.0f,-cos(phi));
        RTCGeometryFlags flags = i%2 ? RTC_GEOMETRY_DEFORMABLE : RTC_GEOMETRY_DYNAMIC;
        //RTCGeometryFlags flags = RTC_GEOMETRY_DEFORMABLE;
        int id = createSphere(flags,p,r);
        position[id] = p;
        radius[id] = r;
        colors[id].x = (i%16+1)/17.0f;
        colors[id].y = (i%8+1)/9.0f;
        colors[id].z = (i%4+1)/5.0f;
    }

    /* add ground plane to scene */
    int id = addGroundPlane(g_scene);
    colors[id] = Vec3f(1.0f,1.0f,1.0f);

    /* commit changes to scene */
    rtcCommit (g_scene);

    /* set start render mode */
    renderPixel = renderPixelStandard;
}
コード例 #4
0
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* set error handler */
  rtcSetErrorFunction(error_handler);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_DYNAMIC | RTC_SCENE_ROBUST,RTC_INTERSECT1);

  /* add cube */
  addCube(g_scene);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* commit changes to scene */
#if !defined(PARALLEL_COMMIT)
  rtcCommit (g_scene);
#else
  launch[ getNumHWThreads() ] parallelCommit(g_scene); 
#endif

  /* set start render mode */
  renderPixel = renderPixelStandard;
}
コード例 #5
0
ファイル: bvh_access.cpp プロジェクト: pierremoreau/embree
  /* main function in embree namespace */
  int main(int argc, char** argv) 
  {
    /* for best performance set FTZ and DAZ flags in MXCSR control and status register */
    _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
    _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);

    /* initialize ray tracing core and force bvh4.triangle4v hierarchy for triangles */
    rtcInit("tri_accel=bvh4.triangle4v");
    
    /* set error handler */
    rtcSetErrorFunction(error_handler);
    
    /* create scene */
    g_scene = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
    addCube(g_scene,Vec3fa(-1,0,0));
    addCube(g_scene,Vec3fa(1,0,0));
    addCube(g_scene,Vec3fa(0,0,-1));
    addCube(g_scene,Vec3fa(0,0,1));
    addHair(g_scene);
    addGroundPlane(g_scene);
    rtcCommit (g_scene);

    /* print triangle BVH */
    print_bvh(g_scene);

    /* cleanup */
    rtcDeleteScene (g_scene);
    rtcExit();
    return 0;
  }
コード例 #6
0
ファイル: hal.c プロジェクト: Kreyl/WitcherGlove
/**
 * @brief   HAL initialization.
 * @details This function invokes the low level initialization code then
 *          initializes all the drivers enabled in the HAL. Finally the
 *          board-specific initialization is performed by invoking
 *          @p boardInit() (usually defined in @p board.c).
 *
 * @init
 */
void halInit(void) {

  hal_lld_init();

#if HAL_USE_TM || defined(__DOXYGEN__)
  tmInit();
#endif
#if HAL_USE_PAL || defined(__DOXYGEN__)
  palInit(&pal_default_config);
#endif
#if HAL_USE_ADC || defined(__DOXYGEN__)
  adcInit();
#endif
#if HAL_USE_CAN || defined(__DOXYGEN__)
  canInit();
#endif
#if HAL_USE_EXT || defined(__DOXYGEN__)
  extInit();
#endif
#if HAL_USE_GPT || defined(__DOXYGEN__)
  gptInit();
#endif
#if HAL_USE_I2C || defined(__DOXYGEN__)
  i2cInit();
#endif
#if HAL_USE_ICU || defined(__DOXYGEN__)
  icuInit();
#endif
#if HAL_USE_MAC || defined(__DOXYGEN__)
  macInit();
#endif
#if HAL_USE_PWM || defined(__DOXYGEN__)
  pwmInit();
#endif
#if HAL_USE_SERIAL || defined(__DOXYGEN__)
  sdInit();
#endif
#if HAL_USE_SDC || defined(__DOXYGEN__)
  //KL All in Kl_sdc sdcInit();
#endif
#if HAL_USE_SPI || defined(__DOXYGEN__)
  spiInit();
#endif
#if HAL_USE_UART || defined(__DOXYGEN__)
  uartInit();
#endif
#if HAL_USE_USB || defined(__DOXYGEN__)
  usbInit();
#endif
#if HAL_USE_MMC_SPI || defined(__DOXYGEN__)
  mmcInit();
#endif
#if HAL_USE_SERIAL_USB || defined(__DOXYGEN__)
  sduInit();
#endif
#if HAL_USE_RTC || defined(__DOXYGEN__)
  rtcInit();
#endif
}
コード例 #7
0
ファイル: Raytracer.cpp プロジェクト: ThermalPixel/osgdemos
Raytracer::Raytracer(osg::Node *scene, osg::Camera *camera)
    :_rootNode(scene), _camera(camera), TILE_SIZE_X(32),TILE_SIZE_Y(32), _backgroundColor(0.3f,0.4f,0.5f,1.0f)
{
    rtcInit();
    _scene = rtcNewScene(RTC_SCENE_STATIC, RTC_INTERSECT1);
    buildScene();
    setOutputResolution(512,512);
}
コード例 #8
0
ファイル: board.c プロジェクト: LucasMahieu/neon
void boardInit(void)
{
    SIM_SCGC5 |= 0x00000400; //enable Port B clock
    SIM_SCGC5 |= 0x00000200; //enable Port A clock
    SIM_SCGC5 |= 0x00001000; //enable Port D clock

    PORTB_PCR19 |= (uint32_t)0x00000100; //Configure portB19 as GPIO (GREEN)
    GPIOB_PDDR |= (uint32_t)0x00080000; //Configure portB19 as output

    PORTA_PCR12 |= (uint32_t)0x000A0102; //Configure portA12 as GPIO with falling edge interrupt and pullup enabled.
    GPIOA_PDDR &= ~(uint32_t)(1<<12); //Configure portA12 as input.

    PORTB_PCR18 |= (uint32_t)0x00000100; //Configure portB18 as GPIO (RED)
    GPIOB_PSOR |= (uint32_t)0x00040000;
    GPIOB_PDDR |= (uint32_t)0x00040000; //Configure portB18 as output

    PORTD_PCR1 |= (uint32_t)0x00000100; //Configure portD1 as GPIO (BLUE)
    FGPIOD_PSOR |= (uint32_t)0x00000002;
    FGPIOD_PDDR |= (uint32_t)0x00000002; //Configure portD1 as output

    //SIM_SCGC6 |= (uint8_t) 0x00800000; // Enable PIT clock

    SIM_SOPT2 |= 0x01000000; // Set TPM to use the MCGFLLCLK as a clock source
    // MCGFLLCLK is either 24MHz or 23 986 176Hz
    SIM_SCGC6 |= 0x01000000; // Enable TPM0 clock

    uart0Config();
    uart0Enable();

    llwuConfigure();
    vllsEnable();
    vllsConfigure(1);

    PMC_REGSC = 0x08;

    systickConfigure();

    interruptSetPriority(30,0); //Port A ISR
    interruptEnable(30);

    interruptSetPriority(7,0); // Configure LLWU interrupt as highest priority.
    interruptEnable(7); //Enable LLWU interrupt.

    systickEnable();

    rtcInit();
    rtcStart();

    interruptSetPriority(21,0); // Configure RTC Seconds interrupt as highest priority.
    interruptEnable(21); //Enable RTC Seconds interrupt.

    i2cInit();
    interruptSetPriority(9,3); // Configure I2C interrupt as Lowest priority.
    interruptEnable(9); //Enable I2C interrupt.

    interruptSetPriority(22,3); // Configure PIT interrupt as Lowest priority.
    interruptEnable(9); //Enable PIT interrupt.
}
コード例 #9
0
ファイル: utility.c プロジェクト: bgomberg/TapeBot
//perform all initialization
void initialize()
{
	//configure BTN1 as an input
	cbi(DDRD, 4);
	//enable pullup for BTN1
	sbi(PORTD, 4);

	//configure LED as an output
	sbi(DDRG, 2);

	//configure 74LS374 (D Flip-Flop) clock pin as an output
	sbi(DDRD, 5);

	//configure LCD/Servo bus on port C as an output
	DDRC = 0xFF;

	#if USE_LCD == 1
		//initialize LCD
		lcdInit();
	#endif

	#if USE_I2C == 1
		//configure I2C clock rate
		i2cInit();
	#endif

	#if USE_MOTOR0 == 1 || USE_MOTOR1 == 1
		//initialize enabled motors
		motorInit();
	#endif

	#if NUM_SERVOS > 0
		//initialize servos
		servoInit();
	#endif

	#if USE_ADC == 1
		//initialize ADC
		adcInit();
	#endif

	#if USE_UART0 == 1
		//initialize UART0
		uart0Init();
	#endif

	#if USE_UART1 == 1
		//initialize UART1
		uart1Init();
	#endif
	
	#if USE_RTC == 1
		//initialize RTC
		rtcInit();
	#endif
}
コード例 #10
0
/*
 * @brief Application Program Loop
 */
void application()
{
	// Stop Watchdog Timer
	stopWatchdogTimer();

	// Configure DCO Frequency 1 MHz
	configureDCOFrequency1MHz();

	// Configure PushButtons Inputs
	pinDigitalInput(RTCSET);
	pinDigitalInput(RTCINC);
	pinDigitalInput(RTCDEC);

	// Configure PullUps
	pinDigitalEnabledPullUp(RTCSET);
	pinDigitalEnabledPullUp(RTCINC);
	pinDigitalEnabledPullUp(RTCDEC);

	// Configure High Low Interrupt
	pinDigitalSelectHighLowTransitionInterrupt(RTCSET);
	pinDigitalSelectHighLowTransitionInterrupt(RTCINC);
	pinDigitalSelectHighLowTransitionInterrupt(RTCDEC);

	// Configure Pin Interrupts
	pinDigitalEnableInterrupt(RTCSET);
	pinDigitalEnableInterrupt(RTCINC);
	pinDigitalEnableInterrupt(RTCDEC);

	// Init PAP Motor
	papMotorInit();

	// RTC Init
	rtcInit();

	// Start RTC
	rtcStart();

	// Initialize LCD Module
	lcdInit();

	// Write Message Constant
	lcdWriteMessage(1,1,mensaje);

	// Write Date and Time LCD Module
	lcdDataTimeFormat(2, 1, rtcGetHour(), rtcGetMinute(), rtcGetSecond());
	lcdDataDateFormat(2, 11, rtcGetDay(), rtcGetMonth(), rtcGetYear());

	// Enable Interrupts
	enableInterrupts();

	// Entry Low Power Mode 0
	entryLowPowerMode0();
}
コード例 #11
0
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* set error handler */
  rtcSetErrorFunction(error_handler);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_DYNAMIC,RTC_INTERSECT1);

  /* create scene with 4 triangulated spheres */
  g_scene1 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,+1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa( 0, 0,-1),0.5);
  createTriangulatedSphere(g_scene1,Vec3fa(-1, 0, 0),0.5);
  rtcCommit (g_scene1);

  /* instantiate geometry */
  g_instance0 = rtcNewInstance(g_scene,g_scene1);
  g_instance1 = rtcNewInstance(g_scene,g_scene1);
  g_instance2 = rtcNewInstance(g_scene,g_scene1);
  g_instance3 = rtcNewInstance(g_scene,g_scene1);
  createGroundPlane(g_scene);

  /* set all colors */
  colors[0][0] = Vec3fa(0.25,0,0);
  colors[0][1] = Vec3fa(0.50,0,0);
  colors[0][2] = Vec3fa(0.75,0,0);
  colors[0][3] = Vec3fa(1.00,0,0);

  colors[1][0] = Vec3fa(0,0.25,0);
  colors[1][1] = Vec3fa(0,0.50,0);
  colors[1][2] = Vec3fa(0,0.75,0);
  colors[1][3] = Vec3fa(0,1.00,0);

  colors[2][0] = Vec3fa(0,0,0.25);
  colors[2][1] = Vec3fa(0,0,0.50);
  colors[2][2] = Vec3fa(0,0,0.75);
  colors[2][3] = Vec3fa(0,0,1.00);

  colors[3][0] = Vec3fa(0.25,0.25,0);
  colors[3][1] = Vec3fa(0.50,0.50,0);
  colors[3][2] = Vec3fa(0.75,0.75,0);
  colors[3][3] = Vec3fa(1.00,1.00,0);

  /* set start render mode */
  renderPixel = renderPixelStandard;
  key_pressed_handler = device_key_pressed_default;
}
コード例 #12
0
ファイル: tutorial01_device.cpp プロジェクト: D-POWER/embree
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* set error handler */
  rtcSetErrorFunction(error_handler);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_DYNAMIC,RTC_INTERSECT1);

  /* create some triangulated spheres */
  for (int i=0; i<numSpheres; i++)
  {
    const float phi = i*2.0f*float(pi)/numSpheres;
    const float r = 2.0f*float(pi)/numSpheres;
    const Vec3fa p = 2.0f*Vec3fa(sin(phi),0.0f,-cos(phi));
    //RTCGeometryFlags flags = i%3 == 0 ? RTC_GEOMETRY_STATIC : i%3 == 1 ? RTC_GEOMETRY_DEFORMABLE : RTC_GEOMETRY_DYNAMIC;
    RTCGeometryFlags flags = i%2 ? RTC_GEOMETRY_DEFORMABLE : RTC_GEOMETRY_DYNAMIC;
    //RTCGeometryFlags flags = RTC_GEOMETRY_DEFORMABLE;
    int id = createSphere(flags,p,r);
    position[id] = p;
    radius[id] = r;
    colors[id].x = (i%16+1)/17.0f;
    colors[id].y = (i%8+1)/9.0f;
    colors[id].z = (i%4+1)/5.0f;
  }

  /* add ground plane to scene */
  int id = addGroundPlane(g_scene);
  colors[id] = Vec3fa(1.0f,1.0f,1.0f);

  /* commit changes to scene */
#if !defined(PARALLEL_COMMIT)
  rtcCommit (g_scene);
#else
  launch[ getNumHWThreads() ] parallelCommit(g_scene); 
#endif

  /* set start render mode */
  renderPixel = renderPixelStandard;
}
コード例 #13
0
ファイル: tutorial05_device.cpp プロジェクト: cpaalman/embree
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);

  /* add cube */
  addCube(g_scene);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* commit changes to scene */
  rtcCommit (g_scene);

  /* set start render mode */
  renderPixel = renderPixelStandard;
}
コード例 #14
0
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* set error handler */
  rtcSetErrorFunction(error_handler);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_DYNAMIC | RTC_SCENE_ROBUST,RTC_INTERSECT1);

  /* add cube */
  addCube(g_scene);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* set start render mode */
  renderPixel = renderPixelStandard;
}
コード例 #15
0
ファイル: tutorial07_device.cpp プロジェクト: D-POWER/embree
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize last seen camera */
  g_accu_vx = Vec3fa(0.0f);
  g_accu_vy = Vec3fa(0.0f);
  g_accu_vz = Vec3fa(0.0f);
  g_accu_p  = Vec3fa(0.0f);

  /* initialize hair colors */
  hair_K  = Vec3fa(0.8f,0.57f,0.32f);
  hair_dK = Vec3fa(0.1f,0.12f,0.08f);
  hair_Kr = 0.2f*hair_K;    //!< reflectivity of hair
  hair_Kt = 0.8f*hair_K;    //!< transparency of hair

  /* initialize ray tracing core */
  rtcInit(cfg);

  /* set error handler */
  rtcSetErrorFunction(error_handler);

  /* set start render mode */
  renderPixel = renderPixelStandard;

}
コード例 #16
0
void setup() {
  Serial.begin(9600);
  Serial.println();
  Serial.print(SELF_NAME);
  Serial.println(F(" started..."));

  #ifdef ETHERNET_FEATURE
    ethernetInit();
  #endif

  sdCardInit();

  #ifdef RTC_FEATURE
    rtcInit();
  #endif

  #ifdef SERVER_FEATURE
    serverInit();
  #endif

  timersInit();

  #ifdef MAJORDOMO_FEATURE
    majordomoInit();
    majordomoMegaLive();
  #endif

  #ifdef LAURENT_FEATURE
    laurentInit();
  #endif

  #ifdef SD_INFO_FEATURE
    sdInfoInit();
  #endif

  #ifdef SD_FILES_FEATURE
    sdFilesInit();
  #endif

  #ifdef PING_FEATURE
    pingInit();
  #endif

  #ifdef UPLOAD_FEATURE
    uploadInit();
  #endif

  #ifdef PIRS_FEATURE
    pirsInit();
  #endif

  #ifdef CONTACTS_FEATURE
    contactsInit();
  #endif

  #ifdef TEMP_FEATURE
    tempInit();
  #endif

  #ifdef ELECTRO_FEATURE
    electroInit();
  #endif

  #ifdef KEYS_FEATURE
    keysInit();
  #endif

  #ifdef LEDS_FEATURE
    ledsInit();
  #endif

  #ifdef NOO_FEATURE
    nooInit();
  #endif

  timeStamp();
  Serialprint("GLOBAL Init DONE\n");
  Serial.println();
  timeStamp();
  Serialprint("AMS WORK\n");
} // setup
コード例 #17
0
extern "C" void ispcInit(const char* cfg) {
    rtcInit(cfg);
}
コード例 #18
0
ファイル: usartTask.c プロジェクト: nerox8664/diplom-firmware
// Private functions
void usartTask_initHW(void) {
  usartInit();
  rtcInit();
  consoleInit();
}
コード例 #19
0
ファイル: task_lpm.c プロジェクト: kylemanna/kinetis-sdk1
void task_lpm(task_param_t param)
{
    demo_power_modes_t testVal;
    uint8_t cmConfigMode = CLOCK_RUN;
    uint8_t mode;
    power_manager_error_code_t ret;
    uint32_t freq = 0;

    rtc_datetime_t date;
    memset(&date, 0, sizeof(rtc_datetime_t));
    memset(&cmCallbackData, 0, sizeof(lptmrStructure_t));
    cmCallbackData.instance = PM_RTOS_DEMO_LPTMR_FUNC_INSTANCE;
    lptmr_user_config_t *lptmrUserConfig = &(cmCallbackData.lptmrUserConfig);
    lptmr_state_t *lptmrState = &(cmCallbackData.lptmrState);

    CLOCK_SYS_Init(g_defaultClockConfigurations,
                   CLOCK_NUMBER_OF_CONFIGURATIONS,
                   cm_callback_tbl,
                   cm_callback_tbl_size);

    CLOCK_SYS_UpdateConfiguration(cmConfigMode, kClockManagerPolicyForcible);

    // Set a start date time and start RTC
    date.year = 2014;
    date.month = 4U;
    date.day = 30U;
    date.hour = 14U;
    date.minute = 0U;
    date.second = 0U;
    rtcInit(PM_RTOS_DEMO_RTC_FUNC_INSTANCE, &date);
    lptmrUserConfig->timerMode = kLptmrTimerModeTimeCounter; // Use LPTMR in Time Counter mode
    lptmrUserConfig->freeRunningEnable = false; // When hit compare value, set counter back to zero
    lptmrUserConfig->prescalerEnable = false; // bypass prescaler
    lptmrUserConfig->prescalerClockSource = kClockLptmrSrcLpoClk; // use 1kHz Low Power Clock
    lptmrUserConfig->isInterruptEnabled = false;
    lptmrInit(lptmrUserConfig, lptmrState);

    // initialize power manager driver
    POWER_SYS_Init(powerConfigs,
                   powerConfigsSize,
                   pm_callback_tbl,
                   pm_callback_tbl_size);

    // Enables LLWU interrupt
    INT_SYS_EnableIRQ(LLWU_IRQn);

#if (defined FSL_RTOS_BM)
    PRINTF("\n\r####################  Power Manager BM Demo ####################\n\n\r");
#elif (defined FSL_RTOS_FREE_RTOS)
    PRINTF("\n\r####################  Power Manager FreeRTOS Demo ####################\n\n\r");
#elif (defined FSL_RTOS_MQX)
    PRINTF("\n\r####################  Power Manager MQX Demo ####################\n\n\r");
#elif (defined FSL_RTOS_UCOSII)
    PRINTF("\n\r####################  Power Manager Ucosii Demo ####################\n\n\r");
#elif (defined FSL_RTOS_UCOSIII)
    PRINTF("\n\r####################  Power Manager Ucosiii Demo ####################\n\n\r");
#else
    PRINTF("\n\rUnknown RTOS\n\n\r");
#endif

    while (1)
    {
        mode = 0;
        CLOCK_SYS_GetFreq(kCoreClock, &freq);
        PRINTF("    Core Clock = %luHz \n\r", freq);
        displayPowerMode();
        PRINTF("\n\rSelect the desired operation \n\n\r");
        PRINTF("Press  %c for enter: RUN   - Normal RUN mode\n\r",kDemoRun);
        PRINTF("Press  %c for enter: Wait  - Wait mode\n\r",kDemoWait);
        PRINTF("Press  %c for enter: Stop  - Stop mode\n\r",kDemoStop);
        PRINTF("Press  %c for enter: VLPR  - Very Low Power Run mode\n\r",kDemoVlpr);
        PRINTF("Press  %c for enter: VLPW  - Very Low Power Wait mode\n\r",kDemoVlpw);
        PRINTF("Press  %c for enter: VLPS  - Very Low Power Stop mode\n\r",kDemoVlps);

        PRINTF("Press  %c for enter: LLS   - Low Leakage Stop mode\n\r",kDemoLls);

        PRINTF("Press  %c for enter: VLLS1 - Very Low Leakage Stop 1 mode\n\r",kDemoVlls1);

        PRINTF("Press  %c for enter: VLLS2 - Very Low Leakage Stop 2 mode\n\r",kDemoVlls2);

        PRINTF("Press  %c for enter: VLLS3 - Very Low Leakage Stop 3 mode\n\r",kDemoVlls3);
        PRINTF("Press  %c to get current chip temperature\n\r",KDemoADC);

        PRINTF("------------------------------------------------------------\n\r");
        PRINTF("\n\rWaiting for key press..\n\r\n\r");

        // Wait for user response
        testVal = (demo_power_modes_t)getInput();
        PRINTF("You pressed: '%c'\r\n", testVal);

        // convert lower to upper character.
        if(testVal > kDemoMax)
        {
            testVal = (demo_power_modes_t)(testVal + 'A' - 'a');
        }

        mode = testVal - kDemoMin - 1;

        switch (testVal)
        {
            case kDemoWait:
                if (POWER_SYS_GetCurrentMode() == kPowerManagerVlpr)
                {
                    PRINTF("Can not go from VLPR to WAIT directly\n\r");
                    break;
                }
                setWakeUpSource(selectWakeUpSource(testVal),"Wait mode");

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);
                CHECK_RET_VAL(ret, mode);
                break;

            case kDemoStop:
                if (POWER_SYS_GetCurrentMode() == kPowerManagerVlpr)
                {
                    PRINTF("Can not go from VLPR to STOP directly\n\r");
                    break;
                }
                setWakeUpSource(selectWakeUpSource(testVal),"Stop mode");

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);
                CHECK_RET_VAL(ret, mode);

                // update Clock Mode
                update_clock_mode(CLOCK_RUN);
                break;

            case kDemoVlpr:
                if(kPowerManagerVlpr != POWER_SYS_GetCurrentMode())
                {
                    /*
                     If apps default CM config mode is not VLPR, but needs to enter VLPR, and real CM config
                     is not VLPR, then we need to update it to VLPR mode here. Otherwise pass through.
                     */

                    update_clock_mode(CLOCK_VLPR);
                    PRINTF("Entering Very Low Power Run mode\n\r");

                    ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);

                    CHECK_RET_VAL(ret, mode);
                }
                else
                {
                    PRINTF("Very Low Power Run mode already active\n\r");
                }
                break;

            case kDemoVlpw:
                if (POWER_SYS_GetCurrentMode() == kPowerManagerRun)
                {
                    PRINTF("Can not go from RUN to VLPW directly\n\r");
                    break;
                }

                setWakeUpSource(selectWakeUpSource(testVal),"Very Low Wait mode");

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);

                if (POWER_SYS_GetCurrentMode() == kPowerManagerRun)
                {
                    // update Clock Mode to Run
                    update_clock_mode(CLOCK_RUN);
                }

                CHECK_RET_VAL(ret, mode);
                break;

            case kDemoVlps:
                setWakeUpSource(selectWakeUpSource(testVal),"Very Low Power Stop mode");

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);

                if (POWER_SYS_GetCurrentMode() == kPowerManagerRun)
                {
                    // update Clock Mode to Run
                    update_clock_mode(CLOCK_RUN);
                }

                CHECK_RET_VAL(ret, mode);
                break;
            case kDemoLls:
                setWakeUpSource(selectWakeUpSource(testVal),"Low Leakage Stop mode");
                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);

                // Check the mode LLS was entered
                if(kPowerManagerVlpr != POWER_SYS_GetCurrentMode())
                {
                    update_clock_mode(CLOCK_RUN);
                }

                CHECK_RET_VAL(ret, mode);
                break;
            case kDemoVlls1:
                setWakeUpSource(selectWakeUpSource(testVal),"Very Low Leakage Stop 1 mode");
                PRINTF("Wake up goes through Reset sequence.\n\r");

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);
                CHECK_RET_VAL(ret, mode);

                break;

            case kDemoVlls2:
                setWakeUpSource(selectWakeUpSource(testVal),"Very Low Leakage Stop 2 mode");
                PRINTF("Wake up goes through Reset sequence.\n\r");

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);
                CHECK_RET_VAL(ret, mode);

                break;
            case kDemoVlls3:
                setWakeUpSource(selectWakeUpSource(testVal),"Very Low Leakage Stop 3 mode");
                PRINTF("Wake up goes through Reset sequence.\n\r");

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);
                CHECK_RET_VAL(ret, mode);

                break;

            case kDemoRun:

                ret = POWER_SYS_SetMode(mode, kPowerManagerPolicyAgreement);
                if (ret != kPowerManagerSuccess)
                {
                    PRINTF("POWER_SYS_SetMode(%u) returned unexpected status : %u\n\r",mode,ret);
                }
                else
                {
                    update_clock_mode(CLOCK_RUN);
                }
                break;
            case KDemoADC:
                adc16PrintTemperature();
            break;

            default:
                break;
        }
        PRINTF("\n\rNext loop\n\r\n\r");
    }
}
コード例 #20
0
ファイル: sysinit.c プロジェクト: go2ev-devteam/GPCV
static UINT32
sysInit(
	void
)
{
	/* board dependent modules */
	rtcInit();
	wdtInit();

	inputInit();

	audioInit();
	fmInit();
	lineBufferInit();
	graphicInit();
	scalarInit();
	if (strcmp(SYSCONFIG_PRODUCT, "gplus.microwindowsUI__gplus.evm32900b") != 0) {
		aesInit();
	}
	sdmaInit();
#ifdef SYSCONFIG_ARCH_SPMP8050
	rotatorInit();
#endif
#ifdef SYSCONFIG_ARCH_SPMP8050
	cevaInit();
#endif
	if( gp_ver.major == MACH_GPL32900 )
	{
		cevaInit();
	}
	
	storageInit();

	if (strcmp(SYSCONFIG_MAINSTORAGE, "gp_usb_disk")) {
		usbInit();
	}

	usbWifiInit();
    touchpanelInit();
#ifdef SYSCONFIG_SDIO
	system("modprobe cfg80211");
	system("modprobe mac80211");
	system("modprobe sunrpc");
#endif
	sensorInit();
	ppuInit();
	//tvInit();

	powerInit();
	batteryInit();
	gsensorInit();
	asensorInit();
#ifdef SYSCONFIG_GP_FAST_BOOT
	gpFastBootInit();
#endif /* SYSCONFIG_GP_FAST_BOOT */
	if( gp_ver.major == MACH_GPL32900B )
	{
		On2Init();
		LBPInit();
	}

	return SP_OK;
}
コード例 #21
0
/* called by the C++ code for initialization */
extern "C" void device_init (int8* cfg)
{
  /* initialize ray tracing core */
  rtcInit(cfg);

  /* create scene */
  g_scene = rtcNewScene(RTC_SCENE_DYNAMIC,RTC_INTERSECT1);

  /* create scene with 4 analytical spheres */
  g_scene0 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  Sphere* spheres = createAnalyticalSpheres(g_scene0,4);
  spheres[0].p = Vec3f( 0, 0,+1); spheres[0].r = 0.5f;
  spheres[1].p = Vec3f(+1, 0, 0); spheres[1].r = 0.5f;
  spheres[2].p = Vec3f( 0, 0,-1); spheres[2].r = 0.5f;
  spheres[3].p = Vec3f(-1, 0, 0); spheres[3].r = 0.5f;
  rtcCommit(g_scene0);

  /* create scene with 4 triangulated spheres */
  g_scene1 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  createTriangulatedSphere(g_scene1,Vec3f( 0, 0,+1),0.5);
  createTriangulatedSphere(g_scene1,Vec3f(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene1,Vec3f( 0, 0,-1),0.5);
  createTriangulatedSphere(g_scene1,Vec3f(-1, 0, 0),0.5);
  rtcCommit(g_scene1);

  /* create scene with 2 triangulated and 2 analytical spheres */
  g_scene2 = rtcNewScene(RTC_SCENE_STATIC,RTC_INTERSECT1);
  createTriangulatedSphere(g_scene2,Vec3f( 0, 0,+1),0.5);
  createAnalyticalSphere  (g_scene2,Vec3f(+1, 0, 0),0.5);
  createTriangulatedSphere(g_scene2,Vec3f( 0, 0,-1),0.5);
  createAnalyticalSphere  (g_scene2,Vec3f(-1, 0, 0),0.5);
  rtcCommit(g_scene2);

  /* instantiate geometry */
  createGroundPlane(g_scene);
  g_instance0 = createInstance(g_scene,g_scene0,0,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));
  g_instance1 = createInstance(g_scene,g_scene1,1,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));
  g_instance2 = createInstance(g_scene,g_scene2,2,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));
  g_instance3 = createInstance(g_scene,g_scene2,3,Vec3f(-2,-2,-2),Vec3f(+2,+2,+2));

  /* set all colors */
  colors[0][0] = Vec3f(0.25,0,0);
  colors[0][1] = Vec3f(0.50,0,0);
  colors[0][2] = Vec3f(0.75,0,0);
  colors[0][3] = Vec3f(1.00,0,0);

  colors[1][0] = Vec3f(0,0.25,0);
  colors[1][1] = Vec3f(0,0.50,0);
  colors[1][2] = Vec3f(0,0.75,0);
  colors[1][3] = Vec3f(0,1.00,0);

  colors[2][0] = Vec3f(0,0,0.25);
  colors[2][1] = Vec3f(0,0,0.50);
  colors[2][2] = Vec3f(0,0,0.75);
  colors[2][3] = Vec3f(0,0,1.00);

  colors[3][0] = Vec3f(0.25,0.25,0);
  colors[3][1] = Vec3f(0.50,0.50,0);
  colors[3][2] = Vec3f(0.75,0.75,0);
  colors[3][3] = Vec3f(1.00,1.00,0);

  colors[4][0] = Vec3f(1.0,1.0,1.0);
  colors[4][1] = Vec3f(1.0,1.0,1.0);
  colors[4][2] = Vec3f(1.0,1.0,1.0);
  colors[4][3] = Vec3f(1.0,1.0,1.0);

  /* set start render mode */
  renderPixel = renderPixelStandard;
}
コード例 #22
0
ファイル: hal_hal.c プロジェクト: AlexShiLucky/ChibiOS
/**
 * @brief   HAL initialization.
 * @details This function invokes the low level initialization code then
 *          initializes all the drivers enabled in the HAL. Finally the
 *          board-specific initialization is performed by invoking
 *          @p boardInit() (usually defined in @p board.c).
 *
 * @init
 */
void halInit(void) {

  /* Initializes the OS Abstraction Layer.*/
  osalInit();

  /* Platform low level initializations.*/
  hal_lld_init();

#if (HAL_USE_PAL == TRUE) || defined(__DOXYGEN__)
  palInit(&pal_default_config);
#endif
#if (HAL_USE_ADC == TRUE) || defined(__DOXYGEN__)
  adcInit();
#endif
#if (HAL_USE_CAN == TRUE) || defined(__DOXYGEN__)
  canInit();
#endif
#if (HAL_USE_DAC == TRUE) || defined(__DOXYGEN__)
  dacInit();
#endif
#if (HAL_USE_EXT == TRUE) || defined(__DOXYGEN__)
  extInit();
#endif
#if (HAL_USE_GPT == TRUE) || defined(__DOXYGEN__)
  gptInit();
#endif
#if (HAL_USE_I2C == TRUE) || defined(__DOXYGEN__)
  i2cInit();
#endif
#if (HAL_USE_I2S == TRUE) || defined(__DOXYGEN__)
  i2sInit();
#endif
#if (HAL_USE_ICU == TRUE) || defined(__DOXYGEN__)
  icuInit();
#endif
#if (HAL_USE_MAC == TRUE) || defined(__DOXYGEN__)
  macInit();
#endif
#if (HAL_USE_PWM == TRUE) || defined(__DOXYGEN__)
  pwmInit();
#endif
#if (HAL_USE_SERIAL == TRUE) || defined(__DOXYGEN__)
  sdInit();
#endif
#if (HAL_USE_SDC == TRUE) || defined(__DOXYGEN__)
  sdcInit();
#endif
#if (HAL_USE_SPI == TRUE) || defined(__DOXYGEN__)
  spiInit();
#endif
#if (HAL_USE_UART == TRUE) || defined(__DOXYGEN__)
  uartInit();
#endif
#if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
  usbInit();
#endif
#if (HAL_USE_MMC_SPI == TRUE) || defined(__DOXYGEN__)
  mmcInit();
#endif
#if (HAL_USE_SERIAL_USB == TRUE) || defined(__DOXYGEN__)
  sduInit();
#endif
#if (HAL_USE_RTC == TRUE) || defined(__DOXYGEN__)
  rtcInit();
#endif
#if (HAL_USE_WDG == TRUE) || defined(__DOXYGEN__)
  wdgInit();
#endif

  /* Community driver overlay initialization.*/
#if defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
#if (HAL_USE_COMMUNITY == TRUE) || defined(__DOXYGEN__)
  halCommunityInit();
#endif
#endif

  /* Board specific initialization.*/
  boardInit();

/*
 *  The ST driver is a special case, it is only initialized if the OSAL is
 *  configured to require it.
 */
#if OSAL_ST_MODE != OSAL_ST_MODE_NONE
  stInit();
#endif
}
コード例 #23
0
ファイル: mcp3301.c プロジェクト: wangdongqqqq/123
void mcp3301Task(void *p_arg){
     
     uint16_t v;
     uint16_t temp;
     uint32_t i;
     uint16_t j;
     char ch;
   
     (void)p_arg;
     
     rtcInit();
               
//    mcp3301Init(64,0x43,0x50,0);     /// wrong use, spiInit should be called only once!!!
    m25p40Init(32,0x43,0x50,0);
      
    AD1_Init();
    dinInit();
    doutInit();
//    wfx40Init();   //rs485 水位计
    YSIInit();
//    RS485Init();
    
             
//   TUFInit();
   
    at24Init();          //参数初始化
    configParaInit();
   
    
    getDin16(&wdin);/// get Din;

    rtc_pause_count = 0;
    mcu_time_count = 0;    
      //m25p40Init(32,0x43,0x90,0);
//    m25p40Init(64,0x43,0x90,0);
    
/////////////////////////////   fix it!//////////////////////////////////////////////////    

/*********************************** 
    m25p40EraseCmd(0);
    m25p40EraseCmd(SECTOR_BYTES);
    m25p40EraseCmd(SECTOR_BYTES*2);
    m25p40EraseCmd(SECTOR_BYTES*3);
    m25p40EraseCmd(SECTOR_BYTES*4);
    m25p40EraseCmd(SECTOR_BYTES*5);
    m25p40EraseCmd(SECTOR_BYTES*6);
    m25p40EraseCmd(SECTOR_BYTES*7);*******************/ 
   
    
    OSTimeDly(500);         // waiting for GPRS ready
    
    pcf8563Init();   //RTC
    trigger_minutes = 0;        //启动后发送数据
    //////此处增加参数初始化//
    fixed_sendtime1 = 0xffff;  //需要改为从at24中读取
    fixed_sent = 0;   
    

    m25p40ParaInit();
    
    m25_add = m25sector.start_addr; 
     
    pcf8563GetTime();
    m25p40Write(m25_add,"reset:",6);
    m25_add+=6;
    m25p40Write(m25_add,(uint8_t *)&pcfTime,6); 
    m25_add+=6; 
    pre_minutes =  BCD2char(pcfTime.hour)*60 + BCD2char(pcfTime.min);
    
    stop_check_minutes = pre_minutes;
    ////////循环开始    ////////////////////////////////////////////
    req_sample = 0;
    rtc_pause_count = 0;
    mcu_time_count = 0;
    raingaugebak = raingauge;
    
    
    OSTimeDly(3500);         // waiting for GPRS ready
    

    while(1){
    
      
     
      pcf8563GetTime();
      
      current_minutes =  BCD2char(pcfTime.hour)*60 + BCD2char(pcfTime.min);
/*      if(current_minutes - pre_minutes >= para_send_gap_min){
            req_sample = 1;
            req_send = 1;
            pre_minutes = current_minutes;
            
      }  */
       //需要修改,防止一分钟内重复进入
         
      if((TRUE == triggerTime(current_minutes))&&(current_minutes != pre_minutes)){
           req_sample = 1;
            req_send = 1;
            pre_minutes = current_minutes;  
      }
      
      if(fixed_sendtime1 == current_minutes){
          if(0 == fixed_sent){
              req_send = 1; 
              fixed_sent = 1;   
          }
      }
      if(current_minutes > fixed_sendtime1 ){
            fixed_sent = 0;      //恢复
      }
      if((TRUE == triggerSample(current_minutes))&&(current_minutes != pre_minutes)){
           req_sample = 1;
           pre_minutes = current_minutes;  
      }
      
    //判断PCF8536是否正常
    
     if(rtc_pause_count > 15){      //大于一分钟却没有变化
        if(stop_check_minutes == current_minutes){
            
            if(mcu_time_count > 60*para_send_gap_min){
                req_sample = 1;
                req_send = 1;
                
                mcu_time_count = 0;
            }
        }else{
            stop_check_minutes = current_minutes; 
            rtc_pause_count = 0; 
            mcu_time_count = 0; 
        }
      } 
    rtc_pause_count++;    //每个循环6秒钟
     mcu_time_count++;
    
    
  //翻斗式雨量计
          /**** 雨量采集 ****/   /** 实时采集,有降雨就发送 **/
        if(raingaugebak != raingauge){
            if(raingauge - raingaugebak>= RAIN_TRIGGER){
                req_sample = 1;
                req_send = 1;
            }
            raingaugebak = raingauge;
             ch = '#';
            sc16puts(&ch,1); 
            configParaSet(PARA_RAIN,&raingauge,2);   //只在雨量有变化才存贮
            if(0 ==(raingauge%para_rain_cont)){
                
                req_sample = 1;
                req_send = 1;
            }
        }
    
    
    
     if(reUDPsend){    //需要重发
        ch = '$';
        sc16puts(&ch,1); 
         req_sample = 1;
         req_send = 1;
        reUDPsend = 0;
      }
//    req_sample = 1;
    if(req_sample){
        
        
        
        //数字量采集
        getDin16(&wdin);/// get Din;
        ///模拟量采集
        for(i=0;i<9;i++){
            adAverage[i] = 0;
      
        }
        for(i=0;i<3;i++){
      
            AD1_Measure(1);
            AD1_GetValue16(adValues);
            for(j=0;j<9;j++){
                adAverage[j] += (adValues[j]>>4);
            }
        }
        for(j=0;j<9;j++){
            adAverage[j] /= 3;
        }   
      
        for(j=0;j<4;j++){
            ch = adAverage[8]>>((3-j)*4)&0x0f;
            ch += '0';
            sc16puts(&ch,1);
        }
        sc16puts(" ",1);
        //485采集
        /*
        */
#if  WFX_485        
        setDout(0);         //打开电源
        OSTimeDly(200);
        wfx40Write();       //

        OSTimeDly(100);
        if(TRUE == wfx40Data(&waterlevel)){
            sc16puts(&waterlevel,2);    
       
        }
        /*判断界限**/
        if(waterlevel > para_water_high){
                req_send = 1;   
        }
        OSTimeDly(100);
        clrDout(0);         //关闭电源
#endif
        YSIWeekup();
       OSTimeDly(50);
       YSITwipeb();
       OSTimeDly(50);
  
       
       YSIWrite();
       OSTimeDly(10);
       YSIClr();
       
       OSTimeDly(700);
       YSIRead(); 
        OSTimeDly(50);
       YSISleep();           
        
        
 /*

TUFRead();
TUFWrite();
  OSTimeDly(3);
//   TUFCSRxd();

TUFRead();
*/
        
        protocolConstruct();
      
        m25p40Write(m25_add,(uint8_t *)&rtufile,rtufile.len*2+4);
        m25_add+= rtufile.len*2+4;
        
        
        ///以下代码根据阀值判断是否需要发送
        /*
        if((waterlevel > high) ||(waterlevel < low)){
            req_send = 1;
        } 
        
        */
        
      
        if(1 == req_send ){
            if(0 == gprsIPdone){
                rebootflag = 1;   //重新配置gprs标志
                    task_active[TASKACTIVE_SAMPLE]++;
                gprsPrepare();  
                    task_active[TASKACTIVE_SAMPLE]++;              
                rebootflag = 0;
            }
                 
            if((1 ==gprsIPdone) && (0== gprsLock)) { 
            pro_in.no_received++;     //先增加,避免在3秒时间内收到数据而统计错误
                gprsSendData((uint8_t *)&rtufile,rtufile.len*2+2+2);    // head + crc
                for(j=0;j<3;j++){
                    if(1 == gprsStnDone[j]){
                        OSTimeDly(500);
                      gprsData(j+2,(uint8_t *)&rtufile,rtufile.len*2+2+2 + 5);    // head + crc  
                      
                    }
                }
//               pro_in.no_received++;
                    noUDPrec = rtc_pause_count;     //记录发送时间,六秒为单位
                    
                      
            }
            /*else  if((1 == SMSdone)&&(0== gprsLock)){
                msgProtocolSend("13910996917",&rtufile);
            
                myReset();     
            } */
            req_send = 0;
             OSTimeDly(300);
            msgGetList();      //短信列表
             OSTimeDly(300);
         
            gprsShutdown();
            clrDout(1);
            gprsIPdone =0;
            
        }else{              //增加心跳包
                            
        }
      
        for(j=0;j<4;j++){
            ch = rtufile.time[2]>>((3-j)*4)&0x0f;
            ch += '0';
            sc16puts(&ch,1);
        }
        sc16puts(" ",1);
        req_sample = 0; 
         
         
        
         
       
       
    }
    if(0 == task_active[TASKACTIVE_SAMPLE]&0x0f){
        
        msgGetList();      //短信列表
    }
    
    if(udp_download){          //召测
            i = timegap_end-timegap_start ;
            time_add = timegap_start;
            frame_buffer[0] = 'Z';
            frame_buffer[1] = 'C';
            j = 0;
            while(i){
                if(i>80){
                    for(temp=0;temp<80;temp++){
                        m25p40RD(time_add,&frame_buffer[temp+2],1);
                        time_add++;
                                
                    }
                    frame_buffer[82]= j>>8;
                    frame_buffer[83]= j&0xff;
                    gprsSendData(frame_buffer,84);
                    i-=80;
                }else{
                    for(temp=0;temp<i;temp++){
                        m25p40RD(time_add,&frame_buffer[temp+2],1);        
                        time_add++;
                    }
                    frame_buffer[temp+2]= 0xE5;
                    frame_buffer[temp+3]= 0xE5;    //最后一帧
                    gprsSendData(frame_buffer,i+4);  
                    i=0;
                }
                j++;
                task_active[TASKACTIVE_SAMPLE]++;
            }
       
          udp_download = 0;
        
    }
          
    OSTimeDly(300);
    task_active[TASKACTIVE_SAMPLE]++;
    OSTimeDly(300);
    }