PlayBack
Dependencies: TPixy-Interface
Fork of ObjectFollower by
Diff: Drivers/DE0_driver.cpp
- Revision:
- 9:fe56b888985c
- Parent:
- 8:a0890fa79084
--- a/Drivers/DE0_driver.cpp Mon Feb 19 17:42:33 2018 +0000 +++ b/Drivers/DE0_driver.cpp Fri Feb 23 20:58:34 2018 +0000 @@ -1,9 +1,9 @@ /******************************************************************************/ // ECE4333 -// LAB Partner 1: Ahmed Sobhy - ID: 3594449 -// LAB Partner 2: Brandon Kingman - ID: 3470444 -// Project: Autonomous Robot Design -// Instructor: Prof. Chris Diduch +// LAB Partner 1: Ahmed Sobhy - ID: 3594449 +// LAB Partner 2: Brandon Kingman - ID: 3470444 +// Project: Autonomous Robot Design +// Instructor: Prof. Chris Diduch /******************************************************************************/ // filename: DE0_driver.cpp // file content description: @@ -13,6 +13,7 @@ /******************************************************************************/ #include "mbed.h" +#include "DE0_driver.h" #define DUMMY 0 @@ -24,7 +25,6 @@ DigitalOut IoReset(p15); // 0-1-0 reset for all SPI peripherals in the DE0 FPGA DigitalOut SpiReset(p14); // 0-1-0 tells the DE0 SPI interace that the next word sent is a control word - int SignExtend(int16_t x) { // if number is negative @@ -100,17 +100,21 @@ * @param none * @return none *******************************************************************************/ -void DE0_read(uint16_t * id, int * dP, uint16_t * dT) +void DE0_read(sensors_t * sensors) { // To place SPI module into control mode, where the next word received by the // slave is interpreted as a control word. RestartSpi(); // rd = 1 (control if 1) address = 0 no of word = 2 - Specify a read only transactions of 2 words - *id = (uint16_t)DE0.write(0x8002); + sensors->id = (uint16_t)DE0.write(0x8004); // Read the two 16 bits registers from the FPGA - *dP = SignExtend(DE0.write(DUMMY)); // A SPI read only transaction occurs. - *dT = DE0.write(DUMMY); // + sensors->dp_right = SignExtend(DE0.write(DUMMY)); // A SPI read only transaction occurs. + sensors->dt_right = DE0.write(DUMMY); // + + sensors->dp_left = SignExtend(DE0.write(DUMMY)); // A SPI read only transaction occurs. + sensors->dt_left = DE0.write(DUMMY); // + } \ No newline at end of file