Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extern "C" wrappers around all high-level API C functions #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tmc/helpers/CRC.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@
// Each table takes ~260 bytes (257 bytes, one bool and structure padding)
#define CRC_TABLE_COUNT 2

#ifdef __cplusplus
extern "C" {
#endif

uint8_t tmc_fillCRC8Table(uint8_t polynomial, bool isReflected, uint8_t index);
uint8_t tmc_CRC8(uint8_t *data, uint32_t bytes, uint8_t index);

uint8_t tmc_tableGetPolynomial(uint8_t index);
bool tmc_tableIsReflected(uint8_t index);

#ifdef __cplusplus
}
#endif

#endif /* TMC_HELPERS_CRC_H_ */
8 changes: 8 additions & 0 deletions tmc/helpers/Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@

#include "API_Header.h"

#ifdef __cplusplus
extern "C" {
#endif

int32_t tmc_limitInt(int32_t value, int32_t min, int32_t max);
int64_t tmc_limitS64(int64_t value, int64_t min, int64_t max);
int32_t tmc_sqrti(int32_t x);
int32_t tmc_filterPT1(int64_t *akku, int32_t newValue, int32_t lastValue, uint8_t actualFilter, uint8_t maxFilter);

#ifdef __cplusplus
}
#endif

#endif /* TMC_FUNCTIONS_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/MAX22216/MAX22216.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ typedef struct {
uint8_t crc_en;
} MAX22216TypeDef;

#ifdef __cplusplus
extern "C" {
#endif

uint8_t max22216_CRC(uint8_t *data, size_t length);

void max22216_writeDatagram(MAX22216TypeDef *max22216, uint8_t address, uint8_t x1, uint8_t x2);
Expand All @@ -42,4 +46,8 @@ void max22216_init(MAX22216TypeDef *max22216, uint8_t channel);
uint8_t max22216_getSlaveAddress(const MAX22216TypeDef *max22216);
void max22216_setSlaveAddress(MAX22216TypeDef *max22216, uint8_t slaveAddress);

#ifdef __cplusplus
}
#endif

#endif /* API_IC_MAX22216_H */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2130/TMC2130.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ static const TMCRegisterConstant tmc2130_RegisterConstants[] =
#undef R10
#undef R6C

