Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
ms2100_arch.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3
* Copyright (C) 2012 Gautier Hattenberger
4
*
5
* This file is part of paparazzi.
6
*
7
* paparazzi is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2, or (at your option)
10
* any later version.
11
*
12
* paparazzi is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with paparazzi; see the file COPYING. If not, write to
19
* the Free Software Foundation, 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
21
*/
22
29
#include "
peripherals/ms2100.h
"
30
31
#include "
LPC21xx.h
"
32
#include "
armVIC.h
"
33
#include "
mcu_periph/sys_time.h
"
34
#include BOARD_CONFIG
35
36
static
void
EXTINT_ISR
(
void
) __attribute__((naked));
37
38
void
ms2100_arch_init
(
void
)
39
{
40
41
/* configure RESET pin */
42
Ms2100Reset
();
/* pin idles low */
43
SetBit(
MS2100_RESET_IODIR
,
MS2100_RESET_PIN
);
/* pin is output */
44
45
/* configure DRDY pin */
46
/* connected pin to EXINT */
47
MS2100_DRDY_PINSEL
|=
MS2100_DRDY_PINSEL_VAL
<<
MS2100_DRDY_PINSEL_BIT
;
48
SetBit(
EXTMODE
,
MS2100_DRDY_EINT
);
/* EINT is edge trigered */
49
SetBit(
EXTPOLAR
,
MS2100_DRDY_EINT
);
/* EINT is trigered on rising edge */
50
SetBit(
EXTINT
,
MS2100_DRDY_EINT
);
/* clear pending EINT */
51
52
/* initialize interrupt vector */
53
VICIntSelect
&= ~
VIC_BIT
(
MS2100_DRDY_VIC_IT
);
/* select EINT as IRQ source */
54
VICIntEnable
=
VIC_BIT
(
MS2100_DRDY_VIC_IT
);
/* enable it */
55
_VIC_CNTL
(MS2100_DRDY_VIC_SLOT) =
VIC_ENABLE
|
MS2100_DRDY_VIC_IT
;
56
_VIC_ADDR
(MS2100_DRDY_VIC_SLOT) = (
uint32_t
)
EXTINT_ISR
;
// address of the ISR
57
58
}
59
60
void
EXTINT_ISR
(
void
)
61
{
62
ISR_ENTRY
();
63
/* no, we won't do anything asynchronously, so just notify */
64
ms2100
.
status
=
MS2100_GOT_EOC
;
65
/* clear EINT */
66
EXTINT
= (1 <<
MS2100_DRDY_EINT
);
67
VICVectAddr
= 0x00000000;
/* clear this interrupt from the VIC */
68
ISR_EXIT
();
69
}
70
71
void
ms2100_reset_cb
(
struct
spi_transaction
*t __attribute__((unused)))
72
{
73
// set RESET pin high for at least 100 nsec
74
// busy wait should not harm
75
// storing start and dt is probably long enough...
76
Ms2100Set
();
77
uint32_t
start =
T0TC
;
78
uint32_t
dt =
cpu_ticks_of_nsec
(110);
79
while
((
uint32_t
)(
T0TC
- start) < dt);
80
Ms2100Reset
();
81
}
82
armVIC.h
LPC21xx.h
MS2100_DRDY_PINSEL_BIT
#define MS2100_DRDY_PINSEL_BIT
Definition:
booz_1.0.h:149
VICIntSelect
#define VICIntSelect
Definition:
LPC21xx.h:430
spi_transaction
SPI transaction structure.
Definition:
spi.h:148
EXTMODE
#define EXTMODE
Definition:
LPC21xx.h:419
ms2100.h
uint32_t
unsigned long uint32_t
Definition:
types.h:18
MS2100_DRDY_VIC_IT
#define MS2100_DRDY_VIC_IT
Definition:
booz_1.0.h:152
_VIC_ADDR
#define _VIC_ADDR(idx)
Definition:
armVIC.h:20
ms2100
struct Ms2100 ms2100
Definition:
ms2100.c:44
VIC_BIT
#define VIC_BIT(chan)
Definition:
lpcVIC.h:105
EXTINT
#define EXTINT
Definition:
LPC21xx.h:417
MS2100_DRDY_EINT
#define MS2100_DRDY_EINT
Definition:
booz_1.0.h:151
Ms2100::status
enum Ms2100Status status
Definition:
ms2100.h:50
MS2100_RESET_PIN
#define MS2100_RESET_PIN
Definition:
booz_1.0.h:142
sys_time.h
Architecture independent timing functions.
T0TC
#define T0TC
Definition:
LPC21xx.h:52
VICVectAddr
#define VICVectAddr
Definition:
LPC21xx.h:436
EXTPOLAR
#define EXTPOLAR
Definition:
LPC21xx.h:420
Ms2100Reset
#define Ms2100Reset()
Definition:
ms2100_arch.h:34
ISR_ENTRY
#define ISR_ENTRY()
Definition:
armVIC.h:40
ISR_EXIT
#define ISR_EXIT()
Definition:
armVIC.h:61
ms2100_arch_init
void ms2100_arch_init(void)
Definition:
ms2100_arch.c:38
MS2100_DRDY_PINSEL
#define MS2100_DRDY_PINSEL
Definition:
booz_1.0.h:148
VIC_ENABLE
#define VIC_ENABLE
Definition:
lpcVIC.h:102
VICIntEnable
#define VICIntEnable
Definition:
LPC21xx.h:431
MS2100_RESET_IODIR
#define MS2100_RESET_IODIR
Definition:
booz_1.0.h:143
Ms2100Set
#define Ms2100Set()
Definition:
ms2100_arch.h:35
EXTINT_ISR
static void EXTINT_ISR(void)
Definition:
ms2100_arch.c:60
ms2100_reset_cb
void ms2100_reset_cb(struct spi_transaction *t)
Reset callback.
Definition:
ms2100_arch.c:71
_VIC_CNTL
#define _VIC_CNTL(idx)
Definition:
armVIC.h:19
MS2100_DRDY_PINSEL_VAL
#define MS2100_DRDY_PINSEL_VAL
Definition:
booz_1.0.h:150
cpu_ticks_of_nsec
static uint32_t cpu_ticks_of_nsec(uint32_t nsec)
Definition:
sys_time.h:188
MS2100_GOT_EOC
@ MS2100_GOT_EOC
Definition:
ms2100.h:39
sw
airborne
arch
lpc21
peripherals
ms2100_arch.c
Generated on Tue Feb 1 2022 13:51:12 for Paparazzi UAS by
1.8.17