Adding own library to the SDK

Questions for programming 8051 microcontrollers in C or assembly using SDCC

Adding own library to the SDK

Postby 07albi » Tue May 26, 2015 10:16 pm

Hello again,

I am trying to put my own .h and .c file to your existing SDK. Unfortunately, I am getting this error while trying to build it(make all):
Code: Select all
Building object file '../../_target_sdcc_nrf24le1_24/obj/si7021/si7021.rel'
[ -d ../../_target_sdcc_nrf24le1_24/obj/si7021 ] || mkdir -p ../../_target_sdcc_nrf24le1_24/obj/si7021 > /dev/null
sdcc --model-large --std-c99 -I../../include -I../../_target_sdcc_nrf24le1_24/include  -c src/si7021.c -o "../../_target_sdcc_nrf24le1_24/obj/si7021/"
src/si7021.c:39: syntax error: token -> 'uint8_t' ; column 8
src/si7021.c:41: syntax error: token -> ';' ; column 34
src/si7021.c:43: error 20: Undefined identifier 'data'
src/si7021.c:43: error 22: Array or pointer required for '[]' operation
src/si7021.c:43: error 20: Undefined identifier 'data'
src/si7021.c:43: error 22: Array or pointer required for '[]' operation
src/si7021.c:43: error 47: indirections to different types assignment   
from type 'void'
  to type 'unsigned-int fixed'
src/si7021.c:52: syntax error: token -> 'uint8_t' ; column 8
src/si7021.c:54: syntax error: token -> ';' ; column 34
src/si7021.c:56: error 20: Undefined identifier 'data'
src/si7021.c:56: error 22: Array or pointer required for '[]' operation
src/si7021.c:56: error 20: Undefined identifier 'data'
src/si7021.c:56: error 22: Array or pointer required for '[]' operation
src/si7021.c:56: error 47: indirections to different types assignment   
from type 'void'
  to type 'unsigned-int fixed'
make[3]: *** [../../_target_sdcc_nrf24le1_24/obj/si7021/si7021.rel] Error 1
make[3]: Leaving directory `/home/albi/Desktop/Bakalarka-lin-copy/nRF24LE1_SDK/src/si7021'
make[2]: *** [../src/si7021] Error 2
make[2]: Leaving directory `/home/albi/Desktop/Bakalarka-lin-copy/nRF24LE1_SDK/_target_sdcc_nrf24le1_24'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/albi/Desktop/Bakalarka-lin-copy/nRF24LE1_SDK/_target_sdcc_nrf24le1_24'
make: *** [make__target_sdcc_nrf24le1_24] Error 2


the si7021.h is:
Code: Select all
//#ifndef SI7021_H_
//#define SI7021_H_

#include "reg24le1.h"

#define SLAVE_ADDRESS         0x40;
#define RH_HOLD            0xE5;
#define RH_NOHOLD         0xF5;
#define TEMP_HOLD         0xE3;
#define TEMP_NOHOLD         0xF3;
#define TEMP_READ         0xE0;


uint8_t measure_temperature();
uint8_t measure_humidity();

//#endif /*SI7021_H_*/


the .c:
Code: Select all
#include "si7021.h"
#include "w2_src.h"

uint8_t measure_temperature()
{
//   uint8_t slave_address=0x40;
   uint16_t Temp_code = 0;
   uint8_t command= TEMP_READ;      //send last measured temp
   uint8_t data[2];
   if (!w2_master_write_control_bytes(0x40, &command, 1)){      //if ACK
      w2_master_cur_address_read(SLAVE_ADDRESS, data, 2);
   }
   Temp_code = (data[0]<<8)|data[1];
   return ((175.25*Temp_code/65536)-46.85);
   
}

uint8_t measure_humidity()
{
//   uint8_t slave_address=0x40;
   uint16_t RH_code = 0;
   uint8_t command= RH_HOLD;      //measure humidty
   uint8_t data[2];
   if (!w2_master_write_control_bytes(0x40, &command, 1)){      //if ACK
      w2_master_cur_address_read(SLAVE_ADDRESS, data, 2);
   }
   RH_code = (data[0]<<8)|data[1];
   return ((125.0*RH_code/65536)-6);
   
}


I dont know why is there the syntax error, because in the reg24le1 there is already included <stdint.h>. Anyway, if I included it directly to the si7021.h, same error happens.
07albi
 
Posts: 4
Joined: Thu May 21, 2015 7:45 am

Re: Adding own library to the SDK

Postby brennen » Thu May 28, 2015 12:24 pm

You shouldn't put semicolons in your #defines. Other than that, I don't really see anything that's obviously wrong.
brennen
Site Admin
 
Posts: 395
Joined: Sun Aug 17, 2008 2:15 pm

Re: Adding own library to the SDK

Postby 07albi » Fri May 29, 2015 7:06 am

Oh stupid me...
How could I wrote that in the first place?

It solved the problem,
thank you brennen
07albi
 
Posts: 4
Joined: Thu May 21, 2015 7:45 am


Return to 8051 Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron