HP85 GPIB Disk Emulator
1.0
HP85GPIBDiskEmulator
|
Go to the documentation of this file.
29 return( ( (data/10U) << 4 ) | (data%10U) );
40 return ( ( ( (data&0xf0U) >> 4) * 10 ) + (data&0x0fU) );
55 int8_t
i2c_rtc_write(uint8_t address, uint8_t index, uint8_t *buf, uint8_t len)
72 if (
i2c_fn(address, TW_WRITE, reg, len+1) )
77 printf(
"i2c_rtc_write data error\n");
90 int8_t
i2c_rtc_read(uint8_t address, uint8_t index, uint8_t *buf, uint8_t len)
101 if (
i2c_fn(address, TW_WRITE, (uint8_t *) &index,
sizeof(index)) )
106 printf(
"i2c_rtc_read address error\n");
112 if ( !
i2c_fn(address, TW_READ, buf,len) )
114 printf(
"i2c_rtc_read data error\n");
145 buf[3] = ((t->
tm_wday & 7) + 1) & 0x0f;
152 printf(
"rtc_write():%d, day:%d,mon:%d,hour:%d,min:%d,sec:%d, wday:%d\n",
165 printf(
"rtc_write buf: ");
167 printf(
"%02x ", 0xff & buf[i]);
174 printf(
"rtc_write error\n");
195 printf(
"rtc_read error\n");
204 printf(
"%02x ", 0xff & buf[i]);
211 t->
tm_wday = ( buf[3] & 0x07) - 1;
217 printf(
"rtc_read():%d, day:%d,mon:%d,hour:%d,min:%d,sec:%d, wday:%d\n",
247 printf(
"rtc_run read error\n");
252 return ((reg & 0x80) ? 0 : 1);
254 reg = ( reg & 0x7f) | (run ? 0 : 0x80);
258 printf(
"rtc_run write error\n");
317 printf(
"rtc_init write epoch failed\n");
361 fat = ((uint32_t)(t->
tm_year - 80) << 25)
362 | (((uint32_t)t->
tm_mon+1) << 21)
363 | (((uint32_t)t->
tm_mday) << 16)
365 | ((uint32_t)t->
tm_min << 5)
366 | ((uint32_t)t->
tm_sec >> 1);
void i2c_rtc_init()
RTC I2C initialization code.
uint8_t BINtoBCD(uint8_t data)
RTC BCD conversion functions.
MEMSPACE int printf(const char *format,...)
void i2c_init(uint32_t speed)
I2C initialize Clear all i2c_task_op[] pointers and disables I2C tasks.
MEMSPACE tm_t * gmtime(time_t *tp)
Convert epoch GMT time_t *tp into POSIX static tm_t *t.
uint8_t rtc_write(tm_t *t)
RTC functions.
int8_t i2c_rtc_write(uint8_t address, uint8_t index, uint8_t *buf, uint8_t len)
RTC HAL.
int8_t i2c_rtc_read(uint8_t address, uint8_t index, uint8_t *buf, uint8_t len)
RTC I2C READ function.
DWORD get_fattime(void)
Read time and convert to FAT32 time.
Common Linux/POSIX time functions.
Master Include for FatFs, RTC, Timers AVR8 - Part of HP85 disk emulator.
uint8_t i2c_fn(uint8_t address, uint8_t mode, uint8_t *buf, uint8_t len)
I2C setup new OP but do not run it yet.
uint8_t BCDtoBIN(uint8_t data)
Convert two "digit" BCD number to binary.
uint8_t rtc_init(int force, time_t seconds)
Initialize DS1307 rtc if not initialied - or if forced.
int8_t rtc_run_test()
DS1307 run test.
int rtc_run(int run)
Set DS1307 run state.
uint8_t rtc_read(tm_t *t)
Read DS1307 RTC into POSIX struct tm * structure.
uint32_t time_t
type of EPOCH result.
MEMSPACE uint32_t tm_to_fat(tm_t *t)
FAT time structer reference.