Mercurial > lcfOS
view python/stm32f4/blink.c3 @ 229:51d5ed1bd503
Added testrunner
author | Windel Bouwman |
---|---|
date | Sat, 13 Jul 2013 11:13:01 +0200 |
parents | 7f18ed9b6b7e |
children | 521567d17388 |
line wrap: on
line source
// This file blinks a LED on the STM32F4 discovery board. package blink; // import bla type struct { // uint32_t SR; } TIM_Type; type struct { int MODER; int OTYPER; int OSPEEDR; int PUPDR; int IDR; int ODR; } GPIO_Type; const GPIO_Type* GPIOD = cast<GPIO_Type*>(0x400000); function void delay(int count) { while (count > 0) { count = count - 1; } } // Globals: var int divider; //const TIM2_s *TIM2;// = (TIM2_s*)0x40004; // Functions: function void tim2_handler() { // if (TIM2->SR & TIM_SR_UIF) if (true) { divider = divider + 1; if (divider == 100000) { divider = 0; //GPIOD->ODR ^= (1 << 13); } } } function void main() { divider = 0; // delay(100); var int* RCC_AHB1ENR; RCC_AHB1ENR = cast<int*>(0x40003022); *RCC_AHB1ENR = *RCC_AHB1ENR | 8943; /* RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; RCC->APB1ENR |= RCC_APB1ENR_TIM2EN; GPIOD->MODER = (1<<26); NVIC->ISER[0] |= 1<< (TIM2_IRQn); TIM2->PSC = 0xE000; TIM2->DIER |= TIM_DIER_UIE; TIM2->ARR = 0xE000; TIM2->CR1 |= TIM_CR1_ARPE | TIM_CR1_CEN; TIM2->EGR = 1; */ while(true) {} }