#ifndef __FICOSEKCOM_H #define __FICOSEKCOM_H /*-------------------------------- Includes ------------------------------*/ #include "Std_Types.h" #include "DiagnosticL/Comp_HAL_Autosar_Wrappers/FicosarCAN.h" #include "OsekCom/OsekCom.h" /*-------------------------------- Defines -------------------------------*/ /*----------------------------- Data Types -------------------------------*/ typedef UI_8 t_sig_diagnosticreqprndl[8]; typedef UI_8 t_sig_diagnosticfuncaddrreq[8]; #ifndef _FICOSEKCOM_H #define _FICOSEKCOM_H /* Type definition of the symbolic names for signals */ typedef UI_16 t_symbolic_name; typedef UI_16 t_symbolic_frm_name; /* Return type of the calls OSEK COM */ typedef UI_8 t_status_type; /* Structure of data type passed by reference in */ /* the calls of OSEK COM */ typedef void *t_application_data_ref; typedef void *t_length_ref; /* Flag types of OSEK COM */ //typedef enum { //COM_FALSE = 0x00, /* Flag down */ // COM_TRUE = 0x01 /* Flag up */ //} t_flag_value; /* Stop mode of OSEK COM */ //typedef enum { // COM_SHUTDOWN_IMMEDIATE = 0 /* Apagat immediat */ //} t_com_shutdown_mode_type; /* Initialize mode of OSEK COM */ //typedef enum { // COM_NORMAL_MODE = 0 /* No es processen trames de COM de Debug */ //} t_com_application_mode_type; #endif /*--------------------------- Global Variables ---------------------------*/ /*----------- Prototypes of Callback Function Provided by User ----------*/ /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Notification Callbacks provided by user for class 1 (RxNotif), 3 (RxErrorNotif) | 2 (TxNotif) and 4 (TxErrorNotif) | --------------------------------------------------------------------------- | Parameters description: / ------------------------------------------------- -------------------------- */ #define COMCallback(CallbackRoutineName) void CallbackRoutineName(void) //COMCallback(VCU_RX_Timeout_Callback); //COMCallback(CGW_BCM_Status1_Timeout_Callback); COMCallback(SHIFT_Tx_Callback); COMCallback(SHIFT_Tx_Error_Callback); /* --------------------------- Routine Prototypes --------------------------- */ /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Reception of a new frame notification callback | * This callback must be launched by the lower COM driver upon the reception | of a new frame. |--------------------------------------------------------------------------- | Parameters description: | bhdl: Handler of the buffer where the received frame is stored. /---------------------------------------------------------------------------*/ void OsekComRxNotifCallbackPRNDL(t_com_buf_hdl bhdl); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Available transmission buffer notification callback | * This callback must be launched by the lower COM driver upon a transmission | buffer will become available after requesting one to perform a transmission. |--------------------------------------------------------------------------- | Parameters description: | return: TRUE in case that after current transmission lower COM driver should | call again this callback to transmit a new frame. | FALSE otherwise. /---------------------------------------------------------------------------*/ BOOL OsekComTxReqCallbackPRNDL(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Frame transmission confirmation notifying callback | * This callback must be launched by the lower COM driver upon the completion | of a frame transmission for which transmission confirmation has been requested |--------------------------------------------------------------------------- | Parameters description: | bhdl: Handler of the buffer where the transmitted frame is stored. /---------------------------------------------------------------------------*/ void OsekComTxNotifCallbackPRNDL(t_com_buf_hdl bhdl); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Service to initialize OsekCom stack | | ------------------------------------------------- -------------------------- | Parameters description: | app_mode: OsekCom initialization mode (See t_com_application_mode_type) | return: E_OK in case of no errors | Other (see t_status_type). /---------------------------------------------------------------------------*/ //t_status_type StartCom(t_com_application_mode_type app_mode); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Service to inquiry in which mode OsekCom has been initialized. | * If this service is called before initializing the communications stack | a random mode will be returned. | --------------------------------------------------------------------------- | Parameters description: | return: OsekCom initialization mode(See t_com_application_mode_type) / --------------------------------------------------------------------------- */ //t_com_application_mode_type GetComApplicationMode(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Service to close the OsekCom stack. | * This service stops the transmission of periodic frames. | * After calling this service communications could be re-established | calling again service StartCom. | * This service does not change the state of any lower COM driver. | --------------------------------------------------------------------------- | Parameters description: | shtdwn_mode: OsekCom stop mode (See t_com_shutdown_mode_type) | return: E_OK in case of no errors | Other (see t_status_type). / --------------------------------------------------------------------------- */ //t_status_type StopCom(t_com_shutdown_mode_type shtdwn_mode); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Service to start the transmission of periodic or mixed frames. | * If this service is re-executed then transmission timers will be re-started. |--------------------------------------------------------------------------- | Parameters description: | return: E_OK in case of no errors | Other (see t_status_type). /---------------------------------------------------------------------------*/ t_status_type StartPeriodic(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Service to stop the transmission of periodic or mixed frames. | * To re-start the transmission of periodic or mixed frames service | StartPeriodic must be called. |--------------------------------------------------------------------------- | Parameters description: | return: E_OK in case of no errors | Other (see t_status_type). /---------------------------------------------------------------------------*/ t_status_type StopPeriodic(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * This service updates the application variable referenced by >data_ref< with | the data stored in the internal stack for the object identified by >message<. | * This service will reset the class 1 (RxNotif) and 3 (RxErrorNotif) flags | associated to >message< | * If >message< is an enqueued signal the service will return the data | stored in the internal stack (initial value / last received value / last value | set with InitMessage) | If >message< is a queued signal the service will return the first value | available in the queue or error if the queue is empty. (Mode not supported) | * The user is responsible of granting that the parameter >data_ref< | points to a variable correctly allocated and compatible in size with the | received signal type | * Usage example: | t_vehicle_speed vehicle_speed; | (void)ReceiveMessage(SIG_VEHICLE_SPEED,&vehicle_speed); |--------------------------------------------------------------------------- | Parameters description: | message: Identification of the signal to be retrieved. | data_ref: Pointer to a variable where to store the requested signal. | return: | E_OK in case of no errors | E_COM_ID in case the parameter >message< is out of range or if it refers | to signal that is sent, dynamic length or zero-length | E_COM_NOMSG in case the queued signal identified by >message< is empty. | E_COM_LIMIT in case an overflow of the queue of the signal identified by >message< | occurred since the last call to ReceiveMessage for >message<. | E_COM_LIMIT indicates that at least one message has been discarded | since the message queue filled. Nevertheless the service is | performed and a message is returned. The service ReceiveMessage | clears the overflow condition for >message<. | other (see t_status_type). /---------------------------------------------------------------------------*/ t_status_type ReceiveMessage(t_symbolic_name message, t_application_data_ref data_ref); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * This service updates the application variable referenced by >data_ref< with | the data stored in the internal stack for the object identified by >message<. | * The length of the received signal data will be placed in the variable | referenced by >length_ref<. | * This service will reset the class 1 (RxNotif) and 3 (RxErrorNotif) flags | associated to >message< | * This service could be used with enqueued messages only. This service is | provided for external communication only. | * The service will return the data stored in the internal stack | (initial value / last received value / last value set with InitMessage) | * The user is responsible of granting that the parameters >data_ref< | and >lenght_ref< point to variables correctly allocated and compatible in | size with the received signal type | * Usage example: | t_vehicle_speed vehicle_speed; | t_length_ref length_ref; | (void)ReceiveDynamicMessage(SIG_VEHICLE_SPEED,&vehicle_speed,&length_ref); |--------------------------------------------------------------------------- | Parameters description: | message: Identification of the signal to be retrieved. | data_ref: Pointer to a variable where to store the requested signal. | lenght_ref: Pointer to a variable where to store the retrieved signal size. | return: | E_OK in case of no errors | E_COM_ID in case the parameter >message< is out of range or if it refers | to a message that is sent, a queued message, a static-length | message or a zero-length message. | other (see t_status_type). /---------------------------------------------------------------------------*/ t_status_type ReceiveDynamicMessage(t_symbolic_name message, t_application_data_ref data_ref, t_length_ref length_ref); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * This service updates OsekCom internal data structure of the signal | identified by >message< with the data referenced by the variable | referenced by >data_ref< parameter. | * This service will reset the class 2 (TxNotif) and 4 (TxErrorNotif) flags | associated to >message< | * If >message< has the Triggered Transfer Property, the update will be | followed by immediate transmission of the I-PDU associated with the signal except | when the signal is packed into an I-PDU with Periodic Transmission Mode. | In this case, no transmission is initiated by the call to this service. | * If >message< has the Pending Transfer Property, no transmission is | triggered by the usage of this service. | * The user is responsible of granting that the parameter >data_ref< | points to a variable correctly allocated and compatible in size with the | transmitted signal type. | * Usage example: | t_vehicle_speed vehicle_speed = 20; | (void)SendMessage(SIG_VEHICLE_SPEED,&vehicle_speed); |--------------------------------------------------------------------------- | Parameters description: | message: Identification of the signal to be transmitted. | data_ref: Pointer to a variable containing the data to be transmitted. | return: | E_OK in case of no errors | E_COM_ID is case the parameter >message< is out of range or if it refers | to a message that is received or to a dynamic-length or | zero-length message. | other (see t_status_type). /---------------------------------------------------------------------------*/ #define OSEK_SENDMESSAGE t_status_type SendMessage(t_symbolic_name message, t_application_data_ref data_ref); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * This service updates OsekCom internal data structure of the signal | identified by >message< with the data referenced by variables | referenced by >data_ref< and >lenght_ref< | * This service will reset the class 2 (TxNotif) and 4 (TxErrorNotif) flags | associated to >message< | * If >message< has the Triggered Transfer Property, the update is followed | by immediate transmission of the I-PDU associated with the signal except | when the signal is packed into an I-PDU with Periodic Transmission Mode. | In this case, no transmission is initiated by the call to this service. | * If >message< has the Pending Transfer Property, no transmission is | caused by the usage of this service. | * This service can be used with enqueued messages only. This service is | provided for external communication only. | * The user is responsible of granting that the parameters >data_ref< | and >lenght_ref< points to variables correctly allocated and | compatible in size with the transmitted signal type. | * Usage example: | t_vehicle_speed vehicle_speed = 20; | t_length_ref length_ref = 1; | (void)SendDynamicMessage(SIG_VEHICLE_SPEED, &vehicle_speed, &length_ref); |--------------------------------------------------------------------------- | Parameters description: | message: Identification of the signal to be transmitted. | data_ref: Pointer to a variable containing the data to be transmitted. | lenght_ref: Pointer to a variable containing the size of the signal | to be transmitted. | return: | E_OK in case of no errors | E_COM_ID in case the parameter >message< is out of range or if it refers | to a received signal, a static-length signal or a zero-length signal. | E_COM_LENGTH in case the value to which >length_ref< points is not within | the range 0 to the maximum length defined for >message<. | other (see t_status_type). /---------------------------------------------------------------------------*/ #define OSEK_SENDDYNAMICMESSAGE t_status_type SendDynamicMessage(t_symbolic_name message, t_application_data_ref data_ref, t_length_ref length_ref); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * This service updates OsekCom internal data structure of the signal | identified by >message< with the data referenced by the variable | referenced by >data_ref< | * This service will not reset any class flags associated to >message< | * This service will not initiate any transmission. | * The user is responsible of granting that the parameter 'data_ref' | points to an address correctly allocated and compatible in size with the | transmitted signal type. |--------------------------------------------------------------------------- | Parameters description: | message: Identification of the signal. | data_ref: Pointer to a variable containing the data. | return: | E_OK in case of no errors | E_COM_ID if the message or signal to initialize don't exist | Other (see t_status_type). /---------------------------------------------------------------------------*/ t_status_type InitMessage(t_symbolic_name message, t_application_data_ref data_ref); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Consult service for the flag of COM traffic. |--------------------------------------------------------------------------- | Parameters description: | return: | COM_FALSE if has not been detected any communication activity since | last clear | COM_TRUE if has been detected communication activity since last clear /---------------------------------------------------------------------------*/ t_flag_value ReadFlagComTrafficPRNDL(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Reset service for the flag of COM traffic. |--------------------------------------------------------------------------- | Parameters description: /---------------------------------------------------------------------------*/ void ResetFlagComTrafficPRNDL(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Consult service to retrieve the state of class 1 (RxNotif), | class 3 (Rx_ErrorNotif), class 2 (TxNotif) and class 4 (Tx_ErrorNotif) flags |--------------------------------------------------------------------------- | Parameters description: | message: Identification of the signal. | return: | COM_FALSE if the flag is down | COM_TRUE if the flag is up /---------------------------------------------------------------------------*/ t_flag_value ReadFlagRxSig(t_symbolic_name message); t_flag_value ReadFlagTxSig(t_symbolic_name message); t_flag_value ReadFlagTxSigDiagnosticRespPRNDL(void); t_flag_value ReadFlagTxErrorSig(t_symbolic_name message); t_flag_value ReadFlagTxErrorSigDiagnosticRespPRNDL(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Consult service to enable tx message flag |--------------------------------------------------------------------------- | Parameters description: /---------------------------------------------------------------------------*/ void EnableTxFrm_diag_physresp_prndl(void); void DisableTxFrm_diag_physresp_prndl(void); void EnableTxFrm_shiftselectposition(void); void DisableTxFrm_shiftselectposition(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Reset service for the notify class 1 (RxNotif) class 3 (RxErrorNotif) | class 2 (TxNotif) and class 4 (TxErrorNotif) |--------------------------------------------------------------------------- | Parameters description: | message: Identification of the signal. /---------------------------------------------------------------------------*/ void ResetFlagRxSig(t_symbolic_name message); //void ResetFlagRxSigDiagnosticReqSWTL(void); void ResetFlagRxSigDiagnosticFuncAddrReq(void); void ResetFlagTxSig(t_symbolic_name message); void ResetFlagTxErrorSig(t_symbolic_name message); void ResetFlagTxErrorSigDiagnosticRespSWTL(void); /*--------------------------------------------------------------------------- | Portability: Target platform independent |---------------------------------------------------------------------------- | Routine description: | * Main runnable of the OsekCom stack intended to be called periodically by | the system scheduler with a period equal to FICOSEK_COM_TASK_TICKS |--------------------------------------------------------------------------- | Parameters description: /---------------------------------------------------------------------------*/ void OsekComTask(void); #endif