Skip to content

Instantly share code, notes, and snippets.

@yeutterg
Last active February 25, 2023 03:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeutterg/fbd672f7a4a0900785a4b9624aff2fd9 to your computer and use it in GitHub Desktop.
Save yeutterg/fbd672f7a4a0900785a4b9624aff2fd9 to your computer and use it in GitHub Desktop.
How to use PSoC Creator with Git
### PSoCCreator ###
# Modified from https://www.gitignore.io/?templates=psoccreator
# You may need to add additional directories, e.g. CortexM3/
# Project Settings
*.cywrk.*
*.cyprj.*
# Generated Assets and Resources
Debug/
Release/
Export/
CortexM0/
codegentemp
Generated_Source
*_datasheet.pdf
*_timing.html
*.cycdx
*.cyfit
*.rpt
*.svd
*.log
*.zip

How to use Git with Cypress PSoC Creator (Windows)

This script makes it easy to manage your PSoC Creator project with Git using Windows PowerShell. A .gitignore file is provided that works whether or not you decide to use this script.

Tested with PSoC Creator 4.2 on Windows 10

Git Setup

  1. Install Git
  2. Make sure Git is set up with your PATH
  3. Create a new repository
  4. In the PSoC Creator project directory:
git init
git remote add ...
  1. Make sure you are logged in to GitHub (or GitLab, BitBucket, etc.)
  2. Copy the .gitignore and .ps1 file to your project directory. Review them and make any changes. A helpful, but somewhat out-of-date, guide from Cypress about version control can be found here

Add, commit, push

Open PowerShell and invoke the .ps1 script, or right-click it and select "Run with PowerShell." Note that you may get a script execution warning, just press Y

You will see all the files that were added, and then you will be prompted for a commit message. Hopefully, the changes will commit and push to the repo

# Refer to the instructions for using PSoC Creator with version control:
# https://community.cypress.com/docs/DOC-11030
# Add the PSOC Creator Files
git add *.c *.h *.cydwr *.cyprj .\TopDesign\*.cysch
# Add additional files
git add *.md
# Added these files
echo 'Git Status:'
git status
# Ask for the commit message
$CommitMsg = Read-Host -Prompt 'Enter the commit message'
# Commit
git commit --m "$CommitMsg"
# Push
git push -u origin master
# Keep the console open after execution
Read-Host -Prompt 'Press Enter to exit'
@endolith
Copy link

I have to make exceptions for Generated_Source since it can contain custom code sections that aren't overwritten when compiling:

Project_Name.cydsn/Generated_Source/PSoC4/*
!Project_name.cydsn/Generated_Source/PSoC4/USB_audio.*
!Project_name.cydsn/Generated_Source/PSoC4/USB_episr.c
...

Revision Control for PSoC® Creator™ Projects - KBA86358

GitHub and PSoC Creator Projects

Also what about .gitattributes for telling it which files are plain text vs binary, and handing line endings, etc.?

Also I ignored things like datasheet pdfs or cywrk files, but later realized they are necessary if you want to clone a repo to another computer, etc.

@dariy-vel
Copy link

I have to make exceptions for Generated_Source since it can contain custom code sections that aren't overwritten when compiling:

!Project_name.cydsn/Generated_Source/PSoC4/USB_episr.c

Actually, any files from Generated_Source/ folder should not be modified by user code. For example, all the ISRs from USB_episr.c have entry and exit callbacks. You can enable those callbacks by defining special constants in 'cyapicallbacks.h' and write your own implementation. Read the USBFS datasheet carefully on that.

For example, this is the code from my cyapicallbacks.h for endpoint 2:

#define USBFS_EP_2_ISR_EXIT_CALLBACK
    
void USBFS_EP_2_ISR_ExitCallback(void);

@endolith
Copy link

endolith commented Nov 1, 2021

@dariy-vel Files in Generated_Source folder can be modified by user code. For example, in USB_episr.c, see the sections like

/***************************************
* Custom Declarations
***************************************/
/* `#START CUSTOM_DECLARATIONS` Place your declaration here */

/* `#END` */

Content within the tags is not modified when the files are generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment