RTC battery voltage on X12S
This commit is contained in:
@@ -113,13 +113,22 @@ void adcInit()
|
|||||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
GPIO_Init(ADC_GPIO_MOUSE, &GPIO_InitStructure);
|
GPIO_Init(ADC_GPIO_MOUSE, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
// RTC battery
|
||||||
|
ADC1->CR1 = ADC_CR1_SCAN;
|
||||||
|
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
||||||
|
ADC1->SQR1 = (1 - 1) << 20;
|
||||||
|
ADC1->SQR3 = ADC_CHANNEL_RTC;
|
||||||
|
ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24);
|
||||||
|
ADC1->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27);
|
||||||
|
|
||||||
|
// Track pad
|
||||||
ADC3->CR1 = ADC_CR1_SCAN;
|
ADC3->CR1 = ADC_CR1_SCAN;
|
||||||
ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS;
|
||||||
ADC3->SQR1 = (2-1) << 20;
|
ADC3->SQR1 = (2 - 1) << 20;
|
||||||
ADC3->SQR2 = 0;
|
ADC3->SQR2 = 0;
|
||||||
ADC3->SQR3 = ADC_IN_MOUSE1 + (ADC_IN_MOUSE2<<5);
|
ADC3->SQR3 = ADC_CHANNEL_MOUSE1 + (ADC_CHANNEL_MOUSE2<<5);
|
||||||
ADC3->SMPR1 = 0;
|
ADC3->SMPR1 = 0;
|
||||||
ADC3->SMPR2 = (ADC_SAMPTIME<<(3*ADC_IN_MOUSE1)) + (ADC_SAMPTIME<<(3*ADC_IN_MOUSE2));
|
ADC3->SMPR2 = (ADC_SAMPTIME<<(3*ADC_CHANNEL_MOUSE1)) + (ADC_SAMPTIME<<(3*ADC_CHANNEL_MOUSE2));
|
||||||
ADC->CCR = 0;
|
ADC->CCR = 0;
|
||||||
|
|
||||||
// Enable the DMA channel here, DMA2 stream 1, channel 2
|
// Enable the DMA channel here, DMA2 stream 1, channel 2
|
||||||
@@ -197,12 +206,14 @@ uint32_t adcReadNextSPIChannel(uint8_t index)
|
|||||||
void adcOnChipReadStart()
|
void adcOnChipReadStart()
|
||||||
{
|
{
|
||||||
ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||||
|
ADC1->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR);
|
||||||
ADC3->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR);
|
ADC3->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR);
|
||||||
ADC_DMA->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0; // Write ones to clear bits
|
ADC_DMA->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0; // Write ones to clear bits
|
||||||
ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]);
|
ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]);
|
||||||
ADC_DMA_Stream->NDTR = 2;
|
ADC_DMA_Stream->NDTR = 2;
|
||||||
ADC_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
ADC_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
||||||
ADC3->CR2 |= (uint32_t)ADC_CR2_SWSTART;
|
ADC3->CR2 |= (uint32_t)ADC_CR2_SWSTART;
|
||||||
|
ADC1->CR2 |= (uint32_t)ADC_CR2_SWSTART;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool adcOnChipReadFinished()
|
bool adcOnChipReadFinished()
|
||||||
@@ -247,6 +258,14 @@ void adcRead()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t getRTCBattVoltage()
|
||||||
|
{
|
||||||
|
ADC->CCR |= ADC_CCR_VBATE;
|
||||||
|
adcRead();
|
||||||
|
ADC->CCR &= ADC_CCR_VBATE;
|
||||||
|
return ADC1->DR * 330 / 2048;
|
||||||
|
}
|
||||||
|
|
||||||
#if !defined(SIMU)
|
#if !defined(SIMU)
|
||||||
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, -1,-1, -1,1, 0,0,0};
|
const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, -1,-1, -1,1, 0,0,0};
|
||||||
|
|
||||||
|
|||||||
@@ -237,6 +237,8 @@ void boardInit()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ledBlue();
|
ledBlue();
|
||||||
|
|
||||||
|
vbattRTC = getRTCBattVoltage();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -192,8 +192,8 @@
|
|||||||
#define ADC_GPIO_PIN_MOUSE1 GPIO_Pin_8 // PF.08 ADC3_IN6 J5 MOUSE_X
|
#define ADC_GPIO_PIN_MOUSE1 GPIO_Pin_8 // PF.08 ADC3_IN6 J5 MOUSE_X
|
||||||
#define ADC_GPIO_PIN_MOUSE2 GPIO_Pin_9 // PF.09 ADC3_IN7 J6 MOUSE_Y
|
#define ADC_GPIO_PIN_MOUSE2 GPIO_Pin_9 // PF.09 ADC3_IN7 J6 MOUSE_Y
|
||||||
#define ADC_GPIO_MOUSE GPIOF
|
#define ADC_GPIO_MOUSE GPIOF
|
||||||
#define ADC_IN_MOUSE1 6
|
#define ADC_CHANNEL_MOUSE1 6
|
||||||
#define ADC_IN_MOUSE2 7
|
#define ADC_CHANNEL_MOUSE2 7
|
||||||
#define ADC_DMA DMA2
|
#define ADC_DMA DMA2
|
||||||
#define ADC_DMA_Stream DMA2_Stream0
|
#define ADC_DMA_Stream DMA2_Stream0
|
||||||
#define ADC_SAMPTIME 3
|
#define ADC_SAMPTIME 3
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SIMPGMSPC_USE_QT 0
|
#define SIMPGMSPC_USE_QT 0
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -66,6 +66,8 @@ Dacc dacc;
|
|||||||
Adc Adc0;
|
Adc Adc0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
FATFS g_FATFS_Obj;
|
||||||
|
|
||||||
void lcdInit()
|
void lcdInit()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ extern char * main_thread_error;
|
|||||||
|
|
||||||
#define OPENTX_START_DEFAULT_ARGS simu_start_mode
|
#define OPENTX_START_DEFAULT_ARGS simu_start_mode
|
||||||
|
|
||||||
static inline void getADC() { }
|
inline void getADC() { }
|
||||||
|
|
||||||
uint64_t simuTimerMicros(void);
|
uint64_t simuTimerMicros(void);
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ extern "C" void INTERRUPT_xMS_IRQHandler()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PWR_BUTTON_PRESS) && !defined(SIMU)
|
#if defined(PWR_BUTTON_PRESS)
|
||||||
#define PWR_PRESS_DURATION_MIN 100 // 1s
|
#define PWR_PRESS_DURATION_MIN 100 // 1s
|
||||||
#define PWR_PRESS_DURATION_MAX 500 // 5s
|
#define PWR_PRESS_DURATION_MAX 500 // 5s
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user