//init para from default file or default value.
para_init();
ret = sem_init(&sem_com_ready, 0,0); ret = sem_init(&sem_fpga_ready, 0,0); ret = sem_init(&sem_com_data_ready, 0,0);
ret = pthread_mutex_init(&(mutex_com_send),NULL);
if(ret != 0) { ERR("sem_init failed\n"); }
ret = pthread_rwlockattr_init( &attr ); if( ret < 0 ) printf( "pthread_rwlockattr_init failed: %d\n", ret );
ret = pthread_rwlockattr_setpshared( &attr, PTHREAD_PROCESS_SHARED ); if( ret < 0 ) printf( "pthread_rwlockattr_setpshared failed: %d\n", ret );
ret = pthread_rwlock_init( &rwlock, &attr ); if( ret < 0 ) printf( "pthread_rwlock_init failed: %d\n", ret );
pthread_create(&pid_fpga, NULL, thread_fpga, NULL); pthread_create(&pid_com_recv, NULL, thread_com_recv, NULL); pthread_create(&pid_com_data_process, NULL, thread_com_data_process, NULL);
fd = open(DEV_FPGA_ME, O_RDWR); if (fd < 0) { printf("Error: cannot open device (Maybe not present in your board?) %s \n", DEV_FPGA_ME); return -1; }else { printf("open file success\n"); g_fpga_me_fd = fd; sem_post(&sem_fpga_ready);
}
|