sensor-node/Software/Core/Inc/mappings_o.h

133 lines
4.0 KiB
C

#ifndef MAPPINGS_H
#define MAPPINGS_H
#define SN_FRONT
//#define SN_REAR
#include <stdint.h>
typedef struct {
uint8_t en;
uint16_t can_id;
uint8_t start_bit;
char name[16];
float scale_factor; // (phys_max/can_scale)/adc_quants
} adc_ch_tx_cfg_t;
static adc_ch_tx_cfg_t CAN_TX_MAP[16] = {
/* 0 */ {.en = 1, .can_id = 0xD1, .start_bit = 16, .name = "SAS" , .scale_factor = ((6.5535/0.0001)/(2^12)) },
/* 1 */ {.en = 1, .can_id = 0xD2, .start_bit = 0, .name = "APPS1" , .scale_factor = ((6.5535/0.0001)/(2^12)) },
/* 2 */ {.en = 0, .can_id = 0x00, .start_bit = 0, .name = "_unused_", .scale_factor = 0 },
/* 3 */ {.en = 0, .can_id = 0x00, .start_bit = 0, .name = "_unused_", .scale_factor = 0 },
/* 4 */ {.en = 0, .can_id = 0x00, .start_bit = 0, .name = "_unused_", .scale_factor = 0 },
/* 5 */ {.en = 0, .can_id = 0x00, .start_bit = 0, .name = "_unused_", .scale_factor = 0 },
/* 6 */ {.en = 0, .can_id = 0x00, .start_bit = 0, .name = "_unused_", .scale_factor = 0 },
/* 7 */ {.en = 0, .can_id = 0x00, .start_bit = 0, .name = "_unused_", .scale_factor = 0 },
/* 8 */ {.en = 1, .can_id = 0xD2, .start_bit = 16, .name = "APPS2" , .scale_factor = ((6.5535/0.0001)/(2^12)) },
/* 9 */ {.en = 1, .can_id = 0xD3, .start_bit = 0, .name = "DS FL" , .scale_factor = ((6.5535/0.0001)/(2^12)) },
/* A */ {.en = 1, .can_id = 0xD1, .start_bit = 0, .name = "BPS F" , .scale_factor = ((6.5535/0.0001)/(2^12)) },
/* ... */
};
typedef enum {
L1 = 0,
L2 = 1,
L3 = 2,
L4 = 3,
L5 = 4,
L6 = 5,
L7 = 6,
L8 = 7,
R9 = 8,
RA = 9,
RB = 10,
RC = 11,
RD = 12,
RE = 13,
RF = 14,
R0 = 15,
} analog_pin_t;
typedef enum {
L9 = 0,
LA = 1,
LC = 2,
R5 = 3,
R6 = 4,
R7 = 5,
} digital_pin_t;
typedef enum {
LB = 0,
R8 = 1,
} freq_pin_t;
typedef enum {
NONE = 0, // Not used
AIN = 1, // Analog in
DIN = 2, // Digital in
FIN = 3, // Frequency in
DOUT = 4, // Digital out
POUT = 5, // PWM out
} signal_type_t;
typedef struct {
signal_type_t type;
// CAN INFO
uint8_t start; // start byte
uint8_t length; // in bytes
// PERIPHERY INFO
uint8_t channel; // ADC or PWM or Freq channel
uint8_t dio_map[8]; // Up to 8 bits mappable to DIOs
// METADATA
//float scale_factor; // (phys_max/can_scale)/adc_quants
char name[16];
} can_signal_t;
typedef struct {
uint16_t can_id;
uint8_t dlc;
uint8_t num_signals;
can_signal_t signals[8];
} can_pkt_t;
#ifdef SN_FRONT
static can_pkt_t CAN_SIGNAL_MAP[4] {
{
.can_id = 0x0D1, .dlc = 5, .num_signals = 2, .signals = {
{ .type = AIN, .start = 0, .length = 2, .channel = RB, .name = "BPS F" },
{ .type = AIN, .start = 2, .length = 2, .channel = L1, .name = "SAS" },
{ .type = DIN, .start = 4, .length = 1, .dio_map = {L9, LC, R5, R6, R7}, .name = "SAS" }
}
},
{
.can_id = 0x0D2, .dlc = 4, .num_signals = 2, .signals = {
{ .type = AIN, .start = 0, .length = 2, .channel = R9, .name = "APPS 1" },
{ .type = AIN, .start = 2, .length = 2, .channel = L2, .name = "APPS 2" }
}
},
{
.can_id = 0x0D3, .dlc = 8, .num_signals = 4, .signals = {
{ .type = AIN, .start = 0, .length = 2, .channel = RA, .name = "DS FL" },
{ .type = AIN, .start = 2, .length = 2, .channel = RC, .name = "DS FR" },
{ .type = AIN, .start = 4, .length = 2, .channel = RE, .name = "SLS FL" },
{ .type = AIN, .start = 6, .length = 2, .channel = R0, .name = "SLS FR" }
}
},
{
.can_id = 0x0D4, .dlc = 8, .num_signals = 4, .signals = {
{ .type = AIN, .start = 0, .length = 2, .channel = RD, .name = "BDTS FL" },
{ .type = AIN, .start = 2, .length = 2, .channel = RF, .name = "BDTS FR" },
{ .type = FIN, .start = 4, .length = 2, .channel = LB, .name = "WSS FL" },
{ .type = FIN, .start = 6, .length = 2, .channel = R8, .name = "WSS FR" }
}
}
};
#endif
#endif