Use FastIO, sanity-check LPC SD options, apply formatting (#12231)

This commit is contained in:
Scott Lahteine
2018-10-26 15:23:02 -05:00
committed by GitHub
parent d015f746cc
commit 5580773191
8 changed files with 68 additions and 53 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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