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

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

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

1,176 次查看
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

标签 (1)
标记 (2)
0 项奖励
回复
2 回复数

927 次查看
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 项奖励
回复

927 次查看
jcdammeyer
Contributor III

Thanks

0 项奖励
回复