You are here

PSoC 5LP, project with outsourced functions | Cypress Semiconductor

PSoC 5LP, project with outsourced functions

Summary: 4 Replies, Latest post by Jeroen Schäfer on 29 Nov 2016 11:39 PM PST
Verified Answers: 1
Last post
Log in to post new comments.
Jeroen Schäfer's picture
User
3 posts

Hello,

 

I am writing a program for PSoC 5LP (Prototyping Kit) working with the RGB-sensor VEML6040 by Vishay.

I try to outsource most of the functions and only have the core-code remaining in the file main.c. So i created two files: veml6040.h and veml6040.c and added them to the project (in header and source files).

 

Extract from veml6040.h

 

#include "veml6040.c"
#include "main.c"
#include <project.h>

// definitions

// function headers

 

extract from veml6040.c

#include "veml6040.h"

uint16_t ReadSensor(uint8_t CommandCode)
{
    // awesome code
}

// other functions ...

 

When i do so and i change the files following message appears (translated from german by me):

The file cannot be saved: (The process cannot access file "C:\Users\username\Documents\PSoC Creator\PSoC5LP-VEML6040\PSoC5LP-VEML6040.cydsn\main.c", because another process is accessing it.)

 

None of the files can be saved (not even main.c). Also the Build ends with the PSoC Creator crashing.

When i remove the files from the project, everything works fine again.

 

Can someone help me with this problem?

 

 

Best regards,

Jeroen

user_1377889's picture
User
9583 posts

Welcome in the forum.

Do not include .c files!!! just include the corresponding .h files.

 

Bob

Jeroen Schäfer's picture
User
3 posts

Thank you.

I don't have to include the .c file in the corresponding header?

Only the .h file in the .c file?

user_1377889's picture
User
9583 posts

That's right. There usually is a #ifdef to allow a .h file to be #included into several files of a project, see attached example.

 

Bob

PS: Where in Germany are you located? I live near Bremen.

Attachments: 
Jeroen Schäfer's picture
User
3 posts

Thanks for your help. I will try this soon.

I am from the Ruhr area.

 

Best Regards

Jeroen

Log in to post new comments.