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