Paparazzi UAS  v5.18.0_stable
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;
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_
pmw3901_t::delta_x
int16_t delta_x
Definition: pmw3901.h:68
pmw3901_event
void pmw3901_event(struct pmw3901_t *pmw)
Definition: pmw3901.c:274
PMW3901_READ_DELTAXHIGH
@ PMW3901_READ_DELTAXHIGH
Definition: pmw3901.h:55
pmw3901_t::periph
struct spi_periph * periph
Definition: pmw3901.h:61
pmw3901_t::spi_output_buf
volatile uint8_t spi_output_buf[SPI_BUFFER_SIZE]
Definition: pmw3901.h:64
pmw3901_t::readwrite_timeout
uint32_t readwrite_timeout
Definition: pmw3901.h:67
pmw3901_t::data_available
bool data_available
Definition: pmw3901.h:70
PMW3901_READ_DELTAYHIGH
@ PMW3901_READ_DELTAYHIGH
Definition: pmw3901.h:57
spi.h
pmw3901_data_available
bool pmw3901_data_available(struct pmw3901_t *pmw)
Definition: pmw3901.c:322
pmw3901_t::state
enum pmw3901_state state
Definition: pmw3901.h:65
spi_transaction
SPI transaction structure.
Definition: spi.h:148
uint32_t
unsigned long uint32_t
Definition: types.h:18
PMW3901_IDLE
@ PMW3901_IDLE
Definition: pmw3901.h:52
PMW3901_READ_DELTAXLOW
@ PMW3901_READ_DELTAXLOW
Definition: pmw3901.h:54
PMW3901_READ_MOTION
@ PMW3901_READ_MOTION
Definition: pmw3901.h:53
spi_periph
SPI peripheral structure.
Definition: spi.h:174
SPI_BUFFER_SIZE
#define SPI_BUFFER_SIZE
Definition: pmw3901.h:48
pmw3901_state
pmw3901_state
Definition: pmw3901.h:51
int16_t
signed short int16_t
Definition: types.h:17
pmw3901_get_data
bool pmw3901_get_data(struct pmw3901_t *pmw, int16_t *delta_x, int16_t *delta_y)
Definition: pmw3901.c:326
uint8_t
unsigned char uint8_t
Definition: types.h:14
pmw3901_t::trans
struct spi_transaction trans
Definition: pmw3901.h:62
pmw3901_t::readwrite_state
uint8_t readwrite_state
Definition: pmw3901.h:66
PMW3901_READ_DELTAYLOW
@ PMW3901_READ_DELTAYLOW
Definition: pmw3901.h:56
pmw3901_t::delta_y
int16_t delta_y
Definition: pmw3901.h:69
pmw3901_is_idle
bool pmw3901_is_idle(struct pmw3901_t *pmw)
Definition: pmw3901.c:312
spi_transaction::slave_idx
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
Definition: spi.h:153
pmw3901_t::rad_per_px
float rad_per_px
Definition: pmw3901.h:71
pmw3901_t
Definition: pmw3901.h:60
pmw3901_start_read
void pmw3901_start_read(struct pmw3901_t *pmw)
Definition: pmw3901.c:316
pmw3901_t::spi_input_buf
volatile uint8_t spi_input_buf[SPI_BUFFER_SIZE]
Definition: pmw3901.h:63
pmw3901_init
void pmw3901_init(struct pmw3901_t *pmw, struct spi_periph *periph, uint8_t slave_idx)
Definition: pmw3901.c:249