view python/stm32f4/burn.c3 @ 237:81752b0f85a5

Added burn led test program
author Windel Bouwman
date Wed, 17 Jul 2013 22:31:54 +0200
parents
children ce6d390043a7
line wrap: on
line source

/* 

This file blinks a LED on the STM32F4 discovery board.

the board has 4 leds on PD12, PD13, PD14 and PD15

*/

package blink;

type struct {
    int MODER;
    int OTYPER;
    int OSPEEDR;
    int PUPDR;
    int IDR;
    int ODR;
}* GPIO_Type;

type struct {
    int CR;
    int PLLCFGR;
    int CFGR;
    int CIR;
    int AHB1RSTR;
    int AHB2RSTR;
    int AHB3RSTR;
    int reserved0;
    int APB1RSTR;
    int APB2RSTR;
    int reserved1a, reserved1b;
    int AHB1ENR;
    int AHB2ENR;
    int AHB3ENR;
    int reserved2;
    int APB1ENR, APB2ENR;
}* RCC_Type;


// Functions:
function void main()
{
    // Memory mapped control registers:
    var GPIO_Type GPIOD;
    GPIOD = cast<GPIO_Type>(0x40020C00);
    var RCC_Type RCC;
    RCC = cast<RCC_Type>(0x40023800);

    // Enable the clock to port D:
    RCC->AHB1ENR = RCC->AHB1ENR | (1 << 3);

    var int pin;
    pin = 13;
    // PD13 == output (01)
    GPIOD->MODER = (1 << (pin << 1));
    GPIOD->ODR = (1 << pin);

    while(true) {}
}