Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
max1168.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 */
23
24#include "peripherals/max1168.h"
25#include "mcu_periph/spi.h"
26
29
32
34
35/* callback function to lock the spi fifo
36 * after the first transaction
37 */
39
85
86#include "led.h"
87void max1168_read(void)
88{
89 //ASSERT((max1168_status == MAX1168_IDLE), DEBUG_MAX_1168, MAX1168_ERR_READ_OVERUN);
90
91 /* set SPI transaction */
92 /* SPI is locked between the two transactions (callback) */
93 /* SPI is unlocked when EOC is received */
94
97
99}
100
102{
103 // handle request transaction
111 }
112
113 // handle reading transaction
116 // result was already written to max1168_values by DMA
119 }
124 }
125 // Waiting for EOC
126 // FIXME possible race condition, should suspend external int ?
128 // eoc occurs, unlock SPI
131 }
132}
133
138
enum SPIClockPolarity cpol
clock polarity control
Definition spi.h:155
enum SPIClockPhase cpha
clock phase control
Definition spi.h:156
enum SPISlaveSelect select
slave selection behavior
Definition spi.h:154
SPICallback after_cb
NULL or function called after the transaction.
Definition spi.h:161
enum SPIDataSizeSelect dss
data transfer word size
Definition spi.h:157
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
Definition spi.h:150
uint16_t input_length
number of data words to read
Definition spi.h:151
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
Definition spi.h:159
volatile uint8_t * input_buf
pointer to receive buffer for DMA
Definition spi.h:149
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition spi.h:153
enum SPIBitOrder bitorder
MSB/LSB order.
Definition spi.h:158
uint16_t output_length
number of data words to write
Definition spi.h:152
enum SPITransactionStatus status
Definition spi.h:162
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
Definition spi_arch.c:533
bool spi_lock(struct spi_periph *p, uint8_t slave)
spi_lock() function
Definition spi_arch.c:681
void spi_slave_unselect(uint8_t slave)
spi_slave_unselect() function
Definition spi_arch.c:623
bool spi_resume(struct spi_periph *p, uint8_t slave)
spi_resume() function
Definition spi_arch.c:695
@ SPICphaEdge1
CPHA = 0.
Definition spi.h:74
@ SPITransFailed
Definition spi.h:100
@ SPITransSuccess
Definition spi.h:99
@ SPITransDone
Definition spi.h:101
@ SPICpolIdleLow
CPOL = 0.
Definition spi.h:83
@ SPISelect
slave is selected before transaction but not unselected
Definition spi.h:64
@ SPIUnselect
slave is not selected but unselected after transaction
Definition spi.h:65
@ SPIMSBFirst
Definition spi.h:112
@ SPIDiv64
Definition spi.h:125
@ SPIDss16bit
Definition spi.h:91
SPI transaction structure.
Definition spi.h:148
arch independent LED (Light Emitting Diodes) API
uint16_t foo
Definition main_demo5.c:58
volatile uint8_t max1168_status
Definition max1168.c:27
void max1168_init(void)
Definition max1168.c:40
void max1168_lock_cb(struct spi_transaction *t)
Definition max1168.c:134
struct spi_transaction max1168_req_trans
Definition max1168.c:30
uint16_t max1168_conv_req
Definition max1168.c:33
void max1168_event(void)
Definition max1168.c:101
struct spi_transaction max1168_read_trans
Definition max1168.c:31
void max1168_read(void)
Definition max1168.c:87
uint16_t max1168_values[MAX1168_NB_CHAN]
Definition max1168.c:28
#define MAX1168_DATA_AVAILABLE
Definition max1168.h:63
#define MAX1168_CONF_CR
Definition max1168.h:53
#define MAX1168_READING_RES
Definition max1168.h:62
#define MAX1168_SPI_DEV
Definition max1168.h:35
#define MAX1168_GOT_EOC
Definition max1168.h:61
#define MAX1168_SLAVE_IDX
Definition max1168.h:31
#define MAX1168_IDLE
Definition max1168.h:59
#define MAX1168_NB_CHAN
Definition max1168.h:28
#define MAX1168_SENDING_REQ
Definition max1168.h:60
void max1168_arch_init(void)
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.