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
sd_card.c
Go to the documentation of this file.
1 /*
2  * $Id: wt_baro.c 2752 2008-10-09 07:51:24Z gautier $
3  *
4  * Copyright (C) 2007 ENAC
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 
30 #include "sd_card.h"
31 #include "spi.h"
32 
34 
35 static bool_t status_read_data;
36 
37 #define CMD_INIT_1 0x24 // set chanel AIN1/AIN2 and next operation on filter high
38 #define CMD_INIT_2 0xCF // set unipolar mode, 24 bits, no boost, filter high
39 #define CMD_INIT_3 0x34 // set chanel AIN1/AIN2 and next operation on filter low
40 #define CMD_INIT_4 0x00 // set low filter
41 #define CMD_INIT_5 0x14 // set chanel AIN1/AIN2 and next operation on mode register
42 #define CMD_INIT_6 0x20 // set gain to 1, burnout current off, no filter sync, self calibration
43 #define CMD_MEASUREMENT 0x54 // set chanel AIN1/AIN2 and next operation on data register
44 
45 
48 
49 
50 static void send1_on_spi(uint8_t d) {
51  buf_output[0] = d;
53 
56  SpiStart();
57 }
58 
59 
60 void sd_card_init( void ) {
61 
68 
71 
72 }
73 
74 void sd_card_periodic(void) {
75  if (!SpiCheckAvailable()) {
76  SpiOverRun();
77  return;
78  }
79 
80  if (status_read_data) {
81  buf_output[0] = buf_output[1] = buf_output[2] = 0;
83  }
84  else {
87  }
88 
91  //if (status_read_data)
92  // SpiSetCPHA();
93  //else
94  // SpiClrCPHA();
95  SpiStart();
96 }
97 
98 /* Handle the SPI message, i.e. store the received values in variables */
99 void sd_card_event( void ) {
100 
101  if (status_read_data) {
102  } /* else nothing to read */
103 
105 
106 }
107 
uint8_t buf_output[3]
Definition: sd_card.c:47
void sd_card_init(void)
Definition: sd_card.c:60
#define CMD_INIT_1
Definition: sd_card.c:37
#define CMD_MEASUREMENT
Definition: sd_card.c:43
uint8_t buf_input[3]
Definition: sd_card.c:46
uint8_t * spi_buffer_output
Definition: spi.c:29
uint8_t * spi_buffer_input
Definition: spi.c:28
#define FALSE
Definition: imu_chimu.h:141
arch independent SPI (Serial Peripheral Interface) API
#define CMD_INIT_6
Definition: sd_card.c:42
#define CMD_INIT_4
Definition: sd_card.c:40
void sd_card_periodic(void)
Definition: sd_card.c:74
void sd_card_event(void)
Definition: sd_card.c:99
#define CMD_INIT_5
Definition: sd_card.c:41
bool_t sd_card_available
Definition: sd_card.c:33
#define CMD_INIT_2
Definition: sd_card.c:38
unsigned char uint8_t
Definition: types.h:14
static bool_t status_read_data
Definition: sd_card.c:35
#define CMD_INIT_3
Definition: sd_card.c:39
static void send1_on_spi(uint8_t d)
Definition: sd_card.c:50
uint8_t spi_buffer_length
Definition: spi.c:30