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