Commit 0b17e43b authored by Guilherme Sanches's avatar Guilherme Sanches

Changes in occan upper layer

The can read/write tasks have been completed. The can_header_compare has
also been completed and it's no longer a stub
parent 88039001
......@@ -19,10 +19,18 @@ void can_copy_header(
}
void can_compare_header(
uint16_t can_compare_header(
iop_wrapper_t *wrapper,
iop_header_t *header){
can_header_t *can_header = (can_header_t *) header;
int id = *(int *) (wrapper->buffer->v_addr +
wrapper->buffer->header_off +
3*sizeof(int));
if (id == can_header->id){
return 1;
}
return 0;
}
void can_prebuild_header(
......
......@@ -4,7 +4,7 @@
* Created on: Sep 7, 2017
* Author: gmvs@gmv.com
*
* Read and write functions for CAN
* Read and write high level functions for CAN
*/
#include <iop.h>
......@@ -20,19 +20,11 @@ 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;
// rw_args.buffer = wrapper;
/* Write to the device */
if(can_driver->dev.write((iop_device_driver_t *) can_driver,
......@@ -63,7 +55,26 @@ void can_reader(iop_physical_device_t *pdev)
iop_debug(" :: can-read running!\n");
/* Read from the buffer */
uint32_t i;
// uint32_t reads = pdev->reads_per_period[xky_schedule.current_schedule_index];
uint32_t reads= 5; // number of reads per period
for(i = 0; i < reads; i++){
iop_wrapper_t *wrapper = obtain_free_wrapper();
if(wrapper == NULL){
iop_raise_error(OUT_OF_MEMORY);
break;
}
if(driver->dev.read((iop_device_driver_t *) driver,
wrapper) == RTEMS_SUCCESSFUL){
/* We received something lets make it
* available to higher level */
iop_chain_append(&pdev->rcvqueue, &wrapper->node);
wrapper = NULL;
}
if(wrapper != NULL){
release_wrapper(wrapper);
}
}
}
......@@ -39,7 +39,7 @@ void can_copy_header(
iop_physical_device_t *iop_dev,
iop_wrapper_t *wrapper,
iop_header_t *header);
void can_compare_header(
uint16_t can_compare_header(
iop_wrapper_t *wrapper,
iop_header_t *header);
void can_prebuild_header(
......
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