Use FastIO, sanity-check LPC SD options, apply formatting (#12231)
This commit is contained in:
parent
d015f746cc
commit
5580773191
@ -74,3 +74,11 @@
|
|||||||
|| MB(RAMPS_14_RE_ARM_SF))
|
|| MB(RAMPS_14_RE_ARM_SF))
|
||||||
#error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
|
#error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 1 < (ENABLED(LPC_SD_CUSTOM_CABLE) + ENABLED(LPC_SD_LCD) + ENABLED(LPC_SD_ONBOARD))
|
||||||
|
#error "Enable only one of LPC_SD_CUSTOM_CABLE, LPC_SD_LCD, or LPC_SD_ONBOARD."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1 < (ENABLED(USB_SD_DISABLED) + ENABLED(USB_SD_ONBOARD))
|
||||||
|
#error "Enable only one of USB_SD_DISABLED or USB_SD_ONBOARD."
|
||||||
|
#endif
|
||||||
|
@ -56,21 +56,25 @@ void HAL_init() {
|
|||||||
//debug_frmwrk_init();
|
//debug_frmwrk_init();
|
||||||
//_DBG("\n\nDebug running\n");
|
//_DBG("\n\nDebug running\n");
|
||||||
// Initialise the SD card chip select pins as soon as possible
|
// Initialise the SD card chip select pins as soon as possible
|
||||||
#ifdef SS_PIN
|
#if PIN_EXISTS(SS)
|
||||||
digitalWrite(SS_PIN, HIGH);
|
WRITE(SS_PIN, HIGH);
|
||||||
pinMode(SS_PIN, OUTPUT);
|
SET_OUTPUT(SS_PIN);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ONBOARD_SD_CS
|
|
||||||
digitalWrite(ONBOARD_SD_CS, HIGH);
|
#if defined(ONBOARD_SD_CS) && ONBOARD_SD_CS > -1
|
||||||
pinMode(ONBOARD_SD_CS, OUTPUT);
|
WRITE(ONBOARD_SD_CS, HIGH);
|
||||||
|
SET_OUTPUT(ONBOARD_SD_CS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USB_Init(); // USB Initialization
|
USB_Init(); // USB Initialization
|
||||||
USB_Connect(FALSE); // USB clear connection
|
USB_Connect(FALSE); // USB clear connection
|
||||||
delay(1000); // Give OS time to notice
|
delay(1000); // Give OS time to notice
|
||||||
USB_Connect(TRUE);
|
USB_Connect(TRUE);
|
||||||
#ifndef USB_SD_DISABLED
|
|
||||||
|
#if DISABLED(USB_SD_DISABLED)
|
||||||
MSC_SD_Init(0); // Enable USB SD card access
|
MSC_SD_Init(0); // Enable USB SD card access
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const millis_t usb_timeout = millis() + 2000;
|
const millis_t usb_timeout = millis() + 2000;
|
||||||
while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
|
while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
|
||||||
delay(50);
|
delay(50);
|
||||||
@ -94,7 +98,7 @@ void HAL_init() {
|
|||||||
|
|
||||||
// HAL idle task
|
// HAL idle task
|
||||||
void HAL_idletask(void) {
|
void HAL_idletask(void) {
|
||||||
#if ENABLED(SDSUPPORT) && defined(SHARED_SD_CARD)
|
#if ENABLED(SDSUPPORT) && ENABLED(SHARED_SD_CARD)
|
||||||
// If Marlin is using the SD card we need to lock it to prevent access from
|
// If Marlin is using the SD card we need to lock it to prevent access from
|
||||||
// a PC via USB.
|
// a PC via USB.
|
||||||
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
|
// Other HALs use IS_SD_PRINTING() and IS_SD_FILE_OPEN() to check for access but
|
||||||
|
@ -85,8 +85,8 @@ void HAL_timer_start(const uint8_t timer_num, const uint32_t frequency) {
|
|||||||
timerConfig[0].IRQ_Id = TIM5_IRQn;
|
timerConfig[0].IRQ_Id = TIM5_IRQn;
|
||||||
timerConfig[0].callback = (uint32_t)TC5_Handler;
|
timerConfig[0].callback = (uint32_t)TC5_Handler;
|
||||||
HAL_NVIC_SetPriority(timerConfig[0].IRQ_Id, 1, 0);
|
HAL_NVIC_SetPriority(timerConfig[0].IRQ_Id, 1, 0);
|
||||||
pinMode(STEPPER_ENABLE_PIN,OUTPUT);
|
SET_OUTPUT(STEPPER_ENABLE_PIN);
|
||||||
digitalWrite(STEPPER_ENABLE_PIN,LOW);
|
WRITE(STEPPER_ENABLE_PIN);
|
||||||
break;
|
break;
|
||||||
case TEMP_TIMER_NUM:
|
case TEMP_TIMER_NUM:
|
||||||
//TEMP TIMER TIM7 // any available 16bit Timer (1 already used for PWM)
|
//TEMP TIMER TIM7 // any available 16bit Timer (1 already used for PWM)
|
||||||
|
@ -190,7 +190,7 @@ void TMC26XStepper::start() {
|
|||||||
pinMode(step_pin, OUTPUT);
|
pinMode(step_pin, OUTPUT);
|
||||||
pinMode(dir_pin, OUTPUT);
|
pinMode(dir_pin, OUTPUT);
|
||||||
pinMode(cs_pin, OUTPUT);
|
pinMode(cs_pin, OUTPUT);
|
||||||
//pinMode(STEPPER_ENABLE_PIN, OUTPUT);
|
//SET_OUTPUT(STEPPER_ENABLE_PIN);
|
||||||
digitalWrite(step_pin, LOW);
|
digitalWrite(step_pin, LOW);
|
||||||
digitalWrite(dir_pin, LOW);
|
digitalWrite(dir_pin, LOW);
|
||||||
digitalWrite(cs_pin, HIGH);
|
digitalWrite(cs_pin, HIGH);
|
||||||
|
@ -187,14 +187,15 @@
|
|||||||
// is powered on to enable SD access.
|
// is powered on to enable SD access.
|
||||||
|
|
||||||
#if ENABLED(LPC_SD_LCD)
|
#if ENABLED(LPC_SD_LCD)
|
||||||
|
|
||||||
#define SCK_PIN P0_15
|
#define SCK_PIN P0_15
|
||||||
#define MISO_PIN P0_17
|
#define MISO_PIN P0_17
|
||||||
#define MOSI_PIN P0_18
|
#define MOSI_PIN P0_18
|
||||||
#define SS_PIN P1_23 // Chip select for SD card used by Marlin
|
#define SS_PIN P1_23 // Chip select for SD card used by Marlin
|
||||||
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(LPC_SD_ONBOARD)
|
#elif ENABLED(LPC_SD_ONBOARD)
|
||||||
|
|
||||||
#if ENABLED(USB_SD_ONBOARD)
|
#if ENABLED(USB_SD_ONBOARD)
|
||||||
// When sharing the SD card with a PC we want the menu options to
|
// When sharing the SD card with a PC we want the menu options to
|
||||||
// mount/unmount the card and refresh it. So we disable card detect.
|
// mount/unmount the card and refresh it. So we disable card detect.
|
||||||
@ -206,4 +207,5 @@
|
|||||||
#define MOSI_PIN P0_09
|
#define MOSI_PIN P0_09
|
||||||
#define SS_PIN P0_06 // Chip select for SD card used by Marlin
|
#define SS_PIN P0_06 // Chip select for SD card used by Marlin
|
||||||
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -196,16 +196,17 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* There are a number of configurations available for the SBase SD card reader.
|
* There are a number of configurations available for the SBase SD card reader.
|
||||||
* A custom cable can be used to allow access to the LCD based SD card.
|
* - A custom cable can be used to allow access to the LCD based SD card.
|
||||||
* A standard cable can be used for access to the LCD SD card (but no SD detect).
|
* - A standard cable can be used for access to the LCD SD card (but no SD detect).
|
||||||
* The onboard SD card can be used and optionally shared with a PC via USB.
|
* - The onboard SD card can be used and optionally shared with a PC via USB.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#define LPC_SD_CUSTOM_CABLE // Use a custom cable to access the SD
|
//#define LPC_SD_CUSTOM_CABLE // Use a custom cable to access the SD
|
||||||
//#define LPC_SD_LCD // Marlin uses the SD drive attached to the LCD
|
//#define LPC_SD_LCD // Marlin uses the SD drive attached to the LCD
|
||||||
#define LPC_SD_ONBOARD // Marlin uses the SD drive attached to the control board
|
#define LPC_SD_ONBOARD // Marlin uses the SD drive attached to the control board
|
||||||
|
|
||||||
#ifdef LPC_SD_CUSTOM_CABLE
|
#if ENABLED(LPC_SD_CUSTOM_CABLE)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom cable is needed. See the README file in the
|
* A custom cable is needed. See the README file in the
|
||||||
* Marlin\src\config\examples\Mks\Sbase directory
|
* Marlin\src\config\examples\Mks\Sbase directory
|
||||||
@ -226,27 +227,24 @@
|
|||||||
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
||||||
#define LPC_SOFTWARE_SPI // With a custom cable we need software SPI because the
|
#define LPC_SOFTWARE_SPI // With a custom cable we need software SPI because the
|
||||||
// selected pins are not on a hardware SPI controller
|
// selected pins are not on a hardware SPI controller
|
||||||
#endif
|
#elif ENABLED(LPC_SD_LCD)
|
||||||
|
|
||||||
#ifdef LPC_SD_LCD
|
|
||||||
// use standard cable and header, SPI and SD detect sre shared with on-board SD card
|
// use standard cable and header, SPI and SD detect sre shared with on-board SD card
|
||||||
// hardware SPI is used for both SD cards. The detect pin is shred between the
|
// hardware SPI is used for both SD cards. The detect pin is shred between the
|
||||||
// LCD and onboard SD readers so we disable it.
|
// LCD and onboard SD readers so we disable it.
|
||||||
#undef SD_DETECT_PIN
|
|
||||||
#define SCK_PIN P0_07
|
#define SCK_PIN P0_07
|
||||||
#define MISO_PIN P0_08
|
#define MISO_PIN P0_08
|
||||||
#define MOSI_PIN P0_09
|
#define MOSI_PIN P0_09
|
||||||
#define SS_PIN P0_28 // Chip select for SD card used by Marlin
|
#define SS_PIN P0_28 // Chip select for SD card used by Marlin
|
||||||
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LPC_SD_ONBOARD
|
#elif ENABLED(LPC_SD_ONBOARD)
|
||||||
|
|
||||||
// The external SD card is not used. Hardware SPI is used to access the card.
|
// The external SD card is not used. Hardware SPI is used to access the card.
|
||||||
#ifdef USB_SD_ONBOARD
|
#if ENABLED(USB_SD_ONBOARD)
|
||||||
// When sharing the SD card with a PC we want the menu options to
|
// When sharing the SD card with a PC we want the menu options to
|
||||||
// mount/unmount the card and refresh it. So we disable card detect.
|
// mount/unmount the card and refresh it. So we disable card detect.
|
||||||
#define SHARED_SD_CARD
|
#define SHARED_SD_CARD
|
||||||
#undef SD_DETECT_PIN
|
|
||||||
#else
|
#else
|
||||||
#define SD_DETECT_PIN P0_27
|
#define SD_DETECT_PIN P0_27
|
||||||
#endif
|
#endif
|
||||||
@ -255,6 +253,7 @@
|
|||||||
#define MOSI_PIN P0_09
|
#define MOSI_PIN P0_09
|
||||||
#define SS_PIN P0_06 // Chip select for SD card used by Marlin
|
#define SS_PIN P0_06 // Chip select for SD card used by Marlin
|
||||||
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -286,6 +285,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_DRIVER(TMC2208)
|
#if HAS_DRIVER(TMC2208)
|
||||||
// The shortage of pins becomes apparent.
|
// The shortage of pins becomes apparent.
|
||||||
// Worst case you may have to give up the LCD
|
// Worst case you may have to give up the LCD
|
||||||
|
@ -363,23 +363,23 @@
|
|||||||
#define ENET_TXD0 P1_00 // (78) J12-11
|
#define ENET_TXD0 P1_00 // (78) J12-11
|
||||||
#define ENET_TXD1 P1_01 // (79) J12-12
|
#define ENET_TXD1 P1_01 // (79) J12-12
|
||||||
|
|
||||||
|
|
||||||
//#define USB_SD_DISABLED
|
//#define USB_SD_DISABLED
|
||||||
#define USB_SD_ONBOARD // Provide the onboard SD card to the host as a USB mass storage device
|
#define USB_SD_ONBOARD // Provide the onboard SD card to the host as a USB mass storage device
|
||||||
|
|
||||||
//#define LPC_SD_LCD // Marlin uses the SD drive attached to the LCD
|
//#define LPC_SD_LCD // Marlin uses the SD drive attached to the LCD
|
||||||
#define LPC_SD_ONBOARD // Marlin uses the SD drive on the control board
|
#define LPC_SD_ONBOARD // Marlin uses the SD drive on the control board
|
||||||
|
|
||||||
#ifdef LPC_SD_LCD
|
#if ENABLED(LPC_SD_LCD)
|
||||||
|
|
||||||
#define SCK_PIN P0_15
|
#define SCK_PIN P0_15
|
||||||
#define MISO_PIN P0_17
|
#define MISO_PIN P0_17
|
||||||
#define MOSI_PIN P0_18
|
#define MOSI_PIN P0_18
|
||||||
#define SS_PIN P1_23 // Chip select for SD card used by Marlin
|
#define SS_PIN P1_23 // Chip select for SD card used by Marlin
|
||||||
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef LPC_SD_ONBOARD
|
#elif ENABLED(LPC_SD_ONBOARD)
|
||||||
#ifdef USB_SD_ONBOARD
|
|
||||||
|
#if ENABLED(USB_SD_ONBOARD)
|
||||||
// When sharing the SD card with a PC we want the menu options to
|
// When sharing the SD card with a PC we want the menu options to
|
||||||
// mount/unmount the card and refresh it. So we disable card detect.
|
// mount/unmount the card and refresh it. So we disable card detect.
|
||||||
#define SHARED_SD_CARD
|
#define SHARED_SD_CARD
|
||||||
@ -390,10 +390,11 @@
|
|||||||
#define MOSI_PIN P0_09
|
#define MOSI_PIN P0_09
|
||||||
#define SS_PIN P0_06 // Chip select for SD card used by Marlin
|
#define SS_PIN P0_06 // Chip select for SD card used by Marlin
|
||||||
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
#define ONBOARD_SD_CS P0_06 // Chip select for "System" SD card
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fast PWMS
|
* Fast PWMs
|
||||||
*
|
*
|
||||||
* The LPC1768's hardware PWM controller has 6 channels. Each channel
|
* The LPC1768's hardware PWM controller has 6 channels. Each channel
|
||||||
* can be setup to either control a dedicated pin directly or to generate
|
* can be setup to either control a dedicated pin directly or to generate
|
||||||
@ -418,7 +419,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* special pins
|
* Special pins
|
||||||
* P1_30 (37) - not 5V tolerant
|
* P1_30 (37) - not 5V tolerant
|
||||||
* P1_31 (49) - not 5V tolerant
|
* P1_31 (49) - not 5V tolerant
|
||||||
* P0_27 (57) - open collector
|
* P0_27 (57) - open collector
|
||||||
|
Loading…
Reference in New Issue
Block a user