Skip to content

Commit bf0ac46

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 0af4e8f commit bf0ac46

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/IOManagement.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ void initIO() {
3232
}
3333
}
3434

35-
void readIO()
36-
{
35+
void readIO() {
36+
digital_data.mc_on = digitalRead(MC_ON);
3737
digital_data.park_brake = digitalRead(PRK_BRK_TELEM);
3838

3939
acc_in = readADC(ADC_CHANNEL_11); // PA_6
@@ -54,11 +54,6 @@ void set_eco_mode(bool eco){
5454
digital_data.eco_mode = eco;
5555
}
5656

57-
void set_mc_on(bool mc_on){
58-
digital_data.mc_on = mc_on;
59-
digitalWrite(MC_ON, mc_on);
60-
}
61-
6257
void writeAccOut(float newAccOut) {
6358
acc_out = newAccOut;
6459
analogWrite(PA5, acc_out);

src/main.cpp

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

77
CANPDC canBus(CAN1, DEF);
88

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

0 commit comments

Comments
 (0)