1
0
Fork 0

Fix includes for pmw3360 driver (#13108)

This commit is contained in:
Drashna Jaelre 2021-06-05 08:08:35 -07:00 committed by GitHub
parent c7c9f3e3cf
commit 770a3349be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 20 deletions

View file

@ -18,12 +18,12 @@
#ifdef POINTING_DEVICE_ENABLE #ifdef POINTING_DEVICE_ENABLE
#include "wait.h"
#include "debug.h"
#include "print.h"
#include "pmw3360.h" #include "pmw3360.h"
#include "pmw3360_firmware.h" #include "pmw3360_firmware.h"
#ifdef CONSOLE_ENABLE
# include "print.h"
#endif
bool _inBurst = false; bool _inBurst = false;
#ifndef PMW_CPI #ifndef PMW_CPI
@ -36,10 +36,7 @@ bool _inBurst = false;
# define ROTATIONAL_TRANSFORM_ANGLE 0x00 # define ROTATIONAL_TRANSFORM_ANGLE 0x00
#endif #endif
#ifdef CONSOLE_ENABLE
void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); }
#endif
bool spi_start_adv(void) { bool spi_start_adv(void) {
bool status = spi_start(SPI_SS_PIN, false, 3, SPI_DIVISOR); bool status = spi_start(SPI_SS_PIN, false, 3, SPI_DIVISOR);
@ -173,9 +170,7 @@ bool pmw_check_signature(void) {
report_pmw_t pmw_read_burst(void) { report_pmw_t pmw_read_burst(void) {
if (!_inBurst) { if (!_inBurst) {
#ifdef CONSOLE_ENABLE
dprintf("burst on"); dprintf("burst on");
#endif
spi_write_adv(REG_Motion_Burst, 0x00); spi_write_adv(REG_Motion_Burst, 0x00);
_inBurst = true; _inBurst = true;
} }
@ -200,14 +195,12 @@ report_pmw_t pmw_read_burst(void) {
spi_stop(); spi_stop();
#ifdef CONSOLE_ENABLE
print_byte(data.motion); print_byte(data.motion);
print_byte(data.dx); print_byte(data.dx);
print_byte(data.mdx); print_byte(data.mdx);
print_byte(data.dy); print_byte(data.dy);
print_byte(data.mdy); print_byte(data.mdy);
dprintf("\n"); dprintf("\n");
#endif
data.isMotion = (data.motion & 0x80) != 0; data.isMotion = (data.motion & 0x80) != 0;
data.isOnSurface = (data.motion & 0x08) == 0; data.isOnSurface = (data.motion & 0x08) == 0;

View file

@ -16,13 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "wait.h"
#include "debug.h"
#include "print.h"
#include "pmw3360.h" #include "pmw3360.h"
#include "pmw3360_firmware.h" #include "pmw3360_firmware.h"
#ifdef CONSOLE_ENABLE
# include "print.h"
#endif
bool _inBurst = false; bool _inBurst = false;
#ifndef PMW_CPI #ifndef PMW_CPI
@ -35,9 +34,7 @@ bool _inBurst = false;
# define ROTATIONAL_TRANSFORM_ANGLE 0x00 # define ROTATIONAL_TRANSFORM_ANGLE 0x00
#endif #endif
#ifdef CONSOLE_ENABLE
void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); } void print_byte(uint8_t byte) { dprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); }
#endif
bool spi_start_adv(void) { bool spi_start_adv(void) {
@ -172,9 +169,7 @@ bool pmw_check_signature(void) {
report_pmw_t pmw_read_burst(void) { report_pmw_t pmw_read_burst(void) {
if (!_inBurst) { if (!_inBurst) {
#ifdef CONSOLE_ENABLE
dprintf("burst on"); dprintf("burst on");
#endif
spi_write_adv(REG_Motion_Burst, 0x00); spi_write_adv(REG_Motion_Burst, 0x00);
_inBurst = true; _inBurst = true;
} }
@ -199,14 +194,12 @@ report_pmw_t pmw_read_burst(void) {
spi_stop(); spi_stop();
#ifdef CONSOLE_ENABLE
print_byte(data.motion); print_byte(data.motion);
print_byte(data.dx); print_byte(data.dx);
print_byte(data.mdx); print_byte(data.mdx);
print_byte(data.dy); print_byte(data.dy);
print_byte(data.mdy); print_byte(data.mdy);
dprintf("\n"); dprintf("\n");
#endif
data.isMotion = (data.motion & 0x80) != 0; data.isMotion = (data.motion & 0x80) != 0;
data.isOnSurface = (data.motion & 0x08) == 0; data.isOnSurface = (data.motion & 0x08) == 0;