mirror of
https://github.com/apache/nuttx.git
synced 2026-02-06 04:22:26 +08:00
drivers/1wire/1wire_ds2xxx.h: add the driver for DS2XXX eeproms.
Supports these Maxim/Analog Devices eeproms with a scratchpad: DS2430,2431,2432,2433,28E04,28E07,28EC20. For each type of an eeprom, you create a new driver. Other than that, the driver is file oriented and supports seeks, for example. Signed-off-by: Stepan Pressl <pressl.stepan@gmail.com>
This commit is contained in:
committed by
Alin Jerpelea
parent
d1e1643b84
commit
84b0492fbd
829
drivers/1wire/1wire_ds2xxx.c
Normal file
829
drivers/1wire/1wire_ds2xxx.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -27,5 +27,10 @@ if(CONFIG_1WIRE)
|
||||
list(APPEND SRCS ds28e17.c)
|
||||
endif()
|
||||
|
||||
# Include the 1WIRE driver for DS2XXX EEPROMs
|
||||
if(CONFIG_1WIRE_EE_DS2XXX)
|
||||
list(APPEND SRCS 1wire_ds2xxx.c)
|
||||
endif()
|
||||
|
||||
target_sources(drivers PRIVATE ${SRCS})
|
||||
endif()
|
||||
|
||||
@@ -18,4 +18,27 @@ config 1WIRE_DS28E17
|
||||
---help---
|
||||
Enable support for the Maxim DS28E17 1-wire to I2C converter
|
||||
|
||||
config 1WIRE_EE_DS2XXX
|
||||
bool "Support for Maxim/Analog Devices 1wire DS2XXX EEPROM devices"
|
||||
default n
|
||||
depends on 1WIRE
|
||||
---help---
|
||||
Enable support for 1WIRE DS2XXX EEPROMs.
|
||||
The list of supported devices:
|
||||
DS2430: 32 bytes, 1 page
|
||||
DS2431: 128 bytes, 4 pages
|
||||
DS2432: 128 bytes, 4 pages
|
||||
DS2433: 512 bytes, 16 pages
|
||||
DS28E04: 512 bytes, 16 pages
|
||||
DS28E07: 128 bytes, 4 pages
|
||||
DS28EC20: 2560 bytes, 32 pages
|
||||
|
||||
if 1WIRE_EE_DS2XXX
|
||||
|
||||
config 1WIRE_EE_DS2XXX_MEMSONBUS
|
||||
int "Maximum number of DS2XXX eeproms on the same bus"
|
||||
default 10
|
||||
|
||||
endif # 1WIRE_EE_DS2XXX
|
||||
|
||||
endif # 1WIRE
|
||||
|
||||
@@ -28,6 +28,10 @@ ifeq ($(CONFIG_1WIRE_DS28E17),y)
|
||||
CSRCS += ds28e17.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_1WIRE_EE_DS2XXX),y)
|
||||
CSRCS += 1wire_ds2xxx.c
|
||||
endif
|
||||
|
||||
# Include 1wire device driver build support
|
||||
|
||||
DEPPATH += --dep-path 1wire
|
||||
|
||||
88
include/nuttx/1wire/1wire_ds2xxx.h
Normal file
88
include/nuttx/1wire/1wire_ds2xxx.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/1wire/1wire_ds2xxx.h
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Author: Stepan Pressl <pressl.stepan@gmail.com>
|
||||
* <pressste@fel.cvut.cz>
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_EEPROM_1WIRE_DS2XXX_H
|
||||
#define __INCLUDE_NUTTX_EEPROM_1WIRE_DS2XXX_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
#include <nuttx/1wire/1wire.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* All device specific commands for the scratchpad are luckily the same
|
||||
* for all the devices.
|
||||
*/
|
||||
|
||||
#define DS2XXX_WRITE_SCRATCHPAD 0x0f
|
||||
#define DS2XXX_READ_SCRATCHPAD 0xaa
|
||||
#define DS2XXX_COPY_SCRATCHPAD 0x55
|
||||
#define DS2XXX_READ_MEMORY 0xf0
|
||||
|
||||
/* There are other commands, also. For example, the common commands
|
||||
* have a different code than specified in drivers/1wire/1wire.c.
|
||||
*/
|
||||
|
||||
#define DS2XXX_MATCH_ROM 0x55
|
||||
|
||||
/* DS28E05 has a different architecture,
|
||||
* as it does not use a scratchpad. Let's keep this device out of here.
|
||||
*/
|
||||
|
||||
enum ds2xxx_eeproms_e
|
||||
{
|
||||
EEPROM_DS2430 = 0,
|
||||
EEPROM_DS2431,
|
||||
EEPROM_DS2432,
|
||||
EEPROM_DS2433,
|
||||
EEPROM_DS28E04,
|
||||
EEPROM_DS28E07,
|
||||
EEPROM_DS28EC20,
|
||||
EEPROM_DS_COUNT
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ds2xxx_initialize
|
||||
*
|
||||
* Description: Bind a onewire_master_s struct to this driver,
|
||||
* capable of interfacing DS2XXX 1Wire EEPROMs. The user must specify
|
||||
* the device type and also the name of the device (e.g. /dev/ds2xxx).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ds2xxx_initialize(FAR struct onewire_dev_s *dev,
|
||||
enum ds2xxx_eeproms_e devtype, FAR char *devname);
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_EEPROM_1WIRE_DS2XXX_H */
|
||||
Reference in New Issue
Block a user