Initial commit: demo-epb v1.0 — Elektrische Parkbremse Demo
Vollstaendige Demo des slohmaier Dev Process anhand einer EPB-Steuergeraet- Software. Zeigt ASPICE 4.0 / ISO 26262-konforme Entwicklung im Monorepo. Inhalte: - 5 Plaene (PID, PM-, QA-, SWE-, Test-Plan) in Word, ausgefuellt mit EPB-spezifischen Inhalten - 10 System-Anforderungen + 25 Software-Anforderungen (Doorstop-MD) - 5 System-Architektur-Elemente + 10 Software-Architektur-Elemente mit PlantUML-Diagrammen und vollstaendigem Mapping - 3 implementierte Komponenten (Apply Controller D, Actuator Driver B, Switch Debouncer QM) plus 7 Header-Stubs - 28 Unit-Tests, alle gruen, mit Coverage- und MISRA-Build-Targets - Audit-Artefakte: 1 Review-Protokoll, 1 Non-Conformity, 1 MISRA-Record - Gitea-Actions-CI-Pipeline (validate.yml) - Doorstop-Konfiguration fuer bidirektionale Traceability - Generator-Skript fuer alle 50 Reqs/Arch-Elemente aus Strukturdaten - README mit gefuehrter Tour fuer Prospects
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* @file switch_debouncer.c
|
||||
* @brief Implementierung des EPB-Schalter-Debouncers.
|
||||
*
|
||||
* @arch SWA-006
|
||||
* @reqs SWE-025
|
||||
*
|
||||
* ASIL: QM.
|
||||
*/
|
||||
#include "switch_debouncer.h"
|
||||
|
||||
typedef struct {
|
||||
SwitchState current;
|
||||
SwitchState candidate;
|
||||
uint8_t candidate_count;
|
||||
} DebouncerCtx;
|
||||
|
||||
static DebouncerCtx s_ctx;
|
||||
|
||||
static SwitchState raw_to_candidate(SwitchRaw raw)
|
||||
{
|
||||
if (raw.apply_raw && !raw.release_raw) {
|
||||
return SWITCH_APPLY;
|
||||
}
|
||||
if (raw.release_raw && !raw.apply_raw) {
|
||||
return SWITCH_RELEASE;
|
||||
}
|
||||
return SWITCH_NEUTRAL;
|
||||
}
|
||||
|
||||
EpbStatus switch_init(void)
|
||||
{
|
||||
s_ctx.current = SWITCH_NEUTRAL;
|
||||
s_ctx.candidate = SWITCH_NEUTRAL;
|
||||
s_ctx.candidate_count = 0U;
|
||||
return EPB_OK;
|
||||
}
|
||||
|
||||
void switch_step_10ms(SwitchRaw raw)
|
||||
{
|
||||
const SwitchState observed = raw_to_candidate(raw);
|
||||
|
||||
if (observed == s_ctx.candidate) {
|
||||
if (s_ctx.candidate_count < SWITCH_DEBOUNCE_SAMPLES) {
|
||||
++s_ctx.candidate_count;
|
||||
}
|
||||
} else {
|
||||
s_ctx.candidate = observed;
|
||||
s_ctx.candidate_count = 1U;
|
||||
}
|
||||
|
||||
if (s_ctx.candidate_count >= SWITCH_DEBOUNCE_SAMPLES) {
|
||||
s_ctx.current = s_ctx.candidate;
|
||||
}
|
||||
}
|
||||
|
||||
SwitchState switch_get_state(void)
|
||||
{
|
||||
return s_ctx.current;
|
||||
}
|
||||
Reference in New Issue
Block a user