Simple start analog wathdog

Add 900kHz i2c setting
This commit is contained in:
DiSlord 2020-08-02 11:30:01 +03:00
parent 068faa8879
commit 7f34a93067
4 changed files with 8 additions and 4 deletions

4
adc.c
View file

@ -108,14 +108,14 @@ int16_t adc_vbat_read(void)
return vbat_raw + config.vbat_offset;
}
void adc_start_analog_watchdogd(uint32_t chsel)
void adc_start_analog_watchdogd(void)
{
// ADC setup, if it is defined a callback for the analog watch dog then it is enabled.
VNA_ADC->ISR = VNA_ADC->ISR;
VNA_ADC->IER = ADC_IER_AWDIE;
VNA_ADC->TR = ADC_TR(0, TOUCH_THRESHOLD);
VNA_ADC->SMPR = ADC_SMPR_SMP_1P5;
VNA_ADC->CHSELR = chsel;
VNA_ADC->CHSELR = ADC_TOUCH_Y;
/* ADC configuration and start.*/
VNA_ADC->CFGR1 = ADC_CFGR1_RES_12BIT | ADC_CFGR1_AWDEN

4
main.c
View file

@ -2549,6 +2549,10 @@ static const I2CConfig i2ccfg = {
STM32_TIMINGR_PRESC(0U) |
STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(10U) |
STM32_TIMINGR_SCLH(30U) | STM32_TIMINGR_SCLL(50U),
// 900kHz @ SYSCLK 48MHz, manually get values, x2 I2C speed
// STM32_TIMINGR_PRESC(0U) |
// STM32_TIMINGR_SCLDEL(10U) | STM32_TIMINGR_SDADEL(10U) |
// STM32_TIMINGR_SCLH(23U) | STM32_TIMINGR_SCLL(30U),
#else
#error "Need Define STM32_I2C1SW and set correct TIMINGR settings"
#endif

View file

@ -646,7 +646,7 @@ void enter_dfu(void);
void adc_init(void);
uint16_t adc_single_read(uint32_t chsel);
void adc_start_analog_watchdogd(uint32_t chsel);
void adc_start_analog_watchdogd(void);
void adc_stop(void);
int16_t adc_vbat_read(void);

2
ui.c
View file

@ -338,7 +338,7 @@ void
touch_start_watchdog(void)
{
touch_prepare_sense();
adc_start_analog_watchdogd(ADC_TOUCH_Y);
adc_start_analog_watchdogd();
}
static inline int