2021-12-05 06:10 AM
I took the driver from Arduino for ADS119X and implement the HAL code for STM.
When compiling, it gives me “undefined reference to `keepSetting'�?. First I tought on a code problem but after long time of trail and error, I was looking on forums. It’s mentioned that there is some link problem. I try to solve it but no result.
In ADS119X.c I have:
#include "ADS119X.h"
#include "stm32l4xx_hal.h"
uint8_t ADS119X_keepSetting(uint8_t address)
{
return _regData[address];
}
void ADS119X_setChannelSettings(uint8_t _address, uint8_t pwdownSetting, uint8_t gainSetting, uint8_t muxSetting )
{
uint8_t _valueToWrite = keepSetting(_address) & ~(ADS119X_CHnSET_PD_MASK | ADS119X_CHnSET_GAIN_MASK | ADS119X_CHnSET_MUX_MASK) ;
_valueToWrite |= (pwdownSetting & ADS119X_CHnSET_PD_MASK ) | (gainSetting & ADS119X_CHnSET_GAIN_MASK) | (muxSetting & ADS119X_CHnSET_MUX_MASK) ;
WREG(_address , _valueToWrite);
}
void ADS119X_setAllChannelSettings(uint8_t pwdownSetting, uint8_t gainSetting, uint8_t muxSetting )
{
for (uint8_t address = ADS119X_ADD_CH1SET; address < ADS119X_ADD_CH1SET + _num_channels ; address++) {
setChannelSettings(address, pwdownSetting, gainSetting, muxSetting ) ;
}
}
void ADS119X_setAllChannelGain(uint8_t gainSetting )
{
for (uint8_t address = ADS119X_ADD_CH1SET; address < ADS119X_ADD_CH1SET + _num_channels ; address++) {
setChannelSettings(address, keepSetting(address), gainSetting, keepSetting(address)) ;
}
}
void ADS119X_setAllChannelMux(uint8_t muxSetting )
{
for (uint8_t address = ADS119X_ADD_CH1SET; address < ADS119X_ADD_CH1SET + _num_channels ; address++) {
setChannelSettings(address, keepSetting(address), keepSetting(address), muxSetting ) ;
}
}
undefined reference to `keepSetting'
In ADS119X.h I have:
#ifndef INC_ADS119X_H_
#define INC_ADS119X_H_
#include "stm32l4xx_hal.h"
void setAllChannelMux(uint8_t muxSetting );
void setAllChannelGain(uint8_t gainSetting );
uint8_t keepSetting(uint8_t address);
…….
#endif /* INC_ADS119X_H_ */
The code is similar to ADS119X_setAllChannelGain but never has a problem with this part, also when I put “ADS119X_setAllChannelGain�? in comment. A full clean didn’t help. Google refers to “Paths and Symbols�? but what must be added?
Thanks for suggestions
Solved! Go to Solution.
2021-12-05 06:30 AM
Do you define keepSetting somewhere? You haven't shown it in the code you posted.
Ensure it's defined (with an actual body, not just declared), and that the source file which defines it is getting compiled.
2021-12-05 06:30 AM
Do you define keepSetting somewhere? You haven't shown it in the code you posted.
Ensure it's defined (with an actual body, not just declared), and that the source file which defines it is getting compiled.
2021-12-05 06:43 AM
Ooh yes, if I use in the code ADS119X_keepSetting and do this for the other errors, the undefined reference are gone. Thanks a lot, now I can continue.