From 84b4a487fc9f9fdebcabbe4f37c5e566633eaa11 Mon Sep 17 00:00:00 2001 From: Karlsson Winkels Date: Mon, 24 Mar 2025 20:35:14 +0100 Subject: [PATCH] mappings scaffold --- Software/Core/Inc/mappings.h | 95 ++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Software/Core/Inc/mappings.h diff --git a/Software/Core/Inc/mappings.h b/Software/Core/Inc/mappings.h new file mode 100644 index 0000000..cf7a2a8 --- /dev/null +++ b/Software/Core/Inc/mappings.h @@ -0,0 +1,95 @@ +#ifndef MAPPINGS_H +#define MAPPINGS_H + +#define CURRENT_NODE FRONT_NODE + +#define IGRID_L1 1 +#define IGRID_L2 2 +#define IGRID_L3 3 +#define IGRID_L4 4 +#define IGRID_L5 5 +#define IGRID_L6 6 +#define IGRID_L7 7 +#define IGRID_L8 8 +#define IGRID_L9 9 +#define IGRID_L10 10 +#define IGRID_L11 11 +#define IGRID_L12 12 +#define IGRID_L13 13 +#define IGRID_L14 14 +#define IGRID_L15 15 +#define IGRID_L16 16 + +#define IGRID_R1 17 +#define IGRID_R2 18 +#define IGRID_R3 19 +#define IGRID_R4 20 +#define IGRID_R5 21 +#define IGRID_R6 22 +#define IGRID_R7 23 +#define IGRID_R8 24 +#define IGRID_R9 25 +#define IGRID_R10 26 +#define IGRID_R11 27 +#define IGRID_R12 28 +#define IGRID_R13 29 +#define IGRID_R14 30 +#define IGRID_R15 31 +#define IGRID_R16 32 + +// +// Node agnostic mappings: +// + +// NUR BEISPIEL!!!! +#define GET_GPIO_FROM_IGRID(igrid) \ + ((igrid) == IGRID_L1 ? A16_Pin : \ + (igrid) == IGRID_L2 ? A15_Pin : \ + (igrid) == IGRID_L3 ? A14_Pin : \ + (igrid) == IGRID_L4 ? A13_Pin : \ + (igrid) == IGRID_L5 ? A12_Pin : \ + (igrid) == IGRID_L6 ? A11_Pin : \ + ) + +// AUCH NUR BEISPIEL!! +#define GET_ADC_CHANNEL_FROM_GPIO(gpio) \ + ((gpio) == A16_Pin ? ADC_CHANNEL_9 : \ + (gpio) == A15_Pin ? ADC_CHANNEL_3 : \ + (gpio) == A14_Pin ? ADC_CHANNEL_7 : \ + (gpio) == A13_Pin ? ADC_CHANNEL_4 : \ + (gpio) == A12_Pin ? ADC_CHANNEL_10 : \ + (gpio) == A11_Pin ? ADC_CHANNEL_11 : \ + (gpio) == A10_Pin ? ADC_CHANNEL_12 : \ + ) + +// ADC1 GPIO to ADC_Channel macro +#define GET_ADC_CHANNEL_FROM_IGRID(igrid) \ + GET_ADC_CHANNEL_FROM_GPIO(GET_GPIO_FROM_IGRID(igrid)) + +// Node specific mappings: +#if CURRENT_NODE == FRONT_NODE + + // Useful during development / for verification? + #define GET_NAME_FROM_IGRID(igrid) \ + ((igrid) == IGRID_L1 ? "WTPS1" : \ + (igrid) == IGRID_L2 ? "STS FL" : \ + ) + + // @Oskar nicht sicher wie man das am bestem macht, da ja nicht jeder pin ein input is der auf CAN kommt, also wonach man das ordnen will + #define CAN_START_BIT_FROM_IGRID(igrid) \ + ((igrid) == IGRID_L1 ? 0 : \ + (igrid) == IGRID_L2 ? 1 : \ + ) + + // Hier würde ich dann weitere Defines machen für alles was dann das CAN frame bildet, + // Start Bit, Bit count, etc, conversion factor (also von physischer größe die wir im + // code bestimmen zu bits), quasi ne DBC mit defines. Abrufen macht man das dann mit macros + +#elif CURRENT_NODE == REAR_NODE + +#endif + +#define FRONT_NODE 0 +#define REAR_NODE 1 + +#endif