Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

hal_can_interface.cc File Reference

#include "../typedef.h"
#include "../config.h"
#include "../errcodes.h"
#include "hal_can_interface.h"
#include "../system/system_target_extensions.h"
#include <IsoAgLib/driver/can/impl/ident_c.h>
#include <IsoAgLib/util/impl/canpkg_c.h>
#include <IsoAgLib/hal/mitron167/system/system.h>
#include <supplementary_driver/hal/rs232.h>
#include <commercial_BIOS/bios_mitron167/CanDriver/CAN.H>
#include <C166.h>
#include <reg167cs.h>
#include "canr_16x.h"

Include dependency graph for hal_can_interface.cc:

Include dependency graph

Go to the source code of this file.

Namespaces

namespace  __HAL

Classes

struct  canBufferElement_t
 define a struct which allows combination with timestamp More...

Defines

#define TASKING
#define SRVWDT   _srvwdt()
#define TRUE   1
#define FALSE   0

Typedefs

typedef canBufferElement_tcanBuffer_t

Functions

bool isCanRingBufferFull (uint8_t rui8_busNr, uint8_t rui8_msgObj)
 low level helper function to check if buffer is full
bool isCanRingBufferEmpty (uint8_t rui8_busNr, uint8_t rui8_msgObj)
 low level helper function to check if buffer is empty
uint16_t getCanRingBufferSize (uint8_t rui8_busNr, uint8_t rui8_msgObj)
 low level helper function to get current count of elements in buffer
uint16_t getCanRingBufferMaxSize (uint8_t rui8_busNr, uint8_t rui8_msgObj)
 low level helper function to get current count of elements in buffer
uint16_t resetCanRingBuffer (uint8_t rui8_busNr, uint8_t rui8_msgObj)
 low level helper function to reset internal state of buffer: - set read and write position to begin of buffer - set size to 0
canBufferElement_twriteDataToCanRingBuffer (uint8_t rui8_busNr, uint8_t rui8_msgObj, bool rb_force=false)
 low level helper function to write can data
canBufferElement_treadDataFromCanRingBuffer (uint8_t rui8_busNr, uint8_t rui8_msgObj)
 low level helper function to read can data
 interrupt (XP0INT) _using(CAN1_ISR) void CAN1_Isr(void)
 interrupt (XP1INT) _using(CAN2_ISR) void CAN2_Isr(void)

Variables

unsigned char CAN1TxReady
 some prototypes from Mitron CAN example
unsigned char CAN2TxReady
uint16_t ui16_lastCanBusState [CAN_BUS_CNT]
int32_t i32_cinterfBeginBusWarnOff [CAN_BUS_CNT]
int32_t i32_cinterfBeginBit1err [CAN_BUS_CNT]
bool b_runningIrqSendProcess [CAN_BUS_CNT] = { false, false }
 report if active running IRQ controlled send process is active
int32_t i32_cinterfLastSuccSend [CAN_BUS_CNT]
int32_t i32_cinterfLastSuccReceive [CAN_BUS_CNT]
uint16_t gwCinterfBusLoad [CAN_BUS_CNT][10]
 array of 100msec.
uint8_t gb_cinterfBusLoadSlice [CAN_BUS_CNT]
 actual index in gwBusLoad
uint32_t sui32_lastIdent
__IsoAgLib::Ident_c c_cinterfIdent
uint32_t sui32_irqCnt = 0
uint32_t sui32_txIrqCnt = 0
uint32_t sui32_rxIrqCnt = 0
CAN_buf_Seed_def ss_tempSendObj
 define one static CAN HW structure obj for direct send
canBuffer_t arr_canBuffer [2][14]
 Buffer of CAN messages.
uint8_t ui8_canBufferXtd [2][14]
 standardID or extended ID
uint8_t ui8_canBufferDirectionState [2][14]
 direction and open/close state per MSgObj: 0==RX, 1==TX, 0xFF==closed
