Skip to content

Commit

Permalink
Huawei CAN: use SpiManager to claim SPI bus
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed Oct 6, 2024
1 parent 1812e6e commit f746b04
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Huawei_can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "PowerLimiter.h"
#include "Configuration.h"
#include "Battery.h"
#include <SPI.h>
#include "SpiManager.h"
#include <mcp_can.h>

#include <freertos/FreeRTOS.h>
Expand All @@ -35,7 +35,12 @@ void HuaweiCanCommunicationTask(void* parameter) {

bool HuaweiCanCommClass::init(uint8_t huawei_miso, uint8_t huawei_mosi, uint8_t huawei_clk,
uint8_t huawei_irq, uint8_t huawei_cs, uint32_t frequency) {
SPI = new SPIClass(HSPI);

auto spi_bus = SpiManagerInst.claim_bus_arduino();
if (!spi_bus) { return false; }

SPI = new SPIClass(*spi_bus);

SPI->begin(huawei_clk, huawei_miso, huawei_mosi, huawei_cs);
pinMode(huawei_cs, OUTPUT);
digitalWrite(huawei_cs, HIGH);
Expand Down

0 comments on commit f746b04

Please sign in to comment.