X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=firmware%2Flib%2Fstm32f407.c;h=5367012430f6e1c0118169e4e3388d7bf841bda9;hp=fa23289cc0b83d2f17a3e5c89ba377ac4ce2e9c9;hb=e102bade71fcd70ed707339ec1481f5a12587416;hpb=7db4c5ae7e4b65a88db629e617c69961e20deea5 diff --git a/firmware/lib/stm32f407.c b/firmware/lib/stm32f407.c index fa23289..5367012 100644 --- a/firmware/lib/stm32f407.c +++ b/firmware/lib/stm32f407.c @@ -33,6 +33,9 @@ void stmdelay(){ //__IO uint32_t count= 0x100000; // 5 bits per second, for testing while(count--); } + +/* Used for debugging only. + void ledon(){ GPIO_SetBits(GPIOD, GPIO_Pin_14); } @@ -46,6 +49,8 @@ void clkoff(){ GPIO_ResetBits(GPIOD, GPIO_Pin_12); } + + void spibit(int one){ if(one) ledon(); else ledoff(); @@ -74,7 +79,7 @@ void spibyte(uint8_t word){ } } - +*/ //! Count the length of a string. uint32_t strlen(const char *s){ @@ -123,14 +128,17 @@ void USART1_Configuration(void) /* USARTx configuration ------------------------------------------------------*/ /* USARTx configured as follow: - - BaudRate = 9600 baud + - BaudRate = 115200 baud - Word Length = 8 Bits - One Stop Bit - No parity - Hardware flow control disabled (RTS and CTS signals) - Receive and transmit enabled */ - USART_InitStructure.USART_BaudRate = 9600; + //USART_InitStructure.USART_BaudRate = 9600; + //USART_InitStructure.USART_BaudRate = 10000; //Close enough to 9600 + //USART_InitStructure.USART_BaudRate = 115200; + USART_InitStructure.USART_BaudRate = 125200; //Close enough to 115200 USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; @@ -182,23 +190,12 @@ unsigned char serial1_rx(){ //! Transmit a byte. void serial0_tx(unsigned char x){ - spiword(0xdeadbeef); - - spiword(USART1->SR); - - while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET) //original - spiword(USART1->SR); + //Send through USART1 on PB6 + while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); //original USART_SendData(USART1, (uint16_t) x); - spiword(USART1->SR); - - stmdelay(); - stmdelay(); - stmdelay(); - stmdelay(); - stmdelay(); - stmdelay(); - + //Spare goes to SPI. + //spibyte(x); } //! Transmit a byte on the second UART.