altos: Make STM clock configuration per-product. Fix 32MHz CPU speed
[fw/altos] / src / stm / ao_arch.h
index 188b89962b3532b5aa6634a8d47004f50d382495..dd9579f1093252b303cfff84506ebb68d5734b6b 100644 (file)
@@ -145,17 +145,33 @@ extern const uint16_t ao_serial_number;
 
 #define ao_arch_critical(b) do { cli(); do { b } while (0); sei(); } while (0)
 
-#define AO_ARM_NUM_ADC 12
-
-struct ao_adc {
-       uint16_t        tick;                   /* tick when the sample was read */
-       uint16_t        adc[AO_ARM_NUM_ADC];    /* samples */
-};
-
 /*
  * For now, we're running at a weird frequency
  */
-#define STM_APB1       (16000000 * 6 / 4)
+
+#if AO_HSE
+#define AO_PLLSRC      AO_HSE
+#else
+#define AO_PLLSRC      STM_HSI_FREQ
+#endif
+
+#define AO_PLLVCO      (AO_PLLSRC * AO_PLLMUL)
+#define AO_SYSCLK      (AO_PLLVCO / AO_PLLDIV)
+#define AO_HCLK                (AO_SYSCLK / AO_AHB_PRESCALER)
+#define AO_PCLK1       (AO_HCLK / AO_APB1_PRESCALER)
+#define AO_PCLK2       (AO_HCLK / AO_APB2_PRESCALER)
+
+#if AO_APB1_PRESCALER == 1
+#define AO_TIM23467_CLK                AO_PCLK1
+#else
+#define AO_TIM23467_CLK                (2 * AO_PCLK1)
+#endif
+
+#if AO_APB2_PRESCALER == 1
+#define AO_TIM91011_CLK                AO_PCLK2
+#else
+#define AO_TIM91011_CLK                (2 * AO_PCLK2)
+#endif
 
 void ao_lcd_stm_init(void);
 
@@ -203,5 +219,8 @@ ao_serial3_set_speed(uint8_t speed);
 
 extern uint32_t        ao_radio_cal;
 
+void
+ao_adc_init();
+
 #endif /* _AO_ARCH_H_ */