Revision 8c99e03a devices/PowerManagement/PowerManagement.cpp

View differences:

devices/PowerManagement/PowerManagement.cpp
57 57
        return RDY_OK;
58 58
      }
59 59
      break;
60
    case CAN::REQUEST_CHARGING_OVER_PIN:
61
      if (frame->DLC == 1) {
62
        // Error handling 
63
        // TODO: Error Handling, for now just set the given value
64
        this->powerStatus.charging_flags.content.diwheeldrive_enable_power_path = frame->data8[0];
65
        return RDY_OK;
66
      }
67
      break;
60 68

  
61 69
    default:
62 70
      break;
......
69 77

  
70 78
  // update charger status
71 79
  this->powerStatus.charging_flags.content.powermanagement_plugged_in = global.ltc4412.isPluggedIn();
80
  // this->powerStatus.charging_flags.content.powermanagement_plugged_in = (palReadPad((GPIO_TypeDef*)GPIOC, GPIOC_PATHDC) == PAL_HIGH); 
72 81

  
73 82
  // update fuel gauges values
74 83
  const BQ27500::Driver::UpdateData* power[2] {
......
115 124
  return 0;
116 125
}
117 126

  
127
void PowerManagement::setStrategy(uint8_t strategy){
128
  CANTxFrame frame;
129
  chprintf((BaseSequentialStream*) &SD1, "Message Triggered!\n");
130
  // global.triggerCan = false;
131
  frame.SID = 0;
132
  this->encodeDeviceId(&frame, CAN::SET_LINE_FOLLOW_MSG);
133
  frame.data8[0] = strategy;
134
  frame.DLC = 1;
135
  this->transmitMessage(&frame);
136
}
137

  
118 138
void PowerManagement::periodicBroadcast() {
119 139
  CANTxFrame frame;
120 140
  if (this->bc_counter % 10 == 0) {
......
127 147
    frame.DLC = 6;
128 148
    this->transmitMessage(&frame);
129 149
  }
150

  
130 151
  for (int i = 0; i < 8; i++) {
131 152
    frame.SID = 0;
132 153
    this->encodeDeviceId(&frame, CAN::PROXIMITY_RING_ID(i));

Also available in: Unified diff