uint16_t ui16_canBufferMaxSize [2][14]
 allocated size of buffer per MsgObj
uint16_t ui16_canBufferSize [2][14]
 amount of currently stored elements
canBufferElement_tpt_canBufferRead [2][14]
 read position in ringbuffer
canBufferElement_tpt_canBufferWrite [2][14]
 write position in ringbuffer
canBufferElement_tpt_canBufferBegin [2][14]
 write position in ringbuffer
canBufferElement_tpt_canBufferEnd [2][14]
 write position in ringbuffer
bool b_appLock [2][14]
 if Application accesses the buffer -> set LOCK -> if IRQ a READ operation of the App on a receive buffer _must_ be retried as long as one process is not interrupted.
uint8_t ui8_currentBaudrate [2] = { 0, 0 }
 store last used Baudrate


Define Documentation

#define FALSE   0
 

Definition at line 81 of file hal_can_interface.cc.

#define SRVWDT   _srvwdt()
 

Definition at line 78 of file hal_can_interface.cc.

#define TASKING
 

Definition at line 77 of file hal_can_interface.cc.

#define TRUE   1
 

Definition at line 80 of file hal_can_interface.cc.


Typedef Documentation

typedef canBufferElement_t* canBuffer_t
 

Definition at line 123 of file hal_can_interface.cc.


Function Documentation

uint16_t getCanRingBufferMaxSize uint8_t  rui8_busNr,
uint8_t  rui8_msgObj
 

low level helper function to get current count of elements in buffer

Definition at line 238 of file hal_can_interface.cc.

References ui16_canBufferMaxSize, uint16_t, and uint8_t.

uint16_t getCanRingBufferSize uint8_t  rui8_busNr,
uint8_t  rui8_msgObj
 

low level helper function to get current count of elements in buffer

Definition at line 233 of file hal_can_interface.cc.

References ui16_canBufferSize, uint16_t, and uint8_t.

Referenced by interrupt().

interrupt XP1INT   ) 
 

Definition at line 1649 of file hal_can_interface.cc.

References b_appLock, b_runningIrqSendProcess, CAN2TxReady, canBufferElement_t::data, getCanRingBufferSize(), HAL::getTime(), i32_cinterfBeginBusWarnOff, i32_cinterfLastSuccReceive, i32_cinterfLastSuccSend, int32_t, isCanRingBufferEmpty(), isCanRingBufferFull(), readDataFromCanRingBuffer(), sui32_irqCnt, sui32_rxIrqCnt, sui32_txIrqCnt, canBufferElement_t::timestamp, ui16_lastCanBusState, ui8_canBufferDirectionState, uint8_t, and writeDataToCanRingBuffer().

Here is the call graph for this function:

interrupt XP0INT   ) 
 

Definition at line 1499 of file hal_can_interface.cc.

References b_appLock, b_runningIrqSendProcess, CAN1TxReady, canBufferElement_t::data, getCanRingBufferSize(), HAL::getTime(), i32_cinterfBeginBusWarnOff, i32_cinterfLastSuccReceive, i32_cinterfLastSuccSend, int32_t, isCanRingBufferEmpty(), isCanRingBufferFull(), readDataFromCanRingBuffer(), sui32_irqCnt, sui32_lastIdent, sui32_rxIrqCnt, sui32_txIrqCnt, canBufferElement_t::timestamp, ui16_lastCanBusState, ui8_canBufferDirectionState, uint8_t, and writeDataToCanRingBuffer().

Here is the call graph for this function:

bool isCanRingBufferEmpty uint8_t  rui8_busNr,
uint8_t  rui8_msgObj
 

low level helper function to check if buffer is empty

Definition at line 228 of file hal_can_interface.cc.

References ui16_canBufferSize, and uint8_t.

Referenced by interrupt(), and readDataFromCanRingBuffer().

bool isCanRingBufferFull uint8_t  rui8_busNr,
uint8_t  rui8_msgObj
 

low level helper function to check if buffer is full

