# Kernel driver w1_ds2413

_Peios Kernel / Hardware and drivers / 1-Wire / slaves_

> Supported chips:

<a id="rst-kernel-driver-w1-ds2413"></a>

Supported chips:

> - Maxim DS2413 1-Wire Dual Channel Addressable Switch

supported family codes:

>
> <table>
> <tbody>
> <tr>
> <td>
>
>
> W1_FAMILY_DS2413
>
> </td>
> <td>
>
>
> 0x3A
>
> </td>
> </tr>
> </tbody>
> </table>

Author: Mariusz Bialonczyk &lt;[manio@skyboo.net](<mailto:manio@skyboo.net>)&gt;

<a id="rst-description"></a>

## Description

The DS2413 chip has two open-drain outputs (PIO A and PIO B). Support is provided through the sysfs files "output" and "state".

<a id="rst-reading-state"></a>

## Reading state

The "state" file provides one-byte value which is in the same format as for the chip PIO_ACCESS_READ command (refer the datasheet for details):


<table>
<tbody>
<tr>
<td>


Bit 0:

</td>
<td>


PIOA Pin State

</td>
</tr>
<tr>
<td>


Bit 1:

</td>
<td>


PIOA Output Latch State

</td>
</tr>
<tr>
<td>


Bit 2:

</td>
<td>


PIOB Pin State

</td>
</tr>
<tr>
<td>


Bit 3:

</td>
<td>


PIOB Output Latch State

</td>
</tr>
<tr>
<td>


Bit 4-7:

</td>
<td>


Complement of Bit 3 to Bit 0 (verified by the kernel module)

</td>
</tr>
</tbody>
</table>

This file is readonly.

<a id="rst-writing-output"></a>

## Writing output

You can set the PIO pins using the "output" file. It is writable, you can write one-byte value to this sysfs file. Similarly the byte format is the same as for the PIO_ACCESS_WRITE command:


<table>
<tbody>
<tr>
<td>


Bit 0:

</td>
<td>


PIOA

</td>
</tr>
<tr>
<td>


Bit 1:

</td>
<td>


PIOB

</td>
</tr>
<tr>
<td>


Bit 2-7:

</td>
<td>


No matter (driver will set it to "1"s)

</td>
</tr>
</tbody>
</table>

The chip has some kind of basic protection against transmission errors. When reading the state, there is a four complement bits. The driver is checking this complement, and when it is wrong then it is returning I/O error.

When writing output, the master must repeat the PIO Output Data byte in its inverted form and it is waiting for a confirmation. If the write is unsuccessful for three times, the write also returns I/O error.
