1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-30 08:24:11 +01:00

INS: Get the aux uart working. All F2 GPIO pins need to be remapped to work. Good thing to remember.

This commit is contained in:
James Cotton 2011-09-02 15:58:05 -05:00
parent 63f64003e5
commit 5eaebac8d8
3 changed files with 24 additions and 17 deletions

View File

@ -45,7 +45,7 @@
#define PIOS_INCLUDE_SYS
#define PIOS_INCLUDE_USART
#define PIOS_INCLUDE_COM
//#define PIOS_INCLUDE_COM_AUX
#define PIOS_INCLUDE_COM_AUX
#define PIOS_INCLUDE_GPS
#define PIOS_INCLUDE_BMA180
#define PIOS_INCLUDE_HMC5883

View File

@ -289,6 +289,7 @@ void PIOS_SPI_accel_irq_handler(void)
*/
static const struct pios_usart_cfg pios_usart_gps_cfg = {
.regs = USART1,
.remap = GPIO_AF_USART1,
.init = {
.USART_BaudRate = 57600,
.USART_WordLength = USART_WordLength_8b,
@ -328,6 +329,11 @@ static const struct pios_usart_cfg pios_usart_gps_cfg = {
},
};
#define PIOS_COM_AUX_TX_BUF_LEN 255
static uint8_t pios_com_aux_tx_buffer[PIOS_COM_AUX_TX_BUF_LEN];
#define PIOS_COM_AUX_RX_BUF_LEN 255
static uint8_t pios_com_aux_rx_buffer[PIOS_COM_AUX_RX_BUF_LEN];
#endif /* PIOS_INCLUDE_GPS */
#ifdef PIOS_INCLUDE_COM_AUX
@ -335,7 +341,8 @@ static const struct pios_usart_cfg pios_usart_gps_cfg = {
* AUX USART
*/
static const struct pios_usart_cfg pios_usart_aux_cfg = {
.regs = USART4,
.regs = UART4,
.remap = GPIO_AF_UART4,
.init = {
.USART_BaudRate = 57600,
.USART_WordLength = USART_WordLength_8b,
@ -347,14 +354,14 @@ static const struct pios_usart_cfg pios_usart_aux_cfg = {
},
.irq = {
.init = {
.NVIC_IRQChannel = USART4_IRQn,
.NVIC_IRQChannel = UART4_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE,
},
},
.rx = {
.gpio = GPIOB,
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_11,
.GPIO_Speed = GPIO_Speed_2MHz,
@ -364,7 +371,7 @@ static const struct pios_usart_cfg pios_usart_aux_cfg = {
},
},
.tx = {
.gpio = GPIOB,
.gpio = GPIOC,
.init = {
.GPIO_Pin = GPIO_Pin_10,
.GPIO_Speed = GPIO_Speed_2MHz,
@ -375,6 +382,11 @@ static const struct pios_usart_cfg pios_usart_aux_cfg = {
},
};
#define PIOS_COM_GPS_TX_BUF_LEN 192
static uint8_t pios_com_gps_tx_buffer[PIOS_COM_GPS_TX_BUF_LEN];
#define PIOS_COM_GPS_RX_BUF_LEN 96
static uint8_t pios_com_gps_rx_buffer[PIOS_COM_GPS_RX_BUF_LEN];
#endif /* PIOS_COM_AUX */
@ -382,15 +394,6 @@ static const struct pios_usart_cfg pios_usart_aux_cfg = {
#include <pios_com_priv.h>
#if 0
#define PIOS_COM_AUX_TX_BUF_LEN 192
static uint8_t pios_com_aux_tx_buffer[PIOS_COM_AUX_TX_BUF_LEN];
#endif
#define PIOS_COM_GPS_RX_BUF_LEN 96
static uint8_t pios_com_gps_rx_buffer[PIOS_COM_GPS_RX_BUF_LEN];
#endif /* PIOS_INCLUDE_COM */
#if defined(PIOS_INCLUDE_I2C)
@ -732,16 +735,20 @@ void PIOS_Board_Init(void) {
}
if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id,
pios_com_gps_rx_buffer, sizeof(pios_com_gps_rx_buffer),
NULL, 0)) {
pios_com_gps_tx_buffer, sizeof(pios_com_gps_tx_buffer))) {
PIOS_DEBUG_Assert(0);
}
#endif /* PIOS_INCLUDE_GPS */
#if defined(PIOS_INCLUDE_COM_AUX)
uint32_t pios_usart_aux_id;
if (PIOS_USART_Init(&pios_usart_aux_id, &pios_usart_aux_cfg)) {
PIOS_DEBUG_Assert(0);
}
if (PIOS_COM_Init(&pios_com_aux_id, &pios_usart_com_driver, pios_usart_aux_id)) {
if (PIOS_COM_Init(&pios_com_aux_id, &pios_usart_com_driver, pios_usart_aux_id,
pios_com_aux_rx_buffer, sizeof(pios_com_aux_rx_buffer),
pios_com_aux_tx_buffer, sizeof(pios_com_aux_tx_buffer))) {
PIOS_DEBUG_Assert(0);
}
#endif /* PIOS_INCLUDE_COM_AUX */

View File

@ -117,7 +117,7 @@ extern uint32_t pios_i2c_gyro_adapter_id;
// See also pios_board.c
//-------------------------
#define PIOS_COM_MAX_DEVS 2
extern uint32_t pios_com_gps_id;
extern uint32_t pios_com_aux_id;
#define PIOS_COM_AUX (pios_com_aux_id)
#define PIOS_COM_DEBUG PIOS_COM_AUX