/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Adding functions to OS 3.8

Username:     
Password:     
             

Forum

# 1   2010-02-21 21:59:07 Adding functions to OS 3.8

logictechs
Member
Registered: 2009-05-07
Posts: 68

Adding functions to OS 3.8

Can someone explain how I add a function to the OS?  I've added the function to the OS and compiled correctly.  Loaded it into the Primer2.  Put the LD, ELF, HEX files in the lib circleos directory.  What header file do I need to add the function listing to for it to be usable in an application?  Added it to the circle.h and the circle_api.h files but when I make an application, it says my function is undefined.

Offline

 

# 2   2010-02-22 06:25:56 Adding functions to OS 3.8

repzak
Member
Registered: 2008-03-05
Posts: 170

Re: Adding functions to OS 3.8

Hello,

You need to add your function to the list of pointers to functions, and add it into the circle header file as well.

Look in the OS how other public functions are made in code C and H files.

Kasper

Offline

 

# 3   2010-02-22 09:43:30 Adding functions to OS 3.8

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Adding functions to OS 3.8

Here is an example of adding function TOUCHSCR_GetRawPos in CircleOS API list. Be warned: next version of CircleOS might make your function inaccesable (at least you will need to recompile your applications)

1) You need to declare a your function in circle.h

Code:

u32  TOUCHSCR_GetRawPos( void );

2) Implement your function in any file you want (if you creating new file don't forget to add it to CircleOS project)

Code:

/*******************************************************************************
*
*                                TOUCHSCR_GetRawPos
*
*******************************************************************************/
/**
*
*  Return the uncalibrated position of the point touched.
*  This position is usefull only if you implement your own calibration.
*
*  @return  The current screen position with X in the LSB and Y in the MSB.
*
*  @warning       The (0x0) point in on the low left corner.
**/
/******************************************************************************/
u32 TOUCHSCR_GetRawPos( void )
    {
    return ( TOUCHSCR_Info.xRaw | ( TOUCHSCR_Info.yRaw << 16 ) );
    }

3) now you need to assing a new ID to yuor function in circle_api.h. MAKE SURE IT'S NOT USED BY OTHER FUNCTIONS

Code:

#define TOUCHSCR_GET_RAW_POS_ID       (TOUCHSCR_ID + 8)

4) declare your function in circle_api.h. This will describe how applications will see yor function

Code:

#define TOUCHSCR_GetRawPos()    (u32)  (((tCircleFunc0)(Circle_API [TOUCHSCR_GET_RAW_POS_ID])) () )
/* u32 TOUCHSCR_GetRawPos( void );*/

5) put your function into the list of API calls if circle_api.c. Be sure to PUT IT INTO THE RIGHT PLACE (depends on the id form step 3)

Code:

#ifdef PRIMER2
    /* TOUCHSCREEN functions (0x61)*/
    (tCircleFunc0)TOUCHSCR_GetPos,
    (tCircleFunc0)TOUCHSCR_GetAbsPos,
    (tCircleFunc0)TOUCHSCR_IsPressed,
    (tCircleFunc0)TOUCHSCR_GetMode,
    (tCircleFunc0)TOUCHSCR_SetSensibility,       
    (tCircleFunc0)LIST_Manager,
    (tCircleFunc0)LIST_Set,
    0,
    (tCircleFunc0)TOUCHSCR_GetRawPos, //<- Here it is

    /* TOOLBAR functions (0x6A)*/
    (tCircleFunc0)TOOLBAR_Set,
    (tCircleFunc0)TOOLBAR_SetDefaultToolbar,
    (tCircleFunc0)TOOLBAR_ChangeButton,
    0,0,0,
#endif

Now compile and flash CircleOS. In every application you wiil need to use a new circle_api.h. lib and hex files are not required to be updated.

Feel free to ask if you wan't get it working.

Last edited by ntrf.zns (2010-02-22 09:47:14)

Offline

 

# 4   2010-02-28 20:37:25 Adding functions to OS 3.8

logictechs
Member
Registered: 2009-05-07
Posts: 68

Re: Adding functions to OS 3.8

Thanks ntrf.zns for your very helpfull step by step procedure!  I was able to get my application to recognize the functions I added to the OS.  One function so far is creating a hardware fault condition when I use it in my app.  If I put it in the OS main.c file at the end of all other init functions, it works with no harware fault issue.  My functions utilize pin A.4 off the extension connector.  I've been able to use this pin before by having the functions in my app directly.  It needs to work as an input and output.  I have the functions switch between configs as needed before issuing the function.  Any more help/suggestions would be greatly appreciated!

Thanks,

Logictechs

Offline

 

# 5   2010-02-28 21:39:20 Adding functions to OS 3.8

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Adding functions to OS 3.8

Well there is one point i forgot to mention: type tCircleFunc0 (in steps 4 and 5) need to be replaced according to number of arguments your function accepts: tCircleFunc1 for 1 argument (regardles of type), tCircleFunc2 for 2 and so on. I also suggest you check the function declarations and arguments everywhere. When dealing with #define's you need to add arguments and cast them:

Code:

#define MYNAMESPACE_MyFunction(arg1,arg2)    (u32)  (((tCircleFunc2)(Circle_API [MYNAMESPACEMY_FUNCTION_ID])) ((u32)arg1,(s8)arg2) )
/* u32 MYNAMESPACE_MyFunction( u32, s8 );*/

The other problem is ID. It must be equal to number fo functions in list (step 5) before your function.

PS Sorry about streching your browser window, but those must be written in one line

Last edited by ntrf.zns (2010-02-28 21:40:45)

Offline

 

# 6   2010-03-01 00:57:50 Adding functions to OS 3.8

logictechs
Member
Registered: 2009-05-07
Posts: 68

Re: Adding functions to OS 3.8

Thanks for the reply again.  Still no go.  I have 3 functions I'm trying to add to the OS.  Here's what they're trying to do:

1.  Toggle pin a.4, look for a response on same pin, report the response in the app with a u8 value.

2.  Write a u8 value from the app out on pin a.4 by shifting bits out.

3.  Read a u8 value in from pin a.4 by shifting in bits to a value in the app.

Please present examples of doing this.  These functions seem to work ok if I use them in the main.c file of the OS during debug but just not in my application.  I've copied the same circle_api.h file to my app project directory and put all 3 of the OS needed files in the CircleOS directory.

Thanks,

Logictechs

Offline

 

# 7   2010-03-02 20:33:05 Adding functions to OS 3.8

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Adding functions to OS 3.8

If you managed to get your functions working from the OS code itself then your functions are correctly written. I have two options of what might gone wrong in your program:
1) Index for a new function(s) is outside of RAM area dedicated to OS. Try using blank indexes between existing functions
2) When you debuging the application yuo still need CircleOS.elf with your application. Otherwise you will flash the old version of firmware back on debug start. I only tested my method on add_to_circle applications.

If you need functions to controll just one pin why don't you drive the pin directly? Just use stm library and  from application withous using OS functions (same true for interrupts - UTIL_SetIrqHandler helps you to set the new handler).

Offline

 

Board footer