示例#1
0
文件: main.c 项目: chenws/codes
void *f_thread3(void *pvoid)
#endif
{
	int i = 10;
	unsigned long id = gettidx();
	while (i--)
	{
		debugx(xerror, "thread id(%lu): this is %s!\n", id, "xerror");
		sleep(val_time);
	}
}
示例#2
0
文件: main.c 项目: chenws/codes
int main() 
{
	int i = 10;
	unsigned long id = 0;
#if LOG_MOD==LOG_MUL_THREAD
	thread_mgmt_t tm;
	logx_init("D:/abc.txt", LOG_MUL_THREAD);
	tm_init(&tm);
	tm_create_thread(tm,"t1",f_thread1);
	tm_create_thread(tm,"t2",f_thread2);
	tm_create_thread(tm,"t3",f_thread3);
#else
	logx_init("D:/abc.txt", LOG_SIG_THREAD);
#endif
    __assert(0);

	debugx(xinfo, "this is %s!\n", "xinfo");
	debugx(xdata, "this is %s!\n", "xdata");
	debugx(xentry, "this is %s!\n", "xentry");
	debugx(xevent, "this is %s!\n", "xevent");
	debugx(xmsg, "this is %s!\n", "xmsg");
	debugx(xwarn, "this is %s!\n", "xwarn");
	debugx(xerror, "this is %s!\n", "xerror");
	debugx(xfatal, "this is %s!\n", "xfatal");
	debugx(xerror, "this is %s!\n", "xerror");

	id = gettidx();

	while (i--)
	{
		debugx(xfatal, "thread id(%d): this is %s!\n", id, "xfatal");
		sleep(val_time);
	}

#if LOG_MOD==LOG_MUL_THREAD
	tm_exit(&tm);
#endif
	logx_exit();

	return 0;
}
示例#3
0
void DS18S20::DoSearch(void)
{

	numberOf=FindAlladdresses();

	if (!numberOf)
	{
		debugx("  DBG: No DS1820 sensor found");
        InProgress=false;

	}
	else
	{
      debugx("  DBG: %d DS1820 sensors found",numberOf);

      numberOfread=0;
      StartReadNext();
	}


}
示例#4
0
void DS18S20::StartMeasure()
{
	if (!InProgress)
	{

		debugx("  DBG: DS1820 reading task start, try to read up to %d sensors",MAX_SENSORS);
		InProgress=true;
		ds.begin();
		ds.reset_search();
		DelaysTimer.initializeMs(150, TimerDelegate(&DS18S20::DoSearch, this)).start(false);
	}

}
示例#5
0
uint8_t DS18S20::FindAlladdresses()
{
	uint8_t counter=0;
	uint8_t thermoNo=0;
	uint8_t a;

	while (counter++ < MAX_SENSORS)
	{
		if (!ds.search(addr))
		{
			debugx("  DBG: No more address found");
            break;
		}
		else
		if (OneWire::crc8(addr, 7) == addr[7])
			{
			  debugx("  DBG: CRC is valid");
				switch (addr[0]) {
				case 0x10:
				  debugx("  DBG: Chip = DS18S20");  // or old DS1820
				  type_s[thermoNo] = 1;
				  break;
				case 0x28:
				  debugx("  DBG: Chip = DS18B20");
				  type_s[thermoNo] = 0;
				  break;
				case 0x22:
				  debugx("  DBG: Chip = DS1822");
				  type_s[thermoNo] = 0;
				  break;
				default:
				  debugx("  DBG: This Device is not a DS18x20 family device.");
				  break;
				}

			    // address ok, copy uwaga na default teraz zle
				for(a=0;a<8;a++)
				addresses[thermoNo]=(addresses[thermoNo]<<8) +(uint64_t)addr[a];
                thermoNo++;
			}
			else
			{
			debugx("  DBG: CRC is not valid");
			}
	}


  return thermoNo;
}
示例#6
0
int main() {

	led_on();
	usart_init();
	debugln("\nUSART initialized");

	spi_init_master();
	debugln("SPI master");

	for(int i=0; i<5; i++) {
		debugx(spi_tx(42)); debugln(" spi_tx");
	}

	for (;;){}

	return 1;
}