LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-05-2018, 07:29 AM   #1
Jim232
Member
 
Registered: Apr 2018
Posts: 53

Rep: Reputation: Disabled
struct spi_transfer members tx_nbits rx_nbits function ?


SPI_NBITS_SINGLE ?

I am looking for better explanation what tx_nbits and rx_nbits do.
Perhaps they are talking about "bytes"?

tx_nbits
number of bits used for writing. If 0 the default (SPI_NBITS_SINGLE) is used.
rx_nbits
number of bits used for reading. If 0 the default (SPI_N






struct spi_transfer {
const void * tx_buf;
void * rx_buf;
unsigned len;
dma_addr_t tx_dma;
dma_addr_t rx_dma;
struct sg_table tx_sg;
struct sg_table rx_sg;
unsigned cs_change:1;
unsigned tx_nbits:3;
unsigned rx_nbits:3;
#define SPI_NBITS_SINGLE 0x01
#define SPI_NBITS_DUAL 0x02
#define SPI_NBITS_QUAD 0x04
u8 bits_per_word;
u16 delay_usecs;
u32 speed_hz;
struct list_head transfer_list;
};


FYI here is a link to ONE of few copies of SAME article on the web

https://manpages.debian.org/wheezy-b...sfer.9.en.html
 
Old 05-05-2018, 11:58 AM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Quote:
Originally Posted by Jim232 View Post
Perhaps they are talking about "bytes"?
No. The :3 declares a member that is 3 bits wide. http://en.cppreference.com/w/c/language/bit_field

Maybe the following will help. From here: https://github.com/torvalds/linux/bl...spi/spi.h#L765
Quote:
* When SPI can transfer in 1x,2x or 4x. It can get this transfer information
* from device through @tx_nbits and @rx_nbits. In Bi-direction, these
* two should both be set. User can set transfer mode with SPI_NBITS_SINGLE(1x)
* SPI_NBITS_DUAL(2x) and SPI_NBITS_QUAD(4x) to support these three transfer.
 
Old 05-05-2018, 08:50 PM   #3
Jim232
Member
 
Registered: Apr 2018
Posts: 53

Original Poster
Rep: Reputation: Disabled
Thanks
You made a reference to resource I have been using.

" When SPI can transfer (what ?) in 1x,2x or 4x" - seems incomplete sentence.
Transfer in ...what ?

Any data in "small parts" - not a whole 8 bit word at once - as configured elsewhere?

Which member of the struct are they talking about?
The #defines are 1,2,4 and the value for x_nbits is 3

No, I still do not get it, sorry.
 
Old 05-06-2018, 05:58 PM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
1x is 1, 2x is 2, and 4x is 3.
 
  


Reply

Tags
linux



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse on linux -> sluggish preview of struct members erasmospunk Programming 2 01-12-2007 07:49 PM
how to pass pointer of struct to function? jinxcat Programming 2 09-01-2005 09:29 AM
C question;how do I put struct in function? ngan_yine Programming 10 02-09-2005 02:54 PM
Script for vim (shows members of a struct like VC) Xa! Linux - Newbie 3 03-09-2004 07:17 PM
C: struct as a function parameter zokik Programming 3 12-06-2003 02:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration