Paparazzi UAS  v5.15_devel-229-g3fb4ee4
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pmw3901.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Tom van Dijk
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
39 #ifndef PMW3901_H_
40 #define PMW3901_H_
41 
42 #include "mcu_periph/spi.h"
43 
44 #include <stdbool.h>
45 #include <math.h>
46 
47 
48 #define SPI_BUFFER_SIZE 8
49 
50 
58 };
59 
60 struct pmw3901_t {
61  struct spi_periph *periph;
71  float rad_per_px;
72 };
73 
74 void pmw3901_init(struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx);
75 
76 void pmw3901_event(struct pmw3901_t *pmw);
77 
78 bool pmw3901_is_idle(struct pmw3901_t *pmw);
79 void pmw3901_start_read(struct pmw3901_t *pmw);
80 bool pmw3901_data_available(struct pmw3901_t *pmw);
81 bool pmw3901_get_data(struct pmw3901_t *pmw, int16_t *delta_x, int16_t *delta_y);
82 
83 
84 
85 #endif // PMW3901_H_
bool pmw3901_data_available(struct pmw3901_t *pmw)
Definition: pmw3901.c:322
volatile uint8_t spi_output_buf[SPI_BUFFER_SIZE]
Definition: pmw3901.h:64
enum pmw3901_state state
Definition: pmw3901.h:65
uint32_t readwrite_timeout
Definition: pmw3901.h:67
int16_t delta_x
Definition: pmw3901.h:68
SPI transaction structure.
Definition: spi.h:148
bool data_available
Definition: pmw3901.h:70
pmw3901_state
Definition: pmw3901.h:51
#define SPI_BUFFER_SIZE
Definition: pmw3901.h:48
Architecture independent SPI (Serial Peripheral Interface) API.
bool pmw3901_get_data(struct pmw3901_t *pmw, int16_t *delta_x, int16_t *delta_y)
Definition: pmw3901.c:326
struct spi_transaction trans
Definition: pmw3901.h:62
SPI peripheral structure.
Definition: spi.h:174
unsigned long uint32_t
Definition: types.h:18
signed short int16_t
Definition: types.h:17
uint8_t readwrite_state
Definition: pmw3901.h:66
float rad_per_px
Definition: pmw3901.h:71
void pmw3901_init(struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx)
Definition: pmw3901.c:249
unsigned char uint8_t
Definition: types.h:14
int16_t delta_y
Definition: pmw3901.h:69
volatile uint8_t spi_input_buf[SPI_BUFFER_SIZE]
Definition: pmw3901.h:63
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition: spi.h:153
void pmw3901_start_read(struct pmw3901_t *pmw)
Definition: pmw3901.c:316
bool pmw3901_is_idle(struct pmw3901_t *pmw)
Definition: pmw3901.c:312
struct spi_periph * periph
Definition: pmw3901.h:61
void pmw3901_event(struct pmw3901_t *pmw)
Definition: pmw3901.c:274