[X9D] Debug UART driver

This commit is contained in:
bernet.andre@gmail.com
2013-01-11 10:12:26 +00:00
parent 2f0cc91aaf
commit a4ea524748
7 changed files with 134 additions and 7 deletions
+2 -1
View File
@@ -496,7 +496,7 @@ ifeq ($(PCB), X9D)
EEPROMSRC = eeprom_avr.cpp # TODO later eeprom_conversions.cpp
PULSESSRC = pulses_arm.cpp
CPPSRC += sky9x/audio.cpp
CPPSRC += x9d/pwr_driver.cpp x9d/eeprom_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp
CPPSRC += x9d/pwr_driver.cpp x9d/eeprom_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp x9d/uart.cpp
CPPSRC += bmp.cpp monitors_views.cpp
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
@@ -504,6 +504,7 @@ ifeq ($(PCB), X9D)
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_spi.c
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_rtc.c
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_pwr.c
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_usart.c
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/gcc_ride7/startup_stm32f2xx.s
ifeq ($(SDCARD), YES)
+2 -1
View File
@@ -121,7 +121,7 @@ void init5msTimer()
// Timer14
RCC->APB1ENR |= RCC_APB1ENR_TIM14EN ; // Enable clock
TIM14->ARR = 4999 ; // 5mS
TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT) / 1000000 - 1 ; // 1uS from 30MHz
TIM14->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1 ; // 1uS from 30MHz
TIM14->CCER = 0 ;
TIM14->CCMR1 = 0 ;
TIM14->EGR = 0 ;
@@ -174,6 +174,7 @@ void boardInit()
__enable_irq() ;
eepromInit();
uartInit();
}
#endif
+4 -1
View File
@@ -41,6 +41,7 @@
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h"
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rtc.h"
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_pwr.h"
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_usart.h"
#include "./STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h"
#include "hal.h"
@@ -48,10 +49,12 @@
#include "i2c_ee.h"
#include "audio_driver.h"
#include "delays.h"
#include "uart.h"
#define PERI1_FREQUENCY 30000000
#define PERI2_FREQUENCY 60000000
#define TIMER_MULT 2
#define TIMER_MULT_APB1 2
#define TIMER_MULT_APB2 1
// TODO elsewhere
#if !defined(SIMU)
+1 -1
View File
@@ -37,7 +37,7 @@ void delaysInit(void)
{
// Timer13
RCC->APB1ENR |= RCC_APB1ENR_TIM13EN; // Enable clock
TIM13->PSC = (PERI1_FREQUENCY * TIMER_MULT) / 10000000 - 1; // 0.1uS
TIM13->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 10000000 - 1; // 0.1uS
TIM13->CCER = 0;
TIM13->CCMR1 = 0;
TIM13->CR1 = 0x02;
+10 -3
View File
@@ -82,9 +82,16 @@
// Heart Beat
#define PIN_HEART_BEAT GPIO_Pin_7 //PC.07
// Update UART----RS232 ---UART3
#define PIN_UPDATE_UART_TX GPIO_Pin_10 //PB.10
#define PIN_UPDATE_UART_RX GPIO_Pin_11 //PB.11
// Debug UART
#define RCC_AHB1Periph_GPIO_UART RCC_AHB1Periph_GPIOB
#define RCC_APB1Periph_UART_DEBUG RCC_APB1Periph_USART3
#define GPIO_UART GPIOB
#define GPIO_PIN_UART_TX GPIO_Pin_10 //PB.10
#define GPIO_PIN_UART_RX GPIO_Pin_11 //PB.11
#define GPIO_PinSource_UART_TX GPIO_PinSource10
#define GPIO_PinSource_UART_RX GPIO_PinSource11
#define GPIO_AF_UART GPIO_AF_USART3
#define UART_DEBUG USART3
// USB_OTG
#define PIN_FS_VBUS GPIO_Pin_9 //PA.09
+73
View File
@@ -0,0 +1,73 @@
/*
* Authors (alphabetical order)
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Jean-Pierre Parisy
* - Karl Szmutny <shadow@privy.de>
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* open9x is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include "../open9x.h"
void uartSendChar(uint8_t c)
{
USART_SendData(UART_DEBUG, c);
/* Wait for end of previous transfer */
while (USART_GetFlagStatus(UART_DEBUG, USART_FLAG_TC) == RESET);
}
void uartInit(void)
{
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_UART, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART_DEBUG, ENABLE);
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_RX, GPIO_AF_UART);
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_TX, GPIO_AF_UART);
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_UART_TX | GPIO_PIN_UART_RX;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIO_UART, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = DEBUG_UART_BAUDRATE;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_Mode = USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init(UART_DEBUG, &USART_InitStructure);
USART_Cmd(UART_DEBUG, ENABLE);
}
+42
View File
@@ -0,0 +1,42 @@
/*
* Authors (alphabetical order)
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Jean-Pierre Parisy
* - Karl Szmutny <shadow@privy.de>
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* open9x is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#ifndef __UART_H
#define __UART_H
#define DEBUG_UART_BAUDRATE 115200
void uartInit(void);
void uartSendChar(uint8_t c);
#endif