Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
mag_micromag_fw.h
Go to the documentation of this file.
1
#ifndef MICROMAG_FW_H
2
#define MICROMAG_FW_H
3
4
5
#include "
std.h
"
6
#define MM_NB_AXIS 3
7
8
extern
void
micromag_init
(
void
);
9
extern
void
micromag_read
(
void
);
10
11
extern
void
micromag_reset
(
void
);
12
extern
void
micromag_periodic
(
void
);
13
extern
void
micromag_event
(
void
);
14
15
#define MM_IDLE 0
16
#define MM_BUSY 1
17
#define MM_SENDING_REQ 2
18
#define MM_WAITING_EOC 3
19
#define MM_GOT_EOC 4
20
#define MM_READING_RES 5
21
#define MM_DATA_AVAILABLE 6
22
23
/* ssp input clock 468.75kHz, clock that divided by SCR+1 */
24
#define SSP_CLOCK 468750
25
26
/* SSPCR0 settings */
27
#define SSP_DDS 0x07 << 0
/* data size : 8 bits */
28
#define SSP_FRF 0x00 << 4
/* frame format : SPI */
29
#define SSP_CPOL 0x00 << 6
/* clock polarity : data captured on first clock transition */
30
#define SSP_CPHA 0x00 << 7
/* clock phase : SCK idles low */
31
#define SSP_SCR 0x0F << 8
/* serial clock rate : divide by 16 */
32
33
/* SSPCR1 settings */
34
#define SSP_LBM 0x00 << 0
/* loopback mode : disabled */
35
#define SSP_SSE 0x00 << 1
/* SSP enable : disabled */
36
#define SSP_MS 0x00 << 2
/* master slave mode : master */
37
#define SSP_SOD 0x00 << 3
/* slave output disable : don't care when master */
38
39
#define SS_PIN 20
40
#define SS_IODIR IO0DIR
41
#define SS_IOSET IO0SET
42
#define SS_IOCLR IO0CLR
43
44
#define SSPCR0_VAL (SSP_DDS | SSP_FRF | SSP_CPOL | SSP_CPHA | SSP_SCR )
45
#define SSPCR1_VAL (SSP_LBM | SSP_SSE | SSP_MS | SSP_SOD )
46
47
#define SSP_PINSEL1_SCK (2<<2)
48
#define SSP_PINSEL1_MISO (2<<4)
49
#define SSP_PINSEL1_MOSI (2<<6)
50
51
#define SSP_Enable() SetBit(SSPCR1, SSE);
52
#define SSP_Disable() ClearBit(SSPCR1, SSE);
53
#define SSP_EnableRxi() SetBit(SSPIMSC, RXIM)
54
#define SSP_DisableRxi() ClearBit(SSPIMSC, RXIM)
55
#define SSP_EnableTxi() SetBit(SSPIMSC, TXIM)
56
#define SSP_DisableTxi() ClearBit(SSPIMSC, TXIM)
57
#define SSP_EnableRti() SetBit(SSPIMSC, RTIM);
58
#define SSP_DisableRti() ClearBit(SSPIMSC, RTIM);
59
#define SSP_ClearRti() SetBit(SSPICR, RTIC);
60
61
extern
volatile
uint8_t
micromag_status
;
62
extern
volatile
int16_t
micromag_values
[
MM_NB_AXIS
];
63
64
#endif
/* MICROMAG_H */
micromag_read
void micromag_read(void)
Definition:
mag_micromag_fw.c:64
micromag_values
volatile int16_t micromag_values[MM_NB_AXIS]
Definition:
mag_micromag_fw.c:10
micromag_status
volatile uint8_t micromag_status
Definition:
mag_micromag_fw.c:9
micromag_init
void micromag_init(void)
Definition:
mag_micromag_fw.c:47
micromag_reset
void micromag_reset(void)
Definition:
mag_micromag_fw.c:59
std.h
micromag_periodic
void micromag_periodic(void)
Definition:
mag_micromag_fw.c:13
int16_t
signed short int16_t
Definition:
types.h:17
uint8_t
unsigned char uint8_t
Definition:
types.h:14
micromag_event
void micromag_event(void)
Definition:
mag_micromag_fw.c:31
MM_NB_AXIS
#define MM_NB_AXIS
Definition:
mag_micromag_fw.h:6
sw
airborne
modules
sensors
mag_micromag_fw.h
Generated on Tue Feb 1 2022 13:51:16 for Paparazzi UAS by
1.8.17