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

Move Init of HAL SPI before IO_TARGET 1 for using it in SPI related m… #881

Open
wants to merge 1 commit into
base: dev2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/Repetier/src/PrinterTypes/Printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,11 @@ void Printer::setup() {
PULLUP(SDCARDDETECT, HIGH);
#endif
#endif

#ifndef NO_SPI
HAL::spiInit();
#endif

// Define io functions
#undef IO_TARGET
#define IO_TARGET 1
Expand Down
3 changes: 0 additions & 3 deletions src/Repetier/src/boards/SAMD51/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,6 @@ void HAL::setupTimer() {
SYNC_TIMER(SERVO_TIMER);

#endif
#ifndef NO_SPI
HAL::spiInit();
#endif
}

struct PWMChannel {
Expand Down
3 changes: 0 additions & 3 deletions src/Repetier/src/boards/due/HAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ void HAL::setupTimer() {
SERVO_TIMER->TC_CHANNEL[SERVO_TIMER_CHANNEL].TC_IDR = ~TC_IER_CPCS;
NVIC_EnableIRQ((IRQn_Type)SERVO_TIMER_IRQ);
#endif
#ifndef NO_SPI
HAL::spiInit();
#endif
}

struct PWMPin {
Expand Down
19 changes: 16 additions & 3 deletions src/Repetier/src/io/io_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@
#undef IO_SPI_HW
#undef IO_SPI_SW

#if IO_TARGET == 4 // class
#if IO_TARGET == 1 //

#define IO_SPI_HW(name, frequency, mode, msbfirst, csPin) \
name.init();
#define IO_SPI_SW(name, delayus, mode, msbfirst, csPin, clkPin, misoPin, mosiPin) \
name.init();

#elif IO_TARGET == 4 // class

/**
* Classes using SPI will get a super easy interface. To start a transfer they
Expand Down Expand Up @@ -81,9 +88,12 @@ class RFSpiBase {
class name##Class : public RFSpiBase { \
public: \
name##Class() { \
} \
virtual void init()\
{\
SET_OUTPUT(csPin); \
WRITE(csPin, 1); \
} \
}\
virtual void begin() { \
HAL::spiBegin(frequency, mode, msbfirst); \
WRITE(csPin, 0); \
Expand All @@ -106,6 +116,9 @@ class RFSpiBase {
\
public: \
name##Class() { \
} \
virtual void init()\
{\
SET_OUTPUT(csPin); \
WRITE(csPin, 1); \
SET_OUTPUT(clkPin); \
Expand All @@ -115,7 +128,7 @@ class RFSpiBase {
if (mosiPin >= 0) { \
HAL::pinMode(mosiPin, OUTPUT); \
} \
} \
}\
virtual void begin() { \
WRITE(clkPin, modeCPOL()); \
if (!modeCPHA()) { \
Expand Down