====== Annexe 3 ====== ===== Fichier de définition propre à la carte ATON ===== // ************************************************************* // Fichier de définition pour carte controleur CAN "ATON_CAN" // Nom de fichier: Aton_CAN.h //************************************************************** #ifndef _PELICAN_H #define _PELICAN_H #define SJA 0xB30280 /* Adresse de la carte SJA */ #define MODE *(unsigned char *) (SJA) /* Registre de controle */ #define COMMAND *(unsigned char *) (SJA+0x01) /* Registre de commande */ #define STATUS *(unsigned char *) (SJA+0x02) /* Registre status */ #define INTERRUPT *(unsigned char *) (SJA+0x03) /* Registre d'interruption */ #define INTERRUPT_ENABLE *(unsigned char *) (SJA+0x04) #define BUS_TIMING_0 *(unsigned char *) (SJA+0x06) /* Registre bus timing 0 */ #define BUS_TIMING_1 *(unsigned char *) (SJA+0x07) /* Registre bus timing 1 */ #define OUTPUT_CONTROL *(unsigned char *) (SJA+0x08) /* Registre output control */ #define ARBITRATION_LOST_CAPTURE *(unsigned char *) (SJA+0x0B) #define ERROR_CODE_CAPTURE *(unsigned char *) (SJA+0x0C) #define ERROR_WARNING_LIMIT *(unsigned char *) (SJA+0x0D) #define RX_ERROR_COUNTER *(unsigned char *) (SJA+0x0E) #define TX_ERROR_COUNTER *(unsigned char *) (SJA+0x0F) #define RX_FRAME_INFO *(unsigned char *) (SJA+0x10) #define TX_FRAME_INFO *(unsigned char *) (SJA+0x10) /* Mode SIMPLE FRAME */ #define RX_ID_1_S *(unsigned char *) (SJA+0x11) #define RX_ID_2_S *(unsigned char *) (SJA+0x12) #define RX_DATA_S (unsigned char *) (SJA+0x13) /* Adresse debut message */ #define TX_ID_1_S *(unsigned char *) (SJA+0x11) #define TX_ID_2_S *(unsigned char *) (SJA+0x12) #define TX_DATA_S (unsigned char *) (SJA+0x13) /* Adresse debut message */ /* Mode EXTENDED */ #define RX_ID_1_E *(unsigned char *) (SJA+0x11) #define RX_ID_2_E *(unsigned char *) (SJA+0x12) #define RX_ID_3_E *(unsigned char *) (SJA+0x13) #define RX_ID_4_E *(unsigned char *) (SJA+0x14) #define RX_DATA_E (unsigned char *) (SJA+0x15) /* Adresse debut message */ #define TX_ID_1_E *(unsigned char *) (SJA+0x11) #define TX_ID_2_E *(unsigned char *) (SJA+0x12) #define TX_ID_3_E *(unsigned char *) (SJA+0x13) #define TX_ID_4_E *(unsigned char *) (SJA+0x14) #define TX_DATA_E (unsigned char *) (SJA+0x15) /* Adresse debut message */ /* Les 2 modes */ #define RX_MESSAGE_COUNTER *(unsigned char *) (SJA+0x1D) #define RX_BUFFER_START_ADDRESS *(unsigned char *) (SJA+0x1E) #define CLOCK_DIVIDER *(unsigned char *) (SJA+0x1F) /* acceptance code et mask en mode reset uniquement */ #define ACCEPT_CODE0 *(unsigned char *) (SJA+0x10) #define ACCEPT_CODE1 *(unsigned char *) (SJA+0x11) #define ACCEPT_CODE2 *(unsigned char *) (SJA+0x12) #define ACCEPT_CODE3 *(unsigned char *) (SJA+0x13) #define ACCEPT_MASK0 *(unsigned char *) (SJA+0x14) #define ACCEPT_MASK1 *(unsigned char *) (SJA+0x15) #define ACCEPT_MASK2 *(unsigned char *) (SJA+0x16) #define ACCEPT_MASK3 *(unsigned char *) (SJA+0x17) /*** Configurations des bits des registres ***/ /* Registre STATUS */ #define BUS_STATUS 0x80 #define ERROR_STATUS 0x40 #define TRANSMIT_STATUS 0x20 #define RECEIVE_STATUS 0x10 #define TRANSMISSION_COMPLETE 0x08 #define TRANSMIT_BUFFER_STATUS 0x04 #define DATA_OVERRUN_STATUS 0x02 #define RECEIVE_BUFFER_STATUS 0x01 // *************** TYPES ******************** // *************************************************************** // * DECLARATIONS // * des prototypes des fonctions spécifiques CAN - SJA1000 // ***************************************************************** /** Initialisation du SJA1000 en mode PeliCAN. */ void init_sja1000_peli_acc (char acc_code0, char acc_code1, char acc_code2, char acc_code3, char acc_mask0, char acc_mask1, char acc_mask2, char acc_mask3); /** Initialisation du SJA1000 en mode PeliCAN. */ void init_sja1000_peli (); Trame Receive_Trame(); /** Envoi d'une trame */ void send_trame_peli (Message mes); /** Reception d'un message. */ Message receive_trame_peli (); /** Affichage des regsitres en PeliCAN */ void print_reg_peli (); /* Affiche l'etat du STATUS REGISTER */ void show_status (); /* Affiche le message passe en parametres sur une ligne */ void print_little (Message mes); // initialisation de la carte CAN ATON void Init_Aton_CAN(); char Ecrire_Trame(Trame message); char Lire_Trame(Trame *message_recu); void Affiche_Trame(Trame trame);