Some minor fixes, but also commented a bunch of not ported code in examples.

The reason is that most of them are reimplementing the
drivers, that they should be using. These code bases are tested by now
in real code. Left warnings all over the place to make sure we revisit
those.
This commit is contained in:
Piotr Esden-Tempski
2012-03-19 01:00:07 -07:00
parent 492be9af9c
commit d09a2cda43
8 changed files with 103 additions and 47 deletions
+1 -1
View File
@@ -1128,7 +1128,7 @@ void i2c1_hw_init(void) {
// enable error interrupts
I2C_CR2(I2C1) |= I2C_CR2_ITERREN;
i2c_setbitrate(&i2c2, I2C2_CLOCK_SPEED);
i2c_setbitrate(&i2c1, I2C2_CLOCK_SPEED);
#endif
}
@@ -24,10 +24,9 @@
#include "subsystems/radio_control.h"
#include "subsystems/radio_control/ppm.h"
#include <stm32/rcc.h>
#include <stm32/gpio.h>
#include <stm32/tim.h>
#include <stm32/misc.h>
#include <libopencm3/stm32/f1/rcc.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/timer.h>
#include "mcu_periph/sys_time.h"
@@ -42,10 +41,14 @@ uint32_t ppm_last_pulse_time;
bool_t ppm_data_valid;
static uint32_t timer_rollover_cnt;
void tim2_irq_handler(void);
void tim2_isr(void);
void ppm_arch_init ( void ) {
#warning "Needs porting to libopencm3"
#if 0
/* TIM2 channel 2 pin (PA.01) configuration */
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
@@ -98,11 +101,14 @@ void ppm_arch_init ( void ) {
ppm_cur_pulse = RADIO_CONTROL_NB_CHANNEL;
timer_rollover_cnt = 0;
#endif
}
void tim2_irq_handler(void) {
void tim2_isr(void) {
#if 0
if(TIM_GetITStatus(TIM2, TIM_IT_CC2) == SET) {
TIM_ClearITPendingBit(TIM2, TIM_IT_CC2);
@@ -114,4 +120,6 @@ void tim2_irq_handler(void) {
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
}
#endif
}
+1
View File
@@ -47,6 +47,7 @@ static inline void main_event_task( void );
static inline void main_on_baro_diff(void);
static inline void main_on_baro_abs(void);
extern struct i2c_errors i2c2_errors;
int main(void) {
main_init();
+24 -9
View File
@@ -28,11 +28,9 @@
*/
#include <stm32/gpio.h>
#include <stm32/flash.h>
#include <stm32/misc.h>
#include <stm32/exti.h>
#include <stm32/spi.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/exti.h>
#include <libopencm3/stm32/spi.h>
#include BOARD_CONFIG
#include "mcu.h"
@@ -49,7 +47,7 @@ static inline void main_event_task( void );
static inline void main_init_hw(void);
void exti2_irq_handler(void);
void exti2_isr(void);
int main(void) {
main_init();
@@ -83,6 +81,9 @@ static uint8_t values[6];
static void write_to_reg(uint8_t addr, uint8_t val) {
#warning "Needs porting to libopencm3 or use the real driver!"
#if 0
AccSelect();
SPI_I2S_SendData(SPI2, addr);
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
@@ -90,10 +91,15 @@ static void write_to_reg(uint8_t addr, uint8_t val) {
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET);
AccUnselect();
#endif
}
static uint8_t read_fom_reg(uint8_t addr) {
#warning "Needs porting to libopencm3 or use the real driver!"
#if 0
AccSelect();
SPI_I2S_SendData(SPI2, (1<<7|addr));
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
@@ -102,10 +108,14 @@ static uint8_t read_fom_reg(uint8_t addr) {
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET);
uint8_t ret = SPI_I2S_ReceiveData(SPI2);
AccUnselect();
#endif
return ret;
}
static void read_data(void) {
#warning "Needs porting to libopencm3 or use the real driver!"
#if 0
AccSelect();
SPI_I2S_SendData(SPI2, (1<<7|1<<6|ADXL345_REG_DATA_X0));
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
@@ -141,6 +151,8 @@ static void read_data(void) {
AccUnselect();
#endif
}
@@ -205,6 +217,9 @@ static inline void main_event_task( void ) {
static inline void main_init_hw( void ) {
#warning "Needs porting to libopencm3 or use the real driver!"
#if 0
/* configure acc slave select */
/* set acc slave select as output and assert it ( on PB12) */
AccUnselect();
@@ -262,6 +277,7 @@ static inline void main_init_hw( void ) {
SPI_Init(SPI2, &SPI_InitStructure);
DEBUG_SERVO2_INIT();
#endif
}
@@ -269,10 +285,9 @@ static inline void main_init_hw( void ) {
void exti2_irq_handler(void) {
/* clear EXTI */
if(EXTI_GetITStatus(EXTI_Line2) != RESET)
EXTI_ClearITPendingBit(EXTI_Line2);
exti_reset_request(EXTI2);
DEBUG_S4_TOGGLE();
//DEBUG_S4_TOGGLE();
acc_ready_for_read = TRUE;
+37 -14
View File
@@ -21,12 +21,10 @@
* Boston, MA 02111-1307, USA.
*/
#include <stm32/gpio.h>
#include <stm32/flash.h>
#include <stm32/misc.h>
#include <stm32/exti.h>
#include <stm32/spi.h>
#include <stm32/dma.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/exti.h>
#include <libopencm3/stm32/spi.h>
#include <libopencm3/stm32/dma.h>
#include BOARD_CONFIG
#include "mcu.h"
@@ -44,8 +42,8 @@ static inline void main_event_task( void );
static inline void main_init_hw(void);
void exti2_irq_handler(void);
void dma1_c4_irq_handler(void);
void exti2_isr(void);
void dma1_channel4_isr(void);
int main(void) {
main_init();
@@ -81,6 +79,9 @@ static uint8_t dma_rx_buf[7];
static void write_to_reg(uint8_t addr, uint8_t val) {
#warning "Needs porting to libopencm3 or the real driver!"
#if 0
AccSelect();
SPI_I2S_SendData(SPI2, addr);
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
@@ -88,10 +89,17 @@ static void write_to_reg(uint8_t addr, uint8_t val) {
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET);
AccUnselect();
#endif
}
static uint8_t read_fom_reg(uint8_t addr) {
uint8_t ret;
#warning "Needs porting to libopencm3 or the real driver!"
#if 0
AccSelect();
SPI_I2S_SendData(SPI2, (1<<7|addr));
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
@@ -100,10 +108,16 @@ static uint8_t read_fom_reg(uint8_t addr) {
while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_BSY) == SET);
uint8_t ret = SPI_I2S_ReceiveData(SPI2);
AccUnselect();
#endif
return ret;
}
static void read_data(void) {
#warning "Needs porting to libopencm3 or the real driver!"
#if 0
AccSelect();
dma_tx_buf[0] = (1<<7|1<<6|ADXL345_REG_DATA_X0);
@@ -154,6 +168,7 @@ static void read_data(void) {
/* Enable DMA1 Channel4 Transfer Complete interrupt */
DMA_ITConfig(DMA1_Channel4, DMA_IT_TC, ENABLE);
#endif
}
@@ -181,7 +196,7 @@ static inline void main_periodic_task( void ) {
/* Enable full res and interrupt active low */
write_to_reg(ADXL345_REG_DATA_FORMAT, 1<<3|1<<5);
/* reads data once to bring interrupt line up */
uint8_t ret = SPI_I2S_ReceiveData(SPI2);
uint8_t ret = spi_read(SPI2);
read_data();
acc_status = CONFIGURED;
}
@@ -206,6 +221,9 @@ static inline void main_event_task( void ) {
static inline void main_init_hw( void ) {
#warning "Needs porting to libopencm3 or the real driver!"
#if 0
/* configure acc slave select */
/* set acc slave select as output and assert it ( on PB12) */
AccUnselect();
@@ -275,23 +293,27 @@ static inline void main_init_hw( void ) {
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
DEBUG_SERVO2_INIT();
#endif
}
void exti2_irq_handler(void) {
void exti2_isr(void) {
/* clear EXTI */
if(EXTI_GetITStatus(EXTI_Line2) != RESET)
EXTI_ClearITPendingBit(EXTI_Line2);
exti_reset_request(EXTI2);
DEBUG_S4_TOGGLE();
//DEBUG_S4_TOGGLE();
read_data();
}
void dma1_c4_irq_handler(void) {
void dma1_channel4_isr(void) {
#warning "Needs porting to libopencm3 or to the real driver!"
#if 0
AccUnselect();
DMA_ITConfig(DMA1_Channel4, DMA_IT_TC, DISABLE);
/* Disable SPI_2 Rx and TX request */
@@ -300,6 +322,7 @@ void dma1_c4_irq_handler(void) {
/* Disable DMA1 Channel4 and 5 */
DMA_Cmd(DMA1_Channel4, DISABLE);
DMA_Cmd(DMA1_Channel5, DISABLE);
#endif
acc_data_available = TRUE;
}
+13 -9
View File
@@ -21,11 +21,9 @@
* Boston, MA 02111-1307, USA.
*/
#include <stm32/gpio.h>
#include <stm32/flash.h>
#include <stm32/misc.h>
#include <stm32/exti.h>
#include <stm32/spi.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/exti.h>
#include <libopencm3/stm32/spi.h>
/*
* lisa/L lisa/M
@@ -60,8 +58,10 @@ struct i2c_transaction t2;
static uint8_t mag_state = 0;
static volatile uint8_t mag_ready_for_read = FALSE;
static uint8_t reading_mag = FALSE;
extern void exti9_5_irq_handler(void);
extern void exti9_5_isr(void);
extern struct i2c_errors i2c2_errors;
int main(void) {
main_init();
@@ -212,6 +212,10 @@ static void send_config(void) {
static inline void main_init_hw( void ) {
#warning "This has to be ported to libopencm3 or using the actual driver!"
#if 0
/* set mag ss as floating input (on PC12) = shorted to I2C2 sda ----------*/
/* set mag reset as floating input (on PC13) = shorted to I2C2 scl ----------*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
@@ -245,16 +249,16 @@ static inline void main_init_hw( void ) {
DEBUG_SERVO1_INIT();
DEBUG_SERVO2_INIT();
#endif
}
void exti9_5_irq_handler(void) {
void exti9_5_isr(void) {
/* clear EXTI */
if(EXTI_GetITStatus(EXTI_Line5) != RESET)
EXTI_ClearITPendingBit(EXTI_Line5);
exti_reset_request(EXTI5);
if (mag_state == INITIALIZED) mag_ready_for_read = TRUE;
}
+11 -8
View File
@@ -28,11 +28,9 @@
*/
#include <stm32/gpio.h>
#include <stm32/flash.h>
#include <stm32/misc.h>
#include <stm32/exti.h>
#include <stm32/spi.h>
#include <libopencm3/stm32/f1/gpio.h>
#include <libopencm3/stm32/exti.h>
#include <libopencm3/stm32/spi.h>
#include BOARD_CONFIG
#include "mcu.h"
@@ -59,7 +57,9 @@ static uint8_t gyro_state = 0;
static volatile uint8_t gyro_ready_for_read = FALSE;
static uint8_t reading_gyro = FALSE;
void exti15_10_irq_handler(void);
void exti15_10_isr(void);
extern struct i2c_errors i2c2_errors;
int main(void) {
main_init();
@@ -219,6 +219,9 @@ static inline void main_event_task( void ) {
}
static inline void main_init_hw( void ) {
#warning "Needs to be ported to libopencm3 or use the real driver!"
#if 0
/* set mag ss as floating input (on PC12) = shorted to sda ------------------------------*/
/* set mag reset as floating input (on PC13) = shorted to scl ------------------------------*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
@@ -259,6 +262,7 @@ static inline void main_init_hw( void ) {
DEBUG_SERVO1_INIT();
DEBUG_SERVO2_INIT();
#endif
}
@@ -268,8 +272,7 @@ void exti15_10_irq_handler(void) {
// DEBUG_S4_ON();
/* clear EXTI */
if(EXTI_GetITStatus(EXTI_Line14) != RESET)
EXTI_ClearITPendingBit(EXTI_Line14);
exti_reset_request(EXTI14);
// DEBUG_S4_TOGGLE();
+2
View File
@@ -46,6 +46,8 @@ static inline void on_gyro_accel_event(void);
static inline void on_accel_event(void);
static inline void on_mag_event(void);
extern struct i2c_errors i2c2_errors;
int main( void ) {
main_init();
while(1) {