1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

PipBee: Updating project files to fix compile errors. Routine just toggles each LED successively. There is a known error when enabling the PIOS_COM_Init(); or more specifically PIOS_USART_Init(); which blocks at some point when called. This may be due to the pios_board.c defines which I will check later today.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1361 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
patrick 2010-08-21 20:01:37 +00:00 committed by patrick
parent dea2529e38
commit 564a68e825
4 changed files with 247 additions and 221 deletions

View File

@ -85,18 +85,18 @@ TIM8 | | | |
#define PIOS_LED_PINS { PIOS_LED_LED1_GPIO_PIN, PIOS_LED_LED2_GPIO_PIN, PIOS_LED_LED3_GPIO_PIN, PIOS_LED_LED4_GPIO_PIN } #define PIOS_LED_PINS { PIOS_LED_LED1_GPIO_PIN, PIOS_LED_LED2_GPIO_PIN, PIOS_LED_LED3_GPIO_PIN, PIOS_LED_LED4_GPIO_PIN }
#define PIOS_LED_CLKS { PIOS_LED_LED1_GPIO_CLK, PIOS_LED_LED2_GPIO_CLK, PIOS_LED_LED3_GPIO_CLK, PIOS_LED_LED4_GPIO_CLK } #define PIOS_LED_CLKS { PIOS_LED_LED1_GPIO_CLK, PIOS_LED_LED2_GPIO_CLK, PIOS_LED_LED3_GPIO_CLK, PIOS_LED_LED4_GPIO_CLK }
#define USB_LED_ON PIOS_LED_On(LED1); #define USB_LED_ON PIOS_LED_On(LED1)
#define USB_LED_OFF PIOS_LED_Off(LED1); #define USB_LED_OFF PIOS_LED_Off(LED1)
#define USB_LED_TOGGLE PIOS_LED_Toggle(LED1); #define USB_LED_TOGGLE PIOS_LED_Toggle(LED1)
#define LINK_LED_ON PIOS_LED_On(LED2); #define LINK_LED_ON PIOS_LED_On(LED2)
#define LINK_LED_OFF PIOS_LED_Off(LED2); #define LINK_LED_OFF PIOS_LED_Off(LED2)
#define LINK_LED_TOGGLE PIOS_LED_Toggle(LED2); #define LINK_LED_TOGGLE PIOS_LED_Toggle(LED2)
#define RX_LED_ON PIOS_LED_On(LED3); #define RX_LED_ON PIOS_LED_On(LED3)
#define RX_LED_OFF PIOS_LED_Off(LED3); #define RX_LED_OFF PIOS_LED_Off(LED3)
#define RX_LED_TOGGLE PIOS_LED_Toggle(LED3); #define RX_LED_TOGGLE PIOS_LED_Toggle(LED3)
#define TX_LED_ON PIOS_LED_On(LED4); #define TX_LED_ON PIOS_LED_On(LED4)
#define TX_LED_OFF PIOS_LED_Off(LED4); #define TX_LED_OFF PIOS_LED_Off(LED4)
#define TX_LED_TOGGLE PIOS_LED_Toggle(LED4); #define TX_LED_TOGGLE PIOS_LED_Toggle(LED4)
//------------------------- //-------------------------
// Delay Timer // Delay Timer

View File

