view python/stm32f4/burn.c3 @ 244:58155c7c4a8e

Add hexutil
author Windel Bouwman
date Wed, 24 Jul 2013 19:47:13 +0200
parents ce6d390043a7
children 6ed3d3a82a63
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 = 15;
    // PD13 == output (01)
    GPIOD->MODER = (1 << (pin << 1));
    GPIOD->ODR = (1 << pin);

    while(true) {}
}