X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fstm%2Fao_arch.h;h=adb6eb947a30daec3e4c6ff02c051ff3f5e69fc8;hb=afd52a8b54fe31577d939a161ea9cf5ad48e3a43;hp=fcc177ef0b093fd610cc9e07168d2ad15acf1f24;hpb=d7ddfd4e6d75e50ca64a342181f5c52e9f4919af;p=fw%2Faltos diff --git a/src/stm/ao_arch.h b/src/stm/ao_arch.h index fcc177ef..adb6eb94 100644 --- a/src/stm/ao_arch.h +++ b/src/stm/ao_arch.h @@ -42,7 +42,9 @@ #define __interrupt(n) #define __at(n) -#define ao_arch_reboot() /* XXX */ +#define CORTEX_M3_AIRCR ((uint32_t *) 0xe000ed0c) + +#define ao_arch_reboot() (*((uint32_t *) 0xe000ed0c) = 0x05fa0004) #define ao_arch_nop() asm("nop") @@ -145,17 +147,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); @@ -201,5 +219,10 @@ ao_serial3_pollchar(void); void ao_serial3_set_speed(uint8_t speed); +extern uint32_t ao_radio_cal; + +void +ao_adc_init(); + #endif /* _AO_ARCH_H_ */