#ifdef __cplusplus
extern "C" {
#endif

// API Functions
// All functions act on one IC identified by the TMC2130TypeDef pointer

Expand All @@ -110,4 +114,8 @@ void tmc2130_setRegisterResetState(TMC2130TypeDef *tmc2130, const int32_t *reset
void tmc2130_setCallback(TMC2130TypeDef *tmc2130, tmc2130_callback callback);
void tmc2130_periodicJob(TMC2130TypeDef *tmc2130, uint32_t tick);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2130_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2160/TMC2160.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ static const TMCRegisterConstant tmc2160_RegisterConstants[] =
{ 0x69, 0x00F70000 } // MSLUTSTART
};

#ifdef __cplusplus
extern "C" {
#endif

void tmc2160_writeDatagram(TMC2160TypeDef *tmc2160, uint8_t address, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4);
void tmc2160_writeInt(TMC2160TypeDef *tmc2160, uint8_t address, int32_t value);
int32_t tmc2160_readInt(TMC2160TypeDef *tmc2160, uint8_t address);
Expand All @@ -126,4 +130,8 @@ void tmc2160_setRegisterResetState(TMC2160TypeDef *tmc2160, const int32_t *reset
void tmc2160_setCallback(TMC2160TypeDef *tmc2160, tmc2160_callback callback);
void tmc2160_periodicJob(TMC2160TypeDef *tmc2160, uint32_t tick);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2160_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2208/TMC2208.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ static const int32_t tmc2208_defaultRegisterResetState[TMC2208_REGISTER_COUNT] =
#undef R6C
#undef R70

#ifdef __cplusplus
extern "C" {
#endif

void tmc2208_writeInt(TMC2208TypeDef *tmc2208, uint8_t address, int32_t value);
int32_t tmc2208_readInt(TMC2208TypeDef *tmc2208, uint8_t address);

Expand All @@ -85,4 +89,8 @@ void tmc2208_periodicJob(TMC2208TypeDef *tmc2208, uint32_t tick);
uint8_t tmc2208_get_slave(TMC2208TypeDef *tmc2208);
void tmc2208_set_slave(TMC2208TypeDef *tmc2208, uint8_t slave);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2208_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2209/TMC2209.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ static const int32_t tmc2209_defaultRegisterResetState[TMC2209_REGISTER_COUNT] =
#undef R6C
#undef R70

#ifdef __cplusplus
extern "C" {
#endif

// Communication
void tmc2209_writeInt(TMC2209TypeDef *tmc2209, uint8_t address, int32_t value);
int32_t tmc2209_readInt(TMC2209TypeDef *tmc2209, uint8_t address);
Expand All @@ -97,4 +101,8 @@ void tmc2209_periodicJob(TMC2209TypeDef *tmc2209, uint32_t tick);
uint8_t tmc2209_get_slave(TMC2209TypeDef *tmc2209);
void tmc2209_set_slave(TMC2209TypeDef *tmc2209, uint8_t slaveAddress);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2209_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2224/TMC2224.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ typedef struct {
uint8_t slave;
} TMC2224TypeDef;

#ifdef __cplusplus
extern "C" {
#endif

void tmc2224_initConfig(TMC2224TypeDef *TMC2224);
void tmc2224_periodicJob(uint8_t motor, uint32_t tick, TMC2224TypeDef *TMC2224, ConfigurationTypeDef *TMC2224_config);
uint8_t tmc2224_reset(TMC2224TypeDef *tmc2224, ConfigurationTypeDef *TMC2224_config);
Expand All @@ -39,4 +43,8 @@ uint8_t tmc2224_restore(ConfigurationTypeDef *TMC2224_config);
uint8_t tmc2224_get_slave(TMC2224TypeDef *tmc2224);
void tmc2224_set_slave(TMC2224TypeDef *tmc2224, uint8_t slave);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2224_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2225/TMC2225.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ static const int32_t tmc2225_defaultRegisterResetState[TMC2225_REGISTER_COUNT] =
#undef R6C
#undef R70

#ifdef __cplusplus
extern "C" {
#endif

void tmc2225_writeInt(TMC2225TypeDef *tmc2225, uint8_t address, int32_t value);
int32_t tmc2225_readInt(TMC2225TypeDef *tmc2225, uint8_t address);

Expand All @@ -93,4 +97,8 @@ void tmc2225_periodicJob(TMC2225TypeDef *tmc2225, uint32_t tick);
uint8_t tmc2225_get_slave(TMC2225TypeDef *tmc2225);
void tmc2225_set_slave(TMC2225TypeDef *tmc2225, uint8_t slave);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2225_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2226/TMC2226.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ static const TMCRegisterConstant tmc2226_RegisterConstants[] =
#undef R6C
#undef R70

#ifdef __cplusplus
extern "C" {
#endif

// Communication
void tmc2226_writeInt(TMC2226TypeDef *tmc2226, uint8_t address, int32_t value);
int32_t tmc2226_readInt(TMC2226TypeDef *tmc2226, uint8_t address);
Expand All @@ -110,4 +114,8 @@ void tmc2226_periodicJob(TMC2226TypeDef *tmc2226, uint32_t tick);
uint8_t tmc2226_getSlaveAddress(TMC2226TypeDef *tmc2226);
void tmc2226_setSlaveAddress(TMC2226TypeDef *tmc2226, uint8_t slaveAddress);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2226_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2240/TMC2240.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ static const TMCRegisterConstant tmc2240_RegisterConstants[] =
///
};

#ifdef __cplusplus
extern "C" {
#endif

void tmc2240_init(TMC2240TypeDef *tmc2240, uint8_t channel, ConfigurationTypeDef *config, const int32_t *registerResetState);
//void tmc2240_fillShadowRegisters(TMC2240TypeDef *tmc2240);
uint8_t tmc2240_reset(TMC2240TypeDef *tmc2240);
Expand All @@ -111,4 +115,8 @@ void tmc2240_periodicJob(TMC2240TypeDef *tmc2240, uint32_t tick);

uint8_t tmc2240_consistencyCheck(TMC2240TypeDef *tmc2240);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2240_H_ */
7 changes: 7 additions & 0 deletions tmc/ic/TMC2300/TMC2300.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ static const TMCRegisterConstant tmc2300_RegisterConstants[] =
{ 0x70, 0xC40D1024 }, // PWMCONF
};

#ifdef __cplusplus
extern "C" {
#endif

void tmc2300_writeInt(TMC2300TypeDef *tmc2300, uint8_t address, int32_t value);
int32_t tmc2300_readInt(TMC2300TypeDef *tmc2300, uint8_t address);
Expand All @@ -99,4 +102,8 @@ void tmc2300_setSlaveAddress(TMC2300TypeDef *tmc2300, uint8_t slaveAddress);
uint8_t tmc2300_getStandby(TMC2300TypeDef *tmc2300);
void tmc2300_setStandby(TMC2300TypeDef *tmc2300, uint8_t standbyState);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2300_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2590/TMC2590.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ static const int32_t tmc2590_defaultRegisterResetState[TMC2590_REGISTER_COUNT] =
0x000EF040 // 7: DRVCONF
};

#ifdef __cplusplus
extern "C" {
#endif

void tmc2590_init(TMC2590TypeDef *tmc2590, uint8_t channel, ConfigurationTypeDef *tmc2590_config, const int32_t *registerResetState);
void tmc2590_periodicJob(TMC2590TypeDef *tmc2590, uint32_t tick);
void tmc2590_writeInt(TMC2590TypeDef *tmc2590, uint8_t address, int32_t value);
uint32_t tmc2590_readInt(TMC2590TypeDef *tmc2590, uint8_t address);
uint8_t tmc2590_reset(TMC2590TypeDef *tmc2590);
uint8_t tmc2590_restore(TMC2590TypeDef *tmc2590);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2590_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC262/TMC262.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#define TMC262_FLAG_OT 0x02
#define TMC262_FLAG_SG 0x01

#ifdef __cplusplus
extern "C" {
#endif

// Access functions for TMC262
void tmc262_initMotorDrivers(void);
void tmc262_setStepDirMStepRes(uint8_t MicrostepResolution);
Expand Down Expand Up @@ -91,4 +95,8 @@ void tmc262_readState(uint8_t *Phases, uint8_t *MStep, uint32_t *StallGuard, uin

void tmc262_getSPIData(uint8_t Index, int32_t *Data);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC262_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC2660/TMC2660.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ typedef struct {
int32_t registerResetState[TMC2660_REGISTER_COUNT];
} TMC2660TypeDef;

#ifdef __cplusplus
extern "C" {
#endif

void tmc2660_initConfig(TMC2660TypeDef *TMC2660);
void tmc2660_periodicJob(uint8_t motor, uint32_t tick, TMC2660TypeDef *TMC2660, ConfigurationTypeDef *TMC2660_config);
uint8_t tmc2660_reset(TMC2660TypeDef *TMC2660, ConfigurationTypeDef *TMC2660_config);
uint8_t tmc2660_restore(ConfigurationTypeDef *TMC2660_config);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC2660_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC4210/TMC4210.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "tmc/helpers/API_Header.h"
#include "TMC4210_Registers.h"

#ifdef __cplusplus
extern "C" {
#endif

// TMC4210 library functions
void Init4210(void);
void ReadWrite4210(uint8_t *Read, uint8_t *Write);
Expand All @@ -36,4 +40,8 @@ void Set4210SwitchMode(uint8_t SwitchMode);
uint8_t SetAMax(uint32_t AMax);
void HardStop(void);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC4210_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC424/TMC424.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@
#include "tmc/helpers/API_Header.h"
#include "TMC424_Register.h"

#ifdef __cplusplus
extern "C" {
#endif

void SetEncoderPrescaler(uint8_t Index, uint32_t Prescaler, uint8_t SpecialFunctionBits);
int32_t ReadEncoder(uint8_t Which423, uint8_t Index);
void WriteEncoder(uint8_t Index, int32_t Value);
uint8_t ReadEncoderNullChannel(uint8_t Which424, uint8_t Index);
void Init424(void);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC424_H_ */
8 changes: 8 additions & 0 deletions tmc/ic/TMC429/TMC429.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "tmc/helpers/API_Header.h"
#include "TMC429_Register.h"

#ifdef __cplusplus
extern "C" {
#endif

// user must provide this function
uint8_t ReadWriteSPI(void* p_SPI_DeviceHandle, uint8_t data,bool endTransaction);

Expand All @@ -39,4 +43,8 @@
uint8_t SetAMax(uint8_t Motor, uint32_t AMax);
void HardStop(uint32_t Motor);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC429_H_ */
7 changes: 7 additions & 0 deletions tmc/ic/TMC4330/TMC4330.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ static const uint8_t tmc4330_defaultRegisterAccess[TMC4330_REGISTER_COUNT] =
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x01, 0x01, 0x01, 0x02, 0x02, 0x42, 0x01 // 0x70 - 0x7F
};

#ifdef __cplusplus
extern "C" {
#endif

// API Functions
// All functions act on one IC given by the TMC4330TypeDef struct
Expand Down Expand Up @@ -111,4 +114,8 @@ void tmc4330_moveBy(TMC4330TypeDef *tmc4330, int32_t *ticks, uint32_t velocityMa
int32_t tmc4330_discardVelocityDecimals(int32_t value);
uint8_t tmc4330_calibrateClosedLoop(TMC4330TypeDef *tmc4330, uint8_t worker0master1);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC4330_H_ */
7 changes: 7 additions & 0 deletions tmc/ic/TMC4331/TMC4331.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ static const uint8_t tmc4331_defaultRegisterAccess[TMC4331_REGISTER_COUNT] =
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x01, 0x01, 0x53, 0x13, ____, 0x42, 0x01 // 0x70 - 0x7F
};

#ifdef __cplusplus
extern "C" {
#endif

// API Functions
// All functions act on one IC given by the TMC4331TypeDef struct
Expand Down Expand Up @@ -111,4 +114,8 @@ void tmc4331_moveBy(TMC4331TypeDef *tmc4331, int32_t *ticks, uint32_t velocityMa
int32_t tmc4331_discardVelocityDecimals(int32_t value);
uint8_t tmc4331_calibrateClosedLoop(TMC4331TypeDef *tmc4331, uint8_t worker0master1);

#ifdef __cplusplus
}
#endif

#endif /* TMC_IC_TMC4331_H_ */
Loading