Commit 3f97dd6b authored by Guilherme Sanches's avatar Guilherme Sanches

First compiling version with the occan driver. The iop_can example is

still not a testing version, event though it compiles. There is still no
configure tool for the CAN driver
parent 5e80e898
......@@ -24,7 +24,7 @@ static iop_physical_device_t *physical_device_list[1] = \
};
/**
* @brief Physical devices list
* @brief Logical devices list
*/
static iop_logical_device_t *logical_device_list[1] = \
{
......@@ -33,6 +33,9 @@ static iop_logical_device_t *logical_device_list[1] = \
static iop_wrapper_t requests_storage[1024];
/**
* @brief IOP buffers
*/
static iop_buffer_t iop_buffers[1024];
static uint8_t iop_buffers_storage[1024 * IOP_BUFFER_SIZE];
......
......@@ -13,7 +13,7 @@ static iop_header_t route_header[1] = \
{
{
.eth_header = {
.dst_ip = { 192,168,0,3},
.dst_ip = { 192,168,0,3 },
.dst_mac = { 0x00,0x50,0xbf,0x50,0x07,0x0d},
.dst_port = HTONS(13000),
.src_port = HTONS(13000)
......
......@@ -9,11 +9,15 @@
#include <iop.h>
#include <iop_greth.h>
#include <eth_support.h>
/**
* @brief IOP remote ports
*/
extern iop_port_t remote_ports[2];
/**
* @brief IOP buffers
*/
static iop_buffer_t iop_buffers[64];
static uint8_t iop_buffers_storage[64 * IOP_BUFFER_SIZE];
......@@ -78,9 +82,9 @@ static uint32_t reads_per_period[] = \
*/
static iop_header_t route_header[1] = \
{
{
{
.eth_header = {
.dst_ip = { 192,168,0,3},
.dst_ip = { 192,168,0,3 },
.dst_mac = { 0x00,0x50,0xbf,0x50,0x07,0x0d},
.dst_port = HTONS(14000),
.src_port = HTONS(14000)
......
......@@ -63,7 +63,7 @@ typedef struct {
char sshot; /* Single shot option*/
// unsigned char len; /* payload length from 1-8 bytes */
unsigned int id; /* Remote device identifier */
} __attribute__((packet)) can_header_t;
} __attribute__((packed)) can_header_t;
/**
* @brief IOP generic header
......
/*
* ============================================================================
* 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 Ethernet's GRETH devices.
* options for CAN devices.
* ============================================================================
*/
#include <iop.h>
......@@ -35,7 +33,9 @@ static iop_buffer_t *rx_iop_buffer[32];
* to be used by the occan driver
*/
static CANMsg msg_queue[32];
static CANMsg rx_msg_fifo[32];
static CANMsg tx_msg_fifo[32];
/**
* @brief RX and TX descriptor table
......@@ -47,19 +47,30 @@ static CANMsg msg_queue[32];
static occan_priv occan_driver = \
{
.speed = 250000, // TODO maybe use a enum in the future
.code = {0, 0, 0, 0},
.mask = {0, 0, 0, 0},
.filter = {
.single_mode = 0,
.code = {0, 0, 0, 0},
.mask = {0, 0, 0, 0},
},
.iop_buffers = iop_buffers,
.iop_buffers = iop_buffers,
.iop_buffers_storage = iop_buffers_storage,
.internal_msg_queue = {
.rx_fifo = {
.cnt = 0,
.ovcnt = 0,
.next = 0,
.last = 0,
.max = 32,
.fifo = rx_msg_fifo,
},
.tx_fifo = {
.cnt = 0,
.ovcnt = 0,
.next = 0,
.last = 0,
.max = 32,
.fifo = msg_queue,
.fifo = tx_msg_fifo,
},
/** @note descriptor table address are split and aligned at the runtime */
......
......@@ -27,7 +27,7 @@ QUEUING_PORT_ID_TYPE qpid;
------------------------------------------------------------*/
void test(PARTITION_ID_TYPE self_id) {
char msg[1024]="empty\0";
unsigned char msg[1024]="empty\0";
RETURN_CODE_TYPE rc;
MESSAGE_SIZE_TYPE len;
......
This diff is collapsed.
......@@ -37,6 +37,10 @@ void error_message(RETURN_CODE_TYPE rc){
case INVALID_MODE:
pprintf("WRITE_SAMPLING_MESSAGE error Invalid Mode\n");
break;
default:
pprintf("Unknown error\n");
break;
}
}
......@@ -104,11 +108,11 @@ int entry_func() {
CREATE_SAMPLING_PORT (NAME, SIZE, SOURCE, PERIOD, &SEND_PORT, &rc);
if (NO_ERROR != rc) {
pprintf("CREATE_SAMPLING_PORT error %d\n", rc);
pprintf("CREATE_SAMPLING_PORT error %d\n", (int) rc);
}
if (RTEMS_SUCCESSFUL == rtems_task_create (name, 15, 4096, mode, mode_mask, &id)) {
rtems_task_start (id, test, self_id);
rtems_task_start (id, &test, self_id);
}
SET_PARTITION_MODE(NORMAL, &rc);
......
......@@ -6,16 +6,26 @@
*/
#include <can_support.h>
#include <iop.h>
/*
* Stub functions
*/
void can_copy_header() {
void can_copy_header(
iop_physical_device_t *iop_dev,
iop_wrapper_t *wrapper,
iop_header_t *header) {
}
void can_compare_header(){
void can_compare_header(
iop_wrapper_t *wrapper,
iop_header_t *header){
}
void can_prebuild_header(){
void can_prebuild_header(
can_header_t *header){
}
......@@ -9,6 +9,7 @@
#include <iop.h>
#include <can_support.h>
#include <iop_error.h>
void can_write(iop_physical_device_t *pdev)
{
......
......@@ -7,7 +7,7 @@
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*
* Author: Daniel Hellstr��m, Gaisler Research AB, www.gaisler.com
* Author: Daniel Hellstrom, Gaisler Research AB, www.gaisler.com
*/
......@@ -16,9 +16,9 @@
#include <ambapp.h>
#include <can_support.h>
#include <iop.h>
#include <xky.h>
#include <iop.h>
#include <can_support.h>
#ifdef __cplusplus
extern "C" {
......@@ -260,16 +260,16 @@ typedef struct {
// int single_mode;
// unsigned char code[4];
// unsigned char mask[4];
occan_filter *filter;
occan_filter filter;
occan_fifo *tx_msg_queue;
occan_fifo *rx_msg_queue;
occan_fifo tx_fifo;
occan_fifo rx_fifo;
/* IOP descriptors */
// occan_txrxdesc txdesc;
// occan_txrxdesc rxdesc;
/*unsigned int tx_ptr; /* Buffer pointerl
unsigned int rx_ptr;*/
unsigned int tx_ptr; /*Buffer pointer*/
unsigned int rx_ptr;
/* IOP standard buffers */
iop_buffer_t *iop_buffers;
uint8_t *iop_buffers_storage;
......
#ifndef __OCCAN_MSG_QUEUE_H__
#define __OCCAN_MSG_QUEUE_H__
#include <xky.h>
#include <iop.h>
/* CAN MESSAGE */
typedef struct {
char extended; /* 1= Extended Frame (29-bit id), 0= STD Frame (11-bit id) */
......@@ -16,14 +19,14 @@ typedef struct {
int ovcnt;
int next;
int last;
static int max;
int max;
CANMsg *fifo;
} occan_fifo;
void occan_fifo_clear(occan_fifo *queue);
uint8_t occan_fifo_clear(occan_fifo *queue);
uint8_t occan_fifo_put(occan_fifo *queue, CANMsg *new, int force);
CANMsg * occan_fifo_get(occan_fifo *queue);
CANMsg *occan_fifo_get(occan_fifo *queue);
uint8_t occan_fifo_full(occan_fifo *queue);
uint8_t occan_fifo_empty(occan_fifo *queue);
......
This diff is collapsed.
#include <occan_msg_queue.h>
CANMsg empty_msg(){
CANMsg msg ={
.extended = 0,
.rtr = 0,
.sshot = 0,
.len = 0,
.data = {0, 0, 0, 0, 0, 0, 0, 0},
.id = 0
};
return msg;
}
/* Clear all entries on the fifo and
* control data */
uint8_t occan_fifo_clear(occan_fifo *queue ){
int i;
int i, j;
for(i = 0; i < queue->max; i++){
queue->fifo[i].extended = 0;
......@@ -12,6 +24,10 @@ uint8_t occan_fifo_clear(occan_fifo *queue ){
queue->fifo[i].id = 0;
queue->fifo[i].len = 0;
queue->fifo[i].sshot = 0;
/* Clear all bytes of data */
for(j = 0; j < 8; j++){
queue->fifo[i].data[j] = 0;
}
}
queue->cnt = 0;
queue->ovcnt = 0;
......@@ -23,12 +39,20 @@ uint8_t occan_fifo_clear(occan_fifo *queue ){
/* TODO force put option for when the queue is full */
uint8_t occan_fifo_put(occan_fifo *queue, CANMsg *new, int force){
int i;
if(queue->max -queue->cnt < 1){
/* queue is full */
return 0;
}
queue->fifo[queue->last] = new;
queue->fifo[queue->last].extended = new->extended;
queue->fifo[queue->last].rtr = new->rtr;
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++){
queue->fifo[queue->last].data[i] = new->data[i];
}
queue->cnt++;
if(queue->last + 1 >= queue->max){
......@@ -42,6 +66,7 @@ uint8_t occan_fifo_put(occan_fifo *queue, CANMsg *new, int force){
CANMsg *occan_fifo_get(occan_fifo *queue){
if(queue->cnt == 0 ){
/* Queue is empty */
// return empty_msg();
return NULL;
}
int tmp = queue->next;
......@@ -49,7 +74,7 @@ CANMsg *occan_fifo_get(occan_fifo *queue){
if(queue->next >= queue->max){
queue->next = 0;
}
return queue->fifo[tmp];
return &(queue->fifo[tmp]);
}
uint8_t occan_fifo_full(occan_fifo *queue) {
......
......@@ -23,7 +23,6 @@ typedef struct {
iop_device_driver_t dev;
char *dev_name;
struct occan_afilter *filter;
// uint16_t self_id; // This device's ID
// uint16_t rx_count;
// uint16_t tx_count;
......@@ -34,10 +33,16 @@ typedef struct {
} iop_can_device_t;
/* Not used right now TODO take it or leave it*/
void can_copy_header();
void can_compare_header();
void can_prebuild_header();
/* TODO the next three functions are stubs */
void can_copy_header(
iop_physical_device_t *iop_dev,
iop_wrapper_t *wrapper,
iop_header_t *header);
void can_compare_header(
iop_wrapper_t *wrapper,
iop_header_t *header);
void can_prebuild_header(
can_header_t *header);
void can_write(iop_physical_device_t *pdev);
void can_reader(iop_physical_device_t *pdev);
......
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