Definition at line 223 of file hal_can_interface.cc.

References ui16_canBufferMaxSize, ui16_canBufferSize, and uint8_t.

Referenced by interrupt(), and writeDataToCanRingBuffer().

canBufferElement_t* readDataFromCanRingBuffer uint8_t  rui8_busNr,
uint8_t  rui8_msgObj
 

low level helper function to read can data

Definition at line 304 of file hal_can_interface.cc.

References isCanRingBufferEmpty(), pt_canBufferBegin, pt_canBufferEnd, pt_canBufferRead, resetCanRingBuffer(), ui16_canBufferSize, and uint8_t.

Referenced by interrupt().

Here is the call graph for this function:

uint16_t resetCanRingBuffer uint8_t  rui8_busNr,
uint8_t  rui8_msgObj
 

low level helper function to reset internal state of buffer: - set read and write position to begin of buffer - set size to 0

Definition at line 246 of file hal_can_interface.cc.

References arr_canBuffer, pt_canBufferBegin, pt_canBufferEnd, pt_canBufferRead, pt_canBufferWrite, ui16_canBufferMaxSize, ui16_canBufferSize, uint16_t, and uint8_t.

Referenced by readDataFromCanRingBuffer(), and writeDataToCanRingBuffer().

canBufferElement_t* writeDataToCanRingBuffer uint8_t  rui8_busNr,
uint8_t  rui8_msgObj,
bool  rb_force = false
 

low level helper function to write can data

Definition at line 267 of file hal_can_interface.cc.

References isCanRingBufferFull(), pt_canBufferBegin, pt_canBufferEnd, pt_canBufferRead, pt_canBufferWrite, resetCanRingBuffer(), ui16_canBufferSize, and uint8_t.

Referenced by interrupt().

Here is the call graph for this function:


Variable Documentation

canBuffer_t arr_canBuffer[2][14] [static]
 

Initial value:

