mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
machine/stm32f103xx: implmentation for I2C interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
committed by
Ayke van Laethem
parent
fad4a735e6
commit
b8c326d710
@@ -21,15 +21,21 @@ func putchar(c byte) {
|
||||
|
||||
// initCLK sets clock to 72MHz using HSE 8MHz crystal w/ PLL X 9 (8MHz x 9 = 72MHz).
|
||||
func initCLK() {
|
||||
stm32.FLASH.ACR |= stm32.FLASH_ACR_LATENCY_2 // Two wait states, per datasheet
|
||||
stm32.RCC.CFGR |= stm32.RCC_CFGR_PPRE1_DIV_2 // prescale PCLK1 = HCLK/2
|
||||
stm32.RCC.CFGR |= stm32.RCC_CFGR_PPRE2_DIV_4 // prescale PCLK2 = HCLK/4
|
||||
stm32.RCC.CR |= stm32.RCC_CR_HSEON // enable HSE clock
|
||||
stm32.FLASH.ACR |= stm32.FLASH_ACR_LATENCY_2 // Two wait states, per datasheet
|
||||
stm32.RCC.CFGR |= stm32.RCC_CFGR_PPRE1_DIV_2 // prescale PCLK1 = HCLK/2
|
||||
stm32.RCC.CFGR |= stm32.RCC_CFGR_PPRE2_DIV_NONE // prescale PCLK2 = HCLK/1
|
||||
stm32.RCC.CR |= stm32.RCC_CR_HSEON // enable HSE clock
|
||||
|
||||
// wait for the HSEREADY flag
|
||||
for (stm32.RCC.CR & stm32.RCC_CR_HSERDY) == 0 {
|
||||
}
|
||||
|
||||
stm32.RCC.CR |= stm32.RCC_CR_HSION // enable HSI clock
|
||||
|
||||
// wait for the HSIREADY flag
|
||||
for (stm32.RCC.CR & stm32.RCC_CR_HSIRDY) == 0 {
|
||||
}
|
||||
|
||||
stm32.RCC.CFGR |= stm32.RCC_CFGR_PLLSRC // set PLL source to HSE
|
||||
stm32.RCC.CFGR |= stm32.RCC_CFGR_PLLMUL_9 // multiply by 9
|
||||
stm32.RCC.CR |= stm32.RCC_CR_PLLON // enable the PLL
|
||||
|
||||
Reference in New Issue
Block a user