mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-23 20:18:52 +00:00
STM32F1 SPI1 bugfix (#14679)
This commit is contained in:
parent
5b2fd3ad86
commit
a38b9da672
@ -201,6 +201,11 @@ void HAL_init(void) {
|
||||
#if PIN_EXISTS(LED)
|
||||
OUT_WRITE(LED_PIN, LOW);
|
||||
#endif
|
||||
#if PIN_EXISTS(USB_CONNECT)
|
||||
OUT_WRITE(USB_CONNECT_PIN, !USB_CONNECT_INVERTING); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
OUT_WRITE(USB_CONNECT_PIN, USB_CONNECT_INVERTING);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* VGPV Done with defines
|
||||
|
@ -79,15 +79,25 @@ void spiBegin() {
|
||||
* @details
|
||||
*/
|
||||
void spiInit(uint8_t spiRate) {
|
||||
/**
|
||||
* STM32F1 APB1 = 72MHz, APB2 = 36MHz, max SPI speed of this MCU if 18Mhz
|
||||
* STM32F1 has 3 SPI ports, SPI1 in APB1, SPI2/SPI3 in APB2
|
||||
* so the minimum prescale of SPI1 is DIV4, SPI2/SPI3 is DIV2
|
||||
*/
|
||||
#if SPI_DEVICE == 1
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV4
|
||||
#else
|
||||
#define SPI_CLOCK_MAX SPI_CLOCK_DIV2
|
||||
#endif
|
||||
uint8_t clock;
|
||||
switch (spiRate) {
|
||||
case SPI_FULL_SPEED: clock = SPI_CLOCK_DIV2 ; break;
|
||||
case SPI_FULL_SPEED: clock = SPI_CLOCK_MAX ; break;
|
||||
case SPI_HALF_SPEED: clock = SPI_CLOCK_DIV4 ; break;
|
||||
case SPI_QUARTER_SPEED: clock = SPI_CLOCK_DIV8 ; break;
|
||||
case SPI_EIGHTH_SPEED: clock = SPI_CLOCK_DIV16; break;
|
||||
case SPI_SPEED_5: clock = SPI_CLOCK_DIV32; break;
|
||||
case SPI_SPEED_6: clock = SPI_CLOCK_DIV64; break;
|
||||
default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
|
||||
default: clock = SPI_CLOCK_DIV2; // Default from the SPI library
|
||||
}
|
||||
SPI.setModule(SPI_DEVICE);
|
||||
SPI.begin();
|
||||
|
@ -148,7 +148,7 @@
|
||||
//
|
||||
// USB connect control
|
||||
//
|
||||
#define USB_CONNECT PC13
|
||||
#define USB_CONNECT_PIN PC13
|
||||
#define USB_CONNECT_INVERTING false
|
||||
|
||||
#define SD_DETECT_PIN PC4
|
||||
|
@ -19,6 +19,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef TARGET_STM32F1
|
||||
#error "Oops! Select an STM32F1 board in 'Tools > Board.'"
|
||||
@ -102,7 +103,7 @@
|
||||
//
|
||||
// USB connect control
|
||||
//
|
||||
#define USB_CONNECT PC13
|
||||
#define USB_CONNECT_PIN PC13
|
||||
#define USB_CONNECT_INVERTING false
|
||||
|
||||
#define SD_DETECT_PIN PC4
|
||||
|
Loading…
Reference in New Issue
Block a user