Exemplo n.º 1
0
static void ds1302_writebyte(unsigned int addr, unsigned int val)
{
	ds1302_reset();

	ds1302_start();
	ds1302_sendbits(((addr & 0x3f) << 1) | RTC_CMD_WRITE);
	ds1302_sendbits(val);
	ds1302_stop();
}
Exemplo n.º 2
0
static unsigned int ds1302_readbyte(unsigned int addr)
{
	unsigned int val;

	ds1302_reset();

	ds1302_start();
	ds1302_sendbits(((addr & 0x3f) << 1) | RTC_CMD_READ);
	val = ds1302_recvbits();
	ds1302_stop();

	return val;
}
Exemplo n.º 3
0
static int8 ds18b20_ioctl(uint8 id, uint8 cmd, uint16 args)
{
	int16 *p_temp = (int16 *)args;

	if (GET_CMD_DIR(cmd) == CMD_GET)
	{
		switch (cmd)
		{
			case DS18B20_GET:
				ds1302_start();
				OSWait(K_TMO, OS_TICKS_PER_SEC); // delay 1S
				*p_temp = ds1302_read_temp();
				break;
			default: 
				break;
		}
	}
	
	UNUSED(id);
	
	return 0;
}