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(); }
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; }
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; }