LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices



Reply
 
Search this Thread
Old 08-05-2008, 03:27 PM   #1
Gnu2Linux2
LQ Newbie
 
Registered: Jul 2008
Posts: 3

Rep: Reputation: 0
Simple Bit Bang Serial Driver Question


This is dirt simple, so please don't kill me.

I am new to linux drivers and want see if my approach is correct
here. I need to write a little bit banging device driver to a custom
CPLD 3-Wire serial interface. This is a one way communication meaning
we are only writing to the device over the serial interface.

So, I think what i need to do is write a character driver will
implement an open, release, and write methods and of course the init
and exit to setup the character driver. Is the correct approach?

In my write method in the driver, when i receive the 3 bytes of data
that I need to bit-bang over 3 gpios I will enable the chip select
gpio and start the clocking gpio and transmitting the the bits on the
data gpio.

Anyone have a sample driver of something similar? I just basically
want to see how the correct way to implement the timer for the clock
in the kernel. I am sure I can figure it out and will, but would like
to see an example from someone who is not as new to linux as I am.

i know the pseudo code is something like the following, but maybe a
timer (i assume there are timers in the kernel) is the better approach
which is the whole reason I am asking about this.

bbserial_write(....)
{
enable the chip select gpio (set low)
while (bits to write)
{
set clk gpio low
wait 1/2 bit time
set data gpio
wait 1/2 bit time
set clk gpio high
}
disable the chip select gpio (set high)
}
 
Old 08-06-2008, 03:39 PM   #2
cramer-creek
LQ Newbie
 
Registered: Aug 2008
Posts: 2

Rep: Reputation: 0
bit time delay

use udelay(HALF_BIT_TIME)

see linux/drivers/i2c/algos/i2c-algo-bit.c
for a (complex and generic ) example of this.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: Community: Why There is Better Driver Support in 64-bit Linux Than 64-bit Windows XP LXer Syndicated Linux News 0 10-18-2006 10:33 PM
simple video driver question - need help fast dmarotto Linux - General 3 02-15-2004 01:20 PM
serial line is not 8 bit clean thunderrooster Linux - General 0 01-31-2002 09:17 AM
Simple Serial Connection Bloughry Linux - General 0 09-20-2001 07:17 PM
Recieve serial link is not 8-bit clean rdaves@earthlink.net Linux - Networking 5 07-12-2001 01:25 AM


All times are GMT -5. The time now is 12:37 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration