Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/FanControlSystem #267

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Core/Inc/control.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef CONTROL_H
#define CONTROL_H

#include "pdu.h"
#include "can.h"

#define CONTROL_CANID_FANBATTBOX 0xAAA

extern osThreadId_t control_handle;
extern const osThreadAttr_t control_attributes;

typedef struct {
pdu_t *pdu;
} control_args_t;

void vControl(void *param);

void control_fanbattbox_record(can_msg_t args);

int eval_fanbattbox_state();

#endif
7 changes: 7 additions & 0 deletions Core/Src/can_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include "dti.h"
#include "fault.h"
#include "steeringio.h"
#include "control.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#define CAN_MSG_QUEUE_SIZE 50 /* messages */

Expand Down Expand Up @@ -153,6 +157,9 @@ void vCanReceive(void *pv_params)
case STEERING_CANID_IO:
steeringio_update(msg);
break;
case CONTROL_CANID_FANBATTBOX:
control_fanbattbox_record(msg);
break;
default:
break;
}
Expand Down
31 changes: 31 additions & 0 deletions Core/Src/control.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "control.h"
#include "pdu.h"

osThreadId_t control_handle;
const osThreadAttr_t control_attributes = {
.name = "Control",
.stack_size = 128 * 8,
.priority = (osPriority_t)osPriorityRealtime,
};

static int fanBattBoxState = 0;

void vControl(void *param)
{
control_args_t *args = (control_args_t *)param;
dnakhooda marked this conversation as resolved.
Show resolved Hide resolved

for (;;) {
write_fan_battbox(args->pdu, fanBattBoxState);

osDelay(1000);
}
}

void control_fanbattbox_record(can_msg_t msg)
{
if (msg.data > 0) {
dnakhooda marked this conversation as resolved.
Show resolved Hide resolved
fanBattBoxState = 1;
} else {
fanBattBoxState = 0;
}
}
Loading
Loading