Linking errors with IAR

Discussion in 'C Programming' started by SamTal, Apr 12, 2015.

  1. SamTal

    SamTal

    Joined:
    Feb 3, 2015
    Messages:
    2
    Likes Received:
    0
    Hi,
    I have a large embedded ARM program in C, run with IAR Workbench.
    I modified one of the files by adding 3 power supply control I2C functions, all internal within the file.
    While the file compiles clean and nice, when building the program I get linking errors for the 3 new functions.
    To the best of my knowledge (forgot C for many years...), I did all that is needed: Added prototypes, and declared the variables.
    Despite all, I get the following error messages: (removed part of the path)

    In addition, there is a:" #if 0 " in the middle, which I can not figure out what it does, but removing it will cause file compilation errors.

    Error messages:
    Linking
    Error[Li005]: no definition for "SetPowerRemoteOn" [referenced from C:\Users\..........\Debug\Obj\Tester.o]
    Error[Li005]: no definition for "SetPowerSupplyVoltage" [referenced from C:\Users\.....\Debug\Obj\Tester.o]
    Error[Li005]: no definition for" SetPowerSupplyPower" [referenced from C:\Users\.......\Debug\Obj\Tester.o]

    Error while running Linker

    Total number of errors:3
    End of errors
    =====================================================================


    The code: (removed all comments)

    Code (Text):

    #include "Tester.h"
    #include <stdbool.h>
    //vars
    #define Tester_BUF_SIZE    8
    #define POWER_SUPPLY_ADDRESS    0x54
    uint8_t Tester_Buffer[Tester_BUF_SIZE];

    //private prototypes
    Status Tester_WriteBuff(uint8_t uiAddress, uint8_t *uiBuffer, uint8_t uiLength);
    Status SetPowerRemoteOn(bool);
    Status SetPowerSupplyVoltage(double);  //Defaults to 15 V (in header)
    Status SetPowerSupplyPower(uint8_t);

    uint8_t PS_Current_Set = 0;
    double PS_Volts_Set = 15;
    bool PS_State_Set = true;

    uint8_t RxTester_Buffer[Tester_BUF_SIZE];

    /**********************************************************************/

    Status Tester_WriteBuff(uint8_t uiAddress, uint8_t *uiBuffer, uint8_t uiLength)
    {
        Status statWrite =  SUCCESS  ;

        I2C_M_SETUP_Type TransferSetup;
        TransferSetup.sl_addr7bit = uiAddress;
        TransferSetup.tx_data = uiBuffer;
        TransferSetup.tx_length = (uint32_t)uiLength;

        TransferSetup.rx_data = RxTester_Buffer;
        TransferSetup.rx_length = uiLength;

        TransferSetup.rx_data = NULL;
        TransferSetup.rx_length = 0;

        TransferSetup.retransmissions_max = 3;

        statWrite = I2C_MasterTransferData(Tester_I2C_PORT, &TransferSetup, I2C_TRANSFER_POLLING);

        return statWrite ;
    }

    /*********************************************************************//**
    Status Tester_Init(void)
    {
        Status retval;

        if(!TF_BSP_Initialized) return 0;

        //load init register values into buffer
        Tester_Buffer[0] = Tester_OUT0; //reg start address
        Tester_Buffer[1] = 0x00; //preset A
        Tester_Buffer[2] = 0x00; //preset B
        retval = Tester_WriteBuff(Tester_I2C_ADDRESS, Tester_Buffer, 3);

        //load init register values into buffer
        Tester_Buffer[0] = Tester_CONFIG0; //reg start address
        Tester_Buffer[1] = 0x00; //dir A
        Tester_Buffer[2] = 0xFF; //dir B
        retval = Tester_WriteBuff(Tester_I2C_ADDRESS, Tester_Buffer, 3);

    return retval;

    }

    /*********************************************************************/

    Status Tester_Write(uint8_t powerValue)  //0-255, every PID interrupt
    {
        Status retval;

        if(!TF_BSP_Initialized) return 0;

    #ifdef NEW_POWER_SUPPLY

    SetPowerRemoteOn(PS_State_Set);
    SetPowerSupplyVoltage(PS_Volts_Set);  //Defaults to 15 V (in header)
    SetPowerSupplyPower(PS_Current_Set);   //Setting the power current

    retval = SUCCESS;

            Tester_Buffer[0] = Tester_OUT0; //reg start address
        Tester_Buffer[1] = (uint8_t) powerValue;
        Tester_Buffer[2] = 0x00;
        retval = Tester_WriteBuff(Tester_I2C_ADDRESS, Tester_Buffer, 3);

        return retval;
    }
    /**********************************************************************/
    uint8_t Tester_Read(void)
    {

      return Tester_Buffer[1];
    }
    #if 0

    /**********************************************************************/

    Status SetPowerSupplyVoltage(double PS_Volts_Set)
    {
        Status retval;

        if(O_Tester_OVEN_ENABLE == ON)   /
            {
            Tester_Buffer[0] = 0x70; //voltage register start address
        Tester_Buffer[1] = (int)(PS_Volts_Set * 100) & 0xFF; //low byte
        Tester_Buffer[2] = (int)(PS_Volts_Set * 100) >> 8 ; //high byte
        retval = Tester_WriteBuff(POWER_SUPPLY_ADDRESS, Tester_Buffer, 3);

        //Activates the voltage settings while reassuring remote power is On
        Tester_Buffer[0] = 0x7C; //reg start address
        Tester_Buffer[1] = 0x85; //bits 2 must be on to activate the voltage settings
        retval = Tester_WriteBuff(POWER_SUPPLY_ADDRESS, Tester_Buffer, 2);
            }
          else SetPowerRemoteOn(false);

          return retval ;
    }

    Status SetPowerRemoteOn(int PS_State_Set)
    {
        Status retval;

        if (PS_State_Set == true)
        {
             Tester_Buffer[0] = 0x7C; //reg start address
            Tester_Buffer[1] = 0x81; //Bit 7 1 = Remote 0 = Local
            retval = Tester_WriteBuff(POWER_SUPPLY_ADDRESS, Tester_Buffer, 2);
        }
        else
        {
            //Set Power to local and off - will disable the heater power supply
            Tester_Buffer[0] = 0x7C; //reg start address
            Tester_Buffer[1] = 0x00; //Bit 0 1 = Power On 0 = Power Off
            retval = Tester_WriteBuff(POWER_SUPPLY_ADDRESS, Tester_Buffer, 2);
        }
        return retval ;
    }

    Status SetPowerSupplyPower(bool PS_Current_Set)   //from PID,
    {
      retval = SUCCESS ;
        double paramValue = PS_Current_Set * 100 / 255;
    .
        int iValue = (int)(paramValue * 100) ;
        if (iValue > 10000)   iValue = 10000 ;

        if(O_Tester_OVEN_ENABLE == ON)
            {

            Tester_Buffer[0] = 0x72; //reg start address
        Tester_Buffer[1] = (iValue & 0xFF) ;
        Tester_Buffer[2] = ((iValue >> 8) & 0xFF) ;
        retval = Tester_WriteBuff(POWER_SUPPLY_ADDRESS, Tester_Buffer, 3);

        //Activates the current settings
        Tester_Buffer[0] = 0x7C; //reg start address
        Tester_Buffer[1] = 0x85; //bits 2 must be on to activate the voltage settings
        retval = Tester_WriteBuff(POWER_SUPPLY_ADDRESS, Tester_Buffer, 2);
        }
        else        {
            //Set Power to local and off - will disable the heater power supply
            Tester_Buffer[0] = 0x7C; //reg start address
            Tester_Buffer[1] = 0x00; //Bit 0 1 = Power On 0 = Power Off
            retval = Tester_WriteBuff(POWER_SUPPLY_ADDRESS, Tester_Buffer, 2);
        }

      return retval;
    }
    #endif


    /*********************************************************************************
                               End Of File
    *********************************************************************************/
     
     
    SamTal, Apr 12, 2015
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,386
    Mark Goldin
    Jan 17, 2004
  2. murali
    Replies:
    1
    Views:
    430
    John Harrison
    Sep 2, 2003
  3. mp
    Replies:
    2
    Views:
    7,327
  4. Craig
    Replies:
    2
    Views:
    567
    Craig
    Jan 21, 2004
  5. robin.pain@tesco.net

    IAR, __ASM(), and *.s33 to *.C files

    robin.pain@tesco.net, Oct 3, 2003, in forum: C Programming
    Replies:
    16
    Views:
    1,244
    E. Robert Tisdale
    Oct 6, 2003
  6. kashumoto_tokugawa
    Replies:
    1
    Views:
    2,344
    RippedOffStockTrader2@gmail.com
    Jan 9, 2007
  7. Steven Woody
    Replies:
    2
    Views:
    654
    Victor Bazarov
    Nov 14, 2005
  8. softy342
    Replies:
    0
    Views:
    1,576
    softy342
    Dec 17, 2015
Loading...