functions.h
Go to the documentation of this file.
00001 /***********************************************************************/
00010  #ifndef FUNCTIONS_H_
00011  #define FUNCTIONS_H_
00012  
00013  #include <stdlib.h>
00014  #include "uCmaskFile.h"
00015  #include "MCP2515control.h"
00016  #include "config.h"
00017  
00018  
00019  /* Needed pre-processor directives =============================== */
00020 
00021  #define        MCP_ACTIVATE            ( HW_CS_MCP2515_PORT &= ~( 1<<HW_CS_MCP2515 ) ) 
00022  #define        MCP_DEACTIVATE          ( HW_CS_MCP2515_PORT |= ( 1<<HW_CS_MCP2515 ) )
00023  #define        MASK_ARBITRATOR         0x00
00024  #define        MASK_DEVICE                     0xFF
00025  #define        DUMMY_DATA                      0x00
00026  
00027 
00028  /* Structure for error handling ================================== */
00029  struct errorStr{
00030         uint8_t recBufOvf0;
00031         uint8_t recBufOvf1;
00032         uint8_t busOffError;
00033         uint8_t transmitPassive; 
00034         uint8_t receivePassive;
00035         uint8_t transmitWarning; 
00036         uint8_t receiveWarning;
00037         uint8_t errorWarning;
00038  };
00039  
00040  struct errorStr errorStructure;
00041  
00042  /* Static variables ================================== */
00043  static volatile uint8_t readBuffer;    
00044  static volatile uint8_t dataToSend;
00045  
00046  /* Enumerated types ================================== */
00047  /* Enum: SPI - SPI_INIT_STATUS */
00050  typedef enum {
00051         SPI_INIT_OK = 0,        
00052         SPI_INIT_FAILED
00053  } SPI_INIT_STATUS;
00054  
00055  /* Enum: SPI - SPI_TRANS_STATUS */
00058  typedef enum {
00059         SPI_TRANS_OK = 0,       
00060         SPI_TRANS_FAILED
00061  } SPI_TRANS_STATUS;
00062  
00063  
00064  /* Enum: CAN_INIT_STATUS */
00067  typedef enum {
00068         CAN_INIT_OK = 0,        
00069         CAN_INIT_FAILED
00070  } CAN_INIT_STATUS;
00071  
00072  
00073 
00074 
00075  
00076  /* Function declarations ================================== */
00077   
00078  /* CAN handling  */
00079  SPI_INIT_STATUS initSpi ( void );
00080  uint8_t transmitSpi ( uint8_t data );
00081  CAN_INIT_STATUS initCan ( uint8_t id );
00082  void hal_set_filter( uint8_t id );
00083  void hal_set_mask( uint8_t id );
00084  
00085  /* EEPROM functions */
00086  void initEEPROM ( void );
00087  uint8_t readEEPROM ( uint8_t address );
00088  void writeEEPROM ( uint8_t address, uint8_t data );
00089  
00090  /* Init interrupts/ports functions */
00091  void initInterrupts ( void );
00092  void initIOPort ( void );
00093  void initIOPort_appDesigner ( void );
00094  void initInterrupts_appDesigner ( void );
00095  void initSPIPorts ( void );
00096  void initINTPorts ( void );
00097  void initUSART ( uint16_t baud );
00098   
00099  /* Error handling functions */ 
00100  void checkTransmissionErrors ( struct errorStr* readErrStr );
00101  void clearTransmissionErrors ( void );
00102  
00103  /* Others */ 
00104  uint8_t mcp2515TransmitData ( uint8_t mode, uint8_t reg, uint8_t val, uint8_t setClearFlag );
00105  void triggerSoftwareInterrupt ( uint8_t port);
00106  void initLowLevelProtocolHardware ( void );
00107  void initUSART ( uint16_t baud );
00108  void printCharUsart ( char sign );
00109  void printUsart ( char* str );
00110  void hal_msg_take ( void );
00111  void wdtEnable ( uint8_t time );
00112  void wdtDisable ( void );
00113  void forceReset ( void );
00114  
00115  #endif
 All Classes Files Functions Enumerations Enumerator Defines