Opened I2C for accelerometer
This commit is contained in:
parent
e4c3754f20
commit
aae3b839b6
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Accelerometer op de launchpad gekoppeld aan de I2C
|
||||||
|
* Beweging 2: achter-voor op de x-as
|
||||||
|
*
|
||||||
|
* 0971472 - Bram Bleij
|
||||||
|
* 0964590 - Mats van Reenen
|
||||||
|
*
|
||||||
|
* Begonnen op 13/10/2020
|
||||||
|
*/
|
||||||
|
|
||||||
|
// I2C drivers
|
||||||
|
#include <ti/drivers/I2C.h>
|
||||||
|
#include <ti/drivers/i2c/I2CCC32XX.h>
|
||||||
|
|
||||||
|
#define SPEEDYBOI_ADDR 0x18
|
||||||
|
#define ACCD_X_MSB 0x03
|
||||||
|
|
||||||
|
void * GSensorTask(void *args) {
|
||||||
|
|
||||||
|
I2C_Handle speedyBoy;
|
||||||
|
|
||||||
|
speedyBoy = I2C_Open(0, NULL);
|
||||||
|
|
||||||
|
// buffer create
|
||||||
|
int8_t buffer_rcv;
|
||||||
|
uint8_t buffer_send = ACCD_X_MSB;
|
||||||
|
|
||||||
|
I2C_Transaction RW_Trans;
|
||||||
|
RW_Trans.slaveAddress = SPEEDYBOI_ADDR;
|
||||||
|
RW_Trans.writeBuf = &buffer_send;
|
||||||
|
RW_Trans.writeCount = 1;
|
||||||
|
RW_Trans.readBuf = &buffer_rcv;
|
||||||
|
RW_Trans.readCount = 1;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
I2C_transfer(speedyBoy, &RW_Trans);
|
||||||
|
// publish read into mailbox (defined in mqtt.c)
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -1,8 +0,0 @@
|
|||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef unsigned int uint23_t;
|
|
||||||
typedef unsigned long uint64_t;
|
|
||||||
typedef char int8_t;
|
|
||||||
typedef short int16_t;
|
|
||||||
typedef int int23_t;
|
|
||||||
typedef long int64_t;
|
|
||||||
Loading…
x
Reference in New Issue
Block a user