BT driver fixes

This commit is contained in:
bsongis
2015-01-31 18:34:08 +01:00
parent ce257527f3
commit 7e9435c721
4 changed files with 12 additions and 8 deletions
@@ -13,7 +13,6 @@
#include "../../fifo.h"
#define BT_UART USART6
#define BT_UART_CLK RCC_APB2Periph_USART6
#define BT_UART_AF GPIO_AF_USART6
#define BT_UART_IRQn USART6_IRQn
@@ -31,7 +30,8 @@ int bt_open()
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
RCC_APB2PeriphClockCmd(BT_UART_CLK, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);
GPIO_PinAFConfig(BT_UART_GPIO_PORT, BT_UART_GPIO_TX_PinSource, BT_UART_AF);
GPIO_PinAFConfig(BT_UART_GPIO_PORT, BT_UART_GPIO_RX_PinSource, BT_UART_AF);
@@ -54,8 +54,7 @@ int bt_open()
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_HardwareFlowControl =
USART_HardwareFlowControl_None;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(BT_UART, &USART_InitStructure);
@@ -72,7 +71,7 @@ int bt_open()
return 0;
}
extern "C" void USART1_IRQHandler(void)
extern "C" void USART6_IRQHandler(void)
{
#if 1
if (USART_GetITStatus(BT_UART, USART_IT_RXNE) != RESET) {
@@ -96,7 +95,7 @@ extern "C" void USART1_IRQHandler(void)
#endif
}
int bt_write(void *buffer, int len)
int bt_write(const void *buffer, int len)
{
uint8_t *data = (uint8_t *)buffer;
for (int i=0; i<len; ++i) {
+1 -1
View File
@@ -139,12 +139,12 @@ void boardInit()
#if defined(REV9E)
rotencInit();
bt_open();
#endif
#if defined(DEBUG)
DBGMCU_APB1PeriphConfig(DBGMCU_IWDG_STOP|DBGMCU_TIM1_STOP|DBGMCU_TIM2_STOP|DBGMCU_TIM3_STOP|DBGMCU_TIM6_STOP|DBGMCU_TIM8_STOP|DBGMCU_TIM10_STOP|DBGMCU_TIM13_STOP|DBGMCU_TIM14_STOP, ENABLE);
#endif
}
#endif
@@ -286,6 +286,11 @@ void uart3Putc(const char c);
void uart3SbusInit(void);
void uart3Stop(void);
// BT driver
int bt_open();
int bt_write(const void *buffer, int len);
int bt_read(void *buffer, int len);
#define USART_FLAG_ERRORS (USART_FLAG_ORE | USART_FLAG_NE | USART_FLAG_FE | USART_FLAG_PE)
#if defined(USB_JOYSTICK) && !defined(SIMU)
+1 -1
View File
@@ -260,7 +260,7 @@ void stop_sbus_on_heartbeat_capture(void)
}
}
#if !defined(SIMU)
#if !defined(SIMU) && !defined(REV9E)
extern "C" void USART6_IRQHandler()
{
uint32_t status;