diff --git a/tmc/ic/TMC2130/TMC2130.c b/tmc/ic/TMC2130/TMC2130.c index ef1508a4..c6999167 100644 --- a/tmc/ic/TMC2130/TMC2130.c +++ b/tmc/ic/TMC2130/TMC2130.c @@ -121,10 +121,13 @@ void tmc2130_initCache() { for (id = 0; id < TMC2130_IC_CACHE_COUNT; id++) { - tmc2130_cache(id, TMC2130_CACHE_FILL_DEFAULT, i, &tmc2130_RegisterConstants[j].value); + uint32_t value = tmc2130_RegisterConstants[j].value; + tmc2130_cache(id, TMC2130_CACHE_FILL_DEFAULT, i, &value); } } } + + (void)motor; } #else // User must implement their own cache @@ -186,6 +189,6 @@ void writeRegisterSPI(uint16_t icID, uint8_t address, int32_t value) // Send the write request tmc2130_readWriteSPI(icID, &data[0], sizeof(data)); //Cache the registers with write-only access - tmc2130_cache(icID, TMC2130_CACHE_WRITE, address, &value); + tmc2130_cache(icID, TMC2130_CACHE_WRITE, address, (uint32_t*)&value); } /***************************************************************************************************************************************************************/ diff --git a/tmc/ic/TMC2160/TMC2160.c b/tmc/ic/TMC2160/TMC2160.c index 95ab6817..e27e7270 100644 --- a/tmc/ic/TMC2160/TMC2160.c +++ b/tmc/ic/TMC2160/TMC2160.c @@ -119,10 +119,12 @@ void tmc2160_initCache() { for (id = 0; id < TMC2160_IC_CACHE_COUNT; id++) { - tmc2160_cache(id, TMC2160_CACHE_FILL_DEFAULT, i, &tmc2160_RegisterConstants[j].value); + uint32_t value = tmc2160_RegisterConstants[j].value; + tmc2160_cache(id, TMC2160_CACHE_FILL_DEFAULT, i, &value); } } } + (void)motor; } #else // User must implement their own cache @@ -184,6 +186,6 @@ void writeRegisterSPI(uint16_t icID, uint8_t address, int32_t value) tmc2160_readWriteSPI(icID, &data[0], sizeof(data)); //Cache the registers with write-only access - tmc2160_cache(icID, TMC2160_CACHE_WRITE, address, &value); + tmc2160_cache(icID, TMC2160_CACHE_WRITE, address, (uint32_t*)&value); } diff --git a/tmc/ic/TMC2208/TMC2208.c b/tmc/ic/TMC2208/TMC2208.c index 0aa47bff..b3053a9a 100644 --- a/tmc/ic/TMC2208/TMC2208.c +++ b/tmc/ic/TMC2208/TMC2208.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -188,7 +188,7 @@ void writeRegisterUART(uint16_t icID, uint8_t registerAddress, int32_t value) tmc2208_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc2208_cache(icID, TMC2208_CACHE_WRITE, registerAddress, &value); + tmc2208_cache(icID, TMC2208_CACHE_WRITE, registerAddress, (uint32_t*)&value); } static uint8_t CRC8(uint8_t *data, uint32_t bytes) diff --git a/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.c b/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.c index 6b964306..cf0c418c 100644 --- a/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.c +++ b/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.c @@ -10,7 +10,7 @@ * Configures the registers with the right settings that are needed for rotating the motor. * E.g Enabling driver, setting IRUN current etc. */ -void initAllMotors(uint16_t icID) +void TMC2209initAllMotors(uint16_t icID) { tmc2209_writeRegister(icID, TMC2209_GCONF, 0x00000040); tmc2209_writeRegister(icID, TMC2209_IHOLD_IRUN, 0x00071703); diff --git a/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.h b/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.h index e3b73668..41353eee 100644 --- a/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.h +++ b/tmc/ic/TMC2209/Examples/TMC2209_Simple_Rotation.h @@ -7,8 +7,8 @@ #ifndef TMC2209_SIMPLE_ROTATION_H_ #define TMC2209_SIMPLE_ROTATION_H_ -#include "TMC2209.h" +#include "../TMC2209.h" -void initAllMotors(uint16_t icID); +void TMC2209initAllMotors(uint16_t icID); #endif diff --git a/tmc/ic/TMC2209/TMC2209.c b/tmc/ic/TMC2209/TMC2209.c index f2bc8c30..92965ba6 100644 --- a/tmc/ic/TMC2209/TMC2209.c +++ b/tmc/ic/TMC2209/TMC2209.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -185,7 +185,7 @@ void writeRegisterUART(uint16_t icID, uint8_t address, int32_t value) tmc2209_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc2209_cache(icID, TMC2209_CACHE_WRITE, address, &value); + tmc2209_cache(icID, TMC2209_CACHE_WRITE, address, (uint32_t*)&value); } static uint8_t CRC8(uint8_t *data, uint32_t bytes) diff --git a/tmc/ic/TMC2224/TMC2224.c b/tmc/ic/TMC2224/TMC2224.c index 9445ab23..5ebdc35e 100644 --- a/tmc/ic/TMC2224/TMC2224.c +++ b/tmc/ic/TMC2224/TMC2224.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -187,7 +187,7 @@ void writeRegisterUART(uint16_t icID, uint8_t address, int32_t value) tmc2224_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc2224_cache(icID, TMC2224_CACHE_WRITE, address, &value); + tmc2224_cache(icID, TMC2224_CACHE_WRITE, address, (uint32_t*)&value); } static uint8_t CRC8(uint8_t *data, uint32_t bytes) diff --git a/tmc/ic/TMC2225/TMC2225.c b/tmc/ic/TMC2225/TMC2225.c index 4396f488..01c065de 100644 --- a/tmc/ic/TMC2225/TMC2225.c +++ b/tmc/ic/TMC2225/TMC2225.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -190,7 +190,7 @@ void writeRegisterUART(uint16_t icID, uint8_t registerAddress, int32_t value) tmc2225_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc2225_cache(icID, TMC2225_CACHE_WRITE, registerAddress, &value); + tmc2225_cache(icID, TMC2225_CACHE_WRITE, registerAddress, (uint32_t*)&value); } static uint8_t CRC8(uint8_t *data, uint32_t bytes) @@ -208,5 +208,6 @@ static uint8_t CRC8(uint8_t *data, uint32_t bytes) // swap nibbles ... result = ((result >> 4) & 0x0F) | ((result & 0x0F) << 4); + (void)table; return result; } diff --git a/tmc/ic/TMC2226/TMC2226.c b/tmc/ic/TMC2226/TMC2226.c index 6abd374d..40dff7d7 100644 --- a/tmc/ic/TMC2226/TMC2226.c +++ b/tmc/ic/TMC2226/TMC2226.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -190,7 +190,7 @@ void writeRegisterUART(uint16_t icID, uint8_t registerAddress, int32_t value) tmc2226_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc2226_cache(icID, TMC2226_CACHE_WRITE, registerAddress, &value); + tmc2226_cache(icID, TMC2226_CACHE_WRITE, registerAddress, (uint32_t*)&value); } static uint8_t CRC8(uint8_t *data, uint32_t bytes) diff --git a/tmc/ic/TMC2240/TMC2240.c b/tmc/ic/TMC2240/TMC2240.c index aa0a0de5..a672e88f 100644 --- a/tmc/ic/TMC2240/TMC2240.c +++ b/tmc/ic/TMC2240/TMC2240.c @@ -12,7 +12,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, 0x24, 0xB5, 0xC7, 0x56, 0x23, 0xB2, 0xC0, 0x51, 0x2A, 0xBB, 0xC9, 0x58, 0x2D, 0xBC, 0xCE, 0x5F, @@ -142,7 +142,8 @@ void tmc2240_initCache() { for (id = 0; id < TMC2240_IC_CACHE_COUNT; id++) { - tmc2240_cache(id, TMC2240_CACHE_FILL_DEFAULT, i, &tmc2240_RegisterConstants[j].value); + uint32_t value = tmc2240_RegisterConstants[j].value; + tmc2240_cache(id, TMC2240_CACHE_FILL_DEFAULT, i, &value); } } } @@ -199,7 +200,7 @@ void tmc2240_writeRegister(uint16_t icID, uint8_t address, int32_t value) writeRegisterUART(icID, address, value); } //Cache the registers with write-only access - tmc2240_cache(icID, TMC2240_CACHE_WRITE, address, &value); + tmc2240_cache(icID, TMC2240_CACHE_WRITE, address, (uint32_t*)&value); } int32_t readRegisterSPI(uint16_t icID, uint8_t address) diff --git a/tmc/ic/TMC2300/TMC2300.c b/tmc/ic/TMC2300/TMC2300.c index 24766481..b2fa8376 100644 --- a/tmc/ic/TMC2300/TMC2300.c +++ b/tmc/ic/TMC2300/TMC2300.c @@ -12,7 +12,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -142,10 +142,12 @@ void tmc2300_initCache() { for (id = 0; id < TMC2300_IC_CACHE_COUNT; id++) { - tmc2300_cache(id, TMC2300_CACHE_FILL_DEFAULT, i, &tmc2300_RegisterConstants[j].value); + uint32_t value = tmc2300_RegisterConstants[j].value; + tmc2300_cache(id, TMC2300_CACHE_FILL_DEFAULT, i, &value); } } } + (void)motor; } #else // User must implement their own cache @@ -226,7 +228,7 @@ void writeRegisterUART(uint16_t icID, uint8_t registerAddress, int32_t value) tmc2300_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc2300_cache(icID, TMC2300_CACHE_WRITE, registerAddress, &value); + tmc2300_cache(icID, TMC2300_CACHE_WRITE, registerAddress, (uint32_t*)&value); } diff --git a/tmc/ic/TMC5031/TMC5031.c b/tmc/ic/TMC5031/TMC5031.c index 843686e9..06c834da 100644 --- a/tmc/ic/TMC5031/TMC5031.c +++ b/tmc/ic/TMC5031/TMC5031.c @@ -119,10 +119,12 @@ void tmc5031_initCache() { for (id = 0; id < TMC5031_IC_CACHE_COUNT; id++) { - tmc5031_cache(id, TMC5031_CACHE_FILL_DEFAULT, i, &tmc5031_RegisterConstants[j].value); + uint32_t value = tmc5031_RegisterConstants[j].value; + tmc5031_cache(id, TMC5031_CACHE_FILL_DEFAULT, i, &value); } } } + (void)motor; } #else // User must implement their own cache @@ -186,5 +188,5 @@ void writeRegisterSPI(uint16_t icID, uint8_t address, int32_t value) tmc5031_readWriteSPI(icID, &data[0], sizeof(data)); //Cache the registers with write-only access - tmc5031_cache(icID, TMC5031_CACHE_WRITE, address, &value); + tmc5031_cache(icID, TMC5031_CACHE_WRITE, address, (uint32_t*)&value); } diff --git a/tmc/ic/TMC5041/TMC5041.c b/tmc/ic/TMC5041/TMC5041.c index f5b203b7..0ec991ec 100644 --- a/tmc/ic/TMC5041/TMC5041.c +++ b/tmc/ic/TMC5041/TMC5041.c @@ -9,6 +9,11 @@ #include "TMC5041.h" +// => SPI wrapper +extern void tmc5041_readWriteSPI(uint16_t icID, uint8_t *data, size_t dataLength); +// <= SPI wrapper + + /**************************************************************** Cache Implementation *************************************************************************/ @@ -121,10 +126,12 @@ void tmc5041_initCache() { for (id = 0; id < TMC5041_IC_CACHE_COUNT; id++) { - tmc5041_cache(id, TMC5041_CACHE_FILL_DEFAULT, i, &tmc5041_RegisterConstants[j].value); + uint32_t value = tmc5041_RegisterConstants[j].value; + tmc5041_cache(id, TMC5041_CACHE_FILL_DEFAULT, i, &value); } } } + (void)motor; } #else // User must implement their own cache @@ -189,5 +196,5 @@ void writeRegisterSPI(uint16_t icID, uint8_t address, int32_t value) tmc5041_readWriteSPI(icID, &data[0], sizeof(data)); //Cache the registers with write-only access - tmc5041_cache(icID, TMC5041_CACHE_WRITE, address, &value); + tmc5041_cache(icID, TMC5041_CACHE_WRITE, address, (uint32_t*)&value); } diff --git a/tmc/ic/TMC5062/TMC5062.c b/tmc/ic/TMC5062/TMC5062.c index ae53f57e..33cb94d2 100644 --- a/tmc/ic/TMC5062/TMC5062.c +++ b/tmc/ic/TMC5062/TMC5062.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -141,7 +141,8 @@ void tmc5062_initCache() { for (id = 0; id < TMC5062_IC_CACHE_COUNT; id++) { - tmc5062_cache(id, TMC5062_CACHE_FILL_DEFAULT, i, &tmc5062_RegisterConstants[j].value); + uint32_t value = tmc5062_RegisterConstants[j].value; + tmc5062_cache(id, TMC5062_CACHE_FILL_DEFAULT, i, &value); } } } @@ -235,7 +236,7 @@ void writeRegisterSPI(uint16_t icID, uint8_t address, int32_t value) tmc5062_readWriteSPI(icID, &data[0], sizeof(data)); //Cache the registers with write-only access - tmc5062_cache(icID, TMC5062_CACHE_WRITE, address, &value); + tmc5062_cache(icID, TMC5062_CACHE_WRITE, address, (uint32_t*)&value); } int32_t readRegisterUART(uint16_t icID, uint8_t address) @@ -281,7 +282,7 @@ void writeRegisterUART(uint16_t icID, uint8_t address, int32_t value) tmc5062_readWriteUART(icID, &data[0], 7, 0); //Cache the registers with write-only access - tmc5062_cache(icID, TMC5062_CACHE_WRITE, address, &value); + tmc5062_cache(icID, TMC5062_CACHE_WRITE, address, (uint32_t*)&value); } void tmc5062_rotateMotor(uint16_t icID, uint8_t motor, int32_t velocity) @@ -309,5 +310,6 @@ static uint8_t CRC8(uint8_t *data, uint32_t bytes) // swap nibbles ... result = ((result >> 4) & 0x0F) | ((result & 0x0F) << 4); + (void)table; return result; } diff --git a/tmc/ic/TMC5072/TMC5072.c b/tmc/ic/TMC5072/TMC5072.c index 49e00056..3b652559 100644 --- a/tmc/ic/TMC5072/TMC5072.c +++ b/tmc/ic/TMC5072/TMC5072.c @@ -11,7 +11,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -141,10 +141,12 @@ void tmc5072_initCache() { for (id = 0; id < TMC5072_IC_CACHE_COUNT; id++) { - tmc5072_cache(id, TMC5072_CACHE_FILL_DEFAULT, i, &tmc5072_RegisterConstants[j].value); + uint32_t value = tmc5072_RegisterConstants[j].value; + tmc5072_cache(id, TMC5072_CACHE_FILL_DEFAULT, i, &value); } } } + (void)motor; } #else // User must implement their own cache @@ -196,7 +198,7 @@ void tmc5072_writeRegister(uint16_t icID, uint8_t address, int32_t value) } //Cache the registers with write-only access - tmc5072_cache(icID, TMC5072_CACHE_WRITE, address, &value); + tmc5072_cache(icID, TMC5072_CACHE_WRITE, address, (uint32_t*)&value); } int32_t readRegisterSPI(uint16_t icID, uint8_t address) @@ -298,6 +300,7 @@ static uint8_t CRC8(uint8_t *data, uint32_t bytes) // swap nibbles ... result = ((result >> 4) & 0x0F) | ((result & 0x0F) << 4); + (void)table; return result; } diff --git a/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.c b/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.c index 7ca45006..0a3334ee 100644 --- a/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.c +++ b/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.c @@ -10,7 +10,7 @@ * Configures the registers with the right settings that are needed for rotating the motor. * E.g Enabling driver, setting IRUN current etc. */ -void initAllMotors(uint16_t icID) +void TMC5130initAllMotors(uint16_t icID) { tmc5130_writeRegister(icID, TMC5130_GCONF, 0x00000000); // Digital current scaling, SpreadCycle mode diff --git a/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.h b/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.h index 143ef695..70bc8c57 100644 --- a/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.h +++ b/tmc/ic/TMC5130/Examples/TMC5130_Simple_Rotation.h @@ -7,8 +7,8 @@ #ifndef TMC5130_SIMPLE_ROTATION_H_ #define TMC5130_SIMPLE_ROTATION_H_ -#include "TMC5130.h" +#include "../TMC5130.h" -void initAllMotors(uint16_t icID); +void TMC5130initAllMotors(uint16_t icID); #endif diff --git a/tmc/ic/TMC5130/TMC5130.c b/tmc/ic/TMC5130/TMC5130.c index 12d0a87c..660f099b 100644 --- a/tmc/ic/TMC5130/TMC5130.c +++ b/tmc/ic/TMC5130/TMC5130.c @@ -12,7 +12,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -142,7 +142,8 @@ void tmc5130_initCache() { for (id = 0; id < TMC5130_IC_CACHE_COUNT; id++) { - tmc5130_cache(id, TMC5130_CACHE_FILL_DEFAULT, i, &tmc5130_RegisterConstants[j].value); + uint32_t value = tmc5130_RegisterConstants[j].value; + tmc5130_cache(id, TMC5130_CACHE_FILL_DEFAULT, i, &value); } } } @@ -235,7 +236,7 @@ void writeRegisterSPI(uint16_t icID, uint8_t address, int32_t value) tmc5130_readWriteSPI(icID, &data[0], sizeof(data)); //Cache the registers with write-only access - tmc5130_cache(icID, TMC5130_CACHE_WRITE, address, &value); + tmc5130_cache(icID, TMC5130_CACHE_WRITE, address, (uint32_t*)&value); } int32_t readRegisterUART(uint16_t icID, uint8_t registerAddress) @@ -287,7 +288,7 @@ void writeRegisterUART(uint16_t icID, uint8_t registerAddress, int32_t value) tmc5130_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc5130_cache(icID, TMC5130_CACHE_WRITE, registerAddress, &value); + tmc5130_cache(icID, TMC5130_CACHE_WRITE, registerAddress, (uint32_t*)&value); } static uint8_t CRC8(uint8_t *data, uint32_t bytes) @@ -306,6 +307,7 @@ static uint8_t CRC8(uint8_t *data, uint32_t bytes) // swap nibbles ... result = ((result >> 4) & 0x0F) | ((result & 0x0F) << 4); + (void)table; return result; } diff --git a/tmc/ic/TMC5160/TMC5160.c b/tmc/ic/TMC5160/TMC5160.c index 28b6af71..1719f682 100644 --- a/tmc/ic/TMC5160/TMC5160.c +++ b/tmc/ic/TMC5160/TMC5160.c @@ -12,7 +12,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -138,7 +138,8 @@ void tmc5160_initCache() { for (id = 0; id < TMC5160_IC_CACHE_COUNT; id++) { - tmc5160_cache(id, TMC5160_CACHE_FILL_DEFAULT, i, &tmc5160_RegisterConstants[j].value); + uint32_t value = tmc5160_RegisterConstants[j].value; + tmc5160_cache(id, TMC5160_CACHE_FILL_DEFAULT, i, &value); } } } @@ -228,7 +229,7 @@ void writeRegisterSPI(uint16_t icID, uint8_t address, int32_t value) tmc5160_readWriteSPI(icID, &data[0], sizeof(data)); //Cache the registers with write-only access - tmc5160_cache(icID, TMC5160_CACHE_WRITE, address, &value); + tmc5160_cache(icID, TMC5160_CACHE_WRITE, address, (uint32_t*)&value); } int32_t readRegisterUART(uint16_t icID, uint8_t address) @@ -279,7 +280,7 @@ void writeRegisterUART(uint16_t icID, uint8_t address, int32_t value) tmc5160_readWriteUART(icID, &data[0], 8, 0); //Cache the registers with write-only access - tmc5160_cache(icID, TMC5160_CACHE_WRITE, address, &value); + tmc5160_cache(icID, TMC5160_CACHE_WRITE, address, (uint32_t*)&value); } void tmc5160_rotateMotor(uint16_t icID, uint8_t motor, int32_t velocity) diff --git a/tmc/ic/TMC5240/TMC5240.c b/tmc/ic/TMC5240/TMC5240.c index 731a2358..120a64e7 100644 --- a/tmc/ic/TMC5240/TMC5240.c +++ b/tmc/ic/TMC5240/TMC5240.c @@ -11,7 +11,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, diff --git a/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.c b/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.c index bc8e4223..aa418874 100644 --- a/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.c +++ b/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.c @@ -10,7 +10,7 @@ * Configures the registers with the right settings that are needed for rotating the motor. * E.g Enabling driver, setting IRUN current etc. */ -void initMotor(uint16_t icID) +void TMC5271initMotor(uint16_t icID) { // Set IREF_R2 and IREF_R3 to High for setting the REF resistor to 10k. // Run Current = 0.2A rms diff --git a/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.h b/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.h index f75790be..1e15b57b 100644 --- a/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.h +++ b/tmc/ic/TMC5271/Examples/TMC5271_Simple_Rotation.h @@ -7,8 +7,8 @@ #ifndef TMC5271_SIMPLE_ROTATION_H_ #define TMC5271_SIMPLE_ROTATION_H_ -#include "TMC5271.h" +#include "../TMC5271.h" -void initMotor(uint16_t icID); +void TMC5271initMotor(uint16_t icID); #endif diff --git a/tmc/ic/TMC5271/TMC5271.c b/tmc/ic/TMC5271/TMC5271.c index 598d52b3..c61ba847 100644 --- a/tmc/ic/TMC5271/TMC5271.c +++ b/tmc/ic/TMC5271/TMC5271.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, diff --git a/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.c b/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.c index e3dca89c..5faa9002 100644 --- a/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.c +++ b/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.c @@ -10,7 +10,7 @@ * Configures the registers with the right settings that are needed for rotating both motors. * E.g Enabling drivers, setting IRUN current etc. */ -void initAllMotors(uint16_t icID) +void TMC5272initAllMotors(uint16_t icID) { // Set IREF_R2 and IREF_R3 to High for setting the REF resistor to 10k. // Run Current = 0.2A rms diff --git a/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.h b/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.h index ac942c2d..7a2c1041 100644 --- a/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.h +++ b/tmc/ic/TMC5272/Examples/TMC5272_Simple_Rotation.h @@ -7,8 +7,8 @@ #ifndef TMC5272_SIMPLE_ROTATION_H_ #define TMC5272_SIMPLE_ROTATION_H_ -#include "TMC5272.h" +#include "../TMC5272.h" -void initAllMotors(uint16_t icID); +void TMC5272initAllMotors(uint16_t icID); #endif diff --git a/tmc/ic/TMC5272/TMC5272.c b/tmc/ic/TMC5272/TMC5272.c index fd24524d..cf6663b3 100644 --- a/tmc/ic/TMC5272/TMC5272.c +++ b/tmc/ic/TMC5272/TMC5272.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, diff --git a/tmc/ic/TMC7300/TMC7300.c b/tmc/ic/TMC7300/TMC7300.c index 0d23b5d7..ee6d65c9 100644 --- a/tmc/ic/TMC7300/TMC7300.c +++ b/tmc/ic/TMC7300/TMC7300.c @@ -13,7 +13,7 @@ #ifdef TMC_API_EXTERNAL_CRC_TABLE extern const uint8_t tmcCRCTable_Poly7Reflected[256]; #else -const uint8_t tmcCRCTable_Poly7Reflected[256] = { +static const uint8_t tmcCRCTable_Poly7Reflected[256] = { 0x00, 0x91, 0xE3, 0x72, 0x07, 0x96, 0xE4, 0x75, 0x0E, 0x9F, 0xED, 0x7C, 0x09, 0x98, 0xEA, 0x7B, 0x1C, 0x8D, 0xFF, 0x6E, 0x1B, 0x8A, 0xF8, 0x69, 0x12, 0x83, 0xF1, 0x60, 0x15, 0x84, 0xF6, 0x67, 0x38, 0xA9, 0xDB, 0x4A, 0x3F, 0xAE, 0xDC, 0x4D, 0x36, 0xA7, 0xD5, 0x44, 0x31, 0xA0, 0xD2, 0x43, @@ -143,7 +143,8 @@ void tmc7300_initCache() { for (id = 0; id < TMC7300_IC_CACHE_COUNT; id++) { - tmc7300_cache(id, TMC7300_CACHE_FILL_DEFAULT, i, &tmc7300_RegisterConstants[j].value); + uint32_t value = tmc7300_RegisterConstants[j].value; + tmc7300_cache(id, TMC7300_CACHE_FILL_DEFAULT, i, &value); } } } @@ -229,7 +230,7 @@ void writeRegisterUART(uint16_t icID, uint8_t registerAddress, int32_t value ) // Write to the shadow register and mark the register dirty //Cache the registers with write-only access - tmc7300_cache(icID, TMC7300_CACHE_WRITE, registerAddress, &value); + tmc7300_cache(icID, TMC7300_CACHE_WRITE, registerAddress, (uint32_t*)&value); } static uint8_t CRC8(uint8_t *data, uint32_t bytes)