Commit 7d9ccb9c authored by Guilherme Sanches's avatar Guilherme Sanches

Work in progress on branch canbus-configure. There is the need to bring...

Work in progress on branch canbus-configure. There is the need to bring updates that have been made on the canbus branch in the meantime
parent 6d3734ed
......@@ -3,11 +3,13 @@ SPW = 'SPW'
MIL = 'MIL'
ETH = 'ETH'
RTR = 'SPWRTR'
CAN = 'CANBUS'
SUPPORTED_DEVICES = { SPW : ['GRSPW'],
MIL : ['GR1553B', 'BRM1553'],
ETH : ['GRETH'],
RTR : ['SPWRTR'] }
RTR : ['SPWRTR'],
CAN : ['CANBUS'] }
IOP_PORT_TYPE = { 'SamplingPort' : 'IOP_SAMPLING_PORT',
'QueuingPort' : 'IOP_QUEUING_PORT' }
......@@ -64,6 +66,13 @@ ETHHEADER_PORT = 'Port'
SPWHEADER = 'SpwHeader'
SPWHEADER_ADDRESS = 'Address'
#CANBUS Header
CANHEADER = 'CanHeader'
CANHEADER_EXTENDED = 'Extended'
CANHEADER_RTR = 'RTR'
CANHEADER_SSHOT = 'SSHOT'
CANHEADER_ID = 'CANId'
import utils.parser as parserutils
......@@ -78,12 +87,13 @@ VALID_FLOAT_TYPE = [ parserutils.str2float, lambda x : x >= 0 ]
VALID_DECIMAL_TYPE = [ parserutils.str2int, lambda x : x >= 0 ]
VALID_BOOLEAN_TYPE = [ parserutils.str2bool, lambda x : isinstance(x, bool) ]
VALID_DIRECTION_TYPE = [ str, lambda x : x in [ REMOTE_PORT_SRC, REMOTE_PORT_DST] ]
VALID_ID = [ lambda x: x < 15]
LOGICAL_DEVICE_STR = 'Logical Device (Id: {0}, Name: {1})'
PHYSICAL_DEVICE_STR = 'Physical Device (Id: {0}, Device: {1})'
ETH_HEADER_STR = 'Ethernet Header (Mac: {0}, Ip: {1}, Port: {2})'
SPW_HEADER_STR = 'SpaceWire Header (Address: {0})'
CAN_HEADER_STR = 'Canbus Header (extended: {0}, Rtr: {1}, Sshot: {2}, Id: {3})'
REMOTE_PORT_STR = 'Remote Port (Name: {0})'
ROUTE_STR = 'Route (Id: {0})'
ROUTE_PHYSICAL_STR = 'Physical Route (Id: {0})'
......@@ -255,5 +265,29 @@ class SpwHeader(object):
def __repr__(self):
return self.__str__()
def details(self):
return self.__str__()
## CANBUS Header
class CANHeader(object):
def __init__(self):
self.extended = 0
self.rtr = 0
self.sshot = 0
self.id = 0
def __eq__(self, other):
return isinstance(other, self.__class__) and \
self.id == other.id
def __ne__(self, other):
return not self.__eq__(other)
def __str__(self):
return CAN_HEADER_STR.format(self.extended, self.rtr, self.sshot, self.id)
def __repr__(self):
return self.__str__()
def details(self):
return self.__str__()
\ No newline at end of file
......@@ -13,5 +13,5 @@ iop_supported_devices = {
'CPSW' : [ ETH, ti.phy_cpsw, ti.sch_cpsw, 'iop_cpsw.mako' ],
'GRSPW' : [ SPW, gaisler.phy_grspw, gaisler.sch_grspw, 'iop_grspw.mako'],
'SPWRTR' : [ RTR, gaisler.phy_spwrtr, gaisler.sch_spwrtr, 'iop_spw_router.mako'],
'OCCAN' : [ CAN, gaisler.phy gaisler ''],
'OCCAN' : [ CAN, gaisler.phy_occan, gaisler.sch_occan, 'iop_occan.mako'],
}
......@@ -26,7 +26,7 @@ ${iop_template.RemotePortList(iop_configuration)}\
${iop_template.IopBuffersStorage(2 * device.setup.txdesccnt + device.setup.rxdesccnt)}\
/**
* @brief RX and TX descriptor table
* @brief RX and TX descriptor tablel
* @warning this should be 2048, but we need 3072 to ensure the 0x400 alignment
*/
static uint8_t descriptor_table[3072];
......
......@@ -9,15 +9,23 @@
<Device Id="1" Name="PARSERVER" />
</LogicalDevices>
<PhysicalDevices>
<!--<Device Id="0" Device="ETH0" Ip="192.168.0.17" MAC="d0:39:72:74:d8:1f" TXD="32" RXD="32">-->
<!--<PhysicalDevices>
<Device Id="0" Device="ETH0" Ip="192.168.0.17" MAC="d0:39:72:74:d8:1f" TXD="32" RXD="32">
<Device Id="0" Device="ETH0" Ip="192.168.0.17" MAC="00:50:C2:75:a0:60" TXD="32" RXD="32">
<LogicalRoute Id="1" LogicalDeviceId="1">
<EthHeader Ip="192.168.0.3" MAC="00:50:bf:50:07:0d" Port="13000"/>
</LogicalRoute>
</Device>
</PhysicalDevices>
</PhysicalDevices>-->
<PhysicalDevices>
<Device Id="0" Device="CAN0" >
<LogicalRoute Id="1" LogicalDeviceId="1">
<CANHeader Extended="0" RTR="0" SSHOT="0" CANId="1"/>
</LogicalRoute>
</Device>
</PhysicalDevices>
<ModuleSchedules>
<Schedule ScheduleIdentifier="1">
<DevicesConfiguration>
......
......@@ -19,7 +19,7 @@
#include <leon.h>
#include <ambapp.h>
#include <occan.h>
#include <iop_occan.h>
#include <can_support.h>
#include <occan_msg_queue.h>
......
/**
* @author gmvs@gmv.com
* @brief CAN support structures and functions definitions
* to integrate the occan driver into AIR
*/
#ifndef __CAN_SUPPORT_H__
......
<%
# device functions
device_functions = dict(
reader_task='can_reader',
write_task='can_write',
header_prebuild='can_prebuild_header',
header_compare='can_compare_header',
header_copy='can_copy_header')
%>\
<%namespace name="iop_template" file="/iop_template.mako />\
/*
* ============================================================================
* This file was generated by the GMV's Configurator Tool and is part of an I/O
* partition configuration.
* File Purpose: IO Partition user configuration. Contains the configuration
* options for OCCAN driver of CAN devices.
* ============================================================================
*/
#include <iop.h>
#include <iop_occan.h>
#include <can_support.h>
${iop_template.RemotePortList(iop_configuration)}
${iop_template.IopBuffersStorage(device.setup.txd_count + device.setup.rxd_count)}\
/**
* @brief TX descriptor to IOP buffer mapping
*/
static iop_buffer_t *tx_iop_buffer[${device.setup.txd_count}];
/**
* @brief RX descriptor to IOP buffer mapping
*/
static iop_buffer_t *rx_iop_buffer[${device.setup.rxd_count}];
/**
* @brief RX and TX descriptor table
* @warning this should be 2048, but we need 3072 to ensure the 0x400 alignment
*/
static uint8_t descriptor_table[3072];
/** @brief OCCAN control strucutre */
static iop_can_device_t device_configuration =${'\\'}
{
/* device configuration */
.dev = {
.driver = (void *)&occan_driver,
.init = occan_initialize,
.open = occan_open,
.read = occan_read,
.write = occan_write,
.close = occan_close,
},
.dev_name =${}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment