Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
mcp355x.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Gautier Hattenberger
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
23 /* driver for MCP3550/1/3
24  */
25 
26 #include "peripherals/mcp355x.h"
27 #include "mcu_periph/spi.h"
28 
32 
33 void mcp355x_init(void) {
35  mcp355x_data = 0;
36 
37  SpiClrCPOL();
38  SpiClrCPHA();
39 }
40 
41 void mcp355x_read(void) {
44  //SpiSelectSlave0();
45  SpiStart();
46 }
47 
48 void mcp355x_event(void) {
51  if ((mcp355x_spi_buf[0]>>4) == 0) {
53  ((uint32_t)mcp355x_spi_buf[0]<<17) |
54  ((uint32_t)mcp355x_spi_buf[1]<<9) |
55  ((uint32_t)mcp355x_spi_buf[2]<<1) |
56  (mcp355x_spi_buf[3]>>7));
58  }
59  }
60 }
61 
bool_t spi_message_received
Definition: sim_baro.c:8
int32_t mcp355x_data
Definition: mcp355x.c:30
uint8_t * spi_buffer_input
Definition: spi.c:28
#define FALSE
Definition: imu_chimu.h:141
arch independent SPI (Serial Peripheral Interface) API
unsigned long uint32_t
Definition: types.h:18
#define SpiClrCPOL()
Definition: spi_arch.h:189
void mcp355x_init(void)
Definition: mcp355x.c:33
uint8_t mcp355x_spi_buf[4]
Definition: mcp355x.c:31
signed long int32_t
Definition: types.h:19
#define TRUE
Definition: imu_chimu.h:144
unsigned char uint8_t
Definition: types.h:14
void mcp355x_event(void)
Definition: mcp355x.c:48
bool_t mcp355x_data_available
Definition: mcp355x.c:29
void mcp355x_read(void)
Definition: mcp355x.c:41
#define SpiClrCPHA()
Definition: spi_arch.h:192
uint8_t spi_buffer_length
Definition: spi.c:30