def __init__(self, sensor, timer): StreamConfig.__init__(self, sensor) self.define_request_message(fmt=">BBBBBh", hdr="ch!stat!P_msb!P_lsb!P_xl!T_raw", reg=r.BM1383AGLV_STATUS_REG, timer=timer)
def __init__(self, sensors, pin_index=None, timer=None): "DRDY and timer data stream" assert sensors[0].name in KX134Driver.supported_parts StreamConfig.__init__(self, sensors[0]) sensors[0].resource[CFG_AXIS_MAP] = [0, 1, 2, 3, 4, 5, 6] sensor = sensors[0] # get pin_index if it is not given and timer is not used if pin_index is None: pin_index = get_drdy_pin_index() if timer is None: timer = get_drdy_timer() proto = self.adapter.protocol message = RequestMessageDefinition(sensor, fmt=self.fmt, hdr=self.hdr, pin_index=pin_index, timer=timer) if pin_index is not None: req = proto.create_macro_req( trigger_type=proto.EVKIT_MACRO_TYPE_INTR, gpio_pin=message.gpio_pin, gpio_sense=self.sense_dict[sensor.resource[CFG_POLARITY]], gpio_pullup=self.pullup_dict[sensor.resource[CFG_PULLUP]]) elif timer is not None: time_unit, time_val = proto.seconds_to_proto_time(message.timer) req = proto.create_macro_req( trigger_type=proto.EVKIT_MACRO_TYPE_POLL, timer_scale=time_unit, timer_value=time_val) self.adapter.send_message(req) _, macro_id = self.adapter.receive_message( proto.EVKIT_MSG_CREATE_MACRO_RESP) self.macro_id_list.append(macro_id) self.msg_ind_dict[macro_id] = message message.msg_req.append(req) # read three separate register areas reg_read_cfgs = [(r.KX134_1211_XOUT_L, 6, False), (self.reg, 6, False), (r.KX134_1211_STATUS_REG, 1, False), (r.KX134_1211_INT_REL, 1, True)] for addr_start, read_size, discard in reg_read_cfgs: if self.sensor.resource.get(CFG_SPI_PROTOCOL, 0) == 1: # With Kionix components, MSB must be set 1 to indicate reading addr_start = addr_start | 1 << 7 req = proto.add_macro_action_req( macro_id, action=proto.EVKIT_MACRO_ACTION_READ, target=self.sensor.resource[CFG_TARGET], identifier=self.sensor.get_identifier(), discard=discard, start_register=addr_start, bytes_to_read=read_size) self.adapter.send_message(req) self.adapter.receive_message(proto.EVKIT_MSG_ADD_MACRO_ACTION_RESP) message.msg_req.append(req)
def __init__(self, sensor, pin_index=None): StreamConfig.__init__(self, sensor) if pin_index is None: pin_index = get_pin_index() self.define_request_message(fmt="<Bhhhhhhh", hdr="ch!ax!ay!az!mx!my!mz!temp", reg=r.KMX62_ACCEL_XOUT_L, pin_index=pin_index)
def __init__(self, sensor, pin_index=None): StreamConfig.__init__(self, sensor) if pin_index is None: pin_index = get_pin_index() self.define_request_message(fmt="<Bhhh", hdr="ch!ax!ay!az", reg=r.KX224_XOUT_L, pin_index=pin_index)
def __init__(self, sensor, pin_index=None): StreamConfig.__init__(self, sensor) if pin_index is None: pin_index = get_pin_index() self.define_request_message(fmt="<Bhhh", hdr="ch!mx!my!mz", reg=r.BM1422GMV_DATAX, pin_index=pin_index)
def __init__(self, sensor, pin_index=None): StreamConfig.__init__(self, sensor) if pin_index is None: pin_index = get_pin_index() self.define_request_message(fmt=">BBBBBh", hdr="ch!stat!P_msb!P_lsb!P_xl!T_raw", reg=r.BM1383AGLV_STATUS_REG, pin_index=pin_index)
def __init__(self, sensor, pin_index=None, timer=0.1): StreamConfig.__init__(self, sensor) if pin_index is None: pin_index = get_pin_index() # Default way to define request message self.define_request_message(fmt="<Bhhh", hdr="ch!ax!ay!az", reg=r.KX022_XOUT_L, timer=timer)
def __init__(self, sensors, pin_index=1, timer=None): assert sensors[0].name in KXTJ3Driver.supported_parts StreamConfig.__init__(self, sensors[0]) if pin_index is None: pin_index = get_other_pin_index() if timer is None: timer = get_other_timer() self.define_request_message(fmt=self.fmt, hdr=self.hdr, reg=self.reg, pin_index=pin_index, timer=timer)
def __init__(self, sensors, pin_index=None, timer=None): "DRDY and timer data stream" assert sensors[0].name in KX134Driver.supported_parts StreamConfig.__init__(self, sensors[0]) # get pin_index if it is not given and timer is not used if pin_index is None: pin_index = get_drdy_pin_index() if timer is None: timer = get_drdy_timer() self.define_request_message(fmt=self.fmt, hdr=self.hdr, reg=self.reg, pin_index=pin_index, timer=timer)
def __init__(self, sensors, pin_index=None, timer=None): "DRDY and timer data stream" assert sensors[0].name in KX134Driver.supported_parts StreamConfig.__init__(self, sensors[0]) # get pin_index if it is not given and timer is not used if pin_index is None: pin_index = get_drdy_pin_index() protocol = self.adapter.protocol message = RequestMessageDefinition(self.sensor, fmt=self.fmt, hdr=self.hdr, reg=self.reg, pin_index=pin_index) # Create macro handler for interrupt req = protocol.create_macro_req( trigger_type=protocol.EVKIT_MACRO_TYPE_INTR, gpio_pin=message.gpio_pin, gpio_sense=self.sense_dict[sensors[0].resource[CFG_POLARITY]], gpio_pullup=self.pullup_dict[sensors[0].resource[CFG_PULLUP]] ) self.adapter.send_message(req) _, macro_id = self.adapter.receive_message( wait_for_message=protocol.EVKIT_MSG_CREATE_MACRO_RESP) self.macro_id_list.append(macro_id) self.msg_ind_dict[macro_id] = message message.msg_req.append(req) LOGGER.debug('Macro created with id %d', macro_id) SPI_MODE = 0 if CFG_SAD in self.sensor.resource else 128 req = protocol.add_macro_action_req( macro_id, action=protocol.EVKIT_MACRO_ACTION_READ, target=self.sensor.resource[CFG_TARGET], identifier=self.sensor.get_identifier(), start_register=message.reg | SPI_MODE, bytes_to_read=6, append=False, run_count=WATERMARK_LEVEL) self.adapter.send_message(req) self.adapter.receive_message( wait_for_message=protocol.EVKIT_MSG_ADD_MACRO_ACTION_RESP) message.msg_req.append(req) LOGGER.debug(req)
def __init__(self, sensors, pin_index=2, timer=None): StreamConfig.__init__(self, sensors[0]) assert pin_index in [1, 2], 'got %s' % pin_index assert not timer, 'Timer not supported in this data stream' sensor = sensors[0] proto = self.adapter.protocol message = RequestMessageDefinition(sensor, fmt=self.fmt, hdr=self.hdr, pin_index=pin_index, timer=timer) req = proto.create_macro_req( trigger_type=proto.EVKIT_MACRO_TYPE_INTR, gpio_pin=message.gpio_pin, gpio_sense=self.sense_dict[sensor.resource[CFG_POLARITY]], gpio_pullup=self.pullup_dict[sensor.resource[CFG_PULLUP]]) self.adapter.send_message(req) _, macro_id = self.adapter.receive_message( proto.EVKIT_MSG_CREATE_MACRO_RESP) self.macro_id_list.append(macro_id) self.msg_ind_dict[macro_id] = message message.msg_req.append(req) # read int_rel separately as it needs to be 1st byte to read when SPI in use reg_read_cfgs = [(r.KX132_1211_INS3, 2, False), (r.KX132_1211_INT_REL, 1, False)] for addr_start, read_size, discard in reg_read_cfgs: if self.sensor.resource.get(CFG_SPI_PROTOCOL, 0) == 1: # With Kionix components, MSB must be set 1 to indicate reading addr_start = addr_start | 1 << 7 req = proto.add_macro_action_req( macro_id, action=proto.EVKIT_MACRO_ACTION_READ, target=self.sensor.resource[CFG_TARGET], identifier=self.sensor.get_identifier(), discard=discard, start_register=addr_start, bytes_to_read=read_size) self.adapter.send_message(req) self.adapter.receive_message(proto.EVKIT_MSG_ADD_MACRO_ACTION_RESP) message.msg_req.append(req)
def __init__(self, sensors, pin_index=None, timer=None): "DRDY and timer data stream" assert sensors[0].name in KXTJ3Driver.supported_parts StreamConfig.__init__(self, sensors[0]) # get pin_index if it is not given and timer is not used if pin_index is None: pin_index = get_drdy_pin_index() if timer is None: timer = get_drdy_timer() 'Sensor can only be connected to adapter logical int pin 1' assert pin_index in [None, 1] self.define_request_message(fmt=self.fmt, hdr=self.hdr, reg=self.reg, pin_index=pin_index, timer=timer)
def __init__(self, sensor, pin_index=None): StreamConfig.__init__(self, sensor) if pin_index is None: pin_index = get_pin_index() if 1: # pylint disable=using-constant-test # Default way to define request message self.define_request_message(fmt="<Bhhh", hdr="ch!ax!ay!az", reg=r.KX022_XOUT_L, pin_index=pin_index) if 0: # pylint disable=using-constant-test # define request message with packet counter # works with FW1, not work in FW2 self.define_request_message( fmt="<Bhhh" + ExtraData.fmt_packet_count_8, hdr="ch!ax!ay!az" + ExtraData.hdr_packet_count_8, reg=[sensor.resource[CFG_SAD], r.KX022_XOUT_L, 6] + ExtraData.reg_packet_count_8, pin_index=pin_index)