mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 05:42:49 +08:00
add some tests
This commit is contained in:
@@ -7,9 +7,9 @@
|
||||
* PA2 = PWM7
|
||||
* PA3 = PWM6
|
||||
* PA4 = ADC_4 (ADC12 IN 4)+CS43L22 DAC out, capacitively coupled+100Kohm, should not interfere.
|
||||
* PA5 = FREE
|
||||
* PA6 = CANNOT BE USED
|
||||
* PA7 = FREE
|
||||
* PA5 = SPI1 SCK if STM32F4_DISCOVERY_SPI1_FOR_LIS302
|
||||
* PA6 = SPI1 MISO if STM32F4_DISCOVERY_SPI1_FOR_LIS302
|
||||
* PA7 = SPI1 MOSI if STM32F4_DISCOVERY_SPI1_FOR_LIS302
|
||||
* PA8 = SPECTRUM BIND
|
||||
* PA9 = FREE (ONLY if usb is not active during runtime, PC0 must be high or input )
|
||||
* PA10 = UART2 (Spektrum input)
|
||||
@@ -73,7 +73,7 @@
|
||||
* PE0 = CANNOT BE USED (Accel int output)
|
||||
* PE1 = CANNOT BE USED (Accel int output)
|
||||
* PE2 = SPI SLAVE 0
|
||||
* PE3 = FREE (Needs some testing as it is used for the accel spi/i2c select pin)
|
||||
* PE3 = SPI SLAVE 2 (used for the LIS302DL accel spi/i2c select pin)
|
||||
* PE4 = FREE
|
||||
* PE5 = PWM4
|
||||
* PE6 = PWM5
|
||||
@@ -214,6 +214,15 @@
|
||||
/************************************** SPI *************************************************/
|
||||
/***************************************************************************************************/
|
||||
|
||||
#if STM32F4_DISCOVERY_SPI1_FOR_LIS302
|
||||
#define SPI1_GPIO_AF GPIO_AF5
|
||||
#define SPI1_GPIO_PORT_SCK GPIOA
|
||||
#define SPI1_GPIO_SCK GPIO5
|
||||
#define SPI1_GPIO_PORT_MISO GPIOA
|
||||
#define SPI1_GPIO_MISO GPIO6
|
||||
#define SPI1_GPIO_PORT_MOSI GPIOA
|
||||
#define SPI1_GPIO_MOSI GPIO7
|
||||
#else
|
||||
#define SPI1_GPIO_AF GPIO_AF5
|
||||
#define SPI1_GPIO_PORT_SCK GPIOB
|
||||
#define SPI1_GPIO_SCK GPIO3
|
||||
@@ -221,7 +230,7 @@
|
||||
#define SPI1_GPIO_MISO GPIO4
|
||||
#define SPI1_GPIO_PORT_MOSI GPIOB
|
||||
#define SPI1_GPIO_MOSI GPIO5
|
||||
|
||||
#endif
|
||||
|
||||
/* CANNOT BE USED IF PWM CHANNELS 10 & 11 ARE ACTIVE !!! */
|
||||
#define SPI2_GPIO_AF GPIO_AF5
|
||||
@@ -245,6 +254,8 @@
|
||||
#define SPI_SELECT_SLAVE0_PIN GPIO2
|
||||
#define SPI_SELECT_SLAVE1_PORT GPIOE
|
||||
#define SPI_SELECT_SLAVE1_PIN GPIO7
|
||||
#define SPI_SELECT_SLAVE2_PORT GPIOE
|
||||
#define SPI_SELECT_SLAVE2_PIN GPIO3
|
||||
|
||||
|
||||
/***************************************************************************************************/
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file test/peripherals/test_lis302dl_spi.c
|
||||
*
|
||||
* Test for LIS302DL 3-axis accelerometer from ST using SPI.
|
||||
*/
|
||||
|
||||
#include BOARD_CONFIG
|
||||
#include "mcu.h"
|
||||
#include "mcu_periph/sys_time.h"
|
||||
#include "mcu_periph/uart.h"
|
||||
#include "subsystems/datalink/downlink.h"
|
||||
#include "led.h"
|
||||
|
||||
#include "peripherals/lis302dl_spi.h"
|
||||
|
||||
#ifndef LIS302DL_SPI_DEV
|
||||
#define LIS302DL_SPI_DEV spi2
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(LIS302DL_SPI_DEV)
|
||||
|
||||
#ifndef LIS302DL_SPI_SLAVE_IDX
|
||||
#define LIS302DL_SPI_SLAVE_IDX SPI_SLAVE2
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(LIS302DL_SPI_SLAVE_IDX)
|
||||
|
||||
struct Lis302dl_Spi lis302;
|
||||
|
||||
static inline void main_init( void );
|
||||
static inline void main_periodic_task( void );
|
||||
static inline void main_event_task( void );
|
||||
|
||||
int main(void) {
|
||||
main_init();
|
||||
|
||||
while(1) {
|
||||
if (sys_time_check_and_ack_timer(0))
|
||||
main_periodic_task();
|
||||
main_event_task();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static inline void main_init( void ) {
|
||||
mcu_init();
|
||||
mcu_int_enable();
|
||||
|
||||
sys_time_register_timer((1./50), NULL);
|
||||
|
||||
lis302dl_spi_init(&lis302, &(LIS302DL_SPI_DEV), LIS302DL_SPI_SLAVE_IDX);
|
||||
}
|
||||
|
||||
static inline void main_periodic_task( void ) {
|
||||
RunOnceEvery(100, DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM));
|
||||
|
||||
if (sys_time.nb_sec > 1) {
|
||||
lis302dl_spi_periodic(&lis302);
|
||||
#if USE_LED_5
|
||||
RunOnceEvery(10, LED_TOGGLE(5););
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static inline void main_event_task( void ) {
|
||||
if (sys_time.nb_sec > 1)
|
||||
lis302dl_spi_event(&lis302);
|
||||
|
||||
if (lis302.data_available) {
|
||||
struct Int32Vect3 accel;
|
||||
VECT3_COPY(accel, lis302.data.vect);
|
||||
lis302.data_available = FALSE;
|
||||
|
||||
RunOnceEvery(10, {
|
||||
DOWNLINK_SEND_IMU_ACCEL_RAW(DefaultChannel, DefaultDevice,
|
||||
&accel.x, &accel.y, &accel.z);
|
||||
#if USE_LED_6
|
||||
LED_TOGGLE(6);
|
||||
#endif
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user