Thread 中讨论的其他器件: CCStudio、 C2000WARE
工具与软件:
大家好、团队成员:
我编写了一个 CLA 代码、调用一个测试用例函数并进行一些转换。 代码正在生成、调试未按预期在 CLA 中进行。 2到3个函数调用后、调试将转到 asm 文件(看门狗)。
这里、我附加了 CLA 文件和主文件。
如果需要任何文件/信息、请告诉我。
谢谢。此致、
Rajesh
/*
Filename: main.c
*/
#include "device.h"
void breakfunc();
int main(void)
{
Device_setup();
//
// Enable ADC interrupt
//
ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
#ifndef CLA_CPU
Interrupt_enable(INT_ADCA1);
#endif
//
// Enable the clock to synchronously enable all the ePWMs
//
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC);
breakfunc();
//while(1);
return 0;
}
void breakfunc()
{
volatile int bp=0;
}
/*
Filename: test.cla
*/
#include <stdio.h>
#include <device.h>
#define MSG_SIZE 32
int testbed_out;
int history_in_target;
int fileid;
int Configured;
char message[MSG_SIZE];
int exit_reached;
int iter_message;
char *qqqqone;
int test_return;
void upload (void)
{
int iter;
iter_message=0;
for ( iter=0; iter<MSG_SIZE; iter++ ) {
message[iter] = 0;
}
}
void port_init (void)
{
int i;
Configured=0;
qqqqone="%6d%6d\n";
for( i=0;i<MSG_SIZE;i++)
{
message[i]=0;
}
upload();
iter_message=0;
message[0]=0;
Configured=1;
}
void c_exit()
{
Configured = 1;
}
void port_close()
{
exit_reached=1;
upload();
c_exit();
}
int port_configured (void) {
return Configured;
}
int port_open (void) {
fileid = 1;
/*
* Protect against the case with just a single main and in white box
* where the port can get initialised twice
*/
if ( port_configured() == 0 ) {
port_init();
}
/* Need to stop ldra_port_close from being optimised out */
if ( port_configured() == 0 ) {
port_close();
}
return fileid;
}
void port_write(const char *pMsg)
{
if ( pMsg != 0 ) {
/* Output characters in string until 0 terminator */
while (*pMsg != 0 ) {
/* Write characters to the buffer */
message[iter_message] = *pMsg;
iter_message++;
if ( iter_message >= MSG_SIZE ) {
/* Upload the entire buffer in one go when full */
upload();
}
/* Point to next character */
pMsg++;
}
message[iter_message]=0;
}
}
int port_initialisation(void)
{
/* ****4 New test case initialisation */
testbed_out = port_open();
return 1;
} /* end of port_initialisation */
void output (char *fmt,int start,int new_line)
{
port_write (fmt);
if (new_line)
{
port_write ("\n");
}
}
char abs (const int n)
{
int v;
if ( n < 0 ) {
v = -n;
} else {
v = n;
}
return v;
}
void char_push_front(char* buf, int i, const char add)
{
/* Move any previous values */
int k = i-1;
while (k >= 0) {
buf[i] = buf[k];
i--;
k--;
}
/* Add the next value */
buf[0]=add;
}
int int_sprintf(char* buf, const char *fmt, const int ap)
{
int i = 0;
int ret = 0;
int value = ap;
/* null terminate the array */
buf[i]=0;
i++;
if (value == 0) {
char_push_front(buf,i,'0');
i++;
}
while (value != 0) {
/* Compute the next character */
char next = abs(value % 10) + '0';
/* Add to the existing array */
char_push_front(buf,i,next);
/* Calculate the next step */
value = value / 10;
i++;
}
/* If the original value was negative, add the sign */
if (ap < 0) {
char_push_front(buf,i,'-');
i++;
}
/* return number of printed characters minus the null terminator */
ret = i-1;
return ret;
}
int signed_int_convert(const signed int value, char* res)
{
int_sprintf (res,"%d", value);
return 1;
}
int int_strcmp (const char* a, const char* b)
{
int ret = 0;
if (a == (const char*)(0) && b == (const char*)(0)) {
ret = 0;
} else if (a == (const char*)(0)) {
ret = 1;
} else if (b == (const char*)(0)) {
ret = -1;
} else {
while (!(ret = *(unsigned char*)a - *(unsigned char*)b) && *b) {
++a;
++b;
}
if (ret < 0 ) {
ret = -1;
} else if (ret > 0) {
ret = 1;
}
}
return ret;
}
int string_compare (char* a, char* b)
{
int equal = 0;
if (a == (char*)(0) && b == (char*)(0)) {
equal = 1;
} else if (a != (char*)(0) && b != (char*)(0)) {
equal = int_strcmp(a,b) == 0;
}
return equal;
}
int int_convert(int expected_value,int actual_value,char * name,
char * svalue,char df,int convert,int compare,
int convert_ok,char * expstr)
{
char testbed_buff[64];
int variable_converted = 1;
int variable_passed = 1;
int var_exception_raised = 0;
char str[3];
int saved_history_in_target = history_in_target;
testbed_buff[0] = '\0';
str[0] = df;
str[1] = ' ';
str[2] = '\0';
if (convert == 1)
{
variable_converted = signed_int_convert (actual_value,testbed_buff);
}
if (var_exception_raised == 1)
{
output (name,0,1);
variable_passed = 0;
}
else
{
if (convert > 0)
{
output ("pass",0,1);
}
else
{
output ("fail",0,1);
}
if (variable_converted == 1)
{
variable_passed = 0;
if (compare == 1)
{
if (expected_value != actual_value)
{
variable_passed = 0;
}
else
{
variable_passed = 1;
}
}
}
else
{
if (convert_ok == 0)
{
variable_passed = string_compare (expstr,testbed_buff);
}
else
{
variable_passed = 0;
}
}
if (variable_passed == 1)
{
output ("P ",1,0);
}
else
{
output ("F ",1,0);
}
history_in_target = 0;
if (variable_converted == 1)
{
output ("V",0,0);
}
else
{
output ("F",0,0);
}
if (convert > 0)
{
output (" ",0,0);
output (testbed_buff,0,0);
}
output ("",0,1);
history_in_target = saved_history_in_target;
}
return variable_passed;
}
int unit_test()
{
return 0;
}
int test_case_1()
{
int passed=1;
int exception_raised=1;
output("need to print",1,1);
test_return=unit_test();
if (exception_raised == 1)
{
output ("pass",1,1);
}
else
{
output ("fail",1,1);
}
if (int_convert(test_return,test_return,"%",
"",'O',1,1,
1,"") == 0)
{
passed = 0;
}
return passed;
}
void initialise()
{
testbed_out=0;
fileid=0;
history_in_target = 1;
Configured=0;
}
void test_cla()
{
//
// Uncomment to halt and debug
__mdebugstop();
initialise();
if (port_initialisation())
{
/*
* Execute new test case
*/
test_case_1 ();
}
port_close();
return ;
}
