Microchip® Advanced Software Framework

can_task.c File Reference

Application CAN Task Management.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <stddef.h>
#include <stdio.h>
#include <avr32/io.h>
#include "compiler.h"
#include "board.h"
#include "power_clocks_lib.h"
#include "gpio.h"
#include "pm_uc3c.h"
#include "scif_uc3c.h"
#include "print_funcs.h"
#include "can_task.h"
#include "conf_can_task.h"
#include "dsp.h"
#include "conf_demo.h"

Functions

void can_example_prepare_data_to_receive (void)
 CAN Prepare Data to Receive. More...
 
void can_example_prepare_data_to_send (void)
 Local function to prepare RX and TX buffers. More...
 
void can_out_callback_channel0 (U8 handle, U8 event)
 CAN Call Back when message is received. More...
 
void can_out_callback_channel1 (U8 handle, U8 event)
 CAN Call Back when message is transmitted. More...
 
void can_task (void)
 CAN Task: More...
 
void can_task_init (void)
 

Variables

volatile uint16_t adc_current_conversion
 External reference on ADC Current Conversion. More...
 
volatile bool message_received_on_channel0 = false
 Boolean for message transmitted on CAN channel 0. More...
 
volatile bool message_transmitted_on_channel1 = false
 Boolean for message transmitted on CAN channel 1. More...
 
can_msg_t mob_ram_ch0 [NB_MOB_CHANNEL]
 Local Mob Declaration. More...
 
can_msg_t mob_ram_ch1 [NB_MOB_CHANNEL]
 
A_ALIGNED dsp16_t signal3_buf [BUFFER_LENGTH]
 Buffer to store ADC Conversions. More...
 

void can_example_prepare_data_to_receive ( void  )

CAN Prepare Data to Receive.

  • Allocate one MOB in reception
  • Start the reception

References can_init(), can_mob_alloc(), can_out_callback_channel0(), can_rx(), CANIF_CHANNEL_MODE_NORMAL, can_mob_t::handle, and pCANMOB_message2.

Referenced by can_task(), and can_task_init().

void can_example_prepare_data_to_send ( void  )

Local function to prepare RX and TX buffers.

CAN Prepare Data to Send.

  • Allocate one MOB in transmission
  • Fill the MOB with the correct DATA
  • Start the transmission

References adc_current_conversion, CAN_CMD_REFUSED, can_init(), can_mob_alloc(), can_mob_t::can_msg, can_out_callback_channel1(), can_tx(), CANIF_CHANNEL_MODE_NORMAL, can_msg_t::data, can_mob_t::handle, pCANMOB_message0, and Union64::u8.

Referenced by can_task(), and can_task_init().

void can_out_callback_channel1 ( U8  handle,
U8  event 
)

CAN Call Back when message is transmitted.

References can_mob_free(), gpio_tgl_gpio_pin(), and message_transmitted_on_channel1.

Referenced by can_example_prepare_data_to_send().

void can_task ( void  )

CAN Task:

  • Check if messages are correctly transmitted/received
  • Update message for transmission/reception

References BUFFER_LENGTH, can_example_prepare_data_to_receive(), can_example_prepare_data_to_send(), can_mob_t::can_msg, can_msg_t::data, i, message_received_on_channel0, message_transmitted_on_channel1, pCANMOB_message2, signal3_buf, and Union64::u8.

Referenced by main().

volatile uint16_t adc_current_conversion

External reference on ADC Current Conversion.

Referenced by adc_process_task(), and can_example_prepare_data_to_send().

volatile bool message_received_on_channel0 = false

Boolean for message transmitted on CAN channel 0.

Referenced by can_out_callback_channel0(), and can_task().

volatile bool message_transmitted_on_channel1 = false

Boolean for message transmitted on CAN channel 1.

Referenced by can_out_callback_channel1(), and can_task().

can_msg_t mob_ram_ch0[NB_MOB_CHANNEL]

Local Mob Declaration.

can_msg_t mob_ram_ch1[NB_MOB_CHANNEL]

Buffer to store ADC Conversions.

Referenced by can_task(), and gui_task().