{ { (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL,
    (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL },
 { (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL,
   (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL, (canBuffer_t)NULL } }
Buffer of CAN messages.

Definition at line 132 of file hal_can_interface.cc.

Referenced by resetCanRingBuffer().

bool b_appLock[2][14] [static]
 

Initial value:

{ { false, false, false, false, false, false, false,
    false, false, false, false, false, false, false },
 { false, false, false, false, false, false, false,
   false, false, false, false, false, false, false } }
if Application accesses the buffer -> set LOCK -> if IRQ a READ operation of the App on a receive buffer _must_ be retried as long as one process is not interrupted.

On a send buffer, the sending IRQ can regard the buffer as empty, if the lock is set, and the current reported size is < 2 - avoid reading of a not aet complete written message

Definition at line 213 of file hal_can_interface.cc.

Referenced by interrupt().

bool b_runningIrqSendProcess[CAN_BUS_CNT] = { false, false } [static]
 

report if active running IRQ controlled send process is active

Definition at line 103 of file hal_can_interface.cc.

Referenced by interrupt().

__IsoAgLib::Ident_c c_cinterfIdent
 

Definition at line 115 of file hal_can_interface.cc.

unsigned char CAN1TxReady
 

some prototypes from Mitron CAN example

Definition at line 91 of file hal_can_interface.cc.

Referenced by interrupt().

unsigned char CAN2TxReady
 

Definition at line 92 of file hal_can_interface.cc.

Referenced by interrupt().

uint8_t gb_cinterfBusLoadSlice[CAN_BUS_CNT] [static]
 

actual index in gwBusLoad

Definition at line 111 of file hal_can_interface.cc.

uint16_t gwCinterfBusLoad[CAN_BUS_CNT][10] [static]
 

array of 100msec.

timeslice conters of received and sent msg per BUS [uint8_t]

Definition at line 109 of file hal_can_interface.cc.

int32_t i32_cinterfBeginBit1err[CAN_BUS_CNT] [static]
 

Definition at line 100 of file hal_can_interface.cc.

int32_t i32_cinterfBeginBusWarnOff[CAN_BUS_CNT] [static]
 

Definition at line 99 of file hal_can_interface.cc.

Referenced by interrupt().

int32_t i32_cinterfLastSuccReceive[CAN_BUS_CNT] [static]
 

Definition at line 106 of file hal_can_interface.cc.

Referenced by interrupt().

int32_t i32_cinterfLastSuccSend[CAN_BUS_CNT] [static]
 

Definition at line 105 of file hal_can_interface.cc.

Referenced by interrupt().

canBufferElement_t* pt_canBufferBegin[2][14] [static]
 

Initial value:

{ { arr_canBuffer[0][0], arr_canBuffer[0][1], arr_canBuffer[0][2], arr_canBuffer[0][3],
    arr_canBuffer[0][4], arr_canBuffer[0][5], arr_canBuffer[0][6], arr_canBuffer[0][7],
    arr_canBuffer[0][8], arr_canBuffer[0][9], arr_canBuffer[0][10], arr_canBuffer[0][11],
    arr_canBuffer[0][12], arr_canBuffer[0][13] },
  { arr_canBuffer[1][0], arr_canBuffer[1][1], arr_canBuffer[1][2], arr_canBuffer[1][3],
    arr_canBuffer[1][4], arr_canBuffer[1][5], arr_canBuffer[1][6], arr_canBuffer[1][7],
    arr_canBuffer[1][8], arr_canBuffer[1][9], arr_canBuffer[1][10], arr_canBuffer[1][11],
    arr_canBuffer[1][12], arr_canBuffer[1][13] } }
write position in ringbuffer

Definition at line 187 of file hal_can_interface.cc.

Referenced by readDataFromCanRingBuffer(), resetCanRingBuffer(), and writeDataToCanRingBuffer().

canBufferElement_t* pt_canBufferEnd[2][14] [static]
 

Initial value:

{ { arr_canBuffer[0][0], arr_canBuffer[0][1], arr_canBuffer[0][2], arr_canBuffer[0][3],
    arr_canBuffer[0][4], arr_canBuffer[0][5], arr_canBuffer[0][6], arr_canBuffer[0][7],
    arr_canBuffer[0][8], arr_canBuffer[0][9], arr_canBuffer[0][10], arr_canBuffer[0][11],
    arr_canBuffer[0][12], arr_canBuffer[0][13] },
  { arr_canBuffer[1][0], arr_canBuffer[1][1], arr_canBuffer[1][2], arr_canBuffer[1][3],
    arr_canBuffer[1][4], arr_canBuffer[1][5], arr_canBuffer[1][6], arr_canBuffer[1][7],
    arr_canBuffer[1][8], arr_canBuffer[1][9], arr_canBuffer[1][10], arr_canBuffer[1][11],
    arr_canBuffer[1][12], arr_canBuffer[1][13] } }
write position in ringbuffer

Definition at line 198 of file hal_can_interface.cc.

Referenced by readDataFromCanRingBuffer(), resetCanRingBuffer(), and writeDataToCanRingBuffer().

canBufferElement_t* pt_canBufferRead[2][14] [static]
 

Initial value:

{ { arr_canBuffer[0][0], arr_canBuffer[0][1], arr_canBuffer[0][2], arr_canBuffer[0][3],
    arr_canBuffer[0][4], arr_canBuffer[0][5], arr_canBuffer[0][6], arr_canBuffer[0][7],
    arr_canBuffer[0][8], arr_canBuffer[0][9], arr_canBuffer[0][10], arr_canBuffer[0][11],
    arr_canBuffer[0][12], arr_canBuffer[0][13] },
  { arr_canBuffer[1][0], arr_canBuffer[1][1], arr_canBuffer[1][2], arr_canBuffer[1][3],
    arr_canBuffer[1][4], arr_canBuffer[1][5], arr_canBuffer[1][6], arr_canBuffer[1][7],
    arr_canBuffer[1][8], arr_canBuffer[1][9], arr_canBuffer[1][10], arr_canBuffer[1][11],
    arr_canBuffer[1][12], arr_canBuffer[1][13] } }
read position in ringbuffer

Definition at line 165 of file hal_can_interface.cc.

Referenced by readDataFromCanRingBuffer(), resetCanRingBuffer(), and writeDataToCanRingBuffer().

canBufferElement_t* pt_canBufferWrite[2][14] [static]
 

Initial value:

{ { arr_canBuffer[0][0], arr_canBuffer[0][1], arr_canBuffer[0][2], arr_canBuffer[0][3],
    arr_canBuffer[0][4], arr_canBuffer[0][5], arr_canBuffer[0][6], arr_canBuffer[0][7],
    arr_canBuffer[0][8], arr_canBuffer[0][9], arr_canBuffer[0][10], arr_canBuffer[0][11],
    arr_canBuffer[0][12], arr_canBuffer[0][13] },
  { arr_canBuffer[1][0], arr_canBuffer[1][1], arr_canBuffer[1][2], arr_canBuffer[1][3],
    arr_canBuffer[1][4], arr_canBuffer[1][5], arr_canBuffer[1][6], arr_canBuffer[1][7],
    arr_canBuffer[1][8], arr_canBuffer[1][9], arr_canBuffer[1][10], arr_canBuffer[1][11],
    arr_canBuffer[1][12], arr_canBuffer[1][13] } }
write position in ringbuffer

Definition at line 176 of file hal_can_interface.cc.

Referenced by resetCanRingBuffer(), and writeDataToCanRingBuffer().

CAN_buf_Seed_def ss_tempSendObj [static]
 

define one static CAN HW structure obj for direct send

Definition at line 130 of file hal_can_interface.cc.

uint32_t sui32_irqCnt = 0 [static]
 

Definition at line 125 of file hal_can_interface.cc.

Referenced by interrupt().

uint32_t sui32_lastIdent [static]
 

Definition at line 113 of file hal_can_interface.cc.

Referenced by interrupt().

uint32_t sui32_rxIrqCnt = 0 [static]
 

Definition at line 127 of file hal_can_interface.cc.

Referenced by interrupt().

uint32_t sui32_txIrqCnt = 0 [static]
 

Definition at line 126 of file hal_can_interface.cc.

Referenced by interrupt().

uint16_t ui16_canBufferMaxSize[2][14] [static]
 

Initial value:

{ { 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0 } }
allocated size of buffer per MsgObj

Definition at line 152 of file hal_can_interface.cc.

Referenced by getCanRingBufferMaxSize(), isCanRingBufferFull(), and resetCanRingBuffer().

uint16_t ui16_canBufferSize[2][14] [static]
 

Initial value:

{ { 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0 } }
amount of currently stored elements

Definition at line 158 of file hal_can_interface.cc.

Referenced by getCanRingBufferSize(), isCanRingBufferEmpty(), isCanRingBufferFull(), readDataFromCanRingBuffer(), resetCanRingBuffer(), and writeDataToCanRingBuffer().

uint16_t ui16_lastCanBusState[CAN_BUS_CNT] [static]
 

Definition at line 98 of file hal_can_interface.cc.

Referenced by interrupt().

uint8_t ui8_canBufferDirectionState[2][14] [static]
 

Initial value:

 { { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF },
   { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF } }
direction and open/close state per MSgObj: 0==RX, 1==TX, 0xFF==closed

Definition at line 145 of file hal_can_interface.cc.

Referenced by interrupt().

uint8_t ui8_canBufferXtd[2][14] [static]
 

Initial value:

{ { 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0 } }
standardID or extended ID

Definition at line 138 of file hal_can_interface.cc.

uint8_t ui8_currentBaudrate[2] = { 0, 0 } [static]
 

store last used Baudrate

Definition at line 220 of file hal_can_interface.cc.


Generated on Wed Oct 13 15:09:31 2004 for IsoAgLib by  doxygen 1.3.8-20040913