[X9D] Serial debug now uses a FIFO, RTC fixed

This commit is contained in:
bernet.andre@gmail.com
2013-02-24 15:48:03 +00:00
parent 5def4849fe
commit 98100708d6
8 changed files with 54 additions and 41 deletions
+3
View File
@@ -171,6 +171,9 @@ void interrupt5ms()
pre_scale = 0 ;
per10ms();
}
#if defined(DEBUG)
debugTx();
#endif
}
extern "C" void TIM8_TRG_COM_TIM14_IRQHandler()
+10 -10
View File
@@ -105,16 +105,16 @@
// Heart Beat
#define PIN_HEART_BEAT GPIO_Pin_7 //PC.07
// 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
// UART3
#define RCC_AHB1Periph_GPIO_UART3 RCC_AHB1Periph_GPIOB
#define RCC_APB1Periph_UART3 RCC_APB1Periph_USART3
#define GPIO_UART3 GPIOB
#define GPIO_PIN_UART3_TX GPIO_Pin_10 //PB.10
#define GPIO_PIN_UART3_RX GPIO_Pin_11 //PB.11
#define GPIO_PinSource_UART3_TX GPIO_PinSource10
#define GPIO_PinSource_UART3_RX GPIO_PinSource11
#define GPIO_AF_UART3 GPIO_AF_USART3
#define UART3 USART3
// USB_OTG
#define PIN_FS_VBUS GPIO_Pin_9 //PA.09
+11 -8
View File
@@ -41,15 +41,18 @@ void rtcSetTime(struct gtm * t)
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;
RTC_TimeStructInit(&RTC_TimeStruct);
RTC_DateStructInit(&RTC_DateStruct);
RTC_TimeStruct.RTC_Hours = t->tm_hour;
RTC_TimeStruct.RTC_Minutes = t->tm_min;
RTC_TimeStruct.RTC_Seconds = t->tm_sec;
RTC_DateStruct.RTC_Year = t->tm_year - 100;
RTC_DateStruct.RTC_Month = t->tm_mon;
RTC_DateStruct.RTC_Month = t->tm_mon + 1;
RTC_DateStruct.RTC_Date = t->tm_mday;
RTC_SetTime(RTC_Format_BCD, &RTC_TimeStruct);
RTC_SetDate(RTC_Format_BCD, &RTC_DateStruct);
RTC_SetTime(RTC_Format_BIN, &RTC_TimeStruct);
RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct);
}
void rtc_gettime(struct gtm * t)
@@ -57,14 +60,14 @@ void rtc_gettime(struct gtm * t)
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;
RTC_GetTime(RTC_Format_BCD, &RTC_TimeStruct);
RTC_GetDate(RTC_Format_BCD, &RTC_DateStruct);
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
t->tm_hour = RTC_TimeStruct.RTC_Hours;
t->tm_min = RTC_TimeStruct.RTC_Minutes;
t->tm_sec = RTC_TimeStruct.RTC_Seconds;
t->tm_year = RTC_DateStruct.RTC_Year + 100;
t->tm_mon = RTC_DateStruct.RTC_Month;
t->tm_mon = RTC_DateStruct.RTC_Month - 1;
t->tm_mday = RTC_DateStruct.RTC_Date;
}
+11 -13
View File
@@ -41,34 +41,32 @@ void uartInit(uint32_t baudrate)
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_UART, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART_DEBUG, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIO_UART3, ENABLE);
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_RX, GPIO_AF_UART);
GPIO_PinAFConfig(GPIO_UART, GPIO_PinSource_UART_TX, GPIO_AF_UART);
GPIO_PinAFConfig(GPIO_UART3, GPIO_PinSource_UART3_RX, GPIO_AF_UART3);
GPIO_PinAFConfig(GPIO_UART3, GPIO_PinSource_UART3_TX, GPIO_AF_UART3);
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_UART_TX | GPIO_PIN_UART_RX;
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_UART3_TX | GPIO_PIN_UART3_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);
GPIO_Init(GPIO_UART3, &GPIO_InitStructure);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART3, ENABLE);
USART_InitStructure.USART_BaudRate = 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_InitStructure.USART_Mode = USART_Mode_Tx;
USART_Init(UART_DEBUG, &USART_InitStructure);
USART_Cmd(UART_DEBUG, ENABLE);
USART_Init(UART3, &USART_InitStructure);
USART_Cmd(UART3, ENABLE);
}
void uartPutc(const char c)
{
USART_SendData(UART_DEBUG, c);
/* Wait for end of previous transfer */
while (USART_GetFlagStatus(UART_DEBUG, USART_FLAG_TC) == RESET);
USART_SendData(UART3, c);
}