Skip to content

Commit e9595fb

Browse files
committed
WORKING: IOManagement input pins are correct
* Change IOManagement timer to TIM2 to not conflict with motor_control * Remove remnants of MC_ON being an output pin * Add testing code in main.cpp for IOManagement inputs
1 parent 2344c28 commit e9595fb

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/IOManagement.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ volatile float current_in_telem = 0;
1212
volatile float brake_pressure_telem = 0;
1313

1414
// Ticker to poll input readings at fixed rate
15-
STM32TimerInterrupt IOTimer(TIM7);
15+
STM32TimerInterrupt IOTimer(TIM2);
1616

1717
void initIO() {
1818
pinMode(MCU_DIR, OUTPUT);
@@ -35,6 +35,7 @@ void initIO() {
3535

3636
void readIO()
3737
{
38+
digital_data.mc_on = digitalRead(MC_ON);
3839
digital_data.mc_speed_sig = digitalRead(MCU_SPEED_SIG);
3940
digital_data.park_brake = digitalRead(PRK_BRK_TELEM);
4041

@@ -56,11 +57,6 @@ void set_eco_mode(bool eco){
5657
digital_data.eco_mode = eco;
5758
}
5859

59-
void set_mc_on(bool mc_on){
60-
digital_data.mc_on = mc_on;
61-
digitalWrite(MC_ON, mc_on);
62-
}
63-
6460
void writeAccOut(float newAccOut) {
6561
acc_out = newAccOut;
6662
analogWrite(PA5, acc_out);

src/main.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
CANPDC canBus(CAN1, DEF);
77

8+
uint8_t counter = 0;
9+
810
void setup() {
911
Serial.begin(115200);
1012
initIO();
@@ -13,4 +15,23 @@ void setup() {
1315
void loop() {
1416
canBus.sendPDCData();
1517
canBus.runQueue(DATA_SEND_PERIOD);
18+
counter++;
19+
if (counter >= 10) {
20+
counter = 0;
21+
22+
// clear the screen
23+
printf("\e[1;1H\e[2J");
24+
25+
// digital inputs
26+
printf("mc_on: %d\n", digital_data.mc_on);
27+
printf("park_brake: %d\n", digital_data.park_brake);
28+
29+
// analog inputs
30+
printf("acc_in: %f\n", acc_in);
31+
printf("12V: %f\n", lv_12V_telem);
32+
printf("5V: %f\n", lv_5V_telem);
33+
printf("5V current: %f\n", lv_5V_current);
34+
printf("current in: %f\n", current_in_telem);
35+
printf("brake pressure: %f\n", brake_pressure_telem);
36+
}
1637
}

0 commit comments

Comments
 (0)