cleaning
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#define OW_INTERNAL
|
||||
#include "_ow_internal.h"
|
||||
#include "_ow_commands.h"
|
||||
#include "_ow_checksum.h"
|
||||
#include "_ow_low_level.h"
|
||||
|
||||
/* Check presence of any devices on the bus */
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// Created by MightyPork on 2018/02/01.
|
||||
//
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#define OW_INTERNAL
|
||||
#include "_ow_checksum.h"
|
||||
|
||||
static inline uint8_t crc8_bits(uint8_t data)
|
||||
{
|
||||
uint8_t crc = 0;
|
||||
if(data & 1) crc ^= 0x5e;
|
||||
if(data & 2) crc ^= 0xbc;
|
||||
if(data & 4) crc ^= 0x61;
|
||||
if(data & 8) crc ^= 0xc2;
|
||||
if(data & 0x10) crc ^= 0x9d;
|
||||
if(data & 0x20) crc ^= 0x23;
|
||||
if(data & 0x40) crc ^= 0x46;
|
||||
if(data & 0x80) crc ^= 0x8c;
|
||||
return crc;
|
||||
}
|
||||
|
||||
static uint8_t crc8_add(uint8_t cksum, uint8_t byte)
|
||||
{
|
||||
return crc8_bits(byte ^ cksum);
|
||||
}
|
||||
|
||||
uint8_t ow_checksum(const uint8_t *buff, uint32_t len)
|
||||
{
|
||||
uint8_t cksum = 0;
|
||||
for(uint32_t i = 0; i < len; i++) {
|
||||
cksum = crc8_add(cksum, buff[i]);
|
||||
}
|
||||
return cksum;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
//
|
||||
// Created by MightyPork on 2018/02/01.
|
||||
//
|
||||
|
||||
#ifndef GEX_F072_OW_CHECKSUM_H
|
||||
#define GEX_F072_OW_CHECKSUM_H
|
||||
|
||||
#ifndef OW_INTERNAL
|
||||
#error bad include!
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* Compute a 1-wire type checksum.
|
||||
* If the buffer includes the checksum, the result should be 0.
|
||||
*
|
||||
* (this function may be used externally, or you can delete the implementation
|
||||
* from the c file if another implementation is already available)
|
||||
*
|
||||
* @param[in] buf - buffer of bytes to verify
|
||||
* @param[in] len - buffer length
|
||||
* @return checksum
|
||||
*/
|
||||
uint8_t ow_checksum(const uint8_t *buf, uint32_t len);
|
||||
|
||||
#endif //GEX_F072_OW_CHECKSUM_H
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// Created by MightyPork on 2018/02/03.
|
||||
//
|
||||
|
||||
#ifndef GEX_F072_OW_INIT_H
|
||||
#define GEX_F072_OW_INIT_H
|
||||
|
||||
#ifndef OW_INTERNAL
|
||||
#error bad include!
|
||||
#endif
|
||||
|
||||
#include "unit_base.h"
|
||||
|
||||
/** Allocate data structure and set defaults */
|
||||
error_t OW_preInit(Unit *unit);
|
||||
|
||||
/** Finalize unit set-up */
|
||||
error_t OW_init(Unit *unit);
|
||||
|
||||
/** Tear down the unit */
|
||||
void OW_deInit(Unit *unit);
|
||||
|
||||
extern void OW_TimerCb(TimerHandle_t xTimer);
|
||||
|
||||
#endif //GEX_F072_OW_INIT_H
|
||||
@@ -27,6 +27,37 @@ struct priv {
|
||||
struct ow_search_state searchState;
|
||||
};
|
||||
|
||||
// Prototypes
|
||||
/** Allocate data structure and set defaults */
|
||||
error_t OW_preInit(Unit *unit);
|
||||
|
||||
/** Load from a binary buffer stored in Flash */
|
||||
void OW_loadBinary(Unit *unit, PayloadParser *pp);
|
||||
|
||||
/** Write to a binary buffer for storing in Flash */
|
||||
void OW_writeBinary(Unit *unit, PayloadBuilder *pb);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Parse a key-value pair from the INI file */
|
||||
error_t OW_loadIni(Unit *unit, const char *key, const char *value);
|
||||
|
||||
/** Generate INI file section for the unit */
|
||||
void OW_writeIni(Unit *unit, IniWriter *iw);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Allocate data structure and set defaults */
|
||||
error_t OW_preInit(Unit *unit);
|
||||
|
||||
/** Finalize unit set-up */
|
||||
error_t OW_init(Unit *unit);
|
||||
|
||||
/** Tear down the unit */
|
||||
void OW_deInit(Unit *unit);
|
||||
|
||||
/** Callback for the FreeRTOS timer used to wait for device ready */
|
||||
void OW_TimerCb(TimerHandle_t xTimer);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
#endif //GEX_F072_OW_INTERNAL_H
|
||||
|
||||
@@ -10,6 +10,36 @@
|
||||
#include "_ow_internal.h"
|
||||
#include "_ow_low_level.h"
|
||||
|
||||
static inline uint8_t crc8_bits(uint8_t data)
|
||||
{
|
||||
uint8_t crc = 0;
|
||||
if(data & 1) crc ^= 0x5e;
|
||||
if(data & 2) crc ^= 0xbc;
|
||||
if(data & 4) crc ^= 0x61;
|
||||
if(data & 8) crc ^= 0xc2;
|
||||
if(data & 0x10) crc ^= 0x9d;
|
||||
if(data & 0x20) crc ^= 0x23;
|
||||
if(data & 0x40) crc ^= 0x46;
|
||||
if(data & 0x80) crc ^= 0x8c;
|
||||
return crc;
|
||||
}
|
||||
|
||||
static uint8_t crc8_add(uint8_t cksum, uint8_t byte)
|
||||
{
|
||||
return crc8_bits(byte ^ cksum);
|
||||
}
|
||||
|
||||
uint8_t ow_checksum(const uint8_t *buff, uint32_t len)
|
||||
{
|
||||
uint8_t cksum = 0;
|
||||
for(uint32_t i = 0; i < len; i++) {
|
||||
cksum = crc8_add(cksum, buff[i]);
|
||||
}
|
||||
return cksum;
|
||||
}
|
||||
|
||||
// ----------------------------------------------
|
||||
|
||||
static inline void ow_pull_high(Unit *unit)
|
||||
{
|
||||
struct priv *priv = unit->data;
|
||||
|
||||
@@ -13,6 +13,19 @@
|
||||
#include "unit_base.h"
|
||||
#include "_ow_low_level.h"
|
||||
|
||||
/**
|
||||
* Compute a 1-wire type checksum.
|
||||
* If the buffer includes the checksum, the result should be 0.
|
||||
*
|
||||
* (this function may be used externally, or you can delete the implementation
|
||||
* from the c file if another implementation is already available)
|
||||
*
|
||||
* @param[in] buf - buffer of bytes to verify
|
||||
* @param[in] len - buffer length
|
||||
* @return checksum
|
||||
*/
|
||||
uint8_t ow_checksum(const uint8_t *buf, uint32_t len);
|
||||
|
||||
/**
|
||||
* Reset the 1-wire bus
|
||||
*/
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// Created by MightyPork on 2018/02/03.
|
||||
//
|
||||
|
||||
#ifndef GEX_F072_OW_SETTINGS_H
|
||||
#define GEX_F072_OW_SETTINGS_H
|
||||
|
||||
#ifndef OW_INTERNAL
|
||||
#error bad include!
|
||||
#endif
|
||||
|
||||
#include "unit_base.h"
|
||||
|
||||
/** Allocate data structure and set defaults */
|
||||
error_t OW_preInit(Unit *unit);
|
||||
|
||||
/** Load from a binary buffer stored in Flash */
|
||||
void OW_loadBinary(Unit *unit, PayloadParser *pp);
|
||||
|
||||
/** Write to a binary buffer for storing in Flash */
|
||||
void OW_writeBinary(Unit *unit, PayloadBuilder *pb);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Parse a key-value pair from the INI file */
|
||||
error_t OW_loadIni(Unit *unit, const char *key, const char *value);
|
||||
|
||||
/** Generate INI file section for the unit */
|
||||
void OW_writeIni(Unit *unit, IniWriter *iw);
|
||||
|
||||
#endif //GEX_F072_OW_SETTINGS_H
|
||||
Reference in New Issue
Block a user