din renames, dout split
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
#include "_din_internal.h"
|
||||
|
||||
/** Read request */
|
||||
error_t UU_DI_Read(Unit *unit, uint16_t *packed)
|
||||
error_t UU_DIn_Read(Unit *unit, uint16_t *packed)
|
||||
{
|
||||
CHECK_TYPE(unit, &UNIT_DIN);
|
||||
struct priv *priv = unit->data;
|
||||
@@ -20,7 +20,7 @@ error_t UU_DI_Read(Unit *unit, uint16_t *packed)
|
||||
}
|
||||
|
||||
/** Arm pins */
|
||||
error_t UU_DI_Arm(Unit *unit, uint16_t arm_single_packed, uint16_t arm_auto_packed)
|
||||
error_t UU_DIn_Arm(Unit *unit, uint16_t arm_single_packed, uint16_t arm_auto_packed)
|
||||
{
|
||||
CHECK_TYPE(unit, &UNIT_DIN);
|
||||
struct priv *priv = unit->data;
|
||||
@@ -52,7 +52,7 @@ error_t UU_DI_Arm(Unit *unit, uint16_t arm_single_packed, uint16_t arm_auto_pack
|
||||
}
|
||||
|
||||
/** DisArm pins */
|
||||
error_t UU_DI_DisArm(Unit *unit, uint16_t disarm_packed)
|
||||
error_t UU_DIn_DisArm(Unit *unit, uint16_t disarm_packed)
|
||||
{
|
||||
CHECK_TYPE(unit, &UNIT_DIN);
|
||||
struct priv *priv = unit->data;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* data1 - packed, triggering pin
|
||||
* data2 - snapshot
|
||||
*/
|
||||
static void DI_SendTriggerReportToMaster(Job *job)
|
||||
static void DIn_SendTriggerReportToMaster(Job *job)
|
||||
{
|
||||
PayloadBuilder pb = pb_start(unit_tmp512, UNIT_TMP_LEN, NULL);
|
||||
pb_u16(&pb, (uint16_t) job->data1); // packed, 1 on the triggering pin
|
||||
@@ -40,7 +40,7 @@ static void DI_SendTriggerReportToMaster(Job *job)
|
||||
*
|
||||
* @param arg - the unit is passed here
|
||||
*/
|
||||
void DI_handleExti(void *arg)
|
||||
void DIn_handleExti(void *arg)
|
||||
{
|
||||
const uint64_t ts = PTIM_GetMicrotime();
|
||||
|
||||
@@ -74,7 +74,7 @@ void DI_handleExti(void *arg)
|
||||
.timestamp = ts,
|
||||
.data1 = pinmask_pack(trigger_map, priv->pins),
|
||||
.data2 = pinmask_pack(snapshot, priv->pins),
|
||||
.cb = DI_SendTriggerReportToMaster
|
||||
.cb = DIn_SendTriggerReportToMaster
|
||||
};
|
||||
scheduleJob(&j);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
*
|
||||
* @param arg - the unit is passed here
|
||||
*/
|
||||
void DI_handleExti(void *arg);
|
||||
void DIn_handleExti(void *arg);
|
||||
|
||||
#endif //GEX_F072_DIN_EXTI_H
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "_din_exti.h"
|
||||
|
||||
/** Allocate data structure and set defaults */
|
||||
error_t DI_preInit(Unit *unit)
|
||||
error_t DIn_preInit(Unit *unit)
|
||||
{
|
||||
struct priv *priv = unit->data = calloc_ck(1, sizeof(struct priv));
|
||||
if (priv == NULL) return E_OUT_OF_MEM;
|
||||
@@ -31,7 +31,7 @@ error_t DI_preInit(Unit *unit)
|
||||
}
|
||||
|
||||
/** Finalize unit set-up */
|
||||
error_t DI_init(Unit *unit)
|
||||
error_t DIn_init(Unit *unit)
|
||||
{
|
||||
bool suc = true;
|
||||
struct priv *priv = unit->data;
|
||||
@@ -88,7 +88,7 @@ error_t DI_init(Unit *unit)
|
||||
|
||||
LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTS[priv->port_name-'A'], LL_SYSCFG_EXTI_LINES[i]);
|
||||
|
||||
irqd_attach(EXTIS[i], DI_handleExti, unit);
|
||||
irqd_attach(EXTIS[i], DIn_handleExti, unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ error_t DI_init(Unit *unit)
|
||||
|
||||
|
||||
/** Tear down the unit */
|
||||
void DI_deInit(Unit *unit)
|
||||
void DIn_deInit(Unit *unit)
|
||||
{
|
||||
struct priv *priv = unit->data;
|
||||
|
||||
@@ -116,7 +116,7 @@ void DI_deInit(Unit *unit)
|
||||
for (int i = 0; i < 16; i++, mask <<= 1) {
|
||||
if (triggs & mask) {
|
||||
LL_EXTI_DisableIT_0_31(LL_EXTI_LINES[i]);
|
||||
irqd_detach(EXTIS[i], DI_handleExti);
|
||||
irqd_detach(EXTIS[i], DIn_handleExti);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include "unit_base.h"
|
||||
|
||||
/** Finalize unit set-up */
|
||||
error_t DI_init(Unit *unit);
|
||||
error_t DIn_init(Unit *unit);
|
||||
|
||||
/** Tear down the unit */
|
||||
void DI_deInit(Unit *unit);
|
||||
void DIn_deInit(Unit *unit);
|
||||
|
||||
#endif //GEX_F072_DIN_INIT_H
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "_din_settings.h"
|
||||
|
||||
/** Load from a binary buffer stored in Flash */
|
||||
void DI_loadBinary(Unit *unit, PayloadParser *pp)
|
||||
void DIn_loadBinary(Unit *unit, PayloadParser *pp)
|
||||
{
|
||||
struct priv *priv = unit->data;
|
||||
|
||||
@@ -33,7 +33,7 @@ void DI_loadBinary(Unit *unit, PayloadParser *pp)
|
||||
}
|
||||
|
||||
/** Write to a binary buffer for storing in Flash */
|
||||
void DI_writeBinary(Unit *unit, PayloadBuilder *pb)
|
||||
void DIn_writeBinary(Unit *unit, PayloadBuilder *pb)
|
||||
{
|
||||
struct priv *priv = unit->data;
|
||||
|
||||
@@ -52,7 +52,7 @@ void DI_writeBinary(Unit *unit, PayloadBuilder *pb)
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Parse a key-value pair from the INI file */
|
||||
error_t DI_loadIni(Unit *unit, const char *key, const char *value)
|
||||
error_t DIn_loadIni(Unit *unit, const char *key, const char *value)
|
||||
{
|
||||
bool suc = true;
|
||||
struct priv *priv = unit->data;
|
||||
@@ -90,7 +90,7 @@ error_t DI_loadIni(Unit *unit, const char *key, const char *value)
|
||||
}
|
||||
|
||||
/** Generate INI file section for the unit */
|
||||
void DI_writeIni(Unit *unit, IniWriter *iw)
|
||||
void DIn_writeIni(Unit *unit, IniWriter *iw)
|
||||
{
|
||||
struct priv *priv = unit->data;
|
||||
|
||||
|
||||
@@ -12,20 +12,20 @@
|
||||
#include "unit_base.h"
|
||||
|
||||
/** Allocate data structure and set defaults */
|
||||
error_t DI_preInit(Unit *unit);
|
||||
error_t DIn_preInit(Unit *unit);
|
||||
|
||||
/** Load from a binary buffer stored in Flash */
|
||||
void DI_loadBinary(Unit *unit, PayloadParser *pp);
|
||||
void DIn_loadBinary(Unit *unit, PayloadParser *pp);
|
||||
|
||||
/** Write to a binary buffer for storing in Flash */
|
||||
void DI_writeBinary(Unit *unit, PayloadBuilder *pb);
|
||||
void DIn_writeBinary(Unit *unit, PayloadBuilder *pb);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Parse a key-value pair from the INI file */
|
||||
error_t DI_loadIni(Unit *unit, const char *key, const char *value);
|
||||
error_t DIn_loadIni(Unit *unit, const char *key, const char *value);
|
||||
|
||||
/** Generate INI file section for the unit */
|
||||
void DI_writeIni(Unit *unit, IniWriter *iw);
|
||||
void DIn_writeIni(Unit *unit, IniWriter *iw);
|
||||
|
||||
#endif //GEX_F072_DIN_SETTINGS_H
|
||||
|
||||
+15
-15
@@ -20,13 +20,13 @@ enum PinCmd_ {
|
||||
};
|
||||
|
||||
/** Handle a request message */
|
||||
static error_t DI_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, PayloadParser *pp)
|
||||
static error_t DIn_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, PayloadParser *pp)
|
||||
{
|
||||
uint16_t pins = 0;
|
||||
|
||||
switch (command) {
|
||||
case CMD_READ:;
|
||||
TRY(UU_DI_Read(unit, &pins));
|
||||
TRY(UU_DIn_Read(unit, &pins));
|
||||
|
||||
PayloadBuilder pb = pb_start((uint8_t*)unit_tmp512, UNIT_TMP_LEN, NULL);
|
||||
pb_u16(&pb, pins); // packed input pins
|
||||
@@ -37,21 +37,21 @@ static error_t DI_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, Pay
|
||||
pins = pp_u16(pp);
|
||||
if (!pp->ok) return E_MALFORMED_COMMAND;
|
||||
|
||||
TRY(UU_DI_Arm(unit, pins, 0));
|
||||
TRY(UU_DIn_Arm(unit, pins, 0));
|
||||
return E_SUCCESS;
|
||||
|
||||
case CMD_ARM_AUTO:;
|
||||
pins = pp_u16(pp);
|
||||
if (!pp->ok) return E_MALFORMED_COMMAND;
|
||||
|
||||
TRY(UU_DI_Arm(unit, 0, pins));
|
||||
TRY(UU_DIn_Arm(unit, 0, pins));
|
||||
return E_SUCCESS;
|
||||
|
||||
case CMD_DISARM:;
|
||||
pins = pp_u16(pp);
|
||||
if (!pp->ok) return E_MALFORMED_COMMAND;
|
||||
|
||||
TRY(UU_DI_DisArm(unit, pins));
|
||||
TRY(UU_DIn_DisArm(unit, pins));
|
||||
return E_SUCCESS;
|
||||
|
||||
default:
|
||||
@@ -64,7 +64,7 @@ static error_t DI_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, Pay
|
||||
*
|
||||
* @param unit
|
||||
*/
|
||||
static void DI_updateTick(Unit *unit)
|
||||
static void DIn_updateTick(Unit *unit)
|
||||
{
|
||||
struct priv *priv = unit->data;
|
||||
|
||||
@@ -82,15 +82,15 @@ const UnitDriver UNIT_DIN = {
|
||||
.name = "DI",
|
||||
.description = "Digital input with triggers",
|
||||
// Settings
|
||||
.preInit = DI_preInit,
|
||||
.cfgLoadBinary = DI_loadBinary,
|
||||
.cfgWriteBinary = DI_writeBinary,
|
||||
.cfgLoadIni = DI_loadIni,
|
||||
.cfgWriteIni = DI_writeIni,
|
||||
.preInit = DIn_preInit,
|
||||
.cfgLoadBinary = DIn_loadBinary,
|
||||
.cfgWriteBinary = DIn_writeBinary,
|
||||
.cfgLoadIni = DIn_loadIni,
|
||||
.cfgWriteIni = DIn_writeIni,
|
||||
// Init
|
||||
.init = DI_init,
|
||||
.deInit = DI_deInit,
|
||||
.init = DIn_init,
|
||||
.deInit = DIn_deInit,
|
||||
// Function
|
||||
.handleRequest = DI_handleRequest,
|
||||
.updateTick = DI_updateTick,
|
||||
.handleRequest = DIn_handleRequest,
|
||||
.updateTick = DIn_updateTick,
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ extern const UnitDriver UNIT_DIN;
|
||||
* @param packed - output; the packed (right aligned) bits representing the pins, highest to lowest, are written here.
|
||||
* @return success
|
||||
*/
|
||||
error_t UU_DI_Read(Unit *unit, uint16_t *packed);
|
||||
error_t UU_DIn_Read(Unit *unit, uint16_t *packed);
|
||||
|
||||
/**
|
||||
* Arm pins for trigger generation
|
||||
@@ -28,7 +28,7 @@ error_t UU_DI_Read(Unit *unit, uint16_t *packed);
|
||||
* @param arm_auto_packed - packed bit map of pins to arm for auto trigger (repeated)
|
||||
* @return success
|
||||
*/
|
||||
error_t UU_DI_Arm(Unit *unit, uint16_t arm_single_packed, uint16_t arm_auto_packed);
|
||||
error_t UU_DIn_Arm(Unit *unit, uint16_t arm_single_packed, uint16_t arm_auto_packed);
|
||||
|
||||
/**
|
||||
* Dis-arm pins to not generate events
|
||||
@@ -37,6 +37,6 @@ error_t UU_DI_Arm(Unit *unit, uint16_t arm_single_packed, uint16_t arm_auto_pack
|
||||
* @param disarm_packed - packed bit map of pins to dis-arm
|
||||
* @return success
|
||||
*/
|
||||
error_t UU_DI_DisArm(Unit *unit, uint16_t disarm_packed);
|
||||
error_t UU_DIn_DisArm(Unit *unit, uint16_t disarm_packed);
|
||||
|
||||
#endif //U_DIN_H
|
||||
|
||||
Reference in New Issue
Block a user