Skip to content

Commit

Permalink
Minor adjustments for better compatibility with some Linux AVR toolch…
Browse files Browse the repository at this point in the history
…ain components (thanks to Pablo Huijse)
  • Loading branch information
jrowberg committed Jun 1, 2012
1 parent beed5bb commit ade67cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Arduino/MPU6050/MPU6050.cpp
Expand Up @@ -2941,7 +2941,7 @@ void MPU6050::readMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, ui
}
}
}
bool MPU6050::writeMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify, bool useProgMem) {
bool MPU6050::writeMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify, bool useProgMem) {
setMemoryBank(bank);
setMemoryStartAddress(address);
uint8_t chunkSize;
Expand All @@ -2966,7 +2966,7 @@ bool MPU6050::writeMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, u
for (j = 0; j < chunkSize; j++) progBuffer[j] = pgm_read_byte(data + i + j);
} else {
// write the chunk of data as specified
progBuffer = data + i;
progBuffer = (uint8_t *)data + i;
}

I2Cdev::writeBytes(devAddr, MPU6050_RA_MEM_R_W, chunkSize, progBuffer);
Expand Down Expand Up @@ -3017,11 +3017,11 @@ bool MPU6050::writeMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, u
if (useProgMem) free(progBuffer);
return true;
}
bool MPU6050::writeProgMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify) {
bool MPU6050::writeProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank, uint8_t address, bool verify) {
return writeMemoryBlock(data, dataSize, bank, address, verify, true);
}
#define MPU6050_DMP_CONFIG_BLOCK_SIZE 6
bool MPU6050::writeDMPConfigurationSet(uint8_t *data, uint16_t dataSize, bool useProgMem) {
bool MPU6050::writeDMPConfigurationSet(const uint8_t *data, uint16_t dataSize, bool useProgMem) {
uint8_t *progBuffer, success, special;
uint16_t i, j;
if (useProgMem) {
Expand Down Expand Up @@ -3055,7 +3055,7 @@ bool MPU6050::writeDMPConfigurationSet(uint8_t *data, uint16_t dataSize, bool us
if (sizeof(progBuffer) < length) progBuffer = (uint8_t *)realloc(progBuffer, length);
for (j = 0; j < length; j++) progBuffer[j] = pgm_read_byte(data + i + j);
} else {
progBuffer = data + i;
progBuffer = (uint8_t *)data + i;
}
success = writeMemoryBlock(progBuffer, length, bank, offset, true);
i += length;
Expand Down Expand Up @@ -3094,7 +3094,7 @@ bool MPU6050::writeDMPConfigurationSet(uint8_t *data, uint16_t dataSize, bool us
if (useProgMem) free(progBuffer);
return true;
}
bool MPU6050::writeProgDMPConfigurationSet(uint8_t *data, uint16_t dataSize) {
bool MPU6050::writeProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize) {
return writeDMPConfigurationSet(data, dataSize, true);
}

Expand Down
12 changes: 6 additions & 6 deletions Arduino/MPU6050/MPU6050.h
Expand Up @@ -758,11 +758,11 @@ class MPU6050 {
uint8_t readMemoryByte();
void writeMemoryByte(uint8_t data);
void readMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0);
bool writeMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true, bool useProgMem=false);
bool writeProgMemoryBlock(uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true);
bool writeMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true, bool useProgMem=false);
bool writeProgMemoryBlock(const uint8_t *data, uint16_t dataSize, uint8_t bank=0, uint8_t address=0, bool verify=true);

bool writeDMPConfigurationSet(uint8_t *data, uint16_t dataSize, bool useProgMem=false);
bool writeProgDMPConfigurationSet(uint8_t *data, uint16_t dataSize);
bool writeDMPConfigurationSet(const uint8_t *data, uint16_t dataSize, bool useProgMem=false);
bool writeProgDMPConfigurationSet(const uint8_t *data, uint16_t dataSize);

// DMP_CFG_1 register
uint8_t getDMPConfig1();
Expand Down Expand Up @@ -796,7 +796,7 @@ class MPU6050 {
// this block of memory gets written to the MPU on start-up, and it seems
// to be volatile memory, so it has to be done each time (it only takes ~1
// second though)
prog_uchar dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = {
const prog_uchar dmpMemory[MPU6050_DMP_CODE_SIZE] PROGMEM = {
// bank 0, 256 bytes
0xFB, 0x00, 0x00, 0x3E, 0x00, 0x0B, 0x00, 0x36, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00,
0x00, 0x65, 0x00, 0x54, 0xFF, 0xEF, 0x00, 0x00, 0xFA, 0x80, 0x00, 0x0B, 0x12, 0x82, 0x00, 0x01,
Expand Down Expand Up @@ -938,7 +938,7 @@ class MPU6050 {
#define MPU6050_DMP_CONFIG_SIZE 192

// thanks to Noah Zerkin for piecing this stuff together!
prog_uchar dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
const prog_uchar dmpConfig[MPU6050_DMP_CONFIG_SIZE] PROGMEM = {
// BANK OFFSET LENGTH [DATA]
0x03, 0x7B, 0x03, 0x4C, 0xCD, 0x6C, // FCFG_1 inv_set_gyro_calibration
0x03, 0xAB, 0x03, 0x36, 0x56, 0x76, // FCFG_3 inv_set_gyro_calibration
Expand Down

0 comments on commit ade67cf

Please sign in to comment.