Пример #1
0
//------------------------------------------------------------------------------
int main(void)
{
	SystemCoreClockUpdate();

	port_init();
#ifdef USE_SERIAL
	usart_init();
#endif
	tim_init();
  rtc_init();
#ifdef USE_LCD
	lcd_init();
#endif
	ds1820_init(PIN_TEMP1);

	if (SysTick_Config(SystemCoreClock / 1000)) { 
		/* Capture error */ 
		while (1);
	}

	 xQueueCreate(5, sizeof(char));
	
   xTaskCreate( TaskComm,  "cmm", configMINIMAL_STACK_SIZE, NULL,
        tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
   xTaskCreate( TaskMeasure,"meas", configMINIMAL_STACK_SIZE, NULL, 
        tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );

   vTaskStartScheduler();
		
	nexa_send(NEXA_CH_1, NEXA_UNIT_1, NEXA_ON);

	for (;;);
/*
	set_LED1;
#ifdef USE_LCD			
				lcd_clear();
				out_time(lcd_write, &timeRtc);
				lcd_write(' ');
				out_byte(lcd_write, (temp >> 1));
				lcd_write('.');
				if (temp & 1)
					lcd_write('5');
				else
					lcd_write('0');
#endif				
				clr_LED1;
*/
}
Пример #2
0
////////////////////////////////////////////////////////////////////////////
// Interfacing Function
////////////////////////////////////////////////////////////////////////////
void vTaskDS1820Convert( void *pvParameters ){
    char buf[30];
    static char print_buf[80];
    int ii = 0;
    static float fTemp[NUM_SENSORS] = {0.0, 0.0}, fLastTemp[NUM_SENSORS] = {0.0, 0.0};

    // initialise the bus
    ds1820_init();
    if (ds1820_reset() ==PRESENCE_ERROR)
    {
        ds1820_error(PRESENCE_ERROR);
        vConsolePrint("Presence Error, Deleting DS1820 Task\r\n\0");
        vTaskDelete(NULL); // if this task fails... delete it
    }
  
    // Allocate memory for sensors
    b[HLT] = (char *) pvPortMalloc (sizeof(rom)+1);
    b[MASH] = (char *) pvPortMalloc (sizeof(rom)+1);
   // b[CABINET] = (char *) malloc (sizeof(rom)+1);



    // Copy default values
    memcpy(b[HLT], HLT_TEMP_SENSOR, sizeof(HLT_TEMP_SENSOR)+1);
    memcpy(b[MASH], MASH_TEMP_SENSOR, sizeof(MASH_TEMP_SENSOR)+1);
   // memcpy(b[CABINET], CABINET_TEMP_SENSOR, sizeof(CABINET_TEMP_SENSOR)+1);

    ds1820_search();

    //if (rom[0] == 0x10)
      if (rom[0] != 0)
      {
        sprintf(print_buf, "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\r\n\0",rom[0],
            rom[1], rom[2], rom[3], rom[4], rom[5], rom[6], rom[7]);
        vConsolePrint(print_buf);
      }
    else
      {
        vConsolePrint("NO SENSOR\r\n\0");
      }

    for (;;)
    {
        ds1820_convert();
        vTaskDelay(850/portTICK_RATE_MS); // wait for conversion

        // save values in array for use by application
        for (ii = 0 ; ii < NUM_SENSORS; ii++)
        {
            fTemp[ii] = ds1820_read_device(b[ii]);
            if (fTemp[ii] < 105.0 && fTemp[ii] > 0.0)
              {
                if ((fTemp[ii] < (temps[ii] + 5.0)) || (fTemp[ii] > (temps[ii] - 5.0)) || (fTemp[ii] <= 85.0 && fTemp[ii] >= 86.0))
                  {
                    portENTER_CRITICAL(); // so that other task cannot access temps[] while we are saving.
                    temps[ii] = fTemp [ii];
                    portEXIT_CRITICAL();
                  }

              }
            if (fTemp[ii] == 0.0)
              {
                vConsolePrint("zero values. Temp Bus Resetting\r\n\0");
                ds1820_power_reset();
                ds1820_reset();
              }
        }
        taskYIELD();
    }
    
}