mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-06 16:58:48 +08:00
bunch of tests
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Open-BLDC - Open BruschLess DC Motor Controller
|
||||
* Copyright (C) 2009 by Piotr Esden-Tempski <piotr@esden.net>
|
||||
*
|
||||
* This program 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MAIN_H
|
||||
#define __MAIN_H
|
||||
|
||||
int main(void);
|
||||
|
||||
#endif /* __MAIN_H */
|
||||
@@ -24,17 +24,26 @@
|
||||
#include <stm32/flash.h>
|
||||
#include <stm32/misc.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include BOARD_CONFIG
|
||||
#include "init_hw.h"
|
||||
#include "sys_time.h"
|
||||
#include "lisa/lisa_overo_link.h"
|
||||
|
||||
static inline void main_periodic( void );
|
||||
static inline void main_event( void );
|
||||
static inline void on_overo_msg_received(void);
|
||||
static inline void on_overo_link_lost(void);
|
||||
|
||||
struct AutopilotMessageFoo my_msg;
|
||||
|
||||
int main(void) {
|
||||
|
||||
hw_init();
|
||||
sys_time_init();
|
||||
|
||||
overo_link_init();
|
||||
|
||||
while (1) {
|
||||
|
||||
if (sys_time_periodic())
|
||||
@@ -49,9 +58,29 @@ int main(void) {
|
||||
static inline void main_periodic( void ) {
|
||||
// LED_TOGGLE(1);
|
||||
|
||||
uart2_transmit('a');
|
||||
uart2_transmit('b');
|
||||
uart2_transmit('b');
|
||||
uart2_transmit('\n');
|
||||
// uart2_transmit('a');
|
||||
// uart2_transmit('b');
|
||||
// uart2_transmit('b');
|
||||
// uart2_transmit('\n');
|
||||
|
||||
OveroLinkPeriodic(on_overo_link_lost);
|
||||
|
||||
}
|
||||
|
||||
static inline void main_event( void ) {
|
||||
OveroLinkEvent(on_overo_msg_received);
|
||||
// send previously received msg
|
||||
memcpy(overo_link.msg_out, &my_msg, sizeof(my_msg));
|
||||
// store newly received message
|
||||
memcpy(&my_msg, overo_link.msg_in, sizeof(my_msg));
|
||||
}
|
||||
|
||||
|
||||
static inline void on_overo_link_lost(void) {
|
||||
|
||||
}
|
||||
|
||||
static inline void on_overo_msg_received(void) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -91,10 +91,10 @@ static inline void main_periodic_task( void ) {
|
||||
/* set actuators */
|
||||
booz2_commands[COMMAND_PITCH] = 0;
|
||||
booz2_commands[COMMAND_ROLL] = 0;
|
||||
booz2_commands[COMMAND_YAW] = 0;
|
||||
booz2_commands[COMMAND_YAW] = 20;
|
||||
booz2_commands[COMMAND_THRUST] = 0;
|
||||
actuators_set(TRUE);
|
||||
//actuators_set(FALSE);
|
||||
// actuators_set(TRUE);
|
||||
actuators_set(FALSE);
|
||||
}
|
||||
LED_PERIODIC();
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
|
||||
|
||||
// absolute
|
||||
#define BARO_ADDR 0x90
|
||||
//#define BARO_ADDR 0x90
|
||||
// differential
|
||||
//#define BARO_ADDR 0x92
|
||||
#define BARO_ADDR 0x92
|
||||
|
||||
#include <stm32/flash.h>
|
||||
#include <stm32/misc.h>
|
||||
@@ -92,8 +92,9 @@ static inline void main_periodic_task( void ) {
|
||||
if (!initialised) {
|
||||
main_send_reset();
|
||||
//main_send_config();
|
||||
// uint8_t cfg_msb = 0x84;
|
||||
uint8_t cfg_msb = 0x86;
|
||||
uint8_t cfg_msb = 0x84;
|
||||
// double gain ??
|
||||
// uint8_t cfg_msb = 0x86;
|
||||
uint8_t cfg_lsb = 0x83;
|
||||
write_to_register(0x01, cfg_msb, cfg_lsb);
|
||||
// low tresh msb to 0
|
||||
@@ -108,11 +109,18 @@ static inline void main_periodic_task( void ) {
|
||||
|
||||
int16_t adc = foo<<8 | bar;
|
||||
uint16_t adc1 = 255* foo + bar;
|
||||
int16_t bla = 0;
|
||||
DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, &adc, &foo, &bar);
|
||||
DOWNLINK_SEND_BOOT(DefaultChannel, &adc1);
|
||||
//DOWNLINK_SEND_BOOT(DefaultChannel, &adc1);
|
||||
// uint16_t bla = 0;
|
||||
// DOWNLINK_SEND_BOOZ2_BARO_RAW(DefaultChannel, &bla, &adc, &bla);
|
||||
LED_PERIODIC();
|
||||
});
|
||||
|
||||
RunOnceEvery(100, {
|
||||
LED_TOGGLE(3);
|
||||
DOWNLINK_SEND_ALIVE(DefaultChannel, 16, MD5SUM);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
static inline void main_event_task( void ) {
|
||||
@@ -294,8 +302,6 @@ static void main_read_register( uint8_t reg) {
|
||||
I2C_AcknowledgeConfig(I2C2, DISABLE);
|
||||
I2C_GenerateSTOP(I2C2, ENABLE);
|
||||
|
||||
|
||||
|
||||
while (!I2C_CheckEvent(I2C2, I2C_EVENT_MASTER_BYTE_RECEIVED));
|
||||
bar = I2C_ReceiveData(I2C2);
|
||||
|
||||
|
||||
@@ -21,15 +21,9 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stm32/rcc.h>
|
||||
#include <stm32/gpio.h>
|
||||
|
||||
#include <stm32/flash.h>
|
||||
#include <stm32/misc.h>
|
||||
|
||||
#define DATALINK_C
|
||||
|
||||
#include CONFIG
|
||||
#include BOARD_CONFIG
|
||||
#include "init_hw.h"
|
||||
#include "sys_time.h"
|
||||
#include "downlink.h"
|
||||
@@ -58,7 +52,7 @@ static inline void main_init( void ) {
|
||||
}
|
||||
|
||||
static inline void main_periodic( void ) {
|
||||
RunOnceEvery(50, {DOWNLINK_SEND_BOOT(&cpu_time_sec);});
|
||||
RunOnceEvery(100, {DOWNLINK_SEND_ALIVE(DefaultChannel, 16, MD5SUM);});
|
||||
}
|
||||
|
||||
static inline void main_event( void ) {
|
||||
@@ -73,7 +67,7 @@ void dl_parse_msg(void) {
|
||||
|
||||
case DL_PING:
|
||||
{
|
||||
DOWNLINK_SEND_PONG();
|
||||
DOWNLINK_SEND_PONG(DefaultChannel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,19 +26,37 @@
|
||||
|
||||
#include BOARD_CONFIG
|
||||
#include "init_hw.h"
|
||||
#include "led.h"
|
||||
|
||||
void Delay(__IO uint32_t nCount);
|
||||
|
||||
int main(void) {
|
||||
|
||||
hw_init();
|
||||
// led_init(); // handled by PERIPHERALS_AUTO_INIT
|
||||
while (1) {
|
||||
LED_ON(1);
|
||||
Delay(500000);
|
||||
LED_ON(3);
|
||||
LED_ON(5);
|
||||
LED_ON(7);
|
||||
#if 1
|
||||
LED_OFF(0);
|
||||
LED_OFF(2);
|
||||
LED_OFF(4);
|
||||
LED_OFF(6);
|
||||
#endif
|
||||
LED_PERIODIC();
|
||||
Delay(1000000);
|
||||
LED_OFF(1);
|
||||
Delay(500000);
|
||||
LED_OFF(3);
|
||||
LED_OFF(5);
|
||||
LED_OFF(7);
|
||||
#if 1
|
||||
LED_ON(0);
|
||||
LED_ON(2);
|
||||
LED_ON(4);
|
||||
LED_ON(6);
|
||||
#endif
|
||||
LED_PERIODIC();
|
||||
Delay(1000000);
|
||||
|
||||
};
|
||||
return 0;
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
// addr 4
|
||||
// J6 = SCL orange
|
||||
// J7 = SDA
|
||||
|
||||
#include <stm32/flash.h>
|
||||
#include <stm32/misc.h>
|
||||
#include <stm32/i2c.h>
|
||||
@@ -35,7 +39,7 @@ static inline void main_event_task( void );
|
||||
|
||||
static inline void main_i2c_init( void );
|
||||
static inline void main_test_send( void );
|
||||
|
||||
static void test_gpios(void);
|
||||
|
||||
int main(void) {
|
||||
main_init();
|
||||
@@ -53,13 +57,14 @@ int main(void) {
|
||||
static inline void main_init( void ) {
|
||||
hw_init();
|
||||
sys_time_init();
|
||||
main_i2c_init();
|
||||
//main_i2c_init();
|
||||
test_gpios();
|
||||
}
|
||||
|
||||
static inline void main_periodic_task( void ) {
|
||||
|
||||
main_test_send();
|
||||
|
||||
// main_test_send();
|
||||
LED_PERIODIC();
|
||||
}
|
||||
|
||||
static inline void main_event_task( void ) {
|
||||
@@ -67,6 +72,23 @@ static inline void main_event_task( void ) {
|
||||
}
|
||||
|
||||
|
||||
static void test_gpios(void) {
|
||||
/* Enable GPIOB clock */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
||||
/* Configure I2C1 pins: SCL and SDA ------------------------------------------*/
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
|
||||
//GPIOB->BRR = GPIO_Pin_6 | GPIO_Pin_7;
|
||||
|
||||
GPIOC->BSRR = GPIO_Pin_10 | GPIO_Pin_11;
|
||||
}
|
||||
|
||||
|
||||
static inline void main_i2c_init( void ) {
|
||||
|
||||
/* Enable peripheral clocks --------------------------------------------------*/
|
||||
@@ -103,16 +125,18 @@ static inline void main_i2c_init( void ) {
|
||||
|
||||
static inline void main_test_send( void ) {
|
||||
|
||||
// return;
|
||||
/* Send START condition */
|
||||
I2C_GenerateSTART(I2C1, ENABLE);
|
||||
|
||||
/* Test on EV5 and clear it */
|
||||
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
|
||||
|
||||
// return;
|
||||
//return;
|
||||
|
||||
/* Send address */
|
||||
I2C_Send7bitAddress(I2C1, 0x52, I2C_Direction_Transmitter);
|
||||
// I2C_Send7bitAddress(I2C1, 0x52, I2C_Direction_Transmitter);
|
||||
I2C_Send7bitAddress(I2C1, 0x58, I2C_Direction_Transmitter);
|
||||
|
||||
// return;
|
||||
|
||||
@@ -122,7 +146,7 @@ static inline void main_test_send( void ) {
|
||||
// return;
|
||||
|
||||
/* Snd data */
|
||||
I2C_SendData(I2C1, 0x05);
|
||||
I2C_SendData(I2C1, 0x00);
|
||||
|
||||
/* Test on EV8 and clear it */
|
||||
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
|
||||
|
||||
@@ -51,9 +51,11 @@ static inline void main_init( void ) {
|
||||
|
||||
|
||||
static inline void main_periodic_task( void ) {
|
||||
|
||||
i2c1_buf[0] = 0x00;
|
||||
i2c1_transmit(0x58, 1, &i2c_done);
|
||||
|
||||
i2c1_buf[0] = 0x05;
|
||||
i2c1_transmit(0x52, 1, &i2c_done);
|
||||
LED_PERIODIC();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ static inline void main_periodic( void ) {
|
||||
if (bar < -9600) { foo = -foo; bar = -9600;}
|
||||
booz_actuators_pwm_values[0] = 3375 + bar * 1125 / 9600;
|
||||
booz_actuators_pwm_commit();
|
||||
|
||||
LED_PERIODIC();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include BOARD_CONFIG
|
||||
#include "init_hw.h"
|
||||
#include "sys_time.h"
|
||||
#include "downlink.h"
|
||||
|
||||
static inline void main_init( void );
|
||||
static inline void main_periodic_task( void );
|
||||
@@ -64,6 +65,8 @@ static inline void main_periodic_task( void ) {
|
||||
GPIOC->BSRR = GPIO_Pin_4;
|
||||
foo = !foo;
|
||||
#endif
|
||||
RunOnceEvery(10, {DOWNLINK_SEND_BOOT(DefaultChannel, &cpu_time_sec);});
|
||||
LED_PERIODIC();
|
||||
}
|
||||
|
||||
static inline void main_event_task( void ) {
|
||||
@@ -125,6 +128,9 @@ void spi1_irq_handler(void) {
|
||||
static uint8_t cnt = 0;
|
||||
SPI_I2S_SendData(SPI1, cnt);
|
||||
cnt++;
|
||||
LED_TOGGLE(1);
|
||||
LED_TOGGLE(3);
|
||||
DOWNLINK_SEND_DEBUG_MCU_LINK(DefaultChannel, &foo, &foo, &cnt);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,38 +29,21 @@
|
||||
#include BOARD_CONFIG
|
||||
#include "init_hw.h"
|
||||
#include "sys_time.h"
|
||||
#include "downlink.h"
|
||||
#include "fms/fms_autopilot_msg.h"
|
||||
|
||||
static inline void main_init( void );
|
||||
static inline void main_periodic_task( void );
|
||||
static inline void main_event_task( void );
|
||||
|
||||
#define USE_DMA 1
|
||||
//#define USE_DRDY 1
|
||||
|
||||
#define BufferSize 32
|
||||
#define BufferSize sizeof(struct AutopilotMessageFoo)
|
||||
uint8_t SPI_SLAVE_Buffer_Rx[BufferSize];
|
||||
uint8_t SPI_SLAVE_Buffer_Tx[BufferSize];
|
||||
static inline void main_spi_slave_init( void );
|
||||
|
||||
#define SETUP_DMA() { \
|
||||
/* SPI_SLAVE_Rx_DMA_Channel configuration ------------------------------------*/ \
|
||||
DMA_InitTypeDef DMA_InitStructure; \
|
||||
DMA_DeInit(DMA1_Channel2); \
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(SPI1_BASE+0x0C); \
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)SPI_SLAVE_Buffer_Rx; \
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; \
|
||||
DMA_InitStructure.DMA_BufferSize = BufferSize; \
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; \
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; \
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; \
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; \
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; \
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh; \
|
||||
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; \
|
||||
DMA_Init(DMA1_Channel2, &DMA_InitStructure); \
|
||||
}
|
||||
|
||||
|
||||
static inline void main_spi_slave_init(void);
|
||||
static void main_setup_dma(void);
|
||||
static void main_enable_dma(void);
|
||||
|
||||
int main(void) {
|
||||
main_init();
|
||||
@@ -82,14 +65,11 @@ static inline void main_init( void ) {
|
||||
}
|
||||
|
||||
static inline void main_periodic_task( void ) {
|
||||
#ifdef USE_DRDY
|
||||
static uint8_t foo = FALSE;
|
||||
if (foo)
|
||||
GPIOC->BRR = GPIO_Pin_4;
|
||||
else
|
||||
GPIOC->BSRR = GPIO_Pin_4;
|
||||
foo = !foo;
|
||||
#endif
|
||||
RunOnceEvery(10,
|
||||
{
|
||||
DOWNLINK_SEND_BOOT(DefaultChannel, &cpu_time_sec);
|
||||
LED_PERIODIC();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -97,14 +77,12 @@ static inline void main_event_task( void ) {
|
||||
|
||||
#ifdef USE_DMA
|
||||
if (DMA_GetFlagStatus(DMA1_FLAG_TC2)) {
|
||||
LED_TOGGLE(1);
|
||||
SETUP_DMA();
|
||||
/* Enable SPI_1 Rx request */
|
||||
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Rx, ENABLE);
|
||||
/* Enable DMA1 Channel4 */
|
||||
DMA_Cmd(DMA1_Channel2, ENABLE);
|
||||
|
||||
// LED_ON(1);
|
||||
LED_TOGGLE(3);
|
||||
RunOnceEvery(10, {DOWNLINK_SEND_DEBUG_MCU_LINK(DefaultChannel, &SPI_SLAVE_Buffer_Rx[0],
|
||||
&SPI_SLAVE_Buffer_Rx[1], &SPI_SLAVE_Buffer_Rx[2]);});
|
||||
memcpy(SPI_SLAVE_Buffer_Tx, SPI_SLAVE_Buffer_Rx, BufferSize);
|
||||
main_setup_dma();
|
||||
main_enable_dma();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -128,26 +106,10 @@ static inline void main_spi_slave_init( void ) {
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
#ifdef USE_DMA
|
||||
/* SPI_SLAVE_Rx_DMA_Channel configuration ------------------------------------*/
|
||||
SETUP_DMA();
|
||||
#endif
|
||||
|
||||
#ifndef USE_DMA
|
||||
/* Configure the nested vectored interrupt controller. ----------------------*/
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
/* 1 bit for pre-emption priority, 3 bits for subpriority */
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
|
||||
NVIC_InitStructure.NVIC_IRQChannel = SPI1_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
#endif
|
||||
|
||||
/* SPI_SLAVE configuration --------------------------------------------------*/
|
||||
SPI_InitTypeDef SPI_InitStructure;
|
||||
SPI_InitStructure.SPI_Direction = SPI_Direction_1Line_Rx;
|
||||
//SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
||||
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
|
||||
SPI_InitStructure.SPI_Mode = SPI_Mode_Slave;
|
||||
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
|
||||
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
|
||||
@@ -159,38 +121,68 @@ static inline void main_spi_slave_init( void ) {
|
||||
SPI_InitStructure.SPI_CRCPolynomial = 7;
|
||||
SPI_Init(SPI1, &SPI_InitStructure);
|
||||
|
||||
#ifndef USE_DMA
|
||||
/* Enable SPI_SLAVE RXNE interrupt */
|
||||
SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_RXNE, ENABLE);
|
||||
#endif
|
||||
|
||||
/* Enable SPI_SLAVE */
|
||||
SPI_Cmd(SPI1, ENABLE);
|
||||
|
||||
/* Enable SPI_1 Rx request */
|
||||
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Rx, ENABLE);
|
||||
|
||||
/* Enable DMA1 Channel4 */
|
||||
DMA_Cmd(DMA1_Channel2, ENABLE);
|
||||
|
||||
#ifdef USE_DRDY
|
||||
/* enable DRDY signaling */
|
||||
/* configure DATA_READY on PC4 */
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
#ifdef USE_DMA
|
||||
/* SPI_SLAVE_Rx_DMA_Channel configuration ------------------------------------*/
|
||||
main_setup_dma();
|
||||
main_enable_dma();
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void main_setup_dma(void) {
|
||||
/* SPI_SLAVE_Rx_DMA_Channel configuration ------------------------------------*/
|
||||
DMA_InitTypeDef DMA_InitStructure;
|
||||
DMA_DeInit(DMA1_Channel2);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(SPI1_BASE+0x0C);
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)SPI_SLAVE_Buffer_Rx;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
|
||||
DMA_InitStructure.DMA_BufferSize = BufferSize;
|
||||
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
|
||||
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
|
||||
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
|
||||
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
|
||||
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_VeryHigh;
|
||||
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
|
||||
DMA_Init(DMA1_Channel2, &DMA_InitStructure);
|
||||
/* SPI_SLAVE_Tx_DMA_Channel configuration ------------------------------------*/
|
||||
DMA_DeInit(DMA1_Channel3);
|
||||
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(SPI1_BASE+0x0C);
|
||||
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)SPI_SLAVE_Buffer_Tx;
|
||||
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
|
||||
DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;
|
||||
DMA_Init(DMA1_Channel3, &DMA_InitStructure);
|
||||
}
|
||||
|
||||
static void main_enable_dma(void) {
|
||||
/* Enable SPI_1 Rx request */
|
||||
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Rx, ENABLE);
|
||||
/* Enable DMA1 Channel2 */
|
||||
DMA_Cmd(DMA1_Channel2, ENABLE);
|
||||
/* Enable SPI_1 Rx request */
|
||||
SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, ENABLE);
|
||||
/* Enable DMA1 Channel3 */
|
||||
DMA_Cmd(DMA1_Channel3, ENABLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
void spi1_irq_handler(void) {
|
||||
uint8_t foo = SPI_I2S_ReceiveData(SPI1);
|
||||
static uint8_t cnt = 0;
|
||||
SPI_I2S_SendData(SPI1, cnt);
|
||||
cnt++;
|
||||
LED_TOGGLE(1);
|
||||
LED_TOGGLE(4);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void spi1_dma_irq_handler(void) {
|
||||
|
||||
LED_TOGGLE(5);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ static inline void main_init( void ) {
|
||||
|
||||
static inline void main_periodic( void ) {
|
||||
RunOnceEvery(10, {DOWNLINK_SEND_BOOT(DefaultChannel, &cpu_time_sec);});
|
||||
LED_PERIODIC();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user