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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-27-2017, 02:27 AM
|
#1
|
LQ Newbie
Registered: Apr 2017
Posts: 1
Rep:
|
Coding serial ISR for UART 16550 under Linux kernel 3.18
Hello,
I have a problem with my ISR made on the basis of http://http://www.linuxquestions.org...-linux-763595/Coding an Interrupt Service Routine for the serial port in Linux !! post. Here is my code:
Code:
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/version.h>
#include <linux/fs.h>
#include <asm/io.h>
#include <asm/signal.h>
#include <linux/irq.h>
#define PORT 0x3F8
void delayedOp (unsigned long currentlyUnused);
DECLARE_TASKLET (rs232Tasklet, delayedOp, 0);
static int times;
static unsigned char znak;
unsigned char status, intr_identify;
irq_handler_t isrSerialPort (int irq, void *dev_id, struct pt_regs *regs)
{
times++;
printk (KERN_ALERT "\nisrSerialPort called %d ", times);
intr_identify = inb( PORT + 2 ) & 0x0F;
if ( intr_identify == 0x01 ) return IRQ_NONE;
if ( intr_identify == 0x04 ) // a new character has arrived
znak=inb( PORT );
printk (" irq = %x, intr = %x ", znak,intr_identify);
outb(znak,PORT);
tasklet_schedule (&rs232Tasklet);
outb(0x20,0x20);
return (irq_handler_t) IRQ_HANDLED;
}
int init_module ()
{
int status;
int result = request_irq (4, (irq_handler_t) isrSerialPort, IRQF_DISABLED, "softbrainISR", NULL);
outb(0x0b,PORT+4); //ster_modem - DTR,RTS,OUT2
outb( 0x07, PORT + 2 ); // turn off FIFO-mode
inb(PORT+6); //stan_modem
inb(PORT+5); //status_port
inb(PORT); //dane
outb(0x8b,PORT+3); //LCR=1, param_trans = 0x0b - parity even (b3-b5), 1 bit stopu(b2), 8 bitów danych (b0,b1)
//03 - dla parity none
outb(0x0c,PORT); //9600 bodów
outb(0x0b,PORT+3); //LCR=0
outb(01,PORT+1); //przerwanie od odbiornika aktyw_przerw=1
status=inb(PORT+5);
if(status&01)inb(PORT);
inb(PORT);
printk (KERN_INFO "\ncinit_module called\n");
return result;
}
void delayedOp (unsigned long currentlyUnused)
{
printk ("\nznak = %x ", znak);
}
void cleanup_module ()
{
free_irq (4, NULL);
printk (KERN_INFO "\ncleanup_module called\n");
}
The problem is that the first interrupt doesn't come - the first character I send comes after I send the next character and so on... In effect I never get the last one - It waits for interrupt until next character.
Where is the problem?
Please help me
Anna
|
|
|
04-28-2017, 06:48 PM
|
#2
|
LQ Guru
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524
|
Hi Anna,
Welcome to LQ!
OK, for this you must learn the debugger. It will allow you to step through the code while monitoring what is going on. If I had to figure this out, that is what I'd need to do.
|
|
|
All times are GMT -5. The time now is 09:43 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|