Serial-Debugger entfernt.
This commit is contained in:
parent
2ce96ae16b
commit
6385143965
14
Makefile
14
Makefile
|
|
@ -16,7 +16,7 @@ endif
|
|||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
all: .rs232dbg .drivers .rt .mini
|
||||
all: .drivers .rt .mini
|
||||
|
||||
doc docs:
|
||||
doxygen Doxyfile
|
||||
|
|
@ -32,14 +32,6 @@ else
|
|||
@echo "Skipping Real-Time."
|
||||
endif
|
||||
|
||||
ifeq ($(MAKE_RS232),yes)
|
||||
.rs232dbg:
|
||||
$(MAKE) -C rs232dbg
|
||||
else
|
||||
.rs232dbg:
|
||||
@echo "Skipping rs232dbg."
|
||||
endif
|
||||
|
||||
.mini:
|
||||
$(MAKE) -C mini
|
||||
|
||||
|
|
@ -50,17 +42,13 @@ config conf $(CONFIG_FILE):
|
|||
@echo "RTAIDIR =" >> $(CONFIG_FILE)
|
||||
@echo "RTLIBDIR =" >> $(CONFIG_FILE)
|
||||
@echo >> $(CONFIG_FILE)
|
||||
@echo "#GCC_SYSTEMDIR = /usr/lib/gcc-lib/i486-suse-linux/3.3/include" >> $(CONFIG_FILE)
|
||||
@echo >> $(CONFIG_FILE)
|
||||
@echo "MAKE_RT = yes" >> $(CONFIG_FILE)
|
||||
@echo "MAKE_RS232 = yes" >> $(CONFIG_FILE)
|
||||
@echo >> $(CONFIG_FILE)
|
||||
@echo "$(CONFIG_FILE) erstellt."
|
||||
|
||||
clean:
|
||||
$(MAKE) -C rt clean
|
||||
$(MAKE) -C drivers clean
|
||||
$(MAKE) -C rs232dbg clean
|
||||
$(MAKE) -C mini clean
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
#include <linux/slab.h>
|
||||
|
||||
#include "ec_command.h"
|
||||
#include "ec_dbg.h"
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
|
|
@ -79,7 +78,7 @@ void EtherCAT_command_read(EtherCAT_command_t *cmd,
|
|||
unsigned int length)
|
||||
{
|
||||
if (node_address == 0x0000)
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Using node address 0x0000!\n");
|
||||
printk(KERN_WARNING "EtherCAT: Using node address 0x0000!\n");
|
||||
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
|
|
@ -112,7 +111,7 @@ void EtherCAT_command_write(EtherCAT_command_t *cmd,
|
|||
const unsigned char *data)
|
||||
{
|
||||
if (node_address == 0x0000)
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Using node address 0x0000!\n");
|
||||
printk(KERN_WARNING "EtherCAT: Using node address 0x0000!\n");
|
||||
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef ECDBG_H_
|
||||
#define ECDBG_H_
|
||||
|
||||
|
||||
//#define DEBUG_SEND_RECEIVE
|
||||
#define ECMASTER_DEBUG
|
||||
|
||||
|
||||
//#include "../rs232dbg/rs232dbg.h"
|
||||
|
||||
|
||||
#ifdef ECMASTER_DEBUG
|
||||
/* note: prints function name for you */
|
||||
//# define EC_DBG(fmt, args...) SDBG_print(fmt, ## args)
|
||||
|
||||
//#define EC_DBG(fmt, args...) SDBG_print("%s: " fmt, __FUNCTION__ , ## args)
|
||||
#define EC_DBG(fmt, args...) printk(fmt, ## args)
|
||||
#else
|
||||
#define EC_DBG(fmt, args...)
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
#include <linux/delay.h>
|
||||
|
||||
#include "ec_device.h"
|
||||
#include "ec_dbg.h"
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
|
|
@ -92,13 +91,13 @@ int EtherCAT_device_assign(EtherCAT_device_t *ecd,
|
|||
{
|
||||
if (!dev)
|
||||
{
|
||||
EC_DBG("EtherCAT: Device is NULL!\n");
|
||||
printk("EtherCAT: Device is NULL!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ecd->tx_skb = dev_alloc_skb(ECAT_FRAME_BUFFER_SIZE)) == NULL)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not allocate device tx socket buffer!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate device tx socket buffer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +106,7 @@ int EtherCAT_device_assign(EtherCAT_device_t *ecd,
|
|||
dev_kfree_skb(ecd->tx_skb);
|
||||
ecd->tx_skb = NULL;
|
||||
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not allocate device rx socket buffer!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate device rx socket buffer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -115,7 +114,7 @@ int EtherCAT_device_assign(EtherCAT_device_t *ecd,
|
|||
ecd->tx_skb->dev = dev;
|
||||
ecd->rx_skb->dev = dev;
|
||||
|
||||
EC_DBG("EtherCAT: Assigned Device %X.\n", (unsigned) dev);
|
||||
printk("EtherCAT: Assigned Device %X.\n", (unsigned) dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -139,13 +138,13 @@ int EtherCAT_device_open(EtherCAT_device_t *ecd)
|
|||
{
|
||||
if (!ecd)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Trying to open a NULL device!\n");
|
||||
printk(KERN_ERR "EtherCAT: Trying to open a NULL device!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ecd->dev)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: No device to open!\n");
|
||||
printk(KERN_ERR "EtherCAT: No device to open!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -171,15 +170,15 @@ int EtherCAT_device_close(EtherCAT_device_t *ecd)
|
|||
{
|
||||
if (!ecd->dev)
|
||||
{
|
||||
EC_DBG("EtherCAT: No device to close!\n");
|
||||
printk("EtherCAT: No device to close!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
EC_DBG("EtherCAT: txcnt: %u, rxcnt: %u\n",
|
||||
printk("EtherCAT: txcnt: %u, rxcnt: %u\n",
|
||||
(unsigned int) ecd->tx_intr_cnt,
|
||||
(unsigned int) ecd->rx_intr_cnt);
|
||||
|
||||
EC_DBG("EtherCAT: Stopping device at 0x%X\n",
|
||||
printk("EtherCAT: Stopping device at 0x%X\n",
|
||||
(unsigned int) ecd->dev);
|
||||
|
||||
return ecd->dev->stop(ecd->dev);
|
||||
|
|
@ -211,7 +210,7 @@ int EtherCAT_device_send(EtherCAT_device_t *ecd,
|
|||
|
||||
if (ecd->state == ECAT_DS_SENT)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Trying to send frame while last was not received!\n");
|
||||
printk(KERN_WARNING "EtherCAT: Trying to send frame while last was not received!\n");
|
||||
}
|
||||
|
||||
skb_trim(ecd->tx_skb, 0); // Clear transmit socket buffer
|
||||
|
|
@ -224,7 +223,7 @@ int EtherCAT_device_send(EtherCAT_device_t *ecd,
|
|||
// Add Ethernet-II-Header
|
||||
if ((eth = (struct ethhdr *) skb_push(ecd->tx_skb, ETH_HLEN)) == NULL)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: device_send - Could not allocate Ethernet-II header!\n");
|
||||
printk(KERN_ERR "EtherCAT: device_send - Could not allocate Ethernet-II header!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -262,13 +261,13 @@ int EtherCAT_device_receive(EtherCAT_device_t *ecd,
|
|||
{
|
||||
if (ecd->state != ECAT_DS_RECEIVED)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: receive - Nothing received!\n");
|
||||
printk(KERN_ERR "EtherCAT: receive - Nothing received!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ecd->rx_data_length > ECAT_FRAME_BUFFER_SIZE)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: receive - Reveived frame too long (%i Bytes)!\n",
|
||||
printk(KERN_ERR "EtherCAT: receive - Reveived frame too long (%i Bytes)!\n",
|
||||
ecd->rx_data_length);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -303,29 +302,29 @@ void EtherCAT_device_call_isr(EtherCAT_device_t *ecd)
|
|||
|
||||
void EtherCAT_device_debug(EtherCAT_device_t *ecd)
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "---EtherCAT device information begin---\n");
|
||||
printk(KERN_DEBUG "---EtherCAT device information begin---\n");
|
||||
|
||||
if (ecd)
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "Assigned net_device: %X\n", (unsigned) ecd->dev);
|
||||
EC_DBG(KERN_DEBUG "Transmit socket buffer: %X\n", (unsigned) ecd->tx_skb);
|
||||
EC_DBG(KERN_DEBUG "Receive socket buffer: %X\n", (unsigned) ecd->rx_skb);
|
||||
EC_DBG(KERN_DEBUG "Time of last transmission: %u\n", (unsigned) ecd->tx_time);
|
||||
EC_DBG(KERN_DEBUG "Time of last receive: %u\n", (unsigned) ecd->rx_time);
|
||||
EC_DBG(KERN_DEBUG "Number of transmit interrupts: %u\n", (unsigned) ecd->tx_intr_cnt);
|
||||
EC_DBG(KERN_DEBUG "Number of receive interrupts: %u\n", (unsigned) ecd->rx_intr_cnt);
|
||||
EC_DBG(KERN_DEBUG "Total Number of interrupts: %u\n", (unsigned) ecd->intr_cnt);
|
||||
EC_DBG(KERN_DEBUG "Actual device state: %i\n", (int) ecd->state);
|
||||
EC_DBG(KERN_DEBUG "Receive buffer: %X\n", (unsigned) ecd->rx_data);
|
||||
EC_DBG(KERN_DEBUG "Receive buffer fill state: %u/%u\n",
|
||||
printk(KERN_DEBUG "Assigned net_device: %X\n", (unsigned) ecd->dev);
|
||||
printk(KERN_DEBUG "Transmit socket buffer: %X\n", (unsigned) ecd->tx_skb);
|
||||
printk(KERN_DEBUG "Receive socket buffer: %X\n", (unsigned) ecd->rx_skb);
|
||||
printk(KERN_DEBUG "Time of last transmission: %u\n", (unsigned) ecd->tx_time);
|
||||
printk(KERN_DEBUG "Time of last receive: %u\n", (unsigned) ecd->rx_time);
|
||||
printk(KERN_DEBUG "Number of transmit interrupts: %u\n", (unsigned) ecd->tx_intr_cnt);
|
||||
printk(KERN_DEBUG "Number of receive interrupts: %u\n", (unsigned) ecd->rx_intr_cnt);
|
||||
printk(KERN_DEBUG "Total Number of interrupts: %u\n", (unsigned) ecd->intr_cnt);
|
||||
printk(KERN_DEBUG "Actual device state: %i\n", (int) ecd->state);
|
||||
printk(KERN_DEBUG "Receive buffer: %X\n", (unsigned) ecd->rx_data);
|
||||
printk(KERN_DEBUG "Receive buffer fill state: %u/%u\n",
|
||||
(unsigned) ecd->rx_data_length, ECAT_FRAME_BUFFER_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "Device is NULL!\n");
|
||||
printk(KERN_DEBUG "Device is NULL!\n");
|
||||
}
|
||||
|
||||
EC_DBG(KERN_DEBUG "---EtherCAT device information end---\n");
|
||||
printk(KERN_DEBUG "---EtherCAT device information end---\n");
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "ec_globals.h"
|
||||
#include "ec_master.h"
|
||||
#include "ec_dbg.h"
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ int EtherCAT_master_init(EtherCAT_master_t *master,
|
|||
{
|
||||
if (!dev)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Master init without device!\n");
|
||||
printk(KERN_ERR "EtherCAT: Master init without device!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -95,12 +94,9 @@ int EtherCAT_simple_send_receive(EtherCAT_master_t *master,
|
|||
{
|
||||
unsigned int tries_left;
|
||||
|
||||
// EC_DBG("ECAT send...\n"); //HM
|
||||
|
||||
if (EtherCAT_simple_send(master, cmd) < 0) return -1;
|
||||
|
||||
// EC_DBG("ECAT call isr \n"); //HM
|
||||
udelay(3); //FIXME nur zum Test HM
|
||||
udelay(3);
|
||||
|
||||
EtherCAT_device_call_isr(master->dev);
|
||||
|
||||
|
|
@ -108,17 +104,12 @@ int EtherCAT_simple_send_receive(EtherCAT_master_t *master,
|
|||
while (master->dev->state == ECAT_DS_SENT && tries_left)
|
||||
{
|
||||
udelay(1);
|
||||
// EC_DBG("ECAT call isr \n"); //HM
|
||||
EtherCAT_device_call_isr(master->dev);
|
||||
tries_left--;
|
||||
}
|
||||
|
||||
// EC_DBG("ECAT recieve \n"); //HM
|
||||
|
||||
if (EtherCAT_simple_receive(master, cmd) < 0) return -1;
|
||||
|
||||
// EC_DBG("ECAT recieve done\n"); //HM
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -140,12 +131,12 @@ int EtherCAT_simple_send(EtherCAT_master_t *master,
|
|||
|
||||
if (master->debug_level > 0)
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "EtherCAT_send_receive_command\n");
|
||||
printk(KERN_DEBUG "EtherCAT_send_receive_command\n");
|
||||
}
|
||||
|
||||
if (cmd->state != ECAT_CS_READY)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT_send_receive_command: Command not in ready state!\n");
|
||||
printk(KERN_WARNING "EtherCAT_send_receive_command: Command not in ready state!\n");
|
||||
}
|
||||
|
||||
length = cmd->data_length + 12;
|
||||
|
|
@ -153,7 +144,7 @@ int EtherCAT_simple_send(EtherCAT_master_t *master,
|
|||
|
||||
if (framelength > ECAT_FRAME_BUFFER_SIZE)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Frame too long (%i)!\n", framelength);
|
||||
printk(KERN_ERR "EtherCAT: Frame too long (%i)!\n", framelength);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +152,7 @@ int EtherCAT_simple_send(EtherCAT_master_t *master,
|
|||
|
||||
if (master->debug_level > 0)
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "Frame length: %i\n", framelength);
|
||||
printk(KERN_DEBUG "Frame length: %i\n", framelength);
|
||||
}
|
||||
|
||||
master->tx_data[0] = length & 0xFF;
|
||||
|
|
@ -172,7 +163,7 @@ int EtherCAT_simple_send(EtherCAT_master_t *master,
|
|||
|
||||
if (master->debug_level > 0)
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "Sending command index %i\n", cmd->index);
|
||||
printk(KERN_DEBUG "Sending command index %i\n", cmd->index);
|
||||
}
|
||||
|
||||
cmd->state = ECAT_CS_SENT;
|
||||
|
|
@ -210,19 +201,19 @@ int EtherCAT_simple_send(EtherCAT_master_t *master,
|
|||
|
||||
if (master->debug_level > 0)
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "device send...\n");
|
||||
printk(KERN_DEBUG "device send...\n");
|
||||
}
|
||||
|
||||
// Send frame
|
||||
if (EtherCAT_device_send(master->dev, master->tx_data, framelength) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not send!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not send!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (master->debug_level > 0)
|
||||
{
|
||||
EC_DBG(KERN_DEBUG "EtherCAT_send done.\n");
|
||||
printk(KERN_DEBUG "EtherCAT_send done.\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -257,7 +248,7 @@ int EtherCAT_simple_receive(EtherCAT_master_t *master,
|
|||
|
||||
if (master->rx_data_length < 2)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Received frame with incomplete EtherCAT header!\n");
|
||||
printk(KERN_ERR "EtherCAT: Received frame with incomplete EtherCAT header!\n");
|
||||
output_debug_data(master);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -267,7 +258,7 @@ int EtherCAT_simple_receive(EtherCAT_master_t *master,
|
|||
|
||||
if (length > master->rx_data_length)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Received corrupted frame (length does not match)!\n");
|
||||
printk(KERN_ERR "EtherCAT: Received corrupted frame (length does not match)!\n");
|
||||
output_debug_data(master);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -278,7 +269,7 @@ int EtherCAT_simple_receive(EtherCAT_master_t *master,
|
|||
|
||||
if (master->rx_data_length - 2 < length + 12)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Received frame with incomplete command data!\n");
|
||||
printk(KERN_ERR "EtherCAT: Received frame with incomplete command data!\n");
|
||||
output_debug_data(master);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -299,7 +290,7 @@ int EtherCAT_simple_receive(EtherCAT_master_t *master,
|
|||
}
|
||||
else
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: WARNING - Send/Receive anomaly!\n");
|
||||
printk(KERN_WARNING "EtherCAT: WARNING - Send/Receive anomaly!\n");
|
||||
output_debug_data(master);
|
||||
}
|
||||
|
||||
|
|
@ -337,14 +328,14 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
// EtherCAT_clear_slaves() must be called before!
|
||||
if (master->slaves || master->slave_count)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT duplicate slave check!");
|
||||
printk(KERN_ERR "EtherCAT duplicate slave check!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// No slaves.
|
||||
if (slave_count == 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: No slaves in list!");
|
||||
printk(KERN_ERR "EtherCAT: No slaves in list!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -356,13 +347,13 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != slave_count)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Wrong number of slaves on bus: %i / %i\n",
|
||||
printk(KERN_ERR "EtherCAT: Wrong number of slaves on bus: %i / %i\n",
|
||||
cmd.working_counter, slave_count);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
EC_DBG("EtherCAT: Found all %i slaves.\n", slave_count);
|
||||
printk("EtherCAT: Found all %i slaves.\n", slave_count);
|
||||
}
|
||||
|
||||
// For every slave in the list
|
||||
|
|
@ -372,7 +363,7 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
|
||||
if (!cur->desc)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Slave %i has no description.\n", i);
|
||||
printk(KERN_ERR "EtherCAT: Slave %i has no description.\n", i);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +381,7 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Slave %i did not repond while writing station address!\n", i);
|
||||
printk(KERN_ERR "EtherCAT: Slave %i did not repond while writing station address!\n", i);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +392,7 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Slave %i did not respond while reading base data!\n", i);
|
||||
printk(KERN_ERR "EtherCAT: Slave %i did not respond while reading base data!\n", i);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -415,28 +406,28 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
if (EtherCAT_read_slave_information(master, cur->station_address,
|
||||
0x0008, &cur->vendor_id) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not read SII vendor id!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not read SII vendor id!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (EtherCAT_read_slave_information(master, cur->station_address,
|
||||
0x000A, &cur->product_code) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not read SII product code!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not read SII product code!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (EtherCAT_read_slave_information(master, cur->station_address,
|
||||
0x000C, &cur->revision_number) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not read SII revision number!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not read SII revision number!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (EtherCAT_read_slave_information(master, cur->station_address,
|
||||
0x000E, &cur->serial_number) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not read SII serial number!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not read SII serial number!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -453,7 +444,7 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
|
||||
if (cur->desc != slave_idents[j].desc)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Unexpected slave device \"%s %s\""
|
||||
printk(KERN_ERR "EtherCAT: Unexpected slave device \"%s %s\""
|
||||
" at position %i. Expected: \"%s %s\"\n",
|
||||
slave_idents[j].desc->vendor_name,
|
||||
slave_idents[j].desc->product_name, i,
|
||||
|
|
@ -467,7 +458,7 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
|
||||
if (!found)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Unknown slave device"
|
||||
printk(KERN_ERR "EtherCAT: Unknown slave device"
|
||||
" (vendor %X, code %X) at position %i.\n",
|
||||
i, cur->vendor_id, cur->product_code);
|
||||
return -1;
|
||||
|
|
@ -483,7 +474,7 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
if ((master->process_data = (unsigned char *)
|
||||
kmalloc(sizeof(unsigned char) * length, GFP_KERNEL)) == NULL)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not allocate %i bytes for process data.\n", length);
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate %i bytes for process data.\n", length);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -496,7 +487,7 @@ int EtherCAT_check_slaves(EtherCAT_master_t *master,
|
|||
slaves[i].process_data = master->process_data + pos;
|
||||
slaves[i].logical_address0 = pos;
|
||||
|
||||
EC_DBG(KERN_DEBUG "EtherCAT: Slave %i - Address 0x%X, \"%s %s\", s/n %u\n",
|
||||
printk(KERN_DEBUG "EtherCAT: Slave %i - Address 0x%X, \"%s %s\", s/n %u\n",
|
||||
i, pos, slaves[i].desc->vendor_name, slaves[i].desc->product_name,
|
||||
slaves[i].serial_number);
|
||||
|
||||
|
|
@ -561,7 +552,7 @@ int EtherCAT_read_slave_information(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: SII-read - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: SII-read - Slave %04X did not respond!\n",
|
||||
node_address);
|
||||
return -4;
|
||||
}
|
||||
|
|
@ -580,7 +571,7 @@ int EtherCAT_read_slave_information(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: SII-read status - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: SII-read status - Slave %04X did not respond!\n",
|
||||
node_address);
|
||||
return -4;
|
||||
}
|
||||
|
|
@ -596,7 +587,7 @@ int EtherCAT_read_slave_information(EtherCAT_master_t *master,
|
|||
|
||||
if (!tries_left)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: SSI-read. Slave %04X timed out!\n",
|
||||
printk(KERN_WARNING "EtherCAT: SSI-read. Slave %04X timed out!\n",
|
||||
node_address);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -634,13 +625,13 @@ int EtherCAT_state_change(EtherCAT_master_t *master,
|
|||
|
||||
if (EtherCAT_simple_send_receive(master, &cmd) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not set state %02X - Unable to send!\n", state_and_ack);
|
||||
printk(KERN_ERR "EtherCAT: Could not set state %02X - Unable to send!\n", state_and_ack);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not set state %02X - Device \"%s %s\" (%d) did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Could not set state %02X - Device \"%s %s\" (%d) did not respond!\n",
|
||||
state_and_ack,
|
||||
slave->desc->vendor_name,
|
||||
slave->desc->product_name,
|
||||
|
|
@ -659,19 +650,19 @@ int EtherCAT_state_change(EtherCAT_master_t *master,
|
|||
|
||||
if (EtherCAT_simple_send_receive(master, &cmd) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not check state %02X - Unable to send!\n", state_and_ack);
|
||||
printk(KERN_ERR "EtherCAT: Could not check state %02X - Unable to send!\n", state_and_ack);
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not check state %02X - Device did not respond!\n", state_and_ack);
|
||||
printk(KERN_ERR "EtherCAT: Could not check state %02X - Device did not respond!\n", state_and_ack);
|
||||
return -3;
|
||||
}
|
||||
|
||||
if (cmd.data[0] & 0x10) // State change error
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not set state %02X - Device refused state change (code %02X)!\n", state_and_ack, cmd.data[0]);
|
||||
printk(KERN_ERR "EtherCAT: Could not set state %02X - Device refused state change (code %02X)!\n", state_and_ack, cmd.data[0]);
|
||||
return -4;
|
||||
}
|
||||
|
||||
|
|
@ -685,7 +676,7 @@ int EtherCAT_state_change(EtherCAT_master_t *master,
|
|||
|
||||
if (!tries_left)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not check state %02X - Timeout while checking!\n", state_and_ack);
|
||||
printk(KERN_ERR "EtherCAT: Could not check state %02X - Timeout while checking!\n", state_and_ack);
|
||||
return -5;
|
||||
}
|
||||
|
||||
|
|
@ -734,7 +725,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Resetting FMMUs - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Resetting FMMUs - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -750,7 +741,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Resetting SMs - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Resetting SMs - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -767,7 +758,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Setting SM0 - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Setting SM0 - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -3;
|
||||
}
|
||||
|
|
@ -780,7 +771,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Setting SM1 - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Setting SM1 - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -810,7 +801,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Setting FMMU0 - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Setting FMMU0 - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -2;
|
||||
}
|
||||
|
|
@ -827,7 +818,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Setting SM0 - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Setting SM0 - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -3;
|
||||
}
|
||||
|
|
@ -840,7 +831,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Setting SM1 - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Setting SM1 - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -3;
|
||||
}
|
||||
|
|
@ -854,7 +845,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Setting SM2 - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Setting SM2 - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -3;
|
||||
}
|
||||
|
|
@ -867,7 +858,7 @@ int EtherCAT_activate_slave(EtherCAT_master_t *master,
|
|||
|
||||
if (cmd.working_counter != 1)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Setting SM3 - Slave %04X did not respond!\n",
|
||||
printk(KERN_ERR "EtherCAT: Setting SM3 - Slave %04X did not respond!\n",
|
||||
slave->station_address);
|
||||
return -3;
|
||||
}
|
||||
|
|
@ -986,7 +977,7 @@ int EtherCAT_write_process_data(EtherCAT_master_t *master)
|
|||
|
||||
if (EtherCAT_simple_send(master, &master->process_data_command) < 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not send process data command!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not send process data command!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1023,19 +1014,19 @@ int EtherCAT_read_process_data(EtherCAT_master_t *master)
|
|||
|
||||
if (!tries_left)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Timeout while receiving process data!\n");
|
||||
printk(KERN_ERR "EtherCAT: Timeout while receiving process data!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (EtherCAT_simple_receive(master, &master->process_data_command) < 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not receive cyclic command!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not receive cyclic command!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (master->process_data_command.state != ECAT_CS_RECEIVED)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Process data command not received!\n");
|
||||
printk(KERN_WARNING "EtherCAT: Process data command not received!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -1072,27 +1063,27 @@ void output_debug_data(const EtherCAT_master_t *master)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
EC_DBG(KERN_DEBUG "EtherCAT: tx_data content (%i Bytes):\n",
|
||||
printk(KERN_DEBUG "EtherCAT: tx_data content (%i Bytes):\n",
|
||||
master->tx_data_length);
|
||||
|
||||
EC_DBG(KERN_DEBUG);
|
||||
printk(KERN_DEBUG);
|
||||
for (i = 0; i < master->tx_data_length; i++)
|
||||
{
|
||||
EC_DBG("%02X ", master->tx_data[i]);
|
||||
if ((i + 1) % 16 == 0) EC_DBG("\n" KERN_DEBUG);
|
||||
printk("%02X ", master->tx_data[i]);
|
||||
if ((i + 1) % 16 == 0) printk("\n" KERN_DEBUG);
|
||||
}
|
||||
EC_DBG("\n");
|
||||
printk("\n");
|
||||
|
||||
EC_DBG(KERN_DEBUG "EtherCAT: rx_data content (%i Bytes):\n",
|
||||
printk(KERN_DEBUG "EtherCAT: rx_data content (%i Bytes):\n",
|
||||
master->rx_data_length);
|
||||
|
||||
EC_DBG(KERN_DEBUG);
|
||||
printk(KERN_DEBUG);
|
||||
for (i = 0; i < master->rx_data_length; i++)
|
||||
{
|
||||
EC_DBG("%02X ", master->rx_data[i]);
|
||||
if ((i + 1) % 16 == 0) EC_DBG("\n" KERN_DEBUG);
|
||||
printk("%02X ", master->rx_data[i]);
|
||||
if ((i + 1) % 16 == 0) printk("\n" KERN_DEBUG);
|
||||
}
|
||||
EC_DBG("\n");
|
||||
printk("\n");
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
#include "ec_globals.h"
|
||||
#include "ec_slave.h"
|
||||
#include "ec_dbg.h"
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
|
|
@ -84,7 +83,7 @@ int EtherCAT_read_value(EtherCAT_slave_t *slave,
|
|||
{
|
||||
if (!slave->desc)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
" - Slave has no description.\n",
|
||||
slave->station_address, (unsigned int) slave);
|
||||
return 0;
|
||||
|
|
@ -92,7 +91,7 @@ int EtherCAT_read_value(EtherCAT_slave_t *slave,
|
|||
|
||||
if (!slave->desc->read)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
" - Slave type (%s %s) has no read method.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name);
|
||||
|
|
@ -101,7 +100,7 @@ int EtherCAT_read_value(EtherCAT_slave_t *slave,
|
|||
|
||||
if (channel >= slave->desc->channels)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Reading failed on slave %4X (addr %0X)"
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %4X (addr %0X)"
|
||||
" - Type (%s %s) has no channel %i.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name,
|
||||
|
|
@ -134,7 +133,7 @@ void EtherCAT_write_value(EtherCAT_slave_t *slave,
|
|||
{
|
||||
if (!slave->desc)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
" - Slave has no description.\n",
|
||||
slave->station_address, (unsigned int) slave);
|
||||
return;
|
||||
|
|
@ -142,7 +141,7 @@ void EtherCAT_write_value(EtherCAT_slave_t *slave,
|
|||
|
||||
if (!slave->desc->write)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
" - Type (%s %s) has no write method.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name);
|
||||
|
|
@ -151,7 +150,7 @@ void EtherCAT_write_value(EtherCAT_slave_t *slave,
|
|||
|
||||
if (channel >= slave->desc->channels)
|
||||
{
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Writing failed on slave %4X (addr %0X)"
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %4X (addr %0X)"
|
||||
" - Type (%s %s) has no channel %i.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name,
|
||||
|
|
|
|||
|
|
@ -9,14 +9,12 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
//#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
#include "../drivers/ec_master.h"
|
||||
#include "../drivers/ec_device.h"
|
||||
#include "../drivers/ec_types.h"
|
||||
#include "../drivers/ec_dbg.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
@ -254,41 +252,41 @@ int __init init_module()
|
|||
#endif
|
||||
#endif
|
||||
|
||||
EC_DBG(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n");
|
||||
printk(KERN_INFO "=== Starting Minimal EtherCAT environment... ===\n");
|
||||
|
||||
#ifdef ECAT
|
||||
|
||||
EtherCAT_device_debug(&rtl_ecat_dev);
|
||||
|
||||
#ifdef ECAT_OPEN
|
||||
EC_DBG("Opening EtherCAT device.\n");
|
||||
printk("Opening EtherCAT device.\n");
|
||||
|
||||
// HIER PASSIERT DER FEHLER:
|
||||
if (EtherCAT_device_open(&rtl_ecat_dev) < 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "msr_modul: Could not initialize EtherCAT NIC.\n");
|
||||
printk(KERN_ERR "msr_modul: Could not initialize EtherCAT NIC.\n");
|
||||
goto out_nothing;
|
||||
}
|
||||
|
||||
if (!rtl_ecat_dev.dev) // Es gibt kein EtherCAT-Device
|
||||
{
|
||||
EC_DBG(KERN_ERR "msr_modul: No EtherCAT device!\n");
|
||||
printk(KERN_ERR "msr_modul: No EtherCAT device!\n");
|
||||
goto out_close;
|
||||
}
|
||||
#endif // ECAT_OPEN
|
||||
|
||||
#ifdef ECAT_MASTER
|
||||
EC_DBG("Initialising EtherCAT master\n");
|
||||
printk("Initialising EtherCAT master\n");
|
||||
|
||||
if ((ecat_master = (EtherCAT_master_t *) kmalloc(sizeof(EtherCAT_master_t), GFP_KERNEL)) == 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "msr_modul: Could not alloc memory for EtherCAT master!\n");
|
||||
printk(KERN_ERR "msr_modul: Could not alloc memory for EtherCAT master!\n");
|
||||
goto out_close;
|
||||
}
|
||||
|
||||
if (EtherCAT_master_init(ecat_master, &rtl_ecat_dev) < 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT could not init master!\n");
|
||||
printk(KERN_ERR "EtherCAT could not init master!\n");
|
||||
goto out_master;
|
||||
}
|
||||
|
||||
|
|
@ -297,19 +295,19 @@ int __init init_module()
|
|||
#endif // ECAT_MASTER
|
||||
|
||||
#ifdef ECAT_SLAVES
|
||||
EC_DBG("Checking EtherCAT slaves.\n");
|
||||
printk("Checking EtherCAT slaves.\n");
|
||||
|
||||
if (EtherCAT_check_slaves(ecat_master, ecat_slaves, ECAT_SLAVES_COUNT) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not init slaves!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not init slaves!\n");
|
||||
goto out_masterclear;
|
||||
}
|
||||
|
||||
EC_DBG("Activating all EtherCAT slaves.\n");
|
||||
printk("Activating all EtherCAT slaves.\n");
|
||||
|
||||
if (EtherCAT_activate_all_slaves(ecat_master) != 0)
|
||||
{
|
||||
EC_DBG(KERN_ERR "EtherCAT: Could not activate slaves!\n");
|
||||
printk(KERN_ERR "EtherCAT: Could not activate slaves!\n");
|
||||
goto out_masterclear;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -317,7 +315,7 @@ int __init init_module()
|
|||
#endif // ECAT
|
||||
|
||||
#ifdef ECAT_CYCLIC_DATA
|
||||
EC_DBG("Starting cyclic sample thread.\n");
|
||||
printk("Starting cyclic sample thread.\n");
|
||||
|
||||
schedule();
|
||||
mdelay(1000);
|
||||
|
|
@ -330,10 +328,10 @@ int __init init_module()
|
|||
last_start_jiffies = timer.expires;
|
||||
add_timer(&timer);
|
||||
|
||||
EC_DBG("Initialised sample thread.\n");
|
||||
printk("Initialised sample thread.\n");
|
||||
#endif
|
||||
|
||||
EC_DBG(KERN_INFO "=== Minimal EtherCAT environment started. ===\n");
|
||||
printk(KERN_INFO "=== Minimal EtherCAT environment started. ===\n");
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
@ -341,19 +339,19 @@ int __init init_module()
|
|||
|
||||
#ifdef ECAT_SLAVES
|
||||
out_masterclear:
|
||||
EC_DBG(KERN_INFO "Clearing EtherCAT master.\n");
|
||||
printk(KERN_INFO "Clearing EtherCAT master.\n");
|
||||
EtherCAT_master_clear(ecat_master);
|
||||
#endif
|
||||
|
||||
#ifdef ECAT_MASTER
|
||||
out_master:
|
||||
EC_DBG(KERN_INFO "Freeing EtherCAT master.\n");
|
||||
printk(KERN_INFO "Freeing EtherCAT master.\n");
|
||||
kfree(ecat_master);
|
||||
#endif
|
||||
|
||||
#ifdef ECAT_OPEN
|
||||
out_close:
|
||||
EC_DBG(KERN_INFO "Closing device.\n");
|
||||
printk(KERN_INFO "Closing device.\n");
|
||||
EtherCAT_device_close(&rtl_ecat_dev);
|
||||
|
||||
out_nothing:
|
||||
|
|
@ -371,7 +369,7 @@ int __init init_module()
|
|||
|
||||
void __exit cleanup_module()
|
||||
{
|
||||
EC_DBG(KERN_INFO "=== Stopping Minimal EtherCAT environment... ===\n");
|
||||
printk(KERN_INFO "=== Stopping Minimal EtherCAT environment... ===\n");
|
||||
|
||||
#ifdef ECAT_MASTER
|
||||
|
||||
|
|
@ -394,14 +392,14 @@ void __exit cleanup_module()
|
|||
#ifdef ECAT
|
||||
|
||||
#ifdef ECAT_SLAVES
|
||||
EC_DBG(KERN_INFO "Deactivating slaves.\n");
|
||||
printk(KERN_INFO "Deactivating slaves.\n");
|
||||
EtherCAT_deactivate_all_slaves(ecat_master);
|
||||
#endif
|
||||
|
||||
EC_DBG(KERN_INFO "Clearing EtherCAT master.\n");
|
||||
printk(KERN_INFO "Clearing EtherCAT master.\n");
|
||||
EtherCAT_master_clear(ecat_master);
|
||||
|
||||
EC_DBG(KERN_INFO "Freeing EtherCAT master.\n");
|
||||
printk(KERN_INFO "Freeing EtherCAT master.\n");
|
||||
kfree(ecat_master);
|
||||
ecat_master = NULL;
|
||||
}
|
||||
|
|
@ -411,12 +409,12 @@ void __exit cleanup_module()
|
|||
|
||||
#ifdef ECAT
|
||||
#ifdef ECAT_OPEN
|
||||
EC_DBG(KERN_INFO "Closing device.\n");
|
||||
printk(KERN_INFO "Closing device.\n");
|
||||
EtherCAT_device_close(&rtl_ecat_dev);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
EC_DBG(KERN_INFO "=== Minimal EtherCAT environment stopped. ===\n");
|
||||
printk(KERN_INFO "=== Minimal EtherCAT environment stopped. ===\n");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,57 +0,0 @@
|
|||
#----------------------------------------------------------------
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
# Kernel-Debugging über die serielle Schnittstelle
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
#----------------------------------------------------------------
|
||||
|
||||
CONFIG_FILE = ../kerneldirs.mk
|
||||
|
||||
ifeq ($(CONFIG_FILE),$(wildcard $(CONFIG_FILE)))
|
||||
include $(CONFIG_FILE)
|
||||
else
|
||||
KERNELDIR = /vol/projekte/msr_messen_steuern_regeln/linux/kernel/2.4.20/include/linux-2.4.20.CX1100-rthal5
|
||||
RTAIDIR = /vol/projekte/msr_messen_steuern_regeln/linux/kernel/2.4.20/include/rtai-24.1.13
|
||||
RTLIBDIR = rt_lib
|
||||
endif
|
||||
|
||||
CFLAGS = -O2 -Wall -Wuninitialized -D__KERNEL__ -DMODULE \
|
||||
-I$(KERNELDIR)/include -D_RTAI -I$(RTAIDIR)/include -I$(RTLIBDIR)/msr-include
|
||||
|
||||
MODULE = sdbg.o
|
||||
SRC = rs232dbg.c aip_com.c
|
||||
OBJ = $(SRC:.c=.o)
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
all: .output_dirs .depend $(MODULE) Makefile
|
||||
|
||||
$(MODULE): $(OBJ)
|
||||
$(LD) -r $(OBJ) -o $@
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
.output_dirs:
|
||||
@echo "x-- Directories -------------"
|
||||
@echo "| Kernel $(KERNELDIR)"
|
||||
@echo "| RTAI $(RTAIDIR)"
|
||||
@echo "| RT_lib $(RTLIBDIR)"
|
||||
@echo "x----------------------------"
|
||||
|
||||
depend .depend dep:
|
||||
$(CC) $(CFLAGS) -M $(SRC) > .depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ core .depend
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
ifeq (.depend,$(wildcard .depend))
|
||||
include .depend
|
||||
endif
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
|
@ -1,847 +0,0 @@
|
|||
/** rt_com
|
||||
* ======
|
||||
*
|
||||
* RT-Linux kernel module for communication across serial lines.
|
||||
*
|
||||
* Copyright (C) 1997 Jens Michaelsen
|
||||
* Copyright (C) 1997-2000 Jochen Kupper
|
||||
* Copyright (C) 1999 Hua Mao <hmao@nmt.edu>
|
||||
* Copyright (C) 1999 Roberto Finazzi
|
||||
* Copyright (C) 2000-2002 Giuseppe Renoldi
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file License. if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*
|
||||
* $Id: aip_com.c,v 1.1 2005/09/16 14:16:31 hm Exp hm $ */
|
||||
#define VERSION "0.6.pre2-rtaicvs (modified by Hm, IgH for aip)" //Hm, IgH
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <asm/system.h>
|
||||
#include <asm/io.h>
|
||||
|
||||
#ifdef _RTAI
|
||||
#include <rtai.h>
|
||||
#endif
|
||||
|
||||
#include "aip_com.h"
|
||||
#include "aip_comP.h"
|
||||
|
||||
/* Hm, IgH
|
||||
MODULE_AUTHOR("Jochen Kuepper");
|
||||
MODULE_DESCRIPTION("real-time serial port driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
*/
|
||||
|
||||
|
||||
/* size of internal queues
|
||||
* This is the default value. */
|
||||
unsigned int rt_com_buffersize = RT_COM_BUF_SIZ;
|
||||
|
||||
/** Default: mode=0 - no hw flow control
|
||||
* used=0 - port and irq setting by rt_com_hwparam.
|
||||
* If you want to work like
|
||||
* a standard rt_com you can set used=1. */
|
||||
struct rt_com_struct rt_com_table[] = {
|
||||
{ // ttyS0 - COM1
|
||||
RT_COM_BASE_BAUD, // int baud_base;
|
||||
0x3f8, // int port;
|
||||
4, // int irq;
|
||||
rt_com0_isr, // void (*isr)(void);
|
||||
115200, // int baud;
|
||||
8, // unsigned int wordlength;
|
||||
RT_COM_PARITY_NONE, // unsigned int parity;
|
||||
1, // stopbits;
|
||||
RT_COM_NO_HAND_SHAKE, // int mode;
|
||||
RT_COM_FIFO_SIZE_8, // int fifotrig;
|
||||
1 //Hm, IgH // int used;
|
||||
}, { // ttyS1 - COM2
|
||||
RT_COM_BASE_BAUD, // int baud_base;
|
||||
0x2f8, // int port;
|
||||
3, // int irq;
|
||||
rt_com1_isr, // void (*isr)(void);
|
||||
0, // int baud;
|
||||
8, // unsigned int wordlength;
|
||||
RT_COM_PARITY_NONE, // unsigned int parity;
|
||||
1, // stopbits;
|
||||
RT_COM_NO_HAND_SHAKE, // int mode;
|
||||
RT_COM_FIFO_SIZE_8, // int fifotrig;
|
||||
0 // int used;
|
||||
}
|
||||
};
|
||||
|
||||
/** Number and descriptions of serial ports to manage. You also need
|
||||
* to create an ISR ( rt_comN_isr() ) for each port. */
|
||||
#define RT_COM_CNT (sizeof(rt_com_table) / sizeof(struct rt_com_struct))
|
||||
|
||||
/** Internal: Remaining free space of buffer
|
||||
*
|
||||
* @return amount of free space remaining in a buffer (input or output)
|
||||
*
|
||||
* @author Jochen Kupper
|
||||
* @version 2000/03/10 */
|
||||
static inline unsigned int rt_com_buffer_free(unsigned int head, unsigned int tail)
|
||||
{
|
||||
return(head < tail) ? (tail - head) : (rt_com_buffersize - (head - tail));
|
||||
}
|
||||
|
||||
/** Clear input buffer.
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @return 0 if all right, -ENODEV or -EPERM on error.
|
||||
*
|
||||
* @author Roberto Finazzi, Jochen Kupper
|
||||
* @version 2000/03/12 */
|
||||
int rt_com_clear_input(unsigned int ttyS)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else if (0 >= (rt_com_table[ttyS]).used) {
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
struct rt_buf_struct *b = &(p->ibuf);
|
||||
long state;
|
||||
rt_com_irq_off(state);
|
||||
b->tail = b->head;
|
||||
if (p->fifotrig)
|
||||
outb(inb(p->port + RT_COM_FCR) | FCR_INPUT_FIFO_RESET, p->port + RT_COM_FCR);
|
||||
rt_com_irq_on(state);
|
||||
if (p->mode & RT_COM_HW_FLOW) {
|
||||
/* with hardware flow set RTS */
|
||||
p->mcr |= MCR_RTS;
|
||||
outb(p->mcr, p->port + RT_COM_MCR);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Clear output buffer.
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @return 0 if all right, negative error conditions otherwise
|
||||
*
|
||||
* @author Roberto Finazzi, Jochen Kupper
|
||||
* @version 2000/03/12
|
||||
*/
|
||||
int rt_com_clear_output(unsigned int ttyS)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (0 >= (rt_com_table[ttyS]).used) {
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
struct rt_buf_struct *b = &(p->obuf);
|
||||
long state;
|
||||
rt_com_irq_off(state);
|
||||
p->ier &= ~IER_ETBEI;
|
||||
outb(p->ier, p->port | RT_COM_IER);
|
||||
b->tail = b->head;
|
||||
if (p->fifotrig)
|
||||
outb(inb(p->port + RT_COM_FCR) | FCR_OUTPUT_FIFO_RESET, p->port + RT_COM_FCR);
|
||||
rt_com_irq_on(state);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Set functioning mode.
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @param mode functioning mode
|
||||
* @return 0 if all right, negative on error
|
||||
*
|
||||
* @author Roberto Finazzi, Jochen Kupper
|
||||
* @version 2000/03/12
|
||||
*/
|
||||
int rt_com_set_mode(unsigned int ttyS, int mode)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (0 >= p->used) {
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
p->mode = mode;
|
||||
if (p->used & RT_COM_PORT_SETUP) {
|
||||
/* setup done */
|
||||
if (mode == RT_COM_NO_HAND_SHAKE) {
|
||||
/* if no hw signals disable modem interrupts */
|
||||
p->ier &= ~IER_EDSSI;
|
||||
}
|
||||
else {
|
||||
/* else enable it */
|
||||
p->ier |= IER_EDSSI;
|
||||
}
|
||||
|
||||
outb(p->ier, p->port + RT_COM_IER);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Set receiver fifo trigger level.
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @param fifotrig receiver fifo trigger level
|
||||
* @return 0 if all right, negative on error
|
||||
*
|
||||
* @author Roberto Finazzi, Jochen Kupper
|
||||
* @version 2000/03/12
|
||||
*/
|
||||
int rt_com_set_fifotrig(unsigned int ttyS, int fifotrig)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
p->fifotrig = fifotrig;
|
||||
if (p->used & RT_COM_PORT_SETUP) {
|
||||
/* setup done */
|
||||
if (p->fifotrig)
|
||||
outb(FCR_FIFO_ENABLE | p->fifotrig, p->port + RT_COM_FCR); // enable fifo
|
||||
else
|
||||
outb(0, p->port + RT_COM_FCR); // disable fifo
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/** Set output signal for modem control (DTR, RTS).
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @param signal Output signals: RT_COM_DTR or RT_COM_RTS.
|
||||
* @param value Status: 0 or 1.
|
||||
* @return 0 if all right, negative error code otherwise
|
||||
*
|
||||
* @author Roberto Finazzi, Jochen Kupper
|
||||
* @version 2000/03/12 */
|
||||
int rt_com_write_modem(unsigned int ttyS, int signal, int value)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else if (value &~0x01) {
|
||||
return(-EINVAL);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (0 >= p->used) {
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
if (value)
|
||||
p->mcr |= signal;
|
||||
else
|
||||
p->mcr &= ~signal;
|
||||
outb(p->mcr, p->port + RT_COM_MCR);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Read input signal from modem (CTS, DSR, RI, DCD).
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @param signal Input signals: RT_COM_CTS, RT_COM_DSR, RT_COM_RI, RT_COM_DCD
|
||||
* or any combination.
|
||||
* @return input signal status; that is the bitwise-OR of the signal
|
||||
* argument and the MSR register.
|
||||
*
|
||||
* @author Roberto Finazzi, Jochen Kupper
|
||||
* @version 2000/03/12 */
|
||||
int rt_com_read_modem(unsigned int ttyS, int signal)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else if (signal & 0xf) {
|
||||
return(-EINVAL);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (0 >= p->used) {
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
return(inb(p->port + RT_COM_MSR) & signal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Return last error detected.
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @return bit 0 :1 = Input buffer overflow
|
||||
* bit 1 :1 = Receive data overrun
|
||||
* bit 2 :1 = Parity error
|
||||
* bit 3 :1 = Framing error
|
||||
* bit 4 :1 = Break detected
|
||||
*
|
||||
* @author Roberto Finazzi
|
||||
* @version 2000/03/12
|
||||
*/
|
||||
int rt_com_error(unsigned int ttyS)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
int tmp = p->error;
|
||||
p->error = 0;
|
||||
return(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/** Write data to a line.
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @param buffer Address of data.
|
||||
* @param count Number of bytes to write. If negative, send byte only if
|
||||
* possible to send them all together.
|
||||
* @return Number of bytes not written. Negative values are error
|
||||
* conditions.
|
||||
*
|
||||
* @author Jens Michaelsen, Jochen Kupper, Giuseppe Renoldi
|
||||
* @version 2000/03/12 */
|
||||
int rt_com_write(unsigned int ttyS, char *buffer, int count)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (!(p->used & RT_COM_PORT_SETUP)) {
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
struct rt_buf_struct *b = &(p->obuf);
|
||||
long state;
|
||||
int bytestosend;
|
||||
if (count == 0)
|
||||
return(0);
|
||||
bytestosend = rt_com_buffer_free(b->head, b->tail);
|
||||
if (count < 0) {
|
||||
count = -count;
|
||||
if (count > bytestosend)
|
||||
return(count);
|
||||
bytestosend = count;
|
||||
}
|
||||
else {
|
||||
if (count <= bytestosend)
|
||||
bytestosend = count;
|
||||
}
|
||||
|
||||
rt_com_irq_off(state);
|
||||
while (bytestosend-- > 0) {
|
||||
/* put byte into buffer, move pointers to next elements */
|
||||
b->buf[b->head++] = *buffer++;
|
||||
if (b->head >= rt_com_buffersize)
|
||||
b->head = 0;
|
||||
--count;
|
||||
}
|
||||
|
||||
p->ier |= IER_ETBEI;
|
||||
outb(p->ier, p->port + RT_COM_IER);
|
||||
rt_com_irq_on(state);
|
||||
return(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Read data we got from a line.
|
||||
*
|
||||
* @param ttyS Port to use corresponding to internal numbering scheme.
|
||||
* @param buffer Address of data buffer. Needs to be of size > cnt !
|
||||
* @param count Number of bytes to read.
|
||||
* @return Number of bytes actually read.
|
||||
*
|
||||
* @author Jens Michaelsen, Jochen Kupper
|
||||
* @version 2000/03/17 */
|
||||
int rt_com_read(unsigned int ttyS, char *buffer, int count)
|
||||
{
|
||||
if (0 > count) {
|
||||
return(-EINVAL);
|
||||
}
|
||||
else if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (!(p->used & RT_COM_PORT_SETUP)) {
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
struct rt_buf_struct *b = &(p->ibuf);
|
||||
int done = 0;
|
||||
long state;
|
||||
rt_com_irq_off(state);
|
||||
while ((b->head != b->tail) && (--count >= 0)) {
|
||||
done++;
|
||||
*buffer++ = b->buf[b->tail++];
|
||||
b->tail &= (RT_COM_BUF_SIZ - 1);
|
||||
}
|
||||
|
||||
rt_com_irq_on(state);
|
||||
if ((p->mode & RT_COM_HW_FLOW) && (rt_com_buffer_free(b->head, b->tail) > RT_COM_BUF_HI)) {
|
||||
/* if hardware flow and enough free space on input buffer
|
||||
then set RTS */
|
||||
p->mcr |= MCR_RTS;
|
||||
outb(p->mcr, p->port + RT_COM_MCR);
|
||||
}
|
||||
|
||||
return(done);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Get first byte from the write buffer.
|
||||
*
|
||||
* @param p rt_com_struct of the line we are writing to.
|
||||
* @param c Address to put the char in.
|
||||
* @return Number of characters we actually got.
|
||||
*
|
||||
* @author Jens Michaelsen, Jochen Kupper
|
||||
* @version 1999/10/01
|
||||
*/
|
||||
static inline int rt_com_irq_get(struct rt_com_struct *p, unsigned char *c)
|
||||
{
|
||||
struct rt_buf_struct *b = &(p->obuf);
|
||||
if (b->head != b->tail) {
|
||||
*c = b->buf[b->tail++];
|
||||
b->tail &= (RT_COM_BUF_SIZ - 1);
|
||||
return(1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/** Concatenate a byte to the read buffer.
|
||||
*
|
||||
* @param p rt_com_struct of the line we are writing to.
|
||||
* @param ch Byte to put into buffer.
|
||||
*
|
||||
* @author Jens Michaelsen, Jochen Kupper
|
||||
* @version 1999/07/20 */
|
||||
static inline void rt_com_irq_put(struct rt_com_struct *p, unsigned char ch)
|
||||
{
|
||||
struct rt_buf_struct *b = &(p->ibuf);
|
||||
b->buf[b->head++] = ch;
|
||||
b->head &= (RT_COM_BUF_SIZ - 1);
|
||||
}
|
||||
|
||||
/** Real interrupt handler.
|
||||
*
|
||||
* This one is called by the registered ISRs and does the actual work.
|
||||
*
|
||||
* @param ttyS Port to use corresponding to internal numbering scheme.
|
||||
*
|
||||
* @author Jens Michaelsen, Jochen Kupper, Hua Mao, Roberto Finazzi
|
||||
* @version 2000/03/17 */
|
||||
static inline int rt_com_isr(unsigned int ttyS)
|
||||
{
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
struct rt_buf_struct *b = &(p->ibuf);
|
||||
unsigned int base = p->port;
|
||||
int buff, data_to_tx;
|
||||
int loop = 4;
|
||||
int toFifo = 16;
|
||||
unsigned char data, msr, lsr, iir;
|
||||
|
||||
do {
|
||||
//iir=inb(base + RT_COM_IIR);
|
||||
//rt_printk("iir=0x%02x\n",iir);
|
||||
/* get available data from port */
|
||||
lsr = inb(base + RT_COM_LSR);
|
||||
if (0x1e & lsr)
|
||||
p->error = lsr & 0x1e;
|
||||
while (LSR_DATA_READY & lsr) {
|
||||
data = inb(base + RT_COM_RXB);
|
||||
|
||||
//rt_printk("[%02x<- ",data);
|
||||
rt_com_irq_put(p, data);
|
||||
lsr = inb(base + RT_COM_LSR);
|
||||
if (0x1e & lsr)
|
||||
p->error = 0x1e & lsr;
|
||||
}
|
||||
|
||||
/* controls on buffer full and RTS clear on hardware flow
|
||||
control */
|
||||
buff = rt_com_buffer_free(b->head, b->tail);
|
||||
if (buff < RT_COM_BUF_FULL)
|
||||
p->error = RT_COM_BUFFER_FULL;
|
||||
|
||||
if ((p->mode & RT_COM_HW_FLOW) && (buff < RT_COM_BUF_LOW)) {
|
||||
p->mcr &= ~MCR_RTS;
|
||||
outb(p->mcr, p->port + RT_COM_MCR);
|
||||
}
|
||||
|
||||
/* if possible, put data to port */
|
||||
msr = inb(base + RT_COM_MSR);
|
||||
if
|
||||
(
|
||||
(p->mode == RT_COM_NO_HAND_SHAKE) ||
|
||||
((p->mode & RT_COM_DSR_ON_TX) && (MSR_DSR & msr) && (p->mode & RT_COM_HW_FLOW) && (MSR_CTS & msr))
|
||||
) {
|
||||
/* (DSR && (CTS || Mode==no hw flow)) or Mode==no handshake */
|
||||
// if (THRE==1) i.e. transmitter empty
|
||||
if ((lsr = inb(base + RT_COM_LSR)) & LSR_THRE) {
|
||||
// if there are data to transmit
|
||||
if ((data_to_tx = rt_com_irq_get(p, &data)) != 0) {
|
||||
do {
|
||||
//rt_printk("->%02x] ",data);
|
||||
outb(data, base + RT_COM_TXB);
|
||||
} while ((--toFifo > 0) && (data_to_tx = rt_com_irq_get(p, &data) != 0));
|
||||
}
|
||||
|
||||
if (!data_to_tx) {
|
||||
/* no data in output buffer, disable Transmitter
|
||||
Holding Register Empty Interrupt */
|
||||
p->ier &= ~IER_ETBEI;
|
||||
outb(p->ier, base + RT_COM_IER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check the low nibble of IIR wheather there is another pending
|
||||
interrupt. bit 0 = 0 if interrupt pending, bits 1,2,3
|
||||
are the interrupt ID */
|
||||
iir = inb(base + RT_COM_IIR);
|
||||
} while (((iir & 0x0F) != 1) && (--loop > 0));
|
||||
|
||||
#if defined RTLINUX_V2
|
||||
rtl_hard_enable_irq(p->irq);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Interrupt Service Routines
|
||||
*
|
||||
* These are the Interrupt Service Routines to be registered with the
|
||||
* OS. They simply call the genereric interrupt handler for the
|
||||
* current port to do the work.
|
||||
*
|
||||
* @author Jens Michaelsen, Jochen Kupper, Hua Mao
|
||||
* @version 1999/11/11 */
|
||||
static void rt_com0_isr(void)
|
||||
{
|
||||
//rt_printk("rt_com0_isr\n");
|
||||
rt_com_isr(0);
|
||||
}
|
||||
|
||||
static void rt_com1_isr(void)
|
||||
{
|
||||
//rt_printk("rt_com1_isr\n");
|
||||
rt_com_isr(1);
|
||||
}
|
||||
|
||||
/** Setup one port
|
||||
*
|
||||
* Calls from init_module + cleanup_module have baud == 0; in these
|
||||
* cases we only do some cleanup.
|
||||
*
|
||||
* To allocate a port, give usefull setup parameter, to deallocate
|
||||
* give negative baud.
|
||||
*
|
||||
* @param ttyS Number corresponding to internal port numbering scheme.
|
||||
* This is esp. the index of the rt_com_table to use.
|
||||
* @param baud Data transmission rate to use [Byte/s]. If negative,
|
||||
* deallocate port instead. Called with baud == 0 from
|
||||
* init_module for basic initialization. Needs to be called
|
||||
* by user-task again before use !
|
||||
* @param mode see rt_com_set_mode docs for now
|
||||
* @param parity Parity for transmission protocol.
|
||||
* (RT_COM_PARITY_EVEN, RT_COM_PARITY_ODD, RT_COM_PARITY_NONE)
|
||||
* @param stopbits Number of stopbits to use. 1 gives you one stopbit, 2
|
||||
* actually gives really two stopbits for wordlengths of
|
||||
* 6 - 8 bit, but 1.5 stopbits for a wordlength of 5 bits.
|
||||
* @param wordlength Number of bits per word (5 - 8 bits).
|
||||
* @param fifotrig if <0 set trigger fifo using default value set
|
||||
* in rt_com_table[], otherwise set trigger fifo accordingly
|
||||
* to the parameter
|
||||
* @return 0 - all right
|
||||
* -ENODEV - no entry for that ttyS in rt_com_table
|
||||
* -EPERM - get hardware resources first (the port needs to
|
||||
* be setup hardware-wise first, that means you have
|
||||
* to specify a positive used flag at compile time
|
||||
* or call rt_com_set_hwparm first.)
|
||||
*
|
||||
* @author Jens Michaelsen, Jochen Kupper, Roberto Finazzi
|
||||
* @version 2000/03/12 */
|
||||
int rt_com_setup
|
||||
(
|
||||
unsigned int ttyS,
|
||||
int baud,
|
||||
int mode,
|
||||
unsigned int parity,
|
||||
unsigned int stopbits,
|
||||
unsigned int wordlength,
|
||||
int fifotrig
|
||||
)
|
||||
{
|
||||
if (ttyS >= RT_COM_CNT) {
|
||||
return(-ENODEV);
|
||||
}
|
||||
else {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (0 == p->used) {
|
||||
/* */
|
||||
return(-EPERM);
|
||||
}
|
||||
else {
|
||||
unsigned int base = p->port;
|
||||
|
||||
/* Stop everything, set DLAB */
|
||||
outb(0x00, base + RT_COM_IER);
|
||||
outb(0x80, base + RT_COM_LCR);
|
||||
|
||||
/* clear irqs */
|
||||
inb(base + RT_COM_IIR);
|
||||
inb(base + RT_COM_LSR);
|
||||
inb(base + RT_COM_RXB);
|
||||
inb(base + RT_COM_MSR);
|
||||
|
||||
/* initialize error code */
|
||||
p->error = 0;
|
||||
|
||||
/* if 0 == baud, nothing else to do ! */
|
||||
if (baud == 0)
|
||||
return(0);
|
||||
|
||||
if (0 > baud) {
|
||||
/* free the port */
|
||||
/* disable interrupts */
|
||||
outb(0, base + RT_COM_IER);
|
||||
//MOD_DEC_USE_COUNT; Hm, IgH
|
||||
return(0);
|
||||
}
|
||||
else {
|
||||
/* allocate and set-up the port */
|
||||
unsigned int divider = p->baud_base / baud;
|
||||
|
||||
//MOD_INC_USE_COUNT; Hm, IgH
|
||||
|
||||
/* set transfer rate */
|
||||
outb(divider % 256, base + RT_COM_DLL);
|
||||
outb(divider / 256, base + RT_COM_DLM);
|
||||
|
||||
/* bits 3,4 + 5 determine parity, mask away anything else */
|
||||
parity &= 0x38;
|
||||
|
||||
/* set transmission parameters and clear DLAB */
|
||||
outb((wordlength - 5) | ((stopbits - 1) << 2) | parity, base + RT_COM_LCR);
|
||||
|
||||
/* set-up MCR value and write it */
|
||||
p->mcr = MCR_DTR | MCR_RTS | MCR_OUT1 | MCR_OUT2;
|
||||
outb(p->mcr, base + RT_COM_MCR);
|
||||
|
||||
/* set-up IER value and write it */
|
||||
p->mode = mode;
|
||||
if (p->mode == RT_COM_NO_HAND_SHAKE) {
|
||||
/* if no handshaking signals enable only receiver interrupts */
|
||||
p->ier = IER_ERBI | IER_ELSI;
|
||||
}
|
||||
else {
|
||||
/* enable receiver and modem interrupts */
|
||||
p->ier = IER_ERBI | IER_ELSI | IER_EDSSI;
|
||||
}
|
||||
|
||||
outb(p->ier, base + RT_COM_IER);
|
||||
if (fifotrig>=0)
|
||||
p->fifotrig = fifotrig;
|
||||
outb(FCR_FIFO_ENABLE | p->fifotrig, base + RT_COM_FCR); // enable fifo
|
||||
/* mark setup done */
|
||||
p->used |= RT_COM_PORT_SETUP;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/** Set hardware parameter for a specific port.
|
||||
*
|
||||
* Change port address and irq setting for a specified port. The port
|
||||
* must have an entry in rt_com_table beforehand.
|
||||
*
|
||||
* To allow the specification of additional ports we would need to
|
||||
* dynamically allocate memory, that's not really feasible within a
|
||||
* real-time context, although we could preallocate a few entries in
|
||||
* init_module. However, it doesn't make too much sense, as you can
|
||||
* specify all ports that really exist (in hardware) at compile time
|
||||
* and enable only these you want to use.
|
||||
*
|
||||
* @param ttyS Port to use; corresponding to internal numbering scheme.
|
||||
* @param port port address, if zero, use standard value from rt_com_table
|
||||
* @param irq irq address, if zero, use standard value from rt_com_table
|
||||
* @return 0 everything all right,
|
||||
* -ENODEV no entry in rt_com_table for that device,
|
||||
* -EBUSY port-region is used already.
|
||||
*
|
||||
* @author Roberto Finazzi, Jochen Kupper
|
||||
* @version 2000/03/10 */
|
||||
int rt_com_hwsetup(unsigned int ttyS, int port, int irq)
|
||||
{
|
||||
if (ttyS < RT_COM_CNT) {
|
||||
struct rt_com_struct *p = &(rt_com_table[ttyS]);
|
||||
if (0 == p->used) {
|
||||
if (0 != port)
|
||||
p->port = port;
|
||||
if (0 != irq)
|
||||
p->irq = irq;
|
||||
if (-EBUSY == check_region(p->port, 8)) {
|
||||
return(-EBUSY);
|
||||
}
|
||||
|
||||
request_region(p->port, 8, RT_COM_NAME);
|
||||
rt_com_request_irq(p->irq, p->isr);
|
||||
p->used = 1;
|
||||
rt_com_setup(ttyS, p->baud, p->mode, p->parity, p->stopbits, p->wordlength, p->fifotrig);
|
||||
return(0);
|
||||
}
|
||||
else {
|
||||
if (port >= 0)
|
||||
return(-EBUSY);
|
||||
rt_com_setup(ttyS, 0, 0, 0, 0, 0, 0);
|
||||
rt_com_free_irq(p->irq);
|
||||
release_region(p->port, 8);
|
||||
p->used = 0;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
return(-ENODEV);
|
||||
}
|
||||
|
||||
/** Initialization
|
||||
*
|
||||
* For all ports that have a used flag greater than 0, request port
|
||||
* memory and register ISRs. If we cannot get the memory of all these
|
||||
* ports, release all already requested ports and return an error.
|
||||
*
|
||||
* @return Success status, zero on success. With a non-zero return
|
||||
* value of this routine, insmod will fail to load the module !
|
||||
*
|
||||
* @author Jochen Kupper, Hua Mao, Roberto Finazzi
|
||||
* @version 2000/03/10 */
|
||||
//int init_module(void) //Hm, IgH
|
||||
int init_aip_com(void)
|
||||
{
|
||||
int errorcode = 0;
|
||||
unsigned int i, j;
|
||||
|
||||
printk(KERN_INFO "rt_com: Loading real-time serial port driver (version "VERSION ").\n");
|
||||
|
||||
for (i = 0; i < RT_COM_CNT; i++) {
|
||||
struct rt_com_struct *p = &(rt_com_table[i]);
|
||||
|
||||
// if used set default values
|
||||
if (p->used > 0) {
|
||||
printk(KERN_WARNING "RS232 testing %d\n",i);
|
||||
if (-EBUSY == check_region(p->port, 8)) {
|
||||
errorcode = -EBUSY;
|
||||
printk(KERN_WARNING "rt_com: error %d: cannot request port region %x\n", errorcode, p->port);
|
||||
break;
|
||||
}
|
||||
|
||||
request_region(p->port, 8, "rt_com");
|
||||
rt_com_request_irq(p->irq, p->isr);
|
||||
printk(KERN_WARNING "RS232 Request IRQ: %d\n",p->irq);
|
||||
rt_com_setup(i, p->baud, p->mode, p->parity, p->stopbits, p->wordlength, p->fifotrig);
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != errorcode) {
|
||||
printk(KERN_WARNING "rt_com: giving up.\n");
|
||||
for (j = 0; j < i; j++) {
|
||||
struct rt_com_struct *p = &(rt_com_table[j]);
|
||||
if (0 < p->used) {
|
||||
rt_com_free_irq(p->irq);
|
||||
release_region(p->port, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
printk(KERN_INFO "rt_com: sucessfully loaded.\n");
|
||||
}
|
||||
|
||||
return(errorcode);
|
||||
}
|
||||
|
||||
/** Cleanup
|
||||
*
|
||||
* Unregister ISR and releases memory for all ports
|
||||
*
|
||||
* @author Jochen Kupper
|
||||
* @version 1999/10/01 */
|
||||
//void cleanup_module(void) Hm, IgH
|
||||
void cleanup_aip_com(void)
|
||||
{
|
||||
unsigned int i;
|
||||
for (i = 0; i < RT_COM_CNT; i++) {
|
||||
struct rt_com_struct *p = &(rt_com_table[i]);
|
||||
if (0 < p->used) {
|
||||
rt_com_free_irq(p->irq);
|
||||
rt_com_setup(i, 0, 0, 0, 0, 0, 0);
|
||||
release_region(p->port, 8);
|
||||
}
|
||||
}
|
||||
|
||||
printk(KERN_INFO "rt_com: unloaded.\n");
|
||||
}
|
||||
|
||||
/*
|
||||
EXPORT_SYMBOL(rt_com_buffersize);
|
||||
EXPORT_SYMBOL(rt_com_clear_input);
|
||||
EXPORT_SYMBOL(rt_com_clear_output);
|
||||
EXPORT_SYMBOL(rt_com_error);
|
||||
EXPORT_SYMBOL(rt_com_hwsetup);
|
||||
EXPORT_SYMBOL(rt_com_read);
|
||||
EXPORT_SYMBOL(rt_com_read_modem);
|
||||
EXPORT_SYMBOL(rt_com_setup);
|
||||
EXPORT_SYMBOL(rt_com_table);
|
||||
EXPORT_SYMBOL(rt_com_write);
|
||||
EXPORT_SYMBOL(rt_com_write_modem);
|
||||
EXPORT_SYMBOL(rt_com_set_mode);
|
||||
EXPORT_SYMBOL(rt_com_set_fifotrig);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-file-style: "Stroustrup"
|
||||
* End:
|
||||
*/
|
||||
|
|
@ -1,159 +0,0 @@
|
|||
/**************************************************************************************************
|
||||
*
|
||||
* aip_com.h
|
||||
*
|
||||
* Macros für Kommunikation über serielle Schnittstelle
|
||||
* Basiert auf rt_com.h von rtai !! (siehe unten)
|
||||
*
|
||||
*
|
||||
* Autor: Wilhelm Hagemeister
|
||||
*
|
||||
* (C) Copyright IgH 2002
|
||||
* Ingenieurgemeinschaft IgH
|
||||
* Heinz-Bäcker Str. 34
|
||||
* D-45356 Essen
|
||||
* Tel.: +49 201/61 99 31
|
||||
* Fax.: +49 201/61 98 36
|
||||
* E-mail: hm@igh-essen.com
|
||||
*
|
||||
*
|
||||
* $RCSfile: aip_com.h,v $
|
||||
* $Revision: 1.1 $
|
||||
* $Author: hm $
|
||||
* $Date: 2004/09/30 15:50:32 $
|
||||
* $State: Exp $
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
/** rt_com
|
||||
* ======
|
||||
*
|
||||
* RT-Linux kernel module for communication across serial lines.
|
||||
*
|
||||
* Copyright (C) 1997 Jens Michaelsen
|
||||
* Copyright (C) 1997-2000 Jochen Kupper
|
||||
* Copyright (C) 2002 Giuseppe Renoldi
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file License. if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*
|
||||
* $Id: aip_com.h,v 1.1 2004/09/30 15:50:32 hm Exp $ */
|
||||
|
||||
|
||||
|
||||
#ifndef AIP_COM_H
|
||||
#define AIP_COM_H
|
||||
|
||||
/** This is the interface definition of the plain rt_com API.
|
||||
*
|
||||
* This should be all you need to use rt_com within your real-time
|
||||
* kernel module.
|
||||
*
|
||||
* (When POSIX is done, we will reference the appropriate header
|
||||
* here - probably depending on a flag.) */
|
||||
|
||||
int init_aip_com(void); //Hm, IgH
|
||||
void cleanup_aip_com(void); //Hm, IgH
|
||||
|
||||
|
||||
/** specify hardware parameters, set-up communication parameters */
|
||||
extern int rt_com_hwsetup( unsigned int ttyS, int base, int irq );
|
||||
extern int rt_com_setup( unsigned int ttyS, int baud, int mode,
|
||||
unsigned int parity, unsigned int stopbits,
|
||||
unsigned int wordlength, int fifotrig );
|
||||
|
||||
/** read/write from/to input/output buffer */
|
||||
extern int rt_com_read( unsigned int, char *, int );
|
||||
extern int rt_com_write( unsigned int ttyS, char *buffer, int count );
|
||||
|
||||
/** clear input or output buffer */
|
||||
extern int rt_com_clear_input( unsigned int ttyS );
|
||||
extern int rt_com_clear_output( unsigned int ttyS );
|
||||
|
||||
/** read input signal from modem (CTS,DSR,RI,DCD), set output signal
|
||||
* for modem control (DTR,RTS) */
|
||||
extern int rt_com_read_modem( unsigned int ttyS, int signal );
|
||||
extern int rt_com_write_modem( unsigned int ttyS, int signal, int value );
|
||||
|
||||
/** functioning mode and fifo trigger setting */
|
||||
extern int rt_com_set_mode( unsigned int ttyS, int mode);
|
||||
extern int rt_com_set_fifotrig( unsigned int ttyS, int fifotrig);
|
||||
|
||||
/** return last error detected */
|
||||
extern int rt_com_error( unsigned int ttyS );
|
||||
|
||||
|
||||
/** size of internal queues, this is constant during module lifetime */
|
||||
extern unsigned int rt_com_buffersize;
|
||||
|
||||
#define rt_com_set_param rt_com_hwsetup
|
||||
#define rt_com_setup_old(a,b,c,d,e) rt_com_setup((a),(b),0,(c),(d),(e),-1)
|
||||
|
||||
|
||||
/** functioning modes */
|
||||
#define RT_COM_NO_HAND_SHAKE 0x00
|
||||
#define RT_COM_DSR_ON_TX 0x01
|
||||
#define RT_COM_HW_FLOW 0x02
|
||||
|
||||
/** parity flags */
|
||||
#define RT_COM_PARITY_EVEN 0x18
|
||||
#define RT_COM_PARITY_NONE 0x00
|
||||
#define RT_COM_PARITY_ODD 0x08
|
||||
#define RT_COM_PARITY_HIGH 0x28
|
||||
#define RT_COM_PARITY_LOW 0x38
|
||||
|
||||
/* FIFO Control */
|
||||
#define RT_COM_FIFO_DISABLE 0x00
|
||||
#define RT_COM_FIFO_SIZE_1 0x00
|
||||
#define RT_COM_FIFO_SIZE_4 0x40
|
||||
#define RT_COM_FIFO_SIZE_8 0x80
|
||||
#define RT_COM_FIFO_SIZE_14 0xC0
|
||||
|
||||
/** rt_com_write_modem masks */
|
||||
#define RT_COM_DTR 0x01
|
||||
#define RT_COM_RTS 0x02
|
||||
|
||||
/** rt_com_read_modem masks */
|
||||
#define RT_COM_CTS 0x10
|
||||
#define RT_COM_DSR 0x20
|
||||
#define RT_COM_RI 0x40
|
||||
#define RT_COM_DCD 0x80
|
||||
|
||||
/** rt_com_error masks */
|
||||
#define RT_COM_BUFFER_FULL 0x01
|
||||
#define RT_COM_OVERRUN_ERR 0x02
|
||||
#define RT_COM_PARITY_ERR 0x04
|
||||
#define RT_COM_FRAMING_ERR 0x08
|
||||
#define RT_COM_BREAK 0x10
|
||||
|
||||
|
||||
#endif /* RT_COM_H */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-file-style: "Stroustrup"
|
||||
* End:
|
||||
*/
|
||||
|
|
@ -1,206 +0,0 @@
|
|||
/**
|
||||
* rt_com
|
||||
* ======
|
||||
*
|
||||
* RT-Linux kernel module for communication across serial lines.
|
||||
*
|
||||
* Copyright (C) 1997 Jens Michaelsen
|
||||
* Copyright (C) 1997-2000 Jochen Kupper
|
||||
* Copyright (C) 1999 Hua Mao <hmao@nmt.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file License. if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef AIP_COM_P_H
|
||||
#define AIP_COM_P_H
|
||||
|
||||
|
||||
#define RT_COM_NAME "rt_com(aip)" //Hm, IgH
|
||||
|
||||
/* input/ouput buffer (FIFO) sizes */
|
||||
#define RT_COM_BUF_SIZ 2048 //256 // MUST BE ONLY POWER OF 2 !!
|
||||
/* amount of free space on input buffer for RTS reset */
|
||||
#define RT_COM_BUF_LOW (RT_COM_BUF_SIZ / 3)
|
||||
/* amount of free space on input buffer for RTS set */
|
||||
#define RT_COM_BUF_HI (RT_COM_BUF_SIZ * 2 / 3)
|
||||
/* limit of free space on input buffer for buffer full error */
|
||||
#define RT_COM_BUF_FULL 20
|
||||
|
||||
|
||||
/* usage flags */
|
||||
#define RT_COM_PORT_FREE 0x00
|
||||
#define RT_COM_PORT_INUSE 0x01
|
||||
#define RT_COM_PORT_SETUP 0x02
|
||||
|
||||
|
||||
/* Some hardware description */
|
||||
#define RT_COM_BASE_BAUD 115200
|
||||
|
||||
/** Interrupt Service Routines
|
||||
* These are private functions */
|
||||
static void rt_com0_isr( void );
|
||||
static void rt_com1_isr( void );
|
||||
|
||||
|
||||
|
||||
|
||||
/** Interrupt handling
|
||||
*
|
||||
* Define internal convinience macros for interrupt handling, so we
|
||||
* get rid of the system dependencies.
|
||||
*/
|
||||
//#define rt_com_irq_off( state ) do{}while(0) //rt_global_save_flags( &state ); rt_global_cli() schreiben und lesen sowieso in IRQ Hm
|
||||
//#define rt_com_irq_on(state) do{}while(0) //rt_global_restore_flags( state )
|
||||
#define rt_com_irq_off( state ) rt_global_save_flags( &state ); rt_global_cli()
|
||||
#define rt_com_irq_on(state) rt_global_restore_flags( state )
|
||||
#define rt_com_request_irq( irq, isr ) rt_request_global_irq( irq, isr ); rt_enable_irq( irq );
|
||||
#define rt_com_free_irq( irq ) rt_free_global_irq( irq )
|
||||
|
||||
|
||||
/* port register offsets */
|
||||
#define RT_COM_RXB 0x00
|
||||
#define RT_COM_TXB 0x00
|
||||
#define RT_COM_IER 0x01
|
||||
#define RT_COM_IIR 0x02
|
||||
#define RT_COM_FCR 0x02
|
||||
#define RT_COM_LCR 0x03
|
||||
#define RT_COM_MCR 0x04
|
||||
#define RT_COM_LSR 0x05
|
||||
#define RT_COM_MSR 0x06
|
||||
#define RT_COM_DLL 0x00
|
||||
#define RT_COM_DLM 0x01
|
||||
|
||||
/** MCR Modem Control Register masks */
|
||||
#define MCR_DTR 0x01 // Data Terminal Ready
|
||||
#define MCR_RTS 0x02 // Request To Send
|
||||
#define MCR_OUT1 0x04
|
||||
#define MCR_OUT2 0x08
|
||||
#define MCR_LOOP 0x10
|
||||
#define MCR_AFE 0x20 // AutoFlow Enable
|
||||
|
||||
/** IER Interrupt Enable Register masks */
|
||||
#define IER_ERBI 0x01 // Enable Received Data Available Interrupt
|
||||
#define IER_ETBEI 0x02 // Enable Transmitter Holding Register
|
||||
// Empty Interrupt
|
||||
#define IER_ELSI 0x04 // Enable Receiver Line Status Interrupt
|
||||
#define IER_EDSSI 0x08 // Enable Modem Status Interrupt
|
||||
|
||||
/** MSR Modem Status Register masks */
|
||||
#define MSR_DELTA_CTS 0x01
|
||||
#define MSR_DELTA_DSR 0x02
|
||||
#define MSR_TERI 0x04
|
||||
#define MSR_DELTA_DCD 0x08
|
||||
#define MSR_CTS 0x10
|
||||
#define MSR_DSR 0x20
|
||||
#define MSR_RI 0x40
|
||||
#define MSR_DCD 0x80
|
||||
|
||||
/** LSR Line Status Register masks */
|
||||
#define LSR_DATA_READY 0x01
|
||||
#define LSR_OVERRUN_ERR 0x02
|
||||
#define LSR_PARITY_ERR 0x04
|
||||
#define LSR_FRAMING_ERR 0x08
|
||||
#define LSR_BREAK 0x10
|
||||
#define LSR_THRE 0x20 // Transmitter Holding Register
|
||||
#define LSR_TEMT 0x40 // Transmitter Empty
|
||||
|
||||
/** FCR FIFO Control Register masks */
|
||||
#define FCR_FIFO_ENABLE 0x01
|
||||
#define FCR_INPUT_FIFO_RESET 0x02
|
||||
#define FCR_OUTPUT_FIFO_RESET 0x04
|
||||
|
||||
/** data buffer
|
||||
*
|
||||
* Used for buffering of input and output data. Two buffers per port
|
||||
* (one for input, one for output). Organized as a FIFO */
|
||||
struct rt_buf_struct{
|
||||
unsigned int head;
|
||||
unsigned int tail;
|
||||
char buf[ RT_COM_BUF_SIZ ];
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Port data
|
||||
*
|
||||
* Internal information structure containing all data for a port. One
|
||||
* structure for every port.
|
||||
*
|
||||
* Contains all current setup parameters and all data currently
|
||||
* buffered by rt_com.
|
||||
*
|
||||
* mode (functioning mode)
|
||||
* possible values:
|
||||
* - RT_COM_DSR_ON_TX - for standard functioning mode (DSR needed on TX)
|
||||
* - RT_COM_NO_HAND_SHAKE - for comunication without hand shake signals
|
||||
* (only RXD-TXD-GND)
|
||||
* - RT_COM_HW_FLOW - for hardware flow control (RTS-CTS)
|
||||
* Of course RT_COM_DSR_ON_TX and RT_COM_NO_HAND_SHAKE cannot be
|
||||
* sppecified at the same time.
|
||||
*
|
||||
* NOTE: When you select a mode that uses hand shake signals pay
|
||||
* attention that no input signals (CTS,DSR,RI,DCD) must be
|
||||
* floating.
|
||||
*
|
||||
* used (usage flag)
|
||||
* possible values:
|
||||
* - RT_COM_PORT_INUSE - port region requested by init_module
|
||||
* - RT_COM_PORT_FREE - port region requested by rt_com_set_param
|
||||
* - RT_COM_PORT_SETUP - port parameters are setup,
|
||||
* don't specify at compile time !
|
||||
*
|
||||
* error
|
||||
* last error detected
|
||||
*
|
||||
* ier (interrupt enable register)
|
||||
* copy of IER chip register, last value set by rt_com.
|
||||
*
|
||||
* mcr (modem control register)
|
||||
* copy of the MCR internal register
|
||||
*/
|
||||
struct rt_com_struct{
|
||||
int baud_base;
|
||||
int port;
|
||||
int irq;
|
||||
void (*isr)(void);
|
||||
int baud;
|
||||
unsigned int wordlength;
|
||||
unsigned int parity;
|
||||
unsigned int stopbits;
|
||||
int mode;
|
||||
int fifotrig;
|
||||
int used;
|
||||
int error;
|
||||
int type;
|
||||
int ier;
|
||||
int mcr;
|
||||
struct rt_buf_struct ibuf;
|
||||
struct rt_buf_struct obuf;
|
||||
};
|
||||
|
||||
|
||||
#endif /* RT_COM_P_H */
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-file-style: "Stroustrup"
|
||||
* End:
|
||||
*/
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
/******************************************************************************
|
||||
*
|
||||
* msr_io.c
|
||||
*
|
||||
* Debugging über Serielle Schnittstelle
|
||||
*
|
||||
* Autoren: Wilhelm Hagemeister
|
||||
*
|
||||
* $LastChangedDate: 2005-09-16 17:45:46 +0200 (Fri, 16 Sep 2005) $
|
||||
* $Author: hm $
|
||||
*
|
||||
* (C) Copyright IgH 2005
|
||||
* Ingenieurgemeinschaft IgH
|
||||
* Heinz-Bäcker Str. 34
|
||||
* D-45356 Essen
|
||||
* Tel.: +49 201/61 99 31
|
||||
* Fax.: +49 201/61 98 36
|
||||
* E-mail: sp@igh-essen.com
|
||||
*
|
||||
* /bin/setserial /dev/ttyS0 uart none
|
||||
* /bin/setserial /dev/ttyS1 uart none
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*--Includes-----------------------------------------------------------------*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/tqueue.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/spinlock.h>
|
||||
|
||||
#include "aip_com.h"
|
||||
#include "rs232dbg.h"
|
||||
#include <rtai.h>
|
||||
|
||||
spinlock_t rs232wlock;
|
||||
|
||||
|
||||
void SDBG_print(const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
static char buf[1024];
|
||||
int len;
|
||||
if(format != NULL) {
|
||||
va_start(argptr,format);
|
||||
len = vsnprintf(buf, sizeof(buf), format, argptr);
|
||||
if (len > 0 && buf[len - 1] == '\n') len--; // fp
|
||||
rt_com_write(0,buf,len);
|
||||
rt_com_write(0,"\r\n",2);
|
||||
va_end(argptr);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void SDBG_print(unsigned char *buf)
|
||||
{
|
||||
static int counter = 0;
|
||||
unsigned char cbuf[20];
|
||||
unsigned long flags;
|
||||
|
||||
// flags = rt_spin_lock_irqsave (&rs232wlock);
|
||||
|
||||
sprintf(cbuf,"%0d -- ",counter);
|
||||
rt_com_write(0,cbuf,strlen(cbuf));
|
||||
rt_com_write(0,buf,strlen(buf));
|
||||
rt_com_write(0,"\r\n",2);
|
||||
counter++;
|
||||
counter %= 10; //did we miss frames ??
|
||||
// rt_spin_unlock_irqrestore (&rs232wlock,flags);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Function: msr_init
|
||||
*
|
||||
* Beschreibung: MSR initialisieren
|
||||
*
|
||||
* Parameter:
|
||||
*
|
||||
* Rückgabe:
|
||||
*
|
||||
* Status: exp
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
int msr_init(void)
|
||||
{
|
||||
spin_lock_init (&rs2323wlock);
|
||||
|
||||
printk("starting RS232 Setup\n");
|
||||
if(init_aip_com())
|
||||
{
|
||||
printk("RS232 Setup failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDBG_print("Hello Word, Serial Debugger started...");
|
||||
mdelay(10);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
*
|
||||
* Function: msr_io_cleanup
|
||||
*
|
||||
* Beschreibung: Aufräumen
|
||||
*
|
||||
* Parameter:
|
||||
*
|
||||
* Rückgabe:
|
||||
*
|
||||
* Status: exp
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
void msr_io_cleanup(void)
|
||||
{
|
||||
cleanup_aip_com();
|
||||
}
|
||||
|
||||
/*---Treiber-Einsprungspunkte etc.-------------------------------------------*/
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(msr_init);
|
||||
module_exit(msr_io_cleanup);
|
||||
|
||||
/*---Ende--------------------------------------------------------------------*/
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
#ifndef RS232DBG_H
|
||||
#define RS232DBG_H
|
||||
|
||||
void SDBG_print(const char *format, ...);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue