Example #1
0
//===========================================================================
//                             READER THREAD 
//===========================================================================
void can0_thread(cyg_addrword_t data)
{
    cyg_uint32             len;
    cyg_uint32             blocking;
    cyg_can_event          rx_event;
    Cyg_ErrNo              res;

    blocking = 0;
    len = sizeof(blocking);
    if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_READ_BLOCKING ,&blocking, &len))
    {
        CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
    } 
    
    len = sizeof(rx_event);  
    res = cyg_io_read(hDrvFlexCAN, &rx_event, &len);
            
    if (-EAGAIN == res)
    {
        CYG_TEST_PASS_FINISH("can_test1 test OK");
    }
    else if (-EINTR == res)
    {
    	CYG_TEST_PASS_FINISH("can_test1 test OK");
    }
    else
    {
        CYG_TEST_FAIL_FINISH("Error reading from /dev/can0");
    }           
}
Example #2
0
static void
test_channel(const char *dev, cyg_io_handle_t channel)
{
    Cyg_ErrNo res;
    cyg_uint32 cfg_data;
    cyg_uint32 len;
    cyg_adc_sample_t sample;
    int count;
    
    diag_printf("\nTesting ADC channel '%s'\n", dev);
    
    // Disable channel
    res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_DISABLE, 0, 0);
    if (res != ENOERR)
        CYG_TEST_FAIL_FINISH("Failed to disable ADC channel");
    
    // Make channel non-blocking
    cfg_data = 0;
    len = sizeof(cfg_data);
    res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_READ_BLOCKING,
                            &cfg_data, &len);
    if (res != ENOERR)
        CYG_TEST_FAIL_FINISH("Failed to make ADC channel non-blocking");

    // Set channel sampling rate
    cfg_data = TEST_RATE;
    len = sizeof(cfg_data);
    res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_RATE,
                            &cfg_data, &len);
    if (res != ENOERR)
        CYG_TEST_FAIL_FINISH("Failed to set ADC channel sampling rate");
    
    // Flush channel
    do {
        len = sizeof(sample);
        res = cyg_io_read(channel, &sample, &len);
    } while (res == ENOERR);
    
    // Enable channel
    res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_ENABLE, 0, 0);
    if (res != ENOERR)
        CYG_TEST_FAIL_FINISH("Failed to enable ADC channel");
    
    // Read from channel
    count = 0;
    while (count < TEST_SAMPLES) {
        len = sizeof(sample);
        res = cyg_io_read(channel, &sample, &len);
        if (res == ENOERR) {
            diag_printf("%d\n", sample);
            count++;
        }
    }
    
    // Disable channel
    res = cyg_io_set_config(channel, CYG_IO_SET_CONFIG_ADC_DISABLE, 0, 0);
    if (res != ENOERR)
        CYG_TEST_FAIL_FINISH("Failed to disable ADC channel");
}
Example #3
0
externC void
cyg_start( void )
{
  ezxml_t f1, team, driver;
  const char * teamname;
  int i;
  
  CYG_TEST_INIT();
  
  f1 = ezxml_parse_str(document, sizeof(document));

  for (team = ezxml_child(f1, "team"); team; team = team->next) {
    teamname = ezxml_attr(team, "name");
    for (i=0,driver = ezxml_child(team, "driver"); 
         driver; 
         driver = driver->next,i++) {
      if (strcmp(results[i].driver, ezxml_child(driver, "name")->txt) ||
          strcmp(results[i].team, teamname) ||
          strcmp(results[i].points, ezxml_child(driver, "points")->txt))
        CYG_TEST_FAIL("Parser failed first test");
    }
  }
  
  if (strcmp(ezxml_get(f1, "team", 0, "driver", 1, "name", -1)->txt,
              "David Coultard")) 
    CYG_TEST_FAIL_FINISH("Parser failed second test");
  else
    CYG_TEST_PASS_FINISH("Parser passed");
  
  ezxml_free(f1);
}
Example #4
0
int main(int argc, char **argv)
{
    pthread_t thread;
    pthread_attr_t attr;
    void *retval;

    CYG_TEST_INIT();

    // Create test thread
    pthread_attr_init( &attr );

    pthread_attr_setstackaddr( &attr, (void *)&thread_stack[sizeof(thread_stack)] );
    pthread_attr_setstacksize( &attr, sizeof(thread_stack) );

    pthread_create( &thread,
                    &attr,
                    pthread_entry1,
                    (void *)0x12345678);

    // Now join with it
    pthread_join( thread, &retval );

    // check retval
    
    if( (long)retval == 0x12345679 )
        CYG_TEST_PASS_FINISH( "pthread1" );
    else
        CYG_TEST_FAIL_FINISH( "pthread1" );
}
Example #5
0
void
cyg_start(void)
{
    CYG_TEST_INIT();
    
    //
    // open flexcan device driver
    //
    if (ENOERR != cyg_io_lookup("/dev/can0", &hDrvFlexCAN)) 
    {
        CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
    }
    
   
    //
    // create the two threads which access the CAN device driver
    // a reader thread with a higher priority and a writer thread
    // with a lower priority
    //
    cyg_thread_create(4, can0_thread, 
                        (cyg_addrword_t) 0,
		                "can0_thread", 
		                (void *) can0_thread_data.stack, 
		                1024 * sizeof(long),
		                &can0_thread_data.hdl, 
		                &can0_thread_data.obj);
		                
    cyg_thread_resume(can0_thread_data.hdl);
    
    cyg_scheduler_start();
}
void
cyg_start(void)
{
    CYG_TEST_INIT();
    
    //
    // open CAN device driver
    //
    if (ENOERR != cyg_io_lookup("/dev/can0", &hCAN0)) 
    {
        CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
    }
    
    //
    // create the thread that accesses the CAN device driver
    //
    cyg_thread_create(4, can0_thread, 
                        (cyg_addrword_t) 0,
                        "can0_thread", 
                        (void *) can0_thread_data.stack, 
                        1024 * sizeof(long),
                        &can0_thread_data.hdl, 
                        &can0_thread_data.obj);
                        
    cyg_thread_resume(can0_thread_data.hdl);
    
    cyg_scheduler_start();
}
Example #7
0
static void entry1( cyg_addrword_t data )
{
    cyg_count32 val;

    cyg_semaphore_peek(&s1, &val);
    CHECK( 2 == val);
    cyg_semaphore_wait(&s1);
    cyg_semaphore_peek(&s1, &val);
    CHECK( 1 == val);
    cyg_semaphore_wait(&s1);
    CHECK( 0 == q++ );
    cyg_semaphore_peek(&s0, &val);
    CHECK( 0 == val);
    cyg_semaphore_post(&s0);
    cyg_semaphore_wait(&s1);
    CHECK( 2 == q++ );
    cyg_semaphore_post(&s0);
    cyg_semaphore_wait(&s1);
    CHECK( 5 == q++ );
    cyg_semaphore_peek(&s0, &val);
    CHECK( 2 == val);
    CHECK( cyg_semaphore_trywait(&s0) );
    cyg_semaphore_peek(&s0, &val);
    CHECK( 1 == val);
    CHECK( cyg_semaphore_trywait(&s0) );
    cyg_semaphore_peek(&s0, &val);
    CHECK( 0 == val);
    cyg_semaphore_post(&s2);
    cyg_semaphore_wait(&s0);
    CYG_TEST_FAIL_FINISH("Not reached");
}
Example #8
0
void server(void)
{
    int s_source;
    struct sockaddr_in local,c_addr;
    int c_len;
    int len;
    
    char *hello_string=" Hello eCos network \n";
    diag_printf("UDP SERVER:");
    diag_printf(hello_string);

    s_source = socket(AF_INET, SOCK_DGRAM, 0);
    if (s_source < 0) {
        pexit("stream socket");
    }   
    memset(&local, 0, sizeof(local));
    local.sin_family = AF_INET;
    local.sin_len = sizeof(local);
    local.sin_port = ntohs(SOURCE_PORT);
    local.sin_addr.s_addr = htonl(INADDR_ANY);  //accepts everyone...
    if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) {
        pexit("bind /source/ error");
    }
    c_len = sizeof(c_addr);

    if ((len = recvfrom(s_source, data_buf, sizeof(data_buf),0,
                        (struct sockaddr *)&c_addr,&c_len)) < 0  ) {
        CYG_TEST_FAIL_FINISH("I/O error");
    }
    diag_printf("SERVER : message arrived from %s\n",inet_ntoa(c_addr.sin_addr));
    diag_printf("SERVER : Message : %s\n",data_buf);
    close(s_source); 
}
Example #9
0
void kmutex1_main( void )
{
    CYG_TEST_INIT();

    cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "kmutex1-0",
        (void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
    cyg_thread_resume(thread[0]);

    cyg_thread_create(4, entry1 , (cyg_addrword_t)1, "kmutex1-1",
        (void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]);
    cyg_thread_resume(thread[1]);

    cyg_thread_create(4, entry2 , (cyg_addrword_t)2, "kmutex1-2",
        (void *)stack[2], STACKSIZE, &thread[2], &thread_obj[2]);
    cyg_thread_resume(thread[2]);

    cyg_mutex_init( &m0 );
    cyg_mutex_init( &m1 );

    cyg_cond_init( &cvar0, &m0 );
    cyg_cond_init( &cvar1, &m0 );
    cyg_cond_init( &cvar2, &m1 );

    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
}
Example #10
0
externC void
cyg_start( void )
{
    CYG_TEST_INIT();

    CYG_TEST_INFO("Calculating CRCs");

    if (1500790746l != cyg_posix_crc32(license_txt,sizeof(license_txt)-1)) {
        CYG_TEST_FAIL("Wrong POSIX CRC32 calculation");
    } else {
        CYG_TEST_PASS("POSIX CRC32 calculation");
    }

    if (1247800780 != cyg_crc32(license_txt,sizeof(license_txt)-1)) {
        CYG_TEST_FAIL("Wrong Gary S. Browns' crc32 calculation");
    } else {
        CYG_TEST_PASS("Gary S. Browns' crc32 calculation");
    }

    if (32256 != cyg_crc16(license_txt,sizeof(license_txt)-1)) {
        CYG_TEST_FAIL_FINISH("Wrong 16bit CRC calculation");
    } else {
        CYG_TEST_PASS_FINISH("16bit CRC calculation");
    }
}
Example #11
0
void client(void)
{
    int s_source;
    struct sockaddr_in local;
    int len;

    diag_printf("client:started\n");
    
    s_source = socket(AF_INET, SOCK_STREAM, 0);
    if (s_source < 0) {
        pexit("stream socket");
    }
    memset(&local, 0, sizeof(local));
    local.sin_family = AF_INET;
    local.sin_len = sizeof(local);
    local.sin_port = htons(SOURCE_PORT);
    local.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
    
    if (connect(s_source, (struct sockaddr *)&local, sizeof(local)) < 0) {
        pexit("Can't connect to target");
    }
    
    if ((len = write(s_source,data_buf_write,40)) < 0){
        CYG_TEST_FAIL_FINISH( "Error writing buffer");
    } 
}
Example #12
0
// ------------------------------------------------------------------------
static void sender( cyg_addrword_t which ) // which means which set (odd/even) here...
{
    int s_source;
    struct sockaddr_in local;
    int len;

    diag_printf("client %d [%s] :started\n", which, (which & 1) ? "odd" : "even" );

    for ( /* which as is */; which < NLISTENERS; which += 2 ) {

        s_source = socket(AF_INET, SOCK_STREAM, 0);
        if (s_source < 0) {
            pexit("stream socket");
        }
        memset(&local, 0, sizeof(local));
        local.sin_family = AF_INET;
        local.sin_len = sizeof(local);
        local.sin_port = htons( SOURCE_PORT1 + which );
        local.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
    
        if (connect(s_source, (struct sockaddr *)&local, sizeof(local)) < 0) {
            pexit("Can't connect to target");
        }
    
        if ((len = write(s_source,data_buf_write1,sizeof(data_buf_write1) )) < 0) {
            CYG_TEST_FAIL_FINISH("Error writing buffer");
        } 
        cyg_semaphore_wait( &listen_sema[which] ); // wait for the appropriate semaphore "reply"
        cyg_semaphore_post( &send_sema ); // count up successful sends

        close ( s_source );
    }
    cyg_thread_exit(); // explicitly
}
Example #13
0
//===========================================================================
// Thread 1
//===========================================================================
void can_tx_thread(cyg_addrword_t data)
{
    cyg_uint32      len;
    cyg_can_message tx_msg;
    cyg_uint32      msg_cnt = 0;
    cyg_uint8       i;

    
    CYG_CAN_MSG_SET_PARAM(tx_msg, 0, CYGNUM_CAN_ID_STD, 0, CYGNUM_CAN_FRAME_DATA);
    
    //
    // Prepare CAN message with a known CAN state
    //
    for (i = 0; i < 8; ++i)
    {
        tx_msg.data.bytes[i] = i; 
    }
    
    while (msg_cnt < 0xF0)
    {
        tx_msg.id = msg_cnt;
        len = sizeof(tx_msg);
        if (ENOERR != cyg_io_write(hCAN_Tbl[0], &tx_msg, &len))
        {
            CYG_TEST_FAIL_FINISH("Error writing to channel 0");    
        }
        
        
        tx_msg.id = msg_cnt;
        len = sizeof(tx_msg);
        if (ENOERR != cyg_io_write(hLoopCAN_Tbl[0], &tx_msg, &len))
        {
            CYG_TEST_FAIL_FINISH("Error writing to channel 1");    
        }
        
        //
        // Increment data in each single data byte
        //
        for (i = 0; i < 8; ++i)
        {
            tx_msg.data.bytes[i] += 1;    
        }
        
        msg_cnt++;
        tx_msg.dlc = (tx_msg.dlc + 1) % 9;
    } // while (msg_cnt < 0x100)
}
Example #14
0
static void finish( cyg_ucount8 t )
{
    cyg_mutex_lock( &m1 ); {
        m1d |= 1<<t;
        if( 0x7 == m1d )
            CYG_TEST_PASS_FINISH("Kernel C API Mutex 1 OK");
        cyg_cond_wait( &cvar2 );
    } /* cyg_mutex_unlock( &m1 ); */
    CYG_TEST_FAIL_FINISH("Not reached");    
}
Example #15
0
void server(void)
{
    int s_source, e_source;
    struct sockaddr_in e_source_addr, local;
    int one = 1;
    fd_set in_fds;
    int len;
    
    char *hello_string=" Hello eCos network \n";
    diag_printf("TCP SERVER:");
    diag_printf(hello_string);

    s_source = socket(AF_INET, SOCK_STREAM, 0);
    if (s_source < 0) {
        pexit("stream socket");
    }   
    if (setsockopt(s_source, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one))) {
        pexit("setsockopt /source/ SO_REUSEADDR");
    }
    if (setsockopt(s_source, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one))) {
        pexit("setsockopt /source/ SO_REUSEPORT");
    }
    memset(&local, 0, sizeof(local));
    local.sin_family = AF_INET;
    local.sin_len = sizeof(local);
    local.sin_port = ntohs(SOURCE_PORT);
    local.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
    if(bind(s_source, (struct sockaddr *) &local, sizeof(local)) < 0) {
        pexit("bind /source/ error");
    }
    listen(s_source, SOMAXCONN);
   
    e_source = 0; 
    while (true) {
	FD_ZERO(&in_fds);
	FD_SET(s_source, &in_fds);
        len = sizeof(e_source_addr);
        if ((e_source = accept(s_source,(struct sockaddr *)&e_source_addr,&len))<0) {
            pexit("accept /source/");
        }
	diag_printf("TCP SERVER connection from %s: %d\n",
	       inet_ntoa(e_source_addr.sin_addr),ntohs(e_source_addr.sin_port));

        if (e_source != 0) {
            break;
        }
    }   /* while (true) */ 
    
    if ((len = read(e_source, data_buf, MAX_BUF)) < 0  ) {
        CYG_TEST_FAIL_FINISH( "I/O error" );
    }
    diag_printf("SERVER : %s\n",data_buf);
    
}
Example #16
0
void
cyg_start(void)
{
    cyg_uint32     len;
    cyg_can_info_t can_cfg;
    
    CYG_TEST_INIT();
    
    //
    // open flexcan device driver
    //
    if (ENOERR != cyg_io_lookup("/dev/can0", &hDrvFlexCAN)) 
    {
        CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
    }
    
    //
    // setup CAN baudrate 250 KBaud
    //
    can_cfg.baud = CYGNUM_CAN_KBAUD_250;
    len = sizeof(can_cfg);
    if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_CAN_INFO ,&can_cfg, &len))
    {
        CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
    }
    
    //
    // create the main thread
    //
    cyg_thread_create(4, can0_thread, 
                        (cyg_addrword_t) 0,
		                "can0_thread", 
		                (void *) can0_thread_data.stack, 
		                1024 * sizeof(long),
		                &can0_thread_data.hdl, 
		                &can0_thread_data.obj);
		                
    cyg_thread_resume(can0_thread_data.hdl);
    
    cyg_scheduler_start();
}
Example #17
0
void zlib2_main( void )
{
    CYG_TEST_INIT();

    cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "zlib1",
        (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]);
    cyg_thread_resume(thread[0]);

    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
}
Example #18
0
static void entry0( cyg_addrword_t data )
{
    int i;
    unsigned long len;
    int err;
    int buf_size = sizeof(gzip_test_ref)+512;
    unsigned char* unpacked = malloc(buf_size);
    
    if (NULL == unpacked)
        CYG_TEST_NA("Not enough memory for buffers");

    CYG_TEST_INFO("Decompressing");
    len = buf_size;
    err = uncompress(unpacked, &len, gzip_test, sizeof(gzip_test));

    switch (err) {
    case Z_OK:
        break;
    case Z_MEM_ERROR:
        CYG_TEST_NA("Not enough memory for decompression");
        break;
    case Z_BUF_ERROR:
        CYG_TEST_FAIL_FINISH("Decompressed data larger than original");
        break;
    case Z_DATA_ERROR:
        CYG_TEST_FAIL_FINISH("Decompression failed");
        break;
    default:
        CYG_TEST_FAIL_FINISH("Unknown decompression error");
        break;
    }

    for (i = 0; i < sizeof(gzip_test_ref)-1; i++) {
        if (gzip_test_ref[i] != unpacked[i])
            CYG_TEST_FAIL_FINISH("Verify failed");
    }

    CYG_TEST_PASS_FINISH("zlib2 OK");
}
Example #19
0
// Clock measurement is done in a separate function so that alignment
// constraints are deterministic - some processors may perform better
// in loops that are better aligned, so by making it always the same
// function, this is prevented.
// FIXME: how do we guarantee the compiler won't inline this on -O3?
static unsigned long
clock_loop( const int timeout, clock_t prevclock, clock_t *newclock )
{
    clock_t c=0;
    long i;

    for (i=0; i<timeout; i++) {
        c = clock();
        if ( c != prevclock )
            break; // Hit the next clock pulse
    }
    
    if (i==timeout)
        CYG_TEST_FAIL_FINISH("No change in clock state!");

    // it should not overflow in the lifetime of this test
    if (c < prevclock)
        CYG_TEST_FAIL_FINISH("Clock decremented!");

    *newclock = c;

    return i;
} // clock_loop()
Example #20
0
//===========================================================================
// Entry point
//===========================================================================
void cyg_start(void)
{
    CYG_TEST_INIT();

    //
    // open CAN device driver channel 1
    //
    if (ENOERR != cyg_io_lookup(CYGPKG_DEVS_CAN_LPC2XXX_CAN0_NAME, &hCAN_Tbl[0])) 
    {
        CYG_TEST_FAIL_FINISH("Error opening CAN channel 0");
    }
    

    //
    // open CAN device driver channel 2
    //
    if (ENOERR != cyg_io_lookup(CYGPKG_DEVS_CAN_LPC2XXX_CAN1_NAME, &hCAN_Tbl[1])) 
    {
        CYG_TEST_FAIL_FINISH("Error opening CAN channel 1");
    }
   
    //
    // create the main thread
    //
    cyg_thread_create(5, can0_thread, 
                        (cyg_addrword_t) 0,
                        "can_tx_thread", 
                        (void *) can0_thread_data.stack, 
                        1024 * sizeof(long),
                        &can0_thread_data.hdl, 
                        &can0_thread_data.obj);
                        
    cyg_thread_resume(can0_thread_data.hdl);
    
    cyg_scheduler_start();
}
Example #21
0
void kthread1_main( void )
{
    CYG_TEST_INIT();

    cyg_thread_create(4, entry0, (cyg_addrword_t)222, "kthread1-0",
        (void *)stack[0], STACKSIZE, &pt0, &thread[0] );
    cyg_thread_create(4, entry1, (cyg_addrword_t)333, "kthread1-1",
        (void *)stack[1], STACKSIZE, &pt1, &thread[1] );

    cyg_thread_resume(pt0);
    cyg_thread_resume(pt1);

    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
}
void
nc_slave_main(void)
{
	int i;	
	
	CYG_TEST_INIT();
   // Create the idle thread environment
    cyg_semaphore_init(&idle_thread_sem, 0);
    cyg_thread_create(IDLE_THREAD_PRIORITY,     // Priority
                      net_idle,                 // entry
                      0,                        // entry parameter
                      "Network idle",           // Name
                      &idle_thread_stack[0],    // Stack
                      STACK_SIZE,               // Size
                      &idle_thread_handle,      // Handle
                      &idle_thread_data         // Thread data structure
            );
    cyg_thread_resume(idle_thread_handle);      // Start it
    // Create the load threads and their environment(s)
    for (i = 0;  i < NUM_LOAD_THREADS;  i++) {
        cyg_semaphore_init(&load_thread_sem[i], 0);
        cyg_thread_create(LOAD_THREAD_PRIORITY,     // Priority
                          net_load,                 // entry
                          i,                        // entry parameter
                          "Background load",        // Name
                          &load_thread_stack[i][0], // Stack
                          STACK_SIZE,               // Size
                          &load_thread_handle[i],   // Handle
                          &load_thread_data[i]      // Thread data structure
            );
        cyg_thread_resume(load_thread_handle[i]);   // Start it
    }
    // Create a main thread, so we can run the scheduler and have time 'pass'
    cyg_thread_create(10,                // Priority - just a number
                      tmain,          // entry
                      0,                 // entry parameter
                      "socket echo test",        // Name
                      &stack[0],         // Stack
                      STACK_SIZE,        // Size
                      &thread_handle,    // Handle
                      &thread_data       // Thread data structure
            );
    cyg_thread_resume(thread_handle);  // Start it
    cyg_scheduler_start();
    CYG_TEST_FAIL_FINISH("Not reached");
}
Example #23
0
void
cyg_start(void)
{
    CYG_TEST_INIT();
    
    //
    // open flexcan device driver
    //
    if (ENOERR != cyg_io_lookup("/dev/can0", &hDrvFlexCAN)) 
    {
        CYG_TEST_FAIL_FINISH("Error opening /dev/can0");
    }
    
    //
    // setup CAN baudrate 250 KBaud
    // We do not setup baud rate and use the default baud rate instead
    /*
    cyg_uint32     len;
    cyg_can_info_t can_cfg;
    can_cfg.baud = CYGNUM_CAN_KBAUD_250;
    len = sizeof(can_cfg);
    if (ENOERR != cyg_io_set_config(hDrvFlexCAN, CYG_IO_SET_CONFIG_CAN_INFO ,&can_cfg, &len))
    {
        CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
    }*/
    
    //
    // create the two threads which access the CAN device driver
    // a reader thread with a higher priority and a writer thread
    // with a lower priority
    //
    cyg_thread_create(4, can0_thread, 
                        (cyg_addrword_t) 0,
		                "can0_thread", 
		                (void *) can0_thread_data.stack, 
		                1024 * sizeof(long),
		                &can0_thread_data.hdl, 
		                &can0_thread_data.obj);
		                
    cyg_thread_resume(can0_thread_data.hdl);
    
    cyg_scheduler_start();
}
Example #24
0
void except0_main( void )
{
    // Use CYG_TEST_GDBCMD _before_ CYG_TEST_INIT()
    CYG_TEST_GDBCMD("handle SIGBUS nostop");
    CYG_TEST_GDBCMD("handle SIGSEGV nostop");
    CYG_TEST_GDBCMD("handle SIGFPE nostop");

    CYG_TEST_INIT();

#ifdef HAL_VSR_SET_TO_ECOS_HANDLER
    // Reclaim the VSR off CygMon possibly
#ifdef CYGNUM_HAL_EXCEPTION_DATA_ACCESS
    HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_ACCESS, NULL );
#endif
#ifdef CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS
    HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_TLBMISS_ACCESS, NULL );
#endif
#ifdef CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS
    HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DATA_UNALIGNED_ACCESS, NULL );
#endif
#ifdef CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION
    HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION, NULL );
#endif
#ifdef CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO
    HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_DIV_BY_ZERO, NULL );
#endif
#ifdef CYGNUM_HAL_EXCEPTION_FPU
    HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_FPU, NULL );
#endif
#ifdef CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO
    HAL_VSR_SET_TO_ECOS_HANDLER( CYGNUM_HAL_EXCEPTION_FPU_DIV_BY_ZERO, NULL );
#endif
#endif

    cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "kexcept1",
        (void *)stack[0], STACKSIZE, &thread[0], &thread_obj[0]);
    cyg_thread_resume(thread[0]);

    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
}
Example #25
0
void ksem1_main( void )
{
    CYG_TEST_INIT();

    cyg_semaphore_init( &s0, 0);
    cyg_semaphore_init( &s1, 2);
    cyg_semaphore_init( &s2, 0);

    cyg_thread_create(4, entry0 , (cyg_addrword_t)0, "ksem1-0",
        (void *)stack[0], STACKSIZE,&thread[0], &thread_obj[0]);
    cyg_thread_resume(thread[0]);

    cyg_thread_create(4, entry1 , (cyg_addrword_t)1, "ksem1-1",
        (void *)stack[1], STACKSIZE, &thread[1], &thread_obj[1]);
    cyg_thread_resume(thread[1]);

    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
}
Example #26
0
void
tcpecho_main(void)
{
    CYG_TEST_INIT();
    
    // Create a main thread, so we can run the scheduler and have time 'pass'
    cyg_thread_create(10,                // Priority - just a number
                      tmain,          // entry
                      0,                 // entry parameter
                      "TCP echo test",        // Name
                      &stack[0],         // Stack
                      STACK_SIZE,        // Size
                      &thread_handle,    // Handle
                      &thread_data       // Thread data structure
            );
            
    cyg_thread_resume(thread_handle);  // Start it   
    cyg_scheduler_start();
    CYG_TEST_FAIL_FINISH("Not reached");
}
Example #27
0
static void
adc_thread(cyg_addrword_t data)
{
    cyg_io_handle_t channel;
    cyg_devtab_entry_t *t;
    
    CYG_TEST_INFO("ADC test");
    
    for (t = &__DEVTAB__[0]; t != &__DEVTAB_END__; t++) {
        if (t->handlers != &cyg_io_adc_devio)
            continue;
        if (cyg_io_lookup(t->name, &channel) == ENOERR) {
            test_channel(t->name, channel);
        } else {
            CYG_TEST_FAIL_FINISH("Cannot open ADC channel");
        }
    }
    
    CYG_TEST_PASS_FINISH("ADC test OK");
}
Example #28
0
externC void
cyg_start( void )
{

    CYG_TEST_INIT();
    
    cyg_thread_create(CONTROLLER_PRI_HI, controller, (cyg_addrword_t)0, "controller",
                      (void *)(&thread_stack[0]), STACKSIZE,
                      &thread_handle[0], &thread[0]);
    
    // resume it
    cyg_thread_resume(thread_handle[0]);

    
    // Get the world going
    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
    
}
Example #29
0
void
tty_api_test(cyg_io_handle_t* handle)
{
    int res;
    cyg_uint32 len;
    unsigned char buffer[16];

    // Always return...
    if (handle)
        return;

    CYG_TEST_FAIL_FINISH("Not reached");

    // read & write
    res = cyg_io_read(handle, &buffer[0], &len);
    res = cyg_io_write(handle, &buffer[0], &len);

    // cyg_io_get_config
    // TTY layer
    cyg_io_get_config(handle, 
                      CYG_IO_GET_CONFIG_TTY_INFO, &buffer[0], &len);
    // Call-throughs to serial layer.
    cyg_io_get_config(handle, 
                      CYG_IO_GET_CONFIG_SERIAL_INFO, &buffer[0], &len);
    cyg_io_get_config(handle, 
                      CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, &buffer[0], &len);
    cyg_io_get_config(handle, 
                      CYG_IO_GET_CONFIG_SERIAL_INPUT_FLUSH, &buffer[0], &len);
    cyg_io_get_config(handle, 
                      CYG_IO_GET_CONFIG_SERIAL_ABORT, &buffer[0], &len);
    cyg_io_get_config(handle, 
                      CYG_IO_GET_CONFIG_SERIAL_OUTPUT_FLUSH, &buffer[0], &len);

    // cyg_io_set_config
    // TTY layer.
    cyg_io_set_config(handle, 
                      CYG_IO_SET_CONFIG_TTY_INFO, &buffer[0], &len);
    // Call-throughs to serial layer.
    cyg_io_set_config(handle, 
                      CYG_IO_SET_CONFIG_SERIAL_INFO, &buffer[0], &len);
}
Example #30
0
void
httpd_main(void)
{
    CYG_TEST_INIT();
    CYG_TEST_INFO("Testing httpd");

    cyg_thread_create(
        10,                 // Priority
        main_thread_entry,  // Entry
        0,                  // Entry parameter
        "main",             // Name
        main_stack,         // Stack
        STACK_SIZE,         // Size
        &main_handle,       // Handle
        &main_thread        // Thread data structure
    );
    cyg_thread_resume(main_handle);
    cyg_scheduler_start();

    CYG_TEST_FAIL_FINISH("Not reached");
}