Use FastIO, sanity-check LPC SD options, apply formatting (#12231)
This commit is contained in:
parent
d015f746cc
commit
5580773191
|
@ -76,14 +76,14 @@ void Servo_Handler(timer16_Sequence_t timer, Tc *tc, uint8_t channel) {
|
|||
tc->TC_CHANNEL[channel].TC_SR;
|
||||
if (Channel[timer] < 0)
|
||||
tc->TC_CHANNEL[channel].TC_CCR |= TC_CCR_SWTRG; // channel set to -1 indicated that refresh interval completed so reset the timer
|
||||
else if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive)
|
||||
digitalWrite(SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
|
||||
else if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && SERVO(timer, Channel[timer]).Pin.isActive)
|
||||
digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
|
||||
|
||||
Channel[timer]++; // increment to the next channel
|
||||
if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
|
||||
tc->TC_CHANNEL[channel].TC_RA = tc->TC_CHANNEL[channel].TC_CV + SERVO(timer,Channel[timer]).ticks;
|
||||
if (SERVO(timer,Channel[timer]).Pin.isActive) // check if activated
|
||||
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
|
||||
digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // its an active channel so pulse it high
|
||||
}
|
||||
else {
|
||||
// finished all channels so wait for the refresh period to expire before starting over
|
||||
|
|
|
@ -74,3 +74,11 @@
|
|||
|| MB(RAMPS_14_RE_ARM_SF))
|
||||
#error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 require TMC_USE_SW_SPI"
|
||||
#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();
|
||||
//_DBG("\n\nDebug running\n");
|
||||
// Initialise the SD card chip select pins as soon as possible
|
||||
#ifdef SS_PIN
|
||||
digitalWrite(SS_PIN, HIGH);
|
||||
pinMode(SS_PIN, OUTPUT);
|
||||
#if PIN_EXISTS(SS)
|
||||
WRITE(SS_PIN, HIGH);
|
||||
SET_OUTPUT(SS_PIN);
|
||||
#endif
|
||||
#ifdef ONBOARD_SD_CS
|
||||
digitalWrite(ONBOARD_SD_CS, HIGH);
|
||||
pinMode(ONBOARD_SD_CS, OUTPUT);
|
||||
|
||||
#if defined(ONBOARD_SD_CS) && ONBOARD_SD_CS > -1
|
||||
WRITE(ONBOARD_SD_CS, HIGH);
|
||||
SET_OUTPUT(ONBOARD_SD_CS);
|
||||
#endif
|
||||
|
||||
USB_Init(); // USB Initialization
|
||||
USB_Connect(FALSE); // USB clear connection
|
||||
delay(1000); // Give OS time to notice
|
||||
USB_Connect(TRUE);
|
||||
#ifndef USB_SD_DISABLED
|
||||
|
||||
#if DISABLED(USB_SD_DISABLED)
|
||||
MSC_SD_Init(0); // Enable USB SD card access
|
||||
#endif
|
||||
|
||||
const millis_t usb_timeout = millis() + 2000;
|
||||
while (!USB_Configuration && PENDING(millis(), usb_timeout)) {
|
||||
delay(50);
|
||||
|
@ -94,7 +98,7 @@ void HAL_init() {
|
|||
|
||||
// HAL idle task
|
||||
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
|
||||
// a PC via USB.
|
||||
// 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].callback = (uint32_t)TC5_Handler;
|
||||
HAL_NVIC_SetPriority(timerConfig[0].IRQ_Id, 1, 0);
|
||||
pinMode(STEPPER_ENABLE_PIN,OUTPUT);
|
||||
digitalWrite(STEPPER_ENABLE_PIN,LOW);
|
||||
SET_OUTPUT(STEPPER_ENABLE_PIN);
|
||||
WRITE(STEPPER_ENABLE_PIN);
|
||||
break;
|
||||
case TEMP_TIMER_NUM:
|
||||
//TEMP TIMER TIM7 // any available 16bit Timer (1 already used for PWM)
|
||||
|
|
|
@ -190,7 +190,7 @@ void TMC26XStepper::start() {
|
|||
pinMode(step_pin, OUTPUT);
|
||||
pinMode(dir_pin, OUTPUT);
|
||||
pinMode(cs_pin, OUTPUT);
|
||||
//pinMode(STEPPER_ENABLE_PIN, OUTPUT);
|
||||
//SET_OUTPUT(STEPPER_ENABLE_PIN);
|
||||
digitalWrite(step_pin, LOW);
|
||||
digitalWrite(dir_pin, LOW);
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
|
@ -887,7 +887,7 @@ inline void TMC26XStepper::send262(uint32_t datagram) {
|
|||
//}
|
||||
|
||||
//select the TMC driver
|
||||
digitalWrite(cs_pin,LOW);
|
||||
digitalWrite(cs_pin, LOW);
|
||||
|
||||
//ensure that only valid bist are set (0-19)
|
||||
//datagram &=REGISTER_BIT_PATTERN;
|
||||
|
@ -916,7 +916,7 @@ inline void TMC26XStepper::send262(uint32_t datagram) {
|
|||
#endif
|
||||
|
||||
//deselect the TMC chip
|
||||
digitalWrite(cs_pin,HIGH);
|
||||
digitalWrite(cs_pin, HIGH);
|
||||
|
||||
//restore the previous SPI mode if neccessary
|
||||
//if the mode is not correct set it to mode 3
|
||||
|
|
|
@ -187,14 +187,15 @@
|
|||
// is powered on to enable SD access.
|
||||
|
||||
#if ENABLED(LPC_SD_LCD)
|
||||
|
||||
#define SCK_PIN P0_15
|
||||
#define MISO_PIN P0_17
|
||||
#define MOSI_PIN P0_18
|
||||
#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
|
||||
#endif
|
||||
|
||||
#if ENABLED(LPC_SD_ONBOARD)
|
||||
#elif ENABLED(LPC_SD_ONBOARD)
|
||||
|
||||
#if ENABLED(USB_SD_ONBOARD)
|
||||
// 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.
|
||||
|
@ -206,4 +207,5 @@
|
|||
#define MOSI_PIN P0_09
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
|
|
@ -196,16 +196,17 @@
|
|||
|
||||
/*
|
||||
* 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 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.
|
||||
* - 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).
|
||||
* - 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_LCD // Marlin uses the SD drive attached to the LCD
|
||||
#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
|
||||
* Marlin\src\config\examples\Mks\Sbase directory
|
||||
|
@ -226,27 +227,24 @@
|
|||
#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
|
||||
// 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
|
||||
// hardware SPI is used for both SD cards. The detect pin is shred between the
|
||||
// LCD and onboard SD readers so we disable it.
|
||||
#undef SD_DETECT_PIN
|
||||
#define SCK_PIN P0_07
|
||||
#define MISO_PIN P0_08
|
||||
#define MOSI_PIN P0_09
|
||||
#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
|
||||
#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.
|
||||
#ifdef USB_SD_ONBOARD
|
||||
#if ENABLED(USB_SD_ONBOARD)
|
||||
// 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.
|
||||
#define SHARED_SD_CARD
|
||||
#undef SD_DETECT_PIN
|
||||
#else
|
||||
#define SD_DETECT_PIN P0_27
|
||||
#endif
|
||||
|
@ -255,6 +253,7 @@
|
|||
#define MOSI_PIN P0_09
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -286,6 +285,7 @@
|
|||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER(TMC2208)
|
||||
// The shortage of pins becomes apparent.
|
||||
// Worst case you may have to give up the LCD
|
||||
|
|
|
@ -363,23 +363,23 @@
|
|||
#define ENET_TXD0 P1_00 // (78) J12-11
|
||||
#define ENET_TXD1 P1_01 // (79) J12-12
|
||||
|
||||
|
||||
//#define USB_SD_DISABLED
|
||||
#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_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 MISO_PIN P0_17
|
||||
#define MOSI_PIN P0_18
|
||||
#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
|
||||
#endif
|
||||
|
||||
#ifdef LPC_SD_ONBOARD
|
||||
#ifdef USB_SD_ONBOARD
|
||||
#elif ENABLED(LPC_SD_ONBOARD)
|
||||
|
||||
#if ENABLED(USB_SD_ONBOARD)
|
||||
// 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.
|
||||
#define SHARED_SD_CARD
|
||||
|
@ -390,10 +390,11 @@
|
|||
#define MOSI_PIN P0_09
|
||||
#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
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Fast PWMS
|
||||
* Fast PWMs
|
||||
*
|
||||
* The LPC1768's hardware PWM controller has 6 channels. Each channel
|
||||
* 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_31 (49) - not 5V tolerant
|
||||
* P0_27 (57) - open collector
|
||||
|
|
Loading…
Reference in a new issue