7 Replies Latest reply on Aug 24, 2016 6:19 AM by userc_39729

    Disabling Code Generation

    userc_39729

      I'm sure this is pretty basic knowledge but I could not find the answer: I need to modify a driver and I don't have enough flexibility with the small code sections that are user modifiable, so is there an easy way of shutting off code generation so that I can modify the driver code?

         

      thanks

         

      Doug

        • 1. Re: Disabling Code Generation
          BoTa_264741

          Do you mean by driver is a PSoC Creator stock component? If so, create a copy of the component, make sure that it still works, save it under new name and modify its internal code and hardware to your needs.

             

          check this links:

             

          http://www.cypress.com/forum/psoc-3-architecture/editing-existing-components

             

          http://www.mbedded.ninja/programming/microcontrollers/psoc/creating-and-editing-your-own-psoc-components

             

          importing components:

             

          http://www.cypress.com/resource-types/video/psoc-creator-tutorial-importing-components

             

          https://www.youtube.com/watch?v=cEAEk-HRib8

          • 2. Re: Disabling Code Generation
            userc_39729

            Thanks Odissey1 for your help.

               

            I guess I'm missing some basic knowledge...

               

            Here are more details for what I'm trying to accomplish.  I am trying to create a spi slave device only i don't want the api source code (or, specifically, the interrupt handler) to be regenerated every time it is compiled.  I need to modify that ISR code for my own needs.  I tried to copy the spi_slave_2_70 component to my own copy (spi_slave_2_70_local) and I now have that as a component in my project.  I assume I now have to modify my project's schematic to use that new component for the spi slave device?

               

            But when I try to create a new device based off of my new component, I can't find the new device to add.  Maybe that is a wrong assumption.

               

            How do I make use of the new component?

               

            thanks

               

            Doug

               

            PS - it would be nice if there was a config flag for turning off autogeneration of api code for a device.

            • 3. Re: Disabling Code Generation
              BoTa_264741
                      Ok then it's another story. For ISR to have custom code you have two options: (I) use Isrname_StartEx(...) custom handler, or (ii) use API callback functions. There are examples available inside demo projects in Creator, so you will find them faster than I draft a sample. Callback: http://www.cypress.com/blog/psoc-creator-news-and-information/psoc-creator-33-new-features-patch-code-generated-source   
              • 4. Re: Disabling Code Generation
                JoMe_264151

                There is a flag that stops auto-generation of code. You can find that under the Built-in tab of your component.

                   

                You will need to provide your own code and have it put into the "Source Files" and "Header Files" items.

                   

                There was no mention of creating your own component which is a bit complicated when you want to replace an existing one.

                   

                I would suggest you to avoid changes to the generated files which become difficult with version changes. What exactly do you need to perform in the interrupt handler?

                   

                 

                   

                Bob

                • 5. Re: Disabling Code Generation
                  userc_39729

                  Thanks again for the help.

                     

                  In our design, GPIOs are at a premium and so we did not use a CS for the SPI interface (the spi slave has CS always asserted).  Because of this, I have to track the completion of a spi packet by retrieving the byte count in the packet and counting down to 0 on each received byte before signaling packet completion.  This would be a lot easier to do if I could modify the driver code. The ISR is only called to drain the HW fifo which means there is not a one to one correlation of ISRs to incoming bytes.

                     

                  I'll ask the HW guys to give me a CS signal.  That way I can get an interrupt on negation of CS and then parse the completed packet.

                     

                  thanks

                     

                  Doug

                  • 6. Re: Disabling Code Generation
                    JoMe_264151

                    Search SPI Master datasheet for "callback". There is a macro named SPIM_RX_ISR_ExitCallback that will be called after the receive of a byte. You can hook into as described in Creator Help and check for your number of bytes received.

                       

                     

                       

                    Bob

                    • 7. Re: Disabling Code Generation
                      userc_39729

                      Thank Bob,

                         

                      I'm using a slave not master.  There is an isr callback and in it I return the byte just transferred from the fifo over to the sw queue.  However, if i run the device at a reasonable rate (above 500Kbps) there is not a one to one correlation of ISRs to byte transfers - sometimes an ISR transfers multiple bytes out of the hw fifo.  This is why I wanted to be able to modify the ISR code.

                         

                      I am going to add an interrupt on the negation of the SPI CS and use that to signal packet complete (the master only negates CS once the packet tx is complete).  This way I will not need to do byte by byte processing with a callback.  I'll just parse the pkt when I get the CS negation interrupt.

                         

                      thanks

                         

                      Doug