Commit adecd584 authored by Guilherme Sanches's avatar Guilherme Sanches

refs #104462 Multiple changes not only on the configure tool but on the

can driver as well. Parts of the configuration were missing and that
became clear while changing the configure tool.
parent 7d9ccb9c
......@@ -26,6 +26,8 @@ ${EthHeader(route.header)}${',' if i < len(pdevice.routes) - 1 else ''}
% for i, route in enumerate(pdevice.routes):
${SpwHeader(route.header)}${',' if i < len(pdevice.routes) - 1 else ''}
% endfor
%elif pdevice.type =='CAN':
${CANHeader(route.header)}${',' if i < len(pdevice.routes) -1 else ''}
% endif
};
......@@ -120,6 +122,17 @@ extern iop_port_t remote_ports[${len(iop_configuration.ports)}];
}\
</%def>
</%def name="CANHeader(header)">\
{
.can_header = {
.extended = ${},
.rtr = ${},
.sshot = ${},
.id = ${}
}
}\
</%def>
<%def name="IopBuffersStorage(size)">\
/**
* @brief IOP buffers
......
......@@ -19,7 +19,8 @@
</PhysicalDevices>-->
<PhysicalDevices>
<Device Id="0" Device="CAN0" >
<Device Id="0" Device="CAN0" Speed="250" TXD="32" RXD="32" InternalBuf="8">
<Filter SingleMode="true" Code="f:f:f:f" Mask="f:f:f:f" />
<LogicalRoute Id="1" LogicalDeviceId="1">
<CANHeader Extended="0" RTR="0" SSHOT="0" CANId="1"/>
</LogicalRoute>
......
......@@ -20,12 +20,19 @@ void can_write(iop_physical_device_t *pdev)
/* Get the underlying driver */
iop_can_device_t *can_driver = (iop_can_device_t *) pdev->driver;
// rtems_libio_rw_args_t rw_args = {
// .buffer = NULL,
// .count = 0,
// .flags = 0,
// .bytes_moved = 0,
// };
iop_debug(" :: can-write running!\n");
while(!iop_chain_is_empty(&pdev->sendqueue)){
iop_wrapper_t *wrapper = obtain_wrapper(&pdev->sendqueue);
uint8_t *message = (uint8_t *) wrapper->buffer->v_addr;
// uint8_t *message = (uint8_t *) wrapper->buffer->v_addr;
// rw_args.buffer = wrapper;
/* Write to the device */
if(can_driver->dev.write((iop_device_driver_t *) can_driver,
......@@ -35,7 +42,6 @@ void can_write(iop_physical_device_t *pdev)
iop_chain_append(&error, &wrapper->node);
iop_raise_error(HW_WRITE_ERROR);
}
}
/* Failed transmissions */
while(!iop_chain_is_empty(&error)) {
......
......@@ -365,7 +365,7 @@ static void pelican_regadr_print(pelican_regs *regs);
#endif
/***** Driver related interface *****/
uint32_t occan_ioctl(iop_can_device_t *device, void *arg);
//uint32_t occan_ioctl(iop_can_device_t *device, void *arg);
uint32_t occan_write(iop_device_driver_t *iop_dev, void *arg);
uint32_t occan_read(iop_device_driver_t *iop_dev, void *arg);
uint32_t occan_close(iop_device_driver_t *iop_dev, void *arg);
......@@ -385,29 +385,35 @@ static unsigned int sys_freq_hz;
* It must include 'offset' instead of using iop's offset since we can have
* multiple outstanding i/o's on a device.
*/
typedef struct {
char *buffer;
uint32_t count;
uint32_t flags;
uint32_t bytes_moved;
} rtems_libio_rw_args_t;
/**
* @brief Parameter block for open/close.
*/
typedef struct {
uint32_t flags;
uint32_t mode;
} rtems_libio_open_close_args_t;
//typedef struct {
// char *buffer;
// uint32_t count;
// uint32_t flags;
// uint32_t bytes_moved;
//} rtems_libio_rw_args_t;
/**
* @brief Parameter block for ioctl.
* @brief Paramameter block for read/write.
*
* It must include 'offset' instead of using iop's offset since we can have
* multiple outstanding i/o's on a device.
*/
typedef struct {
uint32_t command;
void *buffer;
uint32_t ioctl_return;
} rtems_libio_ioctl_args_t;
///**
// * @brief Parameter block for open/close.
// */
//typedef struct {
// uint32_t flags;
// uint32_t mode;
//} rtems_libio_open_close_args_t;
//
///**
// * @brief Parameter block for ioctl.
// */
//typedef struct {
// uint32_t command;
// void *buffer;
// uint32_t ioctl_return;
//} rtems_libio_ioctl_args_t;
#ifdef __cplusplus
}
......
......@@ -21,7 +21,6 @@ typedef struct {
int last;
int max;
CANMsg *fifo;
} occan_fifo;
uint8_t occan_fifo_clear(occan_fifo *queue);
......
This diff is collapsed.
......@@ -50,7 +50,7 @@ uint8_t occan_fifo_put(occan_fifo *queue, CANMsg *new, int force){
queue->fifo[queue->last].sshot = new->sshot;
queue->fifo[queue->last].id = new->id;
queue->fifo[queue->last].len = new->len;
for(i = 0; i < 8; i++){
for(i = 0; i < new->len; i++){
queue->fifo[queue->last].data[i] = new->data[i];
}
queue->cnt++;
......
......@@ -12,13 +12,6 @@
#include <iop_support.h>
#include <occan_msg_queue.h>
//typedef struct {
// uint16_t identifier;
// uint8_t RTR;
// uint8_t data_len; // Data length in bytes to a maximum of 8
// char data[8];
//}can_frame;
typedef struct {
/* Generic device configuration */
iop_device_driver_t dev;
......@@ -28,12 +21,19 @@ typedef struct {
// uint16_t rx_count;
// uint16_t tx_count;
// char *buffer;
uint32_t count;
uint32_t flags;
uint32_t bytes_moved;
// uint32_t count;
// uint32_t flags;
// uint32_t bytes_moved;
} iop_can_device_t;
//typedef struct {
// uint8_t extended;
// uint8_t rtr;
// uint8_t sshot;
// uint8_t id;
//} __attribute__ ((packet)) iop_can_header_t;
/* TODO the next three functions are stubs */
void can_copy_header(
iop_physical_device_t *iop_dev,
......
<%
<%
# device functions
device_functions = dict(
reader_task='can_reader',
......@@ -35,12 +35,48 @@ static iop_buffer_t *tx_iop_buffer[${device.setup.txd_count}];
*/
static iop_buffer_t *rx_iop_buffer[${device.setup.rxd_count}];
/**
* @brief Allocation of the occan driver internal
* message queue
*/
static CANMsg rx_msg_fifo[${}];
static CANMsg tx_msg_fifo[${}];
/**
* @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 structure*/
static occan_priv occan_driver = \
{
.speed = ${device.setup.speed},
.filter = {
.single_mode = ${0 \
if device.setup.single_mode is True else \
1},
.code = {${device.setup.code}},
.mask = {${device.setup.mask}},
},
.iop_buffers = iop_buffers,
.iop_buffers_storage = iop_buffers_storage,
.rx_fifo = {
.max = ${device.setup.internal_buffer},
.fifo = rx_msg_fifo,
},
.tx_fifo = {
.max = ${},
.fifo = tx_msg_fifo,
}
}
/** @brief OCCAN control strucutre */
static iop_can_device_t device_configuration =${'\\'}
{
......@@ -53,5 +89,10 @@ static iop_can_device_t device_configuration =${'\\'}
.write = occan_write,
.close = occan_close,
},
.dev_name =${}
}
\ No newline at end of file
.dev_name = ${},
.count = ${},
.flags = ${},
.bytes_moved = ${},
}
${iop_template.PhysicalDevice(iop_configuration, device, device_functions)}\
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