Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 */
#define MM_NB_AXIS
void micromag_read(void)
void micromag_init(void)
volatile uint8_t micromag_status
signed short int16_t
Definition: types.h:17
volatile int16_t micromag_values[MM_NB_AXIS]
unsigned char uint8_t
Definition: types.h:14
void micromag_reset(void)
void micromag_periodic(void)
void micromag_event(void)