|
|
@ -27,22 +27,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __STM32F1__
|
|
|
|
#ifdef __STM32F1__
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Includes
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "HAL.h"
|
|
|
|
#include "HAL.h"
|
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <STM32ADC.h>
|
|
|
|
#include <STM32ADC.h>
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Externals
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Types
|
|
|
|
// Types
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#define __I
|
|
|
|
#define __I
|
|
|
|
#define __IO volatile
|
|
|
|
#define __IO volatile
|
|
|
@ -70,13 +62,10 @@
|
|
|
|
__IO uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */
|
|
|
|
__IO uint32_t CPACR; /*!< Offset: 0x088 (R/W) Coprocessor Access Control Register */
|
|
|
|
} SCB_Type;
|
|
|
|
} SCB_Type;
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Variables
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Local defines
|
|
|
|
// Local defines
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
|
|
|
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
|
|
|
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
|
|
|
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
|
|
|
|
|
|
|
|
|
|
|
@ -89,18 +78,19 @@
|
|
|
|
#define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
|
|
|
|
#define SCB_AIRCR_PRIGROUP_Pos 8 /*!< SCB AIRCR: PRIGROUP Position */
|
|
|
|
#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
|
|
|
|
#define SCB_AIRCR_PRIGROUP_Msk (7UL << SCB_AIRCR_PRIGROUP_Pos) /*!< SCB AIRCR: PRIGROUP Mask */
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Public Variables
|
|
|
|
// Public Variables
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SERIAL_USB
|
|
|
|
#ifdef SERIAL_USB
|
|
|
|
USBSerial SerialUSB;
|
|
|
|
USBSerial SerialUSB;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t HAL_adc_result;
|
|
|
|
uint16_t HAL_adc_result;
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Private Variables
|
|
|
|
// Private Variables
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
STM32ADC adc(ADC1);
|
|
|
|
STM32ADC adc(ADC1);
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t adc_pins[] = {
|
|
|
|
uint8_t adc_pins[] = {
|
|
|
@ -166,13 +156,13 @@ enum TEMP_PINS : char {
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t HAL_adc_results[ADC_PIN_COUNT];
|
|
|
|
uint16_t HAL_adc_results[ADC_PIN_COUNT];
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Function prototypes
|
|
|
|
// Function prototypes
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Private functions
|
|
|
|
// Private functions
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
|
|
|
static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
|
|
|
uint32_t reg_value;
|
|
|
|
uint32_t reg_value;
|
|
|
|
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */
|
|
|
|
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07); /* only values 0..7 are used */
|
|
|
@ -185,9 +175,9 @@ static void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) {
|
|
|
|
SCB->AIRCR = reg_value;
|
|
|
|
SCB->AIRCR = reg_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Public functions
|
|
|
|
// Public functions
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Leave PA11/PA12 intact if USBSerial is not used
|
|
|
|
// Leave PA11/PA12 intact if USBSerial is not used
|
|
|
@ -263,9 +253,9 @@ extern "C" {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// ADC
|
|
|
|
// ADC
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ------------------------
|
|
|
|
// Init the AD in continuous capture mode
|
|
|
|
// Init the AD in continuous capture mode
|
|
|
|
void HAL_adc_init(void) {
|
|
|
|
void HAL_adc_init(void) {
|
|
|
|
// configure the ADC
|
|
|
|
// configure the ADC
|
|
|
|