#
# ------------------------------------------------------------
# Copyright (c) All rights reserved
# SiLab, Institute of Physics, University of Bonn
# ------------------------------------------------------------
#
# SVN revision information:
#  $Rev::                       $:
#  $Author::                    $:
#  $Date::                      $:
#

from basil.HL.HardwareLayer import HardwareLayer


class fast_spi_rx(HardwareLayer):
    '''Fast SPI interface
    '''
    def __init__(self, intf, conf):
        super(fast_spi_rx, self).__init__(intf, conf)

    def init(self):
        self.reset()

    def reset(self):
        self._intf.write(self._conf['base_addr'], [0])

    def set_en(self, value=True):
        current = self._intf.read(self._conf['base_addr'] + 2, 1)[0]
        self._intf.write(self._conf['base_addr'] + 2, [(current & 0xfe) | value])

    def get_en(self):
        return True if (self._intf.read(self._conf['base_addr'] + 2, 1)[0] & 0x01) else False

    def get_lost_count(self):
        return self._intf.read(self._conf['base_addr'] + 3, 1)[0]

@@ -213,262 +213,504 @@
 -%0A#%0A
-# SVN revision information:%0A#  $Rev::          
+%0Afrom basil.HL.RegisterHardwareLayer import RegisterHardwareLayer%0A%0Aclass fast_spi_rx(RegisterHardwareLayer):%0A    '''Fast SPI interface%0A    '''%0A
     
+%0A
     
-     $:%0A#  $Author::                    $:%0A#  $Date::                      $:%0A#%0A%0Afrom basil.HL.HardwareLayer import HardwareLayer%0A%0A%0Aclass fast_spi_rx(HardwareLayer):%0A    '''Fast SPI interface%0A    '''
+_registers = %7B'RESET': %7B'descr': %7B'addr': 0, 'size': 8, 'properties': %5B'writeonly'%5D%7D%7D,%0A                  'VERSION': %7B'descr': %7B'addr': 0, 'size': 8, 'properties': %5B'ro'%5D%7D%7D,%0A                  'EN': %7B'descr': %7B'addr': 2, 'size': 1, 'offset': 0%7D%7D,%0A                  'LOST_COUNT': %7B'descr': %7B'addr': 3, 'size': 8, 'properties': %5B'ro'%5D%7D%7D,%0A    %7D%0A    
 %0A   
@@ -829,20 +829,12 @@
     
-self.reset()
+pass
 %0A%0A  
@@ -864,240 +864,118 @@
     
-self._intf.write(self._conf%5B'base_addr'%5D, %5B0%5D)%0A%0A    def set_en(self, value=True):%0A        current = self._intf.read(self._conf%5B'base_addr'%5D + 2, 1)%5B0%5D%0A        self._intf.write(self._conf%5B'base_addr'%5D + 2, %5B(current & 0xfe) %7C
+'''Soft reset the module.'''%0A        self.RESET = 0%0A%0A    def set_en(self, value=True):%0A        self.EN =
  value
-%5D)
 %0A%0A  
@@ -1021,67 +1021,15 @@
  if 
-(
 self.
-_intf.read(self._conf%5B'base_addr'%5D + 2, 1)%5B0%5D & 0x01)
+EN
  els
@@ -1091,50 +1091,15 @@
 elf.
-_intf.read(self._conf%5B'base_addr'%5D + 3, 1)%5B0%5D
+LOST_COUNT
 %0A

Use RegisterHardwareLayer