Commit 067aab8c authored by Vidisha Srivastav's avatar Vidisha Srivastav
Browse files

include changes to motor control bindings + minor bug fixes

parent 604ed077
......@@ -272,10 +272,10 @@ acceleration get_raw_accel(ACCEL_TYPE side){
accel = read_bird_accelerometer(&center_sensor);
}
else if(side==RIGHTWING){
accel = read_i2c_accelerometer(&right_wing);
accel = read_i2c_accelerometer(right_wing);
}
else if (side==LEFTWING) {
accel = read_i2c_accelerometer(&left_wing);
accel = read_i2c_accelerometer(left_wing);
}
else
printf("Invalid accelerometer choice. Please select LEFTWING(0), CENTER(1) or RIGHTWING(2)");
......
......@@ -24,10 +24,7 @@ typedef uint8_t ACCEL_TYPE;
void init_accels(void);
acceleration get_raw_accel (uint8_t);
void accel_reset(uint8_t);
<<<<<<< HEAD
void init_accels(void);
=======
>>>>>>> spi-driver-refactor
void test_spi_reading(void);
void test_spi_reset(void);
......
......@@ -15,6 +15,11 @@
static bool initted = false;
/*
Checks if sensor has been initted. If not:
Initializes the Feather M4 SPI bus, selected GPIO pin, and accelerometer object for a new sensor object
*/
void spi_init(spi_sensor_t* device){
if(initted){
return;
......@@ -70,7 +75,7 @@ static void *_read_register (spi_sensor_t *device, uint8_t reg, size_t length)
return device->gbuf;
}
//Uncomment when needed since circuitpython doesn't compile with warnings
// Send a register and value to write within that register over the SPI bus using a buffer
void spi_write_register_byte(spi_sensor_t *device, uint8_t reg, uint8_t value)
{
device->gbuf[0] = reg & 0x7F;
......@@ -80,6 +85,7 @@ void spi_write_register_byte(spi_sensor_t *device, uint8_t reg, uint8_t value)
common_hal_adafruit_bus_device_spidevice_exit(&device->sensor);
}
// Reads an individual byte from a
uint8_t spi_read_register_byte(spi_sensor_t *device, uint8_t reg)
{
return *(int *)_read_register(device, reg, 1);
......
......@@ -61,12 +61,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(control_motor_tasks_obj, 1, control_motor_obj_tasks);
// This is the function that initializes the accelerometers. Called once in python script.
<<<<<<< HEAD
STATIC mp_obj_t control_motor_obj_init_accels(void) {
init_accels();
=======
STATIC mp_obj_t control_motor_obj_init_spi(void) {
>>>>>>> spi-driver-refactor
return mp_const_none;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment