Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ms2100_arch.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2010 Antoine Drouin <poinix@gmail.com>
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
24 #include "peripherals/ms2100.h"
25 
26 #include <stm32/rcc.h>
27 #include <stm32/spi.h>
28 #include <stm32/exti.h>
29 #include <stm32/misc.h>
30 #include <stm32/dma.h>
31 
33 int16_t ms2100_last_reading; // can't write in place because that stupid beast
34  // stips stupid values once in a while that I need
35  // to filter - high time we get rid of this crap hardware
36  // and no, I checked with the logic analyzer, timing are
37  // within specs
38 
39 void ms2100_arch_init( void ) {
40 
41  ms2100_cur_axe = 0;
42 
43  /* set mag SS and reset as output and assert them (SS on PC12 reset on PC13) ----*/
45  Ms2100Set();
46 
47  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
48  GPIO_InitTypeDef GPIO_InitStructure;
49  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
50  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
51  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
52  GPIO_Init(GPIOC, &GPIO_InitStructure);
53 
54  /* configure data ready on PB5 */
55  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);
56  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
57  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
58  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
59  GPIO_Init(GPIOB, &GPIO_InitStructure);
60 
61 #ifdef MS2100_HANDLES_DMA_IRQ
62  /* Enable DMA1 channel4 IRQ Channel */
63  NVIC_InitTypeDef NVIC_init_structure_dma = {
64  .NVIC_IRQChannel = DMA1_Channel4_IRQn,
65  .NVIC_IRQChannelPreemptionPriority = 0,
66  .NVIC_IRQChannelSubPriority = 0,
67  .NVIC_IRQChannelCmd = ENABLE
68  };
69  NVIC_Init(&NVIC_init_structure_dma);
70 #endif /* MS2100_HANDLES_DMA_IRQ */
71 
72 #ifdef MS2100_HANDLES_SPI_IRQ
73  NVIC_InitTypeDef NVIC_init_structure_spi = {
74  .NVIC_IRQChannel = SPI2_IRQn,
75  .NVIC_IRQChannelPreemptionPriority = 0,
76  .NVIC_IRQChannelSubPriority = 1,
77  .NVIC_IRQChannelCmd = ENABLE
78  };
79  NVIC_Init(&NVIC_init_structure_spi);
80 #endif /* MS2100_HANDLES_SPI_IRQ */
81 
82 }
83 
84 #ifdef MS2100_HANDLES_SPI_IRQ
85 void spi2_irq_handler(void) {
87 }
88 #endif
89 
90 
91 #ifdef MS2100_HANDLES_DMA_IRQ
92 void dma1_c4_irq_handler(void) {
94 }
95 #endif /* MS2100_HANDLES_DMA_IRQ */
#define Ms2100OnDmaIrq()
Definition: ms2100_arch.h:125
int16_t ms2100_last_reading
Definition: ms2100_arch.c:33
void dma1_c4_irq_handler(void)
#define Ms2100Unselect()
Definition: ms2100_arch.h:20
#define Ms2100Set()
Definition: ms2100_arch.h:23
void spi2_irq_handler(void)
Definition: imu_b2_arch.c:119
signed short int16_t
Definition: types.h:17
volatile uint8_t ms2100_cur_axe
Definition: ms2100_arch.c:11
unsigned char uint8_t
Definition: types.h:14
#define Ms2100OnSpiIrq()
Definition: ms2100_arch.h:143
void ms2100_arch_init(void)
Definition: ms2100_arch.c:39