Exemple #1
0
void lps331_set_drdy_int(handler_t data_ready_handler, handler_arg_t data_ready_arg)
{
    if(data_ready_handler)
    {
        exti_set_handler(lps331.data_ready_line, data_ready_handler, data_ready_arg);
        exti_enable_interrupt_line(lps331.data_ready_line, EXTI_TRIGGER_RISING);
    }
    else
    {
        exti_disable_interrupt_line(lps331.data_ready_line);
    }
}
Exemple #2
0
void l3g4200d_set_drdy_int(handler_t data_ready_handler,
                                 handler_arg_t data_ready_arg)
{
    // Enable interrupt generation if required
    if (data_ready_handler)
    {
        exti_set_handler(l3g4200d.data_ready_line, data_ready_handler,
                         data_ready_arg);
        exti_enable_interrupt_line(l3g4200d.data_ready_line,
                                   EXTI_TRIGGER_RISING);
    }
    else
    {
        exti_disable_interrupt_line(l3g4200d.data_ready_line);
    }
}
Exemple #3
0
void platform_drivers_setup()
{
    // Set base address and AHB bit for all GPIO ports
    gpio_enable(GPIO_A);
    gpio_enable(GPIO_B);
    gpio_enable(GPIO_C);
    gpio_enable(GPIO_D);

    // Enable the AFIO
    rcc_apb_enable(RCC_APB_BUS_AFIO, RCC_APB_BIT_AFIO);

    // Start the TIM3 at ~32kHz
    timer_enable(TIM_3);
    timer_select_internal_clock(TIM_3, (rcc_sysclk_get_clock_frequency(
                                           RCC_SYSCLK_CLOCK_PCLK1_TIM) / 32768) - 1);
    timer_start(TIM_3, 0xFFFF, NULL, NULL);

    // Enable the print uart
    gpio_set_uart_tx(GPIO_A, GPIO_PIN_9);
    gpio_set_uart_rx(GPIO_A, GPIO_PIN_10);
    uart_enable(UART_1, PLATFORM_UART_PRINT_BAUDRATE);

    // Configure the DMA for the SPIs
    dma_enable(DMA_1_CH4);
    dma_enable(DMA_1_CH5);

    // Configure the SPI 2
    gpio_set_spi_clk(GPIO_B, GPIO_PIN_13);
    gpio_set_spi_miso(GPIO_B, GPIO_PIN_14);
    gpio_set_spi_mosi(GPIO_B, GPIO_PIN_15);
    spi_set_dma(SPI_2, DMA_1_CH4, DMA_1_CH5);
    spi_enable(SPI_2, 4000000, SPI_CLOCK_MODE_IDLE_LOW_RISING);

    // Configure the I2C 1
    gpio_set_i2c_scl(GPIO_B, GPIO_PIN_6);
    gpio_set_i2c_sda(GPIO_B, GPIO_PIN_7);
    i2c_enable(I2C_1, I2C_CLOCK_MODE_FAST);

    // Force inclusion of EXTI
    exti_set_handler(EXTI_LINE_Px0, NULL, NULL);
}