Add CAN send logic and DIO mapping

This commit is contained in:
2025-03-30 10:47:13 +02:00
parent eb994ad693
commit c06d273f9f
4 changed files with 108 additions and 15 deletions

View File

@ -35,7 +35,7 @@ extern "C" {
extern ADC_HandleTypeDef hadc1;
/* USER CODE BEGIN Private defines */
#define NUM_ADC_PINS 16
/* USER CODE END Private defines */
void MX_ADC1_Init(void);

View File

@ -34,6 +34,20 @@ extern "C" {
/* USER CODE BEGIN Private defines */
#define NUM_DIO_PINS 6
static struct {
GPIO_TypeDef* port;
uint16_t pin;
} DIO_PIN_MAP[NUM_DIO_PINS] = {
/* 0 */ { .port = D1_IC_GPIO_Port, .pin = D1_IC_Pin},
/* 1 */ { .port = D2_GPIO_Port, .pin = D2_Pin},
/* 2 */ { .port = D3_GPIO_Port, .pin = D3_Pin},
/* 3 */ { .port = D4_IC_GPIO_Port, .pin = D4_IC_Pin},
/* 4 */ { .port = D5_GPIO_Port, .pin = D5_Pin},
/* 5 */ { .port = D6_GPIO_Port, .pin = D6_Pin},
};
/* USER CODE END Private defines */
void MX_GPIO_Init(void);

View File

@ -3,7 +3,7 @@
// CHOOSE ONE, comment the other or comment both and use -D SN_FRONT
#define SN_FRONT
#define SN_REAR
//#define SN_REAR
#include <stdint.h>
@ -72,11 +72,12 @@ typedef struct {
can_signal_t signals[9];
} can_pkt_t;
#define NUM_TX_PKT 4
#define ADQ (1<<12)
#ifdef SN_FRONT
static can_pkt_t CAN_SIGNAL_MAP[4] {
static can_pkt_t CAN_SIGNAL_MAP[NUM_TX_PKT] = {
{
.can_id = 0x0D1, .dlc = 3, .num_signals = 7, .period = 100, .signals = {
{ .type = DIN, .channel = R5, .start = 0, .length = 1, .factor = 1., .name = "LS L" },
@ -117,7 +118,7 @@ static can_pkt_t CAN_SIGNAL_MAP[4] {
#ifdef SN_REAR
static can_pkt_t CAN_SIGNAL_MAP[4] {
static can_pkt_t CAN_SIGNAL_MAP[NUM_TX_PKT] = {
{
.can_id = 0x0D2, .dlc = 7, .num_signals = 9, .period = 100, .signals = {
{ .type = DIN, .channel = L9, .start = 0, .length = 1, .factor = 1., .name = "ExtTSOn" },