diff options
Diffstat (limited to 'src/stm/stm32l.h')
| -rw-r--r-- | src/stm/stm32l.h | 139 | 
1 files changed, 139 insertions, 0 deletions
diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h index e03556b0..b9f45513 100644 --- a/src/stm/stm32l.h +++ b/src/stm/stm32l.h @@ -1013,4 +1013,143 @@ extern struct stm_spi stm_spi1, stm_spi2, stm_spi3;  #define STM_SPI_SR_TXE		1  #define STM_SPI_SR_RXNE		0 +struct stm_adc { +	vuint32_t	sr; +	vuint32_t	cr1; +	vuint32_t	cr2; +	vuint32_t	smpr1; +	vuint32_t	smpr2; +	vuint32_t	smpr3; +	vuint32_t	jofr1; +	vuint32_t	jofr2; +	vuint32_t	jofr3; +	vuint32_t	jofr4; +	vuint32_t	htr; +	vuint32_t	ltr; +	vuint32_t	sqr1; +	vuint32_t	sqr2; +	vuint32_t	sqr3; +	vuint32_t	sqr4; +	vuint32_t	sqr5; +	vuint32_t	jsqr; +	vuint32_t	jdr1; +	vuint32_t	jdr2; +	vuint32_t	jdr3; +	vuint32_t	jdr4; +	vuint32_t	dr; +	uint8_t		reserved[0x300 - 0x5c]; +	vuint32_t	csr; +	vuint32_t	ccr; +}; + +extern struct stm_adc stm_adc; + +#define STM_ADC_SR_JCNR		9 +#define STM_ADC_SR_RCNR		8 +#define STM_ADC_SR_ADONS	6 +#define STM_ADC_SR_OVR		5 +#define STM_ADC_SR_STRT		4 +#define STM_ADC_SR_JSTRT	3 +#define STM_ADC_SR_JEOC		2 +#define STM_ADC_SR_EOC		1 +#define STM_ADC_SR_AWD		0 + +#define STM_ADC_CR1_OVRIE	26 +#define STM_ADC_CR1_RES		24 +#define  STM_ADC_CR1_RES_12		0 +#define  STM_ADC_CR1_RES_10		1 +#define  STM_ADC_CR1_RES_8		2 +#define  STM_ADC_CR1_RES_6		3 +#define  STM_ADC_CR1_RES_MASK		3 +#define STM_ADC_CR1_AWDEN       23 +#define STM_ADC_CR1_JAWDEN	22 +#define STM_ADC_CR1_PDI		17 +#define STM_ADC_CR1_PDD		16 +#define STM_ADC_CR1_DISCNUM	13 +#define  STM_ADC_CR1_DISCNUM_1		0 +#define  STM_ADC_CR1_DISCNUM_2		1 +#define  STM_ADC_CR1_DISCNUM_3		2 +#define  STM_ADC_CR1_DISCNUM_4		3 +#define  STM_ADC_CR1_DISCNUM_5		4 +#define  STM_ADC_CR1_DISCNUM_6		5 +#define  STM_ADC_CR1_DISCNUM_7		6 +#define  STM_ADC_CR1_DISCNUM_8		7 +#define  STM_ADC_CR1_DISCNUM_MASK	7 +#define STM_ADC_CR1_JDISCEN	12 +#define STM_ADC_CR1_DISCEN	11 +#define STM_ADC_CR1_JAUTO	10 +#define STM_ADC_CR1_AWDSGL	9 +#define STM_ADC_CR1_SCAN	8 +#define STM_ADC_CR1_JEOCIE	7 +#define STM_ADC_CR1_AWDIE	6 +#define STM_ADC_CR1_EOCIE	5 +#define STM_ADC_CR1_AWDCH	0 +#define  STM_ADC_CR1_AWDCH_MASK		0x1f + +#define STM_ADC_CR2_SWSTART	30 +#define STM_ADC_CR2_EXTEN	28 +#define  STM_ADC_CR2_EXTEN_DISABLE	0 +#define  STM_ADC_CR2_EXTEN_RISING	1 +#define  STM_ADC_CR2_EXTEN_FALLING	2 +#define  STM_ADC_CR2_EXTEN_BOTH		3 +#define  STM_ADC_CR2_EXTEN_MASK		3 +#define STM_ADC_CR2_EXTSEL	24 +#define  STM_ADC_CR2_EXTSEL_TIM9_CC2	0 +#define  STM_ADC_CR2_EXTSEL_TIM9_TRGO	1 +#define  STM_ADC_CR2_EXTSEL_TIM2_CC3	2 +#define  STM_ADC_CR2_EXTSEL_TIM2_CC2	3 +#define  STM_ADC_CR2_EXTSEL_TIM3_TRGO	4 +#define  STM_ADC_CR2_EXTSEL_TIM4_CC4	5 +#define  STM_ADC_CR2_EXTSEL_TIM2_TRGO	6 +#define  STM_ADC_CR2_EXTSEL_TIM3_CC1	7 +#define  STM_ADC_CR2_EXTSEL_TIM3_CC3	8 +#define  STM_ADC_CR2_EXTSEL_TIM4_TRGO	9 +#define  STM_ADC_CR2_EXTSEL_TIM6_TRGO	10 +#define  STM_ADC_CR2_EXTSEL_EXTI_11	15 +#define  STM_ADC_CR2_EXTSEL_MASK	15 +#define STM_ADC_CR2_JWSTART	22 +#define STM_ADC_CR2_JEXTEN	20 +#define  STM_ADC_CR2_JEXTEN_DISABLE	0 +#define  STM_ADC_CR2_JEXTEN_RISING	1 +#define  STM_ADC_CR2_JEXTEN_FALLING	2 +#define  STM_ADC_CR2_JEXTEN_BOTH	3 +#define  STM_ADC_CR2_JEXTEN_MASK	3 +#define STM_ADC_CR2_JEXTSEL	16 +#define  STM_ADC_CR2_JEXTSEL_TIM9_CC1	0 +#define  STM_ADC_CR2_JEXTSEL_TIM9_TRGO	1 +#define  STM_ADC_CR2_JEXTSEL_TIM2_TRGO	2 +#define  STM_ADC_CR2_JEXTSEL_TIM2_CC1	3 +#define  STM_ADC_CR2_JEXTSEL_TIM3_CC4	4 +#define  STM_ADC_CR2_JEXTSEL_TIM4_TRGO	5 +#define  STM_ADC_CR2_JEXTSEL_TIM4_CC1	6 +#define  STM_ADC_CR2_JEXTSEL_TIM4_CC2	7 +#define  STM_ADC_CR2_JEXTSEL_TIM4_CC3	8 +#define  STM_ADC_CR2_JEXTSEL_TIM10_CC1	9 +#define  STM_ADC_CR2_JEXTSEL_TIM7_TRGO	10 +#define  STM_ADC_CR2_JEXTSEL_EXTI_15	15 +#define  STM_ADC_CR2_JEXTSEL_MASK	15 +#define STM_ADC_CR2_ALIGN	11 +#define STM_ADC_CR2_EOCS	10 +#define STM_ADC_CR2_DDS		9 +#define STM_ADC_CR2_DMA		8 +#define STM_ADC_CR2_DELS	4 +#define  STM_ADC_CR2_DELS_NONE		0 +#define  STM_ADC_CR2_DELS_UNTIL_READ	1 +#define  STM_ADC_CR2_DELS_7		2 +#define  STM_ADC_CR2_DELS_15		3 +#define  STM_ADC_CR2_DELS_31		4 +#define  STM_ADC_CR2_DELS_63		5 +#define  STM_ADC_CR2_DELS_127		6 +#define  STM_ADC_CR2_DELS_255		7 +#define  STM_ADC_CR2_DELS_MASK		7 +#define STM_ADC_CR2_CONT	1 +#define STM_ADC_CR2_ADON	0 + +#define STM_ADC_CCR_TSVREFE	23 +#define STM_ADC_CCR_ADCPRE	16 +#define  STM_ADC_CCR_ADCPRE_HSI_1	0 +#define  STM_ADC_CCR_ADCPRE_HSI_2	1 +#define  STM_ADC_CCR_ADCPRE_HSI_4	2 +#define  STM_ADC_CCR_ADCPRE_MASK	3 +  #endif /* _STM32L_H_ */  | 
