X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Flib%2Fstm32f407.c;h=167d05ad61eca977398032b0a332f019894aa883;hp=8e22329f0080aaf8dab35724b964326733de9708;hb=9f6b0281ff22d7230550e1c74d29b9eccf8528d6;hpb=62b6ab15afdcff1bf22efa9d285ca34c7816fa7d diff --git a/firmware/lib/stm32f407.c b/firmware/lib/stm32f407.c index 8e22329..167d05a 100644 --- a/firmware/lib/stm32f407.c +++ b/firmware/lib/stm32f407.c @@ -1,9 +1,60 @@ -//! MSP430F2618 clock and I/O definitions - -// Included by other 2xx ports, such as the 2274. +/*! \file stm32f407.h + \author Travis Goodspeed + \brief STM32F407 port definitions. +*/ #include "platform.h" +#include "stm32f4xx.h" +//#include "stm322xg_eval.h" +#include +#include +#include +//#include "stm32f4_discovery.h" + + +void ioinit(){ + GPIO_InitTypeDef GPIO_InitStructure; + + /* GPIOD Periph clock enable */ + RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); + + /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */ + GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(GPIOD, &GPIO_InitStructure); +} + + +void ledon(){ + //GPIOG->BSRRL=GPIO_Pin_14; + GPIO_ResetBits(GPIOD, GPIO_Pin_14); +} +void ledoff(){ + //GPIOG->BSRRH=GPIO_Pin_14; + GPIO_SetBits(GPIOD, GPIO_Pin_14); +} + + +//! Count the length of a string. +uint32_t strlen(const char *s){ + return 0; +} + +//! Initialize the STM32F4xx ports and USB. +void stm32f4xx_init(){ + SystemInit(); + ioinit(); + while(1){ + ledon(); + delay(0x1000); + ledoff(); + delay(0x1000); + } +} //! Receive a byte. unsigned char serial0_rx(){ @@ -35,16 +86,22 @@ void setbaud1(unsigned char rate){ } -void msp430_init_uart(){ -} +//Declarations +void nmi_handler(void); +void hardfault_handler(void); +int main(void); +//From min.s +void Reset_Handler(void); -//! Initialization is correct. -void msp430_init_dco_done(){ -} -//! Initialize the MSP430 clock. -void msp430_init_dco() { -} +// Define the vector table +unsigned int * myvectors[50] + __attribute__ ((section("vectors")))= { + (unsigned int *) 0x20000800, // stack pointer + (unsigned int *) Reset_Handler, // code entry point + (unsigned int *) main, // NMI handler (not really) + (unsigned int *) main, // hard fault handler (let's hope not) +};