Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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;
62  struct spi_transaction trans;
65  enum pmw3901_state state;
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_
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition: spi.h:153
SPI peripheral structure.
Definition: spi.h:174
SPI transaction structure.
Definition: spi.h:148
volatile uint8_t spi_output_buf[SPI_BUFFER_SIZE]
Definition: pmw3901.h:64
struct spi_periph * periph
Definition: pmw3901.h:61
uint8_t readwrite_state
Definition: pmw3901.h:66
volatile uint8_t spi_input_buf[SPI_BUFFER_SIZE]
Definition: pmw3901.h:63
bool pmw3901_is_idle(struct pmw3901_t *pmw)
Definition: pmw3901.c:312
void pmw3901_start_read(struct pmw3901_t *pmw)
Definition: pmw3901.c:316
float rad_per_px
Definition: pmw3901.h:71
int16_t delta_y
Definition: pmw3901.h:69
void pmw3901_init(struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx)
Definition: pmw3901.c:249
struct spi_transaction trans
Definition: pmw3901.h:62
void pmw3901_event(struct pmw3901_t *pmw)
Definition: pmw3901.c:274
#define SPI_BUFFER_SIZE
Definition: pmw3901.h:48
bool data_available
Definition: pmw3901.h:70
bool pmw3901_data_available(struct pmw3901_t *pmw)
Definition: pmw3901.c:322
uint32_t readwrite_timeout
Definition: pmw3901.h:67
enum pmw3901_state state
Definition: pmw3901.h:65
bool pmw3901_get_data(struct pmw3901_t *pmw, int16_t *delta_x, int16_t *delta_y)
Definition: pmw3901.c:326
int16_t delta_x
Definition: pmw3901.h:68
pmw3901_state
Definition: pmw3901.h:51
@ PMW3901_IDLE
Definition: pmw3901.h:52
@ PMW3901_READ_DELTAXHIGH
Definition: pmw3901.h:55
@ PMW3901_READ_MOTION
Definition: pmw3901.h:53
@ PMW3901_READ_DELTAYLOW
Definition: pmw3901.h:56
@ PMW3901_READ_DELTAXLOW
Definition: pmw3901.h:54
@ PMW3901_READ_DELTAYHIGH
Definition: pmw3901.h:57
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98