How to customize 'FILE' operations on a 9S12XDP512 under CodeWarrier 5.9.0 and Metroworks C

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to customize 'FILE' operations on a 9S12XDP512 under CodeWarrier 5.9.0 and Metroworks C

757 Views
jcdammeyer
Contributor III

Starting with this statement in my application:

USBDevice = fopen("USB1:", "r+");  // Calls TERMIO_Init()

Following fopen(LIBDEF_ConstStringPtr name, LIBDEF_ConstStringPtr mode) in the debugger I find I'm taken to TERMIO_Init() without any arguments to let me expand on the file i/o system.  The code for this is in embedded.c.  Not only that, stdlib.c has the one single declaration for FILE channels[1];  In stdio.h we have extern FILE channels[1]; and the FILE struct itself declared in stdio.h.

 

What I'd like to be able to do is handle multiple FILE channels so I can support the two UARTs, a USB connection and possibly a few others.  To do that it looks like I have to remove embedded.c and recompile into the library the stdlib.c to get rid of the channels declaration.  Shouldn't really be there in the first place since it's not used within the entire library that I can find with grep.

The run time library routines all have

   Copyright (c) Metrowerks, Basel, Switzerland

               All rights reserved

                  Do not modify!

So is there by chance an application note with code that has most of the work done to redirect the system functions like fopen, close, fputc etc. as contained in embedded.c?

Or am I on my own here?

The longer term project is to possibly add SD card and file name support.  Perhaps there's an app note that handles the fopen with file names?

Thanks

John

Labels (1)
Tags (2)
0 Kudos
Reply
2 Replies

508 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

hello John,

We can not use FILE operations in CW for HCS12. It is not possible since there is NO "standard output" in embedded system.

normally FILE operations need RTOS support. for example, MQX. however MQX can't support hcs12(x) device because its limited resource. other Freescale device such as Kinetis can support FILE operations with MQX support.



Best Regards,

Zhang Jun

==============================================

this answer is for you. if it helps, please click on "correct answer " button. thanks!

==============================================

0 Kudos
Reply

508 Views
jcdammeyer
Contributor III

Thanks

0 Kudos
Reply