This commit is contained in:
2018-02-03 11:54:22 +01:00
parent 96a7b58091
commit 611b38c5e6
39 changed files with 260 additions and 487 deletions
-1
View File
@@ -9,7 +9,6 @@
#define OW_INTERNAL #define OW_INTERNAL
#include "_ow_internal.h" #include "_ow_internal.h"
#include "_ow_commands.h" #include "_ow_commands.h"
#include "_ow_checksum.h"
#include "_ow_low_level.h" #include "_ow_low_level.h"
/* Check presence of any devices on the bus */ /* Check presence of any devices on the bus */
-36
View File
@@ -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;
}
-27
View File
@@ -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
-25
View File
@@ -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
+32 -1
View File
@@ -27,6 +27,37 @@ struct priv {
struct ow_search_state searchState; 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 #endif //GEX_F072_OW_INTERNAL_H
+30
View File
@@ -10,6 +10,36 @@
#include "_ow_internal.h" #include "_ow_internal.h"
#include "_ow_low_level.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) static inline void ow_pull_high(Unit *unit)
{ {
struct priv *priv = unit->data; struct priv *priv = unit->data;
+13
View File
@@ -13,6 +13,19 @@
#include "unit_base.h" #include "unit_base.h"
#include "_ow_low_level.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 * Reset the 1-wire bus
*/ */
-31
View File
@@ -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
-21
View File
@@ -1,21 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_DIN_EXTI_H
#define GEX_F072_DIN_EXTI_H
#ifndef DIN_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/**
* EXTI callback for pin change interrupts
*
* @param arg - the unit is passed here
*/
void DIn_handleExti(void *arg);
#endif //GEX_F072_DIN_EXTI_H
-20
View File
@@ -1,20 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_DIN_INIT_H
#define GEX_F072_DIN_INIT_H
#ifndef DIN_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Finalize unit set-up */
error_t DIn_init(Unit *unit);
/** Tear down the unit */
void DIn_deInit(Unit *unit);
#endif //GEX_F072_DIN_INIT_H
+34
View File
@@ -28,4 +28,38 @@ struct priv {
GPIO_TypeDef *port; GPIO_TypeDef *port;
}; };
/** Allocate data structure and set defaults */
error_t DIn_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void DIn_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void DIn_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t DIn_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void DIn_writeIni(Unit *unit, IniWriter *iw);
// ------------------------------------------------------------------------
/** Finalize unit set-up */
error_t DIn_init(Unit *unit);
/** Tear down the unit */
void DIn_deInit(Unit *unit);
// ------------------------------------------------------------------------
/**
* EXTI callback for pin change interrupts
*
* @param arg - the unit is passed here
*/
void DIn_handleExti(void *arg);
#endif //GEX_F072_DIN_INTERNAL_H #endif //GEX_F072_DIN_INTERNAL_H
-31
View File
@@ -1,31 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_DIN_SETTINGS_H
#define GEX_F072_DIN_SETTINGS_H
#ifndef DIN_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Allocate data structure and set defaults */
error_t DIn_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void DIn_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void DIn_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t DIn_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void DIn_writeIni(Unit *unit, IniWriter *iw);
#endif //GEX_F072_DIN_SETTINGS_H
-20
View File
@@ -1,20 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_DOUT_INIT_H
#define GEX_F072_DOUT_INIT_H
#ifndef DOUT_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Finalize unit set-up */
error_t DOut_init(Unit *unit);
/** Tear down the unit */
void DOut_deInit(Unit *unit);
#endif //GEX_F072_DOUT_INIT_H
+25
View File
@@ -21,4 +21,29 @@ struct priv {
GPIO_TypeDef *port; GPIO_TypeDef *port;
}; };
/** Allocate data structure and set defaults */
error_t DOut_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void DOut_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void DOut_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t DOut_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void DOut_writeIni(Unit *unit, IniWriter *iw);
// ------------------------------------------------------------------------
/** Finalize unit set-up */
error_t DOut_init(Unit *unit);
/** Tear down the unit */
void DOut_deInit(Unit *unit);
#endif //GEX_F072_DOUT_INTERNAL_H #endif //GEX_F072_DOUT_INTERNAL_H
-31
View File
@@ -1,31 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_DOUT_SETTINGS_H
#define GEX_F072_DOUT_SETTINGS_H
#ifndef DOUT_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Allocate data structure and set defaults */
error_t DOut_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void DOut_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void DOut_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t DOut_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void DOut_writeIni(Unit *unit, IniWriter *iw);
#endif //GEX_F072_DOUT_SETTINGS_H
+2 -4
View File
@@ -6,8 +6,7 @@
#include "unit_dout.h" #include "unit_dout.h"
#define DOUT_INTERNAL #define DOUT_INTERNAL
#include "_dout_settings.h" #include "_dout_internal.h"
#include "_dout_init.h"
enum PinCmd_ { enum PinCmd_ {
CMD_TEST = 0, CMD_TEST = 0,
@@ -17,8 +16,7 @@ enum PinCmd_ {
}; };
/** Handle a request message */ /** Handle a request message */
static error_t DOut_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, static error_t DOut_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, PayloadParser *pp)
PayloadParser *pp)
{ {
uint16_t packed = pp_u16(pp); uint16_t packed = pp_u16(pp);
-1
View File
@@ -7,7 +7,6 @@
#define I2C_INTERNAL #define I2C_INTERNAL
#include "_i2c_internal.h" #include "_i2c_internal.h"
#include "_i2c_init.h"
/** Allocate data structure and set defaults */ /** Allocate data structure and set defaults */
-24
View File
@@ -1,24 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_I2C_INIT_H
#define GEX_F072_I2C_INIT_H
#ifndef I2C_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Allocate data structure and set defaults */
error_t UI2C_preInit(Unit *unit);
/** Finalize unit set-up */
error_t UI2C_init(Unit *unit);
/** Tear down the unit */
void UI2C_deInit(Unit *unit);
#endif //GEX_F072_I2C_INIT_H
+27 -4
View File
@@ -19,10 +19,33 @@ struct priv {
uint8_t speed; //!< 0 - Standard, 1 - Fast, 2 - Fast+ uint8_t speed; //!< 0 - Standard, 1 - Fast, 2 - Fast+
I2C_TypeDef *periph; I2C_TypeDef *periph;
// GPIO_TypeDef *port;
// uint32_t ll_pin_scl;
// uint32_t ll_pin_sda;
}; };
/** Load from a binary buffer stored in Flash */
void UI2C_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void UI2C_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t UI2C_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void UI2C_writeIni(Unit *unit, IniWriter *iw);
// ------------------------------------------------------------------------
/** Allocate data structure and set defaults */
error_t UI2C_preInit(Unit *unit);
/** Finalize unit set-up */
error_t UI2C_init(Unit *unit);
/** Tear down the unit */
void UI2C_deInit(Unit *unit);
// ------------------------------------------------------------------------
#endif //GEX_F072_I2C_INTERNAL_H #endif //GEX_F072_I2C_INTERNAL_H
-28
View File
@@ -1,28 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_I2C_SETTINGS_H
#define GEX_F072_I2C_SETTINGS_H
#ifndef I2C_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Load from a binary buffer stored in Flash */
void UI2C_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void UI2C_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t UI2C_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void UI2C_writeIni(Unit *unit, IniWriter *iw);
#endif //GEX_F072_I2C_SETTINGS_H
-1
View File
@@ -7,7 +7,6 @@
#define NPX_INTERNAL #define NPX_INTERNAL
#include "_npx_internal.h" #include "_npx_internal.h"
#include "_npx_init.h"
#include "ws2812.h" #include "ws2812.h"
/** Allocate data structure and set defaults */ /** Allocate data structure and set defaults */
-20
View File
@@ -1,20 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_NPX_INIT_H
#define GEX_F072_NPX_INIT_H
#ifndef NPX_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Finalize unit set-up */
error_t Npx_init(Unit *unit);
/** Tear down the unit */
void Npx_deInit(Unit *unit);
#endif //GEX_F072_NPX_INIT_H
+27
View File
@@ -21,4 +21,31 @@ struct priv {
GPIO_TypeDef *port; GPIO_TypeDef *port;
}; };
// ------------------------------------------------------------------------
/** Allocate data structure and set defaults */
error_t Npx_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void Npx_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void Npx_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t Npx_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void Npx_writeIni(Unit *unit, IniWriter *iw);
// ------------------------------------------------------------------------
/** Finalize unit set-up */
error_t Npx_init(Unit *unit);
/** Tear down the unit */
void Npx_deInit(Unit *unit);
#endif //GEX_F072_NPX_INTERNAL_H #endif //GEX_F072_NPX_INTERNAL_H
-1
View File
@@ -7,7 +7,6 @@
#define NPX_INTERNAL #define NPX_INTERNAL
#include "_npx_internal.h" #include "_npx_internal.h"
#include "_npx_settings.h"
/** Load from a binary buffer stored in Flash */ /** Load from a binary buffer stored in Flash */
void Npx_loadBinary(Unit *unit, PayloadParser *pp) void Npx_loadBinary(Unit *unit, PayloadParser *pp)
-31
View File
@@ -1,31 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_NPX_SETTINGS_H
#define GEX_F072_NPX_SETTINGS_H
#ifndef NPX_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Allocate data structure and set defaults */
error_t Npx_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void Npx_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void Npx_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t Npx_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void Npx_writeIni(Unit *unit, IniWriter *iw);
#endif //GEX_F072_NPX_SETTINGS_H
+1 -2
View File
@@ -6,8 +6,7 @@
#include "unit_neopixel.h" #include "unit_neopixel.h"
#define NPX_INTERNAL #define NPX_INTERNAL
#include "_npx_settings.h" #include "_npx_internal.h"
#include "_npx_init.h"
enum PinCmd_ { enum PinCmd_ {
CMD_CLEAR = 0, CMD_CLEAR = 0,
+3 -4
View File
@@ -7,10 +7,9 @@
#define SPI_INTERNAL #define SPI_INTERNAL
#include "_spi_internal.h" #include "_spi_internal.h"
#include "_spi_init.h"
/** Allocate data structure and set defaults */ /** Allocate data structure and set defaults */
error_t SPI_preInit(Unit *unit) error_t USPI_preInit(Unit *unit)
{ {
struct priv *priv = unit->data = calloc_ck(1, sizeof(struct priv)); struct priv *priv = unit->data = calloc_ck(1, sizeof(struct priv));
if (priv == NULL) return E_OUT_OF_MEM; if (priv == NULL) return E_OUT_OF_MEM;
@@ -32,7 +31,7 @@ error_t SPI_preInit(Unit *unit)
} }
/** Finalize unit set-up */ /** Finalize unit set-up */
error_t SPI_init(Unit *unit) error_t USPI_init(Unit *unit)
{ {
bool suc = true; bool suc = true;
struct priv *priv = unit->data; struct priv *priv = unit->data;
@@ -176,7 +175,7 @@ error_t SPI_init(Unit *unit)
} }
/** Tear down the unit */ /** Tear down the unit */
void SPI_deInit(Unit *unit) void USPI_deInit(Unit *unit)
{ {
struct priv *priv = unit->data; struct priv *priv = unit->data;
-20
View File
@@ -1,20 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_SPI_INIT_H
#define GEX_F072_SPI_INIT_H
#ifndef SPI_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Finalize unit set-up */
error_t SPI_init(Unit *unit);
/** Tear down the unit */
void SPI_deInit(Unit *unit);
#endif //GEX_F072_SPI_INIT_H
+27
View File
@@ -29,4 +29,31 @@ struct priv {
GPIO_TypeDef *ssn_port; GPIO_TypeDef *ssn_port;
}; };
// ------------------------------------------------------------------------
/** Load from a binary buffer stored in Flash */
void USPI_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void USPI_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t USPI_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void USPI_writeIni(Unit *unit, IniWriter *iw);
// ------------------------------------------------------------------------
/** Allocate data structure and set defaults */
error_t USPI_preInit(Unit *unit);
/** Finalize unit set-up */
error_t USPI_init(Unit *unit);
/** Tear down the unit */
void USPI_deInit(Unit *unit);
#endif //GEX_F072_SPI_INTERNAL_H #endif //GEX_F072_SPI_INTERNAL_H
+4 -5
View File
@@ -7,10 +7,9 @@
#define SPI_INTERNAL #define SPI_INTERNAL
#include "_spi_internal.h" #include "_spi_internal.h"
#include "_spi_settings.h"
/** Load from a binary buffer stored in Flash */ /** Load from a binary buffer stored in Flash */
void SPI_loadBinary(Unit *unit, PayloadParser *pp) void USPI_loadBinary(Unit *unit, PayloadParser *pp)
{ {
struct priv *priv = unit->data; struct priv *priv = unit->data;
@@ -31,7 +30,7 @@ void SPI_loadBinary(Unit *unit, PayloadParser *pp)
} }
/** Write to a binary buffer for storing in Flash */ /** Write to a binary buffer for storing in Flash */
void SPI_writeBinary(Unit *unit, PayloadBuilder *pb) void USPI_writeBinary(Unit *unit, PayloadBuilder *pb)
{ {
struct priv *priv = unit->data; struct priv *priv = unit->data;
@@ -53,7 +52,7 @@ void SPI_writeBinary(Unit *unit, PayloadBuilder *pb)
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */ /** Parse a key-value pair from the INI file */
error_t SPI_loadIni(Unit *unit, const char *key, const char *value) error_t USPI_loadIni(Unit *unit, const char *key, const char *value)
{ {
bool suc = true; bool suc = true;
struct priv *priv = unit->data; struct priv *priv = unit->data;
@@ -94,7 +93,7 @@ error_t SPI_loadIni(Unit *unit, const char *key, const char *value)
} }
/** Generate INI file section for the unit */ /** Generate INI file section for the unit */
void SPI_writeIni(Unit *unit, IniWriter *iw) void USPI_writeIni(Unit *unit, IniWriter *iw)
{ {
struct priv *priv = unit->data; struct priv *priv = unit->data;
-31
View File
@@ -1,31 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_SPI_SETTINGS_H
#define GEX_F072_SPI_SETTINGS_H
#ifndef SPI_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Allocate data structure and set defaults */
error_t SPI_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void SPI_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void SPI_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t SPI_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void SPI_writeIni(Unit *unit, IniWriter *iw);
#endif //GEX_F072_SPI_SETTINGS_H
+7 -9
View File
@@ -11,8 +11,6 @@
#define SPI_INTERNAL #define SPI_INTERNAL
#include "_spi_internal.h" #include "_spi_internal.h"
#include "_spi_settings.h"
#include "_spi_init.h"
// SPI master // SPI master
@@ -73,14 +71,14 @@ const UnitDriver UNIT_SPI = {
.name = "SPI", .name = "SPI",
.description = "SPI master", .description = "SPI master",
// Settings // Settings
.preInit = SPI_preInit, .preInit = USPI_preInit,
.cfgLoadBinary = SPI_loadBinary, .cfgLoadBinary = USPI_loadBinary,
.cfgWriteBinary = SPI_writeBinary, .cfgWriteBinary = USPI_writeBinary,
.cfgLoadIni = SPI_loadIni, .cfgLoadIni = USPI_loadIni,
.cfgWriteIni = SPI_writeIni, .cfgWriteIni = USPI_writeIni,
// Init // Init
.init = SPI_init, .init = USPI_init,
.deInit = SPI_deInit, .deInit = USPI_deInit,
// Function // Function
.handleRequest = SPI_handleRequest, .handleRequest = SPI_handleRequest,
}; };
-1
View File
@@ -7,7 +7,6 @@
#define TPL_INTERNAL #define TPL_INTERNAL
#include "_tpl_internal.h" #include "_tpl_internal.h"
#include "_tpl_init.h"
/** Allocate data structure and set defaults */ /** Allocate data structure and set defaults */
error_t TPL_preInit(Unit *unit) error_t TPL_preInit(Unit *unit)
-20
View File
@@ -1,20 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_TPL_INIT_H
#define GEX_F072_TPL_INIT_H
#ifndef TPL_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Finalize unit set-up */
error_t TPL_init(Unit *unit);
/** Tear down the unit */
void TPL_deInit(Unit *unit);
#endif //GEX_F072_TPL_INIT_H
+25
View File
@@ -18,4 +18,29 @@ struct priv {
// internal state // internal state
}; };
/** Allocate data structure and set defaults */
error_t TPL_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void TPL_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void TPL_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t TPL_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void TPL_writeIni(Unit *unit, IniWriter *iw);
// ------------------------------------------------------------------------
/** Finalize unit set-up */
error_t TPL_init(Unit *unit);
/** Tear down the unit */
void TPL_deInit(Unit *unit);
#endif //GEX_F072_TPL_INTERNAL_H #endif //GEX_F072_TPL_INTERNAL_H
-1
View File
@@ -7,7 +7,6 @@
#define TPL_INTERNAL #define TPL_INTERNAL
#include "_tpl_internal.h" #include "_tpl_internal.h"
#include "_tpl_settings.h"
/** Load from a binary buffer stored in Flash */ /** Load from a binary buffer stored in Flash */
void TPL_loadBinary(Unit *unit, PayloadParser *pp) void TPL_loadBinary(Unit *unit, PayloadParser *pp)
-31
View File
@@ -1,31 +0,0 @@
//
// Created by MightyPork on 2018/02/03.
//
#ifndef GEX_F072_TPL_SETTINGS_H
#define GEX_F072_TPL_SETTINGS_H
#ifndef TPL_INTERNAL
#error bad include!
#endif
#include "unit_base.h"
/** Allocate data structure and set defaults */
error_t TPL_preInit(Unit *unit);
/** Load from a binary buffer stored in Flash */
void TPL_loadBinary(Unit *unit, PayloadParser *pp);
/** Write to a binary buffer for storing in Flash */
void TPL_writeBinary(Unit *unit, PayloadBuilder *pb);
// ------------------------------------------------------------------------
/** Parse a key-value pair from the INI file */
error_t TPL_loadIni(Unit *unit, const char *key, const char *value);
/** Generate INI file section for the unit */
void TPL_writeIni(Unit *unit, IniWriter *iw);
#endif //GEX_F072_TPL_SETTINGS_H
-2
View File
@@ -7,8 +7,6 @@
#define TPL_INTERNAL #define TPL_INTERNAL
#include "_tpl_internal.h" #include "_tpl_internal.h"
#include "_tpl_settings.h"
#include "_tpl_init.h"
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
+3 -3
View File
@@ -63,9 +63,6 @@ struct priv {
volatile bool tx_dma_busy; //!< Flag that the Tx DMA request is ongoing volatile bool tx_dma_busy; //!< Flag that the Tx DMA request is ongoing
}; };
/** Allocate data structure and set defaults */
error_t UUSART_preInit(Unit *unit);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Load from a binary buffer stored in Flash */ /** Load from a binary buffer stored in Flash */
@@ -84,6 +81,9 @@ void UUSART_writeIni(Unit *unit, IniWriter *iw);
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Allocate data structure and set defaults */
error_t UUSART_preInit(Unit *unit);
/** Tear down the unit */ /** Tear down the unit */
void UUSART_deInit(Unit *unit); void UUSART_deInit(Unit *unit);