2 \author Travis Goodspeed
3 \brief STM32F407 port definitions.
9 //#include "stm322xg_eval.h"
10 #include <stm32f4xx_gpio.h>
11 #include <stm32f4xx_rcc.h>
12 #include <stm32f4xx_rcc.h>
13 //#include "stm32f4_discovery.h"
17 GPIO_InitTypeDef GPIO_InitStructure;
19 /* GPIOD Periph clock enable */
20 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
22 /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
23 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
24 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
25 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
26 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
27 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
28 GPIO_Init(GPIOD, &GPIO_InitStructure);
33 //GPIOG->BSRRL=GPIO_Pin_14;
34 GPIO_ResetBits(GPIOD, GPIO_Pin_14);
37 //GPIOG->BSRRH=GPIO_Pin_14;
38 GPIO_SetBits(GPIOD, GPIO_Pin_14);
42 //! Count the length of a string.
43 uint32_t strlen(const char *s){
47 //! Initialize the STM32F4xx ports and USB.
48 void stm32f4xx_init(){
60 unsigned char serial0_rx(){
64 unsigned char serial1_rx(){
68 void serial0_tx(unsigned char x){
71 void serial_tx_old(unsigned char x){
74 //! Transmit a byte on the second UART.
75 void serial1_tx(unsigned char x){
79 //! Set the baud rate.
80 void setbaud0(unsigned char rate){
81 //Ignore this, as we'll be in USB.
84 //! Set the baud rate of the second uart.
85 void setbaud1(unsigned char rate){
91 void nmi_handler(void);
92 void hardfault_handler(void);
96 void Reset_Handler(void);
100 // Define the vector table
101 unsigned int * myvectors[50]
102 __attribute__ ((section("vectors")))= {
103 (unsigned int *) 0x20000800, // stack pointer
104 (unsigned int *) Reset_Handler, // code entry point
105 (unsigned int *) main, // NMI handler (not really)
106 (unsigned int *) main, // hard fault handler (let's hope not)