2017-09-27 07:30:23 +02:00
|
|
|
/**
|
|
|
|
* 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) 2017 Victor Perez
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* HAL for stm32duino.com based on Libmaple and compatible (STM32F1)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __STM32F1__
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Includes
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2018-04-13 03:25:08 +02:00
|
|
|
#include "HAL.h"
|
[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
2017-12-11 06:12:45 +01:00
|
|
|
#include <STM32ADC.h>
|
2017-09-27 07:30:23 +02:00
|
|
|
|
|
|
|
//#include <Wire.h>
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Externals
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Local defines
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Types
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Variables
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Public Variables
|
|
|
|
// --------------------------------------------------------------------------
|
2018-03-28 20:07:52 +02:00
|
|
|
USBSerial SerialUSB;
|
2017-09-27 07:30:23 +02:00
|
|
|
|
|
|
|
uint16_t HAL_adc_result;
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Private Variables
|
|
|
|
// --------------------------------------------------------------------------
|
[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
2017-12-11 06:12:45 +01:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2018-03-07 05:35:22 +01:00
|
|
|
enum TEMP_PINS : char {
|
2017-12-20 23:16:36 +01:00
|
|
|
#if HAS_TEMP_0
|
|
|
|
TEMP_0,
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_1
|
|
|
|
TEMP_1,
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_2
|
|
|
|
TEMP_2,
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_3
|
|
|
|
TEMP_3,
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_4
|
|
|
|
TEMP_4,
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
TEMP_BED,
|
|
|
|
#endif
|
|
|
|
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
|
|
|
FILWIDTH,
|
|
|
|
#endif
|
|
|
|
ADC_PIN_COUNT
|
[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
2017-12-11 06:12:45 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
uint16_t HAL_adc_results[ADC_PIN_COUNT];
|
|
|
|
|
2017-09-27 07:30:23 +02:00
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Function prototypes
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Private functions
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Public functions
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/* VGPV Done with defines
|
|
|
|
// disable interrupts
|
|
|
|
void cli(void) { noInterrupts(); }
|
|
|
|
|
|
|
|
// enable interrupts
|
|
|
|
void sei(void) { interrupts(); }
|
|
|
|
*/
|
|
|
|
|
|
|
|
void HAL_clear_reset_source(void) { }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Check this and change or remove.
|
|
|
|
* currently returns 1 that's equal to poweron reset.
|
|
|
|
*/
|
|
|
|
uint8_t HAL_get_reset_source(void) { return 1; }
|
|
|
|
|
|
|
|
void _delay_ms(const int delay_ms) { delay(delay_ms); }
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern unsigned int _ebss; // end of bss section
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO: Change this to correct it for libmaple
|
|
|
|
*/
|
|
|
|
|
|
|
|
// return free memory between end of heap (or end bss) and whatever is current
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include "wirish/syscalls.c"
|
|
|
|
//extern caddr_t _sbrk(int incr);
|
|
|
|
#ifndef CONFIG_HEAP_END
|
|
|
|
extern char _lm_heap_end;
|
|
|
|
#define CONFIG_HEAP_END ((caddr_t)&_lm_heap_end)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
static int freeMemory() {
|
|
|
|
char top = 't';
|
|
|
|
return &top - reinterpret_cast<char*>(sbrk(0));
|
|
|
|
}
|
|
|
|
int freeMemory() {
|
|
|
|
int free_memory;
|
|
|
|
int heap_end = (int)_sbrk(0);
|
|
|
|
free_memory = ((int)&free_memory) - ((int)heap_end);
|
|
|
|
return free_memory;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ADC
|
|
|
|
// --------------------------------------------------------------------------
|
[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
2017-12-11 06:12:45 +01:00
|
|
|
// 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();
|
|
|
|
}
|
2017-09-27 07:30:23 +02:00
|
|
|
|
|
|
|
void HAL_adc_start_conversion(const uint8_t adc_pin) {
|
[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
2017-12-11 06:12:45 +01:00
|
|
|
TEMP_PINS pin_index;
|
|
|
|
switch (adc_pin) {
|
2017-12-20 23:16:36 +01:00
|
|
|
#if HAS_TEMP_0
|
|
|
|
case TEMP_0_PIN: pin_index = TEMP_0; break;
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_1
|
|
|
|
case TEMP_1_PIN: pin_index = TEMP_1; break;
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_2
|
|
|
|
case TEMP_2_PIN: pin_index = TEMP_2; break;
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_3
|
|
|
|
case TEMP_3_PIN: pin_index = TEMP_3; break;
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_4
|
|
|
|
case TEMP_4_PIN: pin_index = TEMP_4; break;
|
|
|
|
#endif
|
|
|
|
#if HAS_TEMP_BED
|
|
|
|
case TEMP_BED_PIN: pin_index = TEMP_BED; break;
|
|
|
|
#endif
|
[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
2017-12-11 06:12:45 +01:00
|
|
|
#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.
|
2017-09-27 07:30:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t HAL_adc_get_result(void) {
|
|
|
|
return HAL_adc_result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __STM32F1__
|