@ -37,9 +37,11 @@
void PIOS_SPI_perif_irq_handler(void); void PIOS_SPI_perif_irq_handler(void);
void DMA1_Channel5_IRQHandler() __attribute__ ((alias ("PIOS_SPI_perif_irq_handler"))); void DMA1_Channel5_IRQHandler() __attribute__ ((alias ("PIOS_SPI_perif_irq_handler")));
void DMA1_Channel4_IRQHandler() __attribute__ ((alias ("PIOS_SPI_perif_irq_handler"))); void DMA1_Channel4_IRQHandler() __attribute__ ((alias ("PIOS_SPI_perif_irq_handler")));
static const struct pios_spi_cfg pios_spi_perif_cfg = { static const struct pios_spi_cfg pios_spi_perif_cfg =
{
.regs = SPI1, .regs = SPI1,
.init = { .init =
{
.SPI_Mode = SPI_Mode_Master, .SPI_Mode = SPI_Mode_Master,
.SPI_Direction = SPI_Direction_2Lines_FullDuplex, .SPI_Direction = SPI_Direction_2Lines_FullDuplex,
.SPI_DataSize = SPI_DataSize_8b, .SPI_DataSize = SPI_DataSize_8b,
@ -50,23 +52,26 @@ static const struct pios_spi_cfg pios_spi_perif_cfg = {
.SPI_CPHA = SPI_CPHA_2Edge, .SPI_CPHA = SPI_CPHA_2Edge,
.SPI_BaudRatePrescaler = 7 << 3, /* Maximum divider (ie. slowest clock rate) */ .SPI_BaudRatePrescaler = 7 << 3, /* Maximum divider (ie. slowest clock rate) */
}, },
.dma = { .dma =
{
.ahb_clk = RCC_AHBPeriph_DMA1, .ahb_clk = RCC_AHBPeriph_DMA1,
.irq =
.irq = { {
.handler = PIOS_SPI_perif_irq_handler, .handler = PIOS_SPI_perif_irq_handler,
.flags = (DMA1_FLAG_TC4 | DMA1_FLAG_TE4 | DMA1_FLAG_HT4 | DMA1_FLAG_GL4), .flags = (DMA1_FLAG_TC4 | DMA1_FLAG_TE4 | DMA1_FLAG_HT4 | DMA1_FLAG_GL4),
.init = { .init =
{
.NVIC_IRQChannel = DMA1_Channel4_IRQn, .NVIC_IRQChannel = DMA1_Channel4_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0, .NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE, .NVIC_IRQChannelCmd = ENABLE,
}, },
}, },
.rx =
.rx = { {
.channel = DMA1_Channel4, .channel = DMA1_Channel4,
.init = { .init =
{
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
.DMA_DIR = DMA_DIR_PeripheralSRC, .DMA_DIR = DMA_DIR_PeripheralSRC,
.DMA_PeripheralInc = DMA_PeripheralInc_Disable, .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
@ -78,9 +83,11 @@ static const struct pios_spi_cfg pios_spi_perif_cfg = {
.DMA_M2M = DMA_M2M_Disable, .DMA_M2M = DMA_M2M_Disable,
}, },
}, },
.tx = { .tx =
{
.channel = DMA1_Channel5, .channel = DMA1_Channel5,
.init = { .init =
{
.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR), .DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->DR),
.DMA_DIR = DMA_DIR_PeripheralDST, .DMA_DIR = DMA_DIR_PeripheralDST,
.DMA_PeripheralInc = DMA_PeripheralInc_Disable, .DMA_PeripheralInc = DMA_PeripheralInc_Disable,
@ -93,33 +100,41 @@ static const struct pios_spi_cfg pios_spi_perif_cfg = {
}, },
}, },
}, },
.ssel = { .ssel =
{
.gpio = GPIOA, .gpio = GPIOA,
.init = { .init =
{
.GPIO_Pin = GPIO_Pin_4, .GPIO_Pin = GPIO_Pin_4,
.GPIO_Speed = GPIO_Speed_10MHz, .GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_IN_FLOATING, .GPIO_Mode = GPIO_Mode_IN_FLOATING,
}, },
}, },
.sclk = { .sclk =
{
.gpio = GPIOA, .gpio = GPIOA,
.init = { .init =
{
.GPIO_Pin = GPIO_Pin_5, .GPIO_Pin = GPIO_Pin_5,
.GPIO_Speed = GPIO_Speed_10MHz, .GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_IN_FLOATING, .GPIO_Mode = GPIO_Mode_IN_FLOATING,
}, },
}, },
.miso = { .miso =
{
.gpio = GPIOA, .gpio = GPIOA,
.init = { .init =
{
.GPIO_Pin = GPIO_Pin_6, .GPIO_Pin = GPIO_Pin_6,
.GPIO_Speed = GPIO_Speed_10MHz, .GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_AF_PP, .GPIO_Mode = GPIO_Mode_AF_PP,
}, },
}, },
.mosi = { .mosi =
{
.gpio = GPIOA, .gpio = GPIOA,
.init = { .init =
{
.GPIO_Pin = GPIO_Pin_7, .GPIO_Pin = GPIO_Pin_7,
.GPIO_Speed = GPIO_Speed_10MHz, .GPIO_Speed = GPIO_Speed_10MHz,
.GPIO_Mode = GPIO_Mode_IN_FLOATING, .GPIO_Mode = GPIO_Mode_IN_FLOATING,
@ -130,7 +145,8 @@ static const struct pios_spi_cfg pios_spi_perif_cfg = {
/* /*
* Board specific number of devices. * Board specific number of devices.
*/ */
struct pios_spi_dev pios_spi_devs[] = { struct pios_spi_dev pios_spi_devs[] =
{
{ {
.cfg = &pios_spi_perif_cfg, .cfg = &pios_spi_perif_cfg,
}, },
@ -154,9 +170,11 @@ void PIOS_SPI_perif_irq_handler(void)
*/ */
void PIOS_USART_com_irq_handler(void); void PIOS_USART_com_irq_handler(void);
void USART3_IRQHandler() __attribute__ ((alias ("PIOS_USART_com_irq_handler"))); void USART3_IRQHandler() __attribute__ ((alias ("PIOS_USART_com_irq_handler")));
const struct pios_usart_cfg pios_usart_com_cfg = { const struct pios_usart_cfg pios_usart_com_cfg =
{
.regs = USART1, .regs = USART1,
.init = { .init =
{
.USART_BaudRate = 57600, .USART_BaudRate = 57600,
.USART_WordLength = USART_WordLength_8b, .USART_WordLength = USART_WordLength_8b,
.USART_Parity = USART_Parity_No, .USART_Parity = USART_Parity_No,
@ -164,26 +182,32 @@ const struct pios_usart_cfg pios_usart_com_cfg = {
.USART_HardwareFlowControl = USART_HardwareFlowControl_None, .USART_HardwareFlowControl = USART_HardwareFlowControl_None,
.USART_Mode = USART_Mode_Rx | USART_Mode_Tx, .USART_Mode = USART_Mode_Rx | USART_Mode_Tx,
}, },
.irq = { .irq =
{
.handler = PIOS_USART_com_irq_handler, .handler = PIOS_USART_com_irq_handler,
.init = { .init =
{
.NVIC_IRQChannel = USART1_IRQn, .NVIC_IRQChannel = USART1_IRQn,
.NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH, .NVIC_IRQChannelPreemptionPriority = PIOS_IRQ_PRIO_HIGH,
.NVIC_IRQChannelSubPriority = 0, .NVIC_IRQChannelSubPriority = 0,
.NVIC_IRQChannelCmd = ENABLE, .NVIC_IRQChannelCmd = ENABLE,
}, },
}, },
.rx = { .rx =
{
.gpio = GPIOA, .gpio = GPIOA,
.init = { .init =
{
.GPIO_Pin = GPIO_Pin_10, .GPIO_Pin = GPIO_Pin_10,
.GPIO_Speed = GPIO_Speed_2MHz, .GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_IPU, .GPIO_Mode = GPIO_Mode_IPU,
}, },
}, },
.tx = { .tx =
{
.gpio = GPIOA, .gpio = GPIOA,
.init = { .init =
{
.GPIO_Pin = GPIO_Pin_9, .GPIO_Pin = GPIO_Pin_9,
.GPIO_Speed = GPIO_Speed_2MHz, .GPIO_Speed = GPIO_Speed_2MHz,
.GPIO_Mode = GPIO_Mode_AF_PP, .GPIO_Mode = GPIO_Mode_AF_PP,
@ -194,7 +218,8 @@ const struct pios_usart_cfg pios_usart_com_cfg = {
/* /*
* Board specific number of devices. * Board specific number of devices.
*/ */
struct pios_usart_dev pios_usart_devs[] = { struct pios_usart_dev pios_usart_devs[] =
{
#define PIOS_USART_COM 0 #define PIOS_USART_COM 0
{ {
.cfg = &pios_usart_com_cfg, .cfg = &pios_usart_com_cfg,
@ -222,7 +247,8 @@ void PIOS_USART_com_irq_handler(void)
*/ */
extern const struct pios_com_driver pios_usart_com_driver; extern const struct pios_com_driver pios_usart_com_driver;
struct pios_com_dev pios_com_devs[] = { struct pios_com_dev pios_com_devs[] =
{
{ {
.id = PIOS_USART_COM, .id = PIOS_USART_COM,
.driver = &pios_usart_com_driver, .driver = &pios_usart_com_driver,

View File

@ -58,7 +58,7 @@ int main()
PIOS_DELAY_Init(); PIOS_DELAY_Init();
// UART communication system // UART communication system
PIOS_COM_Init(); //PIOS_COM_Init(); // TODO: Find problem when enabling this
// ADC system // ADC system
PIOS_ADC_Init(); PIOS_ADC_Init();