[2.0.x] Multiple updates to STM32F1 HAL (#8733)

* STM32F1 HAL

Adding files for STM32F1 HAL based on libmaple/stm32duino core.
Current persistent_store uses cardreader changes to be sent in separate
commit, but could be changed to use i2c eeprom.
There is another persistent_store implementation that uses the MCU flash memory
to emulate eeprom
Adding readme with some information about the stm32 HAL.

* Switch to Timer4 to avoid a hard reset on STM32F103C6 boards

On bluepill STM32F103C6 boards, using Timer5 results in a error() vector call. Switch to 4 since these are both general purpose, 16 bit timers.

* Add support for EEPROM emulation using Flash

Some low end machines doe not have EEPROM support. Simulate it using the last two pages of flash. Flash does not allow rewrite between erases, so skip writing the working version if that's enabled.

* Basic Pins for a malyan M200

This is a work in progress to go hand in hand with the STM32 work.

* Add support for ADC with DMA. This work has exposed a problem with the pin enumerations in STM boards vs what marlin expects (i.e, try defining PA0 as a temp pin). The hack can be removed with we go to fastio completely. To see this work, set something in adc_pins to a value like PA0 and connect your pullup resistor'd thermistor.

* Missing file - change HAL_adc_init to actually do something

We have an actual ADC init function now.

* Remove pinmode hack

Remove the pin mode hack that I was using to init PA0.

Updated Readme.md

* Several changes to timers and GPIO

Faster GPIO, and faster timer functions by accesing registers and
libmaple.
Still more changes pending for the Timer's code to skip using the
HardwareTimer class altogether.

Switch all enums to be within #defines

This change allows a user to have, for instance, TEMP_4 and TEMP_BED definied but nothing else. The enums which are not defined move "out", allowing the first ones to take the slots in the enum, and since the array is sized on ADC_PIN_COUNT, we always have the right size data and in order.

* Update Malyan M200 pins

Update Malyan M200 pins with correct fan values.

* Test all pins on actual hardware, update definitions

Some of the pin definitions were from knowlege base/pdfs. Now they've been tested against actual hardware. This should be very close to final.

* Update HAL_timers_Stm32f1.cpp

* Add sample configurations for Malyan M200

Add sample configuration for Malyan M200 without bed leveling, and move fan to auto cool E0 since this printer by default has only one fan.


Choose the timer based on MCU defintion. Timer5 is not valid on C8/CB class boards, so use Timer4 for the step timer.


readme.md update

* Updates to timers, and some stm32 boards definitiions

* Correct pin toggle macro.

* Remove duplicated Malyan M200 entry from pins.h

* Update configuration_store.cpp

* Formatting, indentation

* Formatting in HAL_Stm32f1.cpp
This commit is contained in:
victorpv 2017-12-10 23:12:45 -06:00 committed by Scott Lahteine
parent 204199e1ce
commit a5150c83a2
18 changed files with 5951 additions and 29 deletions

View file

@ -32,6 +32,7 @@
// --------------------------------------------------------------------------
#include "../HAL.h"
#include <STM32ADC.h>
//#include <Wire.h>
@ -60,6 +61,45 @@ uint16_t HAL_adc_result;
// --------------------------------------------------------------------------
// Private Variables
// --------------------------------------------------------------------------
STM32ADC adc(ADC1);
uint8 adc_pins[] = {
#if HAS_TEMP_0
TEMP_0_PIN,
#endif
#if HAS_TEMP_1
TEMP_1_PIN
#endif
#if HAS_TEMP_2
TEMP_2_PIN,
#endif
#if HAS_TEMP_3
TEMP_3_PIN,
#endif
#if HAS_TEMP_4
TEMP_4_PIN,
#endif
#if HAS_TEMP_BED
TEMP_BED_PIN,
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
FILWIDTH_PIN,
#endif
};
enum TEMP_PINS {
TEMP_0,
TEMP_1,
TEMP_2,
TEMP_3,
TEMP_4,
TEMP_BED,
FILWIDTH
};
#define ADC_PIN_COUNT (sizeof(adc_pins)/sizeof(adc_pins[0]))
uint16_t HAL_adc_results[ADC_PIN_COUNT];
// --------------------------------------------------------------------------
// Function prototypes
@ -126,9 +166,33 @@ extern "C" {
// --------------------------------------------------------------------------
// ADC
// --------------------------------------------------------------------------
// Init the AD in continuous capture mode
void HAL_adc_init(void) {
// configure the ADC
adc.calibrate();
adc.setSampleRate(ADC_SMPR_41_5); // ?
adc.setPins(adc_pins, ADC_PIN_COUNT);
adc.setDMA(HAL_adc_results, (uint16_t)ADC_PIN_COUNT, (uint32_t)(DMA_MINC_MODE | DMA_CIRC_MODE), (void (*)())NULL);
adc.setScanMode();
adc.setContinuous();
adc.startConversion();
}
void HAL_adc_start_conversion(const uint8_t adc_pin) {
HAL_adc_result = (analogRead(adc_pin) >> 2) & 0x3ff; // shift to get 10 bits only.
TEMP_PINS pin_index;
switch (adc_pin) {
default:
case TEMP_0_PIN: pin_index = TEMP_0; break;
case TEMP_1_PIN: pin_index = TEMP_1; break;
case TEMP_2_PIN: pin_index = TEMP_2; break;
case TEMP_3_PIN: pin_index = TEMP_3; break;
case TEMP_4_PIN: pin_index = TEMP_4; break;
case TEMP_BED_PIN: pin_index = TEMP_BED; break;
#if ENABLED(FILAMENT_WIDTH_SENSOR)
case FILWIDTH_PIN: pin_index = FILWIDTH; break;
#endif
}
HAL_adc_result = (HAL_adc_results[(int)pin_index] >> 2) & 0x3FF; // shift to get 10 bits only.
}
uint16_t HAL_adc_get_result(void) {

View file

@ -183,7 +183,7 @@ void eeprom_update_block (const void *__src, void *__dst, size_t __n);
#define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT_ANALOG);
inline void HAL_adc_init(void) {}
void HAL_adc_init(void);
#define HAL_START_ADC(pin) HAL_adc_start_conversion(pin)
#define HAL_READ_ADC HAL_adc_result

View file

@ -96,22 +96,24 @@ Timer_clock4: Prescaler 128 -> 656.25kHz
void HAL_timer_start(uint8_t timer_num, uint32_t frequency) {
switch (timer_num) {
case STEP_TIMER_NUM:
StepperTimer.pause();
StepperTimer.setCount(0);
StepperTimer.setPrescaleFactor(STEPPER_TIMER_PRESCALE);
StepperTimer.setOverflow(0xFFFF);
StepperTimer.setCompare(STEP_TIMER_CHAN, uint32_t(HAL_STEPPER_TIMER_RATE) / frequency);
StepperTimer.refresh();
StepperTimer.resume();
timer_pause(STEP_TIMER_DEV);
timer_set_count(STEP_TIMER_DEV, 0);
timer_set_prescaler(STEP_TIMER_DEV, (uint16)(STEPPER_TIMER_PRESCALE - 1));
timer_set_reload(STEP_TIMER_DEV, 0xFFFF);
timer_set_compare(STEP_TIMER_DEV, STEP_TIMER_CHAN, min(HAL_TIMER_TYPE_MAX, (HAL_STEPPER_TIMER_RATE / frequency)));
timer_attach_interrupt(STEP_TIMER_DEV, STEP_TIMER_CHAN, stepTC_Handler);
timer_generate_update(STEP_TIMER_DEV);
timer_resume(STEP_TIMER_DEV);
break;
case TEMP_TIMER_NUM:
TempTimer.pause();
TempTimer.setCount(0);
TempTimer.setPrescaleFactor(TEMP_TIMER_PRESCALE);
TempTimer.setOverflow(0xFFFF);
TempTimer.setCompare(TEMP_TIMER_CHAN, (F_CPU) / (TEMP_TIMER_PRESCALE) / frequency);
TempTimer.refresh();
TempTimer.resume();
timer_pause(TEMP_TIMER_DEV);
timer_set_count(TEMP_TIMER_DEV, 0);
timer_set_prescaler(TEMP_TIMER_DEV, (uint16)(TEMP_TIMER_PRESCALE - 1));
timer_set_reload(TEMP_TIMER_DEV, 0xFFFF);
timer_set_compare(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, min(HAL_TIMER_TYPE_MAX, ((F_CPU / TEMP_TIMER_PRESCALE) / frequency)));
timer_attach_interrupt(TEMP_TIMER_DEV, TEMP_TIMER_CHAN, tempTC_Handler);
timer_generate_update(TEMP_TIMER_DEV);
timer_resume(TEMP_TIMER_DEV);
break;
}
}
@ -119,10 +121,10 @@ void HAL_timer_start(uint8_t timer_num, uint32_t frequency) {
void HAL_timer_enable_interrupt(uint8_t timer_num) {
switch (timer_num) {
case STEP_TIMER_NUM:
StepperTimer.attachInterrupt(STEP_TIMER_CHAN, stepTC_Handler);
timer_enable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN);
break;
case TEMP_TIMER_NUM:
TempTimer.attachInterrupt(STEP_TIMER_CHAN, tempTC_Handler);
timer_enable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN);
break;
default:
break;
@ -132,10 +134,10 @@ void HAL_timer_enable_interrupt(uint8_t timer_num) {
void HAL_timer_disable_interrupt(uint8_t timer_num) {
switch (timer_num) {
case STEP_TIMER_NUM:
StepperTimer.detachInterrupt(STEP_TIMER_CHAN);
timer_disable_irq(STEP_TIMER_DEV, STEP_TIMER_CHAN);
break;
case TEMP_TIMER_NUM:
TempTimer.detachInterrupt(STEP_TIMER_CHAN);
timer_disable_irq(TEMP_TIMER_DEV, TEMP_TIMER_CHAN);
break;
default:
break;

View file

@ -46,7 +46,12 @@
typedef uint16_t hal_timer_t;
#define HAL_TIMER_TYPE_MAX 0xFFFF
#define STEP_TIMER_NUM 5 // index of timer to use for stepper
#ifdef MCU_STM32F103CB || defined(MCU_STM32F103C8)
#define STEP_TIMER_NUM 4 // For C8/CB boards, use timer 4
#else
#define STEP_TIMER_NUM 5 // for other boards, five is fine.
#endif
#define STEP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
#define TEMP_TIMER_NUM 2 // index of timer to use for temperature
#define TEMP_TIMER_CHAN 1 // Channel of the timer to use for compare and interrupts
@ -86,10 +91,10 @@ extern "C" void stepTC_Handler(void);
// --------------------------------------------------------------------------
// Public Variables
// --------------------------------------------------------------------------
/*
static HardwareTimer StepperTimer(STEP_TIMER_NUM);
static HardwareTimer TempTimer(TEMP_TIMER_NUM);
*/
// --------------------------------------------------------------------------
// Public functions
// --------------------------------------------------------------------------

View file

@ -31,9 +31,9 @@
#include <libmaple/gpio.h>
#define READ(IO) (gpio_read_bit(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
#define WRITE(IO, v) do{ gpio_write_bit(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit, v); } while (0)
#define TOGGLE(IO) do{ gpio_toggle_bit(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit); } while (0)
#define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & (1U << PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
#define WRITE(IO, v) (PIN_MAP[IO].gpio_device->regs->BSRR = (1U << PIN_MAP[IO].gpio_bit) << (16 * !(bool)v))
#define TOGGLE(IO) (PIN_MAP[IO].gpio_device->regs->ODR = PIN_MAP[IO].gpio_device->regs->ODR ^ (1U << PIN_MAP[IO].gpio_bit))
#define WRITE_VAR(IO, v) WRITE(io, v)
#define _GET_MODE(IO) (gpio_get_mode(PIN_MAP[IO].gpio_device, PIN_MAP[IO].gpio_bit))

View file

@ -0,0 +1,110 @@
/**
* Marlin 3D Printer Firmware
*
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
* Copyright (c) 2015-2016 Nico Tonnhofer wurstnase.reprap@gmail.com
* Copyright (c) 2016 Victor Perez victor_pv@hotmail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* persistent_store_flash.cpp
* HAL for stm32duino and compatible (STM32F1)
* Implementation of EEPROM settings in SDCard
*/
#ifdef __STM32F1__
#include "../../inc/MarlinConfig.h"
// This is for EEPROM emulation in flash
#if ENABLED(EEPROM_SETTINGS) && ENABLED(FLASH_EEPROM_EMULATION)
#include "../persistent_store_api.h"
#include <flash_stm32.h>
#include <EEPROM.h>
namespace HAL {
namespace PersistentStore {
// Store settings in the last two pages
// Flash pages must be erased before writing, so keep track.
bool firstWrite = false;
uint32_t pageBase = EEPROM_START_ADDRESS;
bool access_start() {
firstWrite = true;
return true;
}
bool access_finish(){
FLASH_Lock();
firstWrite = false;
return true;
}
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
FLASH_Status status;
if (firstWrite) {
FLASH_Unlock();
status = FLASH_ErasePage(EEPROM_PAGE0_BASE);
if (status != FLASH_COMPLETE) return false;
status = FLASH_ErasePage(EEPROM_PAGE1_BASE);
if (status != FLASH_COMPLETE) return false;
firstWrite = false;
}
// First write full words
int i = 0;
int wordsToWrite = size / sizeof(uint16_t);
uint16_t* wordBuffer = (uint16_t *)value;
while (wordsToWrite) {
status = FLASH_ProgramHalfWord(pageBase + pos + (i * 2), wordBuffer[i]);
if (status != FLASH_COMPLETE) return false;
wordsToWrite--;
i++;
}
// Now, write any remaining single byte
if (size & 1) {
uint16_t temp = value[size - 1];
status = FLASH_ProgramHalfWord(pageBase + pos + i, temp);
if (status != FLASH_COMPLETE) return false;
}
crc16(crc, value, size);
pos += ((size + 1) & ~1);
return true;
}
void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
for (uint16_t i = 0; i < size; i++) {
byte* accessPoint = (byte*)(pageBase + pos + i);
value[i] = *accessPoint;
}
crc16(crc, value, size);
pos += ((size + 1) & ~1);
}
} // PersistentStore
} // HAL
#endif // EEPROM_SETTINGS && EEPROM FLASH
#endif // __STM32F1__

View file

@ -29,7 +29,7 @@
#include "../../inc/MarlinConfig.h"
#if ENABLED(EEPROM_SETTINGS)
#if ENABLED(EEPROM_SETTINGS) && DISABLED(FLASH_EEPROM_EMULATION)
#include "../persistent_store_api.h"

View file

@ -0,0 +1,32 @@
# This HAL is for STM32F103 boards used with libmaple/stm32duino Arduino core.
# This HAL is in development and has not been tested with an actual printer.
### The stm32 core needs a modification in the file util.h to avoid conflict with Marlin macros for Debug.
Since only 1 file needs change in the stm32duino core, it's preferable over making changes to Marlin.
After these lines:
<>
#else
#define ASSERT_FAULT(exp) (void)((0))
#endif
<>
Add the following 3 lines:
<>
#undef DEBUG_NONE
#undef DEBUG_FAULT
#undef DEBUG_ALL
<>
### Main developers:
Victorpv
### Most up to date repository for this HAL:
https://github.com/victorpv/Marlin/tree/bugfix-2.0.x
PRs should be first sent to that fork, and once tested merged to Marlin bugfix-2.0.x branch.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -194,6 +194,9 @@
//
#define BOARD_TEENSY35_36 841 // Teensy3.5 and Teensy3.6
#define BOARD_STM32F1R 1800 // STM3R Libmaple based STM32F1 controller
#define BOARD_MALYAN_M200 1801 // STM32C8T6 Libmaple based stm32f1 controller
#define BOARD_BEAST 1802 // STM32FxxxVxT6 Libmaple based stm32f4 controller
#define BOARD_STM3R_MINI 1803 // STM32 Libmaple based stm32f1 controller
#define MB(board) (MOTHERBOARD==BOARD_##board)

View file

@ -299,8 +299,11 @@ void MarlinSettings::postprocess() {
EEPROM_START();
eeprom_error = false;
EEPROM_WRITE(ver); // invalidate data first
#if ENABLED(FLASH_EEPROM_EMULATION)
EEPROM_SKIP(ver); // Flash doesn't allow rewriting without erase
#else
EEPROM_WRITE(ver); // invalidate data first
#endif
EEPROM_SKIP(working_crc); // Skip the checksum slot
working_crc = 0; // clear before first "real data"

View file

@ -319,6 +319,14 @@
#include "pins_ALLIGATOR_R2.h"
#elif MB(STM32F1R)
#include "pins_STM32F1R.h"
#elif MB(STM3R_MINI)
#include "pins_STM3R_MINI.h"
#elif MB(MALYAN_M200)
#include "pins_MALYAN_M200.h"
#elif MB(BEAST)
#include "pins_BEAST.h"
#elif MB(CHITU3D)
#include "pins_CHITU3D.h"
#elif MB(MKS_SBASE)
#include "pins_MKS_SBASE.h"
#elif MB(AZSMZ_MINI)

View file

@ -0,0 +1,288 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if !defined(__STM32F1__) && !defined(__STM32F4__)
#error "Oops! Make sure you have an STM32F1/4 board selected from the 'Tools -> Boards' menu."
#endif
/**
* 21017 Victor Perez Marlin for stm32f1 test
*/
#define DEFAULT_MACHINE_NAME "STM32F103RET6"
#define BOARD_NAME "Marlin for STM32"
#define LARGE_FLASH true
// Enable I2C_EEPROM for testing
#define I2C_EEPROM
// Ignore temp readings during develpment.
#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
//
// Steppers
//
#define X_STEP_PIN PE0
#define X_DIR_PIN PE1
#define X_ENABLE_PIN PC0
#define X_MIN_PIN PD5
#define X_MAX_PIN -1
#define Y_STEP_PIN PE2
#define Y_DIR_PIN PE3
#define Y_ENABLE_PIN PC1
#define Y_MIN_PIN PD6
#define Y_MAX_PIN
#define Z_STEP_PIN PE4
#define Z_DIR_PIN PE5
#define Z_ENABLE_PIN PC2
#define Z_MIN_PIN PD7
#define Z_MAX_PIN -1
#define Y2_STEP_PIN -1
#define Y2_DIR_PIN -1
#define Y2_ENABLE_PIN -1
#define Z2_STEP_PIN -1
#define Z2_DIR_PIN -1
#define Z2_ENABLE_PIN -1
#define E0_STEP_PIN PE6
#define E0_DIR_PIN PE7
#define E0_ENABLE_PIN PC3
/**
* TODO: Currently using same Enable pin to all steppers.
*/
#define E1_STEP_PIN PE8
#define E1_DIR_PIN PE9
#define E1_ENABLE_PIN PC4
#define E2_STEP_PIN PE10
#define E2_DIR_PIN PE11
#define E2_ENABLE_PIN PC5
//
// Misc. Functions
//
#define SDPOWER -1
#define SDSS PA15
#define LED_PIN PB2
#define PS_ON_PIN -1
#define KILL_PIN -1
//
// Heaters / Fans
//
#define HEATER_0_PIN PD12 // EXTRUDER 1
#define HEATER_1_PIN PD13
#define HEATER_2_PIN PD14
#define HEATER_BED_PIN PB9 // BED
#define HEATER_BED2_PIN -1 // BED2
#define HEATER_BED3_PIN -1 // BED3
#define FAN_PIN PB10
#define FAN_SOFT_PWM
//
// Temperature Sensors
//
#define TEMP_BED_PIN PA0 // ANALOG NUMBERING
#define TEMP_0_PIN PA1 // ANALOG NUMBERING
#define TEMP_1_PIN PA2 // ANALOG NUMBERING
#define TEMP_2_PIN PA3 // ANALOG NUMBERING
//
// LCD Pins
//
#if ENABLED(ULTRA_LCD)
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define LCD_PINS_RS 49 // CS chip select /SS chip slave select
#define LCD_PINS_ENABLE 51 // SID (MOSI)
#define LCD_PINS_D4 52 // SCK (CLK) clock
#elif ENABLED(NEWPANEL) && ENABLED(PANEL_ONE)
#define LCD_PINS_RS PB8
#define LCD_PINS_ENABLE PD2
#define LCD_PINS_D4 PB12
#define LCD_PINS_D5 PB13
#define LCD_PINS_D6 PB14
#define LCD_PINS_D7 PB15
#else
#define LCD_PINS_RS PB8
#define LCD_PINS_ENABLE PD2
#define LCD_PINS_D4 PB12
#define LCD_PINS_D5 PB13
#define LCD_PINS_D6 PB14
#define LCD_PINS_D7 PB15
#if DISABLED(NEWPANEL)
#define BEEPER_PIN 33
// Buttons are attached to a shift register
// Not wired yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#endif
#endif
#if ENABLED(NEWPANEL)
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#define BEEPER_PIN 37
#define BTN_EN1 31
#define BTN_EN2 33
#define BTN_ENC 35
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
#define LCD_BACKLIGHT_PIN 39
#endif
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#define SD_DETECT_PIN 42
#elif ENABLED(LCD_I2C_PANELOLU2)
#define BTN_EN1 47
#define BTN_EN2 43
#define BTN_ENC 32
#define LCD_SDSS 53
#define SD_DETECT_PIN -1
#define KILL_PIN 41
#elif ENABLED(LCD_I2C_VIKI)
#define BTN_EN1 22 // http://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42.
#define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13.
#define BTN_ENC -1
#define LCD_SDSS 53
#define SD_DETECT_PIN 49
#elif ENABLED(VIKI2) || ENABLED(miniVIKI)
#define BEEPER_PIN 33
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 44
#define DOGLCD_CS 45
#define LCD_SCREEN_ROT_180
#define BTN_EN1 22
#define BTN_EN2 7
#define BTN_ENC 39
#define SDSS 53
#define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board
#define KILL_PIN 31
#define STAT_LED_RED_PIN 32
#define STAT_LED_BLUE_PIN 35
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define BTN_EN1 35
#define BTN_EN2 37
#define BTN_ENC 31
#define SD_DETECT_PIN 49
#define LCD_SDSS 53
#define KILL_PIN 41
#define BEEPER_PIN 23
#define DOGLCD_CS 29
#define DOGLCD_A0 27
#define LCD_BACKLIGHT_PIN 33
#elif ENABLED(MINIPANEL)
#define BEEPER_PIN 42
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 44
#define DOGLCD_CS 66
#define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65
#define SDSS 53
#define KILL_PIN 64
// GLCD features
//#define LCD_CONTRAST 190
// Uncomment screen orientation
//#define LCD_SCREEN_ROT_90
//#define LCD_SCREEN_ROT_180
//#define LCD_SCREEN_ROT_270
// The encoder and click button
#define BTN_EN1 40
#define BTN_EN2 63
#define BTN_ENC 59
// not connected to a pin
#define SD_DETECT_PIN 49
#else
// Beeper on AUX-4
#define BEEPER_PIN 33
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#define SHIFT_OUT 40
#define SHIFT_CLK 44
#define SHIFT_LD 42
#elif ENABLED(PANEL_ONE)
#define BTN_EN1 59 // AUX2 PIN 3
#define BTN_EN2 63 // AUX2 PIN 4
#define BTN_ENC 49 // AUX3 PIN 7
#else
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#else
//#define SD_DETECT_PIN -1 // Ramps doesn't use this
#endif
#endif
#endif // NEWPANEL
#endif // ULTRA_LCD
#define U_MIN_PIN -1
#define V_MIN_PIN -1
#define W_MIN_PIN -1

View file

@ -0,0 +1,287 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if !defined(__STM32F1__) && !defined(__STM32F4__)
#error "Oops! Make sure you have an STM32F1/4 board selected from the 'Tools -> Boards' menu."
#endif
/**
* 2017 Victor Perez Marlin for stm32f1 test
*/
#define DEFAULT_MACHINE_NAME "STM32F103RET6"
#define BOARD_NAME "Chitu3d Marlin"
#define LARGE_FLASH true
// Enable I2C_EEPROM for testing
//#define I2C_EEPROM
// Ignore temp readings during develpment.
#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
//
// Steppers
//
#define X_STEP_PIN PE5
#define X_DIR_PIN PE6
#define X_ENABLE_PIN PC13
#define X_MIN_PIN PG10
#define X_MAX_PIN -1
#define Y_STEP_PIN PE2
#define Y_DIR_PIN PE3
#define Y_ENABLE_PIN PE4
#define Y_MIN_PIN PA12
#define Y_MAX_PIN
#define Z_STEP_PIN PB9
#define Z_DIR_PIN PE0
#define Z_ENABLE_PIN PE1
#define Z_MIN_PIN PA14
#define Z_MAX_PIN -1
#define Y2_STEP_PIN -1
#define Y2_DIR_PIN -1
#define Y2_ENABLE_PIN -1
#define Z2_STEP_PIN -1
#define Z2_DIR_PIN -1
#define Z2_ENABLE_PIN -1
#define E0_STEP_PIN PB4
#define E0_DIR_PIN PB5
#define E0_ENABLE_PIN PB8
#define E1_STEP_PIN -1
#define E1_DIR_PIN -1
#define E1_ENABLE_PIN -1
#define E2_STEP_PIN -1
#define E2_DIR_PIN -1
#define E2_ENABLE_PIN -1
//
// Misc. Functions
//
#define SDPOWER -1
#define SDSS -1
#define LED_PIN -1
#define CASE_LIGHT_PIN 8
#define PS_ON_PIN -1
#define KILL_PIN PD6 // LED strip 24v
//
// Heaters / Fans
//
#define HEATER_0_PIN PD12 // HOT-END
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define HEATER_BED_PIN PG11 // HOT-BED
#define HEATER_BED2_PIN -1 // BED2
#define HEATER_BED3_PIN -1 // BED3
#define FAN_PIN PG14 // MAIN BOARD FAN
#define FAN_SOFT_PWM
//
// Temperature Sensors
//
#define TEMP_BED_PIN PA0 // ANALOG NUMBERING
#define TEMP_0_PIN PA1 // ANALOG NUMBERING
#define TEMP_1_PIN -1 // ANALOG NUMBERING
#define TEMP_2_PIN -1 // ANALOG NUMBERING
//
// LCD Pins
//
#if ENABLED(ULTRA_LCD)
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define LCD_PINS_RS 49 // CS chip select /SS chip slave select
#define LCD_PINS_ENABLE 51 // SID (MOSI)
#define LCD_PINS_D4 52 // SCK (CLK) clock
#elif ENABLED(NEWPANEL) && ENABLED(PANEL_ONE)
#define LCD_PINS_RS PB8
#define LCD_PINS_ENABLE PD2
#define LCD_PINS_D4 PB12
#define LCD_PINS_D5 PB13
#define LCD_PINS_D6 PB14
#define LCD_PINS_D7 PB15
#else
#define LCD_PINS_RS PB8
#define LCD_PINS_ENABLE PD2
#define LCD_PINS_D4 PB12
#define LCD_PINS_D5 PB13
#define LCD_PINS_D6 PB14
#define LCD_PINS_D7 PB15
#if DISABLED(NEWPANEL)
#define BEEPER_PIN 33
// Buttons are attached to a shift register
// Not wired yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#endif
#endif
#if ENABLED(NEWPANEL)
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#define BEEPER_PIN 37
#define BTN_EN1 31
#define BTN_EN2 33
#define BTN_ENC 35
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
#define LCD_BACKLIGHT_PIN 39
#endif
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#define SD_DETECT_PIN 42
#elif ENABLED(LCD_I2C_PANELOLU2)
#define BTN_EN1 47
#define BTN_EN2 43
#define BTN_ENC 32
#define LCD_SDSS 53
#define SD_DETECT_PIN -1
#define KILL_PIN 41
#elif ENABLED(LCD_I2C_VIKI)
#define BTN_EN1 22 // http://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42.
#define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13.
#define BTN_ENC -1
#define LCD_SDSS 53
#define SD_DETECT_PIN 49
#elif ENABLED(VIKI2) || ENABLED(miniVIKI)
#define BEEPER_PIN 33
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 44
#define DOGLCD_CS 45
#define LCD_SCREEN_ROT_180
#define BTN_EN1 22
#define BTN_EN2 7
#define BTN_ENC 39
#define SDSS 53
#define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board
#define KILL_PIN 31
#define STAT_LED_RED_PIN 32
#define STAT_LED_BLUE_PIN 35
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define BTN_EN1 35
#define BTN_EN2 37
#define BTN_ENC 31
#define SD_DETECT_PIN 49
#define LCD_SDSS 53
#define KILL_PIN 41
#define BEEPER_PIN 23
#define DOGLCD_CS 29
#define DOGLCD_A0 27
#define LCD_BACKLIGHT_PIN 33
#elif ENABLED(MINIPANEL)
#define BEEPER_PIN 42
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 44
#define DOGLCD_CS 66
#define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65
#define SDSS 53
#define KILL_PIN 64
// GLCD features
//#define LCD_CONTRAST 190
// Uncomment screen orientation
//#define LCD_SCREEN_ROT_90
//#define LCD_SCREEN_ROT_180
//#define LCD_SCREEN_ROT_270
// The encoder and click button
#define BTN_EN1 40
#define BTN_EN2 63
#define BTN_ENC 59
// not connected to a pin
#define SD_DETECT_PIN 49
#else
// Beeper on AUX-4
#define BEEPER_PIN 33
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#define SHIFT_OUT 40
#define SHIFT_CLK 44
#define SHIFT_LD 42
#elif ENABLED(PANEL_ONE)
#define BTN_EN1 59 // AUX2 PIN 3
#define BTN_EN2 63 // AUX2 PIN 4
#define BTN_ENC 49 // AUX3 PIN 7
#else
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#else
//#define SD_DETECT_PIN -1 // Ramps doesn't use this
#endif
#endif
#endif // NEWPANEL
#endif // ULTRA_LCD
#define U_MIN_PIN -1
#define V_MIN_PIN -1
#define W_MIN_PIN -1

View file

@ -0,0 +1,86 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* MALYAN M200 pin assignments
*/
#ifndef __STM32F1__
#error "Oops! You must be compiling for STM32."
#endif
#define BOARD_NAME "MALYANM200"
// Enable EEPROM Emulation for this board
// This setting should probably be in configuration.h
// but it is literally the only board which uses it.
#define FLASH_EEPROM_EMULATION
#define SDSS SS_PIN
//
// Limit Switches
//
#define X_MIN_PIN PB4
#define Y_MIN_PIN PA15
#define Z_MIN_PIN PB5
//
// Steppers
//
// X & Y enable are the same
#define X_STEP_PIN PB14
#define X_DIR_PIN PB15
#define X_ENABLE_PIN PA8
#define Y_STEP_PIN PB12
#define Y_DIR_PIN PB13
#define Y_ENABLE_PIN PA8
#define Z_STEP_PIN PB10
#define Z_DIR_PIN PB2
#define Z_ENABLE_PIN PB11
#define E0_STEP_PIN PB0
#define E0_DIR_PIN PC13
#define E0_ENABLE_PIN PB1
//
// Temperature Sensors
//
#define TEMP_0_PIN PA0 // Analog Input (HOTEND0 thermistor)
#define TEMP_BED_PIN PA1 // Analog Input (BED thermistor)
//
// Heaters / Fans
//
#define HEATER_0_PIN PB6 // HOTEND0 MOSFET
#define HEATER_BED_PIN PB7 // BED MOSFET
// This board has only the controller fan and the extruder fan
// If someone hacks to put a direct power fan on the controller, PB3 could
// be used as a separate print cooling fan.
// FAN_PIN is commented out because in configuration_adv, we have
// it set to E0_AUTO_FAN_PIN
// #define FAN_PIN PB8 // FAN1 header on board - PRINT FAN
#define FAN1_PIN PB3 // FAN2 header on board - CONTROLLER FAN
#define FAN2_PIN -1 // FAN3 header on board - EXTRUDER0 FAN

View file

@ -0,0 +1,291 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if !defined(__STM32F1__) && !defined(__STM32F4__)
#error "Oops! Make sure you have an STM32F1/4 board selected from the 'Tools -> Boards' menu."
#endif
/**
* 21017 Victor Perez Marlin for stm32f1 test
*/
#define DEFAULT_MACHINE_NAME "STM3R Mini"
#define BOARD_NAME "Marlin for STM32"
#define LARGE_FLASH true
// Enable I2C_EEPROM for testing
#define I2C_EEPROM
// Ignore temp readings during develpment.
#define BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
//
// Steppers
//
#define X_STEP_PIN PE1
#define X_DIR_PIN PE0
#define X_ENABLE_PIN PC0
#define X_MIN_PIN PD0
#define X_MAX_PIN -1
#define Y_STEP_PIN PE3
#define Y_DIR_PIN PE2
#define Y_ENABLE_PIN PC1
#define Y_MIN_PIN PD1
#define Y_MAX_PIN
#define Z_STEP_PIN PE5
#define Z_DIR_PIN PE4
#define Z_ENABLE_PIN PC2
#define Z_MIN_PIN PD4
#define Z_MAX_PIN -1
#define Y2_STEP_PIN -1
#define Y2_DIR_PIN -1
#define Y2_ENABLE_PIN -1
#define Z2_STEP_PIN -1
#define Z2_DIR_PIN -1
#define Z2_ENABLE_PIN -1
#define E0_STEP_PIN PE7
#define E0_DIR_PIN PE6
#define E0_ENABLE_PIN PC3
#define E1_STEP_PIN PE9
#define E1_DIR_PIN PE8
#define E1_ENABLE_PIN PC4
#define E2_STEP_PIN PE11
#define E2_DIR_PIN PE10
#define E2_ENABLE_PIN PC5
//
// Misc. Functions
//
//#define SDPOWER -1
#define SDSS PA15
#define LED_PIN PB2
//#define PS_ON_PIN -1
//#define KILL_PIN -1
//
// Heaters / Fans
//
#define HEATER_0_PIN PD12 // EXTRUDER 1
//#define HEATER_1_PIN PD13
//#define HEATER_2_PIN -1
#define HEATER_BED_PIN PB9 // BED
//#define HEATER_BED2_PIN -1 // BED2
//#define HEATER_BED3_PIN -1 // BED3
#define FAN_PIN PD14
#define FAN1_PIN PD13
#define FAN_SOFT_PWM
//
// Temperature Sensors
//
#define TEMP_BED_PIN PA0
#define TEMP_0_PIN PA1
#define TEMP_1_PIN PA2
#define TEMP_2_PIN PA3
// Laser control
#if ENABLED(SPINDLE_LASER_ENABLE)
#define SPINDLE_LASER_PWM_PIN PB8
#define SPINDLE_LASER_ENABLE_PIN PD5
#endif
//
// LCD Pins
//
#if ENABLED(ULTRA_LCD)
#if ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define LCD_PINS_RS 49 // CS chip select /SS chip slave select
#define LCD_PINS_ENABLE 51 // SID (MOSI)
#define LCD_PINS_D4 52 // SCK (CLK) clock
#elif ENABLED(NEWPANEL) && ENABLED(PANEL_ONE)
#define LCD_PINS_RS PB8
#define LCD_PINS_ENABLE PD2
#define LCD_PINS_D4 PB12
#define LCD_PINS_D5 PB13
#define LCD_PINS_D6 PB14
#define LCD_PINS_D7 PB15
#else
#define LCD_PINS_RS PB8
#define LCD_PINS_ENABLE PD2
#define LCD_PINS_D4 PB12
#define LCD_PINS_D5 PB13
#define LCD_PINS_D6 PB14
#define LCD_PINS_D7 PB15
#if DISABLED(NEWPANEL)
#define BEEPER_PIN 33
// Buttons are attached to a shift register
// Not wired yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#endif
#endif
#if ENABLED(NEWPANEL)
#if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER)
#define BEEPER_PIN 37
#define BTN_EN1 31
#define BTN_EN2 33
#define BTN_ENC 35
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#if ENABLED(BQ_LCD_SMART_CONTROLLER)
#define LCD_BACKLIGHT_PIN 39
#endif
#elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#define SD_DETECT_PIN 42
#elif ENABLED(LCD_I2C_PANELOLU2)
#define BTN_EN1 47
#define BTN_EN2 43
#define BTN_ENC 32
#define LCD_SDSS 53
#define SD_DETECT_PIN -1
#define KILL_PIN 41
#elif ENABLED(LCD_I2C_VIKI)
#define BTN_EN1 22 // http://files.panucatt.com/datasheets/viki_wiring_diagram.pdf explains 40/42.
#define BTN_EN2 7 // 22/7 are unused on RAMPS_14. 22 is unused and 7 the SERVO0_PIN on RAMPS_13.
#define BTN_ENC -1
#define LCD_SDSS 53
#define SD_DETECT_PIN 49
#elif ENABLED(VIKI2) || ENABLED(miniVIKI)
#define BEEPER_PIN 33
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 44
#define DOGLCD_CS 45
#define LCD_SCREEN_ROT_180
#define BTN_EN1 22
#define BTN_EN2 7
#define BTN_ENC 39
#define SDSS 53
#define SD_DETECT_PIN -1 // Pin 49 for display sd interface, 72 for easy adapter board
#define KILL_PIN 31
#define STAT_LED_RED_PIN 32
#define STAT_LED_BLUE_PIN 35
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define BTN_EN1 35
#define BTN_EN2 37
#define BTN_ENC 31
#define SD_DETECT_PIN 49
#define LCD_SDSS 53
#define KILL_PIN 41
#define BEEPER_PIN 23
#define DOGLCD_CS 29
#define DOGLCD_A0 27
#define LCD_BACKLIGHT_PIN 33
#elif ENABLED(MINIPANEL)
#define BEEPER_PIN 42
// Pins for DOGM SPI LCD Support
#define DOGLCD_A0 44
#define DOGLCD_CS 66
#define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65
#define SDSS 53
#define KILL_PIN 64
// GLCD features
//#define LCD_CONTRAST 190
// Uncomment screen orientation
//#define LCD_SCREEN_ROT_90
//#define LCD_SCREEN_ROT_180
//#define LCD_SCREEN_ROT_270
// The encoder and click button
#define BTN_EN1 40
#define BTN_EN2 63
#define BTN_ENC 59
// not connected to a pin
#define SD_DETECT_PIN 49
#else
// Beeper on AUX-4
#define BEEPER_PIN 33
// buttons are directly attached using AUX-2
#if ENABLED(REPRAPWORLD_KEYPAD)
#define BTN_EN1 64
#define BTN_EN2 59
#define BTN_ENC 63
#define SHIFT_OUT 40
#define SHIFT_CLK 44
#define SHIFT_LD 42
#elif ENABLED(PANEL_ONE)
#define BTN_EN1 59 // AUX2 PIN 3
#define BTN_EN2 63 // AUX2 PIN 4
#define BTN_ENC 49 // AUX3 PIN 7
#else
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31
#endif
#if ENABLED(G3D_PANEL)
#define SD_DETECT_PIN 49
#define KILL_PIN 41
#else
//#define SD_DETECT_PIN -1 // Ramps doesn't use this
#endif
#endif
#endif // NEWPANEL
#endif // ULTRA_LCD
#define U_MIN_PIN -1
#define V_MIN_PIN -1
#define W_MIN_PIN -1