Modify & transmit params via CAN
This commit is contained in:
@ -5,8 +5,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
CountedEnum(ParamType, size_t, PF_BBAL, PF_TC1, PF_TC2, PF_TORQUEMAP, PF_TEST1,
|
||||
PF_TEST2, PF_TEST3, PF_TEST4);
|
||||
|
||||
typedef struct {
|
||||
float bbal;
|
||||
unsigned tc1;
|
||||
@ -17,6 +23,11 @@ typedef struct {
|
||||
|
||||
extern Params params;
|
||||
|
||||
void params_init();
|
||||
void params_inc(ParamType param);
|
||||
void params_dec(ParamType param);
|
||||
void params_broadcast(ParamType param);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
11
Core/Inc/util.h
Normal file
11
Core/Inc/util.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef INC_UTIL_H
|
||||
#define INC_UTIL_H
|
||||
|
||||
// This is wacky preprocessor magic that allows us to count the number of
|
||||
// members of an enum. Unfortunately, it doesn't work with enum classes, so we
|
||||
// have to use C-style enums.
|
||||
#define CountedEnum(NAME, TYPE, ...) \
|
||||
typedef enum { __VA_ARGS__ } NAME; \
|
||||
static const size_t NAME##_COUNT = sizeof((int[]){__VA_ARGS__}) / sizeof(int);
|
||||
|
||||
#endif // INC_UTIL_H
|
||||
@ -1,6 +1,7 @@
|
||||
#ifndef __INC_VEHICLE_H
|
||||
#define __INC_VEHICLE_H
|
||||
|
||||
#include "params.h"
|
||||
#include "stw_defines.h"
|
||||
#include "tx_port.h"
|
||||
|
||||
@ -106,6 +107,8 @@ void vehicle_thread_entry(ULONG hfdcan_addr);
|
||||
|
||||
void vehicle_select_mission(Mission mission);
|
||||
|
||||
void vehicle_broadcast_param(ParamType param, int32_t value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user