Cooler (for Laser) - M143, M193 (#21255)
This commit is contained in:
		@@ -285,7 +285,7 @@ enum ClockSource2 : char {
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Determine which harware PWMs are already in use
 | 
			
		||||
#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN)
 | 
			
		||||
#define _PWM_CHK_FAN_B(P) (P == E0_AUTO_FAN_PIN || P == E1_AUTO_FAN_PIN || P == E2_AUTO_FAN_PIN || P == E3_AUTO_FAN_PIN || P == E4_AUTO_FAN_PIN || P == E5_AUTO_FAN_PIN || P == E6_AUTO_FAN_PIN || P == E7_AUTO_FAN_PIN || P == CHAMBER_AUTO_FAN_PIN || P == COOLER_AUTO_FAN_PIN)
 | 
			
		||||
#if PIN_EXISTS(CONTROLLER_FAN)
 | 
			
		||||
  #define PWM_CHK_FAN_B(P) (_PWM_CHK_FAN_B(P) || P == CONTROLLER_FAN_PIN)
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
@@ -185,6 +185,7 @@ void HAL_adc_init() {
 | 
			
		||||
  TERN_(HAS_TEMP_ADC_7, adc3_set_attenuation(get_channel(TEMP_7_PIN), ADC_ATTEN_11db));
 | 
			
		||||
  TERN_(HAS_HEATED_BED, adc1_set_attenuation(get_channel(TEMP_BED_PIN), ADC_ATTEN_11db));
 | 
			
		||||
  TERN_(HAS_TEMP_CHAMBER, adc1_set_attenuation(get_channel(TEMP_CHAMBER_PIN), ADC_ATTEN_11db));
 | 
			
		||||
  TERN_(HAS_TEMP_COOLER, adc1_set_attenuation(get_channel(TEMP_COOLER_PIN), ADC_ATTEN_11db));
 | 
			
		||||
  TERN_(FILAMENT_WIDTH_SENSOR, adc1_set_attenuation(get_channel(FILWIDTH_PIN), ADC_ATTEN_11db));
 | 
			
		||||
 | 
			
		||||
  // Note that adc2 is shared with the WiFi module, which has higher priority, so the conversion may fail.
 | 
			
		||||
 
 | 
			
		||||
@@ -57,6 +57,7 @@
 | 
			
		||||
#define GET_PROBE_ADC()           TERN(HAS_TEMP_PROBE,        PIN_TO_ADC(TEMP_PROBE_PIN),   -1)
 | 
			
		||||
#define GET_BED_ADC()             TERN(HAS_TEMP_ADC_BED,      PIN_TO_ADC(TEMP_BED_PIN),     -1)
 | 
			
		||||
#define GET_CHAMBER_ADC()         TERN(HAS_TEMP_ADC_CHAMBER,  PIN_TO_ADC(TEMP_CHAMBER_PIN), -1)
 | 
			
		||||
#define GET_COOLER_ADC()          TERN(HAS_TEMP_ADC_COOLER,   PIN_TO_ADC(TEMP_COOLER_PIN),  -1)
 | 
			
		||||
#define GET_FILAMENT_WIDTH_ADC()  TERN(FILAMENT_WIDTH_SENSOR, PIN_TO_ADC(FILWIDTH_PIN),     -1)
 | 
			
		||||
#define GET_BUTTONS_ADC()         TERN(HAS_ADC_BUTTONS,       PIN_TO_ADC(ADC_KEYPAD_PIN),   -1)
 | 
			
		||||
 | 
			
		||||
@@ -66,6 +67,7 @@
 | 
			
		||||
  || GET_PROBE_ADC() == n          \
 | 
			
		||||
  || GET_BED_ADC() == n            \
 | 
			
		||||
  || GET_CHAMBER_ADC() == n        \
 | 
			
		||||
  || GET_COOLER_ADC() == n         \
 | 
			
		||||
  || GET_FILAMENT_WIDTH_ADC() == n \
 | 
			
		||||
  || GET_BUTTONS_ADC() == n        \
 | 
			
		||||
)
 | 
			
		||||
@@ -144,6 +146,9 @@ uint16_t HAL_adc_result;
 | 
			
		||||
    #if GET_CHAMBER_ADC() == 0
 | 
			
		||||
      TEMP_CHAMBER_PIN,
 | 
			
		||||
    #endif
 | 
			
		||||
    #if GET_COOLER_ADC() == 0
 | 
			
		||||
      TEMP_COOLER_PIN,
 | 
			
		||||
    #endif
 | 
			
		||||
    #if GET_FILAMENT_WIDTH_ADC() == 0
 | 
			
		||||
      FILWIDTH_PIN,
 | 
			
		||||
    #endif
 | 
			
		||||
@@ -184,6 +189,9 @@ uint16_t HAL_adc_result;
 | 
			
		||||
    #if GET_CHAMBER_ADC() == 1
 | 
			
		||||
      TEMP_CHAMBER_PIN,
 | 
			
		||||
    #endif
 | 
			
		||||
    #if GET_COOLER_ADC() == 1
 | 
			
		||||
      TEMP_COOLER_PIN,
 | 
			
		||||
    #endif
 | 
			
		||||
    #if GET_FILAMENT_WIDTH_ADC() == 1
 | 
			
		||||
      FILWIDTH_PIN,
 | 
			
		||||
    #endif
 | 
			
		||||
@@ -232,6 +240,9 @@ uint16_t HAL_adc_result;
 | 
			
		||||
      #if GET_CHAMBER_ADC() == 0
 | 
			
		||||
        { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
 | 
			
		||||
      #endif
 | 
			
		||||
      #if GET_COOLER_ADC() == 0
 | 
			
		||||
        { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) },
 | 
			
		||||
      #endif
 | 
			
		||||
      #if GET_FILAMENT_WIDTH_ADC() == 0
 | 
			
		||||
        { PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
 | 
			
		||||
      #endif
 | 
			
		||||
@@ -281,6 +292,9 @@ uint16_t HAL_adc_result;
 | 
			
		||||
      #if GET_CHAMBER_ADC() == 1
 | 
			
		||||
        { PIN_TO_INPUTCTRL(TEMP_CHAMBER_PIN) },
 | 
			
		||||
      #endif
 | 
			
		||||
      #if GET_COOLER_ADC() == 1
 | 
			
		||||
        { PIN_TO_INPUTCTRL(TEMP_COOLER_PIN) },
 | 
			
		||||
      #endif
 | 
			
		||||
      #if GET_FILAMENT_WIDTH_ADC() == 1
 | 
			
		||||
        { PIN_TO_INPUTCTRL(FILWIDTH_PIN) },
 | 
			
		||||
      #endif
 | 
			
		||||
 
 | 
			
		||||
@@ -132,6 +132,9 @@ const uint8_t adc_pins[] = {
 | 
			
		||||
  #if HAS_TEMP_CHAMBER
 | 
			
		||||
    TEMP_CHAMBER_PIN,
 | 
			
		||||
  #endif
 | 
			
		||||
  #if HAS_TEMP_COOLER
 | 
			
		||||
    TEMP_COOLER_PIN,
 | 
			
		||||
  #endif
 | 
			
		||||
  #if HAS_TEMP_ADC_1
 | 
			
		||||
    TEMP_1_PIN,
 | 
			
		||||
  #endif
 | 
			
		||||
@@ -189,6 +192,9 @@ enum TempPinIndex : char {
 | 
			
		||||
  #if HAS_TEMP_CHAMBER
 | 
			
		||||
    TEMP_CHAMBER,
 | 
			
		||||
  #endif
 | 
			
		||||
  #if HAS_TEMP_COOLER
 | 
			
		||||
    TEMP_COOLER_PIN,
 | 
			
		||||
  #endif
 | 
			
		||||
  #if HAS_TEMP_ADC_1
 | 
			
		||||
    TEMP_1,
 | 
			
		||||
  #endif
 | 
			
		||||
@@ -385,6 +391,9 @@ void HAL_adc_start_conversion(const uint8_t adc_pin) {
 | 
			
		||||
    #if HAS_TEMP_CHAMBER
 | 
			
		||||
      case TEMP_CHAMBER_PIN: pin_index = TEMP_CHAMBER; break;
 | 
			
		||||
    #endif
 | 
			
		||||
    #if HAS_TEMP_COOLER
 | 
			
		||||
      case TEMP_COOLER_PIN: pin_index = TEMP_COOLER; break;
 | 
			
		||||
    #endif
 | 
			
		||||
    #if HAS_TEMP_ADC_1
 | 
			
		||||
      case TEMP_1_PIN: pin_index = TEMP_1; break;
 | 
			
		||||
    #endif
 | 
			
		||||
 
 | 
			
		||||
@@ -43,26 +43,27 @@ Serial0Type<USBCompositeSerial> MarlinCompositeSerial(true);
 | 
			
		||||
 | 
			
		||||
#if ENABLED(EMERGENCY_PARSER)
 | 
			
		||||
 | 
			
		||||
// The original callback is not called (no way to retrieve address).
 | 
			
		||||
// That callback detects a special STM32 reset sequence: this functionality is not essential
 | 
			
		||||
// as M997 achieves the same.
 | 
			
		||||
void my_rx_callback(unsigned int, void*) {
 | 
			
		||||
  // max length of 16 is enough to contain all emergency commands
 | 
			
		||||
  uint8 buf[16];
 | 
			
		||||
  // The original callback is not called (no way to retrieve address).
 | 
			
		||||
  // That callback detects a special STM32 reset sequence: this functionality is not essential
 | 
			
		||||
  // as M997 achieves the same.
 | 
			
		||||
  void my_rx_callback(unsigned int, void*) {
 | 
			
		||||
    // max length of 16 is enough to contain all emergency commands
 | 
			
		||||
    uint8 buf[16];
 | 
			
		||||
 | 
			
		||||
  //rx is usbSerialPart.endpoints[2]
 | 
			
		||||
  uint16 len = usb_get_ep_rx_count(usbSerialPart.endpoints[2].address);
 | 
			
		||||
  uint32 total = composite_cdcacm_data_available();
 | 
			
		||||
    //rx is usbSerialPart.endpoints[2]
 | 
			
		||||
    uint16 len = usb_get_ep_rx_count(usbSerialPart.endpoints[2].address);
 | 
			
		||||
    uint32 total = composite_cdcacm_data_available();
 | 
			
		||||
 | 
			
		||||
  if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf)))
 | 
			
		||||
    return;
 | 
			
		||||
    if (len == 0 || total == 0 || !WITHIN(total, len, COUNT(buf)))
 | 
			
		||||
      return;
 | 
			
		||||
 | 
			
		||||
  // cannot get character by character due to bug in composite_cdcacm_peek_ex
 | 
			
		||||
  len = composite_cdcacm_peek(buf, total);
 | 
			
		||||
    // cannot get character by character due to bug in composite_cdcacm_peek_ex
 | 
			
		||||
    len = composite_cdcacm_peek(buf, total);
 | 
			
		||||
 | 
			
		||||
    for (uint32 i = 0; i < len; i++)
 | 
			
		||||
      emergency_parser.update(MarlinCompositeSerial.emergency_state, buf[i+total-len]);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for (uint32 i = 0; i < len; i++)
 | 
			
		||||
    emergency_parser.update(MarlinCompositeSerial.emergency_state, buf[i+total-len]);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void MSC_SD_init() {
 | 
			
		||||
@@ -87,7 +88,7 @@ void MSC_SD_init() {
 | 
			
		||||
  MarlinCompositeSerial.registerComponent();
 | 
			
		||||
  USBComposite.begin();
 | 
			
		||||
  #if ENABLED(EMERGENCY_PARSER)
 | 
			
		||||
  	composite_cdcacm_set_hooks(USBHID_CDCACM_HOOK_RX, my_rx_callback);
 | 
			
		||||
    composite_cdcacm_set_hooks(USBHID_CDCACM_HOOK_RX, my_rx_callback);
 | 
			
		||||
  #endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user