Esempio n. 1
0
 static {
   rst = new TPU_DIO(tpuB, RST, true);
   sckl = new TPU_DIO(tpuB, SCKL, true);
   io = new TPU_DIO(tpuB, IO, false);
   rst.set(false);
   sckl.set(false);
 }
Esempio n. 2
0
 /**
  * Write a value to the RTC.
  *
  * @param type The type (sec, min, ...) to write.
  * @param val The value to write.
  */
 private static void write(byte type, byte val) {
   int w = ((val << 8) | (0xFF & type));
   rst.set(true);
   io.dir(true);
   for (int i = 0x1; i < 0x10000; i <<= 1) {
     sckl.set(false);
     if ((w & i) != 0) {
       io.set(true);
     } else {
       io.set(false);
     }
     sckl.set(true);
   }
   sckl.set(false);
   rst.set(false);
 }
Esempio n. 3
0
 /**
  * Read a value from the RTC.
  *
  * @param type The type to read (sec, min, ...).
  * @return The read value.
  */
 private static int read(byte type) {
   type |= 0x01;
   rst.set(true);
   io.dir(true);
   for (int i = 0x1; i < 0x100; i <<= 1) {
     sckl.set(false);
     if ((type & i) != 0) io.set(true);
     else io.set(false);
     sckl.set(true);
   }
   int val = 0;
   io.dir(false);
   for (int i = 0x1; i < 0x100; i <<= 1) {
     sckl.set(true);
     sckl.set(false);
     if (io.get()) val |= i;
   }
   io.dir(false);
   rst.set(false);
   return val;
 }