drivers/1wire: Moves header and adjusts include paths
Moves header to 1wire include sub directory. Moves over common crc definitions to new interface. Signed-off-by: Marco Krahl <ocram.lhark@gmail.com>
This commit is contained in:
parent
c726dac605
commit
8456f3615e
@ -56,7 +56,7 @@
|
|||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/drivers/1wire.h>
|
#include <nuttx/1wire/1wire.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/power/pm.h>
|
#include <nuttx/power/pm.h>
|
||||||
#include <nuttx/drivers/1wire.h>
|
#include <nuttx/1wire/1wire.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/i2c/i2c_master.h>
|
#include <nuttx/1wire/1wire_master.h>
|
||||||
#include <nuttx/drivers/1wire.h>
|
#include <nuttx/1wire/1wire.h>
|
||||||
|
|
||||||
#include "1wire_internal.h"
|
#include "1wire_internal.h"
|
||||||
|
|
||||||
@ -729,7 +729,7 @@ int onewire_removeslave(FAR struct onewire_master_s *master,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct onewire_master_s *
|
FAR struct onewire_master_s *
|
||||||
onewire_initialize(FAR struct onewire_dev_s *dev, int maxslaves)
|
onewire_initialize(FAR struct onewire_dev_s *dev, int maxslaves)
|
||||||
{
|
{
|
||||||
FAR struct onewire_master_s *master;
|
FAR struct onewire_master_s *master;
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <nuttx/1wire/1wire_crc.h>
|
||||||
#include "1wire_internal.h"
|
#include "1wire_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -81,14 +81,9 @@ struct onewire_slave_s
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* CRC helpers from 1wire_crc.c */
|
/* Aditional CRC helpers from 1wire_crc.c */
|
||||||
|
|
||||||
uint8_t onewire_crc8(FAR const uint8_t *input, uint8_t len);
|
|
||||||
uint16_t onewire_crc16(FAR const uint8_t *input, uint16_t len,
|
|
||||||
uint16_t initial_crc);
|
|
||||||
bool onewire_valid_rom(uint64_t rom);
|
bool onewire_valid_rom(uint64_t rom);
|
||||||
bool onewire_check_crc16(FAR const uint8_t *input, uint16_t len,
|
|
||||||
FAR const uint8_t *inverted_crc);
|
|
||||||
|
|
||||||
/* Rest are from 1wire.c */
|
/* Rest are from 1wire.c */
|
||||||
|
|
||||||
@ -146,7 +141,9 @@ int onewire_triplet(FAR struct onewire_master_s *master,
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Search all devices from a 1-wire network. This is the 1-wire search
|
* Search all devices from a 1-wire network. This is the 1-wire search
|
||||||
* algorithm from Maxim Application Note 187.
|
* algorithm from Maxim Application Note 187. Note! This is an atomic
|
||||||
|
* operation. The callback 'cb_search' can't execute any function that will
|
||||||
|
* lock this bus, because of the locked state as long the search is active.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* master - Pointer to the allocated 1-wire interface
|
* master - Pointer to the allocated 1-wire interface
|
||||||
@ -166,34 +163,6 @@ int onewire_search(FAR struct onewire_master_s *master,
|
|||||||
CODE void (*cb_search)(int family,
|
CODE void (*cb_search)(int family,
|
||||||
uint64_t romcode,
|
uint64_t romcode,
|
||||||
FAR void *arg),
|
FAR void *arg),
|
||||||
FAR void *arg);
|
FAR void *arg);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: onewire_initialize
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Return 1-wire bus master from 1-wire lower half device.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* dev - Pointer to the allocated 1-wire lower half
|
|
||||||
* maxslaves - Maximum number of 1-wire slave devices
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
FAR struct onewire_master_s *
|
|
||||||
onewire_initialize(FAR struct onewire_dev_s *dev, int maxslaves);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: onewire_uninitialize
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Release 1-wire bus master.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* master - Pointer to the allocated 1-wire master
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
int onewire_uninitialize(FAR struct onewire_master_s *master);
|
|
||||||
|
|
||||||
#endif /* __DRIVERS_1WIRE_1WIRE_INTERNAL_H */
|
#endif /* __DRIVERS_1WIRE_1WIRE_INTERNAL_H */
|
||||||
|
@ -45,7 +45,9 @@
|
|||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/i2c/i2c_master.h>
|
#include <nuttx/i2c/i2c_master.h>
|
||||||
#include <nuttx/drivers/1wire.h>
|
#include <nuttx/1wire/1wire_master.h>
|
||||||
|
#include <nuttx/1wire/1wire_crc.h>
|
||||||
|
#include <nuttx/1wire/1wire.h>
|
||||||
|
|
||||||
#include <nuttx/1wire/ds28e17.h>
|
#include <nuttx/1wire/ds28e17.h>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/nuttx/drivers/1wire.h
|
* include/nuttx/1wire/1wire.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016 Aleksandr Vyhovanec. All rights reserved.
|
* Copyright (C) 2016 Aleksandr Vyhovanec. All rights reserved.
|
||||||
* Author: Aleksandr Vyhovanec <www.desh@gmail.com>
|
* Author: Aleksandr Vyhovanec <www.desh@gmail.com>
|
||||||
@ -33,8 +33,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __INCLUDE_NUTTX_DRIVERS_1WIRE_H
|
#ifndef __INCLUDE_NUTTX_1WIRE_1WIRE_H
|
||||||
#define __INCLUDE_NUTTX_DRIVERS_1WIRE_H
|
#define __INCLUDE_NUTTX_1WIRE_1WIRE_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@ -43,6 +43,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@ -217,4 +218,4 @@ struct onewire_dev_s
|
|||||||
* Public Functions Definitions
|
* Public Functions Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#endif /* __INCLUDE_NUTTX_DRIVERS_1WIRE_H */
|
#endif /* __INCLUDE_NUTTX_1WIRE_1WIRE_H */
|
102
include/nuttx/1wire/1wire_crc.h
Normal file
102
include/nuttx/1wire/1wire_crc.h
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* include/nuttx/1wire/1wire_crc.h
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __INCLUDE_NUTTX_1WIRE_1WIRE_CRC_H
|
||||||
|
#define __INCLUDE_NUTTX_1WIRE_1WIRE_CRC_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: onewire_crc8
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Compute a Dallas Semiconductor 8 bit CRC.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* input - Input buffer for crc calculation
|
||||||
|
* len - Buffer len
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Calculated crc8
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint8_t onewire_crc8(FAR const uint8_t *input, uint8_t len);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: onewire_crc16
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Compute a Dallas Semiconductor 16 bit CRC. This is used to check
|
||||||
|
* the integrity of received data from many 1-wire devices.
|
||||||
|
*
|
||||||
|
* Note: the CRC-16 computed here is not what you'll get from the 1-wire
|
||||||
|
* network, because:
|
||||||
|
* - The CRC-16 is transmitted bitwise inverted.
|
||||||
|
* - The binary representation of the return value may have a different
|
||||||
|
* byte order than the two bytes you get from 1-wire due to endian-ness.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* input - Input buffer for crc calculation
|
||||||
|
* len - Buffer len
|
||||||
|
* initial_crc - Initial crc for calculation
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Calculated crc16
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint16_t onewire_crc16(FAR const uint8_t *input, uint16_t len,
|
||||||
|
uint16_t initial_crc);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: onewire_check_crc16
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Check CRC-16 of received input
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* input - Array of bytes to checksum
|
||||||
|
* len - Length of input
|
||||||
|
* inverted_crc - The two CRC16 bytes in the received data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* true if CRC-16 matches
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
bool onewire_check_crc16(FAR const uint8_t *input, uint16_t len,
|
||||||
|
FAR const uint8_t *inverted_crc);
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_NUTTX_1WIRE_1WIRE_CRC_H */
|
@ -43,7 +43,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <nuttx/drivers/1wire.h>
|
#include <nuttx/1wire/1wire.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user