update util_lib CodeWarrior project files

pull/1/head
Chris Conlon 2014-09-17 16:39:15 -06:00
parent c1bfdeeb81
commit 53b5d7d7f4
3 changed files with 667 additions and 2707 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,52 +7,7 @@
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
<dictionary>
<key>?name?</key>
<value></value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.append_environment</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value>-j6</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>${system:ECLIPSE_HOME}/../gnu/bin/mingw32-make</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildLocation</key>
<value>${ProjDirPath}/twrk70f120m_Int_Flash_SramData_Debug</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.contents</key>
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
<value>false</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.stopOnError</key>
<value>true</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
@ -70,7 +25,7 @@
<variableList>
<variable>
<name>MQX_ROOT_DIR</name>
<value>file:/C:/Freescale/Freescale%20MQX%203.8</value>
<value>file:/C:/Freescale/Freescale_MQX_4_1</value>
</variable>
</variableList>
</projectDescription>

View File

@ -1,178 +1,180 @@
/* util.c */
#include <mqx.h>
#include <bsp.h>
#include <mfs.h>
#include <fio.h>
#include "util.h"
#if !BSPCFG_ENABLE_IO_SUBSYSTEM
#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined \
non-zero in user_config.h. Please recompile BSP with this option.
#endif
#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED
#error This application requires BSP_DEFAULT_IO_CHANNEL to be not \
NULL. Please set corresponding BSPCFG_ENABLE_TTYx to non-zero \
in user_config.h and recompile BSP with this option.
#endif
#if defined BSP_SDCARD_ESDHC_CHANNEL
#if ! BSPCFG_ENABLE_ESDHC
#error This application requires BSPCFG_ENABLE_ESDHC defined \
non-zero in user_config.h. Please recompile libraries with \
this option.
#endif
#elif defined BSP_SDCARD_SDHC_CHANNEL
#if ! BSPCFG_ENABLE_SDHC
#error This application requires BSPCFG_ENABLE_SDHC defined \
non-zero in user_config.h. Please recompile libraries with \
this option.
#endif
#endif
#if defined (BSP_SDCARD_SPI_CHANNEL)
#define SDCARD_COM_CHANNEL BSP_SDCARD_SPI_CHANNEL
#elif defined (BSP_SDCARD_ESDHC_CHANNEL)
#define SDCARD_COM_CHANNEL BSP_SDCARD_ESDHC_CHANNEL
#elif defined (BSP_SDCARD_SDHC_CHANNEL)
#define SDCARD_COM_CHANNEL BSP_SDCARD_SDHC_CHANNEL
#else
#error "SDCARD low level communication device not defined!"
#endif
int sdcard_open(MQX_FILE_PTR *com_handle, MQX_FILE_PTR *sdcard_handle,
MQX_FILE_PTR *partman_handle, MQX_FILE_PTR *filesystem_handle,
char *partman_name, char *filesystem_name)
{
_mqx_int error_code;
_mqx_uint param;
/* Open low level communication device */
*com_handle = fopen(SDCARD_COM_CHANNEL, NULL);
if (NULL == *com_handle) {
printf("Error installing communication handle.\n");
return -60;
}
/* Install SD card device */
error_code = _io_sdcard_install("sdcard:", (pointer) &_bsp_sdcard0_init,
*com_handle);
if (error_code != MQX_OK) {
printf("Error installing SD card device (0x%x)\n", error_code);
return -61;
}
_time_delay(200);
/* Open the device which MFS will be installed on */
*sdcard_handle = fopen("sdcard:", 0);
if (*sdcard_handle == NULL) {
printf("Unable to open SD card device.\n");
return -62;
}
/* Install partition manager over SD card driver */
error_code = _io_part_mgr_install(*sdcard_handle, partman_name, 0);
if (error_code != MFS_NO_ERROR) {
printf("Error installing partition manager: %s\n", MFS_Error_text(
(uint_32) error_code));
return -63;
}
/* Open partition manager */
*partman_handle = fopen(partman_name, NULL);
if (*partman_handle == NULL) {
error_code = ferror(*partman_handle);
printf("Error opening partition manager: %s\n", MFS_Error_text(
(uint_32) error_code));
return -64;
}
/* Validate partition 1 */
param = 1;
error_code = _io_ioctl(*partman_handle, IO_IOCTL_VAL_PART, &param);
if (error_code == MQX_OK) {
/* Install MFS over partition 1 */
error_code = _io_mfs_install(*partman_handle, filesystem_name, param);
if (error_code != MFS_NO_ERROR) {
printf("Error initializing MFS over partition: %s\n",
MFS_Error_text((uint_32) error_code));
return -65;
}
} else {
/* Install MFS over SD card driver */
error_code = _io_mfs_install(*sdcard_handle, filesystem_name,
(_file_size) 0);
if (error_code != MFS_NO_ERROR) {
printf("Error initializing MFS: %s\n", MFS_Error_text(
(uint_32) error_code));
return -66;
}
} /* end Validate partition 1 */
/* Open file system */
*filesystem_handle = fopen(filesystem_name, NULL);
error_code = ferror(*filesystem_handle);
if ((error_code != MFS_NO_ERROR) && (error_code != MFS_NOT_A_DOS_DISK)) {
printf("Error opening filesystem: %s\n", MFS_Error_text(
(uint_32) error_code));
return -67;
}
if (error_code == MFS_NOT_A_DOS_DISK) {
printf("NOT A DOS DISK! You must format to continue.\n");
return -68;
}
return 0;
}
int sdcard_close(MQX_FILE_PTR *sdcard_handle, MQX_FILE_PTR *partman_handle,
MQX_FILE_PTR *filesystem_handle,
char *partman_name, char *filesystem_name)
{
_mqx_int error_code;
/* Close the filesystem */
if (MQX_OK != fclose(*filesystem_handle)) {
printf("Error closing filesystem.\n");
return -69;
}
*filesystem_handle = NULL;
/* Uninstall MFS */
error_code = _io_dev_uninstall(filesystem_name);
if (error_code != MFS_NO_ERROR) {
printf("Error uninstalling filesystem.\n");
return -70;
}
/* Close partition manager */
if (MQX_OK != fclose(*partman_handle)) {
printf("Unable to close partition manager.\n");
return -71;
}
*partman_handle = NULL;
/* Uninstall partition manager */
error_code = _io_dev_uninstall(partman_name);
if (error_code != MFS_NO_ERROR) {
printf("Error uninstalling partition manager.\n");
return -72;
}
/* Close the SD card device */
if (MQX_OK != fclose(*sdcard_handle)) {
printf("Unable to close SD card device.\n");
return -73;
}
*sdcard_handle = NULL;
return 0;
}
/* EOF */
/* util.c */
#include <mqx.h>
#include <bsp.h>
#include <fio.h>
#include <mfs.h>
#include <sdcard.h>
#include <spi.h>
#include <part_mgr.h>
#include "util.h"
#if !BSPCFG_ENABLE_IO_SUBSYSTEM
#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined \
non-zero in user_config.h. Please recompile BSP with this option.
#endif
#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED
#error This application requires BSP_DEFAULT_IO_CHANNEL to be not \
NULL. Please set corresponding BSPCFG_ENABLE_TTYx to non-zero \
in user_config.h and recompile BSP with this option.
#endif
#if defined BSP_SDCARD_ESDHC_CHANNEL
#if ! BSPCFG_ENABLE_ESDHC
#error This application requires BSPCFG_ENABLE_ESDHC defined \
non-zero in user_config.h. Please recompile libraries with \
this option.
#endif
#elif defined BSP_SDCARD_SDHC_CHANNEL
#if ! BSPCFG_ENABLE_SDHC
#error This application requires BSPCFG_ENABLE_SDHC defined \
non-zero in user_config.h. Please recompile libraries with \
this option.
#endif
#endif
#if defined (BSP_SDCARD_SPI_CHANNEL)
#define SDCARD_COM_CHANNEL BSP_SDCARD_SPI_CHANNEL
#elif defined (BSP_SDCARD_ESDHC_CHANNEL)
#define SDCARD_COM_CHANNEL BSP_SDCARD_ESDHC_CHANNEL
#elif defined (BSP_SDCARD_SDHC_CHANNEL)
#define SDCARD_COM_CHANNEL BSP_SDCARD_SDHC_CHANNEL
#else
#error "SDCARD low level communication device not defined!"
#endif
int sdcard_open(MQX_FILE_PTR *com_handle, MQX_FILE_PTR *sdcard_handle,
MQX_FILE_PTR *partman_handle, MQX_FILE_PTR *filesystem_handle,
char *partman_name, char *filesystem_name)
{
_mqx_int error_code;
_mqx_uint param;
/* Open low level communication device */
*com_handle = fopen(SDCARD_COM_CHANNEL, NULL);
if (NULL == *com_handle) {
printf("Error installing communication handle.\n");
return -60;
}
/* Install SD card device */
error_code = _io_sdcard_install("sdcard:", (void *)&_bsp_sdcard0_init,
*com_handle);
if (error_code != MQX_OK) {
printf("Error installing SD card device (0x%x)\n", error_code);
return -61;
}
_time_delay(200);
/* Open the device which MFS will be installed on */
*sdcard_handle = fopen("sdcard:", 0);
if (*sdcard_handle == NULL) {
printf("Unable to open SD card device.\n");
return -62;
}
/* Install partition manager over SD card driver */
error_code = _io_part_mgr_install(*sdcard_handle, partman_name, 0);
if (error_code != MFS_NO_ERROR) {
printf("Error installing partition manager: %s\n", MFS_Error_text(
(uint32_t) error_code));
return -63;
}
/* Open partition manager */
*partman_handle = fopen(partman_name, NULL);
if (*partman_handle == NULL) {
error_code = ferror(*partman_handle);
printf("Error opening partition manager: %s\n", MFS_Error_text(
(uint32_t) error_code));
return -64;
}
/* Validate partition 1 */
param = 1;
error_code = _io_ioctl(*partman_handle, IO_IOCTL_VAL_PART, &param);
if (error_code == MQX_OK) {
/* Install MFS over partition 1 */
error_code = _io_mfs_install(*partman_handle, filesystem_name, param);
if (error_code != MFS_NO_ERROR) {
printf("Error initializing MFS over partition: %s\n",
MFS_Error_text((uint32_t) error_code));
return -65;
}
} else {
/* Install MFS over SD card driver */
error_code = _io_mfs_install(*sdcard_handle, filesystem_name,
(_file_size) 0);
if (error_code != MFS_NO_ERROR) {
printf("Error initializing MFS: %s\n", MFS_Error_text(
(uint32_t) error_code));
return -66;
}
} /* end Validate partition 1 */
/* Open file system */
*filesystem_handle = fopen(filesystem_name, NULL);
error_code = ferror(*filesystem_handle);
if ((error_code != MFS_NO_ERROR) && (error_code != MFS_NOT_A_DOS_DISK)) {
printf("Error opening filesystem: %s\n", MFS_Error_text(
(uint32_t) error_code));
return -67;
}
if (error_code == MFS_NOT_A_DOS_DISK) {
printf("NOT A DOS DISK! You must format to continue.\n");
return -68;
}
return 0;
}
int sdcard_close(MQX_FILE_PTR *sdcard_handle, MQX_FILE_PTR *partman_handle,
MQX_FILE_PTR *filesystem_handle,
char *partman_name, char *filesystem_name)
{
_mqx_int error_code;
/* Close the filesystem */
if (MQX_OK != fclose(*filesystem_handle)) {
printf("Error closing filesystem.\n");
return -69;
}
*filesystem_handle = NULL;
/* Uninstall MFS */
error_code = _io_dev_uninstall(filesystem_name);
if (error_code != MFS_NO_ERROR) {
printf("Error uninstalling filesystem.\n");
return -70;
}
/* Close partition manager */
if (MQX_OK != fclose(*partman_handle)) {
printf("Unable to close partition manager.\n");
return -71;
}
*partman_handle = NULL;
/* Uninstall partition manager */
error_code = _io_dev_uninstall(partman_name);
if (error_code != MFS_NO_ERROR) {
printf("Error uninstalling partition manager.\n");
return -72;
}
/* Close the SD card device */
if (MQX_OK != fclose(*sdcard_handle)) {
printf("Unable to close SD card device.\n");
return -73;
}
*sdcard_handle = NULL;
return 0;
}
/* EOF */